mirror of https://github.com/mgba-emu/mgba.git
Qt: MemoryModel keyboard navigation
This commit is contained in:
parent
e9d8f1ca46
commit
de6808f3c8
|
@ -273,6 +273,18 @@ void MemoryModel::keyPressEvent(QKeyEvent* event) {
|
||||||
case Qt::Key_F:
|
case Qt::Key_F:
|
||||||
nybble = key - Qt::Key_A + 10;
|
nybble = key - Qt::Key_A + 10;
|
||||||
break;
|
break;
|
||||||
|
case Qt::Key_Left:
|
||||||
|
adjustCursor(-1, event->modifiers() & Qt::ShiftModifier);
|
||||||
|
return;
|
||||||
|
case Qt::Key_Right:
|
||||||
|
adjustCursor(1, event->modifiers() & Qt::ShiftModifier);
|
||||||
|
return;
|
||||||
|
case Qt::Key_Up:
|
||||||
|
adjustCursor(-16, event->modifiers() & Qt::ShiftModifier);
|
||||||
|
return;
|
||||||
|
case Qt::Key_Down:
|
||||||
|
adjustCursor(16, event->modifiers() & Qt::ShiftModifier);
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -340,3 +352,38 @@ void MemoryModel::drawEditingText(QPainter& painter, const QPointF& origin) {
|
||||||
o += QPointF(m_letterWidth * 2, 0);
|
o += QPointF(m_letterWidth * 2, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MemoryModel::adjustCursor(int adjust, bool shift) {
|
||||||
|
if (m_selection.first >= m_selection.second) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (shift) {
|
||||||
|
if (m_selectionAnchor == m_selection.first) {
|
||||||
|
adjust += m_selection.second;
|
||||||
|
if (adjust <= m_selection.first) {
|
||||||
|
m_selection.second = m_selection.first + 1;
|
||||||
|
m_selection.first = adjust - 1;
|
||||||
|
} else {
|
||||||
|
m_selection.second = adjust;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
adjust += m_selection.first;
|
||||||
|
if (adjust >= m_selection.second) {
|
||||||
|
m_selection.first = m_selection.second - 1;
|
||||||
|
m_selection.second = adjust + 1;
|
||||||
|
} else {
|
||||||
|
m_selection.first = adjust;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (m_selectionAnchor == m_selection.first) {
|
||||||
|
m_selectionAnchor = m_selection.second + shift - 1;
|
||||||
|
} else {
|
||||||
|
m_selectionAnchor = m_selection.first + shift;
|
||||||
|
}
|
||||||
|
m_selectionAnchor += adjust;
|
||||||
|
m_selection.first = m_selectionAnchor;
|
||||||
|
m_selection.second = m_selection.first + 1;
|
||||||
|
}
|
||||||
|
viewport()->update();
|
||||||
|
}
|
||||||
|
|
|
@ -53,6 +53,8 @@ private:
|
||||||
bool isEditing(uint32_t address);
|
bool isEditing(uint32_t address);
|
||||||
void drawEditingText(QPainter& painter, const QPointF& origin);
|
void drawEditingText(QPainter& painter, const QPointF& origin);
|
||||||
|
|
||||||
|
void adjustCursor(int adjust, bool shift);
|
||||||
|
|
||||||
ARMCore* m_cpu;
|
ARMCore* m_cpu;
|
||||||
QFont m_font;
|
QFont m_font;
|
||||||
int m_cellHeight;
|
int m_cellHeight;
|
||||||
|
|
Loading…
Reference in New Issue