Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix jump scroll offset #1660

Merged
merged 3 commits into from
May 10, 2024
Merged

Conversation

SparkyTD
Copy link
Contributor

@SparkyTD SparkyTD commented May 9, 2024

Problem description

This PR offers two improvements:

  1. When selecting / jumping to an offset that falls within the current viewport of the scroll view, the scroll offset will no longer force the selected byte to the top of the view. Instead, the scroll offset will only be changed if the selected byte is outside the current view.

  2. In case a wrong offset is entered into the Select or Goto dialog (e.g. and offset beyond EoF), the dialog's button will be disabled.

Implementation description

For the first change, I modified the logic that recalculates the m_scrollPosition based on the current byte offset.

For the second change, I added validation logic to both popups to ensure that the entered offsets are valid (using provider->getActualSize()). In case of the Select popup, I wrapped the button into an ImGui::Begin/EndDisabled to enforce the validation check.

…n necessary

When the cursor jumps to a new byte, the scroll offset should only change when the selected byte falls outside the scrolling viewport.
plugins/ui/source/ui/hex_editor.cpp Outdated Show resolved Hide resolved
plugins/ui/source/ui/hex_editor.cpp Outdated Show resolved Hide resolved
@WerWolv WerWolv merged commit 5f192d5 into WerWolv:master May 10, 2024
WerWolv pushed a commit that referenced this pull request May 10, 2024
### Problem description
Merging my previous PRs, #1660 and #1658 has resulted in a conflict
causing an application crash due to a missing `ImGui::BeginDisabled();`
in the `PopupSelect` class. Specifically, none of the code related to
offset validation made it into the final merge. This PR fixes the crash
by reintroducing the deleted lines.

### Additional things
The nightly release build seems to be unaffected by the crash, most
likely because ImGui's `DisabledStack` assertions are only enforced in
Debug mode. The offset validation was still missing before this fix.
@SparkyTD SparkyTD deleted the fix_jump_scroll_offset branch May 13, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants