mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
io/semantic: [API] replace DisabledOp with EnabledOp
The double-negative DisabledOp is harder to understand than a straightforward EnabledOp. Note that the absence of an EnabledOp implies still means that the widget is enabled. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+1
-1
@@ -49,7 +49,7 @@ func (b *Bool) Layout(gtx layout.Context, w layout.Widget) layout.Dimensions {
|
||||
b.changed = true
|
||||
}
|
||||
semantic.SelectedOp(b.Value).Add(gtx.Ops)
|
||||
semantic.DisabledOp(gtx.Queue == nil).Add(gtx.Ops)
|
||||
semantic.EnabledOp(gtx.Queue != nil).Add(gtx.Ops)
|
||||
return w(gtx)
|
||||
})
|
||||
return dims
|
||||
|
||||
+3
-3
@@ -113,10 +113,10 @@ func (b *Clickable) Layout(gtx layout.Context, w layout.Widget) layout.Dimension
|
||||
dims := w(gtx)
|
||||
c := m.Stop()
|
||||
defer clip.Rect(image.Rectangle{Max: dims.Size}).Push(gtx.Ops).Pop()
|
||||
disabled := gtx.Queue == nil
|
||||
semantic.DisabledOp(disabled).Add(gtx.Ops)
|
||||
enabled := gtx.Queue != nil
|
||||
semantic.EnabledOp(enabled).Add(gtx.Ops)
|
||||
b.click.Add(gtx.Ops)
|
||||
if !disabled {
|
||||
if enabled {
|
||||
keys := key.Set("⏎|Space")
|
||||
if !b.focused {
|
||||
keys = ""
|
||||
|
||||
+3
-3
@@ -116,14 +116,14 @@ func (e *Enum) Layout(gtx layout.Context, k string, content layout.Widget) layou
|
||||
}
|
||||
|
||||
clk.Add(gtx.Ops)
|
||||
disabled := gtx.Queue == nil
|
||||
if !disabled {
|
||||
enabled := gtx.Queue != nil
|
||||
if enabled {
|
||||
key.InputOp{Tag: &state.tag, Keys: "⏎|Space"}.Add(gtx.Ops)
|
||||
} else if e.focus == k {
|
||||
e.focused = false
|
||||
}
|
||||
semantic.SelectedOp(k == e.Value).Add(gtx.Ops)
|
||||
semantic.DisabledOp(disabled).Add(gtx.Ops)
|
||||
semantic.EnabledOp(enabled).Add(gtx.Ops)
|
||||
c.Add(gtx.Ops)
|
||||
|
||||
return dims
|
||||
|
||||
Reference in New Issue
Block a user