Thu, 28 Oct 2021 05:41:36 +0300
* Fixed a scroll inconsistency
#337 Initial window size is now set internally
--- a/Source/Gorgon/UI/Dimension.h Tue Oct 26 14:22:22 2021 +0300 +++ b/Source/Gorgon/UI/Dimension.h Thu Oct 28 05:41:36 2021 +0300 @@ -84,7 +84,31 @@ /// Returns the calculated dimension in pixels constexpr int Calculate(int parentwidth, int unitsize, int spacing, int emwidth = 10, bool issize = false) const { - switch(unit) { + if(issize) { + switch(unit) { + case Percent: + return int(std::floor((double)value * parentwidth / 100)); + case MilliPixel: + return int(std::floor((double)value / 1000)); + case BasisPoint: + return int(std::floor((double)value * parentwidth / 10000)); + case EM: + return int(std::round(value * emwidth / 100)); + case UnitSize: + if(value >= -1 && value <= 1) + return value * unitsize; + return value * unitsize + (value - 1) * spacing; + case MilliUnitSize: + if(value >= -1000 && value <= 1000) + return int(std::floor((double)value * unitsize / 1000)); + return int(std::floor(((double)value * unitsize + (double)(value - 1000) * spacing) / 1000)); + case Pixel: + default: + return value; + } + } + else { + switch(unit) { case Percent: return int(std::round((double)value * parentwidth / 100)); case MilliPixel: @@ -94,20 +118,13 @@ case EM: return int(std::round(value * emwidth / 100)); case UnitSize: - if(!issize) - return value * (unitsize + spacing); - else if(value >= -1 && value <= 1) - return value * unitsize; - return value * unitsize + (value - 1) * spacing; + return value * (unitsize + spacing); case MilliUnitSize: - if(!issize) - return value * (unitsize + spacing); - else if(value >= -1000 && value <= 1000) - return int(std::round((double)value * unitsize / 1000)); - return int(std::round(((double)value * unitsize + (double)(value - 1000) * spacing) / 1000)); + return int(std::round((double)value * (unitsize + spacing) / 1000)); case Pixel: default: return value; + } } } @@ -180,18 +197,13 @@ /// doubles for automatic conversion class UnitDimension : public Dimension { public: - /*constexpr UnitDimension(int value = 0, Unit unit = UnitSize) : Dimension(value, unit) { - }*/ - - constexpr UnitDimension() : Dimension() { } - - constexpr UnitDimension(int value, Unit unit) : Dimension(value, unit) { + constexpr UnitDimension(int value = 0, Unit unit = UnitSize) : Dimension(value, unit) { } - constexpr UnitDimension(double value, Unit unit/* = MilliUnitSize*/) : Dimension(value, unit) { + constexpr UnitDimension(double value, Unit unit = MilliUnitSize) : Dimension(value, unit) { } - constexpr UnitDimension(float value, Unit unit/* = MilliUnitSize*/) : Dimension((double)value, unit) { + constexpr UnitDimension(float value, Unit unit = MilliUnitSize) : Dimension((double)value, unit) { } constexpr UnitDimension(const Dimension &d) : Dimension(d) { } @@ -264,12 +276,12 @@ /// Converts the given value to dimension with unit size inline constexpr Dimension Units(float val) { - return {val, Dimension::UnitSize}; + return {val, Dimension::MilliUnitSize}; } /// Converts the given value to dimension with unit size inline constexpr Dimension Units(double val) { - return {val, Dimension::UnitSize}; + return {val, Dimension::MilliUnitSize}; } class DualDimension {
--- a/Source/Gorgon/UI/ScrollingWidget.cpp Tue Oct 26 14:22:22 2021 +0300 +++ b/Source/Gorgon/UI/ScrollingWidget.cpp Thu Oct 28 05:41:36 2021 +0300 @@ -325,4 +325,22 @@ this->scrollto(scrollto); } + + void ScrollingWidget::SetScrollDistance(Geometry::Point dist) { + scrolldist = dist; + + auto vscroller = dynamic_cast<Widgets::VScrollbar*>(stack.GetWidget(UI::ComponentTemplate::VScrollTag)); + + if(vscroller != nullptr) { + vscroller->SetSmallChange(dist.Y); + } + + auto hscroller = dynamic_cast<Widgets::HScrollbar*>(stack.GetWidget(UI::ComponentTemplate::HScrollTag)); + + if(hscroller != nullptr) { + hscroller->SetSmallChange(dist.X); + } + + } + } }
--- a/Source/Gorgon/UI/ScrollingWidget.h Tue Oct 26 14:22:22 2021 +0300 +++ b/Source/Gorgon/UI/ScrollingWidget.h Thu Oct 28 05:41:36 2021 +0300 @@ -34,7 +34,7 @@ } /// Adjusts the smooth scrolling speed of the panel. Given value is - /// in pixels per second, default value is 250. + /// in pixels per second, default value is 500. void SetSmoothScrollSpeed(int value); /// Returns the smooth scrolling speed of the panel. If smooth scroll @@ -62,6 +62,27 @@ return maxscrolltime; } + /// Sets the horizontal scroll distance per click in pixels. Default depends + /// on the default size of the panel. + void SetScrollDistance(int vert) { + SetScrollDistance({scrolldist.X, vert}); + } + + /// Sets the scroll distance per click in pixels. Default depends + /// on the default size of the panel. + void SetScrollDistance(int hor, int vert) { + SetScrollDistance({hor, vert}); + } + + /// Sets the scroll distance per click in pixels. Default depends + /// on the default size of the panel. + void SetScrollDistance(Geometry::Point dist); + + /// Returns the scroll distance per click + Geometry::Point GetScrollDistance() const { + return scrolldist; + } + protected: /// Ensures given region is visible
--- a/Source/Gorgon/UI/Widget.cpp Tue Oct 26 14:22:22 2021 +0300 +++ b/Source/Gorgon/UI/Widget.cpp Thu Oct 28 05:41:36 2021 +0300 @@ -136,6 +136,50 @@ MouseLeaveEvent(); } + void Widget::calculatebounds() { + int unitsize = 0, spacing = 0; + Geometry::Size sz; + if(HasParent()) { + unitsize = GetParent().GetUnitSize(); + spacing = GetParent().GetSpacing(); + sz = GetParent().GetInteriorSize() + Geometry::Size(spacing, spacing); + } + else { + unitsize = Widgets::Registry::Active().GetUnitSize(); + spacing = Widgets::Registry::Active().GetSpacing(); + sz = GetCurrentSize(); + } + + auto l= Convert( + location, sz, + unitsize, spacing, + Widgets::Registry::Active().GetEmSize() + ); + + if(llocation != l) { + move(l); + llocation = l; + } + + auto s = Convert( + size, sz, + unitsize, spacing, + Widgets::Registry::Active().GetEmSize() + ); + + if(size.Width.IsRelative()) { + s.Width -= spacing; + } + + if(size.Height.IsRelative()) { + s.Height -= spacing; + } + + if(lsize != s) { + resize(s); + lsize = s; + } + } void Widget::Move(const UnitPoint &value) { if(location == value) @@ -143,25 +187,7 @@ location = value; - //move out - int unitsize = 0, spacing = 0; - Geometry::Size sz; - if(HasParent()) { - unitsize = GetParent().GetUnitSize(); - spacing = GetParent().GetSpacing(); - sz = GetParent().GetInteriorSize(); - } - else { - unitsize = Widgets::Registry::Active().GetUnitSize(); - spacing = Widgets::Registry::Active().GetSpacing(); - sz = GetCurrentSize(); - } - - move(Convert( - location, sz, - unitsize, spacing, - Widgets::Registry::Active().GetEmSize() - )); + calculatebounds(); } void Widget::Resize(const UnitSize& value) { @@ -170,61 +196,12 @@ size = value; - //move out - int unitsize = 0, spacing = 0; - Geometry::Size sz; - if(HasParent()) { - unitsize = GetParent().GetUnitSize(); - spacing = GetParent().GetSpacing(); - sz = GetParent().GetInteriorSize(); - } - else { - unitsize = Widgets::Registry::Active().GetUnitSize(); - spacing = Widgets::Registry::Active().GetSpacing(); - sz = GetCurrentSize(); - } - - resize(Convert( - size, sz, - unitsize, spacing, - Widgets::Registry::Active().GetEmSize() - )); + calculatebounds(); } void Widget::parentboundschanged() { - //move out - int unitsize = 0, spacing = 0; - Geometry::Size sz; - if(HasParent()) { - unitsize = GetParent().GetUnitSize(); - spacing = GetParent().GetSpacing(); - sz = GetParent().GetInteriorSize(); - } - else { - unitsize = Widgets::Registry::Active().GetUnitSize(); - spacing = Widgets::Registry::Active().GetSpacing(); - sz = GetCurrentSize(); - } - - auto l= Convert( - location, sz, - unitsize, spacing, - Widgets::Registry::Active().GetEmSize() - ); - - if(GetCurrentLocation() != l) { - move(l); - } - - auto s = Convert( - size, sz, - unitsize, spacing, - Widgets::Registry::Active().GetEmSize() - ); - - if(GetCurrentSize() != s) - resize(s); + calculatebounds(); } } }
--- a/Source/Gorgon/UI/Widget.h Tue Oct 26 14:22:22 2021 +0300 +++ b/Source/Gorgon/UI/Widget.h Thu Oct 28 05:41:36 2021 +0300 @@ -17,6 +17,10 @@ */ class Widget { friend class WidgetContainer; + //non virtual functions for VS + void resize_(const UnitSize &size) { + Resize(size); + } public: @@ -46,7 +50,7 @@ virtual Geometry::Point GetCurrentLocation() const = 0; /// Changes the size of the widget. - virtual void Resize(UnitDimension w, UnitDimension h) { Resize({w, h}); }; + void Resize(UnitDimension w, UnitDimension h) { Resize({w, h}); }; /// Changes the size of the widget. virtual void Resize(const UnitSize &size); @@ -224,7 +228,7 @@ Event<Widget> DestroyedEvent = Event<Widget>{*this}; Geometry::basic_PointProperty<Widget, UnitPoint, &Widget::GetLocation, &Widget::Move> Location; - Geometry::basic_SizeProperty<Widget, UnitSize, &Widget::GetSize, &Widget::Resize> Size; + Geometry::basic_SizeProperty<Widget, UnitSize, &Widget::GetSize, &Widget::resize_> Size; TextualProperty<Widget, std::string, &Widget::GetTooltip, &Widget::SetTooltip> Tooltip; /// This is a debug feature @@ -299,6 +303,10 @@ virtual void mouseenter(); virtual void mouseleave(); + + /// This function will recalculate location and the size of the widget + /// and if there is a change it will call necessary functions. + void calculatebounds(); std::string tooltip; @@ -311,6 +319,9 @@ UnitPoint location; UnitSize size; + + Geometry::Point llocation = {0, 0}; + Geometry::Size lsize = {-1, -1}; /// Never call this function virtual void hide() = 0;
--- a/Source/Gorgon/UI/WidgetContainer.cpp Tue Oct 26 14:22:22 2021 +0300 +++ b/Source/Gorgon/UI/WidgetContainer.cpp Thu Oct 28 05:41:36 2021 +0300 @@ -1,5 +1,6 @@ #include "WidgetContainer.h" #include "../Widgets/Composer.h" +#include "../Widgets/Label.h" namespace Gorgon { namespace UI { @@ -610,4 +611,94 @@ AsWidget().GetParent().SetHoveredWidget(widget); } + + Widgets::Label &WidgetContainer::Add(const std::string& text) { + auto &l = *new Widgets::Label(text); + l.SetHorizonalAutosize(true); + Add(l); + owned.Add(l); + + return l; + } + + Widgets::Label &WidgetContainer::AddUnder(const std::string& text) { + auto &l = *new Widgets::Label(text); + AddUnder(l); + l.SetHorizonalAutosize(true); + owned.Add(l); + + return l; + } + + Widgets::Label &WidgetContainer::AddUnder(const std::string& text, const Widget &other) { + auto &l = *new Widgets::Label(text); + AddUnder(l, other); + l.SetHorizonalAutosize(true); + owned.Add(l); + + return l; + } + + Widgets::Label &WidgetContainer::AddNextTo(const std::string& text) { + auto &l = *new Widgets::Label(text); + l.SetHorizonalAutosize(true); + AddNextTo(l); + owned.Add(l); + + return l; + } + + Widgets::Label &WidgetContainer::AddNextTo(const std::string& text, const Widget &other) { + auto &l = *new Widgets::Label(text); + l.SetHorizonalAutosize(true); + AddNextTo(l, other); + owned.Add(l); + + return l; + } + + bool WidgetContainer::AddUnder(Widget &widget) { + if(GetCount()) + return AddUnder(widget, *widgets.Last()); + else { + bool res = Add(widget); + if(res) + widget.Move(Pixels(0, 0)); + + return res; + } + } + + bool WidgetContainer::AddUnder(Widget &widget, const Widget &other) { + bool res = Add(widget); + if(res) { + widget.Move(Pixels(0, other.GetBounds().Bottom + GetSpacing())); + } + + return res; + } + + bool WidgetContainer::AddNextTo(Widget &widget) { + if(GetCount()) + return AddNextTo(widget, *widgets.Last()); + else { + bool res = Add(widget); + if(res) + widget.Move(Pixels(0, 0)); + + return res; + } + } + + bool WidgetContainer::AddNextTo(Widget &widget, const Widget &other) { + bool res = Add(widget); + if(res) { + auto b = other.GetBounds(); + widget.Move(Pixels(b.Right + GetSpacing(), b.Top)); + } + + return res; + } + + } }
--- a/Source/Gorgon/UI/WidgetContainer.h Tue Oct 26 14:22:22 2021 +0300 +++ b/Source/Gorgon/UI/WidgetContainer.h Thu Oct 28 05:41:36 2021 +0300 @@ -7,7 +7,15 @@ #include "../Input/Keyboard.h" #include "Organizers/Base.h" -namespace Gorgon { namespace UI { +namespace Gorgon { + +namespace Widgets { + + class Label; + +} + +namespace UI { class WidgetContainer; @@ -78,6 +86,60 @@ /// function will return false. bool Add(Widget &widget); + /// Adds a new label with the given text. Ownership of this + /// newly created widget lies with the container. This + /// function enables horizontal autosizing. + Widgets::Label &Add(const std::string &text); + + /// Adds a new label with the given text. Ownership of this + /// newly created widget lies with the container. This + /// function enables horizontal autosizing. + Widgets::Label &AddUnder(const std::string &text); + + /// Adds a new label with the given text. Ownership of this + /// newly created widget lies with the container. This + /// function enables horizontal autosizing. + Widgets::Label &AddUnder(const std::string &text, const Widget &other); + + /// Adds a new label with the given text. Ownership of this + /// newly created widget lies with the container. This + /// function enables horizontal autosizing. + Widgets::Label &AddNextTo(const std::string &text); + + /// Adds a new label with the given text. Ownership of this + /// newly created widget lies with the container. This + /// function enables horizontal autosizing. + Widgets::Label &AddNextTo(const std::string &text, const Widget &other); + + /// Adds the given widget to this container and locates it + /// under the last widget at the start of the next line. + /// If container is empty, the widget will be located at + /// the top left. Note that this does not create a bond + /// between widgets thus if target widget is moved or + /// resized, added widget will not move. + bool AddUnder(Widget &widget); + + /// Adds the given widget to this container and locates it + /// under the given widget at the start of the next line. + /// Note that this does not create a bond between widgets + /// thus if target widget is moved or resized, added widget + /// will not move. + bool AddUnder(Widget &widget, const Widget &other); + + /// Adds the given widget to this container and locates it + /// next to the given widget. + /// If container is empty, the widget will be located at + /// the top left. Note that this does not create a bond + /// between widgets thus if target widget is moved or + /// resized, added widget will not move. + bool AddNextTo(Widget &widget); + + /// Adds the given widget to this container and locates it + /// next to the given widget. Note that this does not create + /// a bond between widgets thus if target widget is moved or + /// resized, added widget will not move. + bool AddNextTo(Widget &widget, const Widget &other); + /// Add the given widget to this container. Widget will /// be placed to the top of the z-order, and to the specified /// focus order. If the given widget cannot be added, this
--- a/Source/Gorgon/Widgets/DialogWindow.cpp Tue Oct 26 14:22:22 2021 +0300 +++ b/Source/Gorgon/Widgets/DialogWindow.cpp Thu Oct 28 05:41:36 2021 +0300 @@ -51,10 +51,12 @@ } } - DialogWindow::DialogWindow(const UI::Template &temp, const std::string &title, const Geometry::Size size, AutoplaceTarget autoplace) : + DialogWindow::DialogWindow(const UI::Template &temp, const std::string &title, const UI::UnitSize size, AutoplaceTarget autoplace) : DialogWindow(temp, title, autoplace) { - Resize(size); + interiorsized = true; + Panel::Resize(size); + updatescrollvisibility(); if(buttonsarea.IsReady())
--- a/Source/Gorgon/Widgets/DialogWindow.h Tue Oct 26 14:22:22 2021 +0300 +++ b/Source/Gorgon/Widgets/DialogWindow.h Thu Oct 28 05:41:36 2021 +0300 @@ -24,9 +24,9 @@ explicit DialogWindow(const UI::Template &temp, const std::string &title = "", AutoplaceTarget autoplace = DialogLevel); - DialogWindow(const UI::Template &temp, const std::string &title, const Geometry::Size size, AutoplaceTarget autoplace = DialogLevel); + DialogWindow(const UI::Template &temp, const std::string &title, const UI::UnitSize size, AutoplaceTarget autoplace = DialogLevel); - DialogWindow(const UI::Template &temp, const Geometry::Size size, AutoplaceTarget autoplace = DialogLevel) : + DialogWindow(const UI::Template &temp, const UI::UnitSize size, AutoplaceTarget autoplace = DialogLevel) : DialogWindow(temp, "", size, autoplace) { } @@ -40,19 +40,19 @@ DialogWindow(Registry::Active()[type], title) { } - DialogWindow(const std::string &title, const Geometry::Size size, AutoplaceTarget autoplace = DialogLevel, Registry::TemplateType type = Registry::Window_Dialog) : + DialogWindow(const std::string &title, const UI::UnitSize size, AutoplaceTarget autoplace = DialogLevel, Registry::TemplateType type = Registry::Window_Dialog) : DialogWindow(Registry::Active()[type], title, size, autoplace) { } - DialogWindow(const std::string &title, const Geometry::Size size, Registry::TemplateType type) : + DialogWindow(const std::string &title, const UI::UnitSize size, Registry::TemplateType type) : DialogWindow(Registry::Active()[type], title, size) { } - DialogWindow(const Geometry::Size size, AutoplaceTarget autoplace = DialogLevel, Registry::TemplateType type = Registry::Window_Dialog) : + DialogWindow(const UI::UnitSize size, AutoplaceTarget autoplace = DialogLevel, Registry::TemplateType type = Registry::Window_Dialog) : DialogWindow(Registry::Active()[type], "", size, autoplace) { } - DialogWindow(const Geometry::Size size, Registry::TemplateType type) : + DialogWindow(const UI::UnitSize size, Registry::TemplateType type) : DialogWindow(Registry::Active()[type], "", size) { }
--- a/Source/Gorgon/Widgets/Generator.cpp Tue Oct 26 14:22:22 2021 +0300 +++ b/Source/Gorgon/Widgets/Generator.cpp Thu Oct 28 05:41:36 2021 +0300 @@ -1933,7 +1933,7 @@ vs.SetSizing(UI::ComponentTemplate::Fixed); vs.SetAnchor(UI::Anchor::TopRight, UI::Anchor::TopRight, UI::Anchor::TopLeft); vs.SetMargin(spacing, 0, 0, 0); - + auto &hs = temp.AddPlaceholder(4, UI::ComponentCondition::HScroll); hs.SetPositioning(UI::ComponentTemplate::Absolute); hs.SetTemplate(hst);
--- a/Source/Gorgon/Widgets/Panel.cpp Tue Oct 26 14:22:22 2021 +0300 +++ b/Source/Gorgon/Widgets/Panel.cpp Thu Oct 28 05:41:36 2021 +0300 @@ -47,7 +47,7 @@ SetSmoothScrollSpeed(scrollspeed); - scrolldist = {temp.GetUnitSize()*4, temp.GetUnitSize()*2}; + SetScrollDistance(temp.GetUnitSize()*4, temp.GetUnitSize()*2); } bool Panel::Activate() { @@ -128,7 +128,6 @@ childboundschanged(nullptr); distributeparentboundschanged(); } - void Panel::move(const Geometry::Point &location) { ComponentStackWidget::move(location);
--- a/Source/Gorgon/Widgets/Panel.h Tue Oct 26 14:22:22 2021 +0300 +++ b/Source/Gorgon/Widgets/Panel.h Thu Oct 28 05:41:36 2021 +0300 @@ -195,29 +195,6 @@ return maxscrolloffset(); } - /// Sets the horizontal scroll distance per click in pixels. Default depends - /// on the default size of the panel. - void SetScrollDistance(int vert) { - SetScrollDistance({scrolldist.X, vert}); - } - - /// Sets the scroll distance per click in pixels. Default depends - /// on the default size of the panel. - void SetScrollDistance(int hor, int vert) { - SetScrollDistance({hor, vert}); - } - - /// Sets the scroll distance per click in pixels. Default depends - /// on the default size of the panel. - void SetScrollDistance(Geometry::Point dist) { - setscrolldistance(dist); - } - - /// Returns the scroll distance per click - Geometry::Point GetScrollDistance() const { - return scrolldist; - } - protected: virtual bool allowfocus() const override;
--- a/Source/Gorgon/Widgets/Window.cpp Tue Oct 26 14:22:22 2021 +0300 +++ b/Source/Gorgon/Widgets/Window.cpp Thu Oct 28 05:41:36 2021 +0300 @@ -47,13 +47,13 @@ Center(); } - //TODO interior sizing minsize = GetCurrentSize() - GetInteriorSize() + Geometry::Size(stack.GetTemplate().GetUnitSize()*2, stack.GetTemplate().GetUnitSize()); } Window::Window(const UI::Template &temp, const std::string &title, const UI::UnitSize size, bool autoplace) : Window(temp, title, autoplace) { + interiorsized = true; Resize(size); updatescrollvisibility(); @@ -529,4 +529,30 @@ return true; } + bool Window::ResizeInterior(Geometry::Size size) { + interiorsized = true; + + Panel::Resize(Pixels(size)); + + return stack.TagBounds(UI::ComponentTemplate::ContentsTag).GetSize() == size; + } + + + void Window::resize(const Geometry::Size& size) { + if(interiorsized) { + Geometry::Size border = {0, 0}; + + auto innersize = stack.TagBounds(UI::ComponentTemplate::ViewPortTag).GetSize(); + + if(innersize.Area() != 0) + border = GetCurrentSize() - innersize; + + Panel::resize(size + border); + } + else { + Panel::resize(size); + } + + } + } }
--- a/Source/Gorgon/Widgets/Window.h Tue Oct 26 14:22:22 2021 +0300 +++ b/Source/Gorgon/Widgets/Window.h Thu Oct 28 05:41:36 2021 +0300 @@ -190,6 +190,16 @@ UI::ComponentStackWidget::Show(); Focus(); } + + using Panel::Resize; + + virtual void Resize(const UI::UnitSize &size) override { + interiorsized = false; + Panel::Resize(size); + } + + using Panel::ResizeInterior; + virtual bool ResizeInterior(Geometry::Size size) override; /// Centers the window to its container. After resizing the window or /// changing its parent you need to recenter it. All windows open @@ -228,6 +238,8 @@ virtual void focused() override; virtual bool allowfocus() const override; + + virtual void resize(const Geometry::Size &size) override; void updatescrollvisibility(); @@ -239,6 +251,8 @@ void mouse_click(UI::ComponentTemplate::Tag tag, Geometry::Point location, Input::Mouse::Button button); + bool interiorsized = false; + private: enum resizedir { none,
--- a/Testing/Source/Manual/UI_Generate.cpp Tue Oct 26 14:22:22 2021 +0300 +++ b/Testing/Source/Manual/UI_Generate.cpp Thu Oct 28 05:41:36 2021 +0300 @@ -108,8 +108,10 @@ // generator.UpdateDimensions(); // generator.Activate(); - Widgets::Panel blank(Widgets::Registry::Panel_Right); + Widgets::Panel blank/*(Widgets::Registry::Panel_Right)*/; blank.Move(Pixels(5, 50)); + blank.SetWidth(6_u); + std::cout << float(blank.GetInteriorSize().Width + blank.GetSpacing()) / (blank.GetUnitSize() + blank.GetSpacing()) << std::endl; blank.SetHeight(300_px); auto icon = Triangle(5, 10); icon.Prepare(); @@ -117,10 +119,14 @@ icon2.Prepare(); Gorgon::Widgets::Button btn("Save Âj", Gorgon::Widgets::Registry::Button_Regular); + Gorgon::Widgets::Button btn2("Another", 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); btn.OwnIcon(icon2.CreateAnimation()); + btn.Size.Width = 50_perc; + btn2.Size.Width = 50_perc; + btn2.Location.X = 50_perc; icnbtn.OwnIcon(icon2.CreateAnimation()); @@ -308,11 +314,14 @@ ; org << org.Action("Ok", [&]() { std::cout << "Ok clicked" << std::endl; }); - btn.SetHorizonalAutosize(Gorgon::UI::Autosize::Unit); + //btn.SetHorizonalAutosize(Gorgon::UI::Autosize::Unit); - Widgets::DialogWindow wind("My window", {200, 300}); + Widgets::DialogWindow wind("My window", {6, 6}); wind.Add(btn); + wind.Add(btn2); + btn.Move(Pixels(0,0)); + btn.Disable(); wind.OwnIcon(icon.CreateAnimation()); int closetrycount = 0; wind.ClosingEvent.Register([&](bool &allow) { @@ -320,16 +329,13 @@ if(!allow) std::cout << "Click once more to close." << std::endl; }); - btn.Move(Pixels(0,0)); - btn.Disable(); Widgets::Checkbox enableclosebtn("Enable close button", true); + enableclosebtn.SetWidth(7_u); enableclosebtn.SetAutosize(Gorgon::UI::Autosize::Unit, Gorgon::UI::Autosize::Automatic); enableclosebtn.ChangedEvent.Register([&] { wind.SetCloseButtonEnabled(bool(enableclosebtn)); }); - wind.Add(enableclosebtn); - wind.CreateOrganizer<UI::Organizers::List>() - .Add("Try resize") - .Add("Click close twice") - ; + wind.AddUnder(enableclosebtn); + wind.AddUnder("Try resize"); + wind.AddNextTo("Click close twice"); wind.AllowResize(); std::vector<std::string> opts = {"Zero", "One", "Two"}; wind.AddButton("?", [&]{