Browse Source

Defer DropDown box layout until visible

Michael Ragazzon 6 years ago
parent
commit
21bfc992e4
2 changed files with 6 additions and 1 deletions
  1. 5 1
      Source/Controls/WidgetDropDown.cpp
  2. 1 0
      Source/Controls/WidgetDropDown.h

+ 5 - 1
Source/Controls/WidgetDropDown.cpp

@@ -45,6 +45,7 @@ WidgetDropDown::WidgetDropDown(ElementFormControl* element)
 
 	box_layout_dirty = false;
 	value_layout_dirty = false;
+	box_visible = false;
 
 	selected_option = -1;
 
@@ -82,7 +83,7 @@ WidgetDropDown::~WidgetDropDown()
 // Updates the selection box layout if necessary.
 void WidgetDropDown::OnRender()
 {
-	if (box_layout_dirty)
+	if (box_visible && box_layout_dirty)
 	{
 		Core::Box box;
 		Core::ElementUtilities::BuildBox(box, parent_element->GetBox().GetSize(), selection_element);
@@ -105,6 +106,8 @@ void WidgetDropDown::OnRender()
 
 void WidgetDropDown::OnLayout()
 {
+	RMLUI_ZoneScopedNC("DropDownLayout", 0x7FFF00);
+
 	if(parent_element->IsDisabled())
 	{
 		// Propagate disabled state to selectvalue and selectarrow
@@ -398,6 +401,7 @@ void WidgetDropDown::ShowSelectBox(bool show)
 		value_element->SetPseudoClass("checked", false);
 		button_element->SetPseudoClass("checked", false);
 	}
+	box_visible = show;
 }
 
 }

+ 1 - 0
Source/Controls/WidgetDropDown.h

@@ -125,6 +125,7 @@ private:
 
 	bool box_layout_dirty;
 	bool value_layout_dirty;
+	bool box_visible;
 };
 
 }