menu system extensions

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

Grimmigbeisser
Just popping in
Just popping in
Posts: 14
Joined: Wed Jul 28, 2010 07:22

menu system extensions

Postby Grimmigbeisser » Sat Oct 30, 2010 22:17

Hello there,

i found, that the menu system (menubar/popup/menuitem) didn't fit 100% to my needs, so i added some features in my local CEGUI source (svn branch 0.7.4). I think this features could be of use to the CEGUI community, so perhaps there is a way to integrate them.

So what i have done?

*(1)Added support for checkable menu items
*(2)Added support for delayed opening / closing of popups, when hovering with the mouse
*(3)Added a property for an offset used for adjusting the position of the popup menus
*(4)Modified the logic, so if the current popup window is switched, all sub popup menus are set to closed state, so they don't appear anymore when the switched popup is reopened.

How i did it?

(1)
*added two new properties to the menu item widget: Checkable, Checked
*added a falagard state imagery "CheckedIcon" to the menu item renderer

(2)
*added a property to the menu item widget: PopupTimerTime, which gives the open/close delay
*added a update routine to CEGUI::MenuItem, which updates the close/open timer if its activated
*triggered the open/close timer depending on the hovering state

(3)
*added a property to the menu item widget: PopupOffset
*the offset is added to the calculated position of the popup window, when it pops up

(4)
*closeAllMenuItemPopups now finds the topmost popup menu and closes its current popup
*added internal onHidden event to PopupMenu where it changes the popups opened state to closed

All changes should be transparent to the current looknfeels and layouts, so no behavior change is made to existing menu systems, except the one in (4), which could be made optional by an additional property if this is not ok.

I have done some more functionality, which i decided to put in my client code. If someone thinks this is useful, i could post some code.
This includes:
*closing all menu popups, when a click is made outside the popup windows or top menu items
*a way to display keyboard shortcuts in the menuitems

Any thoughts, questions or requests on this?

Yours sincerely,
Grimmigbeisser

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: menu system extensions

Postby Kulik » Sun Oct 31, 2010 14:24

I think the checkable menu item can be implemented by adding a checkbox to a menu item but I can't check at the moment. In case it can't be done that way I think the checkable items should be implemented by inheriting MenuItem and creating a new class CheckableMenuItem for example.

Other than that, I would really like to see the patch and perhaps some video demo of it :-)

Grimmigbeisser
Just popping in
Just popping in
Posts: 14
Joined: Wed Jul 28, 2010 07:22

Re: menu system extensions

Postby Grimmigbeisser » Sun Oct 31, 2010 16:40

I have thought about adding the checkable functionality via a checkbox / subclassing too, but i saw no reason for doing so.
A menu items text is set via the windows text property. If you would place a checkbox child in the menu item, you would have to set the checkbox text to an empty string or use the checkbox string as menu item text string. I think both cases are kind of dirty and the second would even break existing menu systems.
Subclassing MenuItem and adding the checkbox to the subclass might be a solution. It would let existing menu systems behavior unchanged and you could use the existing checkbox looknfeels and its logic. However, you have to create a new looknfeel widget anyway to add the autowindow and most of the checkbox logic and state imageries would look odd in a menu item so you would additionally end up in creating a highly downgraded checkbox looknfeel.
I think a checkable menu item only needs an additional icon specified and with my solution this is easy to achieve without breaking existing menu systems. Furthermore i think this functionality is simple and general enough to add it to the menu item directly without subclassing.

If you or someone else have some good arguments for a checkbox / subclass menu item let me know, maybe i'm getting convinced :) .

I will supply a patch, when we have discussed this and you can see a video, when my project gets announced officially. But i can't say when this will be :wink: .

Yours sincerely,
Grimmigbeisser

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: menu system extensions

Postby Kulik » Sun Oct 31, 2010 16:49

I tend to like generic solutions. Your solution works fine for checkboxes but imagine someone wanting radio buttons there? Or even some crazy stuff like Editboxes. Your solution only solves a specific case (even though I admit it's one of the few usable ones :wink: ). Subclassing has the advantage that it doesn't "taint" the old menu item and when something new is needed in the menu, you just subclass again. If everything was added to menu item, it would become more and more complex, eating memory and making maintenance harder.

Grimmigbeisser
Just popping in
Just popping in
Posts: 14
Joined: Wed Jul 28, 2010 07:22

Re: menu system extensions

Postby Grimmigbeisser » Sun Oct 31, 2010 20:05

Ok, i see your point. I agree that only the general functionality should be added to menu item and no specific stuff. Its only that i didn't classify this functionality as specific stuff, because i didn't saw the other possibilities you stated.
However, after i reviewed the possibilites to add a checkbox to a menu item, i came to the conclusion that it might be possible to do without any changes to CEGUI. Perhaps you meant this in your first reply.
It should be possible to add a child auto window checkbox to menuitem looknfeel, link its visible/checked properties to the menu item parent and set its mouse pass through property to true by default. This is just like i did it with the keybord shortcuts.
I will try to re-realize the checkable menu item that way. If this is possible i think that is the best way to implement it.

Grimmigbeisser
Just popping in
Just popping in
Posts: 14
Joined: Wed Jul 28, 2010 07:22

Re: menu system extensions

Postby Grimmigbeisser » Mon Nov 01, 2010 11:26

Alright, i tried it and found a few problems doing it the falagard only way.
For example you want the checkbox to receive clicks made all over its menu item. I found, that a checkbox in the menu item is not suitable in my use case and i'm better off with an additional falagard imagery. So i will simply put the needed properties in a MenuItem subclass and the enhanced rendering in a FalMenuItem subclass, as you suggested and everything should be fine. I will submit a patch if this is ok for you.

Grimmigbeisser
Just popping in
Just popping in
Posts: 14
Joined: Wed Jul 28, 2010 07:22

Re: menu system extensions

Postby Grimmigbeisser » Mon Nov 01, 2010 20:43

Hello again,

i have moved the checkable menu item functionality in a subclass and submitted a patch with all my changes and extensions to the menu system.

Yours sincerely,
Grimmigbeisser

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: menu system extensions

Postby Kulik » Mon Nov 08, 2010 12:50

Sorry for a late reply, I will look into this, I am unfortunately very busy right now but maybe if it doesn't break stuff it could be merged into 0.7.5. I am only concerned about (4), other changes look to be transparent at the first glance. I will also look into why checkboxes in menuitems can't be done via just falagard (because that would be a better, more generic solution). Thanks for the patch!

EDIT: I now realised that I have already digged into this and it can't be done because events can't be linked in falagard looknfeel definition (or anywhere else, no event linking in CEGUI yet). If I can come up with a clean solution to that it would allow creating all sorts of crazy menu items. I discussed this with CE on IRC and he is currently actively thinking about this :wink:

Grimmigbeisser
Just popping in
Just popping in
Posts: 14
Joined: Wed Jul 28, 2010 07:22

Re: menu system extensions

Postby Grimmigbeisser » Mon Nov 08, 2010 17:17

Ah sounds nice :) thanks for looking into it.


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 10 guests