[C++] GUI Advanced Window for Irr 1.8

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
xterminhate
Posts: 206
Joined: Thu Sep 01, 2005 9:26 pm
Location: France

[C++] GUI Advanced Window for Irr 1.8

Post by xterminhate »

Hello,

Here is the last release of both GUI Advanced Window & Window Manager classes.

Demonstration : http://youtu.be/cMvjv1v26Eg

Image

New Features :
  • Windows stick to viewport borders,
  • Windows have got background picture (with alpha and color for each corner),
  • Windows have got a dedicated skin (different from other Irrlicht GUI Elements).
  • Minimized windows may be configured to stack on top, left, right or botton of the view port,
  • Minimized windows may be configured to stack in every direction (from left to right, from right to left, from top to bottom or from bottom to top).
How to create the window manager instance :

Code: Select all

CGUIWindowManager* wm =  new CGUIWindowManager( env, env->getRootGUIElement(), device->getCursorControl() );
How to create an advanced window with buttons and background texture :

Code: Select all

video::ITexture* texture = Context.driver->getTexture("../../media/xyz.jpg");
CGUIAdvancedWindow* window = wm->addWindow(
rect<s32>(150,100,350,200),
L"New Small Advanced Window",
ButtonInfo,
irr::gui::EWC_HIDE,
texture );
How to configure buttons :

Code: Select all

/// First, we create a list of buttons for the new window
core::array<CGUIAdvancedWindow::buttoninfo> ButtonInfo;
 
/// Configure the CLOSE button
CGUIAdvancedWindow::buttoninfo CloseButton;
CloseButton.Type = EWBT_CLOSE;
CloseButton.VisibleWhenNormal = true;
CloseButton.VisibleWhenBar = true;
CloseButton.VisibleWhenMinimized = false;
ButtonInfo.push_back(CloseButton);
 
/// Configure the MINIMIZE button
CGUIAdvancedWindow::buttoninfo MinimizeButton;
MinimizeButton.Type = EWBT_MINIMIZE;
ButtonInfo.push_back(MinimizeButton);
 
/// Configure the PIN button
CGUIAdvancedWindow::buttoninfo PinButton;
PinButton.Type = EWBT_PIN;
PinButton.VisibleWhenNormal = true;
PinButton.VisibleWhenBar = true;
PinButton.VisibleWhenMinimized = false;
ButtonInfo.push_back(PinButton);
 
/// Configure a Uuser-defined button
CGUIAdvancedWindow::buttoninfo MySpecialButton;
MySpecialButton.Type = EWBT_USER_DEFINED; //!< it's a user-defined button
IGUISpriteBank* bank = env->getSpriteBank("SpecialButton"); //!< here is its image
if(!bank)
{
   bank = env->addEmptySpriteBank("SpecialButton");
   bank->addTextureAsSprite(Context.driver->getTexture("../../media/reload16.png"));
   driver->makeColorKeyTexture(Context.driver->getTexture("../../media/reload16.png"), position2di(0,0));
}
MySpecialButton.Sprite = bank;
MySpecialButton.SpriteIndex = 0;
 MySpecialButton.VisibleWhenNormal = true;
 MySpecialButton.VisibleWhenBar = false;
MySpecialButton.VisibleWhenMinimized = false;
MySpecialButton.Text = L"";
MySpecialButton.ToolTipText = L"My Special Button !";
MySpecialButton.UserEventId = GUI_ID_WINDOW_SPECIAL_BUTTON;
ButtonInfo.push_back(MySpecialButton);
Download : http://xterminhate.free.fr/files/13-03- ... anager.rar
2013-03-25 Fixed issues found by Chronologicaldot :
- Improving robustness of window manager impl.

Old Download : http://xterminhate.free.fr/files/13-03- ... anager.rar
2013-03-23 Fixed issues found by Chronologicaldot :
- Closing an Advanced Window managed by the Window Manager, and confgured to be removed when close button is pressed, works properly (window is detached and removed).

Old Download : http://xterminhate.free.fr/files/13-03- ... anager.rar
2013-03-17 Improvements based on Chronologicaldot suggestions and fix window background texture :
- Adding a simple WindowManager::AddWindow() with no user-defined buttons (close, minimize and pin buttons by defaut).

Old Download : http://xterminhate.free.fr/files/13-03- ... anager.rar
2013-03-15 Improvements based on Chronologicaldot suggestions :
- Adding (INCOMPLETE) serializeAttributes and deserializeAttributes.
- Better skin usage to set the size of tittle bar.
- Adding a simple constructor for advanced windows wihtout user-defined buttons (close, minimize and pin buttons by defaut).

