Collapsing widget function (#3664)
* added function to collapse a widget more easily * improved setCollapsed and added overload to specify the uncollapsed height * used new collapse functions in online track_screen
This commit is contained in:
@@ -344,6 +344,35 @@ void Widget::setVisible(bool visible)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void Widget::setCollapsed(bool collapsed, Screen* calling_screen)
|
||||
{
|
||||
// check for height > 0 to not loose height of widget in uncollapsed state
|
||||
// if widget is set to collapse twice.
|
||||
if (collapsed && m_h > 0)
|
||||
m_uncollapsed_height = m_h;
|
||||
|
||||
setCollapsed(collapsed, m_uncollapsed_height, calling_screen);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void Widget::setCollapsed(bool collapsed, int uncollapsed_height, Screen* calling_screen)
|
||||
{
|
||||
m_uncollapsed_height = uncollapsed_height;
|
||||
|
||||
setVisible(!collapsed);
|
||||
|
||||
if (collapsed)
|
||||
m_properties[GUIEngine::PROP_HEIGHT] = "0";
|
||||
else
|
||||
m_properties[GUIEngine::PROP_HEIGHT] = StringUtils::toString(m_uncollapsed_height);
|
||||
|
||||
if (calling_screen != NULL)
|
||||
calling_screen->calculateLayout();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void Widget::moveIrrlichtElement()
|
||||
{
|
||||
if (m_element != NULL)
|
||||
|
||||
@@ -275,6 +275,10 @@ namespace GUIEngine
|
||||
bool m_has_tooltip;
|
||||
irr::core::stringw m_tooltip_text;
|
||||
|
||||
|
||||
/** height of the widget before it was collapsed (only set if widget got collapsed) */
|
||||
int m_uncollapsed_height;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
@@ -346,6 +350,26 @@ namespace GUIEngine
|
||||
*/
|
||||
virtual void setVisible(bool visible);
|
||||
|
||||
/**
|
||||
* \brief Sets the widget (and its children, if any) collapsed or not.
|
||||
* !!! Note: this has to be called inside beforeAddingWidget() !!!
|
||||
* This will also set the widget invisible depending of collapsed state.
|
||||
* Note that setting a widget invisible implicitely calls setDeactivated(), and setting
|
||||
* it visible implicitely calls setActive(true). If you mix visiblity and (de)activated calls,
|
||||
* undefined behavior may ensue (like invisible but clickable buttons).
|
||||
*/
|
||||
virtual void setCollapsed(bool collapsed, Screen* calling_screen = NULL);
|
||||
|
||||
/**
|
||||
* \brief Sets the widget (and its children, if any) collapsed or not.
|
||||
* !!! Note: this has to be called inside beforeAddingWidget() !!!
|
||||
* This will also set the widget invisible depending of collapsed state.
|
||||
* Note that setting a widget invisible implicitely calls setDeactivated(), and setting
|
||||
* it visible implicitely calls setActive(true). If you mix visiblity and (de)activated calls,
|
||||
* undefined behavior may ensue (like invisible but clickable buttons).
|
||||
*/
|
||||
virtual void setCollapsed(bool collapsed, int uncollapsed_height, Screen* calling_screen = NULL);
|
||||
|
||||
/** Returns if the element is visible. */
|
||||
bool isVisible() const;
|
||||
|
||||
|
||||
@@ -225,8 +225,7 @@ void TracksScreen::beforeAddingWidget()
|
||||
m_track_icons->clear();
|
||||
if (m_network_tracks)
|
||||
{
|
||||
rect_box->setVisible(true);
|
||||
rect_box->m_properties[GUIEngine::PROP_HEIGHT] = StringUtils::toString(m_bottom_box_height);
|
||||
rect_box->setCollapsed(false, m_bottom_box_height);
|
||||
getWidget("lap-text")->setVisible(true);
|
||||
m_laps = getWidget<SpinnerWidget>("lap-spinner");
|
||||
assert(m_laps != NULL);
|
||||
@@ -317,8 +316,7 @@ void TracksScreen::beforeAddingWidget()
|
||||
else
|
||||
{
|
||||
m_timer->setVisible(false);
|
||||
rect_box->setVisible(false);
|
||||
rect_box->m_properties[GUIEngine::PROP_HEIGHT] = "0";
|
||||
rect_box->setCollapsed(true);
|
||||
m_laps = NULL;
|
||||
m_reversed = NULL;
|
||||
getWidget("lap-text")->setVisible(false);
|
||||
|
||||
Reference in New Issue
Block a user