mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[escher] Moved repetition factor logic up in Escher from poincare
Change-Id: I7c8f932e3e7d04c928ca881113ba6b5df05b94e7
This commit is contained in:
committed by
LeaNumworks
parent
b69f06b772
commit
636e863323
@@ -641,20 +641,23 @@ bool LayoutField::privateHandleSelectionEvent(Ion::Events::Event event, bool * s
|
||||
if (!IsSelectionEvent(event)) {
|
||||
return false;
|
||||
}
|
||||
Layout addedSelection;
|
||||
int step = Ion::Events::repetitionFactor();
|
||||
LayoutCursor result = m_contentView.cursor()->selectAtDirection(
|
||||
DirectionForSelectionEvent(event),
|
||||
shouldRecomputeLayout,
|
||||
&addedSelection,
|
||||
step
|
||||
);
|
||||
if (addedSelection.isUninitialized()) {
|
||||
return false;
|
||||
// Selection is handled one step at a time. Repeat selection for each step.
|
||||
for (int i = 0; i < step; ++i) {
|
||||
Layout addedSelection;
|
||||
LayoutCursor result = m_contentView.cursor()->selectAtDirection(
|
||||
DirectionForSelectionEvent(event),
|
||||
shouldRecomputeLayout,
|
||||
&addedSelection
|
||||
);
|
||||
if (addedSelection.isUninitialized()) {
|
||||
// Successful event if at least one step succeeded.
|
||||
return i > 0;
|
||||
}
|
||||
m_contentView.addSelection(addedSelection);
|
||||
assert(result.isDefined());
|
||||
m_contentView.setCursor(result);
|
||||
}
|
||||
m_contentView.addSelection(addedSelection);
|
||||
assert(result.isDefined());
|
||||
m_contentView.setCursor(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
|
||||
/* Select */
|
||||
void select(Direction direction, bool * shouldRecomputeLayout, Layout * selection);
|
||||
LayoutCursor selectAtDirection(Direction direction, bool * shouldRecomputeLayout, Layout * selection, int step = 1);
|
||||
LayoutCursor selectAtDirection(Direction direction, bool * shouldRecomputeLayout, Layout * selection);
|
||||
|
||||
/* Layout modification */
|
||||
void addEmptyExponentialLayout();
|
||||
|
||||
@@ -106,33 +106,9 @@ void LayoutCursor::select(Direction direction, bool * shouldRecomputeLayout, Lay
|
||||
}
|
||||
}
|
||||
|
||||
LayoutCursor LayoutCursor::selectAtDirection(Direction direction, bool * shouldRecomputeLayout, Layout * selection, int step) {
|
||||
LayoutCursor LayoutCursor::selectAtDirection(Direction direction, bool * shouldRecomputeLayout, Layout * selection) {
|
||||
LayoutCursor result = clone();
|
||||
if (step <= 0) {
|
||||
return result;
|
||||
}
|
||||
// First step
|
||||
result.select(direction, shouldRecomputeLayout, selection);
|
||||
|
||||
if (step == 1 || selection->isUninitialized()) {
|
||||
// If first step failed, result is returned so the situation is handled
|
||||
return result;
|
||||
}
|
||||
// Otherwise, as many steps as possible are performed
|
||||
// Shallow copy to temporary variables
|
||||
LayoutCursor result_temp = result;
|
||||
Layout selection_temp = *selection;
|
||||
for (int i = 1; i < step; ++i) {
|
||||
result_temp.select(direction, shouldRecomputeLayout, &selection_temp);
|
||||
if (selection_temp.isUninitialized()) {
|
||||
// Return last successful result
|
||||
return result;
|
||||
}
|
||||
// Update last successful result
|
||||
result = result_temp;
|
||||
*selection = selection_temp;
|
||||
assert(result.isDefined());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user