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

Method configScroll

core/scroll.go:61–97  ·  view source on GitHub ↗

configScroll configures scroll for given dimension

(d math32.Dims)

Source from the content-addressed store, hash-verified

59
60// configScroll configures scroll for given dimension
61func (fr *Frame) configScroll(d math32.Dims) {
62 if fr.scrolls[d] != nil {
63 return
64 }
65 fr.scrolls[d] = NewSlider()
66 sb := fr.scrolls[d]
67 tree.SetParent(sb, fr)
68 // sr.SetFlag(true, tree.Field) // note: do not turn on -- breaks pos
69 sb.SetType(SliderScrollbar)
70 sb.InputThreshold = 1
71 sb.Min = 0.0
72 sb.Styler(func(s *styles.Style) {
73 s.Direction = styles.Directions(d)
74 s.Padding.Zero()
75 s.Margin.Zero()
76 s.MaxBorder.Width.Zero()
77 s.Border.Width.Zero()
78 s.FillMargin = false
79 })
80 sb.FinalStyler(func(s *styles.Style) {
81 od := d.Other()
82 _, sz := fr.This.(Layouter).ScrollGeom(d)
83 if sz.X > 0 && sz.Y > 0 {
84 s.SetState(false, states.Invisible)
85 s.Min.SetDim(d, units.Dot(sz.Dim(d)))
86 s.Min.SetDim(od, units.Dot(sz.Dim(od)))
87 } else {
88 s.SetState(true, states.Invisible)
89 }
90 s.Max = s.Min
91 })
92 sb.OnInput(func(e events.Event) {
93 e.SetHandled()
94 fr.This.(Layouter).ScrollChanged(d, sb)
95 })
96 sb.Update()
97}
98
99// ScrollChanged is called in the OnInput event handler for updating,
100// when the scrollbar value has changed, for given dimension.

Callers 1

ConfigScrollsMethod · 0.95

Calls 15

SetParentFunction · 0.92
DirectionsTypeAlias · 0.92
DotFunction · 0.92
NewSliderFunction · 0.85
StylerMethod · 0.80
FinalStylerMethod · 0.80
ScrollGeomMethod · 0.65
SetHandledMethod · 0.65
ScrollChangedMethod · 0.65
UpdateMethod · 0.65
SetTypeMethod · 0.45
ZeroMethod · 0.45

Tested by

no test coverage detected