mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
widget/material: add ink effect and semantic information to decorations
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"image/color"
|
"image/color"
|
||||||
|
|
||||||
"gioui.org/f32"
|
"gioui.org/f32"
|
||||||
|
"gioui.org/io/semantic"
|
||||||
"gioui.org/io/system"
|
"gioui.org/io/system"
|
||||||
"gioui.org/layout"
|
"gioui.org/layout"
|
||||||
"gioui.org/op"
|
"gioui.org/op"
|
||||||
@@ -39,7 +40,6 @@ func Decorations(th *Theme, deco *widget.Decorations, actions system.Action, tit
|
|||||||
// Layout a window with its title and action buttons.
|
// Layout a window with its title and action buttons.
|
||||||
func (d *DecorationsStyle) Layout(gtx layout.Context) layout.Dimensions {
|
func (d *DecorationsStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||||
rec := op.Record(gtx.Ops)
|
rec := op.Record(gtx.Ops)
|
||||||
paint.ColorOp{Color: d.Foreground}.Add(gtx.Ops)
|
|
||||||
dims := d.layoutDecorations(gtx)
|
dims := d.layoutDecorations(gtx)
|
||||||
decos := rec.Stop()
|
decos := rec.Stop()
|
||||||
r := clip.Rect{Max: dims.Size}
|
r := clip.Rect{Max: dims.Size}
|
||||||
@@ -89,8 +89,22 @@ func (d *DecorationsStyle) layoutDecorations(gtx layout.Context) layout.Dimensio
|
|||||||
default:
|
default:
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
dims := d.Decorations.Clickable(a).Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
cl := d.Decorations.Clickable(a)
|
||||||
return inset.Layout(gtx, w)
|
dims := cl.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||||
|
semantic.Button.Add(gtx.Ops)
|
||||||
|
return layout.Stack{Alignment: layout.Center}.Layout(gtx,
|
||||||
|
layout.Expanded(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
defer clip.Rect{Max: gtx.Constraints.Min}.Push(gtx.Ops).Pop()
|
||||||
|
for _, c := range cl.History() {
|
||||||
|
drawInk(gtx, c)
|
||||||
|
}
|
||||||
|
return layout.Dimensions{Size: gtx.Constraints.Min}
|
||||||
|
}),
|
||||||
|
layout.Stacked(func(gtx layout.Context) layout.Dimensions {
|
||||||
|
paint.ColorOp{Color: d.Foreground}.Add(gtx.Ops)
|
||||||
|
return inset.Layout(gtx, w)
|
||||||
|
}),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
size.X += dims.Size.X
|
size.X += dims.Size.X
|
||||||
if size.Y < dims.Size.Y {
|
if size.Y < dims.Size.Y {
|
||||||
|
|||||||
Reference in New Issue
Block a user