Old Download : http://xterminhate.free.fr/files/13-03- ... anager.rar





--------------------------------------------------------- OLD POST ---------------------------------------------------------
Hello,

Here is the source code of my last custom GUI Element, based on the Irrlicht GUI Window, I'd like to share with you.

Demonstration : http://www.youtube.com/watch?v=F0Zl_clgFBQ

Source : http://snipplr.com/users/xterminhate/ta ... cedWindow/
The main.cpp is based on Irrlicht Example #5. YOu will need this picture (Image) into your irrlicht/media directory.

Screenshot :
Image

Features :
- Configurable close button behavior (nothing, remove, set visible false),
- Configurable system buttons,
- Working Minimize button,
- Double click on minimized window maximizes it,
- Restore button shows up when window is minimized,
- Pinned button, to prevent moving the window,
- Programmable user buttons, with attributes (show/hide for each window state) and user sprite bank, posting event catched by the user defined EventReceiver,
- Double click on window bar hides window client area,
- Window frame renderer using cursor coordinates as light source) and default/user skin.
- Configurable minimized window position,
- Flag preventing window minimizing,
- Notification system, making the tittle bar to blink.

Limitation : Breaking IGUIWindow interface.

Note : I am not really satisfied with my code in term of quality, but it could give someone ideas. :(

What's next ? Combining this advanced window with the magnet window manager (http://irrlicht.sourceforge.net/forum/v ... =9&t=48291).
Here is the result : Demonstration (HD) : http://www.youtube.com/watch?v=McE_EtnlZQM


Bye.
Last edited by xterminhate on Mon Mar 25, 2013 10:22 pm, edited 9 times in total.
Return to Irrlicht after years... I'm lovin it.
It's hard to be a Man !
Si vis pacem para belum
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Re: [C++] GUI Advanced Window for Irr 1.8

Post by gerdb »

hi,

thx for working on GUIWindow, it really lacks some cool features.
The thing with showing only the windowtitle from minimized windows at the bottom of RootGUIElement is a good idea.

Imho we need a windowmanager class like AUIManager from wxWidgets kinda thing, and some basic functionality like resizing windows on all 4 borders

there should be some layoutmanager-widgets too like HBoxSizer, SplitterWindow and such.

Personally i find it hard to understand the behaviour of the irrlicht gui and how to extend it with new EVENTS like WINDOW_RESIZED, WINDOW_MOVED
furthermore how to get drag & drop working ( i.e. open image from dragged file in nautilus (linux) and dropped in my irr program )
xterminhate
Posts: 206
Joined: Thu Sep 01, 2005 9:26 pm
Location: France

Re: [C++] GUI Advanced Window for Irr 1.8

Post by xterminhate »

Thank you gerdb ! :)

I decided to code these GUI window and window manager when I switched from wxWidgets to Irrlicht for my own game project.

I did not plan to code a Sizer class, but such a feature is definitely a good idea. Someone has coded one for Irrlicht. Don't know if it still exists.

Bye.
Return to Irrlicht after years... I'm lovin it.
It's hard to be a Man !
Si vis pacem para belum
chronologicaldot
Competition winner
Posts: 688
Joined: Mon Sep 10, 2012 8:51 am

Re: [C++] GUI Advanced Window for Irr 1.8

Post by chronologicaldot »

Nice!
Out of curiosity - will this work with your CGUIDynamicGrid?
xterminhate
Posts: 206
Joined: Thu Sep 01, 2005 9:26 pm
Location: France

Re: [C++] GUI Advanced Window for Irr 1.8

Post by xterminhate »

--edit : Last demonstration : http://www.youtube.com/watch?v=McE_EtnlZQM

Hello chronologicaldot,

Yes ! :) Demonstration (HD) : http://www.youtube.com/watch?v=QFFn1C0xAjc

The GUI Advanced Window class is now integrated in the GUI Window Manager class (my old Dynamic Grid). This window manager will provide a few features like minimize all, restore all, tab window, automatic minimized window position, etc. Those GUI classes are not as generic as standard Irrlicht ones. There is a strong dependancy between window manager and advanced windows classes.

I have got a hard time with the standard skin class. I'm trying to adjust the skin in order to fit with my game theme. That doesn't at the moment. There are a few imperfections in the window rendering :)

Well, let me know if you are interested in the source code of both classes. I will share it.
Bye.

--edit1: I have found a solution for my skin issue. Now, I can set a new skin for the advanced windows classes, different from the skin of other GUI elements.
Return to Irrlicht after years... I'm lovin it.
It's hard to be a Man !
Si vis pacem para belum
Post Reply