Skip to content

Add a scrollbar and mouse wheel scrolling to select boxes - #65

Merged
Flamefire merged 2 commits into
Return-To-The-Roots:masterfrom
littleant:selectbox-scrolling
Nov 19, 2026
Merged

Flamefire merged 2 commits into
Return-To-The-Roots:masterfrom
littleant:selectbox-scrolling

Conversation

@littleant

Copy link
Copy Markdown
Contributor
  • Draw a scrollbar track with a draggable slider between the scroll buttons
  • Scroll by whole lines and only draw/click the visible entries
  • Show the scroll buttons and scrollbar only when needed
  • Make the whole row of an entry clickable
  • Scroll select boxes with the mouse wheel: the wheel goes to the topmost window under the cursor, otherwise to the active menus
  • No existing bugs that were not directly tied to the scrolling logic have been fixed here.

You can see this scrollbar in action when you start the editor and press F1 to show the help-window. The scrollbar on the right contains the changes. Also, the window is now accepting the scroll-wheel.

Tested on Windows 11 and Linux (Wayland and X11).

I need this PR for the upcoming zoom feature.

- Draw a scrollbar track with a draggable slider between the scroll
  buttons
- Scroll by whole lines and only draw/click the visible entries
- Show the scroll buttons and scrollbar only when needed
- Make the whole row of an entry clickable
- Scroll select boxes with the mouse wheel: the wheel goes to the topmost
  window under the cursor, otherwise to the active menus

@Flamefire Flamefire left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, some suggestions inline for polishing

Comment thread CIO/CSelectBox.cpp Resolved
Comment thread CIO/CSelectBox.cpp Resolved
Comment thread CGame_Event.cpp Resolved
Comment thread CIO/CSelectBox.h Resolved
Comment thread CIO/CFont.h Resolved
Comment thread CIO/CSelectBox.cpp Resolved
Comment thread CIO/CSelectBox.cpp Resolved
Comment thread CIO/CSelectBox.h Resolved
- Give the scrollbar slider a minimum height of one scroll button, capped at
  the track height, and map the scroll range onto the slider range so the
  slider reaches both ends of the track exactly
- Don't draw the track and slider if the track is shorter than the minimum
  slider height, drawButtonBox would underflow below 4px
- Rename CSelectBox::scroll to scrollBy and document it
- Add CButton::getRect and use getRect for buttons and windows
- Clarify some comments and document the slider helpers
@littleant
littleant requested a review from Flamefire November 19, 2026 16:22

@Flamefire Flamefire left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you tested that it works manually, so LGTM

@Flamefire
Flamefire merged commit da83a8f into Return-To-The-Roots:master Nov 19, 2026
6 checks passed
@littleant

Copy link
Copy Markdown
Contributor Author

yes, I tested it manually.

@littleant
littleant deleted the selectbox-scrolling branch November 19, 2026 18:09
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