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

Scrollbar dragging batch two #60953

Merged

Conversation

ZeroInternalReflection
Copy link
Contributor

@ZeroInternalReflection ZeroInternalReflection commented Sep 12, 2022

Summary

Interface "Scrollbar dragging batch two"

Purpose of change

Expand the scrollbar click-and-drag support implemented in a few UIs in #60006.

Describe the solution

Move handling of scrollbar dragging to the scrollbar() class. Scrollbar dragging can then be implemented anywhere that uses scrollbar()/draw_scrollbar() with the following changes:

  1. Have a scrollbar object that sticks around, rather than just creating it and discarding it when it's time to draw one
  2. Call scrollbar.set_draggable( input_context ) to ensure the appropriate actions are defined
  3. When handling input, call scrollbar.handle_dragging() and see if the user dragged the scrollbar,
  4. If dragging the scrollbar would change the selected item in a list then parse the scrollbar position back to the new selection (this gets a bit fiddly, and I don't think it's the best long-term solution, but it works for now. See discussion of alternatives)

Implement these changes for:

  • uilist menus (should work in a lot of different places)
  • draw_item_info() (such as examining items in the inventory/crafting screen)
  • Character creation tabs (Scenario list, trait list, etc.)
  • Martial arts information screen

Describe alternatives you've considered

  • For discrete entry lists, such as the list of scenarios in character creation, I think I'd prefer it if the selected entry and the list position were disconnected (e.g. you've got "Evacuee" selected at the top, but you've dragged the scrollbar down to the bottom to look at the expensive scenarios. Evacuee stays selected until you do something else). However, to do that properly, I'd need to add mouse-click selection to the various character creation lists, which I'm not quite ready to do.
  • Converting the martial arts information screen to scrolling_text_view
    Eventually
  • Handling scrollbar dragging on a per-UI bases
    Would result in a staggering amount of code duplication

Testing

Tested in English at a variety of screen sizes (generally smaller ones so there were more scrollbars) in Linux.

Character creation UIs:

Character_creation_scrollbar_drag.mp4

Draw_item_info UI:

Draw_item_info_scrollbar_drag.mp4

uilist and martial arts information screen:

Uilist_and_martial_arts_scrollbar_drag.mp4

Testing in curses on gnome-terminal (it mostly works, but isn't as nice):

Character_creation_scrollbar_drag--Curses.mp4

In a subsequent commit (2022-09-14), I updated the dragging code to actually interpolate properly (rather than the tried-and-tested method of "Eh, looks about right"). Having the mouse cursor over the ^ should now have the scrolling window at the very top, and having the mouse cursor over the V should now have the scrolling window at the very bottom. (Compare to some of the videos above, where it was occasionally necessary to move the mouse beyond the window in order to scroll all of the way)

Corrected_interpolation.mp4

Additional context

If I didn't screw up in this implementation, there are a whole lot more places to add it to.

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` Character / World Generation Issues and enhancements concerning stages of creating a character or a world Info / User Interface Game - player communication, menus, etc. Martial Arts Arts, Techniques, weapons and anything touching martial arts. astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Sep 12, 2022
@leemuar
Copy link
Contributor

leemuar commented Sep 14, 2022

awesome work!

@dseguin dseguin merged commit 6d3d8f8 into CleverRaven:master Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Character / World Generation Issues and enhancements concerning stages of creating a character or a world Info / User Interface Game - player communication, menus, etc. json-styled JSON lint passed, label assigned by github actions Martial Arts Arts, Techniques, weapons and anything touching martial arts.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants