summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-02-24 10:30:14 -0500
committerPietro Gagliardi <[email protected]>2014-02-24 10:30:14 -0500
commita174fbebbda723efb6cae031e712acee3156ea1f (patch)
tree87b83f5e2706029b21a7ac256d307597e6db3c79
parent19f9761a816a224f71cf566da80e42831387ddc2 (diff)
Changed Orientation to a bool to prevent invalid values outright.
-rw-r--r--stack.go11
1 files changed, 3 insertions, 8 deletions
diff --git a/stack.go b/stack.go
index 4a6a033..cd72f02 100644
--- a/stack.go
+++ b/stack.go
@@ -7,10 +7,10 @@ import (
)
// Orientation defines the orientation of controls in a Stack.
-type Orientation int
+type Orientation bool
const (
- Horizontal Orientation = iota
- Vertical
+ Horizontal Orientation = false
+ Vertical Orientation = true
)
// A Stack stacks controls horizontally or vertically within the Stack's parent.
@@ -29,9 +29,6 @@ type Stack struct {
// NewStack creates a new Stack with the specified orientation.
func NewStack(o Orientation, controls ...Control) *Stack {
- if o != Horizontal && o != Vertical {
- panic(fmt.Sprintf("invalid orientation %d given to NewStack()", o))
- }
return &Stack{
orientation: o,
controls: controls,
@@ -75,8 +72,6 @@ func (s *Stack) setRect(x int, y int, width int, height int) error {
case Vertical:
dy = height / len(s.controls)
height = dy
- default:
- panic(fmt.Sprintf("invalid orientation %d given to Stack.setRect()", s.orientation))
}
for i, c := range s.controls {
err := c.setRect(x, y, width, height)