MCPcopy Create free account
hub / github.com/cogentcore/core / Init

Method Init

core/splits.go:115–212  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113}
114
115func (sl *Splits) Init() {
116 sl.Frame.Init()
117 sl.Styler(func(s *styles.Style) {
118 s.Grow.Set(1, 1)
119 s.Margin.Zero()
120 s.Padding.Zero()
121 s.Min.Y.Em(10)
122
123 if sl.SizeClass() == SizeCompact {
124 s.Direction = styles.Column
125 } else {
126 s.Direction = styles.Row
127 }
128 })
129 sl.FinalStyler(func(s *styles.Style) {
130 sl.styleSplits()
131 })
132 sl.SetOnChildAdded(func(n tree.Node) {
133 if n != sl.Parts {
134 AsWidget(n).Styler(func(s *styles.Style) {
135 // splits elements must scroll independently and grow
136 s.Overflow.Set(styles.OverflowAuto)
137 s.Grow.Set(1, 1)
138 })
139 }
140 })
141
142 sl.OnKeyChord(func(e events.Event) {
143 kc := string(e.KeyChord())
144 mod := "Control+"
145 if TheApp.Platform() == system.MacOS {
146 mod = "Meta+"
147 }
148 if !strings.HasPrefix(kc, mod) {
149 return
150 }
151 kns := kc[len(mod):]
152
153 knc, err := strconv.Atoi(kns)
154 if err != nil {
155 return
156 }
157 kn := int(knc)
158 if kn == 0 {
159 e.SetHandled()
160 sl.evenSplits(sl.TileSplits)
161 sl.NeedsLayout()
162
163 } else if kn <= len(sl.Children) {
164 e.SetHandled()
165 if sl.TileSplits[kn-1] <= 0.01 {
166 sl.restoreChild(kn - 1)
167 } else {
168 sl.collapseSplit(true, kn-1)
169 }
170 }
171 })
172

Callers

nothing calls this directly

Calls 15

styleSplitsMethod · 0.95
evenSplitsMethod · 0.95
restoreChildMethod · 0.95
collapseSplitMethod · 0.95
updateSplitsMethod · 0.95
setHandlePosMethod · 0.95
AddAtFunction · 0.92
AsWidgetFunction · 0.85
StylerMethod · 0.80
SizeClassMethod · 0.80
FinalStylerMethod · 0.80
SetOnChildAddedMethod · 0.80

Tested by

no test coverage detected