mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 08:25:34 +00:00
widget: [API] add content widget argument to Editor.Layout
To make the semantic relation between the editor and its content clear, the editor clip operation must cover the content. This change adds an explicit widget argument to editor, and lays it out inside the clip rect. This is an API change. Users of Editor.Layout must provide a content widget. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+16
-14
@@ -58,20 +58,22 @@ func (e EditorStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
if h := dims.Size.Y; gtx.Constraints.Min.Y < h {
|
||||
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: blendDisabledColor(disabled, e.SelectionColor)}.Add(gtx.Ops)
|
||||
e.Editor.PaintSelection(gtx)
|
||||
paint.ColorOp{Color: blendDisabledColor(disabled, e.Color)}.Add(gtx.Ops)
|
||||
e.Editor.PaintText(gtx)
|
||||
} else {
|
||||
call.Add(gtx.Ops)
|
||||
}
|
||||
if !disabled {
|
||||
paint.ColorOp{Color: e.Color}.Add(gtx.Ops)
|
||||
e.Editor.PaintCaret(gtx)
|
||||
}
|
||||
dims = e.Editor.Layout(gtx, e.shaper, e.Font, e.TextSize, func(gtx layout.Context) layout.Dimensions {
|
||||
disabled := gtx.Queue == nil
|
||||
if e.Editor.Len() > 0 {
|
||||
paint.ColorOp{Color: blendDisabledColor(disabled, e.SelectionColor)}.Add(gtx.Ops)
|
||||
e.Editor.PaintSelection(gtx)
|
||||
paint.ColorOp{Color: blendDisabledColor(disabled, e.Color)}.Add(gtx.Ops)
|
||||
e.Editor.PaintText(gtx)
|
||||
} else {
|
||||
call.Add(gtx.Ops)
|
||||
}
|
||||
if !disabled {
|
||||
paint.ColorOp{Color: e.Color}.Add(gtx.Ops)
|
||||
e.Editor.PaintCaret(gtx)
|
||||
}
|
||||
return dims
|
||||
})
|
||||
return dims
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user