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

An other way to open menu #308

Closed
wants to merge 12 commits into from
Closed

Conversation

gwenandres
Copy link
Contributor

Hello,
with @sylvainbeo we propose a new way to open main menu.

If you add appMenuCompact in TopBar cfg, main menu is open in compact mode.
On hover you will have all details .

menuCompact07-02-2024 18-18

I hope we can propose this for everyone.

Have a good day

@manisandro
Copy link
Member

Thanks, I like the idea! I believe it should be restricted to desktop though?

isAppMenuCompact = (pluginsConfig)=> {
const pluginTopBar = pluginsConfig.find((pluginConf) => pluginConf.name === "TopBar");
return pluginTopBar && pluginTopBar.cfg.appMenuCompact;
};
Copy link
Member

Choose a reason for hiding this comment

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

Rather than having this logic in the plugin container, I'd introduce an action setRightMargin or similar in actions/map, which sets state.map.rightMargin, and is then honoured by the various components for positioning (Buttons, WindowManager, MapCopyright). The problem with this approach is that, besides not taking mobile mode into account, it will break right-docked windows with splitscreen=true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @manisandro, I think it is a better way to add an setRightMargin action.
Thanks for your advice.

I'm sorry but I think I didn't manage to set splitscreen=true. How/where to do that ? Or wich behavior in the interface ?

I only have right-docked windows.

Screenshot 2024-02-20 at 10-24-13 QGIS Web Client 2

Have a good day

Copy link
Member

Choose a reason for hiding this comment

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

Hi @gwenandres , the ResizeableWindow component has a splitScreenWhenDocked prop. But the actual plugin rendering the window needs to set it, if it is useful for the component (i.e. AttributeTable, HeightProfile set splitScreenWhenDocked). For testing, you can just set it for a plugin which renders a right-dockable window.

} else {
document.removeEventListener('click', this.checkCloseMenu);
document.removeEventListener('keydown', this.onKeyPress, true);
document.removeEventListener('mousemove', this.onMouseMove, true);
Copy link
Member

Choose a reason for hiding this comment

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

I just debugged an issue related to these event listeners. If they remain active, they will break arrow-pan of the map and i.e. enter-submit of input fields. So it is undesirable to have these event listeners active unless there really is an open menu.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I will remove these changes

return {
type: SET_SPLIT_SCREEN,
windowId: windowId,
side: side,
size: size
size: size,
menuMargins: menuMargins
Copy link
Member

Choose a reason for hiding this comment

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

I don't think there is any advantage in passing the menuMargins here, since it is identical to the state value. Just use menuMargins in the reducer. You can move the const mapMargins = {...} block in the reducer to a separate funtion which you call both as a result of SET_SPLIT_SCREEN and SET_MENU_MARGIN.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sorry I don't understand how to move the const mapMargins = {...} block to a separate function. mapMargin Values in SET_SPLIT_SCREEN and SET_MENU_MARGIN are different...

} else {
document.addEventListener('click', this.checkCloseMenu);
document.addEventListener('keydown', this.onKeyPress, true);
document.addEventListener('mousemove', this.onMouseMove, true);
}
Copy link
Member

Choose a reason for hiding this comment

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

Please enclose the entire block between 174 and 181 in

if (!this.props.keepMenuOpen) {
...
}

@@ -302,6 +305,12 @@ class AppMenu extends React.Component {
mousetrap(el).bind(this.props.appMenuShortcut, this.toggleMenu);
}
};
storeRigthMargin = (el) => {
Copy link
Member

Choose a reason for hiding this comment

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

Rigth -> Right

@@ -302,6 +305,12 @@ class AppMenu extends React.Component {
mousetrap(el).bind(this.props.appMenuShortcut, this.toggleMenu);
}
};
storeRigthMargin = (el) => {
if (this.props.menuCompact && el?.clientWidth > 0) {
const rightmargin = el.clientWidth - MiscUtils.convertEmToPx(11.5);
Copy link
Member

Choose a reason for hiding this comment

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

What is 11.5em?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

const style = {display: this.props.visible ? 'initial' : 'none'};
const style = {
display: this.props.visible ? 'initial' : 'none',
right: 'calc(0.25em + ' + this.props.menuMargins.right + 'px)'
Copy link
Member

Choose a reason for hiding this comment

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

What is 0.25em? Shouldn't this be part of the menuMargin, if necessary? Else with a zero menuMargin, it will still have a 0.25em right offset.
You'll also want to honour the left margin, since you support it in the reducer state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I add 0.25em as it is done for MapCopyright :

https://github.com/qgis/qwc2/blob/master/plugins/MapCopyright.jsx#L57

I found it aesthetically pleasing when everything wasn't aligned (stuck) with the right edge; even without compact menu.

I hope to honor the left margin but I can't do this right now. Should I remove left margin from reducer state ?

@@ -80,6 +81,7 @@ class SideBar extends React.Component {
const render = visible || this.state.render || this.props.renderWhenHidden;
const style = {
width: this.props.width,
right: visible ? 'calc(0.25em + ' + this.props.menuMargins.right + 'px)' : 0,
Copy link
Member

@manisandro manisandro Feb 22, 2024

Choose a reason for hiding this comment

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

Same question regarding 0.25em as above

Also note that the SideBar can be left-aligned, so you also want honour that case.

reducers/map.js Outdated
@@ -27,6 +27,7 @@ const defaultState = {
resolutions: [0],
topbarHeight: 0,
bottombarHeight: 0,
rightMargin: 0,
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a leftover

bottom: 0,
left: action.left,
top: 0
};
Copy link
Member

Choose a reason for hiding this comment

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

This looks wrong - why reset the top and bottom map margin to zero?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I correct that

@manisandro
Copy link
Member

I've merged this manually and added a bunch of fixes, please check out if the latest master works for you. Thanks!

@manisandro manisandro closed this Feb 28, 2024
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