From 5d339e656b66d00356960ae057969532d34245b4 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 2 Jul 2014 17:13:40 -0400 Subject: Moved everything out of the way pending rewrite. --- prevlib/controlsize.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 prevlib/controlsize.go (limited to 'prevlib/controlsize.go') diff --git a/prevlib/controlsize.go b/prevlib/controlsize.go new file mode 100644 index 0000000..98563da --- /dev/null +++ b/prevlib/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) +} -- cgit v1.2.3