diff --git a/apps/graph/Makefile b/apps/graph/Makefile index a62defdbe..22a67789d 100644 --- a/apps/graph/Makefile +++ b/apps/graph/Makefile @@ -12,6 +12,7 @@ app_objs += $(addprefix apps/graph/,\ list/function_name_view.o\ list/list_controller.o\ list/parameter_controller.o\ + values/function_title_cell.o\ values/interval.o\ values/title_cell.o\ values/value_cell.o\ diff --git a/apps/graph/values/function_title_cell.cpp b/apps/graph/values/function_title_cell.cpp new file mode 100644 index 000000000..fe38b0c7d --- /dev/null +++ b/apps/graph/values/function_title_cell.cpp @@ -0,0 +1,21 @@ +#include "function_title_cell.h" +#include "../function.h" + +namespace Graph { + +void FunctionTitleCell::setColor(KDColor color) { + m_functionColor = color; +} + +void FunctionTitleCell::drawRect(KDContext * ctx, KDRect rect) const { + EvenOddCell::drawRect(ctx, rect); + // Write the "(x)" + KDColor background = backgroundColor(); + KDSize textSize = KDText::stringSize("f"); + KDPoint origin(0.5f*(m_frame.width() - textSize.width()), 0.5f*(m_frame.height() - textSize.height())); + ctx->drawString(Function::Parameter, origin.translatedBy(KDPoint(textSize.width(), 0)), m_functionColor , background); + // Color the color indicator + ctx->fillRect(KDRect(0, 0, bounds().width(), k_colorIndicatorThickness), m_functionColor); +} + +} diff --git a/apps/graph/values/function_title_cell.h b/apps/graph/values/function_title_cell.h new file mode 100644 index 000000000..8df2424b9 --- /dev/null +++ b/apps/graph/values/function_title_cell.h @@ -0,0 +1,19 @@ +#ifndef GRAPH_FUNCTION_TITLE_CELL_H +#define GRAPH_FUNCTION_TITLE_CELL_H + +#include +#include "title_cell.h" + +namespace Graph { +class FunctionTitleCell : public TitleCell { +public: + void setColor(KDColor color); + void drawRect(KDContext * ctx, KDRect rect) const override; + private: + constexpr static KDCoordinate k_colorIndicatorThickness = 2; + KDColor m_functionColor; +}; + +} + +#endif diff --git a/apps/graph/values/title_cell.cpp b/apps/graph/values/title_cell.cpp index 74d93bd2b..8529dcee3 100644 --- a/apps/graph/values/title_cell.cpp +++ b/apps/graph/values/title_cell.cpp @@ -1,5 +1,4 @@ #include "title_cell.h" -#include "../function.h" #include namespace Graph { @@ -33,13 +32,4 @@ void TitleCell::layoutSubviews() { m_pointerTextView.setFrame(bounds()); } -void TitleCell::drawRect(KDContext * ctx, KDRect rect) const { - EvenOddCell::drawRect(ctx, rect); - // Write the "(x)" - KDColor background = backgroundColor(); - KDSize textSize = KDText::stringSize("f"); - KDPoint origin(0.5f*(m_frame.width() - textSize.width()), 0.5f*(m_frame.height() - textSize.height())); - ctx->drawString(Function::Parameter, origin.translatedBy(KDPoint(textSize.width(), 0)), KDColorBlack, background); -} - } diff --git a/apps/graph/values/title_cell.h b/apps/graph/values/title_cell.h index a03b4a85e..1c370ab2a 100644 --- a/apps/graph/values/title_cell.h +++ b/apps/graph/values/title_cell.h @@ -13,8 +13,6 @@ public: int numberOfSubviews() const override; View * subviewAtIndex(int index) override; void layoutSubviews() override; - void drawRect(KDContext * ctx, KDRect rect) const override; - protected: PointerTextView m_pointerTextView; };