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

Add hotkey hints to editor menus #29691

Merged
merged 10 commits into from
Oct 1, 2024
Merged

Conversation

bdach
Copy link
Collaborator

@bdach bdach commented Sep 4, 2024

2024-09-04.12-26-32.mp4

RFC.

This is pretty old code that I had lying around on a branch somewhere and showed off on discord once but I didn't get around to cleaning it up until now. It still has a hack in one place that I'm not super sure how to get rid of, so caveat emptor.

Note that this also slightly alters the design and spacing of the menus globally - all menus will now have a space to the left of the item to make sure a checkbox or something else can be displayed there.

For demonstration purposes this is only shown off in the editor right now, but there are probably other places where these could be directly applied pretty much immediately.

Note that the HotkeyDisplay is designed to be reusable, and supports KeyCombinations, GlobalActions, and PlatformActions out of the box.

It didn't ever really make sense for it to be sharing the implementation
details of that (e.g. colouring of primary/dangerous actions), and with
the hotkey display things got outright hacky, so I'm decoupling it
entirely.
Comment on lines +107 to +111
// this hack ensures that the menu can auto-size while leaving enough space for the hotkey display.
// the gist of it is that while the hotkey display is not in the text / "content" that determines sizing
// (because it cannot be, because we want the hotkey display to align to the *right* and not the left),
// enough padding to fit the hotkey with _its_ spacing is added as padding of the text to compensate.
text.Padding = new MarginPadding { Right = hotkey.Alpha > 0 || showChevron ? hotkey.DrawWidth + 15 : 0 };
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the one hack I did not manage to get rid of, so do keep that in mind.

There is probably one way I could get rid of this but it likely involves copious GridContainer usage (to the tune of one per menu item) so I'm not sure of the general feelings on that solution.

@@ -78,8 +81,11 @@ private void load(OverlayColourProvider colourProvider, TextureStore textures)

protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableEditorBarMenuItem(item);

private partial class DrawableEditorBarMenuItem : DrawableOsuMenuItem
internal partial class DrawableEditorBarMenuItem : DrawableMenuItem
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This de-inheritance and resulting code duplication was incurred intentionally to get rid of ugly digging in the innards of the base to hide the checkbox display to the left of menu items. See: 0c4f5bc

@bdach bdach self-assigned this Sep 5, 2024
@peppy peppy self-requested a review October 1, 2024 06:50
@peppy
Copy link
Member

peppy commented Oct 1, 2024

For 162558e see:

JetBrains Rider-EAP 2024-10-01 at 09 49 35

@peppy peppy merged commit 54e6800 into ppy:master Oct 1, 2024
8 of 9 checks passed
@bdach bdach deleted the hotkeys-in-context-menus branch October 1, 2024 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants