* Generators fixed: ComponentStackRework

Tue, 15 Sep 2020 17:33:05 +0300

author
cemkalyoncu
date
Tue, 15 Sep 2020 17:33:05 +0300
branch
ComponentStackRework
changeset 1441
37e20edc5844
parent 1440
89f145018e8e
child 1442
9eed31b1a3f7

* Generators fixed:
- Label
- Panel

Source/Gorgon/UI/ComponentStack.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Generator.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Generator.h file | annotate | diff | comparison | revisions
Testing/Source/Manual/UI_Component.cpp file | annotate | diff | comparison | revisions
Testing/Source/Manual/UI_Generate.cpp file | annotate | diff | comparison | revisions
--- a/Source/Gorgon/UI/ComponentStack.cpp	Tue Sep 15 09:32:09 2020 +0300
+++ b/Source/Gorgon/UI/ComponentStack.cpp	Tue Sep 15 17:33:05 2020 +0300
@@ -3350,7 +3350,7 @@
                 auto old = target->GetColor();
                 target->SetColor(color * c);
                 
-                //target->Draw(comp.location+offset, comp.size, 0x80000000); //for debugging
+                target->Draw(comp.location+offset, comp.size, 0x80000000); //for debugging
                 if(tagnowrap.count(temp.GetTag()))
                     th.GetRenderer().PrintNoWrap(*target, text, comp.location+offset, comp.size.Width);
                 else
--- a/Source/Gorgon/Widgets/Generator.cpp	Tue Sep 15 09:32:09 2020 +0300
+++ b/Source/Gorgon/Widgets/Generator.cpp	Tue Sep 15 17:33:05 2020 +0300
@@ -436,8 +436,8 @@
         return new Graphics::RectangleProvider(cri, hi, cri, vi, ci, vi, cri, hi, cri);
     }
     
-    void SimpleGenerator::setupfocus(UI::ContainerTemplate &foc) {
-        foc.Background.SetAnimation(FocusBorder());
+    void SimpleGenerator::setupfocus(UI::GraphicsTemplate &foc) {
+        foc.Content.SetAnimation(FocusBorder());
         foc.SetSize(100, 100, UI::Dimension::Percent);
         foc.SetPositioning(UI::ComponentTemplate::Absolute);
         foc.SetAnchor(UI::Anchor::None, UI::Anchor::MiddleCenter, UI::Anchor::MiddleCenter);
@@ -528,7 +528,7 @@
         setuptext(Forecolor.Regular.BlendWith(Forecolor.Down), UI::ComponentCondition::Down);
         setuptext(Forecolor.Regular.BlendWith(Forecolor.Disabled), UI::ComponentCondition::Disabled);
 
-        setupfocus(temp.AddContainer(4, UI::ComponentCondition::Focused));
+        setupfocus(temp.AddGraphics(4, UI::ComponentCondition::Focused));
         
         temp.Name = String::Concat("Button ", rand()%100);
 
@@ -586,7 +586,7 @@
         boxed.SetPadding(std::max(Border.Radius / 2, Focus.Spacing));
         boxed.SetPositioning(UI::ComponentTemplate::Absolute);
         
-        setupfocus(temp.AddContainer(4, UI::ComponentCondition::Focused));
+        setupfocus(temp.AddGraphics(4, UI::ComponentCondition::Focused));
         
         //contents
         auto &contents = temp.AddContainer(3, UI::ComponentCondition::Always)
@@ -752,7 +752,7 @@
         makestate(Forecolor.Regular.BlendWith(Forecolor.Down), UI::ComponentCondition::Down);
         makestate(Forecolor.Regular.BlendWith(Forecolor.Disabled), UI::ComponentCondition::Disabled);
         
-        setupfocus(temp.AddContainer(2, UI::ComponentCondition::Focused));
+        setupfocus(temp.AddGraphics(2, UI::ComponentCondition::Focused));
         
         return temp;
     }
@@ -798,7 +798,7 @@
         boxed.SetPadding(std::max(Border.Radius / 2, Focus.Spacing));
         boxed.SetPositioning(UI::ComponentTemplate::Absolute);
         
-        setupfocus(temp.AddContainer(4, UI::ComponentCondition::Focused));
+        setupfocus(temp.AddGraphics(4, UI::ComponentCondition::Focused));
         
         //contents
         auto &contents = temp.AddContainer(3, UI::ComponentCondition::Always)
@@ -943,7 +943,7 @@
         makestate(Forecolor.Regular.BlendWith(Forecolor.Down), UI::ComponentCondition::Down);
         makestate(Forecolor.Regular.BlendWith(Forecolor.Disabled), UI::ComponentCondition::Disabled);
         
-        setupfocus(temp.AddContainer(2, UI::ComponentCondition::Focused));
+        setupfocus(temp.AddGraphics(2, UI::ComponentCondition::Focused));
         
         return temp;
     }
@@ -954,61 +954,30 @@
         UI::Template temp;
         temp.SetSize(defsize);
         
-        auto &bi = *new Graphics::BlankImage({Border.Width, Border.Width}, Border.Color);
-        drawables.Add(bi);
-        
-        {
-            auto &bg_n = temp.AddContainer(0, UI::ComponentCondition::Always);
-            bg_n.SetSizing(UI::ComponentTemplate::Automatic);
-            //assuming border radius = 0
-            bg_n.SetPadding(0);
-            bg_n.AddIndex(1);
-            bg_n.AddIndex(2);
-            bg_n.AddIndex(3);
-        }
-        
-        {
-            auto &icon = temp.AddPlaceholder(1, UI::ComponentCondition::Icon1IsSet);
-            icon.SetDataEffect(UI::ComponentTemplate::Icon);
-            icon.SetAnchor(UI::Anchor::MiddleRight, UI::Anchor::MiddleLeft, UI::Anchor::MiddleLeft);
-            icon.SetSize(100, 100, UI::Dimension::Percent);
-            icon.SetSizing(UI::ComponentTemplate::ShrinkOnly);
-            icon.SetMargin(0, 0, Spacing, 0);
-        }
+        auto &cont = temp.AddContainer(0, UI::ComponentCondition::Always, UI::ComponentCondition::Disabled)
+            .AddIndex(1) //icon
+            .AddIndex(2) //text
+        ;
+        cont.SetValueModification(UI::ComponentTemplate::ModifyAlpha, UI::ComponentTemplate::UseTransition);
+        cont.SetValueRange(0, 1, 0.5);
+        cont.SetReversible(true);
+        cont.SetClip(true);
         
-        {
-            auto &foc = temp.AddContainer(2, UI::ComponentCondition::Focused);
-            foc.Background.SetAnimation(FocusBorder());
-            foc.SetMargin(Spacing / 2);
-            foc.SetSize(100, 100, UI::Dimension::Percent);
-            foc.SetPositioning(foc.Absolute);
-            foc.SetAnchor(UI::Anchor::None, UI::Anchor::MiddleCenter, UI::Anchor::MiddleCenter);
-        }
-
-        {
-            auto &txt_n = temp.AddTextholder(3, UI::ComponentCondition::Always);
-            txt_n.SetRenderer(RegularFont);
-            txt_n.SetColor(Forecolor.Regular);
-            txt_n.SetAnchor(UI::Anchor::MiddleRight, UI::Anchor::MiddleLeft, UI::Anchor::MiddleLeft);
-            txt_n.SetDataEffect(UI::ComponentTemplate::Text);
-            txt_n.SetClip(true);
-            txt_n.SetSize(100, 100, UI::Dimension::Percent);
-            txt_n.SetSizing(UI::ComponentTemplate::ShrinkOnly);
-        }
-
-        {
-            auto &txt_n = temp.AddTextholder(3, UI::ComponentCondition::Disabled);
-            txt_n.SetRenderer(RegularFont);
-            auto c = Forecolor.Regular;
-            c.Blend(Forecolor.Disabled);
-            txt_n.SetColor(c);
-            txt_n.SetAnchor(UI::Anchor::MiddleRight, UI::Anchor::MiddleLeft, UI::Anchor::MiddleLeft);
-            txt_n.SetDataEffect(UI::ComponentTemplate::Text);
-            txt_n.SetClip(true);
-            txt_n.SetSize(100, 100, UI::Dimension::Percent);
-            txt_n.SetSizing(UI::ComponentTemplate::ShrinkOnly);
-        }
-
+        auto &icon = temp.AddPlaceholder(1, UI::ComponentCondition::Icon1IsSet);
+        icon.SetDataEffect(UI::ComponentTemplate::Icon);
+        icon.SetAnchor(UI::Anchor::MiddleRight, UI::Anchor::MiddleLeft, UI::Anchor::MiddleLeft);
+        icon.SetSize(100, 100, UI::Dimension::Percent);
+        icon.SetSizing(UI::ComponentTemplate::ShrinkOnly);
+        icon.SetMargin(0, 0, Spacing, 0);
+        
+        auto &txt = temp.AddTextholder(2, UI::ComponentCondition::Always);
+        txt.SetRenderer(RegularFont);
+        txt.SetColor(Forecolor.Regular);
+        txt.SetAnchor(UI::Anchor::MiddleRight, UI::Anchor::MiddleLeft, UI::Anchor::MiddleLeft);
+        txt.SetDataEffect(UI::ComponentTemplate::Text);
+        txt.SetSize(100, 100, UI::Dimension::Percent);
+        txt.SetSizing(UI::ComponentTemplate::ShrinkOnly);
+        
         return temp;
     }
 
@@ -1017,102 +986,58 @@
         
         UI::Template temp;
         temp.SetSize(defsize);
-
-        auto &bi = *new Graphics::BlankImage({ Border.Width, Border.Width }, Border.Color);
-        drawables.Add(bi);
-
-        {
-            auto &bg_n = temp.AddContainer(0, UI::ComponentCondition::Always);
-            bg_n.SetSizing(UI::ComponentTemplate::Automatic);
-            //assuming border radius = 0
-            bg_n.SetPadding(0);
-            bg_n.AddIndex(1);
-            bg_n.AddIndex(2);
-            bg_n.AddIndex(3);
-        }
-
-        {
-            auto &icon = temp.AddPlaceholder(1, UI::ComponentCondition::Icon1IsSet);
-            icon.SetDataEffect(UI::ComponentTemplate::Icon);
-            icon.SetAnchor(UI::Anchor::MiddleRight, UI::Anchor::MiddleLeft, UI::Anchor::MiddleLeft);
-            icon.SetSize(100, 100, UI::Dimension::Percent);
-            icon.SetSizing(UI::ComponentTemplate::ShrinkOnly);
-            icon.SetMargin(0, 0, Spacing, 0);
-        }
-
-        {
-            auto &foc = temp.AddContainer(2, UI::ComponentCondition::Focused);
-
-            auto &ci = Graphics::EmptyImage::Instance();
-
-
-            auto &hi = *new Graphics::Bitmap({ 2, Focus.Width });
-            hi.Clear();
-            for (auto i = 0; i < Focus.Width; i++)
-                hi.SetRGBAAt(0, i, Focus.Color);
-            hi.Prepare();
-            drawables.Add(hi);
-
-            auto &vi = *new Graphics::Bitmap({ Focus.Width, 2 });
-            vi.Clear();
-            for (auto i = 0; i < Focus.Width; i++)
-                vi.SetRGBAAt(i, 0, Focus.Color);
-            vi.Prepare();
-            drawables.Add(vi);
-
-            auto &cri = *new Graphics::BlankImage(Focus.Width, Focus.Width, Focus.Color);
-
-            auto &rect = *new Graphics::RectangleProvider(cri, hi, cri, vi, ci, vi, cri, hi, cri);
-
-            foc.Background.SetAnimation(rect);
-            providers.Add(rect);
-            foc.SetMargin(Spacing / 2);
-            foc.SetSize(100, 100, UI::Dimension::Percent);
-            foc.SetPositioning(foc.Absolute);
-            foc.SetAnchor(UI::Anchor::None, UI::Anchor::MiddleCenter, UI::Anchor::MiddleCenter);
-        }
-
-        {
-            auto &txt_n = temp.AddTextholder(3, UI::ComponentCondition::Always);
-            txt_n.SetRenderer(RegularFont);
-            txt_n.SetColor(Forecolor.Error);
-            txt_n.SetAnchor(UI::Anchor::MiddleRight, UI::Anchor::MiddleLeft, UI::Anchor::MiddleLeft);
-            txt_n.SetDataEffect(UI::ComponentTemplate::Text);
-            txt_n.SetClip(true);
-            txt_n.SetSize(100, 100, UI::Dimension::Percent);
-            txt_n.SetSizing(UI::ComponentTemplate::ShrinkOnly);
-        }
-
+        
+        auto &cont = temp.AddContainer(0, UI::ComponentCondition::Always, UI::ComponentCondition::Disabled)
+            .AddIndex(1) //icon
+            .AddIndex(2) //text
+        ;
+        cont.SetValueModification(UI::ComponentTemplate::ModifyAlpha, UI::ComponentTemplate::UseTransition);
+        cont.SetValueRange(0, 1, 0.5);
+        cont.SetReversible(true);
+        cont.SetClip(true);
+        
+        auto &icon = temp.AddPlaceholder(1, UI::ComponentCondition::Icon1IsSet);
+        icon.SetDataEffect(UI::ComponentTemplate::Icon);
+        icon.SetAnchor(UI::Anchor::MiddleRight, UI::Anchor::MiddleLeft, UI::Anchor::MiddleLeft);
+        icon.SetSize(100, 100, UI::Dimension::Percent);
+        icon.SetSizing(UI::ComponentTemplate::ShrinkOnly);
+        icon.SetMargin(0, 0, Spacing, 0);
+        
+        auto &txt = temp.AddTextholder(2, UI::ComponentCondition::Always);
+        txt.SetRenderer(RegularFont);
+        txt.SetColor(Forecolor.Regular.BlendWith(Forecolor.Error));
+        txt.SetAnchor(UI::Anchor::MiddleRight, UI::Anchor::MiddleLeft, UI::Anchor::MiddleLeft);
+        txt.SetDataEffect(UI::ComponentTemplate::Text);
+        txt.SetSize(100, 100, UI::Dimension::Percent);
+        txt.SetSizing(UI::ComponentTemplate::ShrinkOnly);
+        
         return temp;
     }
     
     UI::Template SimpleGenerator::BlankPanel() {
-        Geometry::Size defsize = {WidgetWidth * 4 + Spacing * 5, WidgetHeight * 10 + Spacing * 11};
+        Geometry::Size defsize = {WidgetWidth * 2 + Spacing, BorderedWidgetHeight * 10 + Spacing * 9};
         
         UI::Template temp;
         temp.SetSize(defsize);
         
-        
-        auto &bg = temp.AddContainer(0, UI::ComponentCondition::Always);
-        bg.SetClip(true);
-        
-        bg.AddIndex(1);
+        temp.AddContainer(0, UI::ComponentCondition::Always)
+            .AddIndex(1)
+            .SetClip(true)
+        ;
         
         auto &cont = temp.AddContainer(1, UI::ComponentCondition::Always);
         cont.SetTag(UI::ComponentTemplate::ContentsTag);
-        cont.SetValueModification(cont.ModifyPosition, cont.UseXY);
-        cont.SetSize(100, 100, UI::Dimension::Percent);
+        cont.SetSize(0, 0, UI::Dimension::Percent);
         cont.SetPositioning(cont.Absolute);
         cont.SetAnchor(UI::Anchor::TopLeft, UI::Anchor::TopLeft, UI::Anchor::TopLeft);
         cont.SetPosition(0, 0);
-        //bg.Background.SetAnimation(NormalBorder());
         
         return temp;
     }
     
     UI::Template SimpleGenerator::makepanel(int missingedge) {
         Geometry::Size defsize = {
-            WidgetWidth * 4 + Spacing * 3 + Border.Width * 2 + Spacing * 2, 
+            WidgetWidth * 2 + Spacing + Border.Width * 2 + Spacing * 2, 
             BorderedWidgetHeight * 10 + Spacing * 9 + Border.Width * 2 + Spacing * 2
         };
         
@@ -1156,19 +1081,16 @@
         vp.SetSize(100, 100, UI::Dimension::Percent);
         vp.SetPositioning(vp.Absolute);
         vp.SetAnchor(UI::Anchor::TopLeft, UI::Anchor::TopLeft, UI::Anchor::TopLeft);
-        vp.SetPosition(0, 0);
         vp.SetClip(true);
         vp.AddIndex(2);
         //vp.Background.SetAnimation(HoverBorder());
         
         auto &cont = temp.AddContainer(2, UI::ComponentCondition::Always);
         cont.SetTag(UI::ComponentTemplate::ContentsTag);
-        //cont.SetValueModification(cont.ModifyPosition, cont.UseXY);
         cont.SetSize(0, 0, UI::Dimension::Percent);
         cont.SetSizing(UI::ComponentTemplate::Fixed);
         cont.SetPositioning(cont.Absolute);
         cont.SetAnchor(UI::Anchor::TopLeft, UI::Anchor::TopLeft, UI::Anchor::TopLeft);
-        cont.SetPosition(0, 0);
         //cont.Background.SetAnimation(DownBorder());
         
         return temp;
--- a/Source/Gorgon/Widgets/Generator.h	Tue Sep 15 09:32:09 2020 +0300
+++ b/Source/Gorgon/Widgets/Generator.h	Tue Sep 15 17:33:05 2020 +0300
@@ -251,7 +251,7 @@
         Graphics::RectangleProvider *makefocusborder();
         UI::Template makepanel(int missingedge);
         
-        void setupfocus(UI::ContainerTemplate &focus);
+        void setupfocus(UI::GraphicsTemplate &focus);
         
         Graphics::GlyphRenderer *regularrenderer = nullptr;
         Containers::Collection<Graphics::Drawable> drawables;
--- a/Testing/Source/Manual/UI_Component.cpp	Tue Sep 15 09:32:09 2020 +0300
+++ b/Testing/Source/Manual/UI_Component.cpp	Tue Sep 15 17:33:05 2020 +0300
@@ -2721,6 +2721,7 @@
     cont2.Background.SetAnimation(redrect());
     cont2.SetTag(Gorgon::UI::ComponentTemplate::LeftTag);
     cont2.SetSizing(Gorgon::UI::ComponentTemplate::Automatic);
+    cont2.SetSize(100, 0, Gorgon::UI::Dimension::Percent);
 
     static Graphics::BitmapFont fnt;
     fnt.SetGlyphSpacing(10);
--- a/Testing/Source/Manual/UI_Generate.cpp	Tue Sep 15 09:32:09 2020 +0300
+++ b/Testing/Source/Manual/UI_Generate.cpp	Tue Sep 15 17:33:05 2020 +0300
@@ -37,14 +37,14 @@
     basic_Application<UI::Window> app("uitest", "UI Generator Test", helptext, 1, 0x80);
 
     ///Blank Panel & elements with Registry & Regulars 
-    /*Widgets::SimpleGenerator generator;
-    generator.Init(14);
-    generator.Border.Radius = 0;
+    Widgets::SimpleGenerator generator;
+    generator.Init(13);
+    //generator.Border.Radius = 0;
     generator.UpdateDimensions();
-    generator.Activate();*/
+    generator.Activate();
 
-    Widgets::Panel blank(Gorgon::Widgets::Registry::Panel_Blank);
-    blank.Resize({ 120,600 });
+    Widgets::Panel blank/*(Gorgon::Widgets::Registry::Panel_Blank)*/;
+    blank.SetHeight(600);
     Gorgon::Widgets::Button btn("Save as",Gorgon::Widgets::Registry::Button_Regular);
     Gorgon::Widgets::Button icnbtn("+", Gorgon::Widgets::Registry::Button_Icon);
     Gorgon::Widgets::Button icnbtn2("Âj", Gorgon::Widgets::Registry::Button_Icon);
@@ -56,10 +56,9 @@
     btn.OwnIcon(icon2.CreateAnimation());
     
     icnbtn.OwnIcon(icon2.CreateAnimation());
-    icnbtn.Disable();
 
-    btn.Disable();
     Gorgon::Widgets::Label l("Coffee:");
+    Gorgon::Widgets::Label l2("Error", Gorgon::Widgets::Registry::Label_Error);
 
     Gorgon::Widgets::RadioButtons<int> radio(Gorgon::Widgets::Registry::Radio_Regular);
     radio.Add(0,"Americano");
@@ -103,7 +102,6 @@
 
     icnbtn2.PressEvent.Register([&] {
         bar -= 10;
-        icnbtn.Enable();
     });
     //blank.CreateOrganizer<Gorgon::UI::Organizers::List>().SetSpacing(Gorgon::Widgets::Registry::Active().GetSpacing());
     
@@ -121,6 +119,18 @@
         pnl.Add(w);
     };
     
+    app.wind.KeyEvent.Register([&](Gorgon::Input::Key key, float amount) {
+        namespace Keycodes = Gorgon::Input::Keyboard::Keycodes;
+        
+        switch(key) {
+        case Keycodes::D:
+            blank.ToggleEnabled();
+            return true;
+        }
+            
+        return false;
+    });
+    
     app.wind.Add(blank);
     addme(blank, btn);
     addme(blank, icnbtn);
@@ -128,6 +138,7 @@
     addme(blank, icnbtn3);
     addme(blank, l);
     addme(blank, radio);
+    addme(blank, l2);
     addme(blank, input);
     addme(blank, chk);
     addme(blank, chk2);

mercurial