diff options
| author | Pietro Gagliardi <[email protected]> | 2014-10-18 14:17:35 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-10-18 14:17:35 -0400 |
| commit | fd9e614faaae390a42f7dc39e63d0197ea9d7efa (patch) | |
| tree | 67daa05343c858cd697584b87061b63e7805e302 /newctrl/container_darwin.go | |
| parent | b1ac28cc938d2de25357328d9da910a84a2cc8cc (diff) | |
Started the Mac OS X conversion.
Diffstat (limited to 'newctrl/container_darwin.go')
| -rw-r--r-- | newctrl/container_darwin.go | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/newctrl/container_darwin.go b/newctrl/container_darwin.go new file mode 100644 index 0000000..3e8c437 --- /dev/null +++ b/newctrl/container_darwin.go @@ -0,0 +1,76 @@ +// 4 august 2014 + +package ui + +import ( + "unsafe" +) + +// #include "objc_darwin.h" +import "C" + +type container struct { + *controlSingleObject +} + +type sizing struct { + sizingbase + + // for size calculations + // nothing for mac + + // for the actual resizing + neighborAlign C.struct_xalignment +} + +func newContainer() *container { + c := new(container) + c.controlSingleObject = newControlSingleObject(C.newContainerView(unsafe.Pointer(c))) + return c +} + +func (c *container) parent() *controlParent { + return &controlParent{c.id} +} + +func (c *container) allocation(margined bool) C.struct_xrect { + b := C.containerBounds(c.id) + if margined { + b.x += C.intptr_t(macXMargin) + b.y += C.intptr_t(macYMargin) + b.width -= C.intptr_t(macXMargin) * 2 + b.height -= C.intptr_t(macYMargin) * 2 + } + return b +} + +// we can just return these values as is +func (c *container) bounds(d *sizing) (int, int, int, int) { + b := C.containerBounds(c.id) + return int(b.x), int(b.y), int(b.width), int(b.height) +} + +// These are based on measurements from Interface Builder. +const ( + macXMargin = 20 + macYMargin = 20 + macXPadding = 8 + macYPadding = 8 +) + +func (w *window) beginResize() (d *sizing) { + d = new(sizing) + d.xpadding = macXPadding + d.ypadding = macYPadding + return d +} + +/*TODO +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 + } +} +*/ |
