From 3b2eaa5dea19ffa331616c99fc30b93f2a86c6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Wed, 28 Nov 2018 11:34:09 +0100 Subject: [PATCH] [apps/sequence] Sequence title cells are aligned to the right --- apps/sequence/sequence_title_cell.cpp | 10 ++++++++-- apps/sequence/sequence_title_cell.h | 3 +++ apps/shared/function_title_cell.h | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/sequence/sequence_title_cell.cpp b/apps/sequence/sequence_title_cell.cpp index 0bb1d9bb9..9386b0a96 100644 --- a/apps/sequence/sequence_title_cell.cpp +++ b/apps/sequence/sequence_title_cell.cpp @@ -7,11 +7,17 @@ using namespace Poincare; namespace Sequence { SequenceTitleCell::SequenceTitleCell() : - Shared::FunctionTitleCell(), - m_titleTextView(0.5f, 0.5f) + Shared::FunctionTitleCell(Orientation::VerticalIndicator), + m_titleTextView(k_verticalOrientationHorizontalAlignment, 0.5f) { } +void SequenceTitleCell::setOrientation(Orientation orientation) { + float horizontalAlignment = orientation == Orientation::VerticalIndicator ? k_verticalOrientationHorizontalAlignment : k_horizontalOrientationHorizontalAlignment; + m_titleTextView.setAlignment(horizontalAlignment, 0.5f); + FunctionTitleCell::setOrientation(orientation); +} + void SequenceTitleCell::setLayout(Poincare::Layout layout) { m_titleTextView.setLayout(layout); } diff --git a/apps/sequence/sequence_title_cell.h b/apps/sequence/sequence_title_cell.h index ae719a297..262aa8715 100644 --- a/apps/sequence/sequence_title_cell.h +++ b/apps/sequence/sequence_title_cell.h @@ -13,6 +13,7 @@ public: void setEven(bool even) override; void setHighlighted(bool highlight) override; void setColor(KDColor color) override; + void setOrientation(Orientation orientation) override; const KDFont * font() const override { return Poincare::CharLayoutNode::k_defaultFont; } @@ -20,6 +21,8 @@ public: return m_titleTextView.layout(); } private: + static constexpr float k_horizontalOrientationHorizontalAlignment = 0.5f; + static constexpr float k_verticalOrientationHorizontalAlignment = 1.0f; int numberOfSubviews() const override; View * subviewAtIndex(int index) override; void layoutSubviews() override; diff --git a/apps/shared/function_title_cell.h b/apps/shared/function_title_cell.h index 604d44fbc..74ca4d439 100644 --- a/apps/shared/function_title_cell.h +++ b/apps/shared/function_title_cell.h @@ -12,7 +12,7 @@ public: VerticalIndicator }; FunctionTitleCell(Orientation orientation = Orientation::VerticalIndicator); - void setOrientation(Orientation orientation); + virtual void setOrientation(Orientation orientation); virtual void setColor(KDColor color); void drawRect(KDContext * ctx, KDRect rect) const override; virtual const KDFont * font() const = 0;