Commit a9a62b4f authored by cutealien's avatar cutealien

Fix: Buttons can now change the image several times and the pressed image will...

Fix: Buttons can now change the image several times and the pressed image will always be updated. Fixing Bug #197 by some anonymous coder.
Note that the way this works might change again soon (I just wanted to fix old version before rewriting it).


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4739 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 35deb8bf
......@@ -261,21 +261,34 @@ void CGUIButton::draw()
if (DrawBorder)
skin->draw3DButtonPanePressed(this, AbsoluteRect, &AbsoluteClippingRect);
if (PressedImage)
video::ITexture * imgPressed = PressedImage;
core::rect<s32> rectPressed(PressedImageRect);
bool movePos = false; // pressed-down effect by moving the image
if (!imgPressed && Image)
{
imgPressed = Image;
rectPressed = ImageRect;
movePos = true;
}
else if (Image == PressedImage && PressedImageRect == ImageRect)
{
movePos = true;
}
if (imgPressed)
{
core::position2d<s32> pos = spritePos;
pos.X -= PressedImageRect.getWidth() / 2;
pos.Y -= PressedImageRect.getHeight() / 2;
pos.X -= rectPressed.getWidth() / 2;
pos.Y -= rectPressed.getHeight() / 2;
if (Image == PressedImage && PressedImageRect == ImageRect)
if (movePos)
{
pos.X += skin->getSize(EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X);
pos.Y += skin->getSize(EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y);
}
driver->draw2DImage(PressedImage,
driver->draw2DImage(imgPressed,
ScaleImage? AbsoluteRect :
core::recti(pos, PressedImageRect.getSize()),
PressedImageRect, &AbsoluteClippingRect,
core::recti(pos, rectPressed.getSize()),
rectPressed, &AbsoluteClippingRect,
0, UseAlphaChannel);
}
}
......@@ -377,9 +390,6 @@ void CGUIButton::setImage(video::ITexture* image)
Image = image;
if (image)
ImageRect = core::rect<s32>(core::position2d<s32>(0,0), image->getOriginalSize());
if (!PressedImage)
setPressedImage(Image);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment