mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
op: add package op for operations
Extract operation types from package ui into package op. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+5
-5
@@ -6,7 +6,7 @@ import (
|
||||
"image"
|
||||
|
||||
"gioui.org/f32"
|
||||
"gioui.org/ui"
|
||||
"gioui.org/op"
|
||||
)
|
||||
|
||||
// Flex lays out child elements along an axis,
|
||||
@@ -21,7 +21,7 @@ type Flex struct {
|
||||
Alignment Alignment
|
||||
|
||||
ctx *Context
|
||||
macro ui.MacroOp
|
||||
macro op.MacroOp
|
||||
mode flexMode
|
||||
size int
|
||||
rigidSize int
|
||||
@@ -33,7 +33,7 @@ type Flex struct {
|
||||
|
||||
// FlexChild is the layout result of a call End.
|
||||
type FlexChild struct {
|
||||
macro ui.MacroOp
|
||||
macro op.MacroOp
|
||||
dims Dimensions
|
||||
}
|
||||
|
||||
@@ -189,9 +189,9 @@ func (f *Flex) Layout(children ...FlexChild) {
|
||||
cross = f.maxBaseline - b
|
||||
}
|
||||
}
|
||||
var stack ui.StackOp
|
||||
var stack op.StackOp
|
||||
stack.Push(f.ctx.Ops)
|
||||
ui.TransformOp{}.Offset(toPointF(axisPoint(f.Axis, mainSize, cross))).Add(f.ctx.Ops)
|
||||
op.TransformOp{}.Offset(toPointF(axisPoint(f.Axis, mainSize, cross))).Add(f.ctx.Ops)
|
||||
child.macro.Add(f.ctx.Ops)
|
||||
stack.Pop()
|
||||
mainSize += axisMain(f.Axis, dims.Size)
|
||||
|
||||
+8
-7
@@ -6,6 +6,7 @@ import (
|
||||
"image"
|
||||
|
||||
"gioui.org/io/event"
|
||||
"gioui.org/op"
|
||||
"gioui.org/ui"
|
||||
)
|
||||
|
||||
@@ -53,7 +54,7 @@ type Context struct {
|
||||
|
||||
ui.Config
|
||||
event.Queue
|
||||
*ui.Ops
|
||||
*op.Ops
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -97,7 +98,7 @@ func (c *Context) Reset(cfg ui.Config, cs Constraints) {
|
||||
c.Dimensions = Dimensions{}
|
||||
c.Config = cfg
|
||||
if c.Ops == nil {
|
||||
c.Ops = new(ui.Ops)
|
||||
c.Ops = new(op.Ops)
|
||||
}
|
||||
c.Ops.Reset()
|
||||
}
|
||||
@@ -157,9 +158,9 @@ func (in Inset) Layout(gtx *Context, w Widget) {
|
||||
if mcs.Height.Max < mcs.Height.Min {
|
||||
mcs.Height.Max = mcs.Height.Min
|
||||
}
|
||||
var stack ui.StackOp
|
||||
var stack op.StackOp
|
||||
stack.Push(gtx.Ops)
|
||||
ui.TransformOp{}.Offset(toPointF(image.Point{X: left, Y: top})).Add(gtx.Ops)
|
||||
op.TransformOp{}.Offset(toPointF(image.Point{X: left, Y: top})).Add(gtx.Ops)
|
||||
dims := gtx.Layout(mcs, w)
|
||||
stack.Pop()
|
||||
gtx.Dimensions = Dimensions{
|
||||
@@ -176,7 +177,7 @@ func UniformInset(v ui.Value) Inset {
|
||||
|
||||
// Layout a widget.
|
||||
func (a Align) Layout(gtx *Context, w Widget) {
|
||||
var macro ui.MacroOp
|
||||
var macro op.MacroOp
|
||||
macro.Record(gtx.Ops)
|
||||
cs := gtx.Constraints
|
||||
mcs := cs
|
||||
@@ -204,9 +205,9 @@ func (a Align) Layout(gtx *Context, w Widget) {
|
||||
case SW, S, SE:
|
||||
p.Y = sz.Y - dims.Size.Y
|
||||
}
|
||||
var stack ui.StackOp
|
||||
var stack op.StackOp
|
||||
stack.Push(gtx.Ops)
|
||||
ui.TransformOp{}.Offset(toPointF(p)).Add(gtx.Ops)
|
||||
op.TransformOp{}.Offset(toPointF(p)).Add(gtx.Ops)
|
||||
macro.Add(gtx.Ops)
|
||||
stack.Pop()
|
||||
gtx.Dimensions = Dimensions{
|
||||
|
||||
+6
-6
@@ -7,13 +7,13 @@ import (
|
||||
|
||||
"gioui.org/gesture"
|
||||
"gioui.org/io/pointer"
|
||||
"gioui.org/op"
|
||||
"gioui.org/paint"
|
||||
"gioui.org/ui"
|
||||
)
|
||||
|
||||
type scrollChild struct {
|
||||
size image.Point
|
||||
macro ui.MacroOp
|
||||
macro op.MacroOp
|
||||
}
|
||||
|
||||
// List displays a subsection of a potentially infinitely
|
||||
@@ -33,8 +33,8 @@ type List struct {
|
||||
beforeEnd bool
|
||||
|
||||
ctx *Context
|
||||
macro ui.MacroOp
|
||||
child ui.MacroOp
|
||||
macro op.MacroOp
|
||||
child op.MacroOp
|
||||
scroll gesture.Scroll
|
||||
scrollDelta int
|
||||
|
||||
@@ -246,10 +246,10 @@ func (l *List) layout() Dimensions {
|
||||
Min: axisPoint(l.Axis, min, -inf),
|
||||
Max: axisPoint(l.Axis, max, inf),
|
||||
}
|
||||
var stack ui.StackOp
|
||||
var stack op.StackOp
|
||||
stack.Push(ops)
|
||||
paint.RectClip(r).Add(ops)
|
||||
ui.TransformOp{}.Offset(toPointF(axisPoint(l.Axis, pos, cross))).Add(ops)
|
||||
op.TransformOp{}.Offset(toPointF(axisPoint(l.Axis, pos, cross))).Add(ops)
|
||||
child.macro.Add(ops)
|
||||
stack.Pop()
|
||||
pos += childSize
|
||||
|
||||
+5
-5
@@ -5,7 +5,7 @@ package layout
|
||||
import (
|
||||
"image"
|
||||
|
||||
"gioui.org/ui"
|
||||
"gioui.org/op"
|
||||
)
|
||||
|
||||
// Stack lays out child elements on top of each other,
|
||||
@@ -15,7 +15,7 @@ type Stack struct {
|
||||
// smaller than the available space.
|
||||
Alignment Direction
|
||||
|
||||
macro ui.MacroOp
|
||||
macro op.MacroOp
|
||||
constrained bool
|
||||
ctx *Context
|
||||
maxSZ image.Point
|
||||
@@ -24,7 +24,7 @@ type Stack struct {
|
||||
|
||||
// StackChild is the layout result of a call to End.
|
||||
type StackChild struct {
|
||||
macro ui.MacroOp
|
||||
macro op.MacroOp
|
||||
dims Dimensions
|
||||
}
|
||||
|
||||
@@ -99,9 +99,9 @@ func (s *Stack) Layout(children ...StackChild) {
|
||||
case SW, S, SE:
|
||||
p.Y = s.maxSZ.Y - sz.Y
|
||||
}
|
||||
var stack ui.StackOp
|
||||
var stack op.StackOp
|
||||
stack.Push(s.ctx.Ops)
|
||||
ui.TransformOp{}.Offset(toPointF(p)).Add(s.ctx.Ops)
|
||||
op.TransformOp{}.Offset(toPointF(p)).Add(s.ctx.Ops)
|
||||
ch.macro.Add(s.ctx.Ops)
|
||||
stack.Pop()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user