kas-gui / kas

Another GUI toolkit
Apache License 2.0
892 stars 27 forks source link

WidgetId → Id, revise handling of Action and pending ops #413

Closed dhardy closed 8 months ago

dhardy commented 8 months ago

Rename WidgetIdId (finally!). As noted in https://github.com/kas-gui/design/pull/10 , variations were considered and rejected, so this is mostly just a rename.

Revise pending ops in EventState. Instead of attempting to maintain order of the various ops, they are considered independently in the most appropriate order.

Remove *cx |= action operator; replace EventState::send_action(action) method with EventState::action(id, action) method where id: impl HasId (a new trait supporting both Id and widgets). This allows actions to be applied only to sub-trees.

Action::RECONFIGURE and UPDATE now apply to sub-trees. SET_RECT and RESIZE could be given the same treatment (the latter probably requires significant adjustment to Layout::size_rules giving its SizeCx control over recursion to children). Our current renderer does not support "damage regions" (esp. with regards to transparency and draw order), but if another renderer needed this we would probably want to track a redraw: Option<Id> field in EventState (and would need similar tracking for animations).

Aside: sub-tree operations feel unnecessary considering resizes are 1-2ms and redraws 1-2ms (debug builds). But maybe more constrained systems will benefit. Further aside: a future WGPU version is required to fix resizing: wgpu#4227 appears to fix this for me. Edit: correct render time by omitting frame presentation (wait) time.