Material3 components
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package main
|
||||
|
||||
import engine "../zephr"
|
||||
|
||||
// Explicitly scoped containers.
|
||||
//
|
||||
// engine.ui_row/ui_column/ui_scroll_column carry @(deferred_none=pop_parent),
|
||||
// so they pop when the *calling scope* ends. That is fine when a container and
|
||||
// all its children sit in one proc, but it makes them unusable for anything
|
||||
// opened in one proc and closed in another -- a begin/end pair, or a container
|
||||
// that must close before a sibling is drawn. In those cases the row pops the
|
||||
// instant the helper returns and the children land in the wrong parent.
|
||||
//
|
||||
// These push explicitly, with no deferred pop, so the caller controls the scope.
|
||||
// caller is threaded through because box identity is hashed from it: wrapping
|
||||
// ui_create_box_with_id without it would give every call site the same id.
|
||||
|
||||
open_row :: proc(id: engine.Id = 0, caller := #caller_location) -> ^engine.Box {
|
||||
engine.set_next_layout_axis(.X)
|
||||
b := engine.ui_create_box_with_id({}, id, caller)
|
||||
engine.push_parent(b)
|
||||
return b
|
||||
}
|
||||
|
||||
open_column :: proc(id: engine.Id = 0, caller := #caller_location) -> ^engine.Box {
|
||||
engine.set_next_layout_axis(.Y)
|
||||
b := engine.ui_create_box_with_id({}, id, caller)
|
||||
engine.push_parent(b)
|
||||
return b
|
||||
}
|
||||
|
||||
open_scroll_column :: proc(id: engine.Id = 0, caller := #caller_location) -> ^engine.Box {
|
||||
engine.set_next_layout_axis(.Y)
|
||||
engine.ui_set_next_flags({.ClipToBounds, .ScrollableY})
|
||||
b := engine.ui_create_box_with_id({}, id, caller)
|
||||
engine.push_parent(b)
|
||||
return b
|
||||
}
|
||||
|
||||
close_box :: proc() {
|
||||
engine.pop_parent()
|
||||
}
|
||||
Reference in New Issue
Block a user