Reset coordinates before they are updated by layout manager

This commit is contained in:
CodingJellyfish 2024-04-24 22:51:51 +08:00
parent 893c5a7b5d
commit e0be4cfc4f
3 changed files with 20 additions and 10 deletions

View File

@ -420,6 +420,7 @@ void LayoutManager::recursivelyReadCoords(PtrVector<Widget>& widgets)
// ----- read x/y/size parameters // ----- read x/y/size parameters
for (unsigned short n=0; n<widgets_amount; n++) for (unsigned short n=0; n<widgets_amount; n++)
{ {
widgets.get(n)->resetCoordinates();
readCoords(widgets.get(n)); readCoords(widgets.get(n));
}//next widget }//next widget
} }

View File

@ -60,10 +60,6 @@ Widget::Widget(WidgetType type, bool reserve_id)
m_active_event_callback[Input::IT_NONE] = false; m_active_event_callback[Input::IT_NONE] = false;
m_magic_number = 0xCAFEC001; m_magic_number = 0xCAFEC001;
m_x = -1;
m_y = -1;
m_w = -1;
m_h = -1;
m_id = -1; m_id = -1;
m_badge_x_shift = 0; m_badge_x_shift = 0;
m_element = NULL; m_element = NULL;
@ -81,11 +77,7 @@ Widget::Widget(WidgetType type, bool reserve_id)
m_has_tooltip = false; m_has_tooltip = false;
m_uncollapsed_height = 0; m_uncollapsed_height = 0;
m_is_collapsed = false; m_is_collapsed = false;
resetCoordinates();
m_absolute_x = m_absolute_y = m_absolute_w = m_absolute_h = -1;
m_relative_x = m_relative_y = m_relative_w = m_relative_h = -1;
m_absolute_reverse_x = m_absolute_reverse_y = -1;
m_tab_down_root = -1; m_tab_down_root = -1;
m_tab_up_root = -1; m_tab_up_root = -1;
@ -123,6 +115,18 @@ Widget::~Widget()
m_magic_number = 0xDEADBEEF; m_magic_number = 0xDEADBEEF;
} }
// -----------------------------------------------------------------------------
void Widget::resetCoordinates()
{
m_x = -1;
m_y = -1;
m_w = -1;
m_h = -1;
m_absolute_x = m_absolute_y = m_absolute_w = m_absolute_h = -1;
m_relative_x = m_relative_y = m_relative_w = m_relative_h = -1;
m_absolute_reverse_x = m_absolute_reverse_y = -1;
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void Widget::setEventCallbackActive(Input::InputType type, bool active) void Widget::setEventCallbackActive(Input::InputType type, bool active)
{ {

View File

@ -405,7 +405,12 @@ namespace GUIEngine
virtual EventPropagation onActivationInput(const int playerID) { return EVENT_LET; } virtual EventPropagation onActivationInput(const int playerID) { return EVENT_LET; }
/** /**
* Call to resize the widget when its coordinations are updated. * Call to reset its coordinates before they are updated by layout manager.
*/
void resetCoordinates();
/**
* Call to resize the widget after its coordinates are updated.
*/ */
virtual void resize(); virtual void resize();