Finished the previous commit.

This commit is contained in:
Pietro Gagliardi 2014-08-09 00:28:12 -04:00
parent f24e177d99
commit 5198f7202f
2 changed files with 7 additions and 4 deletions

View File

@ -22,7 +22,7 @@ type sizing struct {
// for size calculations // for size calculations
baseX C.int baseX C.int
baseY C.int baseY C.int
internalLeading C.LONG internalLeading C.LONG // for Label; see Label.commitResize() for details
// for the actual resizing // for the actual resizing
// possibly the HDWP // possibly the HDWP

View File

@ -68,7 +68,6 @@ const (
// via http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing // via http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
labelHeight = 8 labelHeight = 8
labelYOffset = 3 labelYOffset = 3
// TODO the label is offset slightly by default...
) )
func (l *label) preferredSize(d *sizing) (width, height int) { func (l *label) preferredSize(d *sizing) (width, height int) {
@ -80,9 +79,13 @@ func (l *label) commitResize(c *allocation, d *sizing) {
yoff := fromdlgunitsY(labelYOffset, d) yoff := fromdlgunitsY(labelYOffset, d)
c.y += yoff c.y += yoff
c.height -= yoff c.height -= yoff
// by default, labels are drawn offset by the internal leading (the space reserved for accents on uppercase letters)
// the above calculation assumes otherwise, so account for the difference
// there will be enough space left over for the internal leading anyway (at least on the standard fonts)
// don't do this to standalone labels, otherwise those accents get cut off!
c.y -= int(d.internalLeading)
c.height += int(d.internalLeading)
} }
c.y -= int(d.internalLeading)
c.height += int(d.internalLeading)
basecommitResize(l, c, d) basecommitResize(l, c, d)
} }