diff --git a/apps/calculation/scrollable_expression_view.cpp b/apps/calculation/scrollable_expression_view.cpp index 35cfe08de..aa35d956f 100644 --- a/apps/calculation/scrollable_expression_view.cpp +++ b/apps/calculation/scrollable_expression_view.cpp @@ -20,8 +20,4 @@ void ScrollableExpressionView::setBackgroundColor(KDColor backgroundColor) { ScrollableView::setBackgroundColor(backgroundColor); } -KDSize ScrollableExpressionView::minimalSizeForOptimalDisplay() const { - return m_expressionView.minimalSizeForOptimalDisplay(); -} - } diff --git a/apps/calculation/scrollable_expression_view.h b/apps/calculation/scrollable_expression_view.h index d4ac8e330..78fc5ff56 100644 --- a/apps/calculation/scrollable_expression_view.h +++ b/apps/calculation/scrollable_expression_view.h @@ -10,7 +10,6 @@ public: ScrollableExpressionView(Responder * parentResponder); void setLayout(Poincare::Layout layout); void setBackgroundColor(KDColor backgroundColor) override; - KDSize minimalSizeForOptimalDisplay() const override; private: ExpressionView m_expressionView; }; diff --git a/apps/code/console_line_cell.cpp b/apps/code/console_line_cell.cpp index 7593591b1..5a696d57a 100644 --- a/apps/code/console_line_cell.cpp +++ b/apps/code/console_line_cell.cpp @@ -31,10 +31,6 @@ ConsoleLineCell::ScrollableConsoleLineView::ScrollableConsoleLineView(Responder { } -KDSize ConsoleLineCell::ScrollableConsoleLineView::minimalSizeForOptimalDisplay() const { - return m_consoleLineView.minimalSizeForOptimalDisplay(); -} - ConsoleLineCell::ConsoleLineCell(Responder * parentResponder) : HighlightCell(), Responder(parentResponder), diff --git a/apps/code/console_line_cell.h b/apps/code/console_line_cell.h index e192e82cc..8cb3ef58a 100644 --- a/apps/code/console_line_cell.h +++ b/apps/code/console_line_cell.h @@ -48,7 +48,6 @@ private: }; ScrollableConsoleLineView(Responder * parentResponder); - KDSize minimalSizeForOptimalDisplay() const override; ConsoleLineView * consoleLineView() { return &m_consoleLineView; } private: ConsoleLineView m_consoleLineView; diff --git a/apps/probability/parameters_controller.cpp b/apps/probability/parameters_controller.cpp index 1a2f82ffd..def7ab459 100644 --- a/apps/probability/parameters_controller.cpp +++ b/apps/probability/parameters_controller.cpp @@ -16,7 +16,7 @@ ParametersController::ContentView::ContentView(Responder * parentResponder, Sele } void ParametersController::ContentView::drawRect(KDContext * ctx, KDRect rect) const { - int tableHeight = m_selectableTableView->minimalSizeForOptimalDisplay().height()+ Metric::CommonTopMargin + Metric::CommonBottomMargin; + int tableHeight = m_selectableTableView->minimalSizeForOptimalDisplay().height(); ctx->fillRect(KDRect(0, tableHeight, bounds().width(), bounds().height() - tableHeight), Palette::WallScreen); } @@ -53,7 +53,7 @@ View * ParametersController::ContentView::subviewAtIndex(int index) { void ParametersController::ContentView::layoutSubviews() { KDCoordinate titleHeight = KDFont::SmallFont->glyphSize().height()+k_titleMargin; m_titleView.setFrame(KDRect(0, 0, bounds().width(), titleHeight)); - KDCoordinate tableHeight = m_selectableTableView->minimalSizeForOptimalDisplay().height() + Metric::CommonTopMargin + Metric::CommonBottomMargin; + KDCoordinate tableHeight = m_selectableTableView->minimalSizeForOptimalDisplay().height(); m_selectableTableView->setFrame(KDRect(0, titleHeight, bounds().width(), tableHeight)); KDCoordinate textHeight = KDFont::SmallFont->glyphSize().height(); KDCoordinate defOrigin = (titleHeight+tableHeight)/2+(bounds().height()-textHeight)/2; diff --git a/apps/shared/scrollable_exact_approximate_expressions_view.cpp b/apps/shared/scrollable_exact_approximate_expressions_view.cpp index 1a26b9709..8f29f1a6f 100644 --- a/apps/shared/scrollable_exact_approximate_expressions_view.cpp +++ b/apps/shared/scrollable_exact_approximate_expressions_view.cpp @@ -138,8 +138,4 @@ bool ScrollableExactApproximateExpressionsView::handleEvent(Ion::Events::Event e return ScrollableView::handleEvent(event); } -KDSize ScrollableExactApproximateExpressionsView::minimalSizeForOptimalDisplay() const { - return m_contentCell.minimalSizeForOptimalDisplay(); -} - } diff --git a/apps/shared/scrollable_exact_approximate_expressions_view.h b/apps/shared/scrollable_exact_approximate_expressions_view.h index 5f963ea75..3b4972edb 100644 --- a/apps/shared/scrollable_exact_approximate_expressions_view.h +++ b/apps/shared/scrollable_exact_approximate_expressions_view.h @@ -25,7 +25,6 @@ public: } void didBecomeFirstResponder() override; bool handleEvent(Ion::Events::Event event) override; - KDSize minimalSizeForOptimalDisplay() const override; Poincare::Layout layout() const { return m_contentCell.layout(); } diff --git a/escher/include/escher/layout_field.h b/escher/include/escher/layout_field.h index 343de5446..bb8a38927 100644 --- a/escher/include/escher/layout_field.h +++ b/escher/include/escher/layout_field.h @@ -43,12 +43,6 @@ public: return m_delegate->layoutFieldShouldFinishEditing(this, event); } - /* View */ - KDSize minimalSizeForOptimalDisplay() const override { - KDSize contentViewSize = m_contentView.minimalSizeForOptimalDisplay(); - return KDSize(contentViewSize.width(), contentViewSize.height()); - } - protected: void reload(KDSize previousSize); virtual bool privateHandleEvent(Ion::Events::Event event); diff --git a/escher/include/escher/scroll_view.h b/escher/include/escher/scroll_view.h index a3e5faf3e..57e7b385e 100644 --- a/escher/include/escher/scroll_view.h +++ b/escher/include/escher/scroll_view.h @@ -8,6 +8,7 @@ class ScrollView : public View { public: ScrollView(View * contentView, ScrollViewDataSource * dataSource); + KDSize minimalSizeForOptimalDisplay() const override; void setTopMargin(KDCoordinate m) { m_topMargin = m; } KDCoordinate topMargin() const { return m_topMargin; } diff --git a/escher/include/escher/table_view.h b/escher/include/escher/table_view.h index eb7010306..7fde8754c 100644 --- a/escher/include/escher/table_view.h +++ b/escher/include/escher/table_view.h @@ -20,7 +20,6 @@ public: virtual void scrollToCell(int i, int j); HighlightCell * cellAtLocation(int i, int j); void reloadCellAtLocation(int i, int j); - KDSize minimalSizeForOptimalDisplay() const override; protected: #if ESCHER_VIEW_LOGGING const char * className() const override; diff --git a/escher/include/escher/text_field.h b/escher/include/escher/text_field.h index f04e5772a..49b488747 100644 --- a/escher/include/escher/text_field.h +++ b/escher/include/escher/text_field.h @@ -20,7 +20,6 @@ public: void setText(const char * text); void setAlignment(float horizontalAlignment, float verticalAlignment); virtual void setEditing(bool isEditing, bool reinitDraftBuffer = true) override; - KDSize minimalSizeForOptimalDisplay() const override; char XNTChar(char defaultXNTChar) override; bool handleEventWithText(const char * text, bool indentation = false, bool forceCursorRightOfText = false) override; bool handleEvent(Ion::Events::Event event) override; diff --git a/escher/src/scroll_view.cpp b/escher/src/scroll_view.cpp index 7a519ff70..2539ea0fa 100644 --- a/escher/src/scroll_view.cpp +++ b/escher/src/scroll_view.cpp @@ -24,6 +24,14 @@ ScrollView::ScrollView(View * contentView, ScrollViewDataSource * dataSource) : assert(m_dataSource != nullptr); } +KDSize ScrollView::minimalSizeForOptimalDisplay() const { + KDSize contentSize = m_contentView->minimalSizeForOptimalDisplay(); + return KDSize( + contentSize.width() + m_leftMargin + m_rightMargin, + contentSize.height() + m_topMargin + m_bottomMargin + ); +} + void ScrollView::setCommonMargins() { setTopMargin(Metric::CommonTopMargin); setRightMargin(Metric::CommonRightMargin); @@ -68,8 +76,8 @@ void ScrollView::scrollToContentPoint(KDPoint p, bool allowOverscroll) { /* Handle cases when the size of the view has decreased. */ setContentOffset(KDPoint( - min(contentOffset().x(), max(contentSize().width() - maxContentWidthDisplayableWithoutScrolling(), 0)), - min(contentOffset().y(), max(contentSize().height() - maxContentHeightDisplayableWithoutScrolling(), 0)) + min(contentOffset().x(), max(minimalSizeForOptimalDisplay().width() - bounds().width(), 0)), + min(contentOffset().y(), max(minimalSizeForOptimalDisplay().height() - bounds().height(), 0)) )); } @@ -92,11 +100,7 @@ void ScrollView::layoutSubviews() { KDPoint absoluteOffset = contentOffset().opposite().translatedBy(KDPoint(m_leftMargin, m_topMargin)); KDRect contentFrame = KDRect(absoluteOffset, contentSize()); m_contentView->setFrame(contentFrame); - KDSize content( - m_contentView->bounds().width() + m_leftMargin + m_rightMargin, - m_contentView->bounds().height() + m_topMargin + m_bottomMargin - ); - decorator()->layoutIndicators(content, contentOffset(), m_frame.size()); + decorator()->layoutIndicators(minimalSizeForOptimalDisplay(), contentOffset(), m_frame.size()); } void ScrollView::setContentOffset(KDPoint offset, bool forceRelayout) { diff --git a/escher/src/scrollable_view.cpp b/escher/src/scrollable_view.cpp index 1faeab4c4..f2781fa32 100644 --- a/escher/src/scrollable_view.cpp +++ b/escher/src/scrollable_view.cpp @@ -19,7 +19,7 @@ bool ScrollableView::handleEvent(Ion::Events::Event event) { } } if (event == Ion::Events::Right) { - KDCoordinate movementToEdge = m_contentView->minimalSizeForOptimalDisplay().width() - bounds().width() - m_manualScrollingOffset.x(); + KDCoordinate movementToEdge = minimalSizeForOptimalDisplay().width() - bounds().width() - m_manualScrollingOffset.x(); if (movementToEdge > 0) { translation = KDPoint(min(Metric::ScrollStep, movementToEdge), 0); } @@ -31,7 +31,7 @@ bool ScrollableView::handleEvent(Ion::Events::Event event) { } } if (event == Ion::Events::Down) { - KDCoordinate movementToEdge = m_contentView->minimalSizeForOptimalDisplay().height() - bounds().height() - m_manualScrollingOffset.y(); + KDCoordinate movementToEdge = minimalSizeForOptimalDisplay().height() - bounds().height() - m_manualScrollingOffset.y(); if (movementToEdge > 0) { translation = KDPoint(0, min(Metric::ScrollStep, movementToEdge)); } diff --git a/escher/src/table_view.cpp b/escher/src/table_view.cpp index 9a9d2ef28..adb859b8d 100644 --- a/escher/src/table_view.cpp +++ b/escher/src/table_view.cpp @@ -13,10 +13,6 @@ TableView::TableView(TableViewDataSource * dataSource, ScrollViewDataSource * sc { } -KDSize TableView::minimalSizeForOptimalDisplay() const { - return m_contentView.minimalSizeForOptimalDisplay(); -} - TableViewDataSource * TableView::dataSource() { return m_contentView.dataSource(); } diff --git a/escher/src/text_field.cpp b/escher/src/text_field.cpp index bd0cb88b9..7f21bcfc6 100644 --- a/escher/src/text_field.cpp +++ b/escher/src/text_field.cpp @@ -312,10 +312,6 @@ bool TextField::privateHandleEvent(Ion::Events::Event event) { return false; } -KDSize TextField::minimalSizeForOptimalDisplay() const { - return m_contentView.minimalSizeForOptimalDisplay(); -} - char TextField::XNTChar(char defaultXNTChar) { static constexpr struct { const char *name; char xnt; } sFunctions[] = { { "diff", 'x' }, { "int", 'x' },