mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[escher/layout_field] Use IsMoveEvent
This commit is contained in:
committed by
LeaNumworks
parent
ec4def61c3
commit
64a1094edf
@@ -430,6 +430,30 @@ void LayoutField::deleteSelection() {
|
||||
m_contentView.deleteSelection();
|
||||
}
|
||||
|
||||
#define static_assert_immediately_follows(a, b) static_assert( \
|
||||
static_cast<uint8_t>(a) + 1 == static_cast<uint8_t>(b), \
|
||||
"Ordering error" \
|
||||
)
|
||||
|
||||
#define static_assert_sequential(a, b, c, d) \
|
||||
static_assert_immediately_follows(a, b); \
|
||||
static_assert_immediately_follows(b, c); \
|
||||
static_assert_immediately_follows(c, d);
|
||||
|
||||
|
||||
static_assert_sequential(
|
||||
Ion::Events::Left,
|
||||
Ion::Events::Up,
|
||||
Ion::Events::Down,
|
||||
Ion::Events::Right
|
||||
);
|
||||
|
||||
static inline bool IsMoveEvent(Ion::Events::Event event) {
|
||||
return
|
||||
static_cast<uint8_t>(event) >= static_cast<uint8_t>(Ion::Events::Left) &&
|
||||
static_cast<uint8_t>(event) <= static_cast<uint8_t>(Ion::Events::Right);
|
||||
}
|
||||
|
||||
bool LayoutField::privateHandleEvent(Ion::Events::Event event) {
|
||||
if (m_delegate && m_delegate->layoutFieldDidReceiveEvent(this, event)) {
|
||||
return true;
|
||||
@@ -454,7 +478,7 @@ bool LayoutField::privateHandleEvent(Ion::Events::Event event) {
|
||||
/* if move event was not caught neither by privateHandleMoveEvent nor by
|
||||
* layoutFieldShouldFinishEditing, we handle it here to avoid bubbling the
|
||||
* event up. */
|
||||
if ((event == Ion::Events::Up || event == Ion::Events::Down || event == Ion::Events::Left || event == Ion::Events::Right) && isEditing()) {
|
||||
if (IsMoveEvent(event) && isEditing()) {
|
||||
return true;
|
||||
}
|
||||
if ((event == Ion::Events::OK || event == Ion::Events::EXE) && !isEditing()) {
|
||||
@@ -503,15 +527,6 @@ bool LayoutField::privateHandleEvent(Ion::Events::Event event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#define static_assert_immediately_follows(a, b) static_assert( \
|
||||
static_cast<uint8_t>(a) + 1 == static_cast<uint8_t>(b), \
|
||||
"Ordering error" \
|
||||
)
|
||||
|
||||
#define static_assert_sequential(a, b, c, d) \
|
||||
static_assert_immediately_follows(a, b); \
|
||||
static_assert_immediately_follows(b, c); \
|
||||
static_assert_immediately_follows(c, d);
|
||||
|
||||
static_assert_sequential(
|
||||
LayoutCursor::Direction::Left,
|
||||
@@ -520,18 +535,6 @@ static_assert_sequential(
|
||||
LayoutCursor::Direction::Right
|
||||
);
|
||||
|
||||
static_assert_sequential(
|
||||
Ion::Events::Left,
|
||||
Ion::Events::Up,
|
||||
Ion::Events::Down,
|
||||
Ion::Events::Right
|
||||
);
|
||||
|
||||
static inline bool IsMoveEvent(Ion::Events::Event event) {
|
||||
return
|
||||
static_cast<uint8_t>(event) >= static_cast<uint8_t>(Ion::Events::Left) &&
|
||||
static_cast<uint8_t>(event) <= static_cast<uint8_t>(Ion::Events::Right);
|
||||
}
|
||||
|
||||
static inline LayoutCursor::Direction DirectionForMoveEvent(Ion::Events::Event event) {
|
||||
assert(IsMoveEvent(event));
|
||||
|
||||
Reference in New Issue
Block a user