mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
widget/material: add disabled state support to all widgets
This commit configures all remaining widgets to draw themselves in a disabled state when their layout.Context is disabled. A description of the strategy employed by each follows: - Checkbox and RadioButton: Draws the icon component in a lighter color. Currently the label text is left in its default color. - ProgressBar: The "progress" color is lightened, but not as much as the background color. This makes the current progress value still readable. - Editor: The cursor is no longer drawn and the text is lightened. - Switch: The track is unchanged, but the circular "thumb" component is lightened. Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
@@ -52,13 +52,20 @@ func (e EditorStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
gtx.Constraints.Min.Y = h
|
||||
}
|
||||
dims = e.Editor.Layout(gtx, e.shaper, e.Font, e.TextSize)
|
||||
disabled := gtx.Queue == nil
|
||||
if e.Editor.Len() > 0 {
|
||||
paint.ColorOp{Color: e.Color}.Add(gtx.Ops)
|
||||
textColor := e.Color
|
||||
if disabled {
|
||||
textColor = mulAlpha(textColor, 150)
|
||||
}
|
||||
paint.ColorOp{Color: textColor}.Add(gtx.Ops)
|
||||
e.Editor.PaintText(gtx)
|
||||
} else {
|
||||
call.Add(gtx.Ops)
|
||||
}
|
||||
paint.ColorOp{Color: e.Color}.Add(gtx.Ops)
|
||||
e.Editor.PaintCaret(gtx)
|
||||
if !disabled {
|
||||
paint.ColorOp{Color: e.Color}.Add(gtx.Ops)
|
||||
e.Editor.PaintCaret(gtx)
|
||||
}
|
||||
return dims
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user