UltraGUI - Window system

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
chronologicaldot
Competition winner
Posts: 684
Joined: Mon Sep 10, 2012 8:51 am

UltraGUI - Window system

Post by chronologicaldot »

Presenting... UltraGUI ... for lack of a better name...

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...
Image
Image
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()
);
 
 
NOTE: Those of you who read the code may note that cursor control is unused. I am debating on this, since I may use it to allow for resizing the menus (a very convenient feature)... and I may want to change the mouse cursor (if that's possible) or show some arrows or something for resizing.
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 icon is the same icon I mentioned above in "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();
 
Simple as that. No need to worry about the location of the menu.

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
Last edited by chronologicaldot on Fri Aug 16, 2013 5:50 am, edited 2 times in total.
chronologicaldot
Competition winner
Posts: 684
Joined: Mon Sep 10, 2012 8:51 am

Re: UltraGUI - Window system

Post by chronologicaldot »

Reserved for updates.

Before you go pointing out the FPS - the top image is Burnings and the bottom image is OpenGL.
chronologicaldot
Competition winner
Posts: 684
Joined: Mon Sep 10, 2012 8:51 am

Re: UltraGUI - Window system

Post by chronologicaldot »

LINK FIX!
I accidentally forgot to include one of the pieces in the download - the animation system. If you downloaded without getting this, you'll need to download it again, otherwise the GUI elements won't work.

Sorry about that!
Serves me right for uploading late at night.
thanhle
Posts: 325
Joined: Wed Jun 12, 2013 8:09 am

Re: UltraGUI - Window system

Post by thanhle »

Looks fantastic mate.
Keep up the great work.

Regards
Mars_999
Posts: 136
Joined: Sat Dec 08, 2012 7:59 pm

Re: UltraGUI - Window system

Post by Mars_999 »

Can you put various textures on different buttons with this lib? Skinning I guess people would call it...

Thanks!

Keep up the great work! Be cool if some people around here who are artist's would make a few decent themes for people to test out these GUI libs with...
chronologicaldot
Competition winner
Posts: 684
Joined: Mon Sep 10, 2012 8:51 am

Re: UltraGUI - Window system

Post by chronologicaldot »

Well... You can switch out the art folder with your own. I did set up the constructor for UltraGUIMenu to receive a resource path, which you can see in the UltraGUIConstants.h file is ULTRAGUI_RESOURCE_PATH and set to irr::io::path("../resources/art/"). You can change the value here if you want to. The UltraGUIMenu defaults to receiving this path because I never gave UltraGUIFrame a io::path variable for holding the resource path (which it would pass to the UltraGUIMenu but be editable by some function such as UltraGUIFrame::setResourcePath() ). Sorry - that was an oversight on my part. I obviously planned to do it and never finished implementing it. Guess I should look into that...

And you're welcome. :)

I thought about making resources for Irrlicht, but I've had other things preoccupying me. But I do agree - it would be nice to have some new resources, especially since the stuff Irrlicht has now makes it look like Windows 98.
emadof85
Posts: 31
Joined: Sun May 25, 2014 6:10 pm

Re: UltraGUI - Window system

Post by emadof85 »

can create multi tab control , tree view , etc ????
chronologicaldot
Competition winner
Posts: 684
Joined: Mon Sep 10, 2012 8:51 am

Re: UltraGUI - Window system

Post by chronologicaldot »

Sorry for the delayed response. You can add those things to the windows/menus since those are already part of irrlicht.
Post Reply