summaryrefslogtreecommitdiff
path: root/prevlib/button.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-02 22:53:03 -0400
committerPietro Gagliardi <[email protected]>2014-07-02 22:53:03 -0400
commit8a81650b3da7ce00725336df9e03b38e935c5a65 (patch)
tree08af843f0460e7226f305cf7162021ef54e8c3f7 /prevlib/button.go
parent4dd5ceb11d62bd6b9af4847936314a9d8c45707f (diff)
Moved it all back; the preemptive multitaksing during an event handler kills us on all platforms. Going to have to restrict ALL GUI accss to happening from one t hread, so going to need to drop uitask entirely and have just a start() callback for startup code and a post() function for posting requests to windows (like channel sends but into a perpetual buffer).
Diffstat (limited to 'prevlib/button.go')
-rw-r--r--prevlib/button.go76
1 files changed, 0 insertions, 76 deletions
diff --git a/prevlib/button.go b/prevlib/button.go
deleted file mode 100644
index 465427a..0000000
--- a/prevlib/button.go
+++ /dev/null
@@ -1,76 +0,0 @@
-// 12 february 2014
-
-package ui
-
-// A Button represents a clickable button with some text.
-type Button struct {
- // Clicked is called when the button is clicked.
- // This cannot be changed after the Window containing the Button has been created.
- // If you do not specify a handler, a default of "do nothing" will be used instead.
- Clicked func()
-
- created bool
- sysData *sysData
- initText string
-}
-
-// NewButton creates a new button with the specified text.
-func NewButton(text string) (b *Button) {
- return &Button{
- sysData: mksysdata(c_button),
- initText: text,
- }
-}
-
-// SetText sets the button's text.
-func (b *Button) SetText(text string) {
- if b.created {
- b.sysData.setText(text)
- return
- }
- b.initText = text
-}
-
-// Text returns the button's text.
-func (b *Button) Text() string {
- if b.created {
- return b.sysData.text()
- }
- return b.initText
-}
-
-func (b *Button) make(window *sysData) error {
- b.sysData.event = b.Clicked
- if b.sysData.event == nil {
- b.sysData.event = func() {}
- }
- err := b.sysData.make(window)
- if err != nil {
- return err
- }
- b.sysData.setText(b.initText)
- b.created = true
- return nil
-}
-
-func (b *Button) allocate(x int, y int, width int, height int, d *sysSizeData) []*allocation {
- return []*allocation{&allocation{
- x: x,
- y: y,
- width: width,
- height: height,
- this: b,
- }}
-}
-
-func (b *Button) preferredSize(d *sysSizeData) (width int, height int) {
- return b.sysData.preferredSize(d)
-}
-
-func (b *Button) commitResize(a *allocation, d *sysSizeData) {
- b.sysData.commitResize(a, d)
-}
-
-func (b *Button) getAuxResizeInfo(d *sysSizeData) {
- b.sysData.getAuxResizeInfo(d)
-}