mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[escher] Implement ScrollView::minimalSizeForOptimalDisplay including margins
Remove from derived classes: - apps/calculation/scrollable_expression_view - apps/code/consol_line_cell - apps/shared/scrollable_exact_approximate_expressions_view - escher/layout_field - escher/table_view - escher/text_field
This commit is contained in:
committed by
EmilieNumworks
parent
0e0b49acce
commit
08e8bf0eeb
@@ -20,8 +20,4 @@ void ScrollableExpressionView::setBackgroundColor(KDColor backgroundColor) {
|
||||
ScrollableView::setBackgroundColor(backgroundColor);
|
||||
}
|
||||
|
||||
KDSize ScrollableExpressionView::minimalSizeForOptimalDisplay() const {
|
||||
return m_expressionView.minimalSizeForOptimalDisplay();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -31,10 +31,6 @@ ConsoleLineCell::ScrollableConsoleLineView::ScrollableConsoleLineView(Responder
|
||||
{
|
||||
}
|
||||
|
||||
KDSize ConsoleLineCell::ScrollableConsoleLineView::minimalSizeForOptimalDisplay() const {
|
||||
return m_consoleLineView.minimalSizeForOptimalDisplay();
|
||||
}
|
||||
|
||||
ConsoleLineCell::ConsoleLineCell(Responder * parentResponder) :
|
||||
HighlightCell(),
|
||||
Responder(parentResponder),
|
||||
|
||||
@@ -48,7 +48,6 @@ private:
|
||||
};
|
||||
|
||||
ScrollableConsoleLineView(Responder * parentResponder);
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
ConsoleLineView * consoleLineView() { return &m_consoleLineView; }
|
||||
private:
|
||||
ConsoleLineView m_consoleLineView;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -138,8 +138,4 @@ bool ScrollableExactApproximateExpressionsView::handleEvent(Ion::Events::Event e
|
||||
return ScrollableView::handleEvent(event);
|
||||
}
|
||||
|
||||
KDSize ScrollableExactApproximateExpressionsView::minimalSizeForOptimalDisplay() const {
|
||||
return m_contentCell.minimalSizeForOptimalDisplay();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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' },
|
||||
|
||||
Reference in New Issue
Block a user