Commit cbe3f1ac authored by cutealien's avatar cutealien

Add skin-constants to control push-button behavior better.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4321 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 0a233089
...@@ -183,6 +183,14 @@ namespace gui ...@@ -183,6 +183,14 @@ namespace gui
EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT, EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT,
//! maximal space to reserve for messagebox text-height //! maximal space to reserve for messagebox text-height
EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT, EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT,
//! pixels to move the button image to the right when a pushbutton is pressed
EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X,
//! pixels to move the button image down when a pushbutton is pressed
EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y,
//! pixels to move the button text to the right when a pushbutton is pressed
EGDS_BUTTON_PRESSED_TEXT_OFFSET_X,
//! pixels to move the button text down when a pushbutton is pressed
EGDS_BUTTON_PRESSED_TEXT_OFFSET_Y,
//! this value is not used, it only specifies the amount of default sizes //! this value is not used, it only specifies the amount of default sizes
//! available. //! available.
...@@ -210,6 +218,10 @@ namespace gui ...@@ -210,6 +218,10 @@ namespace gui
"MessageBoxMaxTextWidth", "MessageBoxMaxTextWidth",
"MessageBoxMinTextHeight", "MessageBoxMinTextHeight",
"MessageBoxMaxTextHeight", "MessageBoxMaxTextHeight",
"ButtonPressedImageOffsetX",
"ButtonPressedImageOffsetY"
"ButtonPressedTextOffsetX",
"ButtonPressedTextOffsetY",
0 0
}; };
......
...@@ -269,8 +269,8 @@ void CGUIButton::draw() ...@@ -269,8 +269,8 @@ void CGUIButton::draw()
if (Image == PressedImage && PressedImageRect == ImageRect) if (Image == PressedImage && PressedImageRect == ImageRect)
{ {
pos.X += 1; pos.X += skin->getSize(EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X);
pos.Y += 1; pos.Y += skin->getSize(EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y);
} }
driver->draw2DImage(PressedImage, driver->draw2DImage(PressedImage,
ScaleImage? AbsoluteRect : ScaleImage? AbsoluteRect :
...@@ -319,7 +319,10 @@ void CGUIButton::draw() ...@@ -319,7 +319,10 @@ void CGUIButton::draw()
core::rect<s32> rect = AbsoluteRect; core::rect<s32> rect = AbsoluteRect;
if (Pressed) if (Pressed)
rect.UpperLeftCorner.Y += 2; {
rect.UpperLeftCorner.X += skin->getSize(EGDS_BUTTON_PRESSED_TEXT_OFFSET_X);
rect.UpperLeftCorner.Y += skin->getSize(EGDS_BUTTON_PRESSED_TEXT_OFFSET_Y);
}
if (font) if (font)
font->draw(Text.c_str(), rect, font->draw(Text.c_str(), rect,
......
...@@ -119,6 +119,11 @@ CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver) ...@@ -119,6 +119,11 @@ CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver)
Sizes[EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT] = 0; Sizes[EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT] = 0;
Sizes[EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT] = 99999; Sizes[EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT] = 99999;
Sizes[EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X] = 1;
Sizes[EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y] = 1;
Sizes[EGDS_BUTTON_PRESSED_TEXT_OFFSET_X] = 0;
Sizes[EGDS_BUTTON_PRESSED_TEXT_OFFSET_Y] = 2;
Texts[EGDT_MSG_BOX_OK] = L"OK"; Texts[EGDT_MSG_BOX_OK] = L"OK";
Texts[EGDT_MSG_BOX_CANCEL] = L"Cancel"; Texts[EGDT_MSG_BOX_CANCEL] = L"Cancel";
Texts[EGDT_MSG_BOX_YES] = L"Yes"; Texts[EGDT_MSG_BOX_YES] = L"Yes";
...@@ -990,6 +995,8 @@ void CGUISkin::serializeAttributes(io::IAttributes* out, io::SAttributeReadWrite ...@@ -990,6 +995,8 @@ void CGUISkin::serializeAttributes(io::IAttributes* out, io::SAttributeReadWrite
//! scripting languages, editors, debuggers or xml deserialization purposes. //! scripting languages, editors, debuggers or xml deserialization purposes.
void CGUISkin::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) void CGUISkin::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
{ {
// TODO: This is not nice code for downward compatibility, whenever new values are added and users
// load an old skin the corresponding values will be set to 0.
u32 i; u32 i;
for (i=0; i<EGDC_COUNT; ++i) for (i=0; i<EGDC_COUNT; ++i)
Colors[i] = in->getAttributeAsColor(GUISkinColorNames[i]); Colors[i] = in->getAttributeAsColor(GUISkinColorNames[i]);
......
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