newSpliter creates and returns a pointer of a new splitter with the specified orientation and initial dimensions.
(horiz bool, width, height float32)
| 54 | // newSpliter creates and returns a pointer of a new splitter with |
| 55 | // the specified orientation and initial dimensions. |
| 56 | func newSplitter(horiz bool, width, height float32) *Splitter { |
| 57 | |
| 58 | s := new(Splitter) |
| 59 | s.horiz = horiz |
| 60 | s.styles = &StyleDefault().Splitter |
| 61 | s.Panel.Initialize(s, width, height) |
| 62 | |
| 63 | // Initialize left/top panel |
| 64 | s.P0.Initialize(&s.P0, 0, 0) |
| 65 | s.Panel.Add(&s.P0) |
| 66 | |
| 67 | // Initialize right/bottom panel |
| 68 | s.P1.Initialize(&s.P1, 0, 0) |
| 69 | s.Panel.Add(&s.P1) |
| 70 | |
| 71 | // Initialize spacer panel |
| 72 | s.spacer.Initialize(&s.spacer, 0, 0) |
| 73 | s.Panel.Add(&s.spacer) |
| 74 | |
| 75 | if horiz { |
| 76 | s.spacer.SetBorders(0, 1, 0, 1) |
| 77 | s.pos = 0.5 |
| 78 | } else { |
| 79 | s.spacer.SetBorders(1, 0, 1, 0) |
| 80 | s.pos = 0.5 |
| 81 | } |
| 82 | |
| 83 | s.Subscribe(OnResize, s.onResize) |
| 84 | s.spacer.Subscribe(OnMouseDown, s.onMouse) |
| 85 | s.spacer.Subscribe(OnMouseUp, s.onMouse) |
| 86 | s.spacer.Subscribe(OnCursor, s.onCursor) |
| 87 | s.spacer.Subscribe(OnCursorEnter, s.onCursor) |
| 88 | s.spacer.Subscribe(OnCursorLeave, s.onCursor) |
| 89 | s.update() |
| 90 | s.recalc() |
| 91 | return s |
| 92 | } |
| 93 | |
| 94 | // SetSplit sets the position of the splitter bar. |
| 95 | // It accepts a value from 0.0 to 1.0 |
no test coverage detected