Modified Button for the new changes. Now I just need to actually create the window class and edit main()...
This commit is contained in:
parent
942490e1aa
commit
5bc4c49afa
25
button.go
25
button.go
|
@ -14,7 +14,6 @@ type Button struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
created bool
|
created bool
|
||||||
parent Control
|
parent Control
|
||||||
pWin *Window
|
|
||||||
sysData *sysData
|
sysData *sysData
|
||||||
initText string
|
initText string
|
||||||
}
|
}
|
||||||
|
@ -44,31 +43,15 @@ func (b *Button) SetText(text string) (err error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Button) apply() error {
|
func (b *Button) apply(window *sysData) error {
|
||||||
b.lock.Lock()
|
b.lock.Lock()
|
||||||
defer b.lock.Unlock()
|
defer b.lock.Unlock()
|
||||||
|
|
||||||
if b.pWin == nil {
|
b.sysData.clicked = b.Clicked
|
||||||
panic(fmt.Sprintf("button (initial text: %q) without parent window", b.initText))
|
return b.sysData.make(b.initText, 300, 300, window)
|
||||||
}
|
// TODO size to parent size
|
||||||
if !b.pWin.created {
|
|
||||||
b.sysData.clicked = b.Clicked
|
|
||||||
b.sysData.parentWindow = b.pWin.sysData
|
|
||||||
return b.sysData.make(b.initText, 300, 300)
|
|
||||||
// TODO size to parent size
|
|
||||||
}
|
|
||||||
return b.sysData.show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Button) setParent(c Control) {
|
func (b *Button) setParent(c Control) {
|
||||||
b.parent = c
|
b.parent = c
|
||||||
if w, ok := b.parent.(*Window); ok {
|
|
||||||
b.pWin = w
|
|
||||||
} else {
|
|
||||||
b.pWin = c.parentWindow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *Button) parentWindow() *Window {
|
|
||||||
return b.pWin
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue