adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
531 stars 128 forks source link

Minigui layouts #136

Closed ASHIT-AXAR closed 6 years ago

ASHIT-AXAR commented 6 years ago

hello adam. layout containers can be very useful i was thinking can we just change the way we use layouts?. something like following (for ex) :

auto layout = new StackLayout();
layout.Orientation = Orientation.Vertical;

window.Add(layout);

auto button = new Button("Button");
auto label = new TextLabel("Label");

// are these following easy to do instead of defining parent on initialization ?
layout.Add(label);
layout.Add(button);

this gives more control if be easy to implement. and also every widget be able to have at most one child. except layouts. emoji-andish-32

adamdruppe commented 6 years ago

On Wed, Feb 21, 2018 at 12:26:39PM -0800, ASHIT-AXAR wrote:

i was thinking can we just change the way we use layouts?. something like following (for ex) :

You can already almost do that, though the layout needs to be added to the window first because otherwise the draw functions and create child window stuff isn't initialized.

Maybe changing the code to do that lazily would work though...

and also every widget be able to have at most one child. except layouts.

...but what is the big advantage to doing it this way?

ASHIT-AXAR commented 6 years ago

...but what is the big advantage to doing it this way?

i don't know really, in WPF(C#) we just using this approach. every Control/Widget can have one child (and parent) at most. except Containers/Layouts. i was never bother myself thinking why. maybe better organizing/control over elements. layouts/containers (mixing with Margin and Padding) are powerful and a great potential (and in my opinion a key) to create structured and good looking UIs

adamdruppe commented 6 years ago

On Thu, Feb 22, 2018 at 12:28:41PM +0000, ASHIT-AXAR wrote:

i don't know really, in WPF(C#) we just using this approach.

Hmm, I have never actually used WPF, heard a lot of good things however. And it makes some sense though, like it often seems silly to give a button child buttons...

But I was modeling this a bit more on the web, where you have a tree of elements and most things can hold other things too, then have their layout adjusted. (You'll see the web influence in a lot of things: margin and padding work like they do in css (mostly), the addEventListener follows the javascript bubbling model, etc.)

layouts/containers (mixing with Margin and Padding) are powerful potential (and in my opinion a key) to create structured and good looking UIs

But you can do that with the way it is now, just the order of calls are slightly different.