diff options
| author | Pietro Gagliardi <[email protected]> | 2014-07-02 22:53:03 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-07-02 22:53:03 -0400 |
| commit | 8a81650b3da7ce00725336df9e03b38e935c5a65 (patch) | |
| tree | 08af843f0460e7226f305cf7162021ef54e8c3f7 /controlsize.go | |
| parent | 4dd5ceb11d62bd6b9af4847936314a9d8c45707f (diff) | |
Moved it all back; the preemptive multitaksing during an event handler kills us on all platforms. Going to have to restrict ALL GUI accss to happening from one t hread, so going to need to drop uitask entirely and have just a start() callback for startup code and a post() function for posting requests to windows (like channel sends but into a perpetual buffer).
Diffstat (limited to 'controlsize.go')
| -rw-r--r-- | controlsize.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/controlsize.go b/controlsize.go new file mode 100644 index 0000000..98563da --- /dev/null +++ b/controlsize.go @@ -0,0 +1,48 @@ +// 25 june 2014 + +package ui + +type allocation struct { + x int + y int + width int + height int + this Control + neighbor Control +} + +type cSysSizeData struct { + xmargin int + ymargin int + xpadding int + ypadding int +} + +// for verification; see sysdata.go +type sysDataSizingFunctions interface { + beginResize() *sysSizeData + endResize(*sysSizeData) + translateAllocationCoords([]*allocation, int, int) + preferredSize(*sysSizeData) (int, int) + commitResize(*allocation, *sysSizeData) + getAuxResizeInfo(*sysSizeData) +} + +func (s *sysData) resizeWindow(width, height int) { + d := s.beginResize() + allocations := s.allocate(0, 0, width, height, d) + s.translateAllocationCoords(allocations, width, height) + // move in reverse so as to approximate right->left order so neighbors make sense + for i := len(allocations) - 1; i >= 0; i-- { + allocations[i].this.commitResize(allocations[i], d) + } + s.endResize(d) +} + +// non-layout controls: allocate() should just return a one-element slice; preferredSize(), commitResize(), and getAuxResizeInfo() should defer to their sysData equivalents +type controlSizing interface { + allocate(x int, y int, width int, height int, d *sysSizeData) []*allocation + preferredSize(d *sysSizeData) (width, height int) + commitResize(c *allocation, d *sysSizeData) + getAuxResizeInfo(d *sysSizeData) +} |
