mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 01:15:35 +00:00
op/paint: remove support for PaintOp.Rect
PaintOp.Rect is the wrong abstraction; it implies a clip operation better handled by package clip, and not all paints need it (colors). Furthermore, it's awkward to specify a PaintOp that fills up the current clip area, regardless of its size. Redefine PathOp to mean "fill current clip area". API change. Replace uses of PaintOp.Rect with a TransformOp applied before the PaintOp. Leave a TODO for the PathOp infinity area. Fixes gio#167 Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -73,7 +73,7 @@ func (s SliderStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
}
|
||||
clip.RRect{Rect: track}.Add(gtx.Ops)
|
||||
paint.ColorOp{Color: color}.Add(gtx.Ops)
|
||||
paint.PaintOp{Rect: track}.Add(gtx.Ops)
|
||||
paint.PaintOp{}.Add(gtx.Ops)
|
||||
st.Pop()
|
||||
|
||||
// Draw track after thumb.
|
||||
@@ -82,7 +82,7 @@ func (s SliderStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
track.Max.X = float32(size.X) - halfWidth
|
||||
clip.RRect{Rect: track}.Add(gtx.Ops)
|
||||
paint.ColorOp{Color: f32color.MulAlpha(color, 96)}.Add(gtx.Ops)
|
||||
paint.PaintOp{Rect: track}.Add(gtx.Ops)
|
||||
paint.PaintOp{}.Add(gtx.Ops)
|
||||
st.Pop()
|
||||
|
||||
// Draw thumb.
|
||||
@@ -103,7 +103,7 @@ func (s SliderStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
NE: rr, NW: rr, SE: rr, SW: rr,
|
||||
}.Add(gtx.Ops)
|
||||
paint.ColorOp{Color: color}.Add(gtx.Ops)
|
||||
paint.PaintOp{Rect: thumb}.Add(gtx.Ops)
|
||||
paint.PaintOp{}.Add(gtx.Ops)
|
||||
st.Pop()
|
||||
|
||||
return layout.Dimensions{Size: size}
|
||||
|
||||
Reference in New Issue
Block a user