diff options
| author | Pietro Gagliardi <[email protected]> | 2014-03-09 19:44:41 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-03-09 19:44:41 -0400 |
| commit | ce571bad52589008b8efe6cc0a6e3f76c7f88856 (patch) | |
| tree | ee797fc408071f929d1a53ae52ba39595d3aab8a | |
| parent | ab11900d43b02ab2c01f5963b3cfaf8b623ebd58 (diff) | |
Removed error returns from Control.preferredSize() since errors are not going to be returned anymore.
| -rw-r--r-- | button.go | 5 | ||||
| -rw-r--r-- | checkbox.go | 5 | ||||
| -rw-r--r-- | combobox.go | 5 | ||||
| -rw-r--r-- | control.go | 2 | ||||
| -rw-r--r-- | grid.go | 14 | ||||
| -rw-r--r-- | label.go | 5 | ||||
| -rw-r--r-- | lineedit.go | 5 | ||||
| -rw-r--r-- | listbox.go | 5 | ||||
| -rw-r--r-- | progressbar.go | 5 | ||||
| -rw-r--r-- | stack.go | 14 |
10 files changed, 23 insertions, 42 deletions
@@ -69,10 +69,9 @@ func (b *Button) setRect(x int, y int, width int, height int, winheight int) err return b.sysData.setRect(x, y, width, height, winheight) } -func (b *Button) preferredSize() (width int, height int, err error) { +func (b *Button) preferredSize() (width int, height int) { b.lock.Lock() defer b.lock.Unlock() - width, height = b.sysData.preferredSize() - return + return b.sysData.preferredSize() } diff --git a/checkbox.go b/checkbox.go index 5dfd3d1..2b2a71a 100644 --- a/checkbox.go +++ b/checkbox.go @@ -75,10 +75,9 @@ func (c *Checkbox) setRect(x int, y int, width int, height int, winheight int) e return c.sysData.setRect(x, y, width, height, winheight) } -func (c *Checkbox) preferredSize() (width int, height int, err error) { +func (c *Checkbox) preferredSize() (width int, height int) { c.lock.Lock() defer c.lock.Unlock() - width, height = c.sysData.preferredSize() - return + return c.sysData.preferredSize() } diff --git a/combobox.go b/combobox.go index d42b353..85384be 100644 --- a/combobox.go +++ b/combobox.go @@ -154,10 +154,9 @@ func (c *Combobox) setRect(x int, y int, width int, height int, winheight int) e return c.sysData.setRect(x, y, width, height, winheight) } -func (c *Combobox) preferredSize() (width int, height int, err error) { +func (c *Combobox) preferredSize() (width int, height int) { c.lock.Lock() defer c.lock.Unlock() - width, height = c.sysData.preferredSize() - return + return c.sysData.preferredSize() } @@ -9,5 +9,5 @@ import ( type Control interface { make(window *sysData) error setRect(x int, y int, width int, height int, winheight int) error - preferredSize() (width int, height int, err error) + preferredSize() (width int, height int) } @@ -132,10 +132,7 @@ func (g *Grid) setRect(x int, y int, width int, height int, winheight int) error // 2) get preferred sizes; compute row/column sizes for row, xcol := range g.controls { for col, c := range xcol { - w, h, err := c.preferredSize() - if err != nil { - return fmt.Errorf("error getting preferred size of control (%d,%d) in Grid.setRect(): %v", row, col, err) - } + w, h := c.preferredSize() g.widths[row][col] = w g.heights[row][col] = h g.rowheights[row] = max(g.rowheights[row], h) @@ -180,7 +177,7 @@ func (g *Grid) setRect(x int, y int, width int, height int, winheight int) error } // filling and stretchy are ignored for preferred size calculation -func (g *Grid) preferredSize() (width int, height int, err error) { +func (g *Grid) preferredSize() (width int, height int) { g.lock.Lock() defer g.lock.Unlock() @@ -201,10 +198,7 @@ func (g *Grid) preferredSize() (width int, height int, err error) { // 2) get preferred sizes; compute row/column sizes for row, xcol := range g.controls { for col, c := range xcol { - w, h, err := c.preferredSize() - if err != nil { - return 0, 0, fmt.Errorf("error getting preferred size of control (%d,%d) in Grid.setRect(): %v", row, col, err) - } + w, h := c.preferredSize() g.widths[row][col] = w g.heights[row][col] = h g.rowheights[row] = max(g.rowheights[row], h) @@ -218,5 +212,5 @@ func (g *Grid) preferredSize() (width int, height int, err error) { for _, h := range g.rowheights { height += h } - return width, height, nil + return width, height } @@ -63,10 +63,9 @@ func (l *Label) setRect(x int, y int, width int, height int, winheight int) erro return l.sysData.setRect(x, y, width, height, winheight) } -func (l *Label) preferredSize() (width int, height int, err error) { +func (l *Label) preferredSize() (width int, height int) { l.lock.Lock() defer l.lock.Unlock() - width, height = l.sysData.preferredSize() - return + return l.sysData.preferredSize() } diff --git a/lineedit.go b/lineedit.go index 037c858..98617a5 100644 --- a/lineedit.go +++ b/lineedit.go @@ -75,10 +75,9 @@ func (l *LineEdit) setRect(x int, y int, width int, height int, winheight int) e return l.sysData.setRect(x, y, width, height, winheight) } -func (l *LineEdit) preferredSize() (width int, height int, err error) { +func (l *LineEdit) preferredSize() (width int, height int) { l.lock.Lock() defer l.lock.Unlock() - width, height = l.sysData.preferredSize() - return + return l.sysData.preferredSize() } @@ -139,10 +139,9 @@ func (l *Listbox) setRect(x int, y int, width int, height int, winheight int) er return l.sysData.setRect(x, y, width, height, winheight) } -func (l *Listbox) preferredSize() (width int, height int, err error) { +func (l *Listbox) preferredSize() (width int, height int) { l.lock.Lock() defer l.lock.Unlock() - width, height = l.sysData.preferredSize() - return + return l.sysData.preferredSize() } diff --git a/progressbar.go b/progressbar.go index 4d41b28..4d80c94 100644 --- a/progressbar.go +++ b/progressbar.go @@ -56,10 +56,9 @@ func (p *ProgressBar) setRect(x int, y int, width int, height int, winheight int return p.sysData.setRect(x, y, width, height, winheight) } -func (p *ProgressBar) preferredSize() (width int, height int, err error) { +func (p *ProgressBar) preferredSize() (width int, height int) { p.lock.Lock() defer p.lock.Unlock() - width, height = p.sysData.preferredSize() - return + return p.sysData.preferredSize() } @@ -91,10 +91,7 @@ func (s *Stack) setRect(x int, y int, width int, height int, winheight int) erro nStretchy++ continue } - w, h, err := c.preferredSize() - if err != nil { - return fmt.Errorf("error getting preferred size of control %d in Stack.setRect(): %v", i, err) - } + w, h := c.preferredSize() if s.orientation == horizontal { // all controls have same height s.width[i] = w s.height[i] = height @@ -136,7 +133,7 @@ func (s *Stack) setRect(x int, y int, width int, height int, winheight int) erro } // The preferred size of a Stack is the sum of the preferred sizes of non-stretchy controls + (the number of stretchy controls * the largest preferred size among all stretchy controls). -func (s *Stack) preferredSize() (width int, height int, err error) { +func (s *Stack) preferredSize() (width int, height int) { s.lock.Lock() defer s.lock.Unlock() @@ -151,13 +148,10 @@ func (s *Stack) preferredSize() (width int, height int, err error) { var maxswid, maxsht int if len(s.controls) == 0 { // no controls, so return emptiness - return 0, 0, nil + return 0, 0 } for i, c := range s.controls { - w, h, err := c.preferredSize() - if err != nil { - return 0, 0, fmt.Errorf("error getting preferred size of control %d in Stack.preferredSize(): %v", i, err) - } + w, h := c.preferredSize() if s.stretchy[i] { nStretchy++ maxswid = max(maxswid, w) |
