Shirakumo / alloy

A new user interface protocol and toolkit implementation
https://shirakumo.github.io/alloy
zlib License
181 stars 12 forks source link

[feature request/idea] layout item more easily with a layout macro #2

Closed Inc0n closed 4 years ago

Inc0n commented 4 years ago

Having a macro to do the heavy lifting for adding items to a layout, replaces and generates the same code, perhaps could be a good idead i.e originally:

...
      (alloy:enter "Frequency" l2 :row 2 :col 0)
      (alloy:enter freq l2 :row 2 :col 1)
      (alloy:enter "Amplitude" l2 :row 1 :col 0)
      (alloy:enter amps l2 :row 1 :col 1)
      (alloy:enter "Phase" l2 :row 0 :col 0)
      (alloy:enter phas l2 :row 0 :col 1)
...

now to:

(let ((l2 (make-instance 'alloy:grid-layout :layout-parent root-layout)))
      (alloy:layout-macro
       l2
       (("Frequency" freq)
        ("Amplitude" amps)
        ("Phase" phas))))

Macro details/specs:

(defmacro layout-macro (layout-obj layout-structure-lst)
 ... ;; implementation detail
)

This macro would:

Shinmera commented 4 years ago

For grid layouts there's no need to specify the rows and columns explicitly as you enter stuff, unless you want gaps. If you specify at least one row-size and the col-sizes when constructing the grid-layout, it'll automatically duplicate rows as you enter elements.

Otherwise to construct nested layouts, there's alloy:build-ui.