diff --git a/apps/sequence/sequence_title_cell.cpp b/apps/sequence/sequence_title_cell.cpp index 5c2eed39f..e7e3c6853 100644 --- a/apps/sequence/sequence_title_cell.cpp +++ b/apps/sequence/sequence_title_cell.cpp @@ -8,13 +8,18 @@ namespace Sequence { SequenceTitleCell::SequenceTitleCell() : Shared::FunctionTitleCell(Orientation::VerticalIndicator), - m_titleTextView(k_verticalOrientationHorizontalAlignment, 0.5f) + m_titleTextView(k_verticalOrientationHorizontalAlignment, k_horizontalOrientationAlignment) { } void SequenceTitleCell::setOrientation(Orientation orientation) { - float horizontalAlignment = orientation == Orientation::VerticalIndicator ? k_verticalOrientationHorizontalAlignment : k_horizontalOrientationHorizontalAlignment; - m_titleTextView.setAlignment(horizontalAlignment, 0.5f); + if (orientation == Orientation::VerticalIndicator) { + /* We do not care here about the vertical alignment, it will be set properly + * in layoutSubviews */ + m_titleTextView.setAlignment(k_verticalOrientationHorizontalAlignment, k_verticalOrientationHorizontalAlignment); + } else { + m_titleTextView.setAlignment(k_horizontalOrientationAlignment, k_horizontalOrientationAlignment); + } FunctionTitleCell::setOrientation(orientation); } @@ -48,8 +53,15 @@ View * SequenceTitleCell::subviewAtIndex(int index) { void SequenceTitleCell::layoutSubviews() { 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, bounds().height()-k_separatorThickness); + if (m_orientation == Orientation::VerticalIndicator) { + KDCoordinate h = bounds().height()-k_separatorThickness; + textFrame = KDRect(k_colorIndicatorThickness, 0, bounds().width() - k_colorIndicatorThickness, h); + /* We try to align the text so that the equal is vertically centered in the + * cell. This makes the title cell and the definition cell baselines be + * approximately at the same level for basic sequences definitions (un = 1, + * un=1/2, ...). */ + float verticalAlignment = 0.5f + 20.0f/((float)h); // 20.0f is a magic value + m_titleTextView.setAlignment(k_verticalOrientationHorizontalAlignment, verticalAlignment); } m_titleTextView.setFrame(textFrame); } diff --git a/apps/sequence/sequence_title_cell.h b/apps/sequence/sequence_title_cell.h index 262aa8715..db787b793 100644 --- a/apps/sequence/sequence_title_cell.h +++ b/apps/sequence/sequence_title_cell.h @@ -21,8 +21,8 @@ public: return m_titleTextView.layout(); } private: - static constexpr float k_horizontalOrientationHorizontalAlignment = 0.5f; - static constexpr float k_verticalOrientationHorizontalAlignment = 1.0f; + static constexpr float k_horizontalOrientationAlignment = 0.5f; + static constexpr float k_verticalOrientationHorizontalAlignment = 0.9f; int numberOfSubviews() const override; View * subviewAtIndex(int index) override; void layoutSubviews() override;