From b0a9d23ce3e8c14b0a014dbff5eb869be96242ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Fri, 30 Dec 2016 17:26:50 +0100 Subject: [PATCH] [apps/regression] Make graph view inherits from Curve view with banner and cursor Change-Id: I3d63eb2b0750ba7c11374bb608347efc2418ccfd --- apps/regression/graph_view.cpp | 6 ++++-- apps/regression/graph_view.h | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/regression/graph_view.cpp b/apps/regression/graph_view.cpp index c866b19b0..3c95177dd 100644 --- a/apps/regression/graph_view.cpp +++ b/apps/regression/graph_view.cpp @@ -5,7 +5,7 @@ namespace Regression { GraphView::GraphView(Data * data) : - CurveViewWithBanner(data, 0.2f, 0.2f, 0.4f, 0.2f), + CurveViewWithBannerAndCursor(data, 0.2f, 0.2f, 0.4f, 0.2f), m_data(data), m_bannerView(BannerView(data)) { @@ -14,8 +14,9 @@ GraphView::GraphView(Data * data) : void GraphView::reloadSelection() { float pixelXSelection = roundf(floatToPixel(Axis::Horizontal, m_data->xCursorPosition())); float pixelYSelection = roundf(floatToPixel(Axis::Vertical, m_data->yCursorPosition())); - KDRect dirtyZone(KDRect(pixelXSelection - k_dotSize/2, pixelYSelection - k_dotSize/2, k_dotSize, k_dotSize)); + KDRect dirtyZone(KDRect(pixelXSelection - k_dotSize, pixelYSelection - k_dotSize, 2*k_dotSize, 2*k_dotSize)); markRectAsDirty(dirtyZone); + layoutSubviews(); m_bannerView.reload(); } @@ -23,6 +24,7 @@ void GraphView::reload() { markRectAsDirty(bounds()); computeLabels(Axis::Horizontal); computeLabels(Axis::Vertical); + layoutSubviews(); m_bannerView.reload(); } diff --git a/apps/regression/graph_view.h b/apps/regression/graph_view.h index bc7f6e92d..c144fa2f5 100644 --- a/apps/regression/graph_view.h +++ b/apps/regression/graph_view.h @@ -5,18 +5,19 @@ #include "data.h" #include "banner_view.h" #include "../constant.h" -#include "../curve_view_with_banner.h" +#include "../cursor_view.h" +#include "../curve_view_with_banner_and_cursor.h" namespace Regression { -class GraphView : public CurveViewWithBanner { +class GraphView : public CurveViewWithBannerAndCursor { public: GraphView(Data * m_data); void reloadSelection() override; void reload(); void drawRect(KDContext * ctx, KDRect rect) const override; private: - constexpr static KDCoordinate k_dotSize = 4; + constexpr static KDCoordinate k_dotSize = 5; char * label(Axis axis, int index) const override; View * bannerView() override; float evaluateModelWithParameter(Model * curve, float t) const override;