summaryrefslogtreecommitdiff
path: root/window.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-01 11:55:11 -0400
committerPietro Gagliardi <[email protected]>2014-07-01 11:55:57 -0400
commit607e710459a98a9c2f8c40bea85908e643a5fef6 (patch)
treedf8a1f1e31db74f1e0a12e9ed103f8ea7b5cbdc2 /window.go
parentad2c8d90334ffa74a6a81308502bbeb9717c060d (diff)
Restructured uitask to accept a limited range of actions. Implemented this on the Windows backend.
Diffstat (limited to 'window.go')
-rw-r--r--window.go60
1 files changed, 29 insertions, 31 deletions
diff --git a/window.go b/window.go
index 5e0cf5f..4521e33 100644
--- a/window.go
+++ b/window.go
@@ -71,47 +71,45 @@ func (w *Window) SetSpaced(spaced bool) {
// Open creates the Window with Create and then shows the Window with Show. As with Create, you cannot call Open more than once per window.
func (w *Window) Open(control Control) {
- w.create(control, true)
+ uitask.createWindow(w, control, true)
}
// Create creates the Window, setting its control to the given control. It does not show the window. This can only be called once per window, and finalizes all initialization of the control.
func (w *Window) Create(control Control) {
- w.create(control, false)
+ uitask.createWindow(w, control, false)
}
func (w *Window) create(control Control, show bool) {
- touitask(func() {
- if w.created {
- panic("window already open")
- }
- w.sysData.spaced = w.spaced
- w.sysData.close = w.Closing
- if w.sysData.close == nil {
- w.sysData.close = func() bool {
- return false
- }
- }
- err := w.sysData.make(nil)
- if err != nil {
- panic(fmt.Errorf("error opening window: %v", err))
- }
- if control != nil {
- w.sysData.allocate = control.allocate
- err = control.make(w.sysData)
- if err != nil {
- panic(fmt.Errorf("error adding window's control: %v", err))
- }
+ if w.created {
+ panic("window already open")
+ }
+ w.sysData.spaced = w.spaced
+ w.sysData.close = w.Closing
+ if w.sysData.close == nil {
+ w.sysData.close = func() bool {
+ return false
}
- err = w.sysData.setWindowSize(w.initWidth, w.initHeight)
+ }
+ err := w.sysData.make(nil)
+ if err != nil {
+ panic(fmt.Errorf("error opening window: %v", err))
+ }
+ if control != nil {
+ w.sysData.allocate = control.allocate
+ err = control.make(w.sysData)
if err != nil {
- panic(fmt.Errorf("error setting window size (in Window.Open()): %v", err))
- }
- w.sysData.setText(w.initTitle)
- w.created = true
- if show {
- w.Show()
+ panic(fmt.Errorf("error adding window's control: %v", err))
}
- })
+ }
+ err = w.sysData.setWindowSize(w.initWidth, w.initHeight)
+ if err != nil {
+ panic(fmt.Errorf("error setting window size (in Window.Open()): %v", err))
+ }
+ w.sysData.setText(w.initTitle)
+ w.created = true
+ if show {
+ w.Show()
+ }
}
// Show shows the window.