red / REP

Red Enhancement Process
BSD 3-Clause "New" or "Revised" License
11 stars 4 forks source link

WISH: query matrix in Draw #144

Open hiiamboris opened 1 year ago

hiiamboris commented 1 year ago

The need arises in Spaces to generate popups with the same transformation matrix as the widget that triggers the popup.

Drop-down lists are good examples. Quoting my own rant:

...imagine an interactive page with some drop-boxes, and if user could choose the page's zoom. Our drop-menu [dropped down list of choices] will appear bigger than the drop-box [drop-down widget or combo box]. Unfortunately, this limitation is currently unavoidable for popups. It is impossible to 'ask' Draw "what's your transformation matrix?" and apply it to the new popup face. It could be done by parsing the whole draw facet of the host until block returned by drop-box's draw will be found, but complexity and performance overhead of such solution makes it unacceptable for me.

Another use case may come in the future from visual effects that should also ignore clipping and be painted over the whole host face or window. One specific type of such effects I would like to have is whole-UI animation that will know where chosen UI element templates (e.g. buttons, images, labels - user-defined) are located and animates how these UI elements move into their proper place from outside the view using a set of predefined trajectories and easings (since they are located on different widget tree levels, such matrix querying inside styles is the only reasonably fast and easy way of doing it that I can imagine).

I propose a copy-matrix <block!> command for Draw that upon evaluation will replace six slots in the given block following its current offset, with the values of the transformation matrix. Then it can be known by the code that shows the popup and applied to it. Reuse of the provided buffer will keep it light on memory pressure and performant.

Also it will be possible to sync frames between the effect and its creator space: creator's Draw code while being drawn will push the matrix right into the other block where popup will pick it up using matrix <block!> command in the same Draw run.

hiiamboris commented 1 year ago

What could also be useful is full state stashing and restoration: matrix, pens, line settings, font. Anti-aliasing not so much.