mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
ui: move macro recording from Ops to MacroOp
Move the Record and Stop methods from Ops to MacroOp itself. Before this change, Ops.Stop stopped the recording of the most recent macro, which could be a different macro than intended. After this change, there is no such confusion. As a bonus, the Ops API becomes less cluttered. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+4
-3
@@ -14,6 +14,7 @@ type Flex struct {
|
||||
MainAxisAlignment MainAxisAlignment
|
||||
CrossAxisAlignment CrossAxisAlignment
|
||||
|
||||
macro ui.MacroOp
|
||||
ops *ui.Ops
|
||||
cs Constraints
|
||||
mode flexMode
|
||||
@@ -74,7 +75,7 @@ func (f *Flex) begin(mode flexMode) {
|
||||
panic("must End before adding a child")
|
||||
}
|
||||
f.mode = mode
|
||||
f.ops.Record()
|
||||
f.macro.Record(f.ops)
|
||||
}
|
||||
|
||||
func (f *Flex) Rigid() Constraints {
|
||||
@@ -107,7 +108,7 @@ func (f *Flex) End(dims Dimens) FlexChild {
|
||||
if f.mode <= modeBegun {
|
||||
panic("End called without an active child")
|
||||
}
|
||||
macro := f.ops.Stop()
|
||||
f.macro.Stop()
|
||||
sz := axisMain(f.Axis, dims.Size)
|
||||
f.size += sz
|
||||
if f.mode == modeRigid {
|
||||
@@ -120,7 +121,7 @@ func (f *Flex) End(dims Dimens) FlexChild {
|
||||
if b := dims.Baseline; b > f.maxBaseline {
|
||||
f.maxBaseline = b
|
||||
}
|
||||
return FlexChild{macro, dims}
|
||||
return FlexChild{f.macro, dims}
|
||||
}
|
||||
|
||||
func (f *Flex) Layout(children ...FlexChild) Dimens {
|
||||
|
||||
Reference in New Issue
Block a user