mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 01:15:35 +00:00
widget/material: use clip.UniformRRect
Signed-off-by: pierre <pierre.curto@gmail.com>
This commit is contained in:
@@ -91,10 +91,7 @@ func Clickable(gtx layout.Context, button *widget.Clickable, w layout.Widget) la
|
|||||||
layout.Expanded(button.Layout),
|
layout.Expanded(button.Layout),
|
||||||
layout.Expanded(func(gtx layout.Context) layout.Dimensions {
|
layout.Expanded(func(gtx layout.Context) layout.Dimensions {
|
||||||
clip.RRect{
|
clip.RRect{
|
||||||
Rect: f32.Rectangle{Max: f32.Point{
|
Rect: f32.Rectangle{Max: layout.FPt(gtx.Constraints.Min)},
|
||||||
X: float32(gtx.Constraints.Min.X),
|
|
||||||
Y: float32(gtx.Constraints.Min.Y),
|
|
||||||
}},
|
|
||||||
}.Add(gtx.Ops)
|
}.Add(gtx.Ops)
|
||||||
for _, c := range button.History() {
|
for _, c := range button.History() {
|
||||||
drawInk(gtx, c)
|
drawInk(gtx, c)
|
||||||
@@ -286,12 +283,6 @@ func drawInk(gtx layout.Context, c widget.Press) {
|
|||||||
X: -rr,
|
X: -rr,
|
||||||
Y: -rr,
|
Y: -rr,
|
||||||
})).Add(gtx.Ops)
|
})).Add(gtx.Ops)
|
||||||
clip.RRect{
|
clip.UniformRRect(f32.Rectangle{Max: f32.Pt(size, size)}, rr).Add(gtx.Ops)
|
||||||
Rect: f32.Rectangle{Max: f32.Point{
|
|
||||||
X: float32(size),
|
|
||||||
Y: float32(size),
|
|
||||||
}},
|
|
||||||
NE: rr, NW: rr, SE: rr, SW: rr,
|
|
||||||
}.Add(gtx.Ops)
|
|
||||||
paint.PaintOp{}.Add(gtx.Ops)
|
paint.PaintOp{}.Add(gtx.Ops)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,11 +35,8 @@ func (p ProgressBarStyle) Layout(gtx layout.Context) layout.Dimensions {
|
|||||||
|
|
||||||
d := image.Point{X: int(width), Y: gtx.Px(maxHeight)}
|
d := image.Point{X: int(width), Y: gtx.Px(maxHeight)}
|
||||||
|
|
||||||
clip.RRect{
|
height := float32(gtx.Px(maxHeight))
|
||||||
Rect: f32.Rectangle{Max: f32.Point{X: width, Y: float32(gtx.Px(maxHeight))}},
|
clip.UniformRRect(f32.Rectangle{Max: f32.Pt(width, height)}, rr).Add(gtx.Ops)
|
||||||
NE: rr, NW: rr, SE: rr, SW: rr,
|
|
||||||
}.Add(gtx.Ops)
|
|
||||||
|
|
||||||
paint.ColorOp{Color: color}.Add(gtx.Ops)
|
paint.ColorOp{Color: color}.Add(gtx.Ops)
|
||||||
paint.PaintOp{}.Add(gtx.Ops)
|
paint.PaintOp{}.Add(gtx.Ops)
|
||||||
|
|
||||||
|
|||||||
@@ -60,10 +60,7 @@ func (s SwitchStyle) Layout(gtx layout.Context) layout.Dimensions {
|
|||||||
}
|
}
|
||||||
trackColor := s.Color.Track
|
trackColor := s.Color.Track
|
||||||
op.Offset(f32.Point{Y: trackOff}).Add(gtx.Ops)
|
op.Offset(f32.Point{Y: trackOff}).Add(gtx.Ops)
|
||||||
clip.RRect{
|
clip.UniformRRect(trackRect, trackCorner).Add(gtx.Ops)
|
||||||
Rect: trackRect,
|
|
||||||
NE: trackCorner, NW: trackCorner, SE: trackCorner, SW: trackCorner,
|
|
||||||
}.Add(gtx.Ops)
|
|
||||||
paint.ColorOp{Color: trackColor}.Add(gtx.Ops)
|
paint.ColorOp{Color: trackColor}.Add(gtx.Ops)
|
||||||
paint.PaintOp{}.Add(gtx.Ops)
|
paint.PaintOp{}.Add(gtx.Ops)
|
||||||
stack.Load()
|
stack.Load()
|
||||||
@@ -78,12 +75,7 @@ func (s SwitchStyle) Layout(gtx layout.Context) layout.Dimensions {
|
|||||||
}
|
}
|
||||||
op.Offset(inkOff).Add(gtx.Ops)
|
op.Offset(inkOff).Add(gtx.Ops)
|
||||||
gtx.Constraints.Min = image.Pt(inkSize, inkSize)
|
gtx.Constraints.Min = image.Pt(inkSize, inkSize)
|
||||||
clip.RRect{
|
clip.UniformRRect(f32.Rectangle{Max: layout.FPt(gtx.Constraints.Min)}, rr).Add(gtx.Ops)
|
||||||
Rect: f32.Rectangle{
|
|
||||||
Max: layout.FPt(gtx.Constraints.Min),
|
|
||||||
},
|
|
||||||
NE: rr, NW: rr, SE: rr, SW: rr,
|
|
||||||
}.Add(gtx.Ops)
|
|
||||||
for _, p := range s.Switch.History() {
|
for _, p := range s.Switch.History() {
|
||||||
drawInk(gtx, p)
|
drawInk(gtx, p)
|
||||||
}
|
}
|
||||||
@@ -142,11 +134,7 @@ func (s SwitchStyle) Layout(gtx layout.Context) layout.Dimensions {
|
|||||||
func drawDisc(ops *op.Ops, sz float32, col color.NRGBA) {
|
func drawDisc(ops *op.Ops, sz float32, col color.NRGBA) {
|
||||||
defer op.Save(ops).Load()
|
defer op.Save(ops).Load()
|
||||||
rr := sz / 2
|
rr := sz / 2
|
||||||
r := f32.Rectangle{Max: f32.Point{X: sz, Y: sz}}
|
clip.UniformRRect(f32.Rectangle{Max: f32.Pt(sz, sz)}, rr).Add(ops)
|
||||||
clip.RRect{
|
|
||||||
Rect: r,
|
|
||||||
NE: rr, NW: rr, SE: rr, SW: rr,
|
|
||||||
}.Add(ops)
|
|
||||||
paint.ColorOp{Color: col}.Add(ops)
|
paint.ColorOp{Color: col}.Add(ops)
|
||||||
paint.PaintOp{}.Add(ops)
|
paint.PaintOp{}.Add(ops)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user