Fixed control positioning on GTK+. This will also "fix" control positioning on Windows; next commit.
This commit is contained in:
parent
772f03f4b3
commit
45acb35a6d
|
@ -50,6 +50,15 @@ func (c *container) allocation(margined bool) C.GtkAllocation {
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we can just return these values as is
|
||||||
|
// note that allocations of a widget on GTK+ have their origin in the /window/ origin
|
||||||
|
func (c *container) bounds(d *sizing) (int, int, int, int) {
|
||||||
|
var a C.GtkAllocation
|
||||||
|
|
||||||
|
C.gtk_widget_get_allocation(c.widget, &a)
|
||||||
|
return int(a.x), int(a.y), int(a.width), int(a.height)
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
gtkXMargin = 12
|
gtkXMargin = 12
|
||||||
gtkYMargin = 12
|
gtkYMargin = 12
|
||||||
|
|
|
@ -205,6 +205,8 @@ func (g *grid) resize(x int, y int, width int, height int, d *sizing) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
x, y, width, height = g.container.bounds(d)
|
||||||
|
|
||||||
// -2) get this Grid's padding
|
// -2) get this Grid's padding
|
||||||
xpadding := d.xpadding
|
xpadding := d.xpadding
|
||||||
ypadding := d.ypadding
|
ypadding := d.ypadding
|
||||||
|
|
|
@ -136,6 +136,7 @@ func (g *simpleGrid) resize(x int, y int, width int, height int, d *sizing) {
|
||||||
if len(g.controls) == 0 {
|
if len(g.controls) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
x, y, width, height = g.container.bounds(d)
|
||||||
// -1) get this SimpleGrid's padding
|
// -1) get this SimpleGrid's padding
|
||||||
xpadding := d.xpadding
|
xpadding := d.xpadding
|
||||||
ypadding := d.ypadding
|
ypadding := d.ypadding
|
||||||
|
@ -146,9 +147,6 @@ func (g *simpleGrid) resize(x int, y int, width int, height int, d *sizing) {
|
||||||
// 0) inset the available rect by the needed padding and reset x/y for children
|
// 0) inset the available rect by the needed padding and reset x/y for children
|
||||||
width -= (len(g.colwidths) - 1) * xpadding
|
width -= (len(g.colwidths) - 1) * xpadding
|
||||||
height -= (len(g.rowheights) - 1) * ypadding
|
height -= (len(g.rowheights) - 1) * ypadding
|
||||||
// TODO get the correct client rect
|
|
||||||
x = 0
|
|
||||||
y = 0
|
|
||||||
// 1) clear data structures
|
// 1) clear data structures
|
||||||
for i := range g.rowheights {
|
for i := range g.rowheights {
|
||||||
g.rowheights[i] = 0
|
g.rowheights[i] = 0
|
||||||
|
|
|
@ -92,6 +92,7 @@ func (s *stack) resize(x int, y int, width int, height int, d *sizing) {
|
||||||
if len(s.controls) == 0 { // do nothing if there's nothing to do
|
if len(s.controls) == 0 { // do nothing if there's nothing to do
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
x, y, width, height = s.container.bounds(d)
|
||||||
// -1) get this Stack's padding
|
// -1) get this Stack's padding
|
||||||
xpadding := d.xpadding
|
xpadding := d.xpadding
|
||||||
ypadding := d.ypadding
|
ypadding := d.ypadding
|
||||||
|
@ -99,14 +100,12 @@ func (s *stack) resize(x int, y int, width int, height int, d *sizing) {
|
||||||
xpadding = 0
|
xpadding = 0
|
||||||
ypadding = 0
|
ypadding = 0
|
||||||
}
|
}
|
||||||
// 0) inset the available rect by the needed padding and reset the x/y coordinates for the children
|
// 0) inset the available rect by the needed padding
|
||||||
if s.orientation == horizontal {
|
if s.orientation == horizontal {
|
||||||
width -= (len(s.controls) - 1) * xpadding
|
width -= (len(s.controls) - 1) * xpadding
|
||||||
} else {
|
} else {
|
||||||
height -= (len(s.controls) - 1) * ypadding
|
height -= (len(s.controls) - 1) * ypadding
|
||||||
}
|
}
|
||||||
x = 0
|
|
||||||
y = 0
|
|
||||||
// 1) get height and width of non-stretchy controls; figure out how much space is alloted to stretchy controls
|
// 1) get height and width of non-stretchy controls; figure out how much space is alloted to stretchy controls
|
||||||
stretchywid = width
|
stretchywid = width
|
||||||
stretchyht = height
|
stretchyht = height
|
||||||
|
|
Loading…
Reference in New Issue