diff --git a/escher/src/layout_field.cpp b/escher/src/layout_field.cpp index b3b77e22a..a33300bc1 100644 --- a/escher/src/layout_field.cpp +++ b/escher/src/layout_field.cpp @@ -453,14 +453,14 @@ bool LayoutField::privateHandleMoveEvent(Ion::Events::Event event, bool * should } LayoutCursor result; if (event == Ion::Events::Left) { - result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::MoveDirection::Left, shouldRecomputeLayout); + result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::Direction::Left, shouldRecomputeLayout); } else if (event == Ion::Events::Right) { - result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::MoveDirection::Right, shouldRecomputeLayout); + result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::Direction::Right, shouldRecomputeLayout); } else if (event == Ion::Events::Up) { - result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::MoveDirection::Up, shouldRecomputeLayout); + result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::Direction::Up, shouldRecomputeLayout); } else { assert(event == Ion::Events::Down); - result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::MoveDirection::Down, shouldRecomputeLayout); + result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::Direction::Down, shouldRecomputeLayout); } if (result.isDefined()) { m_contentView.setCursor(result); @@ -477,10 +477,10 @@ bool LayoutField::privateHandleSelectionEvent(Ion::Events::Event event, bool * s LayoutCursor result; if (eventIsSelection(event)) { Layout addedSelection; - LayoutCursor::MoveDirection direction = event == Ion::Events::ShiftLeft ? LayoutCursor::MoveDirection::Left : - (event == Ion::Events::ShiftRight ? LayoutCursor::MoveDirection::Right : - (event == Ion::Events::ShiftUp ? LayoutCursor::MoveDirection::Up : - LayoutCursor::MoveDirection::Down)); + LayoutCursor::Direction direction = event == Ion::Events::ShiftLeft ? LayoutCursor::Direction::Left : + (event == Ion::Events::ShiftRight ? LayoutCursor::Direction::Right : + (event == Ion::Events::ShiftUp ? LayoutCursor::Direction::Up : + LayoutCursor::Direction::Down)); result = m_contentView.cursor()->selectAtDirection(direction, shouldRecomputeLayout, &addedSelection); if (addedSelection.isUninitialized()) { return false; diff --git a/poincare/include/poincare/layout_cursor.h b/poincare/include/poincare/layout_cursor.h index 42010e00c..3611687b6 100644 --- a/poincare/include/poincare/layout_cursor.h +++ b/poincare/include/poincare/layout_cursor.h @@ -27,7 +27,7 @@ class LayoutCursor final { public: constexpr static KDCoordinate k_cursorWidth = 1; - enum class MoveDirection { //TODO LEA rename direction? + enum class Direction { Left, Right, Up, @@ -82,7 +82,7 @@ public: KDPoint middleLeftPoint(); /* Move */ - void move(MoveDirection direction, bool * shouldRecomputeLayout); + void move(Direction direction, bool * shouldRecomputeLayout); void moveLeft(bool * shouldRecomputeLayout) { layoutNode()->moveCursorLeft(this, shouldRecomputeLayout); } @@ -95,15 +95,15 @@ public: void moveUnder(bool * shouldRecomputeLayout) { layoutNode()->moveCursorDown(this, shouldRecomputeLayout); } - LayoutCursor cursorAtDirection(MoveDirection direction, bool * shouldRecomputeLayout) { + LayoutCursor cursorAtDirection(Direction direction, bool * shouldRecomputeLayout) { LayoutCursor result = clone(); result.move(direction, shouldRecomputeLayout); return result; } /* Select */ - void select(MoveDirection direction, bool * shouldRecomputeLayout, Layout * selection); - LayoutCursor selectAtDirection(MoveDirection direction, bool * shouldRecomputeLayout, Layout * selection) { + void select(Direction direction, bool * shouldRecomputeLayout, Layout * selection); + LayoutCursor selectAtDirection(Direction direction, bool * shouldRecomputeLayout, Layout * selection) { LayoutCursor result = clone(); result.select(direction, shouldRecomputeLayout, selection); return result; diff --git a/poincare/src/layout_cursor.cpp b/poincare/src/layout_cursor.cpp index 2da3caf87..553068739 100644 --- a/poincare/src/layout_cursor.cpp +++ b/poincare/src/layout_cursor.cpp @@ -58,14 +58,14 @@ KDPoint LayoutCursor::middleLeftPoint() { } /* Move */ -void LayoutCursor::move(MoveDirection direction, bool * shouldRecomputeLayout) { - if (direction == MoveDirection::Left) { +void LayoutCursor::move(Direction direction, bool * shouldRecomputeLayout) { + if (direction == Direction::Left) { moveLeft(shouldRecomputeLayout); - } else if (direction == MoveDirection::Right) { + } else if (direction == Direction::Right) { moveRight(shouldRecomputeLayout); - } else if (direction == MoveDirection::Up) { + } else if (direction == Direction::Up) { moveAbove(shouldRecomputeLayout); - } else if (direction == MoveDirection::Down) { + } else if (direction == Direction::Down) { moveUnder(shouldRecomputeLayout); } else { assert(false); @@ -74,11 +74,11 @@ void LayoutCursor::move(MoveDirection direction, bool * shouldRecomputeLayout) { /* Select */ -void LayoutCursor::select(MoveDirection direction, bool * shouldRecomputeLayout, Layout * selection) { - if (direction == MoveDirection::Right || direction == MoveDirection::Left) { - selectLeftRight(direction == MoveDirection::Right, shouldRecomputeLayout, selection); +void LayoutCursor::select(Direction direction, bool * shouldRecomputeLayout, Layout * selection) { + if (direction == Direction::Right || direction == Direction::Left) { + selectLeftRight(direction == Direction::Right, shouldRecomputeLayout, selection); } else { - selectUpDown(direction == MoveDirection::Up, shouldRecomputeLayout, selection); + selectUpDown(direction == Direction::Up, shouldRecomputeLayout, selection); } *shouldRecomputeLayout = true; } @@ -361,7 +361,7 @@ void LayoutCursor::selectLeftRight(bool right, bool * shouldRecomputeLayout, Lay void LayoutCursor::selectUpDown(bool up, bool * shouldRecomputeLayout, Layout * selection) { // Move the cursor in the selection direction - LayoutCursor c = cursorAtDirection(up ? MoveDirection::Up : MoveDirection::Down, shouldRecomputeLayout); + LayoutCursor c = cursorAtDirection(up ? Direction::Up : Direction::Down, shouldRecomputeLayout); if (!c.isDefined()) { return; }