From 1f7ba888c97dfe939f7adc259086f2b3a2c0268d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 19 Sep 2016 15:22:24 +0200 Subject: [PATCH] [apps/graph] add an attribute "activate" to functions Change-Id: I1a1f548c540a6e31fe9ce1aeb742bf6a6292362c --- apps/graph/function.cpp | 11 ++++++++++- apps/graph/function.h | 3 +++ apps/graph/list/function_expression_view.cpp | 4 ++-- apps/graph/list/function_name_view.cpp | 3 ++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/apps/graph/function.cpp b/apps/graph/function.cpp index 227d0818f..5c99cb4b4 100644 --- a/apps/graph/function.cpp +++ b/apps/graph/function.cpp @@ -12,7 +12,8 @@ Graph::Function::Function(const char * text, KDColor color) : m_color(color), m_name("f(x)"), m_expression(nullptr), - m_layout(nullptr) + m_layout(nullptr), + m_active(true) { } @@ -47,3 +48,11 @@ ExpressionLayout * Graph::Function::layout() { } return m_layout; } + +bool Graph::Function::isActive() { + return m_active; +} + +void Graph::Function::setActive(bool active) { + m_active = active; +} diff --git a/apps/graph/function.h b/apps/graph/function.h index 3021f129a..fb04c2ded 100644 --- a/apps/graph/function.h +++ b/apps/graph/function.h @@ -16,12 +16,15 @@ public: KDColor color() const { return m_color; } Expression * expression(); ExpressionLayout * layout(); + bool isActive(); + void setActive(bool active); private: const char * m_text; const char * m_name; KDColor m_color; Expression * m_expression; ExpressionLayout * m_layout; + bool m_active; }; } diff --git a/apps/graph/list/function_expression_view.cpp b/apps/graph/list/function_expression_view.cpp index b127e167d..8a7ebc481 100644 --- a/apps/graph/list/function_expression_view.cpp +++ b/apps/graph/list/function_expression_view.cpp @@ -13,7 +13,8 @@ void FunctionExpressionView::drawRect(KDContext * ctx, KDRect rect) const { bool evenLine = isEven(); KDColor background = evenLine ? KDColor(0xEEEEEE) : KDColor(0x777777); ctx->fillRect(rect, background); - KDColor text = m_focused ? KDColorBlack : KDColorWhite; + bool active = function()->isActive(); + KDColor text = active ? KDColorGreen : KDColorRed; KDColor textBackground = m_focused ? KDColorWhite : KDColorBlack; Graph::Function * function = FunctionExpressionView::function(); @@ -21,7 +22,6 @@ void FunctionExpressionView::drawRect(KDContext * ctx, KDRect rect) const { // m_function->layout()->draw(ctx, KDPointZero); } - void FunctionExpressionView::didBecomeFirstResponder() { m_focused = true; markRectAsDirty(bounds()); diff --git a/apps/graph/list/function_name_view.cpp b/apps/graph/list/function_name_view.cpp index 98f7fe39c..e0b9b7ff8 100644 --- a/apps/graph/list/function_name_view.cpp +++ b/apps/graph/list/function_name_view.cpp @@ -14,7 +14,8 @@ void FunctionNameView::drawRect(KDContext * ctx, KDRect rect) const { bool evenLine = isEven(); KDColor background = evenLine ? KDColor(0xEEEEEE) : KDColor(0x777777); ctx->fillRect(rect, background); - KDColor text = m_focused ? KDColorBlack : KDColorWhite; + bool active = function()->isActive(); + KDColor text = active ? KDColorGreen : KDColorRed; KDColor textBackground = m_focused ? KDColorWhite : KDColorBlack; Graph::Function * function = FunctionNameView::function();