diff --git a/apps/statistics/histogram_controller.cpp b/apps/statistics/histogram_controller.cpp index 5e76144fd..a91490116 100644 --- a/apps/statistics/histogram_controller.cpp +++ b/apps/statistics/histogram_controller.cpp @@ -11,9 +11,10 @@ using namespace Shared; namespace Statistics { HistogramController::ContentView::ContentView(HistogramController * controller, Store * store) : - m_histogramView1(controller, store, 0, &m_bannerView), - m_histogramView2(controller, store, 1, &m_bannerView), - m_histogramView3(controller, store, 2, &m_bannerView), + m_histogramView1(controller, store, 0, &m_bannerView, Palette::Red), + m_histogramView2(controller, store, 1, &m_bannerView, Palette::Blue), + m_histogramView3(controller, store, 2, &m_bannerView, Palette::Green), + // TODO Share colors with stats/store_controller m_bannerView(), m_store(store) { diff --git a/apps/statistics/histogram_view.cpp b/apps/statistics/histogram_view.cpp index 2f729f761..28103299f 100644 --- a/apps/statistics/histogram_view.cpp +++ b/apps/statistics/histogram_view.cpp @@ -7,25 +7,25 @@ using namespace Shared; namespace Statistics { -HistogramView::HistogramView(HistogramController * controller, Store * store, int series, Shared::BannerView * bannerView) : +HistogramView::HistogramView(HistogramController * controller, Store * store, int series, Shared::BannerView * bannerView, KDColor selectedHistogramColor, KDColor notSelectedHistogramColor, KDColor selectedBarColor) : CurveView(store, nullptr, bannerView, nullptr), m_controller(controller), m_store(store), m_labels{}, m_highlightedBarStart(NAN), m_highlightedBarEnd(NAN), - m_series(series) + m_series(series), + m_selectedHistogramColor(selectedHistogramColor), + m_notSelectedHistogramColor(notSelectedHistogramColor), + m_selectedBarColor(selectedBarColor) { } void HistogramView::reload() { CurveView::reload(); - float pixelLowerBound = floatToPixel(Axis::Horizontal, m_highlightedBarStart)-2; - float pixelUpperBound = floatToPixel(Axis::Horizontal, m_highlightedBarEnd)+2; /* We deliberately do not mark as dirty the frame of the banner view to avoid *unpleasant blinking of the drawing of the banner view. */ - KDRect dirtyZone(KDRect(pixelLowerBound, 0, pixelUpperBound-pixelLowerBound, - bounds().height() - (displayBannerView() ? m_bannerView->bounds().height() : 0))); + KDRect dirtyZone(KDRect(0, 0, bounds().width(), bounds().height() - (displayBannerView() ? m_bannerView->bounds().height() : 0))); markRectAsDirty(dirtyZone); } @@ -39,9 +39,9 @@ void HistogramView::drawRect(KDContext * ctx, KDRect rect) const { float totalSize = m_store->sumOfOccurrences(m_series); float context[] = {totalSize, static_cast(m_series)}; if (isMainViewSelected()) { - drawHistogram(ctx, rect, EvaluateHistogramAtAbscissa, m_store, context, m_store->firstDrawnBarAbscissa(), m_store->barWidth(), true, Palette::Select, Palette::YellowDark, m_highlightedBarStart, m_highlightedBarEnd); + drawHistogram(ctx, rect, EvaluateHistogramAtAbscissa, m_store, context, m_store->firstDrawnBarAbscissa(), m_store->barWidth(), true, m_selectedHistogramColor, m_selectedBarColor, m_highlightedBarStart, m_highlightedBarEnd); } else { - drawHistogram(ctx, rect, EvaluateHistogramAtAbscissa, m_store, context, m_store->firstDrawnBarAbscissa(), m_store->barWidth(), true, Palette::GreyMiddle, Palette::YellowDark); + drawHistogram(ctx, rect, EvaluateHistogramAtAbscissa, m_store, context, m_store->firstDrawnBarAbscissa(), m_store->barWidth(), true, m_notSelectedHistogramColor, m_selectedBarColor); } } diff --git a/apps/statistics/histogram_view.h b/apps/statistics/histogram_view.h index 3d7fd3a4d..d67ad3576 100644 --- a/apps/statistics/histogram_view.h +++ b/apps/statistics/histogram_view.h @@ -12,7 +12,7 @@ class HistogramController; class HistogramView : public Shared::CurveView { public: - HistogramView(HistogramController * controller, Store * store, int series, Shared::BannerView * bannerView); + HistogramView(HistogramController * controller, Store * store, int series, Shared::BannerView * bannerView, KDColor selectedHistogramColor = Palette::Select, KDColor notSelectedHistogramColor = Palette::GreyMiddle, KDColor selectedBarColor = Palette::YellowDark); int series() const { return m_series; } void reload() override; void drawRect(KDContext * ctx, KDRect rect) const override; @@ -26,6 +26,9 @@ private: float m_highlightedBarStart; float m_highlightedBarEnd; int m_series; + KDColor m_selectedHistogramColor; + KDColor m_notSelectedHistogramColor; + KDColor m_selectedBarColor; }; }