[apps/stats] Color the box of the selected box view

This commit is contained in:
Léa Saviot
2018-05-28 17:07:00 +02:00
parent b99cd21660
commit c9407d6bdb
5 changed files with 18 additions and 8 deletions

View File

@@ -7,14 +7,15 @@ using namespace Shared;
namespace Statistics {
BoxView::BoxView(BoxController * controller, Store * store, int series, Shared::BannerView * bannerView, Quantile * selectedQuantile, KDColor color) :
BoxView::BoxView(BoxController * controller, Store * store, int series, Shared::BannerView * bannerView, Quantile * selectedQuantile, KDColor color, KDColor lightColor) :
CurveView(&m_boxRange, nullptr, bannerView, nullptr),
m_store(store),
m_boxController(controller),
m_boxRange(BoxRange(store)),
m_series(series),
m_selectedQuantile(selectedQuantile),
m_selectedHistogramColor(color)
m_selectedHistogramColor(color),
m_selectedHistogramLightColor(lightColor)
{
}
@@ -64,14 +65,16 @@ void BoxView::drawRect(KDContext * ctx, KDRect rect) const {
double thirdQuart = m_store->thirdQuartile(m_series);
double maxVal = m_store->maxValue(m_series);
bool isSelected = m_boxController->selectedSeries() == m_series;
KDColor boxColor = isSelected ? m_selectedHistogramLightColor : Palette::GreyWhite;
// Draw the main box
KDCoordinate firstQuartilePixels = std::round(floatToPixel(Axis::Horizontal, firstQuart));
KDCoordinate thirdQuartilePixels = std::round(floatToPixel(Axis::Horizontal, thirdQuart));
ctx->fillRect(KDRect(firstQuartilePixels, lowBoundPixel, thirdQuartilePixels - firstQuartilePixels+2,
upBoundPixel-lowBoundPixel), Palette::GreyWhite);
upBoundPixel-lowBoundPixel), boxColor);
// Draw the horizontal lines linking the box to the extreme bounds
KDColor horizontalColor = m_boxController->selectedSeries() == m_series ? m_selectedHistogramColor : Palette::GreyDark;
KDColor horizontalColor = isSelected ? m_selectedHistogramColor : Palette::GreyDark;
float segmentOrd = (lowBound + upBound)/ 2.0f;
drawSegment(ctx, rect, Axis::Horizontal, segmentOrd, minVal, firstQuart, horizontalColor);
drawSegment(ctx, rect, Axis::Horizontal, segmentOrd, thirdQuart, maxVal, horizontalColor);

View File

@@ -21,7 +21,7 @@ public:
ThirdQuartile = 3,
Max = 4
};
BoxView(BoxController * controller, Store * store, int series, Shared::BannerView * bannerView, Quantile * selectedQuantile, KDColor color);
BoxView(BoxController * controller, Store * store, int series, Shared::BannerView * bannerView, Quantile * selectedQuantile, KDColor color, KDColor lightColor);
Quantile selectedQuantile() const { return *m_selectedQuantile; }
bool selectQuantile(int selectedQuantile);
int series() const { return m_series; }
@@ -42,6 +42,7 @@ private:
int m_series;
Quantile * m_selectedQuantile;
KDColor m_selectedHistogramColor;
KDColor m_selectedHistogramLightColor;
};
}

View File

@@ -7,9 +7,9 @@ namespace Statistics {
MultipleBoxesView::MultipleBoxesView(BoxController * controller, Store * store, BoxView::Quantile * selectedQuantile) :
MultipleDataView(store),
m_boxView1(controller, store, 0, nullptr, selectedQuantile, Palette::Red),
m_boxView2(controller, store, 1, nullptr, selectedQuantile, Palette::Blue),
m_boxView3(controller, store, 2, nullptr, selectedQuantile, Palette::Green),
m_boxView1(controller, store, 0, nullptr, selectedQuantile, Palette::Red, Palette::RedLight),
m_boxView2(controller, store, 1, nullptr, selectedQuantile, Palette::Blue, Palette::BlueLight),
m_boxView3(controller, store, 2, nullptr, selectedQuantile, Palette::Green, Palette::GreenLight),
// TODO Share colors with stats/store_controller
m_axisView(store),
m_bannerView()

View File

@@ -21,12 +21,15 @@ public:
constexpr static KDColor SubTab = KDColor::RGB24(0xb8bbc5);
constexpr static KDColor LowBattery = KDColor::RGB24(0xf30211);
constexpr static KDColor Red = KDColor::RGB24(0xff000c);
constexpr static KDColor RedLight = KDColor::RGB24(0xfe6363);
constexpr static KDColor Magenta = KDColor::RGB24(0xff0588);
constexpr static KDColor Turquoise = KDColor::RGB24(0x60c1ec);
constexpr static KDColor Pink = KDColor::RGB24(0xffabb6);
constexpr static KDColor Blue = KDColor::RGB24(0x5075f2);
constexpr static KDColor BlueLight = KDColor::RGB24(0x718fee);
constexpr static KDColor Orange = KDColor::RGB24(0xfe871f);
constexpr static KDColor Green = KDColor::RGB24(0x76d435);
constexpr static KDColor GreenLight = KDColor::RGB24(0x52db8f);
};
#endif

View File

@@ -16,9 +16,12 @@ constexpr KDColor Palette::WallScreenDark;
constexpr KDColor Palette::SubTab;
constexpr KDColor Palette::LowBattery;
constexpr KDColor Palette::Red;
constexpr KDColor Palette::RedLight;
constexpr KDColor Palette::Magenta;
constexpr KDColor Palette::Turquoise;
constexpr KDColor Palette::Pink;
constexpr KDColor Palette::Blue;
constexpr KDColor Palette::BlueLight;
constexpr KDColor Palette::Orange;
constexpr KDColor Palette::Green;
constexpr KDColor Palette::GreenLight;