From c9407d6bdbf28092984cad42c053caad5b3665ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Mon, 28 May 2018 17:07:00 +0200 Subject: [PATCH] [apps/stats] Color the box of the selected box view --- apps/statistics/box_view.cpp | 11 +++++++---- apps/statistics/box_view.h | 3 ++- apps/statistics/multiple_boxes_view.cpp | 6 +++--- escher/include/escher/palette.h | 3 +++ escher/src/palette.cpp | 3 +++ 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/apps/statistics/box_view.cpp b/apps/statistics/box_view.cpp index c048c935d..8fa05f271 100644 --- a/apps/statistics/box_view.cpp +++ b/apps/statistics/box_view.cpp @@ -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); diff --git a/apps/statistics/box_view.h b/apps/statistics/box_view.h index 9e8d42632..43ce455d6 100644 --- a/apps/statistics/box_view.h +++ b/apps/statistics/box_view.h @@ -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; }; } diff --git a/apps/statistics/multiple_boxes_view.cpp b/apps/statistics/multiple_boxes_view.cpp index 183a7a0f8..26a27cd89 100644 --- a/apps/statistics/multiple_boxes_view.cpp +++ b/apps/statistics/multiple_boxes_view.cpp @@ -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() diff --git a/escher/include/escher/palette.h b/escher/include/escher/palette.h index ad47ce19d..b380a245b 100644 --- a/escher/include/escher/palette.h +++ b/escher/include/escher/palette.h @@ -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 diff --git a/escher/src/palette.cpp b/escher/src/palette.cpp index 59da5fbb7..719638922 100644 --- a/escher/src/palette.cpp +++ b/escher/src/palette.cpp @@ -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;