diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-04 17:46:08 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-04 17:47:39 -0400 |
| commit | 88c01bf69532243f432e03121b922a94d19b0ae1 (patch) | |
| tree | 0685f9e001aff4f6cebe0b06b26ac2212346445e /redo/container_darwin.go | |
| parent | 74e2214f4391d105f439b0190ac7fa640b9053f1 (diff) | |
Began the big sizer cleanup: renamed sizer to container, renamed sizer.go to container.go, did the Mac OS X migration, moved containerctrls.go out of the way by merging its declarations into basicctrls.go, and did a quick cleanup fix to container_darwin.m.
Diffstat (limited to 'redo/container_darwin.go')
| -rw-r--r-- | redo/container_darwin.go | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/redo/container_darwin.go b/redo/container_darwin.go index 1f8a477..96aca31 100644 --- a/redo/container_darwin.go +++ b/redo/container_darwin.go @@ -10,15 +10,23 @@ import ( import "C" type container struct { + containerbase // TODO rename to id - view C.id - *sizer + view C.id +} + +type sizing struct { + sizingbase + + // for size calculations + // nothing for mac + + // for the actual resizing + neighborAlign C.struct_xalignment } func newContainer(child Control) *container { - c := &container{ - sizer: new(sizer), - } + c := new(container) c.view = C.newContainerView(unsafe.Pointer(c)) c.child = child c.child.setParent(&controlParent{c.view}) @@ -31,3 +39,31 @@ func containerResized(data unsafe.Pointer, width C.intptr_t, height C.intptr_t) // the origin of a view's content area is always (0, 0) c.resize(0, 0, int(width), int(height)) } + +// THIS IS A GUESS. TODO. +// The only indication that this is remotely correct is the Auto Layout Guide implying that 12 pixels is the "Aqua space". +const ( + macXMargin = 12 + macYMargin = 12 + macXPadding = 12 + macYPadding = 12 +) + +func (c *container) beginResize() (d *sizing) { + d = new(sizing) + if spaced { + d.xmargin = macXMargin + d.ymargin = macYMargin + d.xpadding = macXPadding + d.ypadding = macYPadding + } + return d +} + +func (c *container) translateAllocationCoords(allocations []*allocation, winwidth, winheight int) { + for _, a := range allocations { + // winheight - y because (0,0) is the bottom-left corner of the window and not the top-left corner + // (winheight - y) - height because (x, y) is the bottom-left corner of the control and not the top-left + a.y = (winheight - a.y) - a.height + } +} |
