From a29be020f5a6e13a45379db5b99b2a94956c2f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 4 Oct 2016 10:20:19 +0200 Subject: [PATCH 1/2] [apps/graph] add a method in function expression view to mark a cell as dirty Change-Id: Iee820055f36f18a31af5bd69097557e9718c6425 --- apps/graph/list/function_cell.cpp | 5 +++++ apps/graph/list/function_cell.h | 1 + apps/graph/list/function_expression_view.h | 1 - 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/graph/list/function_cell.cpp b/apps/graph/list/function_cell.cpp index 5d452b8f7..8777b1152 100644 --- a/apps/graph/list/function_cell.cpp +++ b/apps/graph/list/function_cell.cpp @@ -31,3 +31,8 @@ void FunctionCell::setHighlighted(bool highlight) { Graph::Function * FunctionCell::function() { return m_function; } + +void FunctionCell::reloadCell() { + //TODO: optimize for function_name_view (make it virtual) + markRectAsDirty(bounds()); +} diff --git a/apps/graph/list/function_cell.h b/apps/graph/list/function_cell.h index 579a581ee..a234ce88f 100644 --- a/apps/graph/list/function_cell.h +++ b/apps/graph/list/function_cell.h @@ -11,6 +11,7 @@ public: void setEven(bool even); void setHighlighted(bool highlight); Graph::Function * function(); + void reloadCell(); static constexpr KDColor k_evenLineBackgroundColor = KDColor(0xF9F9F9); static constexpr KDColor k_oddLineBackgroundColor = KDColor(0xEEEEF2); diff --git a/apps/graph/list/function_expression_view.h b/apps/graph/list/function_expression_view.h index 4fd549736..173773bd2 100644 --- a/apps/graph/list/function_expression_view.h +++ b/apps/graph/list/function_expression_view.h @@ -9,7 +9,6 @@ class FunctionCell; class FunctionExpressionView : public FunctionCell { public: FunctionExpressionView(); - void drawRect(KDContext * ctx, KDRect rect) const override; }; From c2981505c12867ebeddca46df1588e4c81a0b1ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 4 Oct 2016 10:20:19 +0200 Subject: [PATCH 2/2] [apps/graph] draw only active functions Change-Id: I83daefa66e17843909c4f2aeab836cbb7affb56e --- apps/graph/graph/graph_view.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/graph/graph/graph_view.cpp b/apps/graph/graph/graph_view.cpp index d8c9dd61b..c688d282b 100644 --- a/apps/graph/graph/graph_view.cpp +++ b/apps/graph/graph/graph_view.cpp @@ -162,13 +162,15 @@ void GraphView::drawFunction(KDContext * ctx, KDRect rect) const { for (KDCoordinate px = rect.x()-stampSize; pxnumberOfFunctions(); i++) { - Float xExp = Float(x); - plotContext.setExpressionForSymbolName(&xExp, "x"); Graph::Function * f = m_functionStore->functionAtIndex(i); - float y = f->expression()->approximate(plotContext); - KDCoordinate py = floatToPixel(Axis::Vertical, y); - KDRect stampRect(px, py, stampSize, stampSize); - ctx->fillRectWithMask(stampRect, f->color(), mask, workingBuffer); + if (f->isActive()) { + Float xExp = Float(x); + plotContext.setExpressionForSymbolName(&xExp, "x"); + float y = f->expression()->approximate(plotContext); + KDCoordinate py = floatToPixel(Axis::Vertical, y); + KDRect stampRect(px, py, stampSize, stampSize); + ctx->fillRectWithMask(stampRect, f->color(), mask, workingBuffer); + } } } }