summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--redo/control.go13
-rw-r--r--redo/control_darwin.go11
-rw-r--r--redo/control_unix.go11
-rw-r--r--redo/control_windows.go11
4 files changed, 16 insertions, 30 deletions
diff --git a/redo/control.go b/redo/control.go
index 8174ad7..0b88533 100644
--- a/redo/control.go
+++ b/redo/control.go
@@ -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,
+ }}
+ }
+}
diff --git a/redo/control_darwin.go b/redo/control_darwin.go
index f6f9312..8248fd9 100644
--- a/redo/control_darwin.go
+++ b/redo/control_darwin.go
@@ -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
diff --git a/redo/control_unix.go b/redo/control_unix.go
index 92baa1b..d0a4c18 100644
--- a/redo/control_unix.go
+++ b/redo/control_unix.go
@@ -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".
diff --git a/redo/control_windows.go b/redo/control_windows.go
index 36f3d4a..f75c765 100644
--- a/redo/control_windows.go
+++ b/redo/control_windows.go
@@ -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