Hello,
I would like to overload the GUIElement::Draw() member function in order to produce a special effect based on the mouse X.Y position. The cursor may be everywhere, not only over my custom GUI element.
I looked into the Irrlicht source code, and I haven't found a way to retreive the cursor position from draw(). Device* is not accessible using defaut irrlicht GUIElement::members.
Have I missed something obvious ?
Well, I would like to avoid passing the Irrlicht Device pointer to my custom GUI Element constructor, unless there is no other way !
Thanks,
X.
[SOLVED] Cursor position inside custom GUIElement::draw()
-
- Posts: 206
- Joined: Thu Sep 01, 2005 9:26 pm
- Location: France
[SOLVED] Cursor position inside custom GUIElement::draw()
Last edited by xterminhate on Thu Mar 07, 2013 9:59 am, edited 1 time in total.
Return to Irrlicht after years... I'm lovin it.
It's hard to be a Man !
Si vis pacem para belum
It's hard to be a Man !
Si vis pacem para belum
Re: Cursor position from inside derived GUIElement::draw()
If your custom gui-element does need the cursor then you should pass it irr::gui::ICursorControl * from the IrrlichtDevice.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 206
- Joined: Thu Sep 01, 2005 9:26 pm
- Location: France
Re: Cursor position from inside derived GUIElement::draw()
Hello,
It is exatly what I did (ICursorControl* as a member variable of my custom GUI Element). This is working well.
It could be interesting to have a getDevice() (aka getDriver() ) from IGUIEnvironnement * inside IGUIElement objects (Irrlicht 1.9 ).
Solved.
Thanks.
X.
It is exatly what I did (ICursorControl* as a member variable of my custom GUI Element). This is working well.
It could be interesting to have a getDevice() (aka getDriver() ) from IGUIEnvironnement * inside IGUIElement objects (Irrlicht 1.9 ).
Solved.
Thanks.
X.
Return to Irrlicht after years... I'm lovin it.
It's hard to be a Man !
Si vis pacem para belum
It's hard to be a Man !
Si vis pacem para belum
Re: [SOLVED] Cursor position inside custom GUIElement::draw(
No, passing that generally is a rather bad idea in OO terms. You would suddenly give all IGUIElements access to everything in Irrlicht - we could as well abondon OO all together :-) This way now anyone looking at your gui-element will see immediately that it's needing ICursorControl as you have to pass it. If we just passed IrrlichtDevice then any IGUIElement could use anything inside Irrlicht - no restrictions - the only way to ever find out what any elements needs from there on would be reading through their complete code each time.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 206
- Joined: Thu Sep 01, 2005 9:26 pm
- Location: France
Re: [SOLVED] Cursor position inside custom GUIElement::draw(
You are right. Giving access to the device is not a good idea.
X.
X.
Return to Irrlicht after years... I'm lovin it.
It's hard to be a Man !
Si vis pacem para belum
It's hard to be a Man !
Si vis pacem para belum
-
- Posts: 206
- Joined: Thu Sep 01, 2005 9:26 pm
- Location: France
Re: [SOLVED] Cursor position inside custom GUIElement::draw(
--edit : Last demonstration : http://www.youtube.com/watch?v=McE_EtnlZQM
Here is the very first result : http://www.youtube.com/watch?v=F0Zl_clgFBQ
A new custom GUI element in my collection, based on the Irrlicht GUI Window, with the features I need for my game GUI :
- Close behavior (nothing, remove, set visible false),
- Configurable system buttons,
- 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,
etc.
I will post in the code snippets, as an addon of my previous GUI element (http://irrlicht.sourceforge.net/forum/v ... =9&t=48291).
Bye,
X.
Here is the very first result : http://www.youtube.com/watch?v=F0Zl_clgFBQ
A new custom GUI element in my collection, based on the Irrlicht GUI Window, with the features I need for my game GUI :
- Close behavior (nothing, remove, set visible false),
- Configurable system buttons,
- 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,
etc.
I will post in the code snippets, as an addon of my previous GUI element (http://irrlicht.sourceforge.net/forum/v ... =9&t=48291).
Bye,
X.
Last edited by xterminhate on Sun Mar 10, 2013 9:31 pm, edited 1 time in total.
Return to Irrlicht after years... I'm lovin it.
It's hard to be a Man !
Si vis pacem para belum
It's hard to be a Man !
Si vis pacem para belum
Re: [SOLVED] Cursor position inside custom GUIElement::draw(
Nice. Also if there are simple features you need to implement your elements you can always propose them. As above I'll often decline adding features, but once in a while I also add one :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm