diff --git a/apps/graph/list/storage_list_controller.cpp b/apps/graph/list/storage_list_controller.cpp index 1ccfcaaaa..60048321c 100644 --- a/apps/graph/list/storage_list_controller.cpp +++ b/apps/graph/list/storage_list_controller.cpp @@ -148,6 +148,8 @@ HighlightCell * StorageListController::expressionCells(int index) { void StorageListController::willDisplayTitleCellAtIndex(HighlightCell * cell, int j) { TextFieldFunctionTitleCell * titleCell = static_cast(cell); + StorageExpressionModelListController::willDisplayExpressionCellAtIndex(m_selectableTableView.cellAtLocation(1, j), j); + titleCell->setBaseline(baseline(j)); if (!titleCell->isEditing()) { ExpiringPointer function = modelStore()->modelForRecord(modelStore()->recordAtIndex(j)); setFunctionNameInTextField(function, titleCell->textField()); diff --git a/apps/graph/list/text_field_function_title_cell.cpp b/apps/graph/list/text_field_function_title_cell.cpp index 4699c7784..061a3e35a 100644 --- a/apps/graph/list/text_field_function_title_cell.cpp +++ b/apps/graph/list/text_field_function_title_cell.cpp @@ -4,10 +4,13 @@ namespace Graph { +static inline float min(float x, float y) { return (xy ? x : y); } + TextFieldFunctionTitleCell::TextFieldFunctionTitleCell(StorageListController * listController, Orientation orientation, const KDFont * font) : Shared::FunctionTitleCell(orientation), Responder(listController), - m_textField(Shared::StorageFunction::k_parenthesedArgumentWithEqualLength, this, m_textFieldBuffer, m_textFieldBuffer, k_textFieldBufferSize, nullptr, listController, false, font, 1.0f, 0.5f) + m_textField(Shared::StorageFunction::k_parenthesedArgumentWithEqualLength, this, m_textFieldBuffer, m_textFieldBuffer, k_textFieldBufferSize, nullptr, listController, false, font, k_horizontalAlignment, 0.5f) {} void TextFieldFunctionTitleCell::setHighlighted(bool highlight) { @@ -45,7 +48,11 @@ void TextFieldFunctionTitleCell::setText(const char * title) { } void TextFieldFunctionTitleCell::layoutSubviews() { - m_textField.setFrame(textFieldFrame()); + KDRect frame = textFieldFrame(); + m_textField.setFrame(frame); + KDCoordinate glyphHeight = font()->glyphSize().height(); + float verticalAlignment = max(0.0f, min(1.0f, m_baseline < 0 ? 0.5f : ((float)(m_baseline - glyphHeight/2))/((float)frame.height()+1-glyphHeight))); + m_textField.setAlignment(k_horizontalAlignment, verticalAlignment); } void TextFieldFunctionTitleCell::didBecomeFirstResponder() { diff --git a/apps/graph/list/text_field_function_title_cell.h b/apps/graph/list/text_field_function_title_cell.h index 29cb36a44..18fa43648 100644 --- a/apps/graph/list/text_field_function_title_cell.h +++ b/apps/graph/list/text_field_function_title_cell.h @@ -41,6 +41,7 @@ public: protected: KDRect textFieldFrame() const; private: + constexpr static float k_horizontalAlignment = 1.0f; constexpr static int k_textFieldBufferSize = Shared::StorageFunction::k_maxNameWithArgumentAndEqualSize; Shared::TextFieldWithExtension m_textField; char m_textFieldBuffer[k_textFieldBufferSize]; diff --git a/apps/shared/function_expression_cell.cpp b/apps/shared/function_expression_cell.cpp index 8b7df31a5..950ccc2a3 100644 --- a/apps/shared/function_expression_cell.cpp +++ b/apps/shared/function_expression_cell.cpp @@ -2,11 +2,6 @@ namespace Shared { -FunctionExpressionCell::FunctionExpressionCell() : - EvenOddExpressionCell() -{ -} - KDSize FunctionExpressionCell::minimalSizeForOptimalDisplay() const { KDSize expressionSize = m_expressionView.minimalSizeForOptimalDisplay(); return KDSize(m_leftMargin + expressionSize.width() + m_rightMargin, expressionSize.height()+k_separatorThickness); diff --git a/apps/shared/function_expression_cell.h b/apps/shared/function_expression_cell.h index 203e3cb82..b35b418f4 100644 --- a/apps/shared/function_expression_cell.h +++ b/apps/shared/function_expression_cell.h @@ -7,7 +7,7 @@ namespace Shared { class FunctionExpressionCell : public EvenOddExpressionCell { public: - FunctionExpressionCell(); + FunctionExpressionCell() : EvenOddExpressionCell() {} KDSize minimalSizeForOptimalDisplay() const override; void drawRect(KDContext * ctx, KDRect rect) const override; void layoutSubviews() override; diff --git a/escher/include/escher/even_odd_expression_cell.h b/escher/include/escher/even_odd_expression_cell.h index 5978cfca8..5a63bfc36 100644 --- a/escher/include/escher/even_odd_expression_cell.h +++ b/escher/include/escher/even_odd_expression_cell.h @@ -17,6 +17,7 @@ public: void setAlignment(float horizontalAlignment, float verticalAlignment) { m_expressionView.setAlignment(horizontalAlignment, verticalAlignment); } void setLeftMargin(KDCoordinate margin); void setRightMargin(KDCoordinate margin); + KDPoint drawingOrigin() const { return m_expressionView.drawingOrigin(); } Poincare::Layout layout() const override { return m_expressionView.layout(); } void drawRect(KDContext * ctx, KDRect rect) const override; protected: