mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[escher] TextField: force layout after scroll reload when the content
size of scrollview might have changed
This commit is contained in:
committed by
EmilieNumworks
parent
4af6e71e21
commit
2b0b40d6d6
@@ -14,7 +14,7 @@ public:
|
||||
KDColor indicatorColor = Palette::GreyDark, KDColor backgroundIndicatorColor = Palette::GreyMiddle,
|
||||
KDCoordinate indicatorMargin = 14);
|
||||
|
||||
void setContentOffset(KDPoint offset);
|
||||
void setContentOffset(KDPoint offset, bool forceRelayout = false);
|
||||
KDPoint contentOffset() const;
|
||||
KDCoordinate topMargin() const;
|
||||
KDCoordinate leftMargin() const;
|
||||
|
||||
@@ -8,7 +8,7 @@ class ScrollableView : public Responder, public ScrollView {
|
||||
public:
|
||||
ScrollableView(Responder * parentResponder, View * view, ScrollViewDataSource * dataSource);
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
void reloadScroll();
|
||||
void reloadScroll(bool forceRelayout = false);
|
||||
protected:
|
||||
void layoutSubviews() override;
|
||||
KDPoint m_manualScrollingOffset;
|
||||
|
||||
@@ -189,8 +189,8 @@ KDSize ScrollView::contentSize() {
|
||||
return m_contentView->minimalSizeForOptimalDisplay();
|
||||
}
|
||||
|
||||
void ScrollView::setContentOffset(KDPoint offset) {
|
||||
if (m_dataSource->setOffset(offset)) {
|
||||
void ScrollView::setContentOffset(KDPoint offset, bool forceRelayout) {
|
||||
if (m_dataSource->setOffset(offset) || forceRelayout) {
|
||||
layoutSubviews();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ bool ScrollableView::handleEvent(Ion::Events::Event event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void ScrollableView::reloadScroll() {
|
||||
void ScrollableView::reloadScroll(bool forceReLayout) {
|
||||
m_manualScrollingOffset = KDPointZero;
|
||||
setContentOffset(m_manualScrollingOffset);
|
||||
setContentOffset(m_manualScrollingOffset, forceReLayout);
|
||||
}
|
||||
|
||||
void ScrollableView::layoutSubviews() {
|
||||
|
||||
@@ -312,7 +312,7 @@ bool TextField::privateHandleEvent(Ion::Events::Event event) {
|
||||
int cursorLoc = cursorLocation();
|
||||
setEditing(false, m_hasTwoBuffers);
|
||||
if (m_delegate->textFieldDidFinishEditing(this, text(), event)) {
|
||||
reloadScroll();
|
||||
reloadScroll(true);
|
||||
return true;
|
||||
}
|
||||
/* if the text was refused (textFieldDidFinishEditing returned false, we
|
||||
|
||||
Reference in New Issue
Block a user