ux: Fixed another hex editor scroll issue
This commit is contained in:
parent
e5ff987392
commit
efed07ac8b
@ -66,6 +66,10 @@ namespace hex::plugin::builtin {
|
|||||||
this->m_shouldScrollToSelection = true;
|
this->m_shouldScrollToSelection = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void jumpIfOffScreen() {
|
||||||
|
this->m_shouldJumpWhenOffScreen = true;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class Popup {
|
class Popup {
|
||||||
public:
|
public:
|
||||||
@ -105,6 +109,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
bool m_shouldJumpToSelection = false;
|
bool m_shouldJumpToSelection = false;
|
||||||
bool m_shouldScrollToSelection = false;
|
bool m_shouldScrollToSelection = false;
|
||||||
|
bool m_shouldJumpWhenOffScreen = false;
|
||||||
|
|
||||||
bool m_selectionChanged = false;
|
bool m_selectionChanged = false;
|
||||||
u64 m_selectionStart = InvalidSelection;
|
u64 m_selectionStart = InvalidSelection;
|
||||||
|
@ -845,7 +845,9 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the cursor is off-screen, directly jump to the byte
|
// If the cursor is off-screen, directly jump to the byte
|
||||||
if (!ImGui::IsMouseDown(ImGuiMouseButton_Left)) {
|
if (this->m_shouldJumpWhenOffScreen) {
|
||||||
|
this->m_shouldJumpWhenOffScreen = false;
|
||||||
|
|
||||||
const auto newSelection = this->getSelection();
|
const auto newSelection = this->getSelection();
|
||||||
if (newSelection.getStartAddress() < u64(clipper.DisplayStart * this->m_bytesPerRow))
|
if (newSelection.getStartAddress() < u64(clipper.DisplayStart * this->m_bytesPerRow))
|
||||||
this->jumpToSelection();
|
this->jumpToSelection();
|
||||||
@ -1059,24 +1061,28 @@ namespace hex::plugin::builtin {
|
|||||||
auto pos = this->m_selectionEnd - this->m_bytesPerRow;
|
auto pos = this->m_selectionEnd - this->m_bytesPerRow;
|
||||||
this->setSelection(pos, pos);
|
this->setSelection(pos, pos);
|
||||||
this->scrollToSelection();
|
this->scrollToSelection();
|
||||||
|
this->jumpIfOffScreen();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ShortcutManager::addShortcut(this, Keys::Down, [this] {
|
ShortcutManager::addShortcut(this, Keys::Down, [this] {
|
||||||
auto pos = this->m_selectionEnd + this->m_bytesPerRow;
|
auto pos = this->m_selectionEnd + this->m_bytesPerRow;
|
||||||
this->setSelection(pos, pos);
|
this->setSelection(pos, pos);
|
||||||
this->scrollToSelection();
|
this->scrollToSelection();
|
||||||
|
this->jumpIfOffScreen();
|
||||||
});
|
});
|
||||||
ShortcutManager::addShortcut(this, Keys::Left, [this] {
|
ShortcutManager::addShortcut(this, Keys::Left, [this] {
|
||||||
if (this->m_selectionEnd > 0) {
|
if (this->m_selectionEnd > 0) {
|
||||||
auto pos = this->m_selectionEnd - 1;
|
auto pos = this->m_selectionEnd - 1;
|
||||||
this->setSelection(pos, pos);
|
this->setSelection(pos, pos);
|
||||||
this->scrollToSelection();
|
this->scrollToSelection();
|
||||||
|
this->jumpIfOffScreen();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ShortcutManager::addShortcut(this, Keys::Right, [this] {
|
ShortcutManager::addShortcut(this, Keys::Right, [this] {
|
||||||
auto pos = this->m_selectionEnd + 1;
|
auto pos = this->m_selectionEnd + 1;
|
||||||
this->setSelection(pos, pos);
|
this->setSelection(pos, pos);
|
||||||
this->scrollToSelection();
|
this->scrollToSelection();
|
||||||
|
this->jumpIfOffScreen();
|
||||||
});
|
});
|
||||||
|
|
||||||
ShortcutManager::addShortcut(this, Keys::PageUp, [this] {
|
ShortcutManager::addShortcut(this, Keys::PageUp, [this] {
|
||||||
@ -1085,32 +1091,37 @@ namespace hex::plugin::builtin {
|
|||||||
auto pos = this->m_selectionEnd - visibleByteCount;
|
auto pos = this->m_selectionEnd - visibleByteCount;
|
||||||
this->setSelection(pos, pos);
|
this->setSelection(pos, pos);
|
||||||
this->scrollToSelection();
|
this->scrollToSelection();
|
||||||
|
this->jumpIfOffScreen();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ShortcutManager::addShortcut(this, Keys::PageDown, [this] {
|
ShortcutManager::addShortcut(this, Keys::PageDown, [this] {
|
||||||
auto pos = this->m_selectionEnd + (this->m_bytesPerRow * this->m_visibleRowCount);
|
auto pos = this->m_selectionEnd + (this->m_bytesPerRow * this->m_visibleRowCount);
|
||||||
this->setSelection(pos, pos);
|
this->setSelection(pos, pos);
|
||||||
this->scrollToSelection();
|
this->scrollToSelection();
|
||||||
|
this->jumpIfOffScreen();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Move selection around
|
// Move selection around
|
||||||
ShortcutManager::addShortcut(this, SHIFT + Keys::Up, [this] {
|
ShortcutManager::addShortcut(this, SHIFT + Keys::Up, [this] {
|
||||||
this->setSelection(this->m_selectionEnd - this->m_bytesPerRow, this->m_selectionEnd);
|
this->setSelection(this->m_selectionEnd - this->m_bytesPerRow, this->m_selectionEnd);
|
||||||
this->scrollToSelection();
|
this->scrollToSelection();
|
||||||
|
this->jumpIfOffScreen();
|
||||||
});
|
});
|
||||||
ShortcutManager::addShortcut(this, SHIFT + Keys::Down, [this] {
|
ShortcutManager::addShortcut(this, SHIFT + Keys::Down, [this] {
|
||||||
this->setSelection(this->m_selectionEnd + this->m_bytesPerRow, this->m_selectionEnd);
|
this->setSelection(this->m_selectionEnd + this->m_bytesPerRow, this->m_selectionEnd);
|
||||||
this->scrollToSelection();
|
this->scrollToSelection();
|
||||||
|
this->jumpIfOffScreen();
|
||||||
|
|
||||||
});
|
});
|
||||||
ShortcutManager::addShortcut(this, SHIFT + Keys::Left, [this] {
|
ShortcutManager::addShortcut(this, SHIFT + Keys::Left, [this] {
|
||||||
this->setSelection(this->m_selectionEnd - 1, this->m_selectionEnd);
|
this->setSelection(this->m_selectionEnd - 1, this->m_selectionEnd);
|
||||||
this->scrollToSelection();
|
this->scrollToSelection();
|
||||||
|
this->jumpIfOffScreen();
|
||||||
});
|
});
|
||||||
ShortcutManager::addShortcut(this, SHIFT + Keys::Right, [this] {
|
ShortcutManager::addShortcut(this, SHIFT + Keys::Right, [this] {
|
||||||
this->setSelection(this->m_selectionEnd + 1, this->m_selectionEnd);
|
this->setSelection(this->m_selectionEnd + 1, this->m_selectionEnd);
|
||||||
this->scrollToSelection();
|
this->scrollToSelection();
|
||||||
|
this->jumpIfOffScreen();
|
||||||
});
|
});
|
||||||
|
|
||||||
ShortcutManager::addShortcut(this, CTRL + Keys::G, [this] {
|
ShortcutManager::addShortcut(this, CTRL + Keys::G, [this] {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user