Browse Source

UIView should have GRAVITY_ALL so it responds to root resize properly, cleanups

Josh Engebretson 10 years ago
parent
commit
79e1e8edbc

+ 0 - 1
Source/Atomic/UI/UI.cpp

@@ -529,7 +529,6 @@ void UI::HandleScreenMode(StringHash eventType, VariantMap& eventData)
 {
 {
     using namespace ScreenMode;
     using namespace ScreenMode;
     rootWidget_->SetSize(eventData[P_WIDTH].GetInt(), eventData[P_HEIGHT].GetInt());
     rootWidget_->SetSize(eventData[P_WIDTH].GetInt(), eventData[P_HEIGHT].GetInt());
-    //SetSize(eventData[P_WIDTH].GetInt(), eventData[P_HEIGHT].GetInt());
 }
 }
 
 
 void UI::HandleUpdate(StringHash eventType, VariantMap& eventData)
 void UI::HandleUpdate(StringHash eventType, VariantMap& eventData)

+ 6 - 1
Source/Atomic/UI/UIView.cpp

@@ -34,13 +34,18 @@ UIView::UIView(Context* context) : UIWidget(context, false)
 {
 {
     widget_ = new TBWidget();
     widget_ = new TBWidget();
     widget_->SetDelegate(this);
     widget_->SetDelegate(this);
-    GetSubsystem<UI>()->WrapWidget(this, widget_);
+
+    // Set gravity all so we resize correctly
+    widget_->SetGravity(WIDGET_GRAVITY_ALL);
 
 
     UI* ui = GetSubsystem<UI>();
     UI* ui = GetSubsystem<UI>();
+    ui->WrapWidget(this, widget_);
 
 
+    // Set initial size for view
     TBRect rect = ui->GetRootWidget()->GetRect();
     TBRect rect = ui->GetRootWidget()->GetRect();
     widget_->SetSize(rect.w, rect.h);
     widget_->SetSize(rect.w, rect.h);
 
 
+    // add to the root widget
     ui->GetRootWidget()->AddChild(widget_);
     ui->GetRootWidget()->AddChild(widget_);
 
 
 }
 }

+ 4 - 0
Source/ThirdParty/TurboBadger/tb_widgets.cpp

@@ -860,15 +860,19 @@ void TBWidget::OnResized(int old_w, int old_h)
     {
     {
         if (child->GetVisibility() == WIDGET_VISIBILITY_GONE)
         if (child->GetVisibility() == WIDGET_VISIBILITY_GONE)
             continue;
             continue;
+
         TBRect rect = child->m_rect;
         TBRect rect = child->m_rect;
+
         if ((child->m_gravity & WIDGET_GRAVITY_LEFT) && (child->m_gravity & WIDGET_GRAVITY_RIGHT))
         if ((child->m_gravity & WIDGET_GRAVITY_LEFT) && (child->m_gravity & WIDGET_GRAVITY_RIGHT))
             rect.w += dw;
             rect.w += dw;
         else if(child->m_gravity & WIDGET_GRAVITY_RIGHT)
         else if(child->m_gravity & WIDGET_GRAVITY_RIGHT)
             rect.x += dw;
             rect.x += dw;
+
         if ((child->m_gravity & WIDGET_GRAVITY_TOP) && (child->m_gravity & WIDGET_GRAVITY_BOTTOM))
         if ((child->m_gravity & WIDGET_GRAVITY_TOP) && (child->m_gravity & WIDGET_GRAVITY_BOTTOM))
             rect.h += dh;
             rect.h += dh;
         else if (child->m_gravity & WIDGET_GRAVITY_BOTTOM)
         else if (child->m_gravity & WIDGET_GRAVITY_BOTTOM)
             rect.y += dh;
             rect.y += dh;
+
         child->SetRect(rect);
         child->SetRect(rect);
     }
     }
 }
 }