vlang / ui

A cross-platform UI library written in V
MIT License
2.32k stars 154 forks source link

Add Grid Layout #488

Closed rcqls closed 1 year ago

dumblob commented 1 year ago

Any plans to make this arbitrarily reshapeable in runtime? E.g.:

a b c
m n o
p q r
x y z

->

a c  
m o
p r
x z
b n q y

And any swaps of arbitrary row/column with arbitrary row/column. Also any insertion of arbitrary-length row/column:

a b c
d e f
x y z

-> (e.g. insert an array of Widgets m, n, o but not as a row but rather as a column and - to make it more capable - in a reversed fashion starting at the position of e)

a b c  
d o e f
x n y z
  m

It seems the foundation is there (it is a generic map[string]Widget) but I am not sure about the envisioned capabilities as my experience with grid APIs can be mostly described as horrible :wink:.

rcqls commented 1 year ago

Any plans to make this arbitrarily reshapeable in runtime? E.g.:

a b c m n o p q r x y z ->

a c   m o
p r
x z
b n q y And any swaps of arbitrary row/column with arbitrary row/column. Also any insertion of arbitrary-length row/column:

a b c d e f x y z -> (e.g. insert an array of Widgets m, n, o but not as a row but rather as a column and - to make it more capable - in a reversed fashion starting at the position of e)

a b c   d o e f x n y z   m
It seems the foundation is there (it is a generic map[string]Widget) but I am not sure about the envisioned capabilities as my experience with grid APIs can be mostly described as horrible 😉.

Everything is indeed possible but not implemented yet for Stack. The grid_layout I have in mind is for locating every widget by giving its relative coordinates and size in a 100x100 grid (that can be viewed as a matrix). Also relative coordinates and sizes would be expressed in percentage of the size of the GridLayout With this specific layout, I guess it would be even easier to apply the transforms you investigate.

rcqls commented 1 year ago

After addition of a lot of PR and just after clipping PR from @edam, I prefer create a new PR #501