Browse Source

Fixed UIElement priority bug when bringing element to front and no elements to compare to.

Lasse Öörni 15 years ago
parent
commit
bec3a65ee3
3 changed files with 10 additions and 9 deletions
  1. 3 3
      Bin/CoreData/UI/DefaultStyle.xml
  2. 5 4
      Engine/UI/UIElement.cpp
  3. 2 2
      Examples/Urho3D/Application.cpp

+ 3 - 3
Bin/CoreData/UI/DefaultStyle.xml

@@ -339,8 +339,8 @@
         <minsize value="400 300" />
         <movable enable="true" />
         <resizable enable="true" />
-        <resizeborder value="8 8 8 8" />
-        <layout spacing="4" border="8 8 8 8" />
+        <resizeborder value="6 6 6 6" />
+        <layout spacing="4" border="6 6 6 6" />
     </element>
     <element type="FileSelectorButton">
         <fixedsize value="96 24" />
@@ -369,7 +369,7 @@
         <selectioncolor value="0.70 0.70 0.70" />
     </element>
     <element type="FileSelectorTitleText">
-        <font name="Cour.ttf" size="12" />
+        <font name="Cour.ttf" size="10" />
     </element>
     <element type="EditorMenuBar">
         <texture name="Textures/UI.png" />

+ 5 - 4
Engine/UI/UIElement.cpp

@@ -731,22 +731,23 @@ void UIElement::bringToFront()
     if ((!ptr) || (!ptr->getBringToFront()))
         return;
     
-    // Get the highest priority used by all other top level elements, decrease their priority by one,
-    // and assign that to new front element. However, take into account only active (enabled) elements
+    // Get the highest priority used by all other top level elements, assign that to the new front element
+    // and decrease others' priority by one. However, take into account only active (enabled) elements
     // and those which have the BringToBack flag set
     int maxPriority = M_MIN_INT;
     std::vector<UIElement*> topLevelElements = root->getChildren();
     for (std::vector<UIElement*>::iterator i = topLevelElements.begin(); i != topLevelElements.end(); ++i)
     {
         UIElement* other = *i;
-        if ((other->isEnabled()) && (other->getBringToBack()) && (other != ptr))
+        if ((other->isEnabled()) && (other->mBringToBack) && (other != ptr))
         {
             int priority = other->getPriority();
             maxPriority = max(priority, maxPriority);
             other->setPriority(priority - 1);
         }
     }
-    ptr->setPriority(maxPriority);
+    if (maxPriority != M_MIN_INT)
+        ptr->setPriority(maxPriority);
 }
 
 void UIElement::addChild(UIElement* element)

+ 2 - 2
Examples/Urho3D/Application.cpp

@@ -86,10 +86,10 @@ void Application::run()
         mCache->addResourcePath(getPath(fileName));
     }
     
-    // Initialize engine & scripting. Render once to avoid the white screen (in case init takes a long time)
+    // Initialize engine & scripting. Render once first to avoid a white screen in case init takes a long time
+    mEngine->createScriptEngine();
     mEngine->init(arguments);
     mEngine->render();
-    mEngine->createScriptEngine();
     
     // Script mode: execute the rest of initialization, including scene creation, in script
     std::string extension = getExtension(fileName);