|
|
@ -5,6 +5,15 @@
|
|
|
|
namespace Gui
|
|
|
|
namespace Gui
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ImageButton::ImageButton()
|
|
|
|
|
|
|
|
: Base()
|
|
|
|
|
|
|
|
, mMouseFocus(false)
|
|
|
|
|
|
|
|
, mMousePress(false)
|
|
|
|
|
|
|
|
, mKeyFocus(false)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
setNeedKeyFocus(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ImageButton::setPropertyOverride(const std::string &_key, const std::string &_value)
|
|
|
|
void ImageButton::setPropertyOverride(const std::string &_key, const std::string &_value)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (_key == "ImageHighlighted")
|
|
|
|
if (_key == "ImageHighlighted")
|
|
|
@ -24,22 +33,36 @@ namespace Gui
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void ImageButton::onMouseSetFocus(Widget* _old)
|
|
|
|
void ImageButton::onMouseSetFocus(Widget* _old)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setImageTexture(mImageHighlighted);
|
|
|
|
mMouseFocus = true;
|
|
|
|
ImageBox::onMouseSetFocus(_old);
|
|
|
|
updateImage();
|
|
|
|
|
|
|
|
Base::onMouseSetFocus(_old);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ImageButton::onMouseLostFocus(Widget* _new)
|
|
|
|
void ImageButton::onMouseLostFocus(Widget* _new)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setImageTexture(mImageNormal);
|
|
|
|
mMouseFocus = false;
|
|
|
|
ImageBox::onMouseLostFocus(_new);
|
|
|
|
updateImage();
|
|
|
|
|
|
|
|
Base::onMouseLostFocus(_new);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ImageButton::onMouseButtonPressed(int _left, int _top, MyGUI::MouseButton _id)
|
|
|
|
void ImageButton::onMouseButtonPressed(int _left, int _top, MyGUI::MouseButton _id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (_id == MyGUI::MouseButton::Left)
|
|
|
|
if (_id == MyGUI::MouseButton::Left)
|
|
|
|
setImageTexture(mImagePushed);
|
|
|
|
{
|
|
|
|
|
|
|
|
mMousePress = true;
|
|
|
|
|
|
|
|
updateImage();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Base::onMouseButtonPressed(_left, _top, _id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ImageBox::onMouseButtonPressed(_left, _top, _id);
|
|
|
|
void ImageButton::updateImage()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (mMousePress)
|
|
|
|
|
|
|
|
setImageTexture(mImagePushed);
|
|
|
|
|
|
|
|
else if (mMouseFocus || mKeyFocus)
|
|
|
|
|
|
|
|
setImageTexture(mImageHighlighted);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
setImageTexture(mImageNormal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MyGUI::IntSize ImageButton::getRequestedSize()
|
|
|
|
MyGUI::IntSize ImageButton::getRequestedSize()
|
|
|
@ -70,8 +93,23 @@ namespace Gui
|
|
|
|
void ImageButton::onMouseButtonReleased(int _left, int _top, MyGUI::MouseButton _id)
|
|
|
|
void ImageButton::onMouseButtonReleased(int _left, int _top, MyGUI::MouseButton _id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (_id == MyGUI::MouseButton::Left)
|
|
|
|
if (_id == MyGUI::MouseButton::Left)
|
|
|
|
setImageTexture(mImageHighlighted);
|
|
|
|
{
|
|
|
|
|
|
|
|
mMousePress = false;
|
|
|
|
|
|
|
|
updateImage();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ImageBox::onMouseButtonReleased(_left, _top, _id);
|
|
|
|
Base::onMouseButtonReleased(_left, _top, _id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ImageButton::onKeySetFocus(MyGUI::Widget *_old)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mKeyFocus = true;
|
|
|
|
|
|
|
|
updateImage();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ImageButton::onKeyLostFocus(MyGUI::Widget *_new)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mKeyFocus = false;
|
|
|
|
|
|
|
|
updateImage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|