Commit 9d2dec96 authored by hybrid's avatar hybrid

Simplify related methods, less duplicated code.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2547 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 8d02b73f
...@@ -278,8 +278,8 @@ void CGUIButton::draw() ...@@ -278,8 +278,8 @@ void CGUIButton::draw()
if (font) if (font)
font->draw(Text.c_str(), rect, font->draw(Text.c_str(), rect,
skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), true, true, skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT),
&AbsoluteClippingRect); true, true, &AbsoluteClippingRect);
} }
IGUIElement::draw(); IGUIElement::draw();
...@@ -312,10 +312,7 @@ void CGUIButton::setImage(video::ITexture* image) ...@@ -312,10 +312,7 @@ void CGUIButton::setImage(video::ITexture* image)
Image = image; Image = image;
if (image) if (image)
{ ImageRect = core::rect<s32>(core::position2d<s32>(0,0), image->getOriginalSize());
core::dimension2di signedSize(image->getOriginalSize());
ImageRect = core::rect<s32>(core::position2d<s32>(0,0), signedSize);
}
if (!PressedImage) if (!PressedImage)
setPressedImage(Image); setPressedImage(Image);
...@@ -325,16 +322,8 @@ void CGUIButton::setImage(video::ITexture* image) ...@@ -325,16 +322,8 @@ void CGUIButton::setImage(video::ITexture* image)
//! Sets the image which should be displayed on the button when it is in its normal state. //! Sets the image which should be displayed on the button when it is in its normal state.
void CGUIButton::setImage(video::ITexture* image, const core::rect<s32>& pos) void CGUIButton::setImage(video::ITexture* image, const core::rect<s32>& pos)
{ {
if (image) setImage(image);
image->grab();
if (Image)
Image->drop();
Image = image;
ImageRect = pos; ImageRect = pos;
if (!PressedImage)
setPressedImage(Image, pos);
} }
...@@ -349,22 +338,14 @@ void CGUIButton::setPressedImage(video::ITexture* image) ...@@ -349,22 +338,14 @@ void CGUIButton::setPressedImage(video::ITexture* image)
PressedImage = image; PressedImage = image;
if (image) if (image)
{ PressedImageRect = core::rect<s32>(core::position2d<s32>(0,0), image->getOriginalSize());
const core::dimension2di signedSize(image->getOriginalSize());
PressedImageRect = core::rect<s32>(core::position2d<s32>(0,0), signedSize);
}
} }
//! Sets the image which should be displayed on the button when it is in its pressed state. //! Sets the image which should be displayed on the button when it is in its pressed state.
void CGUIButton::setPressedImage(video::ITexture* image, const core::rect<s32>& pos) void CGUIButton::setPressedImage(video::ITexture* image, const core::rect<s32>& pos)
{ {
if (image) setPressedImage(image);
image->grab();
if (PressedImage)
PressedImage->drop();
PressedImage = image;
PressedImageRect = pos; PressedImageRect = pos;
} }
......
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