diff options
| author | Pietro Gagliardi <[email protected]> | 2014-02-23 20:04:33 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-02-23 20:04:33 -0500 |
| commit | d5ce49c8b0a2a7c28e1794022424fddc2369f900 (patch) | |
| tree | 08a596d92dc4e084f552ea18fc22bcac468144f6 /prefsize_unix.go | |
| parent | a0c951cca9a89340785dbdd1c24e1517e18608b6 (diff) | |
Added the preferred widget size basework and its GTK+ implementation.
Diffstat (limited to 'prefsize_unix.go')
| -rw-r--r-- | prefsize_unix.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/prefsize_unix.go b/prefsize_unix.go new file mode 100644 index 0000000..b9114fc --- /dev/null +++ b/prefsize_unix.go @@ -0,0 +1,21 @@ +// +build !windows,!darwin,!plan9 + +// 23 february 2014 +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! +// So we use the natural size instead, right? +// We could, but there's one snag: "Handle with care. Note that the natural height of a height-for-width widget will generally be a smaller size than the minimum height, since the required height for the natural width is generally smaller than the required height for the minimum width." +// This will have to be taken care of manually, so TODO; we'll just use the natural size for now + +func (s *sysData) preferredSize() (width int, height int) { + _, _, width, height = gtk_widget_get_preferred_size(s.widget) + return width, height +} |
