mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[escher/layout_field] Fix cursor position on Empty layout
Scenario: In the calculations app, write 1, Enter, write •|/2, go up, then go down. There is a problem with the empty layout and the cursor.
This commit is contained in:
@@ -21,7 +21,7 @@ public:
|
||||
{}
|
||||
void setDelegates(InputEventHandlerDelegate * inputEventHandlerDelegate, LayoutFieldDelegate * delegate) { m_inputEventHandlerDelegate = inputEventHandlerDelegate; m_delegate = delegate; }
|
||||
bool isEditing() const override { return m_contentView.isEditing(); }
|
||||
void setEditing(bool isEditing) override { m_contentView.setEditing(isEditing); }
|
||||
void setEditing(bool isEditing) override;
|
||||
void clearLayout() { m_contentView.clearLayout(); }
|
||||
void scrollToCursor() {
|
||||
scrollToBaselinedRect(m_contentView.cursorRect(), m_contentView.cursor()->baseline());
|
||||
@@ -59,7 +59,7 @@ private:
|
||||
public:
|
||||
ContentView();
|
||||
bool isEditing() const { return m_isEditing; }
|
||||
void setEditing(bool isEditing);
|
||||
bool setEditing(bool isEditing); // returns True if LayoutField should reload
|
||||
void setBackgroundColor(KDColor c) { m_expressionView.setBackgroundColor(c); }
|
||||
void setCursor(Poincare::LayoutCursor cursor) { m_cursor = cursor; }
|
||||
void cursorPositionChanged() { layoutCursorSubview(); }
|
||||
|
||||
@@ -19,10 +19,20 @@ LayoutField::ContentView::ContentView() :
|
||||
clearLayout();
|
||||
}
|
||||
|
||||
void LayoutField::ContentView::setEditing(bool isEditing) {
|
||||
bool LayoutField::ContentView::setEditing(bool isEditing) {
|
||||
m_isEditing = isEditing;
|
||||
markRectAsDirty(bounds());
|
||||
if (isEditing) {
|
||||
/* showEmptyLayoutIfNeeded is done in LayoutField::handleEvent, so no need
|
||||
* to do it here. */
|
||||
if (m_cursor.hideEmptyLayoutIfNeeded()) {
|
||||
m_expressionView.layout().invalidAllSizesPositionsAndBaselines();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
layoutSubviews();
|
||||
markRectAsDirty(bounds());
|
||||
return false;
|
||||
}
|
||||
|
||||
void LayoutField::ContentView::clearLayout() {
|
||||
@@ -70,6 +80,13 @@ void LayoutField::ContentView::layoutCursorSubview() {
|
||||
m_cursorView.setFrame(KDRect(cursorTopLeftPosition, LayoutCursor::k_cursorWidth, m_cursor.cursorHeight()));
|
||||
}
|
||||
|
||||
void LayoutField::setEditing(bool isEditing) {
|
||||
KDSize previousLayoutSize = m_contentView.minimalSizeForOptimalDisplay();
|
||||
if (m_contentView.setEditing(isEditing)) {
|
||||
reload(previousLayoutSize);
|
||||
}
|
||||
}
|
||||
|
||||
CodePoint LayoutField::XNTCodePoint(CodePoint defaultXNTCodePoint) {
|
||||
CodePoint xnt = m_contentView.cursor()->layoutReference().XNTCodePoint();
|
||||
if (xnt != UCodePointNull) {
|
||||
@@ -143,9 +160,9 @@ bool LayoutField::handleEventWithText(const char * text, bool indentation, bool
|
||||
|
||||
bool LayoutField::handleEvent(Ion::Events::Event event) {
|
||||
bool didHandleEvent = false;
|
||||
KDSize previousSize = minimalSizeForOptimalDisplay();
|
||||
bool shouldRecomputeLayout = m_contentView.cursor()->showEmptyLayoutIfNeeded();
|
||||
bool moveEventChangedLayout = false;
|
||||
KDSize previousSize = minimalSizeForOptimalDisplay();
|
||||
if (privateHandleMoveEvent(event, &moveEventChangedLayout)) {
|
||||
if (!isEditing()) {
|
||||
setEditing(true);
|
||||
|
||||
Reference in New Issue
Block a user