Ver Fonte

Merge pull request #596 from AtomicGameEngine/JME-ATOMIC-595

UIView should have GRAVITY_ALL so responds to root resize properly, cleanups
JoshEngebretson há 10 anos atrás
pai
commit
067a40d62e

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

@@ -529,7 +529,6 @@ void UI::HandleScreenMode(StringHash eventType, VariantMap& eventData)
 {
     using namespace ScreenMode;
     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)

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

@@ -34,13 +34,18 @@ UIView::UIView(Context* context) : UIWidget(context, false)
 {
     widget_ = new TBWidget();
     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->WrapWidget(this, widget_);
 
+    // Set initial size for view
     TBRect rect = ui->GetRootWidget()->GetRect();
     widget_->SetSize(rect.w, rect.h);
 
+    // add to the root 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)
             continue;
+
         TBRect rect = child->m_rect;
+
         if ((child->m_gravity & WIDGET_GRAVITY_LEFT) && (child->m_gravity & WIDGET_GRAVITY_RIGHT))
             rect.w += dw;
         else if(child->m_gravity & WIDGET_GRAVITY_RIGHT)
             rect.x += dw;
+
         if ((child->m_gravity & WIDGET_GRAVITY_TOP) && (child->m_gravity & WIDGET_GRAVITY_BOTTOM))
             rect.h += dh;
         else if (child->m_gravity & WIDGET_GRAVITY_BOTTOM)
             rect.y += dh;
+
         child->SetRect(rect);
     }
 }