Removed error returns from Control.preferredSize() since errors are not going to be returned anymore.
This commit is contained in:
parent
ab11900d43
commit
ce571bad52
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
14
grid.go
14
grid.go
|
@ -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
|
||||
}
|
||||
|
|
5
label.go
5
label.go
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
14
stack.go
14
stack.go
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue