mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 16:35:36 +00:00
widget/material: better disabled color calculation
Use desaturation in combination with alpha multiplication. Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
@@ -129,7 +129,7 @@ func (b ButtonLayoutStyle) Layout(gtx layout.Context, w layout.Widget) layout.Di
|
||||
}}, rr).Add(gtx.Ops)
|
||||
background := b.Background
|
||||
if gtx.Queue == nil {
|
||||
background = f32color.MulAlpha(b.Background, 150)
|
||||
background = f32color.Disabled(b.Background)
|
||||
}
|
||||
paint.Fill(gtx.Ops, background)
|
||||
for _, c := range b.Button.History() {
|
||||
@@ -156,7 +156,7 @@ func (b IconButtonStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
}, rr).Add(gtx.Ops)
|
||||
background := b.Background
|
||||
if gtx.Queue == nil {
|
||||
background = f32color.MulAlpha(b.Background, 150)
|
||||
background = f32color.Disabled(b.Background)
|
||||
}
|
||||
paint.Fill(gtx.Ops, background)
|
||||
for _, c := range b.Button.History() {
|
||||
|
||||
@@ -43,7 +43,7 @@ func (c *checkable) layout(gtx layout.Context, checked bool) layout.Dimensions {
|
||||
size := gtx.Px(c.Size)
|
||||
icon.Color = c.IconColor
|
||||
if gtx.Queue == nil {
|
||||
icon.Color = f32color.MulAlpha(icon.Color, 150)
|
||||
icon.Color = f32color.Disabled(icon.Color)
|
||||
}
|
||||
icon.Layout(gtx, unit.Px(float32(size)))
|
||||
return layout.Dimensions{
|
||||
|
||||
@@ -61,7 +61,7 @@ func (e EditorStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
if e.Editor.Len() > 0 {
|
||||
textColor := e.Color
|
||||
if disabled {
|
||||
textColor = f32color.MulAlpha(textColor, 150)
|
||||
textColor = f32color.Disabled(textColor)
|
||||
}
|
||||
paint.ColorOp{Color: textColor}.Add(gtx.Ops)
|
||||
e.Editor.PaintText(gtx)
|
||||
|
||||
@@ -55,7 +55,7 @@ func (p ProgressBarStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
fillWidth := progressBarWidth * clamp1(p.Progress)
|
||||
fillColor := p.Color
|
||||
if gtx.Queue == nil {
|
||||
fillColor = f32color.MulAlpha(fillColor, 200)
|
||||
fillColor = f32color.Disabled(fillColor)
|
||||
}
|
||||
return shader(fillWidth, fillColor)
|
||||
}),
|
||||
|
||||
@@ -68,7 +68,7 @@ func (s SliderStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
|
||||
color := s.Color
|
||||
if gtx.Queue == nil {
|
||||
color = f32color.MulAlpha(color, 150)
|
||||
color = f32color.Disabled(color)
|
||||
}
|
||||
|
||||
// Draw track before thumb.
|
||||
|
||||
@@ -55,7 +55,7 @@ func (s SwitchStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
col = s.Color.Enabled
|
||||
}
|
||||
if gtx.Queue == nil {
|
||||
col = f32color.MulAlpha(col, 150)
|
||||
col = f32color.Disabled(col)
|
||||
}
|
||||
trackColor := s.Color.Track
|
||||
op.Offset(f32.Point{Y: trackOff}).Add(gtx.Ops)
|
||||
|
||||
Reference in New Issue
Block a user