all repos — mgba @ edb91143d059c081ff1144f6c5559e1d05c29e34

mGBA Game Boy Advance Emulator

Qt: Memory view scrolling with cursor
Jeffrey Pfau jeffrey@endrift.com
Sat, 13 Jun 2015 22:05:49 -0700
commit

edb91143d059c081ff1144f6c5559e1d05c29e34

parent

750027a03caf2018525b06ab957586f29627c547

1 files changed, 12 insertions(+), 0 deletions(-)

jump to
M src/platform/qt/MemoryModel.cppsrc/platform/qt/MemoryModel.cpp

@@ -357,6 +357,7 @@ void MemoryModel::adjustCursor(int adjust, bool shift) {

if (m_selection.first >= m_selection.second) { return; } + int cursorPosition = m_top; if (shift) { if (m_selectionAnchor == m_selection.first) { if (adjust < 0 && m_base - adjust > m_selection.second) {

@@ -368,8 +369,10 @@ adjust += m_selection.second;

if (adjust <= m_selection.first) { m_selection.second = m_selection.first + m_align; m_selection.first = adjust - m_align; + cursorPosition = m_selection.first; } else { m_selection.second = adjust; + cursorPosition = m_selection.second; } } else { if (adjust < 0 && m_base - adjust > m_selection.first) {

@@ -381,10 +384,13 @@ adjust += m_selection.first;

if (adjust >= m_selection.second) { m_selection.first = m_selection.second - m_align; m_selection.second = adjust + m_align; + cursorPosition = m_selection.second; } else { m_selection.first = adjust; + cursorPosition = m_selection.first; } } + cursorPosition = (cursorPosition - m_base) / 16; } else { if (m_selectionAnchor == m_selection.first) { m_selectionAnchor = m_selection.second - m_align;

@@ -400,6 +406,12 @@ m_selectionAnchor += adjust;

} m_selection.first = m_selectionAnchor; m_selection.second = m_selection.first + m_align; + cursorPosition = (m_selectionAnchor - m_base) / 16; + } + if (cursorPosition < m_top) { + m_top = cursorPosition; + } else if (cursorPosition >= m_top + viewport()->size().height() / m_cellHeight - 1) { + m_top = cursorPosition - viewport()->size().height() / m_cellHeight + 2; } emit selectionChanged(m_selection.first, m_selection.second); viewport()->update();