improved look of tabs in options/help. mouse navigation still clunky

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3447 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2009-05-02 21:06:48 +00:00
parent 66cc077beb
commit b5af09764f
8 changed files with 79 additions and 31 deletions

View File

@@ -2,7 +2,7 @@
<label align="center" text="SuperTuxKart Help"/>
<tabs id="category" height="15%" max_height="150" width="75%" align="center">
<tabs id="category" height="10%" max_height="110" width="100%" align="center">
<icon-button id="page1" width="128" height="128" icon="gui/track_random.png" text="General"/>
<icon-button id="page2" width="128" height="128" icon="gui/mode_normal.png" text="Weapons"/>
<icon-button id="page3" width="128" height="128" icon="gui/mode_ftl.png" text="Game Modes"/>

View File

@@ -2,7 +2,7 @@
<label align="center" text="SuperTuxKart Help"/>
<tabs id="category" height="15%" max_height="150" width="75%" align="center">
<tabs id="category" height="10%" max_height="110" width="100%" align="center">
<icon-button id="page1" width="128" height="128" icon="gui/track_random.png" text="General"/>
<icon-button id="page2" width="128" height="128" icon="gui/mode_normal.png" text="Weapons"/>
<icon-button id="page3" width="128" height="128" icon="gui/mode_ftl.png" text="Game Modes"/>

View File

@@ -2,7 +2,7 @@
<label align="center" text="SuperTuxKart Help"/>
<tabs id="category" height="15%" max_height="150" width="75%" align="center">
<tabs id="category" height="10%" max_height="110" width="100%" align="center">
<icon-button id="page1" width="128" height="128" icon="gui/track_random.png" text="General"/>
<icon-button id="page2" width="128" height="128" icon="gui/mode_normal.png" text="Weapons"/>
<icon-button id="page3" width="128" height="128" icon="gui/mode_ftl.png" text="Game Modes"/>

View File

@@ -2,7 +2,7 @@
<label align="center" text="SuperTuxKart Options"/>
<tabs id="options_choice" height="15%" max_height="150" width="75%" align="center">
<tabs id="options_choice" height="10%" max_height="110" width="100%" align="center">
<icon-button id="audio_video" width="128" height="128" icon="gui/options_audio_video.png" text="Audio/Video"/>
<icon-button id="players" width="128" height="128" icon="gui/options_players.png" text="Players"/>
<icon-button id="controls" width="128" height="128" icon="gui/options_input.png" text="Controls"/>

View File

@@ -2,7 +2,7 @@
<label align="center" text="SuperTuxKart Options"/>
<tabs id="options_choice" height="15%" max_height="150" width="75%" align="center">
<tabs id="options_choice" height="10%" max_height="110" width="100%" align="center">
<icon-button id="audio_video" width="128" height="128" icon="gui/options_audio_video.png" text="Audio/Video"/>
<icon-button id="players" width="128" height="128" icon="gui/options_players.png" text="Players"/>
<icon-button id="controls" width="128" height="128" icon="gui/options_input.png" text="Controls"/>

View File

@@ -2,7 +2,7 @@
<label align="center" text="SuperTuxKart Options"/>
<tabs id="options_choice" height="15%" max_height="150" width="75%" align="center">
<tabs id="options_choice" height="10%" max_height="110" width="100%" align="center">
<icon-button id="audio_video" width="128" height="128" icon="gui/options_audio_video.png" text="Audio/Video"/>
<icon-button id="players" width="128" height="128" icon="gui/options_players.png" text="Players"/>
<icon-button id="controls" width="128" height="128" icon="gui/options_input.png" text="Controls"/>

View File

