mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 17:05:38 +00:00
op/clip: split Rect into pixel-aligned Rect and rounded RRect
The pixel-aligned Rect is more efficient and easier to use in the common case of layout clipping. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -56,7 +56,7 @@ func (s SwitchStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
}
|
||||
trackColor := mulAlpha(col, 150)
|
||||
op.Offset(f32.Point{Y: trackOff}).Add(gtx.Ops)
|
||||
clip.Rect{
|
||||
clip.RRect{
|
||||
Rect: trackRect,
|
||||
NE: trackCorner, NW: trackCorner, SE: trackCorner, SW: trackCorner,
|
||||
}.Add(gtx.Ops)
|
||||
@@ -74,7 +74,7 @@ func (s SwitchStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
}
|
||||
op.Offset(inkOff).Add(gtx.Ops)
|
||||
gtx.Constraints.Min = image.Pt(inkSize, inkSize)
|
||||
clip.Rect{
|
||||
clip.RRect{
|
||||
Rect: f32.Rectangle{
|
||||
Max: layout.FPt(gtx.Constraints.Min),
|
||||
},
|
||||
@@ -127,7 +127,7 @@ func drawDisc(ops *op.Ops, sz float32, col color.RGBA) {
|
||||
defer op.Push(ops).Pop()
|
||||
rr := sz / 2
|
||||
r := f32.Rectangle{Max: f32.Point{X: sz, Y: sz}}
|
||||
clip.Rect{
|
||||
clip.RRect{
|
||||
Rect: r,
|
||||
NE: rr, NW: rr, SE: rr, SW: rr,
|
||||
}.Add(ops)
|
||||
|
||||
Reference in New Issue
Block a user