MCPcopy
hub / github.com/g3n/engine / initialize

Method initialize

gui/label.go:55–71  ·  view source on GitHub ↗

initialize initializes this label and is normally used by other components which contain a label.

(msg string, font *text.Font)

Source from the content-addressed store, hash-verified

53// initialize initializes this label and is normally used by other
54// components which contain a label.
55func (l *Label) initialize(msg string, font *text.Font) {
56
57 l.font = font
58 l.Panel.Initialize(l, 0, 0)
59 l.Panel.mat.SetTransparent(true)
60
61 // TODO: Remove this hack in an elegant way e.g. set the label style depending of if it's an icon or text label and have two defaults (one for icon labels one for text tabels)
62 if font != StyleDefault().FontIcon {
63 l.Panel.SetPaddings(2, 0, 2, 0)
64 }
65
66 // Copy the style based on the default Label style
67 styleCopy := StyleDefault().Label
68 l.style = &styleCopy
69
70 l.SetText(msg)
71}
72
73// SetText sets and draws the label text using the font.
74func (l *Label) SetText(text string) {

Callers 1

NewLabelWithFontFunction · 0.45

Calls 5

SetTextMethod · 0.95
StyleDefaultFunction · 0.85
SetTransparentMethod · 0.80
SetPaddingsMethod · 0.80
InitializeMethod · 0.45

Tested by

no test coverage detected