Adding properties to widgets
Posted: Fri Dec 16, 2016 05:12
So, I have this issue in my application. I need (or, really want) to be able to place a certain menubar near the bottom of the screen. When I do, if I click on any of the menu items, the popup menu goes off the screen and I can't click on it. I want the popup menus to come up rather than down when this happens.
The behavior of the popup menu locations is set in `src/widgets/Menuitem.cpp`, in `openPopupMenu` member function. If the parent is a `Menubar*` then the popupmenu position is set to the lower left corner. If the parent is itself a `PopupMenu*`, then the popupmenu position is set to the top right corner.
The solution I've converged on is, either MenuItem or MenuBar should have an extra field which I can toggle to make the menus open the opposite direction of default. You have to do a little arithmetic with "getSize" on the popupmenu to get the positioning right.
Like a properly trained code monkey, I can see the `void MenuItem::addMenuItemProperties(void)` member function also and I can see how to extend the pattern in regards to my new property.
Let's suppose I've got that working, or close enough that I can figure it out on my own.
The questions are
- What happens to falagard then? Do I need to tell falagard about the new property, or it will just figure it out?
- What happens to CEED then? Do I need to rebuild CEED from source using my modified CEGUI sources? What's the worst thing that will happen if I don't do this?
- Do I need to do something special with the python bindings? Do they automatically know about new properties somehow, or do they need to be updated somehow?
The main thing that is giving me pause with a change like this is breaking my CEED, I <3 my CEED.
The behavior of the popup menu locations is set in `src/widgets/Menuitem.cpp`, in `openPopupMenu` member function. If the parent is a `Menubar*` then the popupmenu position is set to the lower left corner. If the parent is itself a `PopupMenu*`, then the popupmenu position is set to the top right corner.
The solution I've converged on is, either MenuItem or MenuBar should have an extra field which I can toggle to make the menus open the opposite direction of default. You have to do a little arithmetic with "getSize" on the popupmenu to get the positioning right.
Like a properly trained code monkey, I can see the `void MenuItem::addMenuItemProperties(void)` member function also and I can see how to extend the pattern in regards to my new property.
Let's suppose I've got that working, or close enough that I can figure it out on my own.
![Cool 8)](./images/smilies/icon_cool.gif)
The questions are
- What happens to falagard then? Do I need to tell falagard about the new property, or it will just figure it out?
- What happens to CEED then? Do I need to rebuild CEED from source using my modified CEGUI sources? What's the worst thing that will happen if I don't do this?
- Do I need to do something special with the python bindings? Do they automatically know about new properties somehow, or do they need to be updated somehow?
The main thing that is giving me pause with a change like this is breaking my CEED, I <3 my CEED.