Shirakumo / alloy

A new user interface protocol and toolkit implementation

Home Page:https://shirakumo.github.io/alloy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Inc0n opened this issue · comments

commented

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:

  • determine the dimension of structure-lst
  • cases where dimension doesn't match, such as '((one-object) (two objects)), will be handled accordingly
  • generates the code which this macro replaces (see first code snippet)

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.