Image for IGUIButton disabled

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
andres
Competition winner
Posts: 78
Joined: Tue Jul 08, 2008 5:18 pm
Location: Guarapuava/Brazil
Contact:

Image for IGUIButton disabled

Post by andres »

i'm not sure if this is a bug, but found the following problem:

i've an IGUIbutton that has an image (button->setImage(...)), the image works fine, but
when i disable the button using setEnable(false) the image does not change. this is bad cause the user can't see if the button is enabled or disabled. so i've added an condition on CGUIButton.cpp draw() method:

Code: Select all

if (!IsEnabled)

	{
		core::position2d<s32> pos = spritePos;

		pos.X -= ImageRect.getWidth() / 2;

		pos.Y -= ImageRect.getHeight() / 2;
		driver->draw2DRectangle(irr::video::SColor(150,255,255,255), core::recti(pos, ImageRect.getSize()) );

	}
this way i draw a simple semi-transparent rectangle over the button. So, there is another way to do this? (without recompiling the engine). We could also create a DisabledImage var an methods to set it (just like PressedImage).
Prof. Andres Jessé Porfirio
Federal Technological University of Parana (UTFPR)
www.andresjesse.com
http://irrrpgbuilder.sourceforge.net

Image
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

There is a patch for image-states on the bug-tracker, although I think it also didn't support disabled. It's something that probably should be reworked. I never dared working on that, as it seemed some work-in-process stuff (there had been sprites added in the past additional to images, but not all states there already got support for it) and I didn't know how it was planned. But I guess I better put it on my todo now - it doesn't seem others still work on that (but don't expect it anytime soon, I'm out of time for a while).

For simple GUI's you can maybe work around it by changing the image manually when you disable the button. Otherwise I can currently only recommend either to use a patched engine or to use an own button class for that.
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
Post Reply