how to minimize gui element?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Athlon_Jedi
Posts: 156
Joined: Wed Jul 21, 2004 4:29 am
Location: Mishawaka, In

how to minimize gui element?

Post by Athlon_Jedi »

ok so if i have this nifty chatbox as a gui element, how would i go about minimizing it when im not using it or ignoring it or what ever so it isnt muckin up the scene?

by minimizing it i mean the entire tab control.
Athlon_Jedi
Posts: 156
Joined: Wed Jul 21, 2004 4:29 am
Location: Mishawaka, In

nevermind

Post by Athlon_Jedi »

nevermind all i have decided to go a different route with my interface lol but sugestions are still welcome as i may implement this in my new design in some manner.
Dark Rain
Posts: 47
Joined: Thu Jul 07, 2005 1:31 am

Post by Dark Rain »

As far as I know, there's no real support for minimizing irrlicht windows. You'll have to add a button to your interface to do the minimize and have it make the window invisible or code some minimize animation.
Athlon_Jedi
Posts: 156
Joined: Wed Jul 21, 2004 4:29 am
Location: Mishawaka, In

yea thats kinda what i thought

Post by Athlon_Jedi »

thats kinda what i was thinking but also to set up the interface so the tab contol would acculy be a pannel on either the left or right side of the screen then add all the buttons i need and make them children of the pannel that acculy open new windows as children of the buttons and further the parent/child hiarchy with the accual usable stuff inside the windows.


ov course in game play my project is going to require 3 completly differant
gui schemes. one for the online mmorpg part, one for the singleplayer part, and one for the fps parts when the player is at a space station or on a planet or ship,

basicly i am makeing an mmorpg with a singleplayer element that gets updates from the online world and effects new abilities and such in the online world. and the fps part is where instead of how most space mmorpgs are menu drivin when you go to a station you will accualy get to get off your ship and walk about doing things :lol:
r00r

Post by r00r »

Save window contents
Destroy window object
create "minimized window object"
Assuming you have a little button on each object that calls the correct functionality. Pretty easy to do, if klutzy :)
DaChief
Posts: 45
Joined: Tue Nov 01, 2005 9:02 am
Location: Switzerland

Post by DaChief »

i'm not sure, but i thought that there is a minimize-function for the Windows...

yes, you have to create a button, but you don't have to code it... look at this:

Code: Select all

IGUIWindow* window;
IGUIButton* closeButton;

closeButton=window->getMinimizeButton();
Take a look at the API..
IrrLicht v0.14
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
Dark Rain
Posts: 47
Joined: Thu Jul 07, 2005 1:31 am

Post by Dark Rain »

There *is* a minimize button, it just doens't do anything really. You can always catch the button push event I guess but the minimize part is up to you.
DaChief
Posts: 45
Joined: Tue Nov 01, 2005 9:02 am
Location: Switzerland

Post by DaChief »

are you sure ?
strange... well i've never used this function, i only took a look at the API..

i got no new idea in that case... hope you find some solution
IrrLicht v0.14
Audiere Sounds-API v1.9.3
Current Project: KoulesXD
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The OnEvent handler of CGUIWindow doesn't do anything when you click either the minimize or restore buttons.

If you want all windows with minimize restore buttons to work, you will probably want to modify the code of CGUIWindow.h/cpp. Just handle the OnEvent when the minimize/restore/maximize button is clicked. You would need to keep track of the window size before and then restore it as appropriate. I can give some sample code.

If you only care to use it for you chat window, that same code would just go into your chat window OnEvent handler.

Travis
Athlon_Jedi
Posts: 156
Joined: Wed Jul 21, 2004 4:29 am
Location: Mishawaka, In

that would be great

Post by Athlon_Jedi »

that would rock man im lost and that could atleast point me in the right direction.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Here are the diffs from the change that I made. All minimizing does is reduce the window to the title bar. If you try to reduce the width of the window it will hide the close, minimize and restore buttons. You could add some code to realign those buttons when the window is resized, but I didn't really care for that.

Code: Select all

==== //irrlicht/irrlicht_0.14.0/source/CGUIWindow.cpp#2 (text) ====


***************
*** 17,23 ****
  
  //! constructor
  CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
! : IGUIWindow(environment, parent, id, rectangle), Dragging(false)
  {
  	#ifdef _DEBUG
  	setDebugName("CGUIWindow");
--- 17,23 ----
  
  //! constructor
  CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
! : IGUIWindow(environment, parent, id, rectangle), Dragging(false), Minimized(false)
  {
  	#ifdef _DEBUG
  	setDebugName("CGUIWindow");
***************
*** 80,85 ****
--- 80,117 ----
  				remove();
  				return true;
  			}
+ 			else
+ 			if (!Minimized && (event.GUIEvent.Caller == MinButton))
+ 			{
+ 				RestoreSize.Height = RelativeRect.getHeight();
+ 				RestoreSize.Width  = RelativeRect.getWidth();
+ 
+ 				// calculate the new size to use
+ 				s32 buttonw = Environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH);
+ 
+ 				core::rect<s32> newPosition = RelativeRect;
+ 				newPosition.LowerRightCorner.Y
+ 					= newPosition.UpperLeftCorner.Y + buttonw + 7;
+ 
+ 				setRelativePosition(newPosition);
+ 
+ 				Minimized = true;
+ 				return true;
+ 			}
+ 			else
+ 			if (Minimized && (event.GUIEvent.Caller == RestoreButton))
+ 			{
+ 				core::rect<s32> newPosition = RelativeRect;
+ 				newPosition.LowerRightCorner.X
+ 						= newPosition.UpperLeftCorner.X + RestoreSize.Width;
+ 				newPosition.LowerRightCorner.Y
+ 						= newPosition.UpperLeftCorner.Y + RestoreSize.Height;
+ 
+ 				setRelativePosition(newPosition);
+ 
+ 				Minimized = false;
+ 				return true;
+ 			}
  		}
  		break;
  	case EET_MOUSE_INPUT_EVENT:



==== //irrlicht/irrlicht_0.14.0/source/CGUIWindow.h#2 (text) ====


***************
*** 43,48 ****
--- 43,51 ----
  		core::position2d<s32> DragStart;
  		bool Dragging;
  
+ 		core::dimension2d<s32> RestoreSize;
+ 		bool Minimized;
+ 
  		IGUIButton* CloseButton;
  		IGUIButton* MinButton;
  		IGUIButton* RestoreButton;
Post Reply