summaryrefslogtreecommitdiff
path: root/prev/control.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-12-11 20:37:59 -0500
committerPietro Gagliardi <[email protected]>2015-12-11 20:37:59 -0500
commitf8e3f12ab02b528f2a05a4f713d7af7ea8e44b42 (patch)
tree82dedf4d37f0f6d31e88ebb2ca1ce6499dead261 /prev/control.go
parente34c561ed5bedeb180437ec165882b98d70d38c1 (diff)
LET'S GET THIS FINAL REWRITE EVER STARTED
Diffstat (limited to 'prev/control.go')
-rw-r--r--prev/control.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/prev/control.go b/prev/control.go
new file mode 100644
index 0000000..52202b7
--- /dev/null
+++ b/prev/control.go
@@ -0,0 +1,51 @@
+// 30 july 2014
+
+package ui
+
+// Control represents a control.
+type Control interface {
+ setParent(p *controlParent) // controlParent defined per-platform
+ preferredSize(d *sizing) (width, height int)
+ resize(x int, y int, width int, height int, d *sizing)
+ nTabStops() int // used by the Windows backend
+
+ // these are provided for Tab on Windows, where we have to show and hide the individual tab pages manually
+ // if we ever get something like a SidebarStack of some sort, we'll need to implement this everywhere
+ containerShow() // show if and only if programmer said to show
+ containerHide() // hide regardless of whether programmer said to hide
+}
+
+type controlbase struct {
+ fsetParent func(p *controlParent)
+ fpreferredSize func(d *sizing) (width, height int)
+ fresize func(x int, y int, width int, height int, d *sizing)
+ fnTabStops func() int
+ fcontainerShow func()
+ fcontainerHide func()
+}
+
+// children should not use the same name as these, otherwise weird things will happen
+
+func (c *controlbase) setParent(p *controlParent) {
+ c.fsetParent(p)
+}
+
+func (c *controlbase) preferredSize(d *sizing) (width, height int) {
+ return c.fpreferredSize(d)
+}
+
+func (c *controlbase) resize(x int, y int, width int, height int, d *sizing) {
+ c.fresize(x, y, width, height, d)
+}
+
+func (c *controlbase) nTabStops() int {
+ return c.fnTabStops()
+}
+
+func (c *controlbase) containerShow() {
+ c.fcontainerShow()
+}
+
+func (c *controlbase) containerHide() {
+ c.fcontainerHide()
+}