What is this?
This is a window control system. Basically, you create windows (called "menus" because that was the original intention) with it. The windows/menus are confined to four sectors: left, center, right, and bar.
It's easier to explain with pictures...
The buttons labelled "Win1", "Win2", and "Win3" are not part of the system! Those are for debugging.
Features
- Menus can be shown or hidden (left, right, and center - on the bar, they do nothing).
- Menu dimensions for each state can be set but have defaults.
- Menu buttons for changing the menu locations.
- Close button can alternatively act as a minimize button (on set menus, hence, you can make a single menu default to the bar on close while other menus simply close).
- Absolute rectangle of the menus is set to exclude the menu bar header (so you don't have to worry about it when adding elements)
- Click and drag menus to location! (Note, there are set areas for dragging to based on the % of the screen dedicated to the outer frame in order to keep the dragging independent of the menu size.)
- Easy to use! (see code further below)
- Optional header bar stuff: text, icon, border around icon. (see the pictures)
- Bottom bar height increases when more menus are added than fit on screen. It also shrinks when the leave. The other menu locations are changed to compensate for the bar size increase / decrease.
Bells and whistles
- Menu state changes are animated.
- Attempting to open a menu when it is already centered causes it to glow. (I wanted to apply this to the left and right open states, but I'm debating that.)
- Resources come with two sets of buttons. (I like making buttons )
How to use
Instantiation: new( gui environment, cursor control, id, parent element, absolute rectangle )
NOTE:
If no absolute rectangle is applied, the parent rectangle is used. If no parent rectangle is found, the root gui element rectangle is used. Ideally, this element would be used as one of the lowest-level elements in your setup, so you would only need to pass in 3 parameters instead of 4 or 5.
Code: Select all
// assuming your IrrlichtDevice is named "device"...
UltraGUIFrame* ultra = new UltraGUIFrame(
device->getGUIEnvironment(),
device->getCursorControl(),
1000,
device->getGUIEnvironment()->getRootGUIElement()
);
Moving on...
It's easy to add menus:
Code: Select all
irr::s32 id = 0;
irr::video::ITexture* icon = driver->getVideoDriver()->getTexture( "../art/myBarIcon.png" );
ultra->addMenu( id, icon );
/* addMenu returns a menu of type UltraGUIMenu* so you can then apply your own menu-specific features. */
The other functions are rather self-descriptive:
closeMenu( id )
closeOpenMenuAtLocation( EUltraMenuLocation location ) // see file EnumUltraMenuState.h
openMenu( id )
moveMenu( id, EUltraMenuLocation location )
setMenuState( id, EUltraMenuState state ) // see file EnumUltraMenuState
As you may have guessed, you can directly set the menu state to open or closed in any sector. The states will be animated. If you don't want the animation, do the following:
Code: Select all
// For snapping the state rather than letting it animate
UltraGUIMenu* menu;
ultra->getMenu( id, menu ); // getMenu( irr::s32, UltraGUIMenu*& )
menu->snapState();
Functions you must not call
void requestBarSpace()
void leavingBar()
These methods are called by the menus themselves. At the moment, given how I've been changing things around, these methods have been made public, but I'll probably make them protected and maintain the "friend" status of both classes, despite the fact that some people consider that useless/pointless or bad C++
What would be appreciated
Bug reports.
While I've beaten this thing, I'm sure there's probably still some bug somewhere. If someone will double check this for me, I can get this thing fully cleaned and add it to IrrExt.
DOWNLOAD
Version 1:
http://chronologicaldot.web44.net/proje ... traGUI.zip