Main menu : prevent text on mouse over from overflowing the bounds of the screen. FIxes #2163
This commit is contained in:
parent
33a60ae8d5
commit
e0dd736a7c
@ -39,31 +39,31 @@
|
||||
<spacer width="10" height="10" />
|
||||
|
||||
<buttonbar id="menu_bottomrow" x="0" y="0" width="38%" height="100%" align="center">
|
||||
<icon-button id="test_gpwin" width="64" height="64" icon="gui/main_options.png" extend_label="50"
|
||||
<icon-button id="test_gpwin" width="64" height="64" icon="gui/main_options.png"
|
||||
raw_text="TEST: GPWin" label_location="hover"/>
|
||||
<icon-button id="test_gplose" width="64" height="64" icon="gui/main_options.png" extend_label="50"
|
||||
<icon-button id="test_gplose" width="64" height="64" icon="gui/main_options.png"
|
||||
raw_text="TEST: GPLose" label_location="hover"/>
|
||||
<icon-button id="test_unlocked" width="64" height="64" icon="gui/main_options.png" extend_label="50"
|
||||
<icon-button id="test_unlocked" width="64" height="64" icon="gui/main_options.png"
|
||||
raw_text="TEST: Unlocked" label_location="hover"/>
|
||||
<icon-button id="test_unlocked2" width="64" height="64" icon="gui/main_options.png" extend_label="50"
|
||||
<icon-button id="test_unlocked2" width="64" height="64" icon="gui/main_options.png"
|
||||
raw_text="TEST: Unlocked 2" label_location="hover"/>
|
||||
<icon-button id="test_intro" width="64" height="64" icon="gui/main_options.png" extend_label="50"
|
||||
<icon-button id="test_intro" width="64" height="64" icon="gui/main_options.png"
|
||||
raw_text="TEST: Intro" label_location="hover"/>
|
||||
<icon-button id="test_outro" width="64" height="64" icon="gui/main_options.png" extend_label="50"
|
||||
<icon-button id="test_outro" width="64" height="64" icon="gui/main_options.png"
|
||||
raw_text="TEST: Outro" label_location="hover"/>
|
||||
<icon-button id="options" width="64" height="64" icon="gui/main_options.png" extend_label="50"
|
||||
<icon-button id="options" width="64" height="64" icon="gui/main_options.png"
|
||||
I18N="In the main screen" text="Options" label_location="hover"/>
|
||||
<icon-button id="help" width="64" height="64" icon="gui/main_help.png" extend_label="50"
|
||||
<icon-button id="help" width="64" height="64" icon="gui/main_help.png"
|
||||
I18N="In the main screen" text="Help" label_location="hover"/>
|
||||
<icon-button id="startTutorial" width="64" height="64" icon="gui/tutorial.png" extend_label="150"
|
||||
<icon-button id="startTutorial" width="64" height="64" icon="gui/tutorial.png"
|
||||
I18N="In the main screen" text="Tutorial" label_location="hover"/>
|
||||
<icon-button id="achievements" width="64" height="64" icon="gui/gp_copy.png" extend_label="150"
|
||||
<icon-button id="achievements" width="64" height="64" icon="gui/gp_copy.png"
|
||||
I18N="In the main screen" text="Achievements" label_location="hover"/>
|
||||
<icon-button id="gpEditor" width="64" height="64" icon="gui/gpeditor.png" extend_label="150"
|
||||
<icon-button id="gpEditor" width="64" height="64" icon="gui/gpeditor.png"
|
||||
I18N="In the main screen" text="Grand Prix Editor" label_location="hover"/>
|
||||
<icon-button id="about" width="64" height="64" icon="gui/main_about.png" extend_label="50"
|
||||
<icon-button id="about" width="64" height="64" icon="gui/main_about.png"
|
||||
I18N="In the main screen" text="About" label_location="hover"/>
|
||||
<icon-button id="quit" width="64" height="64" icon="gui/main_quit.png" extend_label="50"
|
||||
<icon-button id="quit" width="64" height="64" icon="gui/main_quit.png"
|
||||
I18N="In the main screen" text="Quit" label_location="hover"/>
|
||||
</buttonbar>
|
||||
</bottombar>
|
||||
|
@ -167,11 +167,34 @@ void IconButtonWidget::add()
|
||||
|
||||
if (m_properties[PROP_LABELS_LOCATION] == "hover")
|
||||
{
|
||||
widget_size = rect<s32>(m_x - label_extra_size/2,
|
||||
m_y - (word_wrap ? GUIEngine::getFontHeight()*2 :
|
||||
GUIEngine::getFontHeight()) - 15,
|
||||
m_x + m_w + label_extra_size/2,
|
||||
m_y - 15);
|
||||
core::dimension2du text_size = GUIEngine::getFont()->getDimension(message.c_str());
|
||||
core::recti pos = btn->getAbsolutePosition();
|
||||
int center_x = pos.UpperLeftCorner.X + pos.getWidth() / 2;
|
||||
int x1 = center_x - text_size.Width / 2 - label_extra_size / 2;
|
||||
int y1 = pos.UpperLeftCorner.Y - (word_wrap ? GUIEngine::getFontHeight() * 2 :
|
||||
GUIEngine::getFontHeight()) - 15;
|
||||
int x2 = center_x + text_size.Width / 2 + label_extra_size / 2;
|
||||
int y2 = pos.UpperLeftCorner.Y - 15;
|
||||
|
||||
if (x1 < 0)
|
||||
{
|
||||
int diff = -x1;
|
||||
x1 += diff;
|
||||
x2 += diff;
|
||||
}
|
||||
else if (x2 > irr_driver->getActualScreenSize().Width)
|
||||
{
|
||||
int diff = x2 - irr_driver->getActualScreenSize().Width;
|
||||
x2 -= diff;
|
||||
x1 -= diff;
|
||||
}
|
||||
|
||||
core::recti parent_pos = m_parent->getAbsolutePosition();
|
||||
x1 -= parent_pos.UpperLeftCorner.X;
|
||||
x2 -= parent_pos.UpperLeftCorner.X;
|
||||
y1 -= parent_pos.UpperLeftCorner.Y;
|
||||
y2 -= parent_pos.UpperLeftCorner.Y;
|
||||
widget_size = rect<s32>(x1, y1, x2, y2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user