@@ -129,8 +129,17 @@ void Skin::drawBoxFromStretchableTexture(const core::rect< s32 > &dest, ITexture
dest_left_border = (int)(left_border *std::min<float>(yscale, 1.0));
dest_right_border = (int)(right_border *std::min<float>(yscale, 1.0));
}
const int dest_top_border = (int)(top_border *std::min<float>(yscale, 1.0));
const int dest_bottom_border = (int)(bottom_border*std::min<float>(yscale, 1.0));
int dest_top_border = (int)(top_border *std::min<float>(yscale, 1.0));
int dest_bottom_border = (int)(bottom_border*std::min<float>(yscale, 1.0));
/*
if(vertical_flip)
{
int temp = dest_bottom_border;
dest_bottom_border = dest_top_border;
dest_top_border = temp;
}*/
const float border_in_portion = 1 - border_out_portion;
const int ax = (int)(dest_x - dest_left_border*border_out_portion);
@@ -189,10 +198,10 @@ void Skin::drawBoxFromStretchableTexture(const core::rect< s32 > &dest, ITexture
if(vertical_flip)
{
#define FLIP_Y( X ) { const int y1 = X.UpperLeftCorner.Y - ay; \
const int y2 = X.LowerRightCorner.Y - ay; \
X.UpperLeftCorner.Y = ny - y2;\
X.LowerRightCorner.Y = ny - y1;}
#define FLIP_Y( X ) { const int y1 = X.UpperLeftCorner.Y - dest_y; \
const int y2 = X.LowerRightCorner.Y - dest_y; \
X.UpperLeftCorner.Y = dest_y + (dest_y2 - dest_y) - y2;\
X.LowerRightCorner.Y = dest_y + (dest_y2 - dest_y) - y1;}
FLIP_Y(dest_area_left)
FLIP_Y(dest_area_center)
@@ -348,22 +357,15 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, const Widget* widget,
/* when not using plain buttons, it's probably icons, so we need more space */
if(widget->m_type != WTYPE_BUTTON)
{
portion_out = 0.9f;
border_below = 50;
//border_below = 40;
}
core::rect< s32 > rect2 = rect;
if(vertical_flip)
{
// move up a bit
rect2.LowerRightCorner.Y -= 10;
rect2.UpperLeftCorner.Y -= 10;
}
if (mark_selected)
{
// selected tab should be slighlty bigger than others
if(vertical_flip)
rect2.UpperLeftCorner.Y -= 10;
else
@@ -373,6 +375,16 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, const Widget* widget,
left_border, right_border,
border_above, border_below, false /* horizontal aspect ratio not kept */, portion_out,
BODY | LEFT | RIGHT | TOP | BOTTOM, vertical_flip);
/*
GUIEngine::getDriver()->draw2DLine( core::position2d< s32 >(rect2.UpperLeftCorner.X,rect2.LowerRightCorner.Y),
core::position2d< s32 >(rect2.LowerRightCorner.X,rect2.LowerRightCorner.Y),
SColor(255,255,0,0) );
GUIEngine::getDriver()->draw2DLine( core::position2d< s32 >(rect2.UpperLeftCorner.X,rect2.UpperLeftCorner.Y),
core::position2d< s32 >(rect2.LowerRightCorner.X,rect2.UpperLeftCorner.Y),
SColor(255,255,0,0) );
*/
}
else
{

View File

@@ -559,11 +559,8 @@ void RibbonWidget::add()
float global_zoom = 1;
const int min_free_space = 50;
//if(free_h_space < min_free_space) // buttons are too big to fit :( zoom out
//{
global_zoom = (float)w / (float)( w - free_h_space + min_free_space );
free_h_space = (int)(w - total_needed_space*global_zoom);
//}
global_zoom = (float)w / (float)( w - free_h_space + min_free_space );
free_h_space = (int)(w - total_needed_space*global_zoom);
const int one_button_space = (int)round((float)w / (float)subbuttons_amount);
@@ -575,13 +572,51 @@ void RibbonWidget::add()
IGUIButton * subbtn;
if(m_children[i].m_type == WTYPE_BUTTON)
if(/*m_children[i].m_type == WTYPE_BUTTON*/ getRibbonType() == RIBBON_TABS)
{
rect<s32> subsize = rect<s32>(widget_x - one_button_space/2+2, 0,
widget_x + one_button_space/2-2, h);
stringw message = m_children[i].m_properties[PROP_TEXT].c_str();
subbtn = GUIEngine::getGUIEnv()->addButton(subsize, btn, ++id_counter, message.c_str(), L"");
if(m_children[i].m_type == WTYPE_BUTTON)
{
subbtn = GUIEngine::getGUIEnv()->addButton(subsize, btn, ++id_counter_2, message.c_str(), L"");
subbtn->setTabStop(false);
subbtn->setTabGroup(false);
}
else if(m_children[i].m_type == WTYPE_ICON_BUTTON)
{
rect<s32> icon_part = rect<s32>(15,
0,
subsize.getHeight()+15,
subsize.getHeight());
rect<s32> label_part = rect<s32>(subsize.getHeight()+15,
0,
subsize.getWidth()-15,
subsize.getHeight());
subbtn = GUIEngine::getGUIEnv()->addButton(subsize, btn, ++id_counter_2, L"", L"");
MyGUIButton* icon = new MyGUIButton(GUIEngine::getGUIEnv(), subbtn, ++id_counter_2, icon_part, true);
icon->setImage( GUIEngine::getDriver()->getTexture((file_manager->getDataDir() + "/" + m_children[i].m_properties[PROP_ICON]).c_str()) );
icon->setUseAlphaChannel(true);
icon->setTabStop(false);
IGUIStaticText* label = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), label_part,
false /* border */,
true /* word wrap */,
subbtn, ++id_counter_2);
label->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
label->setTabStop(false);
label->setNotClipped(true);
m_labels.push_back(label);
subbtn->setTabStop(false);
subbtn->setTabGroup(false);
}
m_children[i].m_element = subbtn;
}
else if(m_children[i].m_type == WTYPE_ICON_BUTTON)
@@ -623,14 +658,15 @@ void RibbonWidget::add()
const int final_y = subsize.getHeight() + label->getTextHeight();
if(final_y > biggest_y) biggest_y = final_y;
}
subbtn->setTabStop(false);
subbtn->setTabGroup(false);
}
else
{
std::cerr << "/!\\ Warning /!\\ : Unknown contents type in ribbon" << std::endl;
std::cerr << "/!\\ Warning /!\\ : Invalid contents type in ribbon" << std::endl;
}
subbtn->setTabStop(false);
subbtn->setTabGroup(false);
m_children[i].id = subbtn->getID();
m_children[i].m_event_handler = this;