sys: Improve drag scrolling behaviour in hex editor view
This commit is contained in:
parent
2b135cf7e0
commit
8024b0a186
@ -1017,20 +1017,21 @@ namespace hex::plugin::builtin {
|
||||
// Scroll to the cursor if it's either at the top or bottom edge of the screen
|
||||
if (this->m_shouldScrollToSelection && this->isSelectionValid()) {
|
||||
// Make sure simply clicking on a byte at the edge of the screen won't cause scrolling
|
||||
if ((ImGui::IsMouseDown(ImGuiMouseButton_Left) && providerData.selectionStart != providerData.selectionEnd)) {
|
||||
auto fractionPerLine = 1.0 / (this->m_visibleRowCount + 1);
|
||||
if ((ImGui::IsMouseDown(ImGuiMouseButton_Left) && providerData.selectionStart != providerData.selectionEnd && providerData.selectionEnd.has_value())) {
|
||||
auto scrollPerLine = ImGui::GetScrollMaxY() / (provider->getSize() / (long double)(this->m_bytesPerRow));
|
||||
|
||||
if (y == (u64(clipper.DisplayStart) + 3)) {
|
||||
if (i128(*providerData.selectionEnd - provider->getBaseAddress() - provider->getCurrentPageAddress()) <= (i64(clipper.DisplayStart + 3) * this->m_bytesPerRow)) {
|
||||
this->m_shouldScrollToSelection = false;
|
||||
ImGui::SetScrollHereY(fractionPerLine * 5);
|
||||
auto scrollPos = ImGui::GetScrollY();
|
||||
auto scrollUpStartPos = scrollPos + scrollPerLine * 2;
|
||||
auto scrollDownStartPos = scrollPos + ImGui::GetWindowHeight() - scrollPerLine * 4;
|
||||
|
||||
}
|
||||
} else if (y == (u64(clipper.DisplayStart) - 3)) {
|
||||
if (i128(*providerData.selectionEnd - provider->getBaseAddress() - provider->getCurrentPageAddress()) >= (i64(clipper.DisplayEnd - 3) * this->m_bytesPerRow)) {
|
||||
this->m_shouldScrollToSelection = false;
|
||||
ImGui::SetScrollHereY(fractionPerLine * (this->m_visibleRowCount - 1));
|
||||
}
|
||||
auto cursorPos = float(u64(*providerData.selectionEnd / this->m_bytesPerRow)) * CharacterSize.y;
|
||||
|
||||
if (cursorPos <= scrollUpStartPos && y == u64(clipper.DisplayStart)) {
|
||||
this->m_shouldScrollToSelection = false;
|
||||
ImGui::SetScrollHereY(0.1F);
|
||||
} else if (cursorPos >= scrollDownStartPos && y == u64(clipper.DisplayEnd - 1)) {
|
||||
this->m_shouldScrollToSelection = false;
|
||||
ImGui::SetScrollHereY(0.95F);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user