diff --git a/apps/graph/Makefile b/apps/graph/Makefile index 6db21faeb..5efff683d 100644 --- a/apps/graph/Makefile +++ b/apps/graph/Makefile @@ -17,6 +17,7 @@ app_objs += $(addprefix apps/graph/,\ graph/root_graph_controller.o\ graph/tangent_graph_controller.o\ list/storage_list_controller.o\ + list/text_field_function_title_cell.o\ values/storage_derivative_parameter_controller.o\ values/storage_function_parameter_controller.o\ values/storage_values_controller.o\ diff --git a/apps/graph/list/storage_list_controller.cpp b/apps/graph/list/storage_list_controller.cpp index 391dff9b1..7c1359a9c 100644 --- a/apps/graph/list/storage_list_controller.cpp +++ b/apps/graph/list/storage_list_controller.cpp @@ -42,7 +42,7 @@ HighlightCell * StorageListController::expressionCells(int index) { } void StorageListController::willDisplayTitleCellAtIndex(HighlightCell * cell, int j) { - Shared::BufferFunctionTitleCell * myFunctionCell = (Shared::BufferFunctionTitleCell *)cell; + TextFieldFunctionTitleCell * myFunctionCell = (TextFieldFunctionTitleCell *)cell; StorageFunction * function = m_functionStore->modelAtIndex(j); char bufferName[BufferTextView::k_maxNumberOfChar]; function->nameWithArgument(bufferName, BufferTextView::k_maxNumberOfChar, m_functionStore->symbol()); diff --git a/apps/graph/list/storage_list_controller.h b/apps/graph/list/storage_list_controller.h index d25baae27..c32b8cfbf 100644 --- a/apps/graph/list/storage_list_controller.h +++ b/apps/graph/list/storage_list_controller.h @@ -2,10 +2,11 @@ #define GRAPH_STORAGE_LIST_CONTROLLER_H #include -#include "../../shared/storage_function_list_controller.h" +#include "text_field_function_title_cell.h" #include "../storage_cartesian_function_store.h" -#include "../../shared/buffer_function_title_cell.h" -#include "../../shared/function_expression_cell.h" +#include +#include +#include #include namespace Graph { @@ -22,7 +23,7 @@ private: void willDisplayTitleCellAtIndex(HighlightCell * cell, int j) override; void willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) override; constexpr static int k_maxNumberOfDisplayableRows = 5; - Shared::BufferFunctionTitleCell m_functionTitleCells[k_maxNumberOfDisplayableRows]; + TextFieldFunctionTitleCell m_functionTitleCells[k_maxNumberOfDisplayableRows]; Shared::FunctionExpressionCell m_expressionCells[k_maxNumberOfDisplayableRows]; Shared::StorageListParameterController m_parameterController; }; diff --git a/apps/graph/list/text_field_function_title_cell.cpp b/apps/graph/list/text_field_function_title_cell.cpp new file mode 100644 index 000000000..8c5daf2b9 --- /dev/null +++ b/apps/graph/list/text_field_function_title_cell.cpp @@ -0,0 +1,37 @@ +#include "text_field_function_title_cell.h" +#include + +namespace Graph { + +void TextFieldFunctionTitleCell::setHighlighted(bool highlight) { + EvenOddCell::setHighlighted(highlight); + m_textField.setBackgroundColor(EvenOddCell::backgroundColor()); +} + +void TextFieldFunctionTitleCell::setEven(bool even) { + EvenOddCell::setEven(even); + m_textField.setBackgroundColor(EvenOddCell::backgroundColor()); +} + +void TextFieldFunctionTitleCell::setColor(KDColor color) { + FunctionTitleCell::setColor(color); + m_textField.setTextColor(color); +} + +void TextFieldFunctionTitleCell::setText(const char * title) { + m_textField.setText(title); +} + +void TextFieldFunctionTitleCell::layoutSubviews() { + m_textField.setFrame(textFieldFrame()); +} + +KDRect TextFieldFunctionTitleCell::textFieldFrame() const { + KDRect textFrame(0, k_colorIndicatorThickness, bounds().width(), bounds().height() - k_colorIndicatorThickness); + if (m_orientation == Orientation::VerticalIndicator){ + textFrame = KDRect(k_colorIndicatorThickness, 0, bounds().width() - k_colorIndicatorThickness-k_separatorThickness, bounds().height()-k_separatorThickness); + } + return textFrame; +} + +} diff --git a/apps/graph/list/text_field_function_title_cell.h b/apps/graph/list/text_field_function_title_cell.h new file mode 100644 index 000000000..7b62f9073 --- /dev/null +++ b/apps/graph/list/text_field_function_title_cell.h @@ -0,0 +1,38 @@ +#ifndef GRAPH_LIST_TEXT_FIELD_FUNCTION_TITLE_CELL_H +#define GRAPH_LIST_TEXT_FIELD_FUNCTION_TITLE_CELL_H + +#include "../../shared/function_title_cell.h" + +namespace Graph { + +class TextFieldFunctionTitleCell : public Shared::FunctionTitleCell { +public: + TextFieldFunctionTitleCell(Orientation orientation = Orientation::VerticalIndicator, KDText::FontSize size = KDText::FontSize::Large) : + Shared::FunctionTitleCell(orientation), + m_textField(nullptr, m_textFieldBuffer, m_textFieldBuffer, k_textFieldBufferSize, nullptr, false, size, 0.5f, 0.5f) + {} + void setEven(bool even) override; + void setHighlighted(bool highlight) override; + void setColor(KDColor color) override; + void setText(const char * textContent); + KDText::FontSize fontSize() const override { return m_textField.fontSize(); } + const char * text() const override { + return m_textField.text(); + } + int numberOfSubviews() const override { return 1; } + View * subviewAtIndex(int index) override { + assert(index == 0); + return &m_textField; + } + void layoutSubviews() override; +protected: + KDRect textFieldFrame() const; +private: + constexpr static int k_textFieldBufferSize = TextField::maxBufferSize(); + TextField m_textField; + char m_textFieldBuffer[k_textFieldBufferSize]; +}; + +} + +#endif diff --git a/escher/include/escher/text_field.h b/escher/include/escher/text_field.h index d7d2401a5..a668b41cc 100644 --- a/escher/include/escher/text_field.h +++ b/escher/include/escher/text_field.h @@ -29,6 +29,7 @@ public: } void scrollToCursor() override; bool shouldFinishEditing(Ion::Events::Event event) override { return m_delegate->textFieldShouldFinishEditing(this, event); } + KDText::FontSize fontSize() const { return m_contentView.fontSize(); } protected: class ContentView : public TextInput::ContentView { public: diff --git a/escher/include/escher/text_input.h b/escher/include/escher/text_input.h index 77801ea03..95d09f8b1 100644 --- a/escher/include/escher/text_input.h +++ b/escher/include/escher/text_input.h @@ -22,6 +22,7 @@ protected: public: ContentView(const KDFont * font); void setFont(const KDFont * font); + const KDFont * font() const { return m_font; } size_t cursorLocation() const { return m_cursorIndex; } void setCursorLocation(int cursorLocation); virtual const char * text() const = 0;