Migrated the Mac OS X backend to sizer. Once I get this control sizing stuff working there and the height of a Tab tab on Windows, I'm going to chuck this whole embedding thing and sacrifice a non-cluttered directory structure for CODE SIMPLICITY.

This commit is contained in:
Pietro Gagliardi 2014-08-02 07:28:20 -04:00
parent 99b6b47a49
commit 37cf0a20c0
3 changed files with 11 additions and 12 deletions

View File

@ -12,7 +12,7 @@ import "C"
type tab struct { type tab struct {
*controlbase *controlbase
containers []*container tabs []*sizer
} }
func newTab() Tab { func newTab() Tab {
@ -23,14 +23,13 @@ func newTab() Tab {
} }
func (t *tab) Append(name string, control Control) { func (t *tab) Append(name string, control Control) {
// TODO isolate and standardize s := new(sizer)
c := new(container) t.tabs = append(t.tabs, s)
t.containers = append(t.containers, c)
cname := C.CString(name) cname := C.CString(name)
defer C.free(unsafe.Pointer(cname)) defer C.free(unsafe.Pointer(cname))
tabview := C.tabAppend(t.id, cname) tabview := C.tabAppend(t.id, cname)
c.child = control s.child = control
c.child.setParent(&controlParent{tabview}) s.child.setParent(&controlParent{tabview})
} }
// no need to override Control.allocate() as only prepared the tabbed control; its children will be reallocated when that one is resized // no need to override Control.allocate() as only prepared the tabbed control; its children will be reallocated when that one is resized
@ -38,8 +37,8 @@ func (t *tab) Append(name string, control Control) {
//export tabResized //export tabResized
func tabResized(data unsafe.Pointer, width C.intptr_t, height C.intptr_t) { func tabResized(data unsafe.Pointer, width C.intptr_t, height C.intptr_t) {
t := (*tab)(unsafe.Pointer(data)) t := (*tab)(unsafe.Pointer(data))
for _, c := range t.containers { for _, s := range t.tabs {
// the tab area's coordinate system is localized, so the origin is (0, 0) // the tab area's coordinate system is localized, so the origin is (0, 0)
c.resize(0, 0, int(width), int(height)) s.resize(0, 0, int(width), int(height))
} }
} }

View File

@ -24,7 +24,7 @@ const (
macYPadding = 12 macYPadding = 12
) )
func (c *container) beginResize() (d *sizing) { func (s *sizer) beginResize() (d *sizing) {
d = new(sizing) d = new(sizing)
if spaced { if spaced {
d.xmargin = macXMargin d.xmargin = macXMargin
@ -35,7 +35,7 @@ func (c *container) beginResize() (d *sizing) {
return d return d
} }
func (c *container) translateAllocationCoords(allocations []*allocation, winwidth, winheight int) { func (s *sizer) translateAllocationCoords(allocations []*allocation, winwidth, winheight int) {
for _, a := range allocations { 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 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 // (winheight - y) - height because (x, y) is the bottom-left corner of the control and not the top-left

View File

@ -15,7 +15,7 @@ type window struct {
closing *event closing *event
*container *sizer
} }
func newWindow(title string, width int, height int, control Control) *window { func newWindow(title string, width int, height int, control Control) *window {
@ -26,7 +26,7 @@ func newWindow(title string, width int, height int, control Control) *window {
w := &window{ w := &window{
id: id, id: id,
closing: newEvent(), closing: newEvent(),
container: new(container), sizer: new(sizer),
} }
C.windowSetDelegate(id, unsafe.Pointer(w)) C.windowSetDelegate(id, unsafe.Pointer(w))
w.child = control w.child = control