Support setting the flip direction of tabs explicitly.
This commit is contained in:
parent
f4da9718c5
commit
69729e3e83
@ -1082,11 +1082,17 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget,
|
||||
else
|
||||
params = &SkinConfig::m_render_params["tab::neutral"];
|
||||
|
||||
RibbonFlip flip = parentRibbon->getRibbonFlip();
|
||||
|
||||
// automatically guess from position on-screen if tabs go up or down
|
||||
const bool vertical_flip =
|
||||
bool vertical_flip =
|
||||
(unsigned int)rect.UpperLeftCorner.Y <
|
||||
irr_driver->getActualScreenSize().Height / 2;
|
||||
// force flip direction when the direction is pointed out
|
||||
if(flip == FLIP_UP_LEFT)
|
||||
vertical_flip = true;
|
||||
else if(flip == FLIP_DOWN_RIGHT)
|
||||
vertical_flip = false;
|
||||
params->m_vertical_flip = vertical_flip;
|
||||
|
||||
core::recti rect2 = rect;
|
||||
@ -1132,11 +1138,17 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget,
|
||||
else
|
||||
params = &SkinConfig::m_render_params["verticalTab::neutral"];
|
||||
|
||||
RibbonFlip flip = parentRibbon->getRibbonFlip();
|
||||
|
||||
// automatically guess from position on-screen if tabs go left or right
|
||||
unsigned int screen_width = irr_driver->getActualScreenSize().Width;
|
||||
const bool horizontal_flip =
|
||||
bool horizontal_flip =
|
||||
(unsigned int)rect.UpperLeftCorner.X > screen_width/ 2;
|
||||
// force flip direction when the direction is pointed out
|
||||
if(flip == FLIP_UP_LEFT)
|
||||
horizontal_flip = true;
|
||||
else if(flip == FLIP_DOWN_RIGHT)
|
||||
horizontal_flip = false;
|
||||
params->m_vertical_flip = false;
|
||||
|
||||
core::recti rect2 = rect;
|
||||
|
@ -460,7 +460,7 @@ void RibbonWidget::add()
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::warn("RiggonWidget", "Invalid contents type in ribbon");
|
||||
Log::warn("RibbonWidget", "Invalid contents type in ribbon");
|
||||
}
|
||||
|
||||
|
||||
@ -921,7 +921,18 @@ void RibbonWidget::setItemVisible(const unsigned int id, bool visible)
|
||||
if (m_labels.size() == 0) return;
|
||||
|
||||
m_labels[id].setVisible(visible);
|
||||
} // RibbonWidget
|
||||
} // setItemVisible
|
||||
|
||||
void RibbonWidget::setFlip(RibbonFlip direction)
|
||||
{
|
||||
if(m_ribbon_type == RIBBON_TABS || m_ribbon_type == RIBBON_VERTICAL_TABS)
|
||||
m_ribbon_flip = direction;
|
||||
else
|
||||
{
|
||||
Log::warn("RibbonWidget", "A flip is set to a not-tab ribbon.");
|
||||
m_ribbon_flip = FLIP_NO;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
int RibbonWidget::findItemNamed(const char* internalName)
|
||||
@ -942,4 +953,4 @@ Widget* RibbonWidget::findWidgetNamed(const char* internalName)
|
||||
if (id >= 0)
|
||||
return m_children.get(id);
|
||||
return NULL;
|
||||
} // findItemNamed
|
||||
} // findWidgetNamed
|
||||
|
@ -40,6 +40,14 @@ namespace GUIEngine
|
||||
RIBBON_TABS, //!< a tab bar
|
||||
RIBBON_VERTICAL_TABS //!< a vertical tab bar
|
||||
};
|
||||
|
||||
/** Filp directions of ribbons */
|
||||
enum RibbonFlip
|
||||
{
|
||||
FLIP_NO, // For non-tab ribbons
|
||||
FLIP_UP_LEFT, // For horizontal tabs it goes up vertical ones it goes left
|
||||
FLIP_DOWN_RIGHT // For horizontal tabs it goes down vertical ones it goes right
|
||||
};
|
||||
|
||||
/** \brief A static text/icons/tabs bar widget.
|
||||
* The contents of this ribbon are static.
|
||||
@ -69,6 +77,9 @@ namespace GUIEngine
|
||||
|
||||
/** The type of this ribbon (toolbar, combo, tabs, vertical tabs) */
|
||||
RibbonType m_ribbon_type;
|
||||
|
||||
/** The flip direction of this ribbon */
|
||||
RibbonFlip m_ribbon_flip;
|
||||
|
||||
/** Each item within the ribbon holds a flag saying whether it is
|
||||
* selected or not. This method updates the flag in all of this
|
||||
@ -130,6 +141,9 @@ namespace GUIEngine
|
||||
* for detailed descriptions) */
|
||||
RibbonType getRibbonType() const { return m_ribbon_type; }
|
||||
// --------------------------------------------------------------------
|
||||
/** Returns the flip direction of thin ribbon */
|
||||
RibbonFlip getRibbonFlip() const { return m_ribbon_flip; }
|
||||
// --------------------------------------------------------------------
|
||||
/** Returns the number of active items within the ribbon */
|
||||
int getActiveChildrenNumber(const int playerID) const
|
||||
{ return m_active_children.size(); }
|
||||
@ -167,6 +181,8 @@ namespace GUIEngine
|
||||
void setLabel(const unsigned int id, irr::core::stringw new_name);
|
||||
|
||||
void setItemVisible(const unsigned int id, bool visible);
|
||||
|
||||
void setFlip(RibbonFlip direction);
|
||||
|
||||
/** Returns the ID of the item, or -1 if not found */
|
||||
int findItemNamed(const char* internalName);
|
||||
|
@ -51,6 +51,7 @@ void GrandPrixEditorScreen::beforeAddingWidget()
|
||||
assert (tabs != NULL);
|
||||
|
||||
tabs->clearAllChildren();
|
||||
tabs->setFlip(FLIP_DOWN_RIGHT);
|
||||
for (int i = 0; i < GrandPrixData::GP_GROUP_COUNT; i++)
|
||||
{
|
||||
core::stringw label = getGroupName((enum GrandPrixData::GPGroupType)i);
|
||||
|
Loading…
x
Reference in New Issue
Block a user