From 24fc727b5392487941d2dbdea02de063cdf54c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 7 Feb 2017 15:39:04 +0100 Subject: [PATCH] [escher] Uniformize methods in menu list cell and even odd cells Change-Id: Idccb55bdfe0ff2010fd06bd5796b8c324469446b --- escher/include/escher/chevron_menu_list_cell.h | 2 +- escher/include/escher/chevron_text_menu_list_cell.h | 2 +- escher/include/escher/editable_text_cell.h | 2 +- escher/include/escher/editable_text_menu_list_cell.h | 2 +- escher/include/escher/even_odd_buffer_text_cell.h | 3 ++- escher/include/escher/even_odd_editable_text_cell.h | 3 ++- escher/include/escher/even_odd_expression_cell.h | 3 ++- escher/include/escher/even_odd_pointer_text_cell.h | 3 ++- escher/include/escher/menu_list_cell.h | 2 +- escher/include/escher/text_menu_list_cell.h | 1 - escher/src/chevron_menu_list_cell.cpp | 6 +++--- escher/src/chevron_text_menu_list_cell.cpp | 4 ++-- escher/src/editable_text_cell.cpp | 6 +++--- escher/src/editable_text_menu_list_cell.cpp | 6 +++--- escher/src/even_odd_buffer_text_cell.cpp | 9 +++++++-- escher/src/even_odd_editable_text_cell.cpp | 9 +++++++-- escher/src/even_odd_expression_cell.cpp | 9 +++++++-- escher/src/even_odd_pointer_text_cell.cpp | 9 +++++++-- escher/src/menu_list_cell.cpp | 6 +++--- escher/src/text_menu_list_cell.cpp | 8 +------- 20 files changed, 56 insertions(+), 39 deletions(-) diff --git a/escher/include/escher/chevron_menu_list_cell.h b/escher/include/escher/chevron_menu_list_cell.h index 7c5c5e293..1abea3424 100644 --- a/escher/include/escher/chevron_menu_list_cell.h +++ b/escher/include/escher/chevron_menu_list_cell.h @@ -8,7 +8,7 @@ class ChevronMenuListCell : public MenuListCell { public: ChevronMenuListCell(char * label = nullptr, KDText::FontSize size = KDText::FontSize::Small); View * accessoryView() const override; - void reloadCell() override; + void setHighlighted(bool highlight) override; private: ChevronView m_accessoryView; }; diff --git a/escher/include/escher/chevron_text_menu_list_cell.h b/escher/include/escher/chevron_text_menu_list_cell.h index 51cb9efca..626706764 100644 --- a/escher/include/escher/chevron_text_menu_list_cell.h +++ b/escher/include/escher/chevron_text_menu_list_cell.h @@ -6,7 +6,7 @@ class ChevronTextMenuListCell : public ChevronMenuListCell { public: ChevronTextMenuListCell(KDText::FontSize size = KDText::FontSize::Small); - void reloadCell() override; + void setHighlighted(bool highlight) override; void setSubtitle(const char * text); private: static constexpr KDCoordinate k_margin = 8; diff --git a/escher/include/escher/editable_text_cell.h b/escher/include/escher/editable_text_cell.h index b91b918cf..b5217d815 100644 --- a/escher/include/escher/editable_text_cell.h +++ b/escher/include/escher/editable_text_cell.h @@ -11,7 +11,7 @@ public: EditableTextCell(Responder * parentResponder, TextFieldDelegate * delegate, char * draftTextBuffer, KDText::FontSize size = KDText::FontSize::Large, float horizontalAlignment = 0.0f, float verticalAlignment = 0.5f, KDColor textColor = KDColorBlack, KDColor = KDColorWhite); TextField * textField(); - void reloadCell() override; + void setHighlighted(bool highlight) override; const char * text() const; void setText(const char * textContent); int numberOfSubviews() const override; diff --git a/escher/include/escher/editable_text_menu_list_cell.h b/escher/include/escher/editable_text_menu_list_cell.h index eff6aa05d..093c13c95 100644 --- a/escher/include/escher/editable_text_menu_list_cell.h +++ b/escher/include/escher/editable_text_menu_list_cell.h @@ -12,7 +12,7 @@ public: const char * editedText() const; void didBecomeFirstResponder() override; void setEditing(bool isEditing); - void reloadCell() override; + void setHighlighted(bool highlight) override; void setAccessoryText(const char * text); void setTextColor(KDColor color) override; constexpr static int k_bufferLength = 255; diff --git a/escher/include/escher/even_odd_buffer_text_cell.h b/escher/include/escher/even_odd_buffer_text_cell.h index e6fa67f87..eebdc7d4e 100644 --- a/escher/include/escher/even_odd_buffer_text_cell.h +++ b/escher/include/escher/even_odd_buffer_text_cell.h @@ -7,7 +7,8 @@ class EvenOddBufferTextCell : public EvenOddCell { public: EvenOddBufferTextCell(KDText::FontSize size = KDText::FontSize::Small, float horizontalAlignment = 1.0f, float verticalAlignment = 0.5f); - void reloadCell() override; + void setEven(bool even) override; + void setHighlighted(bool highlight) override; void setText(const char * textContent); void setTextColor(KDColor textColor); int numberOfSubviews() const override; diff --git a/escher/include/escher/even_odd_editable_text_cell.h b/escher/include/escher/even_odd_editable_text_cell.h index 42b658f67..866c29338 100644 --- a/escher/include/escher/even_odd_editable_text_cell.h +++ b/escher/include/escher/even_odd_editable_text_cell.h @@ -9,7 +9,8 @@ class EvenOddEditableTextCell : public EvenOddCell, public Responder { public: EvenOddEditableTextCell(Responder * parentResponder, TextFieldDelegate * delegate, char * draftTextBuffer, KDText::FontSize size = KDText::FontSize::Large); EditableTextCell * editableTextCell(); - void reloadCell() override; + void setEven(bool even) override; + void setHighlighted(bool highlight) override; const char * text() const; void setText(const char * textContent); int numberOfSubviews() const override; diff --git a/escher/include/escher/even_odd_expression_cell.h b/escher/include/escher/even_odd_expression_cell.h index 9b8c2620c..eee6dd413 100644 --- a/escher/include/escher/even_odd_expression_cell.h +++ b/escher/include/escher/even_odd_expression_cell.h @@ -8,7 +8,8 @@ class EvenOddExpressionCell : public EvenOddCell { public: EvenOddExpressionCell(float horizontalAlignment = 0.0f, float verticalAlignment = 0.5f, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); - void reloadCell() override; + void setEven(bool even) override; + void setHighlighted(bool highlight) override; void setExpression(Poincare::ExpressionLayout * expressionLayout); void setBackgroundColor(KDColor backgroundColor); void setTextColor(KDColor textColor); diff --git a/escher/include/escher/even_odd_pointer_text_cell.h b/escher/include/escher/even_odd_pointer_text_cell.h index 493caab85..067c6a097 100644 --- a/escher/include/escher/even_odd_pointer_text_cell.h +++ b/escher/include/escher/even_odd_pointer_text_cell.h @@ -7,7 +7,8 @@ class EvenOddPointerTextCell : public EvenOddCell { public: EvenOddPointerTextCell(KDText::FontSize size = KDText::FontSize::Large); - void reloadCell() override; + void setEven(bool even) override; + void setHighlighted(bool highlight) override; void setText(const char * textContent, KDColor textColor = KDColorBlack); void setAlignment(float horizontalAlignment, float verticalAlignment); int numberOfSubviews() const override; diff --git a/escher/include/escher/menu_list_cell.h b/escher/include/escher/menu_list_cell.h index 873a28f5b..f026e5a42 100644 --- a/escher/include/escher/menu_list_cell.h +++ b/escher/include/escher/menu_list_cell.h @@ -14,7 +14,7 @@ public: void setText(const char * text); virtual void setTextColor(KDColor color); void drawRect(KDContext * ctx, KDRect rect) const override; - void reloadCell() override; + void setHighlighted(bool highlight) override; protected: int numberOfSubviews() const override; View * subviewAtIndex(int index) override; diff --git a/escher/include/escher/text_menu_list_cell.h b/escher/include/escher/text_menu_list_cell.h index be6a69188..2283e35af 100644 --- a/escher/include/escher/text_menu_list_cell.h +++ b/escher/include/escher/text_menu_list_cell.h @@ -7,7 +7,6 @@ class TextMenuListCell : public MenuListCell { public: TextMenuListCell(char * label = nullptr); - void reloadCell() override; View * accessoryView() const override; void setHighlighted(bool highlight) override; void setAccessoryText(const char * textBody); diff --git a/escher/src/chevron_menu_list_cell.cpp b/escher/src/chevron_menu_list_cell.cpp index 3ddb5b723..ad0152114 100644 --- a/escher/src/chevron_menu_list_cell.cpp +++ b/escher/src/chevron_menu_list_cell.cpp @@ -10,7 +10,7 @@ View * ChevronMenuListCell::accessoryView() const { return (View *)&m_accessoryView; } -void ChevronMenuListCell::reloadCell() { - MenuListCell::reloadCell(); +void ChevronMenuListCell::setHighlighted(bool highlight) { + MenuListCell::setHighlighted(highlight); m_accessoryView.setHighlighted(isHighlighted()); -} \ No newline at end of file +} diff --git a/escher/src/chevron_text_menu_list_cell.cpp b/escher/src/chevron_text_menu_list_cell.cpp index 4345f4a83..7f43792ea 100644 --- a/escher/src/chevron_text_menu_list_cell.cpp +++ b/escher/src/chevron_text_menu_list_cell.cpp @@ -6,8 +6,8 @@ ChevronMenuListCell(nullptr, size), { } -void ChevronTextMenuListCell::reloadCell() { - ChevronMenuListCell::reloadCell(); +void ChevronTextMenuListCell::setHighlighted(bool highlight) { + ChevronMenuListCell::setHighlighted(highlight); KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; m_subtitleView.setBackgroundColor(backgroundColor); } diff --git a/escher/src/editable_text_cell.cpp b/escher/src/editable_text_cell.cpp index f9c2d4927..8b66d829b 100644 --- a/escher/src/editable_text_cell.cpp +++ b/escher/src/editable_text_cell.cpp @@ -15,9 +15,9 @@ TextField * EditableTextCell::textField() { return &m_textField; } -void EditableTextCell::reloadCell() { - TableViewCell::reloadCell(); - KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; +void EditableTextCell::setHighlighted(bool highlight) { + TableViewCell::setHighlighted(highlight); + KDColor backgroundColor = highlight? Palette::Select : KDColorWhite; m_textField.setBackgroundColor(backgroundColor); } diff --git a/escher/src/editable_text_menu_list_cell.cpp b/escher/src/editable_text_menu_list_cell.cpp index bbd611d56..a63425565 100644 --- a/escher/src/editable_text_menu_list_cell.cpp +++ b/escher/src/editable_text_menu_list_cell.cpp @@ -24,9 +24,9 @@ void EditableTextMenuListCell::setEditing(bool isEditing) { m_textField.setEditing(isEditing); } -void EditableTextMenuListCell::reloadCell() { - MenuListCell::reloadCell(); - KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; +void EditableTextMenuListCell::setHighlighted(bool highlight) { + MenuListCell::setHighlighted(highlight); + KDColor backgroundColor = highlight? Palette::Select : KDColorWhite; m_textField.setBackgroundColor(backgroundColor); } diff --git a/escher/src/even_odd_buffer_text_cell.cpp b/escher/src/even_odd_buffer_text_cell.cpp index fd858c0e2..0dd1f4b9e 100644 --- a/escher/src/even_odd_buffer_text_cell.cpp +++ b/escher/src/even_odd_buffer_text_cell.cpp @@ -7,8 +7,13 @@ EvenOddBufferTextCell::EvenOddBufferTextCell(KDText::FontSize size, float horizo { } -void EvenOddBufferTextCell::reloadCell() { - EvenOddCell::reloadCell(); +void EvenOddBufferTextCell::setHighlighted(bool highlight) { + EvenOddCell::setHighlighted(highlight); + m_bufferTextView.setBackgroundColor(backgroundColor()); +} + +void EvenOddBufferTextCell::setEven(bool even) { + EvenOddCell::setEven(even); m_bufferTextView.setBackgroundColor(backgroundColor()); } diff --git a/escher/src/even_odd_editable_text_cell.cpp b/escher/src/even_odd_editable_text_cell.cpp index 95b47d460..1f5105739 100644 --- a/escher/src/even_odd_editable_text_cell.cpp +++ b/escher/src/even_odd_editable_text_cell.cpp @@ -13,8 +13,13 @@ EditableTextCell * EvenOddEditableTextCell::editableTextCell() { return &m_editableCell; } -void EvenOddEditableTextCell::reloadCell() { - EvenOddCell::reloadCell(); +void EvenOddEditableTextCell::setHighlighted(bool highlight) { + EvenOddCell::setHighlighted(highlight); + m_editableCell.textField()->setBackgroundColor(backgroundColor()); +} + +void EvenOddEditableTextCell::setEven(bool even) { + EvenOddCell::setEven(even); m_editableCell.textField()->setBackgroundColor(backgroundColor()); } diff --git a/escher/src/even_odd_expression_cell.cpp b/escher/src/even_odd_expression_cell.cpp index 479d6e4a4..63781525b 100644 --- a/escher/src/even_odd_expression_cell.cpp +++ b/escher/src/even_odd_expression_cell.cpp @@ -9,8 +9,13 @@ EvenOddExpressionCell::EvenOddExpressionCell(float horizontalAlignment, float ve { } -void EvenOddExpressionCell::reloadCell() { - EvenOddCell::reloadCell(); +void EvenOddExpressionCell::setHighlighted(bool highlight) { + EvenOddCell::setHighlighted(highlight); + m_expressionView.setBackgroundColor(backgroundColor()); +} + +void EvenOddExpressionCell::setEven(bool even) { + EvenOddCell::setEven(even); m_expressionView.setBackgroundColor(backgroundColor()); } diff --git a/escher/src/even_odd_pointer_text_cell.cpp b/escher/src/even_odd_pointer_text_cell.cpp index 4e49c6778..3a9bab8cf 100644 --- a/escher/src/even_odd_pointer_text_cell.cpp +++ b/escher/src/even_odd_pointer_text_cell.cpp @@ -7,8 +7,13 @@ EvenOddPointerTextCell::EvenOddPointerTextCell(KDText::FontSize size) : { } -void EvenOddPointerTextCell::reloadCell() { - EvenOddCell::reloadCell(); +void EvenOddPointerTextCell::setHighlighted(bool highlight) { + EvenOddCell::setHighlighted(highlight); + m_pointerTextView.setBackgroundColor(backgroundColor()); +} + +void EvenOddPointerTextCell::setEven(bool even) { + EvenOddCell::setEven(even); m_pointerTextView.setBackgroundColor(backgroundColor()); } diff --git a/escher/src/menu_list_cell.cpp b/escher/src/menu_list_cell.cpp index 4f98c410b..19d6d0400 100644 --- a/escher/src/menu_list_cell.cpp +++ b/escher/src/menu_list_cell.cpp @@ -35,9 +35,9 @@ void MenuListCell::layoutSubviews() { } } -void MenuListCell::reloadCell() { - TableViewCell::reloadCell(); - KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; +void MenuListCell::setHighlighted(bool highlight) { + TableViewCell::setHighlighted(highlight); + KDColor backgroundColor = highlight? Palette::Select : KDColorWhite; m_pointerTextView.setBackgroundColor(backgroundColor); } diff --git a/escher/src/text_menu_list_cell.cpp b/escher/src/text_menu_list_cell.cpp index 053504532..1ab1994bd 100644 --- a/escher/src/text_menu_list_cell.cpp +++ b/escher/src/text_menu_list_cell.cpp @@ -19,15 +19,9 @@ View * TextMenuListCell::accessoryView() const { return (View *)&m_accessoryView; } -void TextMenuListCell::reloadCell() { - MenuListCell::reloadCell(); - KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; - m_accessoryView.setBackgroundColor(backgroundColor); -} - void TextMenuListCell::setHighlighted(bool highlight) { MenuListCell::setHighlighted(highlight); - KDColor backgroundColor = highlight? Palette::Select : KDColorWhite; + KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; m_accessoryView.setBackgroundColor(backgroundColor); }