all repos — mgba @ e0a6af087e83d79b53ad5352511c7e02c557b93f

mGBA Game Boy Advance Emulator

Qt: Adjust memory selection by shift-clicking
Jeffrey Pfau jeffrey@endrift.com
Sat, 04 Jul 2015 00:38:08 -0700
commit

e0a6af087e83d79b53ad5352511c7e02c557b93f

parent

abdf448f81da9f01a323ceef4cb00df9758d5002

1 files changed, 14 insertions(+), 6 deletions(-)

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

@@ -316,13 +316,21 @@ return;

} QPoint position(event->pos() - QPoint(m_margins.left(), m_margins.top())); - uint32_t address = - int(position.x() / m_cellSize.width()) + (int(position.y() / m_cellSize.height()) + m_top) * 16 + m_base; + uint32_t address = int(position.x() / m_cellSize.width()) + + (int(position.y() / m_cellSize.height()) + m_top) * 16 + m_base; if (event->button() == Qt::RightButton && isInSelection(address)) { return; } - m_selectionAnchor = address & ~(m_align - 1); - m_selection = qMakePair(m_selectionAnchor, m_selectionAnchor + m_align); + if (event->modifiers() & Qt::ShiftModifier) { + if ((address & ~(m_align - 1)) < m_selectionAnchor) { + m_selection = qMakePair(address & ~(m_align - 1), m_selectionAnchor + m_align); + } else { + m_selection = qMakePair(m_selectionAnchor, (address & ~(m_align - 1)) + m_align); + } + } else { + m_selectionAnchor = address & ~(m_align - 1); + m_selection = qMakePair(m_selectionAnchor, m_selectionAnchor + m_align); + } m_buffer = 0; m_bufferedNybbles = 0; emit selectionChanged(m_selection.first, m_selection.second);

@@ -336,8 +344,8 @@ return;

} QPoint position(event->pos() - QPoint(m_margins.left(), m_margins.top())); - uint32_t address = - int(position.x() / m_cellSize.width()) + (int(position.y() / m_cellSize.height()) + m_top) * 16 + m_base; + uint32_t address = int(position.x() / m_cellSize.width()) + + (int(position.y() / m_cellSize.height()) + m_top) * 16 + m_base; if ((address & ~(m_align - 1)) < m_selectionAnchor) { m_selection = qMakePair(address & ~(m_align - 1), m_selectionAnchor + m_align); } else {