* All instances of UnitWidth is replaced with UnitSize 4.x-dev

Thu, 21 Oct 2021 15:41:46 +0300

author
cemkalyoncu
date
Thu, 21 Oct 2021 15:41:46 +0300
branch
4.x-dev
changeset 1737
1fab472b8bbb
parent 1736
375fb40537e7
child 1738
dfb250be177d

* All instances of UnitWidth is replaced with UnitSize

Source/Gorgon/UI/ComponentStack.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/UI/ComponentStackWidget.h file | annotate | diff | comparison | revisions
Source/Gorgon/UI/Dialog.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/UI/LayerAdapter.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/UI/LayerAdapter.h file | annotate | diff | comparison | revisions
Source/Gorgon/UI/Organizers/Flow.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/UI/Template.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/UI/Template.h file | annotate | diff | comparison | revisions
Source/Gorgon/UI/WidgetContainer.h file | annotate | diff | comparison | revisions
Source/Gorgon/UI/Window.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/UI/Window.h file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Composer.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Composer.h file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Generator.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Listbox.h file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Panel.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Panel.h file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/RadioButtons.h file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/TabPanel.h file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Window.cpp file | annotate | diff | comparison | revisions
--- a/Source/Gorgon/UI/ComponentStack.cpp	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/UI/ComponentStack.cpp	Thu Oct 21 15:41:46 2021 +0300
@@ -2196,7 +2196,7 @@
             auto ceilfn = ceiltounitsize_fn;
             if(!ceilfn) {
                 ceilfn = [this](int s) {
-                    return (s + temp.GetUnitWidth() - 1) / temp.GetUnitWidth() * temp.GetUnitWidth();
+                    return (s + temp.GetUnitSize() - 1) / temp.GetUnitSize() * temp.GetUnitSize();
                 };
             }
             
--- a/Source/Gorgon/UI/ComponentStackWidget.h	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/UI/ComponentStackWidget.h	Thu Oct 21 15:41:46 2021 +0300
@@ -17,10 +17,10 @@
             stack.SetCeilToUnitSize([this](int s) {
                 int w;
                 if(HasParent()) {
-                    w = GetParent().GetUnitWidth();
+                    w = GetParent().GetUnitSize();
                 }
                 else {
-                    w = stack.GetTemplate().GetUnitWidth();
+                    w = stack.GetTemplate().GetUnitSize();
                 }
                 return (s + w - 1) / w * w;
             });
