forked from joejulian/gio
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(func(gtx layout.Context) layout.Dimensions {
|
||||
clip.RRect{
|
||||
Rect: f32.Rectangle{Max: f32.Point{
|
||||
X: float32(gtx.Constraints.Min.X),
|
||||
Y: float32(gtx.Constraints.Min.Y),
|
||||
}},
|
||||
Rect: f32.Rectangle{Max: layout.FPt(gtx.Constraints.Min)},
|
||||
}.Add(gtx.Ops)
|
||||
for _, c := range button.History() {
|
||||
drawInk(gtx, c)
|
||||
@@ -286,12 +283,6 @@ func drawInk(gtx layout.Context, c widget.Press) {
|
||||
X: -rr,
|
||||
Y: -rr,
|
||||
})).Add(gtx.Ops)
|
||||
clip.RRect{
|
||||
Rect: f32.Rectangle{Max: f32.Point{
|
||||
X: float32(size),
|
||||
Y: float32(size),
|
||||
}},
|
||||
NE: rr, NW: rr, SE: rr, SW: rr,
|
||||
}.Add(gtx.Ops)
|
||||
clip.UniformRRect(f32.Rectangle{Max: f32.Pt(size, size)}, rr).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)}
|
||||
|
||||
clip.RRect{
|
||||
Rect: f32.Rectangle{Max: f32.Point{X: width, Y: float32(gtx.Px(maxHeight))}},
|
||||
NE: rr, NW: rr, SE: rr, SW: rr,
|
||||
}.Add(gtx.Ops)
|
||||
|
||||
height := float32(gtx.Px(maxHeight))
|
||||
clip.UniformRRect(f32.Rectangle{Max: f32.Pt(width, height)}, rr).Add(gtx.Ops)
|
||||
paint.ColorOp{Color: color}.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
|
||||
op.Offset(f32.Point{Y: trackOff}).Add(gtx.Ops)
|
||||
clip.RRect{
|
||||
Rect: trackRect,
|
||||
NE: trackCorner, NW: trackCorner, SE: trackCorner, SW: trackCorner,
|
||||
}.Add(gtx.Ops)
|
||||
clip.UniformRRect(trackRect, trackCorner).Add(gtx.Ops)
|
||||
paint.ColorOp{Color: trackColor}.Add(gtx.Ops)
|
||||
paint.PaintOp{}.Add(gtx.Ops)
|
||||
stack.Load()
|
||||
@@ -78,12 +75,7 @@ func (s SwitchStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
}
|
||||
op.Offset(inkOff).Add(gtx.Ops)
|
||||
gtx.Constraints.Min = image.Pt(inkSize, inkSize)
|
||||
clip.RRect{
|
||||
Rect: f32.Rectangle{
|
||||
Max: layout.FPt(gtx.Constraints.Min),
|
||||
},
|
||||
NE: rr, NW: rr, SE: rr, SW: rr,
|
||||
}.Add(gtx.Ops)
|
||||
clip.UniformRRect(f32.Rectangle{Max: layout.FPt(gtx.Constraints.Min)}, rr).Add(gtx.Ops)
|
||||
for _, p := range s.Switch.History() {
|
||||
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) {
|
||||
defer op.Save(ops).Load()
|
||||
rr := sz / 2
|
||||
r := f32.Rectangle{Max: f32.Point{X: sz, Y: sz}}
|
||||
clip.RRect{
|
||||
Rect: r,
|
||||
NE: rr, NW: rr, SE: rr, SW: rr,
|
||||
}.Add(ops)
|
||||
clip.UniformRRect(f32.Rectangle{Max: f32.Pt(sz, sz)}, rr).Add(ops)
|
||||
paint.ColorOp{Color: col}.Add(ops)
|
||||
paint.PaintOp{}.Add(ops)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user