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

Method positionScroll

core/scroll.go:154–182  ·  view source on GitHub ↗
(d math32.Dims)

Source from the content-addressed store, hash-verified

152}
153
154func (fr *Frame) positionScroll(d math32.Dims) {
155 sb := fr.scrolls[d]
156 pos, ssz := fr.This.(Layouter).ScrollGeom(d)
157 maxSize, _, visPct := fr.This.(Layouter).ScrollValues(d)
158 if sb.Geom.Pos.Total == pos && sb.Geom.Size.Actual.Content == ssz && sb.visiblePercent == visPct {
159 return
160 }
161 if ssz.X <= 0 || ssz.Y <= 0 {
162 sb.SetState(true, states.Invisible)
163 return
164 }
165 sb.SetState(false, states.Invisible)
166 sb.Max = maxSize
167 sb.setVisiblePercent(visPct)
168 // fmt.Println(ly, d, "vis pct:", asz/csz)
169 sb.SetValue(sb.Value) // keep in range
170 fr.This.(Layouter).SetScrollParams(d, sb)
171
172 sb.Update() // applies style
173 sb.SizeUp()
174 sb.Geom.Size.Alloc = fr.Geom.Size.Actual
175 sb.SizeDown(0)
176
177 sb.Geom.Pos.Total = pos
178 sb.setContentPosFromPos()
179 // note: usually these are intersected with parent *content* bbox,
180 // but scrolls are specifically outside of that.
181 sb.setBBoxesFromAllocs()
182}
183
184// RenderScrolls renders the scrollbars.
185func (fr *Frame) RenderScrolls() {

Callers 1

PositionScrollsMethod · 0.95

Calls 11

setVisiblePercentMethod · 0.80
setContentPosFromPosMethod · 0.80
setBBoxesFromAllocsMethod · 0.80
ScrollGeomMethod · 0.65
ScrollValuesMethod · 0.65
SetScrollParamsMethod · 0.65
UpdateMethod · 0.65
SizeUpMethod · 0.65
SizeDownMethod · 0.65
SetStateMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected