Popup Menu & Drop-down Menu Bar


#1

I don’t know if this has been done before, so here it is.

It’s getting too long, get it here :
[size=150]Menu.py[/size]


a menu kit: AgileMenu
#2

Nice!

David


#3

Sorry, I was carried away by v1.6.0’s iterable vector, I didn’t try it with v1.5.x. It’s fixed now.


#4

UPDATES : disabled items and icons are supported now.


#5

Very nice. Will you now try to enhance it with sub menus? That would be most useful. Keep up the good work!


#6

Sub menu is available, but not entirely well tested.


#7

Fixed a bug, and improved a little.


#8

You do wonderful work, thank you. I am planning on adding your menu into my demo game to be released on this forum soon.
It seems like it would now be simple for you to modify the initial menu to optionally be horizontal and act as a standard menu bar control and set to resize with the window aligned at the top and made to stay visible. That im sure would make a powerful tool for developers making simple winform +3d like apps which benefit from the standard top menubar interface style which is shown to work well.
A standard control such as this could make a nice addition to all present and future demos shipped with Panda3D to give the appearance of a very popular and structured framework for making 3d gui apps, which it could be if it just had some more convienient controls like yours.


#9

How is it now ?


#10

Now you can drag and drop the menubar to any screen edge.


#11

Amazing!
I hope the community can keep up with the pace of your work. Putting it to use now should be the fun part although it seems there is not much talk lately of community participation. If anyone has a potential or future use for these great controls in personal or Panda projects they should post them as inspiration for others.
For me the release of code snippets greatly helps to motivate me by showing me that others are still interested in this great platform and that we each do not need to be the one to solve every problem faced by so many of us. With that in mind I would like to hopefully inspire a few people with my current progress and future plans utilizing Panda3D.

My current progress:

save file manager - file list of a single directory and filetype. Includes save delete, and rename options on the files

status - todo: integrate new popup menu

game platform - includes sample fpsplayer class and demo levelplugin which plays out a first person view style game in space, well separated oo style, managed HUD, skysphere effect, pause overlay which gives back the cursor, dynamic level objects collection, uses updated version of trails by treeform for planetary effects (added multiple slices rotated along trajectory, separate head cards which resize for optimal performance)

todo - controls/graphics/sound option menus, integrate save file manager, add web-based auto update with manual version select and default version configuration option

abstract windows - MDI window manager for multiple child and top level windows where the appropriate renderer will be used depending on the type of parent, render using Panda or WX, non top level windows may choose whether they want canvas(wx)/texture(Panda) while top level windows must be opaque and accept any hit test in the rectangle

todo - mousewatcher, hud3d+hit tests, wxloop stuff

multi-metaclasses - add/remove multiple parent classes to/from instances

todo - test persistency support, create visual class editor/template expander environment, support threads, support reference counting, allow instances to link/have full/partial buffered references across internet

My wish list:

treectrl - branchable,optionally multiselect within parent, scrollbars

sorted list or tree grid - sort multiple columns in a configurable order, reorder columns, scrollbars

property editor - for use in a any editable grid scenario, preset with some widgets for some standard data types, a plugin mechanism allowing custom popup property pages to interact dynamically with a temporary copy of the property which may offer a visual appearance which may be shown in a view (different view for each tab of the property editor if multiple dimensions of the object state are best viewed and edited independantly) object by controls on a cust defined property page with buttons “show/hide original” and “/hide original] [original/”,“cancel”/"commit "

toolcanvas - a canvas which manages selected objects using onscreen widgets (such as in 3d modellers for stretch and rotate, or the desktop icon), should allow easy custom item type modification using direct manipulation on only a working copy during modification overlaid translucently on the original object, cancel modification with right click or the escape key, configurable hotkeys to invoke the specific modifier widget on the selected object, toolbar similar to docked popup menu although clicks on the toplevel items should cause the tool to be selected and have the hovering action still possibly open the submenu to display the tools config window (dockable config windows are nice, also give them each a toolbar options to toggle a default show value), menubar option for toggling the toolmenu between icons/text/both

blliboard lod - a wrapper object which may either display the supplied nodepath directly or displays a billboard with a glass (or blur/glow/etc…) effect applied to that nodepath using the appropriate lod texture size for optimal billboarding of arbitrary scene objects updated at optimal rates. It should also know to include any colliding objects in the prerendered scene and preserve surface color while deferring surface alpha. useful for selective item blur (not discluding motion) would come cheap since blur radius can be adjusted just by shrinking the texture and leaving alone the card size which results in less image quality unless you simply have multiple decreasingly transparent billboards overlaid with offsets spread in the direction of motion of the objects center in screen space for rigid body motion.

lodmirror - similar to blliboard lod except using another camera in the same space to display items such as portals/mirrors/tv’s (with video noise animating transparently over the content)

Thats all for now.
Everyone should feel free to post their thoughts about any amazing tool ideas that my desired controls or especially YOUR OWN desired controls may lend themselves to. I ask because I would prefer to see a preview of their appreciation and hear sample use cases before investing time into potentially undesired or overly complicated controls.


#12

GREAT PLAN !!

Once you’re done with them, I’m sure you wouldn’t have any more wish list to think about.


#13

In the newest version of popup menu I tried to start it with the menu being anywhere but PTop but the menu was not visible. I was able to add this line:
self.setEdgePos(self.edgePos)
to the end of DropDownMenu.init and it seems to work fine now. I hope this solution is viable, I have not found the spot in the code which could be tweaked slightly to propertly position the menu at startup (although I looked). I came to the conclusion that the other code might be extra if this method is used by default, although I figured you would be able to sort that out faster than me. Thanks again.


#14

You’re right, sorry for that.
I split some codes from align() to setEdgePos(), and didn’t try it with other edges in the sample.
Adding setEdgePos() call to the end of init is correct.


#15

Nice work, just the kind of thing I was looking for (a right-click popup menu in the 3D scene).

One minor problem it poses for me at the moment: I’m using the default mouse navigation in my program, where mouse3 is used for dollying the camera in/out. This is still active with the popup menu bound to mouse3. I know I can use base.disableMouse() to turn off the built-in mouse navigation and roll my own but I’m quite happy with it. What I’d like to do is just have the built-in mouse code use the mousewheel (mouse4/5, I believe) to dolly instead of mouse3, which will instead open the popup menu.

I did a bit of poking around, suspecting this might be very simple but have come up empty so far. Any ideas?


#16

The built-in trackball mode is implemented in C++, in the file panda/src/tform/trackball.cxx . If you want to change its behavior, you’ll need to be prepared to modify C++ code and recompile Panda.

David


Making a Rich GUI
#17

Or, you could just translate the section of that code into Python. I’ve done it with some other nice functions from e.g. WindowFramework too, usually it works good.

Note that the mouse wheel actually is the wheel_up and wheel_down events, not mouse4 and mouse5.


#18

UPDATE :

  1. better menu rectangle height when the last item is disabled
  2. added “draggable” option to DropDownMenu constructor

#19

UPDATES :
[X] fixed menu item text with respect to the new panda text generation method
[X] fixed default minZ value so it won’t exactly touch screen bottom edge


#20

another bug has gone :
[X] fixed menu placement if it’s scaled