#339 Autosize bug is exterminated 4.x-dev

Wed, 03 Nov 2021 07:09:46 +0200

author
cemkalyoncu
date
Wed, 03 Nov 2021 07:09:46 +0200
branch
4.x-dev
changeset 1756
1fac91a506bf
parent 1755
27fffa70862d
child 1757
af3a7aed9dfe

#339 Autosize bug is exterminated

Source/Gorgon/UI/ComponentStack.h file | annotate | diff | comparison | revisions
Source/Gorgon/UI/ComponentStackWidget.h file | annotate | diff | comparison | revisions
Source/Gorgon/UI/Widget.cpp file | annotate | diff | comparison | revisions
Testing/Source/Manual/UI_WidgetTest.cpp file | annotate | diff | comparison | revisions
--- a/Source/Gorgon/UI/ComponentStack.h	Tue Nov 02 06:45:49 2021 +0200
+++ b/Source/Gorgon/UI/ComponentStack.h	Wed Nov 03 07:09:46 2021 +0200
@@ -281,10 +281,9 @@
         
         /// Notifies the stack about a size change
         virtual void Resize(const Geometry::Size &value) override {
-            Layer::Resize(value);
-            mouse.Resize(value);
-            
-            if(size != value) {
+            if(size != value || Layer::GetSize() != value) {
+                Layer::Resize(value);
+                mouse.Resize(value);
                 size = value;
                 Update();
             }
--- a/Source/Gorgon/UI/ComponentStackWidget.h	Tue Nov 02 06:45:49 2021 +0200
+++ b/Source/Gorgon/UI/ComponentStackWidget.h	Wed Nov 03 07:09:46 2021 +0200
@@ -152,7 +152,7 @@
         /// Adjusts autosizing of the widget. Setting autosize to true sets the autosize to
         /// automatic to nearest unit size
         void SetAutosize(bool hor, bool ver) {
-            SetAutosize(hor ? Autosize::Unit : Autosize::None, ver ? Autosize::Unit : Autosize::None);
+            SetAutosize(hor ? Autosize::Unit : Autosize::None, ver ? Autosize::Automatic : Autosize::None);
         }
 
         /// Adjusts autosizing of the widget. Setting autosize to true sets the autosize to
@@ -164,7 +164,7 @@
         /// Adjusts autosizing of the widget. Setting autosize to true sets the autosize to
         /// automatic to nearest unit size
         void SetVerticalAutosize(bool value) {
-            SetVerticalAutosize(value ? Autosize::Unit : Autosize::None);
+            SetVerticalAutosize(value ? Autosize::Automatic : Autosize::None);
         }
 
         /// Returns the horizontal autosize mode of the widget
--- a/Source/Gorgon/UI/Widget.cpp	Tue Nov 02 06:45:49 2021 +0200
+++ b/Source/Gorgon/UI/Widget.cpp	Wed Nov 03 07:09:46 2021 +0200
@@ -78,8 +78,10 @@
 
         parent = &container;
 
-        if(IsVisible())
+        if(IsVisible()) {
+            calculatebounds();
             boundschanged();
+        }
 
         parentenabledchanged(parent->IsEnabled());
     }
--- a/Testing/Source/Manual/UI_WidgetTest.cpp	Tue Nov 02 06:45:49 2021 +0200
+++ b/Testing/Source/Manual/UI_WidgetTest.cpp	Wed Nov 03 07:09:46 2021 +0200
@@ -6,6 +6,7 @@
 #include <Gorgon/Widgets/Window.h>
 #include <Gorgon/Widgets/TabPanel.h>
 #include <Gorgon/Widgets/Button.h>
+#include <Gorgon/UI/Dialog.h>
 #include <Gorgon/Widgets/Label.h>
 
 std::string helptext =
@@ -19,39 +20,18 @@
 int main() {
     basic_Application<UI::Window> app("uitest", "UI Widget Test", helptext, 1, 0x80);
 
-    auto &org = app.wind.CreateOrganizer<UI::Organizers::Flow>();
-    
-    Widgets::TabPanel wgt1;
-    
-    org
-        << wgt1;
-
-    wgt1.Focus();
-
-    wgt1.New("Tab 1");
-    wgt1.New("Tab 2");
-    wgt1.New("Tab 3");
-    wgt1.New("Tab 4");
-    wgt1.SetTabRollover(true);
-    //wgt1.SetButtonTextWrap(true);
+    //auto &org = app.wind.CreateOrganizer<UI::Organizers::Flow>();
+    Widgets::Panel w;
 
-    Widgets::Button btn1("Hey tab 1");
-    Widgets::Label lbl1("Hey tab 2");
-    Widgets::Label lbl2("Tab control is now working, scroll down for the button");
-    lbl2.SetAutosize(UI::Autosize::Automatic, UI::Autosize::Automatic);
-    Widgets::Button btn2("Hey tab 2");
+    app.wind.Add(w);
+    w.Location.X = 50_perc;
+    
+    Widgets::MarkdownLabel lbl2("This class is the base class for all **widget** containers.\n\nAll widgets require a layer to be placed on, to allow widget containers that are also widgets, this class is left abstract. You may derive from this class and WidgetBase at the same time. Visit <https://darkgaze.org> for more.\n\n[Working directory](.)");
+    lbl2.SetAutosize(UI::Autosize::None, UI::Autosize::Automatic);
+    w.Add(lbl2);
+    w.SetInteriorHeight(6_u);
+    std::cout << lbl2.GetCurrentHeight() << std::endl;
 
-    wgt1["Tab 1"].Add(btn1);
-    wgt1["Tab 2"].Add(lbl1);
-    wgt1["Tab 2"].AddUnder(lbl2);
-    wgt1["Tab 2"].Add(btn2);
-
-    btn2.Location.Y = 400_px;
-    btn2.Location.X = 3_u;
-
-    wgt1.ActivateNext();
-        
-    
     app.wind.Run();
 
     return 0;

mercurial