@@ -67,11 +67,11 @@
         virtual void SetWidthInUnits(int n) override {
             int w, s;
             if(HasParent()) {
-                w = GetParent().GetUnitWidth();
+                w = GetParent().GetUnitSize();
                 s = GetParent().GetSpacing();
             }
             else {
-                w = stack.GetTemplate().GetUnitWidth();
+                w = stack.GetTemplate().GetUnitSize();
                 s = stack.GetTemplate().GetSpacing();
             }
             SetWidth(w * n + s * (n-1));
--- a/Source/Gorgon/UI/Dialog.cpp	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/UI/Dialog.cpp	Thu Oct 21 15:41:46 2021 +0300
@@ -101,9 +101,9 @@
             if(!allowshrink)
                 sz.Width = diag->GetInteriorSize().Width;
 
-            if(sz.Width < diag->GetUnitWidth() * 6) {
+            if(sz.Width < diag->GetUnitSize() * 6) {
                 //too small, use 4units at least
-                sz.Width = diag->GetUnitWidth() * 6;
+                sz.Width = diag->GetUnitSize() * 6;
                 break;
             }
             else if(sz.Width <= maxw && sz.Height > diag->GetHeight()) {
--- a/Source/Gorgon/UI/LayerAdapter.cpp	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/UI/LayerAdapter.cpp	Thu Oct 21 15:41:46 2021 +0300
@@ -23,7 +23,7 @@
         }
     }
 
-    int LayerAdapter::GetUnitWidth() const {
+    int LayerAdapter::GetUnitSize() const {
         if(issizesset) {
             return unitwidth;
         }
--- a/Source/Gorgon/UI/LayerAdapter.h	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/UI/LayerAdapter.h	Thu Oct 21 15:41:46 2021 +0300
@@ -50,21 +50,26 @@
             base = &value;
         }
         
+        using WidgetContainer::GetLayer;
+        
         /// Returns the base layer
         Gorgon::Layer &GetLayer() const {
             return *base;
         }
         
+        
         virtual ExtenderRequestResponse RequestExtender(const Gorgon::Layer &self) override;
         
         /// The spacing should be left between widgets
         virtual int GetSpacing() const override;
+
         
+        using WidgetContainer::GetUnitSize;        
         /// Returns the unit width for a widget. This size is enough to
         /// have a bordered icon. Widgets should be sized according to unit
         /// width and spacing. A single unit width would be too small for
         /// most widgets.
-        virtual int GetUnitWidth() const override;
+        virtual int GetUnitSize() const override;
         
         /// Overrides default spacing and unitwidth
         void SetSizes(int spacing, int unitwidth) {
--- a/Source/Gorgon/UI/Organizers/Flow.cpp	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/UI/Organizers/Flow.cpp	Thu Oct 21 15:41:46 2021 +0300
@@ -18,7 +18,7 @@
             Utils::NotImplemented("Tight organization is not implemented yet.");
         }
         else {
-            int uw = GetAttached().GetUnitWidth();
+            int uw = GetAttached().GetUnitSize();
             int y = 0;
             int maxy = 0;
             int rowc = 0;
@@ -81,7 +81,7 @@
                         nextalign = it->second.align;
                         break;
                     case Flow::Modifier::HSpace:
-                        xoff = it->second.size * att.GetUnitWidth() + GetSpacing();
+                        xoff = it->second.size * att.GetUnitSize() + GetSpacing();
                         break;
                     case Flow::Modifier::VSpace:
                         y += it->second.size * GetSpacing();
@@ -90,7 +90,7 @@
                         indent += it->second.size;
                         break;
                     case Flow::Modifier::IndentUnits:
-                        indent += it->second.size * att.GetUnitWidth() + GetSpacing();
+                        indent += it->second.size * att.GetUnitSize() + GetSpacing();
                         break;
                     case Flow::Modifier::IndentSpaces:
                         indent += it->second.size * GetSpacing();
--- a/Source/Gorgon/UI/Template.cpp	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/UI/Template.cpp	Thu Oct 21 15:41:46 2021 +0300
@@ -363,7 +363,7 @@
         size(std::move(other.size)),
         additional(std::move(other.additional)),
         spacing(std::move(other.spacing)),
-        unitwidth(std::move(other.unitwidth)),
+        unitsize(std::move(other.unitsize)),
         resizehandlesize(std::move(other.resizehandlesize)),
         direction(std::move(other.direction))
     {
--- a/Source/Gorgon/UI/Template.h	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/UI/Template.h	Thu Oct 21 15:41:46 2021 +0300
@@ -591,10 +591,10 @@
         }
 
 
-        /// Sets the unit width for a widget. This size should be enough to
+        /// Sets the unit size for a widget. This size should be enough to
         /// have a bordered icon. 
-        void SetUnitWidth(int value) {
-            unitwidth = value;
+        void SetUnitSize(int value) {
+            unitsize = value;
             ChangedEvent();
         }
         
@@ -603,8 +603,8 @@
         /// width and spacing. A single unit width would be too small for
         /// most widgets. Multiple units can be calculated by following
         /// formula: W(n) = n * W(1) + (n-1) * Spacing
-        int GetUnitWidth() const {
-            return unitwidth;
+        int GetUnitSize() const {
+            return unitsize;
         }
 
 
@@ -618,7 +618,7 @@
         /// Returns the size for resize handles. Default is unitwidth.
         int GetResizeHandleSize() const {
             if(resizehandlesize == -1)
-                return unitwidth;
+                return unitsize;
             else
                 return resizehandlesize;
         }
@@ -671,7 +671,7 @@
         Geometry::Size size;
         Geometry::Size additional = {0, 0};
         int spacing = 4;
-        int unitwidth = 25;
+        int unitsize = 25;
         int resizehandlesize = -1;
 
         Direction direction;
--- a/Source/Gorgon/UI/WidgetContainer.h	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/UI/WidgetContainer.h	Thu Oct 21 15:41:46 2021 +0300
@@ -452,8 +452,16 @@
         /// Returns the unit width for a widget. This size is enough to
         /// have a bordered icon. Widgets should be sized according to unit
         /// width and spacing. A single unit width would be too small for
-        /// most widgets. Multiple units can be obtained by GetUnitWidth(n)
-        virtual int GetUnitWidth() const = 0;
+        /// most widgets. Multiple units can be obtained by GetUnitSize(n)
+        virtual int GetUnitSize() const = 0;
+        
+        /// Returns the unit width for a widget. This size is enough to
+        /// have a bordered icon. Widgets should be sized according to unit
+        /// width and spacing. A single unit width would be too small for
+        /// most widgets. Multiple units can be obtained by GetUnitSize(n)
+        int GetUnitSize(int n) const {
+            return n*GetUnitSize() + (n-1)*GetSpacing();
+        }
 
     protected:
         /// This container is sorted by the focus order
--- a/Source/Gorgon/UI/Window.cpp	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/UI/Window.cpp	Thu Oct 21 15:41:46 2021 +0300
@@ -15,7 +15,7 @@
     }
 
     
-    int Window::GetUnitWidth() const {
+    int Window::GetUnitSize() const {
         if(issizesset) {
             return unitwidth;
         }
--- a/Source/Gorgon/UI/Window.h	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/UI/Window.h	Thu Oct 21 15:41:46 2021 +0300
@@ -203,11 +203,14 @@
         /// The spacing should be left between widgets
         virtual int GetSpacing() const override;
         
+        using WidgetContainer::GetUnitSize;
+        
         /// Returns the unit width for a widget. This size is enough to
         /// have a bordered icon. Widgets should be sized according to unit
         /// width and spacing. A single unit width would be too small for
         /// most widgets.
-        virtual int GetUnitWidth() const override;
+        virtual int GetUnitSize() const override;
+        
         
         /// Overrides default spacing and unitwidth
         void SetSizes(int spacing, int unitwidth) {
--- a/Source/Gorgon/Widgets/Composer.cpp	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/Widgets/Composer.cpp	Thu Oct 21 15:41:46 2021 +0300
@@ -107,7 +107,7 @@
         }
     }
 
-    int Composer::GetUnitWidth() const {
+    int Composer::GetUnitSize() const {
         if(issizesset) {
             return unitwidth;
         }
@@ -121,7 +121,7 @@
         int w, s;
 
         if(HasParent()) {
-            w = GetParent().GetUnitWidth();
+            w = GetParent().GetUnitSize();
             s = GetParent().GetSpacing();
         }
         else {
@@ -215,7 +215,7 @@
         }
     }
 
-    int ComponentStackComposer::GetUnitWidth() const {
+    int ComponentStackComposer::GetUnitSize() const {
         if(issizesset) {
             return unitwidth;
         }
@@ -228,7 +228,7 @@
         int w, s;
 
         if(HasParent()) {
-            w = GetParent().GetUnitWidth();
+            w = GetParent().GetUnitSize();
             s = GetParent().GetSpacing();
         }
         else {
--- a/Source/Gorgon/Widgets/Composer.h	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/Widgets/Composer.h	Thu Oct 21 15:41:46 2021 +0300
@@ -122,11 +122,13 @@
         /// The spacing should be left between widgets
         virtual int GetSpacing() const override;
         
+        using WidgetContainer::GetUnitSize;
+        
         /// Returns the unit width for a widget. This size is enough to
         /// have a bordered icon. Widgets should be sized according to unit
         /// width and spacing. A single unit width would be too small for
         /// most widgets.
-        virtual int GetUnitWidth() const override;
+        virtual int GetUnitSize() const override;
         
         /// Overrides default spacing and unitwidth
         void SetSizes(int spacing, int unitwidth) {
@@ -290,7 +292,7 @@
         /// have a bordered icon. Widgets should be sized according to unit
         /// width and spacing. A single unit width would be too small for
         /// most widgets.
-        virtual int GetUnitWidth() const override;
+        virtual int GetUnitSize() const override;
         
         /// Overrides default spacing and unitwidth
         void SetSizes(int spacing, int unitwidth) {
--- a/Source/Gorgon/Widgets/Generator.cpp	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/Widgets/Generator.cpp	Thu Oct 21 15:41:46 2021 +0300
@@ -469,7 +469,7 @@
     UI::Template SimpleGenerator::maketemplate() {
         UI::Template temp;
         temp.SetSpacing(spacing);
-        temp.SetUnitWidth(unitsize); //BorderedHeight = UnitWidth
+        temp.SetUnitSize(unitsize); //BorderedHeight = UnitSize
         
         return temp;
     }
@@ -2543,7 +2543,7 @@
         UI::Template &closebtn = *new UI::Template;
         closebtn.SetSize(objectheight, objectheight);
         closebtn.SetSpacing(spacing);
-        closebtn.SetUnitWidth(unitsize);
+        closebtn.SetUnitSize(unitsize);
         closebtn.AddContainer(0, UI::ComponentCondition::Always)
             .AddIndex(1)
             .Background.SetAnimation(A(Rectangle, Regular))
--- a/Source/Gorgon/Widgets/Listbox.h	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/Widgets/Listbox.h	Thu Oct 21 15:41:46 2021 +0300
@@ -1811,7 +1811,7 @@
         bool FitHeight(int maxpixels) {
             int curh = GetInteriorSize().Height;
             int overhead = GetHeight() - curh;
-            int defh = stack.GetTemplate().GetUnitWidth();
+            int defh = stack.GetTemplate().GetUnitSize();
             
             auto li = stack.GetTemplate(UI::ComponentTemplate::ItemTag);
             if(li)
--- a/Source/Gorgon/Widgets/Panel.cpp	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/Widgets/Panel.cpp	Thu Oct 21 15:41:46 2021 +0300
@@ -47,7 +47,7 @@
 
         SetSmoothScrollSpeed(scrollspeed);
         
-        scrolldist = {temp.GetUnitWidth()*4, temp.GetUnitWidth()*2};
+        scrolldist = {temp.GetUnitSize()*4, temp.GetUnitSize()*2};
     }
 
     bool Panel::Activate() {
@@ -255,12 +255,12 @@
         }
     }
 
-    int Panel::GetUnitWidth() const {
+    int Panel::GetUnitSize() const {
         if(issizesset) {
             return unitwidth;
         }
         else {
-            return stack.GetTemplate().GetUnitWidth();
+            return stack.GetTemplate().GetUnitSize();
         }
     }
 
--- a/Source/Gorgon/Widgets/Panel.h	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/Widgets/Panel.h	Thu Oct 21 15:41:46 2021 +0300
@@ -103,11 +103,13 @@
         /// The spacing should be left between widgets
         virtual int GetSpacing() const override;
         
+        using WidgetContainer::GetUnitSize;
+        
         /// Returns the unit width for a widget. This size is enough to
         /// have a bordered icon. Widgets should be sized according to unit
         /// width and spacing. A single unit width would be too small for
         /// most widgets.
-        virtual int GetUnitWidth() const override;
+        virtual int GetUnitSize() const override;
         
         /// Overrides default spacing and unitwidth
         void SetSizes(int spacing, int unitwidth) {
--- a/Source/Gorgon/Widgets/RadioButtons.h	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/Widgets/RadioButtons.h	Thu Oct 21 15:41:46 2021 +0300
@@ -56,11 +56,11 @@
         void SetWidthInUnits(int n) override {
             int w, s;
             if(HasParent()) {
-                w = GetParent().GetUnitWidth();
+                w = GetParent().GetUnitSize();
                 s = GetParent().GetSpacing();
             }
             else {
-                w = temp.GetUnitWidth();
+                w = temp.GetUnitSize();
                 s = temp.GetSpacing();
             }
             SetWidth(w * n + s * (n-1));
--- a/Source/Gorgon/Widgets/TabPanel.h	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/Widgets/TabPanel.h	Thu Oct 21 15:41:46 2021 +0300
@@ -102,7 +102,7 @@
                 {UI::ComponentTemplate::ButtonTag, {}},
                 {UI::ComponentTemplate::ContentsTag, {}},
             }),
-            buttonsize(GetUnitWidth() * 3 + GetSpacing() * 2, GetUnitWidth())
+            buttonsize(GetUnitSize() * 3 + GetSpacing() * 2, GetUnitSize())
         {
             stack.SetMouseUpEvent([this](auto, auto, auto) {
                 Focus();
@@ -473,7 +473,7 @@
                     buttonspnl->Resize(maxw, buttons.Last()->GetBounds().Bottom);
                 }
                 else {
-                    buttonspnl->Resize({0, GetUnitWidth()});
+                    buttonspnl->Resize({0, GetUnitSize()});
                 }
 
                 stack.SetTagSize(UI::ComponentTemplate::ButtonsTag, {0, buttonspnl->GetHeight()});
--- a/Source/Gorgon/Widgets/Window.cpp	Sun Oct 10 10:47:04 2021 +0300
+++ b/Source/Gorgon/Widgets/Window.cpp	Thu Oct 21 15:41:46 2021 +0300
@@ -47,7 +47,7 @@
             Center();
         }
         
-        minsize = GetSize() - GetInteriorSize() + Geometry::Size(stack.GetTemplate().GetUnitWidth()*2, stack.GetTemplate().GetUnitWidth());
+        minsize = GetSize() - GetInteriorSize() + Geometry::Size(stack.GetTemplate().GetUnitSize()*2, stack.GetTemplate().GetUnitSize());
     }
     
     Window::Window(const UI::Template &temp, const std::string &title, const Geometry::Size size, bool autoplace) : 

mercurial