|
|
@ -264,9 +264,7 @@ type Dismiss struct {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *Dismiss) Add(gtx layout.Context) {
|
|
|
|
func (d *Dismiss) Add(gtx layout.Context) {
|
|
|
|
var stack op.StackOp
|
|
|
|
defer op.Push(gtx.Ops).Pop()
|
|
|
|
stack.Push(gtx.Ops)
|
|
|
|
|
|
|
|
defer stack.Pop()
|
|
|
|
|
|
|
|
pointer.Rect(image.Rectangle{Max: gtx.Constraints.Min}).Add(gtx.Ops)
|
|
|
|
pointer.Rect(image.Rectangle{Max: gtx.Constraints.Min}).Add(gtx.Ops)
|
|
|
|
pointer.InputOp{Tag: d}.Add(gtx.Ops)
|
|
|
|
pointer.InputOp{Tag: d}.Add(gtx.Ops)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -453,8 +451,7 @@ func (ui *UI) layoutMenu(gtx layout.Context, sysIns system.Insets, expiry time.T
|
|
|
|
f := layout.Flex{Axis: layout.Vertical}
|
|
|
|
f := layout.Flex{Axis: layout.Vertical}
|
|
|
|
// First pass: record and discard operations
|
|
|
|
// First pass: record and discard operations
|
|
|
|
// and determine widest item.
|
|
|
|
// and determine widest item.
|
|
|
|
var m op.MacroOp
|
|
|
|
m := op.Record(gtx.Ops)
|
|
|
|
m.Record(gtx.Ops)
|
|
|
|
|
|
|
|
f.Layout(gtx, children...)
|
|
|
|
f.Layout(gtx, children...)
|
|
|
|
m.Stop()
|
|
|
|
m.Stop()
|
|
|
|
// Second pass: layout items with equal width.
|
|
|
|
// Second pass: layout items with equal width.
|
|
|
@ -689,13 +686,11 @@ func drawLogo(ops *op.Ops, size int) {
|
|
|
|
tx := op.TransformOp{}.Offset(f32.Pt(off, 0))
|
|
|
|
tx := op.TransformOp{}.Offset(f32.Pt(off, 0))
|
|
|
|
ty := op.TransformOp{}.Offset(f32.Pt(0, off))
|
|
|
|
ty := op.TransformOp{}.Offset(f32.Pt(0, off))
|
|
|
|
|
|
|
|
|
|
|
|
var st op.StackOp
|
|
|
|
st := op.Push(ops)
|
|
|
|
st.Push(ops)
|
|
|
|
|
|
|
|
defer st.Pop()
|
|
|
|
defer st.Pop()
|
|
|
|
|
|
|
|
|
|
|
|
var row op.StackOp
|
|
|
|
|
|
|
|
// First row of discs.
|
|
|
|
// First row of discs.
|
|
|
|
row.Push(ops)
|
|
|
|
row := op.Push(ops)
|
|
|
|
drawDisc(ops, discDia, rgb(0x54514d))
|
|
|
|
drawDisc(ops, discDia, rgb(0x54514d))
|
|
|
|
tx.Add(ops)
|
|
|
|
tx.Add(ops)
|
|
|
|
drawDisc(ops, discDia, rgb(0x54514d))
|
|
|
|
drawDisc(ops, discDia, rgb(0x54514d))
|
|
|
@ -705,7 +700,7 @@ func drawLogo(ops *op.Ops, size int) {
|
|
|
|
|
|
|
|
|
|
|
|
ty.Add(ops)
|
|
|
|
ty.Add(ops)
|
|
|
|
// Second row.
|
|
|
|
// Second row.
|
|
|
|
row.Push(ops)
|
|
|
|
row = op.Push(ops)
|
|
|
|
drawDisc(ops, discDia, rgb(0xfffdfa))
|
|
|
|
drawDisc(ops, discDia, rgb(0xfffdfa))
|
|
|
|
tx.Add(ops)
|
|
|
|
tx.Add(ops)
|
|
|
|
drawDisc(ops, discDia, rgb(0xfffdfa))
|
|
|
|
drawDisc(ops, discDia, rgb(0xfffdfa))
|
|
|
@ -715,7 +710,7 @@ func drawLogo(ops *op.Ops, size int) {
|
|
|
|
|
|
|
|
|
|
|
|
ty.Add(ops)
|
|
|
|
ty.Add(ops)
|
|
|
|
// Third row.
|
|
|
|
// Third row.
|
|
|
|
row.Push(ops)
|
|
|
|
row = op.Push(ops)
|
|
|
|
drawDisc(ops, discDia, rgb(0x54514d))
|
|
|
|
drawDisc(ops, discDia, rgb(0x54514d))
|
|
|
|
tx.Add(ops)
|
|
|
|
tx.Add(ops)
|
|
|
|
drawDisc(ops, discDia, rgb(0xfffdfa))
|
|
|
|
drawDisc(ops, discDia, rgb(0xfffdfa))
|
|
|
@ -725,9 +720,7 @@ func drawLogo(ops *op.Ops, size int) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func drawDisc(ops *op.Ops, radius float32, col color.RGBA) {
|
|
|
|
func drawDisc(ops *op.Ops, radius float32, col color.RGBA) {
|
|
|
|
var st op.StackOp
|
|
|
|
defer op.Push(ops).Pop()
|
|
|
|
st.Push(ops)
|
|
|
|
|
|
|
|
defer st.Pop()
|
|
|
|
|
|
|
|
r2 := radius * .5
|
|
|
|
r2 := radius * .5
|
|
|
|
dr := f32.Rectangle{Max: f32.Pt(radius, radius)}
|
|
|
|
dr := f32.Rectangle{Max: f32.Pt(radius, radius)}
|
|
|
|
clip.Rect{
|
|
|
|
clip.Rect{
|
|
|
@ -746,11 +739,10 @@ type Background struct {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (b Background) Layout(gtx layout.Context, w layout.Widget) layout.Dimensions {
|
|
|
|
func (b Background) Layout(gtx layout.Context, w layout.Widget) layout.Dimensions {
|
|
|
|
var m op.MacroOp
|
|
|
|
m := op.Record(gtx.Ops)
|
|
|
|
m.Record(gtx.Ops)
|
|
|
|
|
|
|
|
dims := w(gtx)
|
|
|
|
dims := w(gtx)
|
|
|
|
sz := dims.Size
|
|
|
|
sz := dims.Size
|
|
|
|
m.Stop()
|
|
|
|
call := m.Stop()
|
|
|
|
// Clip corners, if any.
|
|
|
|
// Clip corners, if any.
|
|
|
|
if r := gtx.Px(b.CornerRadius); r > 0 {
|
|
|
|
if r := gtx.Px(b.CornerRadius); r > 0 {
|
|
|
|
rr := float32(r)
|
|
|
|
rr := float32(r)
|
|
|
@ -763,7 +755,7 @@ func (b Background) Layout(gtx layout.Context, w layout.Widget) layout.Dimension
|
|
|
|
}.Op(gtx.Ops).Add(gtx.Ops)
|
|
|
|
}.Op(gtx.Ops).Add(gtx.Ops)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fill{b.Color}.Layout(gtx, sz)
|
|
|
|
fill{b.Color}.Layout(gtx, sz)
|
|
|
|
m.Add()
|
|
|
|
call.Add(gtx.Ops)
|
|
|
|
return dims
|
|
|
|
return dims
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -772,9 +764,7 @@ type fill struct {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (f fill) Layout(gtx layout.Context, sz image.Point) layout.Dimensions {
|
|
|
|
func (f fill) Layout(gtx layout.Context, sz image.Point) layout.Dimensions {
|
|
|
|
var st op.StackOp
|
|
|
|
defer op.Push(gtx.Ops).Pop()
|
|
|
|
st.Push(gtx.Ops)
|
|
|
|
|
|
|
|
defer st.Pop()
|
|
|
|
|
|
|
|
dr := f32.Rectangle{Max: layout.FPt(sz)}
|
|
|
|
dr := f32.Rectangle{Max: layout.FPt(sz)}
|
|
|
|
paint.ColorOp{Color: f.col}.Add(gtx.Ops)
|
|
|
|
paint.ColorOp{Color: f.col}.Add(gtx.Ops)
|
|
|
|
paint.PaintOp{Rect: dr}.Add(gtx.Ops)
|
|
|
|
paint.PaintOp{Rect: dr}.Add(gtx.Ops)
|
|
|
|