Split out the default definitions of Control.allocate() into a single place.

This commit is contained in:
Pietro Gagliardi 2014-07-30 20:38:01 -04:00
parent 713be62f16
commit c5917de29c
4 changed files with 16 additions and 30 deletions

View File

@ -54,3 +54,16 @@ func (w *controldefs) commitResize(c *allocation, d *sizing) {
func (w *controldefs) getAuxResizeInfo(d *sizing) {
w.fgetAuxResizeInfo(d)
}
// and this is the same across all platforms
func baseallocate(c *controlbase) func(x int, y int, width int, height int, d *sizing) []*allocation {
return func(x int, y int, width int, height int, d *sizing) []*allocation {
return []*allocation{&allocation{
x: x,
y: y,
width: width,
height: height,
this: c,
}}
}
}

View File

@ -28,16 +28,7 @@ func newControl(id C.id) *controlbase {
c.fcontainerHide = func() {
C.controlSetHidden(c.id, C.YES)
}
c.fallocate = func(x int, y int, width int, height int, d *sizing) []*allocation {
// TODO split into its own function
return []*allocation{&allocation{
x: x,
y: y,
width: width,
height: height,
this: c,
}}
}
c.fallocate = baseallocate(c)
c.fpreferredSize = func(d *sizing) (int, int) {
// TODO
return 64, 32

View File

@ -35,16 +35,7 @@ func newControl(widget *C.GtkWidget) *controlbase {
c.fcontainerHide = func() {
C.gtk_widget_hide(c.widget)
}
c.fallocate = func(x int, y int, width int, height int, d *sizing) []*allocation {
// TODO split into its own function
return []*allocation{&allocation{
x: x,
y: y,
width: width,
height: height,
this: c,
}}
}
c.fallocate = baseallocate(c)
c.fpreferredSize = func(d *sizing) (int, int) {
// GTK+ 3 makes this easy: controls can tell us what their preferred size is!
// ...actually, it tells us two things: the "minimum size" and the "natural size".

View File

@ -29,16 +29,7 @@ func newControl(class C.LPCWSTR, style C.DWORD, extstyle C.DWORD) *controlbase {
c.fcontainerHide = func() {
C.ShowWindow(c.hwnd, C.SW_HIDE)
}
c.fallocate = func(x int, y int, width int, height int, d *sizing) []*allocation {
// TODO split into its own function
return []*allocation{&allocation{
x: x,
y: y,
width: width,
height: height,
this: c,
}}
}
c.fallocate = baseallocate(c)
c.fpreferredSize = func(d *sizing) (int, int) {
// TODO
return 75, 23