MCPcopy Create free account
hub / github.com/gioui/gio / Layout

Method Layout

widget/selectable.go:184–204  ·  view source on GitHub ↗

Layout clips to the dimensions of the selectable, updates the shaped text, configures input handling, and paints the text and selection rectangles. The provided textMaterial and selectionMaterial ops are used to set the paint material for the text and selection rectangles, respectively.

(gtx layout.Context, lt *text.Shaper, font font.Font, size unit.Sp, textMaterial, selectionMaterial op.CallOp)

Source from the content-addressed store, hash-verified

182// the text and selection rectangles. The provided textMaterial and selectionMaterial ops are used to set the
183// paint material for the text and selection rectangles, respectively.
184func (l *Selectable) Layout(gtx layout.Context, lt *text.Shaper, font font.Font, size unit.Sp, textMaterial, selectionMaterial op.CallOp) layout.Dimensions {
185 l.Update(gtx)
186 l.text.LineHeight = l.LineHeight
187 l.text.LineHeightScale = l.LineHeightScale
188 l.text.Alignment = l.Alignment
189 l.text.MaxLines = l.MaxLines
190 l.text.Truncator = l.Truncator
191 l.text.WrapPolicy = l.WrapPolicy
192 l.text.Layout(gtx, lt, font, size)
193 dims := l.text.Dimensions()
194 defer clip.Rect(image.Rectangle{Max: dims.Size}).Push(gtx.Ops).Pop()
195 pointer.CursorText.Add(gtx.Ops)
196 event.Op(gtx.Ops, l)
197
198 l.clicker.Add(gtx.Ops)
199 l.dragger.Add(gtx.Ops)
200
201 l.paintSelection(gtx, selectionMaterial)
202 l.paintText(gtx, textMaterial)
203 return dims
204}
205
206func (l *Selectable) handleEvents(gtx layout.Context) (selectionChanged bool) {
207 oldStart, oldLen := min(l.text.Selection()), l.text.SelectionLen()

Callers

nothing calls this directly

Calls 9

UpdateMethod · 0.95
paintSelectionMethod · 0.95
paintTextMethod · 0.95
RectTypeAlias · 0.92
OpFunction · 0.92
DimensionsMethod · 0.80
PopMethod · 0.45
PushMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected