Closed Bug 477256 Opened 16 years ago Closed 15 years ago

Implement menubar auto-hiding in toolkit

Categories

(Toolkit :: Toolbars and Toolbar Customization, enhancement)

x86
Windows Vista
enhancement
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla1.9.2a1

People

(Reporter: dao, Assigned: dao)

References

(Depends on 5 open bugs)

Details

(Keywords: dev-doc-complete)

Attachments

(1 file, 8 obsolete files)

Attached patch patch (obsolete) — Splinter Review
This is a Windows Vista quirk that we'll probably want to adopt in Firefox. The menubar is hidden until the Alt key is pressed.
Attachment #360918 - Flags: review?(neil)
What about people who've customised stuff on to their menubar?
We can either disable it in that case or let them deal with it (they know how to customize, after all). I think it might actually be useful to place stuff there that you don't need to see all the time. I'm also thinking of adding a hidden(?) browser(?) pref to disable auto-hiding.
(In reply to comment #2) > I think it might actually be useful to place stuff > there that you don't need to see all the time. This won't work, since DOMMenuBarInactive is dispatched before you can use any other element. So I think we need to disallow this, but in browser code, as an app could place non-interactive elements next to the menubar.
This is bug 456535.
Blocks: 456535
Attached patch patch v2 (obsolete) — Splinter Review
When the attribute is removed during runtime, margin-top needs to be 0 again. Unfortunately, the xbl destructor isn't called in that case, the binding is just detached silently.
Attachment #360918 - Attachment is obsolete: true
Attachment #360980 - Flags: review?(neil)
Attachment #360918 - Flags: review?(neil)
(In reply to comment #5) > When the attribute is removed during runtime, margin-top needs to be 0 again. > Unfortunately, the xbl destructor isn't called in that case, the binding is > just detached silently. Would attachment 278129 [details] [diff] [review] help out here? It shows you how to collapse a menubar without using additional script. Unfortunately as I don't seem to have been CCd to bug 127244 I didn't notice the confusion over whether it had been checked in or not :-(
That would likely have helped for that particular case (unhiding the menubar without script). But I'd still have to hide the toolbar (which has a min-height, border, -moz-appearance and potentially more content) without collapsing it. Calculating the height handles all that in a straightforward way, although the setTimeout it uses is also pretty ugly.
This is with the current patch and autohide="true" on Firefox' main menu bar: <https://build.mozilla.org/tryserver-builds/2009-02-06_15:26-dgottwald@mozilla.com-try-71541a08d6d/> Can be tested on Linux and Windows. Note that Alt doesn't activate the menu bar on Linux, you need to press something like Alt+F.
+toolbar[type="menubar"]:not([autohide="true"]), [....] + margin-top: 0 !important; Hmm. Why is the margin-top set to 0px for non-autohide menubars?
(In reply to comment #9) > +toolbar[type="menubar"]:not([autohide="true"]), > [....] > + margin-top: 0 !important; > > Hmm. Why is the margin-top set to 0px for non-autohide menubars? See comment 5.
Pressing Alt and clicking on a menu item causes the menu-bar to close and re-open, causing a bounce affect leaving the menu in an odd place, pinned to top of the window and the menu bar closes behind it... Weird looking behavior and will be very annoying.
Pressing the Alt key and holding it a second or so.. Release the Alt key the menu appears Press and release the Alt key and the menu-bar jumps up/down (bounces) with each press of the Alt Key Also, while typing this out and playing with the alt-key I somehow managed to select a menu item - Clear Recent History and was presented with the CRH box.
Hm... looks like the DOMMenuBarInactive event isn't as great as it seemed. Thanks for testing.
Attached patch patch v3 (obsolete) — Splinter Review
Attachment #360980 - Attachment is obsolete: true
Attachment #361047 - Flags: review?(neil)
Attachment #360980 - Flags: review?(neil)
Comment on attachment 361047 [details] [diff] [review] patch v3 This also needs to work if the toolbar isn't at the top. Working an a new patch without margin.
Attachment #361047 - Attachment is obsolete: true
Attachment #361047 - Flags: review?(neil)
Attached patch patch v5 (obsolete) — Splinter Review
Changing the binding during customization caused the changes not to be saved. Makes more sense this way anyway...
Attachment #361101 - Attachment is obsolete: true
Attachment #361104 - Flags: review?(neil)
Attachment #361101 - Flags: review?(neil)
Pressing Alt and trying to right-click on the Menu-bar to choose 'customize' - does not show / pop-up the Customize Pallet. Sorry if you have already fixed this with the v5 patch from comment #17 , I'm no good at reading code. View-toolbars-customize still works, but that's the long way around.
Any feeling for how often people use History->Recently Closed tabs list ? Maybe we need a Nav-bar 'button' to implement that particular feature, or maybe just add a path to show Recent Close tabs to the right-click context menu ?
Attached patch patch v6 (obsolete) — Splinter Review
the menubar gets inactive on mousedown, the context menu opens on mouseup => huge hack :(
Attachment #361104 - Attachment is obsolete: true
Attachment #361110 - Flags: review?(neil)
Attachment #361104 - Flags: review?(neil)
(In reply to comment #19) > Any feeling for how often people use History->Recently Closed tabs list ? > > Maybe we need a Nav-bar 'button' to implement that particular feature, or maybe > just add a path to show Recent Close tabs to the right-click context menu ? This belongs more to bug 456535.
Severity: normal → enhancement
I like this new feature, but I think there should be an option to always show the menu bar like with the addon "personal menu"
(In reply to comment #23) > I like this new feature, but I think there should be an option to always show > the menu bar like with the addon "personal menu" See bug 456535.
Dao, have you looked at the code of the Hide Menubar addon? Perhaps it would have saved you some dev time... https://addons.mozilla.org/en-US/firefox/addon/4762
Yes, I looked at the code of that extension. It seemed to be too much of a hack.
Comment on attachment 361110 [details] [diff] [review] patch v6 A moving target is a bit tricky to review ;-) >+ <field name="_inactiveTimout">null</field> s/Tim/Time/g :-) >+ <field name="_contextMenuListener"><![CDATA[({ Personally I wouldn't have created a separate field for this, but I know you browser/toolkit guys like that sort of thing. >+ this.contextMenu = document.getElementById(contextMenu); Slightly confusing ;-) >+ this.toolbar.addEventListener("mousemove", this, false); I managed to nudge my mouse while I was context menuing (between click and release), so the menubar disappeared. Maybe this should be mouseout? Not sure. There did seem to be a bit of repainting involved as the menubar temporarily hides while the dialog loads. [This was more obvious to me when I removed the Mac ifdefs so I got to use the customisation sheet. In this case if you don't customise on the menubar then the sheet appears in an incorrect position.] One thing does worry me: what happens if you customise an item that has its own context menu on to the menubar? Oh, and by the way, 12 lines had trailing whitespace.
(In reply to comment #27) > >+ <field name="_contextMenuListener"><![CDATA[({ > Personally I wouldn't have created a separate field for this, but I know you > browser/toolkit guys like that sort of thing. Actually I don't. But for a toolkit binding, it seems better not to implement handleEvent, so that bindings inheriting from it can implement handleEvent without cloning code. Also in this case I think grouping the context-menu related code improves readability. > >+ this.toolbar.addEventListener("mousemove", this, false); > I managed to nudge my mouse while I was context menuing (between click and > release), so the menubar disappeared. Maybe this should be mouseout? Not sure. Yeah, this isn't pretty. I think mouseout didn't work while the right mouse button is pressed, and I'm pretty sure it wouldn't work when the mouse leaves the window to the top. > One thing does worry me: what happens if you customise an item that has its own > context menu on to the menubar? I'll test that. I don't think we need to make such context menus work, as there's already the limitation that elements other than the menubar aren't interactive. > Oh, and by the way, 12 lines had trailing whitespace. Interesting, I don't see any trailing whitespace in the patch, except for context lines.
(In reply to comment #28) > > One thing does worry me: what happens if you customise an item that has its own > > context menu on to the menubar? > > I'll test that. What happens is that the context menu opens and, as soon as you move the mouse, the toolbar hides ;-)
Attached patch patch v6.1 (obsolete) — Splinter Review
Really the same patch, just with the typo and the var name fixed. I'm unsure what this means: > There did seem to be a bit of repainting involved as the menubar temporarily > hides while the dialog loads.
Attachment #361110 - Attachment is obsolete: true
Attachment #361372 - Flags: review?(neil)
Attachment #361110 - Flags: review?(neil)
(In reply to comment #28) > I don't think we need to make such context menus work, as > there's already the limitation that elements other than the menubar aren't > interactive. Ah, but then I fail to see the point of making the menubar customisable... > Interesting, I don't see any trailing whitespace in the patch, except for > context lines. Well git-apply claims otherwise.
(In reply to comment #31) > (In reply to comment #28) > > I don't think we need to make such context menus work, as > > there's already the limitation that elements other than the menubar aren't > > interactive. > Ah, but then I fail to see the point of making the menubar customisable... Well, toolkit allows it, but it doesn't make menubars customizable by default. That's a decision on the application level that we can't just undo now. I was going to disable auto-hiding when the menubar is customized in Firefox, but given that customized interactive elements won't work for any app, maybe it's better to do this in toolkit? Ideally, we'd fix the interactivity. I currently don't see how to implement this solidly, so I'd spin it off to another bug. > > Interesting, I don't see any trailing whitespace in the patch, except for > > context lines. > Well git-apply claims otherwise. Maybe odd line endings? I certainly don't see trailing spaces.
Attached patch patch v7 (obsolete) — Splinter Review
auto-hiding disabled for customized menubars
Attachment #361372 - Attachment is obsolete: true
Attachment #361616 - Flags: review?(neil)
Attachment #361372 - Flags: review?(neil)
(In reply to comment #33) > Created an attachment (id=361616) [details] > patch v7 > > auto-hiding disabled for customized menubars https://build.mozilla.org/tryserver-builds/2009-02-10_13:42-dgottwald@mozilla.com-try-abd7334c609/
Attachment #361616 - Flags: review?(neil)
Attachment #361616 - Flags: review?(gavin.sharp)
Attachment #361616 - Flags: review+
Comment on attachment 361616 [details] [diff] [review] patch v7 Well, it seems to work fine, but I'd like a second opinion on a) what the expected behaviour is b) whether the code has become too sprawled.
Attachment #361616 - Flags: review?(gavin.sharp) → review?(enndeakin)
Comment on attachment 361616 [details] [diff] [review] patch v7 >+ </binding> >+ >+ <binding id="toolbar-menubar-autohide" >+ extends="chrome://global/content/bindings/toolbar.xml#toolbar"> >+ <content> >+ <xul:hbox flex="1"> >+ <children/> >+ </xul:hbox> >+ </content> Does it not work without these? this.contextMenu.addEventListener("popupshowing", this, false); >+ this.contextMenu.addEventListener("popuphiding", this, false); >+ this.toolbar.addEventListener("mousemove", this, false); I don't understand what the mousemove event is detecting. Also, what if an event listener prevents the popupshowing event? >+ function normalize(aSet) { >+ return aSet.split(",").filter(function (element) { >+ return element != "separator" && >+ element != "spacer" && >+ element != "spring" && >+ element != "__empty"; >+ }).sort().join(","); >+ } >+ if (normalize(aCurrentSet) == normalize(defaultSet)) { >+ this.removeAttribute("customized"); >+ return; So somebody with the same set of items but in a different order, or with extra spacers has not customized?
(In reply to comment #36) > >+ <content> > >+ <xul:hbox flex="1"> > >+ <children/> > >+ </xul:hbox> > >+ </content> > > Does it not work without these? Appears to be working without it (thanks to overflow:hidden, I think). I'll attach a new patch. > I don't understand what the mousemove event is detecting. I need some way to tell if the mouse pointer was moved away from the toolbar after the mousedown event, as the context menu won't appear then. > Also, what if an event listener prevents the popupshowing event? I guess I can't use event.getPreventDefault() reliably and should listen to popupshown instead... > So somebody with the same set of items but in a different order, or with extra > spacers has not customized? Not in a way that's critical for auto-hiding. Maybe a better attribute name is needed...
Attached patch patch v8Splinter Review
Attachment #361616 - Attachment is obsolete: true
Attachment #361616 - Flags: review?(enndeakin)
Attachment #362062 - Flags: review?(enndeakin)
> I need some way to tell if the mouse pointer was moved away from the toolbar > after the mousedown event, as the context menu won't appear then. So why aren't you using the contextmenu event? > Not in a way that's critical for auto-hiding. Maybe a better attribute name is > needed... What is that code trying to actually accomplish?
(In reply to comment #40) > > I need some way to tell if the mouse pointer was moved away from the toolbar > > after the mousedown event, as the context menu won't appear then. > > So why aren't you using the contextmenu event? DOMMenuBarInactive is dispatched sometime around mousedown, whereas the context menu opens on mouseup. > > Not in a way that's critical for auto-hiding. Maybe a better attribute name is > > needed... > > What is that code trying to actually accomplish? The fact that the toolbar hides when the menubar becomes inactive interferes with using other elements, such as toolbarbuttons that a user could place on the toolbar. So when the user does that, we don't hide the toolbar.
Comment on attachment 362062 [details] [diff] [review] patch v8 OK, I don't really understand it fully, but it does seem to work properly. I don't think this should be checked in though until we have a use for it.
Attachment #362062 - Flags: review?(enndeakin) → review+
(In reply to comment #42) > (From update of attachment 362062 [details] [diff] [review]) > don't think this should be checked in though until we have a use for it. Neil could you please clarify? What do you mean have a use for it?
(In reply to comment #43) > (In reply to comment #42) > > (From update of attachment 362062 [details] [diff] [review] [details]) > > don't think this should be checked in though until we have a use for it. > > Neil could you please clarify? What do you mean have a use for it? bug 456535
(In reply to comment #44) > (In reply to comment #43) > > (In reply to comment #42) > > > (From update of attachment 362062 [details] [diff] [review] [details] [details]) > > > don't think this should be checked in though until we have a use for it. > > > > Neil could you please clarify? What do you mean have a use for it? > > bug 456535 Oh ok, thanks. I figured this was what this bug was about. Anyways, should this bug be blocked by that one then. Right now it is the other way around which was probably correct to begin with but now this bug is waiting on a patch from that one.
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.2a1
Keywords: dev-doc-needed
Summary: Implement menubar auto-hiding → Implement menubar auto-hiding in toolkit
Depends on: 498102
Depends on: 498100
Depends on: 498108
Depends on: 498112
Depends on: 498176
Depends on: 498628
Depends on: 499298
Depends on: 501950
Dao, do you know an application from MS which also makes use of this feature? Just to have a reference.
IE7 and 8 on XP, and probably a couple more apps on Vista.
Thanks. Verified fixed with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2a1pre) Gecko/20090709 Minefield/3.6a1pre (.NET CLR 3.5.30729) ID:20090709091211
Status: RESOLVED → VERIFIED
Just a thought - why intentionally hide a major part of the interface unless users know a non-obvious way of getting to it? They did this to IE, and it greatly reduced the usability of that browser. Why do the same to Firefox?
I don't think this patch actually hides the menu bar by default; it just makes it possible, yes?
Yes.
(In reply to comment #53) > Now documented: > https://developer.mozilla.org/XUL:Attribute:autohide Not sure if this is just because of the link here or if this is even a problem but the page that is loaded afte following the link says, "This page redirects to a page that no longer exists en/XUL/Attribute/autohide."
https://developer.mozilla.org/en/XUL/menubar#a-autohide is wrong. It's not <menubar autohide="true"/> but <toolbar type="menubar" autohide="true"/>.
https://developer.mozilla.org/en/XUL:Attribute:autohide I posted the link wrong. Dão - where do you see that? There's no sample anywhere, so I'm not sure what you're referring to.
The whole section on autohide is wrong... that page is about menubar elements, not toolbar elements.
This bug says it's about menubar auto-hiding. So now I'm very confused.
The actual implementation requires setting autohide="true" on <toolbar type="menubar"/> elements. The menubar element is a child of such a toolbar.
Depends on: 525762
Depends on: 526461
Blocks: 540629
Depends on: 542115
No longer depends on: 542115
(In reply to comment #60) > Moved this to the toolbar doc: > > https://developer.mozilla.org/en/XUL/toolbar The link there forwarded me to the MDC front page. Also, the other attributes have examples inline and this one is just a link to a different page, which looks odd.
This was a broken use of a template; fixed now.
Thanks!
No longer depends on: 525762
Blocks: 555576
Depends on: PluginShortcuts
Depends on: 541844
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: