skinned checkboxes
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3397 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
05826d1e96
commit
f875392acb
BIN
data/gui/glasscheckbox.png
Normal file
BIN
data/gui/glasscheckbox.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 3.1 KiB |
BIN
data/gui/glasscheckbox_checked.png
Normal file
BIN
data/gui/glasscheckbox_checked.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 4.9 KiB |
BIN
data/gui/glasscheckbox_checked_focus.png
Normal file
BIN
data/gui/glasscheckbox_checked_focus.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 5.0 KiB |
BIN
data/gui/glasscheckbox_focus.png
Normal file
BIN
data/gui/glasscheckbox_focus.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 3.9 KiB |
@ -15,8 +15,10 @@
|
||||
<spacer proportion="1" width="10" proportion="1"/>
|
||||
|
||||
<div width="75%" height="40" layout="horizontal-row" >
|
||||
<label proportion="1" height="100%" text="Music"/>
|
||||
<checkbox id="music_enabled" proportion="1" height="100%" text="Enabled" />
|
||||
<label proportion="2" height="100%" text="Music"/>
|
||||
<checkbox id="music_enabled" width="40" icon="gui/glasscheckbox.png" height="40"/>
|
||||
<spacer width="20" height="100%" />
|
||||
<label proportion="1" height="100%" text="Enabled"/>
|
||||
</div>
|
||||
<div width="75%" height="30" layout="horizontal-row" >
|
||||
<spacer proportion="1" height="100%"/>
|
||||
@ -26,8 +28,10 @@
|
||||
<spacer proportion="1" width="10" proportion="1"/>
|
||||
|
||||
<div width="75%" height="40" layout="horizontal-row" >
|
||||
<label proportion="1" height="100%" text="Sound Effects"/>
|
||||
<checkbox id="sfx_enabled" proportion="1" height="100%" text="Enabled" />
|
||||
<label proportion="2" height="100%" text="Sound Effects"/>
|
||||
<checkbox id="sfx_enabled" width="40" icon="gui/glasscheckbox.png" height="40"/>
|
||||
<spacer width="20" height="100%" />
|
||||
<label proportion="1" height="100%" text="Enabled"/>
|
||||
</div>
|
||||
<div width="75%" height="30" layout="horizontal-row" >
|
||||
<spacer proportion="1" height="100%"/>
|
||||
|
@ -33,6 +33,11 @@ Skin::Skin(IGUISkin* fallback_skin)
|
||||
|
||||
m_tex_gaugefill = GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/glasssgauge_fill.png").c_str() );
|
||||
|
||||
|
||||
m_tex_checkbox = GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/glasscheckbox.png").c_str() );
|
||||
m_tex_fcheckbox = GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/glasscheckbox_focus.png").c_str() );
|
||||
m_tex_dcheckbox = GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/glasscheckbox_checked.png").c_str() );
|
||||
m_tex_dfcheckbox = GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/glasscheckbox_checked_focus.png").c_str() );
|
||||
}
|
||||
|
||||
Skin::~Skin()
|
||||
@ -479,6 +484,29 @@ void Skin::drawGaugeFill(const core::rect< s32 > &rect, Widget* widget, bool foc
|
||||
0 /* no clipping */, 0, true /* alpha */);
|
||||
}
|
||||
|
||||
void Skin::drawCheckBox(const core::rect< s32 > &rect, Widget* widget, bool focused)
|
||||
{
|
||||
CheckBoxWidget* w = dynamic_cast<CheckBoxWidget*>(widget);
|
||||
|
||||
const int texture_w = m_tex_checkbox->getSize().Width;
|
||||
const int texture_h = m_tex_checkbox->getSize().Height;
|
||||
|
||||
const core::rect< s32 > source_area = core::rect< s32 >(0, 0, texture_w, texture_h);
|
||||
|
||||
|
||||
|
||||
if(w->getState() == true)
|
||||
{
|
||||
GUIEngine::getDriver()->draw2DImage( focused ? m_tex_dfcheckbox : m_tex_dcheckbox, rect, source_area,
|
||||
0 /* no clipping */, 0, true /* alpha */);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUIEngine::getDriver()->draw2DImage( focused ? m_tex_fcheckbox : m_tex_checkbox, rect, source_area,
|
||||
0 /* no clipping */, 0, true /* alpha */);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#pragma mark irrlicht skin functions
|
||||
@ -551,6 +579,10 @@ void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, co
|
||||
{
|
||||
drawGaugeFill(rect, widget, focused);
|
||||
}
|
||||
else if(type == WTYPE_CHECKBOX)
|
||||
{
|
||||
drawCheckBox(rect, widget, focused);
|
||||
}
|
||||
}
|
||||
|
||||
void Skin::draw3DButtonPanePressed (IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip)
|
||||
|
@ -25,6 +25,7 @@ class Skin : public IGUISkin
|
||||
{
|
||||
IGUISkin* m_fallback_skin;
|
||||
|
||||
/* f : focused; d : down state */
|
||||
ITexture* m_tex_button;
|
||||
ITexture* m_tex_fbutton;
|
||||
ITexture* m_tex_spinner;
|
||||
@ -38,6 +39,11 @@ class Skin : public IGUISkin
|
||||
ITexture* m_tex_squarefocus;
|
||||
ITexture* m_tex_gaugefill;
|
||||
|
||||
ITexture* m_tex_checkbox;
|
||||
ITexture* m_tex_fcheckbox;
|
||||
ITexture* m_tex_dcheckbox;
|
||||
ITexture* m_tex_dfcheckbox;
|
||||
|
||||
void drawBoxFromStretchableTexture(const core::rect< s32 > &dest, ITexture* source,
|
||||
const int left_border, const int right_border,
|
||||
const int top_border, const int bottom_border,
|
||||
@ -57,6 +63,7 @@ public:
|
||||
void drawSpinnerBody(const core::rect< s32 > &rect, const Widget* widget, const bool pressed, bool focused);
|
||||
void drawGauge(const core::rect< s32 > &rect, Widget* widget, bool focused);
|
||||
void drawGaugeFill(const core::rect< s32 > &rect, Widget* widget, bool focused);
|
||||
void drawCheckBox(const core::rect< s32 > &rect, Widget* widget, bool focused);
|
||||
|
||||
// irrlicht's callbacks
|
||||
virtual void draw2DRectangle (IGUIElement *element, const video::SColor &color, const core::rect< s32 > &pos, const core::rect< s32 > *clip);
|
||||
|
@ -239,13 +239,18 @@ void LabelWidget::add()
|
||||
#pragma mark Check Box Widget
|
||||
#endif
|
||||
|
||||
CheckBoxWidget::CheckBoxWidget()
|
||||
{
|
||||
m_state = true;
|
||||
}
|
||||
|
||||
void CheckBoxWidget::add()
|
||||
{
|
||||
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
|
||||
stringw message = m_properties[PROP_TEXT].c_str();
|
||||
m_element = GUIEngine::getGUIEnv()->addCheckBox(true /* checked */, widget_size, NULL, ++id_counter, message.c_str());
|
||||
//m_element = GUIEngine::getGUIEnv()->addCheckBox(true /* checked */, widget_size, NULL, ++id_counter, message.c_str());
|
||||
|
||||
m_element = GUIEngine::getGUIEnv()->addButton(widget_size, NULL, ++id_counter, L"");
|
||||
id = m_element->getID();
|
||||
m_element->setTabOrder(id);
|
||||
m_element->setTabGroup(false);
|
||||
@ -302,7 +307,7 @@ void IconButtonWidget::add()
|
||||
if(w < texture_w) ... ;
|
||||
if(h < texture_h) ... ;
|
||||
*/
|
||||
rect<s32> widget_size;
|
||||
rect<s32> widget_size;
|
||||
if(clickable)
|
||||
{
|
||||
widget_size = rect<s32>(x, y, x + w, y + h);
|
||||
@ -318,7 +323,7 @@ void IconButtonWidget::add()
|
||||
// irrlicht widgets don't support scaling while keeping aspect ratio
|
||||
// so, happily, let's implement it ourselves
|
||||
const int x_gap = (int)((float)w - (float)texture_w * (float)h / texture_h);
|
||||
|
||||
|
||||
widget_size = rect<s32>(x + x_gap/2, y, x + w - x_gap/2, y + h);
|
||||
|
||||
IGUIImage* btn = GUIEngine::getGUIEnv()->addImage(widget_size, NULL, ++id_counter_2);
|
||||
|
@ -161,8 +161,11 @@ namespace GUIEngine
|
||||
class CheckBoxWidget : public Widget
|
||||
{
|
||||
void add();
|
||||
bool m_state;
|
||||
public:
|
||||
CheckBoxWidget();
|
||||
virtual ~CheckBoxWidget() {}
|
||||
bool getState() const { return m_state; }
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user