-
Notifications
You must be signed in to change notification settings - Fork 35
[WIP] added layout basics #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Hey, thanks for this! This is definitely a step in the right direction, even if not polished. Sorry for not responding earlier. If you wish to finish this into something that could be merged, I'll gladly provide code reviews. The idea of returning a map is interesting. What would be the advantages of this over simply returning a slice of |
|
Actually it was a slice of |
Good point, but how often do you need to address it? Don't you just create elements and let it go? I'm not arguing, just wanna get more info on this :D |
|
You're right, we only address them once, but it's mainly for clarity purposes. |
|
What about something like this? var left, middle, right gui.Env
hsplit := layout.NewHSplit(env, &left, &middle, &right)And this var (
topLeft, top, topRight gui.Env
left, middle, right gui.Env
bottomLeft, bottom, bottomRight gui.Env
)
grid := layout.NewGrid(
env,
[]*gui.Env{
{&topLeft, &top, &topRight},
{&left, &middle, &right},
{&bottomLeft, &bottom, &bottomRight},
},
)EDIT: And this: var title, image gui.Env
card := layout.NewCard(env, &layout.CardConfig{
Title: &title,
Image: &image,
}) |
|
This is a great alternative i hadn't thought about, and it would make a lot of things easier. |
|
Done, i also introduced a |
|
Great idea with the I am quite busy right now (and gonna be tomorrow as well), but a few quick thoughts:
Thanks for the great work so far, btw :) |
|
Thanks ! |
|
I was also thinking of splitting the Layout interface with a |
|
I refactored quite a bit and added an |
|
Hm, I'm not sure I like the I finally have more time again, so I'll be able to devote more time to this. I'll share new ideas as soon as I get them. |
|
I agree, it feels like a hack, but it felt less like a hack than some layout.NewMux(
mux.MakeEnv(),
[]*gui.Env{&top, &left, &right}, // !
layout.NewGrid(
[][]*gui.Env{
{&top},
{&left, &right},
},
),
)And voilà, no need for magic. There is still a problem though, because it's not really tied to the EDIT: layout.NewMux(
mux.MakeEnv(),
[]*gui.Env{&top, &left, &right},
layout.NewGrid(
[]int{ 1, 2 }, // for row length
),
)because the |
|
Well after implementing it it works really well, there's just something strange I can't quite put my finger on. |
|
I found two major problems with this approach:
The first thing that would come to mind is making the But if some better idea comes out, I'll take it for sure. |
|
I didn't get much time on this project lately, but here it is, mostly done and usable. |
Definitely don't merge this.
This is an attempt of mine at creating a layout system for this GUI system.
This is largely uncommented code, with some bits taken from the examples.
My take is that the layouts take an Env as parameter, and give back a map of string to Env.
The map keys are like "tags" for the sub Envs.
You could have a Scroller with "body", "header" and "footer" areas for example.
The Layouts are then basically acting as sophisticated Muxes.
If this idea takes on, some refactoring is needed because a lot of code for Layout is pasted from Mux.