2014-02-23 19:04:33 -06:00
|
|
|
// +build !windows,!darwin,!plan9
|
|
|
|
|
|
|
|
// 23 february 2014
|
2014-03-12 20:55:45 -05:00
|
|
|
|
2014-02-23 19:04:33 -06:00
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
// ...
|
|
|
|
)
|
|
|
|
|
|
|
|
// GTK+ 3 makes this easy: controls can tell us what their preferred size is!
|
|
|
|
// ...actually, it tells us two things: the "minimum size" and the "natural size".
|
|
|
|
// The "minimum size" is the smallest size we /can/ display /anything/. The "natural size" is the smallest size we would /prefer/ to display.
|
|
|
|
// The difference? Minimum size takes into account things like truncation with ellipses: the minimum size of a label can allot just the ellipses!
|
2014-04-27 15:26:06 -05:00
|
|
|
// So we use the natural size instead.
|
|
|
|
// There is a warning about height-for-width controls, but in my tests this isn't an issue.
|
2014-06-06 22:31:50 -05:00
|
|
|
// For Areas, we manually save the Area size and use that, just to be safe.
|
2014-02-23 19:04:33 -06:00
|
|
|
|
|
|
|
func (s *sysData) preferredSize() (width int, height int) {
|
2014-06-06 22:31:50 -05:00
|
|
|
if s.ctype == c_area {
|
|
|
|
return s.areawidth, s.areaheight
|
|
|
|
}
|
|
|
|
|
2014-02-23 19:04:33 -06:00
|
|
|
_, _, width, height = gtk_widget_get_preferred_size(s.widget)
|
|
|
|
return width, height
|
|
|
|
}
|