-
Notifications
You must be signed in to change notification settings - Fork 24
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 shortcut to maximize golden layout panes #3927
Conversation
just noting that ctrl+m is “mute tab” in firefox, but since wk doesn’t produce sound, I guess it is fair to overwrite that :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet! With the shortcut, the maximize feature feels even better. However, I'm personally not a fan of ctrl+m, since I bound that to a different action in my browser :D However, that's my problem, I guess.
In general, a one-key short cut would be super cool, imo. Would enter
be free? Wdyt @fm3 @normanrz regarding the shortcut? Even if invoked accidentally, the effect should be quite obvious to the user and the pane can even be unmaximized via the "maximize" button in the top right corner which should be intuitive.
keyboardjs doesn't easily allow to set a "target element" and keyup event handlers can only be attached at the document level, so I had to get a little more involved. What do you think? :)
Doesn't your code attach keyup at the document level? document.addEventListener("keyup", maximizeListener)
doesn't contain a target, does it?
If I'm understanding it correctly an keyup handler is attached for each created component, right? So, for each key up event, approx. 10 listeners will fire. There is probably not a measurable difference, but I'm a bit hesitant with adding too many listeners, since we already have quite a lot of those 🙈
I played a bit around in the console and found the following way which would allow to only attach one listener (all hail the premature optimization!):
// ...
// attach one key up listener and if it's ctrl+m do the following
// ...
const hoveredComponents = glRoot.getItemsByFilter(item => {
return item.isComponent && item.element[0].matches(":hover")
});
if (hoveredComponents.length > 0) {
hoveredComponents[0].toggleMaximise();
}
What do you think?
I guess just From a code perspective, would it be feasible to have a keyboard shortcuts defined in one place? |
@philippotto Thanks for your feedback, you were right with both suggestions, I switched to using a single keyboardjs handler :) The shortcut is now
@normanrz I see the benefit of this, but I think it would be rather complicated or at least I don't have a good idea how to do that. We should definitely pay attention to keeping the shortcut overview up-to-date, so we're not losing track for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice clean up 👍
@@ -104,13 +106,13 @@ export class GoldenLayoutAdapter extends React.PureComponent<Props<*>, *> { | |||
if (onLayoutChange != null && this.gl.isInitialised) { | |||
onLayoutChange(this.gl.toConfig(), this.props.activeLayoutName); | |||
// Only when the maximized item changed, adjust css classes to not show hidden gl items. | |||
if (this.maximizedItem !== !this.gl._maximisedItem) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, nice catch. Didn't spot in the other PR.
nice. looking forward to tweet about this 🐦 |
…ture-highlight * 'master' of github.com:scalableminds/webknossos: Hide unreported datasets (#3883) Update puppeteer and refresh screenshots (#3914) only show team names of own organization (#3928) Enable merger mode in skeleton and hybrid tracings (#3619) allow uploading nml for public dataset of different orga (#3929) Always make wheel listeners not passive to allow preventDefault (#3939) Enhance tree search functionallity (#3878) add webknossos-connect to setup (#3913) Update README.md (#3923) Add shortcut to maximize golden layout panes (#3927) Perform bucket picking in web workers and other performance optimizations (#3902) remove alt text for abstract brain loading image (#3930) updated documentation front page (#3917)
This is the best I could come up with. keyboardjs doesn't easily allow to set a "target element" and keyup event handlers can only be attached at the document level, so I had to get a little more involved. What do you think? :)
Of course the shortcut is debatable, I picked M for Maximize, ideally it would be a single key press, but there have been voices in the community to avoid those.The shortcut is
.
now.URL of deployed dev instance (used for testing):
Steps to test:
.
to toggle maximize.Issues: