Mon, 14 Sep 2020 11:54:54 +0300
* Fixed removal of last stack item
* Fixed rendering of tinted rectangles
* Checkbox button generation is fixed
--- a/Source/Gorgon/Graphics/Rectangle.cpp Fri Sep 11 15:31:04 2020 +0300 +++ b/Source/Gorgon/Graphics/Rectangle.cpp Mon Sep 14 11:54:54 2020 +0300 @@ -76,7 +76,7 @@ tm.DrawIn(target, prov.GetSideTiling() ? Tiling::Horizontal : Tiling::None, Geometry::Rectanglef(r.X + maxl, r.Y + maxt - tm.GetHeight(), r.Width-maxl-maxr, (Float)tm.GetHeight()), color); - tr.Draw(target, r.Right() - maxr, r.Y + maxt - tr.GetHeight()); + tr.Draw(target, r.Right() - maxr, r.Y + maxt - tr.GetHeight(), color); ml.DrawIn(target, prov.GetSideTiling() ? Tiling::Vertical : Tiling::None, Geometry::Rectanglef(r.X + maxl - ml.GetWidth(), r.Y + maxt, (Float)ml.GetWidth(), r.Height-maxt-maxb), @@ -93,7 +93,7 @@ bm.DrawIn(target, prov.GetSideTiling() ? Tiling::Horizontal : Tiling::None, Geometry::Rectanglef(r.X + maxl, r.Bottom() - maxb, r.Width-maxl-maxr, (Float)bm.GetHeight()), color); - br.Draw(target, r.Right() - maxr, r.Bottom() - maxb); + br.Draw(target, r.Right() - maxr, r.Bottom() - maxb, color); } void Rectangle::drawin(TextureTarget &target, const SizeController &controller, const Geometry::Rectanglef &r, RGBAf color) const {
--- a/Source/Gorgon/UI/ComponentStack.cpp Fri Sep 11 15:31:04 2020 +0300 +++ b/Source/Gorgon/UI/ComponentStack.cpp Mon Sep 14 11:54:54 2020 +0300 @@ -352,31 +352,27 @@ //if an index does not contain condition in from field and an empty to field //it might still have it as a transition from the previous condition to our condition. //In this case we should take this non-perfect fit. - if(!updatereq && hint != ComponentCondition::None) { - for(int i=0; i<temp.GetCount(); i++) { - //do not use repeated components - if(temp[i].GetRepeatMode() != ComponentTemplate::NoRepeat) - continue; - - if(temp[i].GetCondition() == hint && temp[i].GetTargetCondition() == to && !indicesdone.count(temp[i].GetIndex())) { - updatereq = true; - AddToStack(temp[i], false); - indicesdone.insert(temp[i].GetIndex()); - } + for(int i=0; i<temp.GetCount(); i++) { + //do not use repeated components + if(temp[i].GetRepeatMode() != ComponentTemplate::NoRepeat) + continue; + + if(temp[i].GetTargetCondition() == to && !indicesdone.count(temp[i].GetIndex()) && (hint == ComponentCondition::None || temp[i].GetCondition() == hint)) { + updatereq = true; + AddToStack(temp[i], false); + indicesdone.insert(temp[i].GetIndex()); } } //once more, but this time reversed - if(!updatereq && hint != ComponentCondition::None) { - for(int i=0; i<temp.GetCount(); i++) { - //do not use repeated components - if(temp[i].GetRepeatMode() != ComponentTemplate::NoRepeat) - continue; - - if(temp[i].GetCondition() == to && temp[i].GetTargetCondition() == hint && !indicesdone.count(temp[i].GetIndex())) { - updatereq = true; - AddToStack(temp[i], true); - } + for(int i=0; i<temp.GetCount(); i++) { + //do not use repeated components + if(temp[i].GetRepeatMode() != ComponentTemplate::NoRepeat) + continue; + + if(temp[i].IsReversible() && temp[i].GetCondition() == to && !indicesdone.count(temp[i].GetIndex()) && (hint == ComponentCondition::None || temp[i].GetTargetCondition() == hint)) { + updatereq = true; + AddToStack(temp[i], true); } } } @@ -396,18 +392,15 @@ } } - //not found - if(!updatereq) { - //search for reversed - for(int i=0; i<temp.GetCount(); i++) { - //do not use repeated components - if(temp[i].GetRepeatMode() != ComponentTemplate::NoRepeat) - continue; - - if(temp[i].IsReversible() && temp[i].GetCondition() == to && temp[i].GetTargetCondition() == from && !indicesdone.count(temp[i].GetIndex())) { - updatereq = true; - AddToStack(temp[i], true); - } + //search for reversed + for(int i=0; i<temp.GetCount(); i++) { + //do not use repeated components + if(temp[i].GetRepeatMode() != ComponentTemplate::NoRepeat) + continue; + + if(temp[i].IsReversible() && temp[i].GetCondition() == to && temp[i].GetTargetCondition() == from && !indicesdone.count(temp[i].GetIndex())) { + updatereq = true; + AddToStack(temp[i], true); } } } @@ -462,6 +455,20 @@ remove = temp.GetCondition() == from && temp.GetTargetCondition() == to; } + //do not remove if this item can fill in for always and is the last item + if(remove && stacksizes[temp.GetIndex()] <= 1) { + if(temp.GetTargetCondition() == ComponentCondition::Always) { + remove = false; + comp.reversed = false; + updatereq = true; + } + else if((temp.IsReversible() && temp.GetCondition() == ComponentCondition::Always)) { + remove = false; + comp.reversed = true; + updatereq = true; + } + } + //if so if(remove) { //top of the stack
--- a/Source/Gorgon/Widgets/Generator.cpp Fri Sep 11 15:31:04 2020 +0300 +++ b/Source/Gorgon/Widgets/Generator.cpp Mon Sep 14 11:54:54 2020 +0300 @@ -126,13 +126,6 @@ Spacing = (int)std::round((float)totalh / 5); Focus.Spacing = std::max(1, Spacing / 2); - WidgetWidth = - regularrenderer->GetDigitWidth() * 12 + - Border.Width * 2 + - std::max(Border.Radius, Focus.Spacing * 2) + - Focus.Width * 2 + Focus.Spacing * 2 - ; - BorderedWidgetHeight = totalh + Border.Width * 2 + std::max(Border.Radius, Focus.Spacing * 2) + @@ -141,6 +134,8 @@ WidgetHeight = totalh + Focus.Width * 2 + Focus.Spacing * 2; + WidgetWidth = 3 * BorderedWidgetHeight + 2 * Spacing; + ObjectHeight = asciivsize.second; } @@ -476,7 +471,7 @@ ; boxed.SetSize(100, 100, UI::Dimension::Percent); boxed.SetBorderSize(Border.Width); - boxed.SetPadding(Focus.Spacing); + boxed.SetPadding(std::max(Border.Radius / 2, Focus.Spacing)); boxed.SetPositioning(UI::ComponentTemplate::Absolute); auto &clip = temp.AddContainer(3, UI::ComponentCondition::Always) @@ -554,14 +549,13 @@ iconsize.Height += Focus.Spacing * 2 + Focus.Width * 2; } - auto externalspacing = std::max(Border.Radius, Focus.Spacing); + auto externalspacing = Border.Width + std::max(Border.Radius / 2, Focus.Spacing); iconsize += Geometry::Size(externalspacing) * 2; UI::Template temp; - auto bgsize = iconsize; - temp.SetSize(bgsize); + temp.SetSize(iconsize); temp.AddContainer(0, UI::ComponentCondition::Always) .AddIndex(1) //background @@ -586,7 +580,8 @@ .AddIndex(3) //contents .AddIndex(4) //focus ; - boxed.SetBorderSize(externalspacing); + boxed.SetBorderSize(Border.Width); + boxed.SetPadding(std::max(Border.Radius / 2, Focus.Spacing)); boxed.SetPositioning(UI::ComponentTemplate::Absolute); setupfocus(temp.AddContainer(4, UI::ComponentCondition::Focused)); @@ -751,103 +746,95 @@ UI::Template SimpleGenerator::CheckboxButton() { UI::Template temp; - temp.SetSize((WidgetWidth-Spacing*3)/4, BorderedWidgetHeight); - - auto bgsize = temp.GetSize(); - - { - auto &bg = temp.AddContainer(0, UI::ComponentCondition::Always); - - bg.Background.SetAnimation(NormalBG()); - bg.AddIndex(1); - bg.AddIndex(2); - bg.AddIndex(3); - } + temp.SetSize(BorderedWidgetHeight, BorderedWidgetHeight); - { - auto &bg = temp.AddContainer(0, UI::ComponentCondition::Hover); - - bg.Background.SetAnimation(HoverBG()); - bg.AddIndex(1); - bg.AddIndex(2); - bg.AddIndex(3); - } - - { - auto &bg = temp.AddContainer(0, UI::ComponentCondition::Down); - - bg.Background.SetAnimation(DownBG()); - bg.AddIndex(1); - bg.AddIndex(2); - bg.AddIndex(3); - } - - { - auto &bg = temp.AddContainer(0, UI::ComponentCondition::Disabled); - bg.Background.SetAnimation(DisabledBG()); - bg.AddIndex(1); - bg.AddIndex(2); - bg.AddIndex(3); - bg.AddIndex(4); - } - - { - auto &overlay = temp.AddContainer(4, UI::ComponentCondition::Disabled); - - auto c = Forecolor.Regular; - c.Blend(Forecolor.Disabled); - c.A /= 2; - - auto &im = *new Graphics::BlankImage(bgsize, c); - drawables.Add(im); - - overlay.Background.SetDrawable(im); - overlay.SetPositioning(overlay.Absolute); - overlay.SetSize(100, 100, UI::Dimension::Percent); - overlay.SetSizing(overlay.Fixed); - overlay.SetAnchor(UI::Anchor::MiddleCenter, UI::Anchor::MiddleCenter, UI::Anchor::MiddleCenter); - overlay.SetClip(true); - } - - auto &icon = temp.AddPlaceholder(1, UI::ComponentCondition::Always); - icon.SetDataEffect(icon.Icon); - icon.SetAnchor(UI::Anchor::MiddleCenter, UI::Anchor::MiddleCenter, UI::Anchor::MiddleCenter); - icon.SetSize(100, 100, UI::Dimension::Percent); - icon.SetPositioning(icon.Absolute); - icon.SetSizing(icon.Fixed); - icon.SetClip(true); - - { - auto &txt_n = temp.AddTextholder(3, UI::ComponentCondition::Always); - txt_n.SetRenderer(RegularFont); - txt_n.SetColor(Forecolor.Regular); - txt_n.SetAnchor(UI::Anchor::None, UI::Anchor::MiddleCenter, UI::Anchor::MiddleCenter); - txt_n.SetDataEffect(UI::ComponentTemplate::Text); - txt_n.SetClip(true); - txt_n.SetSize(100, 100, UI::Dimension::Percent); - txt_n.SetSizing(UI::ComponentTemplate::ShrinkOnly); - txt_n.SetPositioning(txt_n.Absolute); - } + temp.AddContainer(0, UI::ComponentCondition::Always) + .AddIndex(1) //background + .AddIndex(8) //checked border + .AddIndex(2) //boxed content + ; + + //background + auto setupbg = [&](auto &anim, UI::ComponentCondition condition) { + auto &bg = temp.AddContainer(1, condition); + bg.Background.SetAnimation(anim); + bg.SetSize(100, 100, UI::Dimension::Percent); + bg.SetPositioning(UI::ComponentTemplate::Absolute); + }; + + setupbg(NormalBG(), UI::ComponentCondition::Always); + setupbg(HoverBG(), UI::ComponentCondition::Hover); + setupbg(DownBG(), UI::ComponentCondition::Down); + setupbg(DisabledBG(), UI::ComponentCondition::Disabled); + + //checked border + auto &border = temp.AddContainer(8, UI::ComponentCondition::Always, UI::ComponentCondition::State2); + border.SetValueModification(UI::ComponentTemplate::ModifyAlpha, UI::ComponentTemplate::UseTransition); + border.SetValueRange(0, 0.5, 1); + border.SetReversible(true); + border.Background.SetAnimation(NormalEmptyBorder()); + + //boxed content + auto &boxed = temp.AddContainer(2, UI::ComponentCondition::Always) + .AddIndex(3) //contents + .AddIndex(4) //focus + ; + boxed.SetBorderSize(Border.Width); + boxed.SetPadding(std::max(Border.Radius / 2, Focus.Spacing)); + boxed.SetPositioning(UI::ComponentTemplate::Absolute); + + setupfocus(temp.AddContainer(4, UI::ComponentCondition::Focused)); + + //contents + auto &contents = temp.AddContainer(3, UI::ComponentCondition::Always) + .AddIndex(5) //Icon or text, if icon exists text will not be displayed + ; + contents.SetClip(true); + contents.SetPadding(Focus.Spacing + Focus.Width); + + //Icon container + temp.AddContainer(5, UI::ComponentCondition::Icon1IsSet) + .AddIndex(6) + ; + + //Icon + auto setupicon = [&](auto &icon) -> auto& { + icon.SetDataEffect(icon.Icon); + icon.SetAnchor(UI::Anchor::MiddleCenter, UI::Anchor::MiddleCenter, UI::Anchor::MiddleCenter); + icon.SetSize(100, 100, UI::Dimension::Percent); + icon.SetPositioning(icon.Absolute); + icon.SetSizing(icon.ShrinkOnly); + icon.SetFillArea(false); + + return icon; + }; + + setupicon(temp.AddGraphics(6, UI::ComponentCondition::Always)); + setupicon(temp.AddGraphics(6, UI::ComponentCondition::Disabled)).SetColor({1.0f, 0.5f}); - { - auto &foc = temp.AddContainer(2, UI::ComponentCondition::Focused); - foc.Background.SetAnimation(FocusBorder()); - foc.SetMargin(1); - foc.SetSize(100, 100, UI::Dimension::Percent); - foc.SetPositioning(foc.Absolute); - foc.SetAnchor(UI::Anchor::None, UI::Anchor::MiddleCenter, UI::Anchor::MiddleCenter); - } + //Text container + temp.AddContainer(5, UI::ComponentCondition::Always) + .AddIndex(7) + ; - { - auto &sel = temp.AddContainer(2, UI::ComponentCondition::State2); - sel.Background.SetAnimation(NormalEmptyBorder()); - sel.SetSize(100, 100, UI::Dimension::Percent); - sel.SetPositioning(sel.Absolute); - sel.SetAnchor(UI::Anchor::None, UI::Anchor::MiddleCenter, UI::Anchor::MiddleCenter); - } + //Text only visible when no icon is set + auto setuptext = [&](Graphics::RGBA color, UI::ComponentCondition condition) { + auto &txt = temp.AddTextholder(7, condition); + txt.SetRenderer(CenteredFont); + txt.SetColor(color); + txt.SetAnchor(UI::Anchor::MiddleCenter, UI::Anchor::MiddleCenter, UI::Anchor::MiddleCenter); + txt.SetDataEffect(UI::ComponentTemplate::Text); + txt.SetSize(100, 100, UI::Dimension::Percent); + txt.SetSizing(UI::ComponentTemplate::ShrinkOnly); + }; + setuptext(Forecolor.Regular, UI::ComponentCondition::Always); + setuptext(Forecolor.Regular.BlendWith(Forecolor.Hover), UI::ComponentCondition::Hover); + setuptext(Forecolor.Regular.BlendWith(Forecolor.Down), UI::ComponentCondition::Down); + setuptext(Forecolor.Regular.BlendWith(Forecolor.Disabled), UI::ComponentCondition::Disabled); + return temp; }
--- a/Source/Gorgon/Widgets/Generator.h Fri Sep 11 15:31:04 2020 +0300 +++ b/Source/Gorgon/Widgets/Generator.h Mon Sep 14 11:54:54 2020 +0300 @@ -216,7 +216,7 @@ struct BackgroundInfo { Graphics::RGBA Regular = {Graphics::Color::Ivory, 0.8}; - Graphics::RGBA Hover = {Graphics::Color::LightTan, 0.5}; + Graphics::RGBA Hover = {Graphics::Color::Tan, 0.5}; Graphics::RGBA Down = {Graphics::Color::Crimson, 0.2}; Graphics::RGBA Disabled= Graphics::Color::LightGrey;
--- a/Testing/Source/Manual/UI_Generate.cpp Fri Sep 11 15:31:04 2020 +0300 +++ b/Testing/Source/Manual/UI_Generate.cpp Mon Sep 14 11:54:54 2020 +0300 @@ -44,10 +44,11 @@ generator.Activate();*/ Widgets::Panel blank(Gorgon::Widgets::Registry::Panel_Blank); - blank.Resize({ 180,600 }); - Gorgon::Widgets::Button btn("Start running",Gorgon::Widgets::Registry::Button_Regular); + blank.Resize({ 120,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); + Gorgon::Widgets::Button icnbtn3("X", Gorgon::Widgets::Registry::Button_Icon); auto icon = Triangle(5, 10); icon.Prepare(); Graphics::TintedBitmapProvider icon2(icon.Rotate270(), Graphics::Color::Charcoal); @@ -69,7 +70,7 @@ Gorgon::Widgets::Checkbox chk("Black",Gorgon::Widgets::Registry::Checkbox_Regular); Gorgon::Widgets::Checkbox chk2("Latte"); - Gorgon::Widgets::Checkbox chkbutton("Cbutton", Gorgon::Widgets::Registry::Checkbox_Button); + Gorgon::Widgets::Checkbox chkbutton("C", Gorgon::Widgets::Registry::Checkbox_Button); Gorgon::Widgets::Progressbar bar(Gorgon::Widgets::Registry::Progress_Regular); Gorgon::Widgets::Panel toppanel(Gorgon::Widgets::Registry::Panel_Top); toppanel.Resize({ 30,30 }); @@ -109,27 +110,35 @@ }); //blank.CreateOrganizer<Gorgon::UI::Organizers::List>().SetSpacing(Gorgon::Widgets::Registry::Active().GetSpacing()); - auto addme = [&](UI::WidgetBase &w) { - Geometry::Point offset = {0, Widgets::Registry::Active().GetSpacing()}; - if(blank.begin() != blank.end()) - w.Move((blank.end() - 1)->GetBounds().BottomLeft() + offset); + auto addme = [&](auto &pnl, UI::WidgetBase &w) { + Geometry::Point offsetx = {Widgets::Registry::Active().GetSpacing(), 0}; + if(pnl.UI::WidgetContainer::begin() != pnl.UI::WidgetContainer::end()) { + auto &last = *(pnl.UI::WidgetContainer::end() - 1); + auto lastb = last.GetBounds(); + if(lastb.Right + w.GetWidth() <= pnl.GetInteriorSize().Width) + w.Move(last.GetBounds().TopRight() + offsetx); + else + w.Move(0, last.GetBounds().Bottom + Widgets::Registry::Active().GetSpacing()); + } - blank.Add(w); + pnl.Add(w); }; - addme(btn); - addme(icnbtn); - addme(icnbtn2); - addme(l); - addme(radio); - addme(input); - addme(chk); - addme(chk2); - addme(chkbutton); - addme(bar); - addme(toppanel); - addme(bottompanel); - addme(leftpanel); - addme(rightpanel); + app.wind.Add(blank); + addme(blank, btn); + addme(blank, icnbtn); + addme(blank, icnbtn2); + addme(blank, icnbtn3); + addme(blank, l); + addme(blank, radio); + addme(blank, input); + addme(blank, chk); + addme(blank, chk2); + addme(blank, chkbutton); + addme(blank, bar); + addme(blank, toppanel); + addme(blank, bottompanel); + addme(blank, leftpanel); + addme(blank, rightpanel); /* ///Generator 1 background.panel color = red focus color = grey, forecolor.regular = green border = blue, fontsize = 12 defualt; @@ -340,7 +349,6 @@ */ - app.wind.Add(blank); /*app.wind.Add(panelgen1); app.wind.Add(panelgen2); panelgen1.Move(blank.GetBounds().Right + 5,blank.GetLocation().Y);