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:
parent
99b6b47a49
commit
37cf0a20c0
|
@ -12,7 +12,7 @@ import "C"
|
|||
type tab struct {
|
||||
*controlbase
|
||||
|
||||
containers []*container
|
||||
tabs []*sizer
|
||||
}
|
||||
|
||||
func newTab() Tab {
|
||||
|
@ -23,14 +23,13 @@ func newTab() Tab {
|
|||
}
|
||||
|
||||
func (t *tab) Append(name string, control Control) {
|
||||
// TODO isolate and standardize
|
||||
c := new(container)
|
||||
t.containers = append(t.containers, c)
|
||||
s := new(sizer)
|
||||
t.tabs = append(t.tabs, s)
|
||||
cname := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
tabview := C.tabAppend(t.id, cname)
|
||||
c.child = control
|
||||
c.child.setParent(&controlParent{tabview})
|
||||
s.child = control
|
||||
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
|
||||
|
@ -38,8 +37,8 @@ func (t *tab) Append(name string, control Control) {
|
|||
//export tabResized
|
||||
func tabResized(data unsafe.Pointer, width C.intptr_t, height C.intptr_t) {
|
||||
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)
|
||||
c.resize(0, 0, int(width), int(height))
|
||||
s.resize(0, 0, int(width), int(height))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ const (
|
|||
macYPadding = 12
|
||||
)
|
||||
|
||||
func (c *container) beginResize() (d *sizing) {
|
||||
func (s *sizer) beginResize() (d *sizing) {
|
||||
d = new(sizing)
|
||||
if spaced {
|
||||
d.xmargin = macXMargin
|
||||
|
@ -35,7 +35,7 @@ func (c *container) beginResize() (d *sizing) {
|
|||
return d
|
||||
}
|
||||
|
||||
func (c *container) translateAllocationCoords(allocations []*allocation, winwidth, winheight int) {
|
||||
func (s *sizer) 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
|
|
@ -15,7 +15,7 @@ type window struct {
|
|||
|
||||
closing *event
|
||||
|
||||
*container
|
||||
*sizer
|
||||
}
|
||||
|
||||
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{
|
||||
id: id,
|
||||
closing: newEvent(),
|
||||
container: new(container),
|
||||
sizer: new(sizer),
|
||||
}
|
||||
C.windowSetDelegate(id, unsafe.Pointer(w))
|
||||
w.child = control
|
||||
|
|
Loading…
Reference in New Issue