summaryrefslogtreecommitdiff
path: root/stack.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-06-30 09:57:44 -0400
committerPietro Gagliardi <[email protected]>2014-06-30 09:57:44 -0400
commit33155f7496a818a1ed83fe49cccb63be7842bc81 (patch)
treebbb14af3d92becf7d5ca5abfb28630a2b413ad93 /stack.go
parente032807546a96e6489d18a0e42ced51b7c31a55c (diff)
Reverted everything back to the old API.
Diffstat (limited to 'stack.go')
-rw-r--r--stack.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/stack.go b/stack.go
index b421252..e8ce332 100644
--- a/stack.go
+++ b/stack.go
@@ -4,6 +4,7 @@ package ui
import (
"fmt"
+ "sync"
)
type orientation bool
@@ -19,6 +20,7 @@ const (
// Any extra space at the end of a Stack is left blank.
// Some controls may be marked as "stretchy": when the Window they are in changes size, stretchy controls resize to take up the remaining space after non-stretchy controls are laid out. If multiple controls are marked stretchy, they are alloted equal distribution of the remaining space.
type Stack struct {
+ lock sync.Mutex
created bool
orientation orientation
controls []Control
@@ -49,6 +51,9 @@ func NewVerticalStack(controls ...Control) *Stack {
// SetStretchy marks a control in a Stack as stretchy. This cannot be called once the Window containing the Stack has been created.
// It panics if index is out of range.
func (s *Stack) SetStretchy(index int) {
+ s.lock.Lock()
+ defer s.lock.Unlock()
+
if s.created {
panic("call to Stack.SetStretchy() after Stack has been created")
}
@@ -59,6 +64,9 @@ func (s *Stack) SetStretchy(index int) {
}
func (s *Stack) make(window *sysData) error {
+ s.lock.Lock()
+ defer s.lock.Unlock()
+
for i, c := range s.controls {
err := c.make(window)
if err != nil {