[haiku-development] Re: BMenuBar scrolling support

  • From: John Scipione <jscipione@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 21 Dec 2011 15:14:30 -0500

On Wed, Dec 21, 2011 at 2:03 PM, Stefano Ceccherini <
stefano.ceccherini@xxxxxxxxx> wrote:

> > I'd like to refactor BMenuBar to support scrolling like implemented in
> BMenuWindow for BMenu's now. Any suggestions on how the best way to handle
> this would be?
>
> From memory, there is a BMenuScroller class which takes care of the
> scrolling. Try to have a look there
>
There is a BMenuScroller class defined in src/kits/interface/MenuWindow.cpp
as well as view classes for the upper and lower arrows. I have managed to
contort the Deskbar window to support scrolling by making it derive from
the private BMenuWindow class instead of from BWindow and modifying the
BMenuWindow class to operate on a view instead of operating on the window
directly. This is all just a temporary hack though.

My plan of attack is to move the code to add and remove the scrollbar
arrows and do the actual scrolling into Deskbar (or a new class that I can
import into Deskbar) so that I can remove the dependency on the private
BMenuWindow class. I'll add the scrollbar arrows as a child of the view
(BarView) instead of the window (BarWindow). Then I'll create a scrollable
container view, add the BMenuBar (ExpandoMenuBar) to it, and then add it as
a child of BarView as well.

Finally, I'll reimplement the code from BMenu to do the scrolling up and
down of the container view. I can't use the scrolling code in BMenu
directly because it assumes that the menu is not a BMenuBar and that the
menu is attached to a BMenuWindow and frankly I don't want to touch it, the
code is a too hairy.

After that scrolling should work in Deskbar... at least that is my current
plan. If all goes well I may be able to export this code into it's own
class and then use that to do implement for any (vertical) BMenuBar.

John Scipione

Other related posts: