configScroll configures scroll for given dimension
(d math32.Dims)
| 59 | |
| 60 | // configScroll configures scroll for given dimension |
| 61 | func (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. |
no test coverage detected