Bläddra i källkod

Layout updates

Josh Engebretson 10 år sedan
förälder
incheckning
c377460363

+ 4 - 8
Source/AtomicEditor/Source/Editors/JSResourceEditor.cpp

@@ -49,9 +49,6 @@ JSResourceEditor ::JSResourceEditor(Context* context, const String &fullpath, TB
     currentFindPos_(-1)
     currentFindPos_(-1)
 {
 {
 
 
-    rootContentWidget_ = new TBWidget();
-    rootContentWidget_->SetGravity(WIDGET_GRAVITY_ALL);
-
     TBLayout* layout = new TBLayout();
     TBLayout* layout = new TBLayout();
     layout->SetLayoutSize(LAYOUT_SIZE_GRAVITY);
     layout->SetLayoutSize(LAYOUT_SIZE_GRAVITY);
     layout->SetGravity(WIDGET_GRAVITY_ALL);
     layout->SetGravity(WIDGET_GRAVITY_ALL);
@@ -108,8 +105,6 @@ JSResourceEditor ::JSResourceEditor(Context* context, const String &fullpath, TB
     layout->AddChild(c);
     layout->AddChild(c);
     layout->SetSpacing(0);
     layout->SetSpacing(0);
 
 
-    container_->GetContentRoot()->AddChild(rootContentWidget_);
-
     TBStyleEdit* sedit = text->GetStyleEdit();
     TBStyleEdit* sedit = text->GetStyleEdit();
     TBTextTheme* theme = new TBTextTheme();
     TBTextTheme* theme = new TBTextTheme();
     for (unsigned i = 0; i < TB_MAX_TEXT_THEME_COLORS; i++)
     for (unsigned i = 0; i < TB_MAX_TEXT_THEME_COLORS; i++)
@@ -152,6 +147,10 @@ JSResourceEditor ::JSResourceEditor(Context* context, const String &fullpath, TB
 
 
     SubscribeToEvent(E_UPDATE, HANDLER(JSResourceEditor, HandleUpdate));
     SubscribeToEvent(E_UPDATE, HANDLER(JSResourceEditor, HandleUpdate));
 
 
+    // FIXME: Set the size at the end of setup, so all children are updated accordingly
+    // future size changes will be handled automatically
+    TBRect rect = container_->GetContentRoot()->GetRect();
+    rootContentWidget_->SetSize(rect.w, rect.h);
 }
 }
 
 
 JSResourceEditor::~JSResourceEditor()
 JSResourceEditor::~JSResourceEditor()
@@ -362,9 +361,6 @@ void JSResourceEditor::HandleUpdate(StringHash eventType, VariantMap& eventData)
     if (!styleEdit_)
     if (!styleEdit_)
         return;
         return;
 
 
-    // FIXME
-    rootContentWidget_->SetSize(rootContentWidget_->GetParent()->GetRect().w, rootContentWidget_->GetParent()->GetRect().h);
-
     // sync line number
     // sync line number
     lineNumberList_->GetScrollContainer()->ScrollTo(0, styleEdit_->scroll_y);
     lineNumberList_->GetScrollContainer()->ScrollTo(0, styleEdit_->scroll_y);
     lineNumberList_->SetValue(styleEdit_->GetCaretLine());
     lineNumberList_->SetValue(styleEdit_->GetCaretLine());

+ 4 - 0
Source/AtomicEditor/Source/Editors/ResourceEditor.cpp

@@ -80,6 +80,10 @@ ResourceEditor::ResourceEditor(Context* context, const String& fullpath, TBTabCo
 
 
     container_->GetTabLayout()->AddChild(editorTabLayout_);
     container_->GetTabLayout()->AddChild(editorTabLayout_);
 
 
+    rootContentWidget_ = new TBWidget();
+    rootContentWidget_->SetGravity(WIDGET_GRAVITY_ALL);
+    container_->GetContentRoot()->AddChild(rootContentWidget_);
+
     SubscribeToEvent(E_FILECHANGED, HANDLER(ResourceEditor, HandleFileChanged));
     SubscribeToEvent(E_FILECHANGED, HANDLER(ResourceEditor, HandleFileChanged));
 }
 }
 
 

+ 5 - 9
Source/AtomicEditor/Source/Editors/SceneEditor3D/SceneEditor3D.cpp

@@ -35,9 +35,6 @@ namespace AtomicEditor
 SceneEditor3D ::SceneEditor3D(Context* context, const String &fullpath, TBTabContainer *container) :
 SceneEditor3D ::SceneEditor3D(Context* context, const String &fullpath, TBTabContainer *container) :
     ResourceEditor(context, fullpath, container)
     ResourceEditor(context, fullpath, container)
 {
 {
-    rootContentWidget_ = new TBWidget();
-    rootContentWidget_->SetGravity(WIDGET_GRAVITY_ALL);
-
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
 
 
     scene_ = new Scene(context_);
     scene_ = new Scene(context_);
@@ -57,8 +54,6 @@ SceneEditor3D ::SceneEditor3D(Context* context, const String &fullpath, TBTabCon
 
 
     rootContentWidget_->AddChild(delegate);
     rootContentWidget_->AddChild(delegate);
 
 
-    container_->GetContentRoot()->AddChild(rootContentWidget_);
-
     gizmo3D_ = new Gizmo3D(context_);
     gizmo3D_ = new Gizmo3D(context_);
     gizmo3D_->SetView(sceneView_);
     gizmo3D_->SetView(sceneView_);
     gizmo3D_->Show();
     gizmo3D_->Show();
@@ -66,6 +61,11 @@ SceneEditor3D ::SceneEditor3D(Context* context, const String &fullpath, TBTabCon
     SubscribeToEvent(E_UPDATE, HANDLER(SceneEditor3D, HandleUpdate));
     SubscribeToEvent(E_UPDATE, HANDLER(SceneEditor3D, HandleUpdate));
     SubscribeToEvent(E_EDITORACTIVENODECHANGE, HANDLER(SceneEditor3D, HandleEditorActiveNodeChange));
     SubscribeToEvent(E_EDITORACTIVENODECHANGE, HANDLER(SceneEditor3D, HandleEditorActiveNodeChange));
 
 
+    // FIXME: Set the size at the end of setup, so all children are updated accordingly
+    // future size changes will be handled automatically
+    TBRect rect = container_->GetContentRoot()->GetRect();
+    rootContentWidget_->SetSize(rect.w, rect.h);
+
     // TODO: generate this event properly
     // TODO: generate this event properly
     VariantMap eventData;
     VariantMap eventData;
     eventData[EditorActiveSceneChange::P_SCENE] = scene_;
     eventData[EditorActiveSceneChange::P_SCENE] = scene_;
@@ -109,10 +109,6 @@ void SceneEditor3D::SelectNode(Node* node)
 
 
 void SceneEditor3D::HandleUpdate(StringHash eventType, VariantMap& eventData)
 void SceneEditor3D::HandleUpdate(StringHash eventType, VariantMap& eventData)
 {    
 {    
-
-    // FIXME
-    rootContentWidget_->SetSize(rootContentWidget_->GetParent()->GetRect().w, rootContentWidget_->GetParent()->GetRect().h);
-
     Vector<Node*> editNodes;
     Vector<Node*> editNodes;
     editNodes.Push(selectedNode_);
     editNodes.Push(selectedNode_);
     gizmo3D_->Update(editNodes);
     gizmo3D_->Update(editNodes);

+ 6 - 9
Source/AtomicEditor/Source/Editors/TextResourceEditor.cpp

@@ -33,12 +33,9 @@ TextResourceEditor ::TextResourceEditor(Context* context, const String &fullpath
     modified_(false),
     modified_(false),
     currentFindPos_(-1)
     currentFindPos_(-1)
 {
 {
-    rootContentWidget_ = new TBWidget();
-    rootContentWidget_->SetGravity(WIDGET_GRAVITY_ALL);
 
 
     TBLayout* layout =  new TBLayout();
     TBLayout* layout =  new TBLayout();
     layout->SetLayoutDistribution(LAYOUT_DISTRIBUTION_GRAVITY);
     layout->SetLayoutDistribution(LAYOUT_DISTRIBUTION_GRAVITY);
-    layout->SetSize(container_->GetRect().w, container_->GetRect().h);
     layout->SetGravity(WIDGET_GRAVITY_ALL);
     layout->SetGravity(WIDGET_GRAVITY_ALL);
 
 
     rootContentWidget_->AddChild(layout);
     rootContentWidget_->AddChild(layout);
@@ -71,8 +68,6 @@ TextResourceEditor ::TextResourceEditor(Context* context, const String &fullpath
     layout->AddChild(c);
     layout->AddChild(c);
     layout->SetSpacing(0);
     layout->SetSpacing(0);
 
 
-    container_->GetContentRoot()->AddChild(rootContentWidget_);
-
     TBStyleEdit* sedit = text->GetStyleEdit();
     TBStyleEdit* sedit = text->GetStyleEdit();
     sedit->text_change_listener = this;
     sedit->text_change_listener = this;
 
 
@@ -86,6 +81,12 @@ TextResourceEditor ::TextResourceEditor(Context* context, const String &fullpath
 
 
     SubscribeToEvent(E_UPDATE, HANDLER(TextResourceEditor, HandleUpdate));
     SubscribeToEvent(E_UPDATE, HANDLER(TextResourceEditor, HandleUpdate));
 
 
+    // FIXME: Set the size at the end of setup, so all children are updated accordingly
+    // future size changes will be handled automatically
+    TBRect rect = container_->GetContentRoot()->GetRect();
+    rootContentWidget_->SetSize(rect.w, rect.h);
+
+
 }
 }
 
 
 TextResourceEditor::~TextResourceEditor()
 TextResourceEditor::~TextResourceEditor()
@@ -204,12 +205,8 @@ void TextResourceEditor::HandleUpdate(StringHash eventType, VariantMap& eventDat
 
 
     if (!styleEdit_)
     if (!styleEdit_)
         return;
         return;
-
-    // FIXME
-    rootContentWidget_->SetSize(rootContentWidget_->GetParent()->GetRect().w, rootContentWidget_->GetParent()->GetRect().h);
 }
 }
 
 
-
 void TextResourceEditor::FindTextClose()
 void TextResourceEditor::FindTextClose()
 {
 {
     editField_->SetFocus(WIDGET_FOCUS_REASON_UNKNOWN);
     editField_->SetFocus(WIDGET_FOCUS_REASON_UNKNOWN);