Implemented preferredSize() for Label on Windows. Seems to work...
This commit is contained in:
parent
e2b8fb81d6
commit
ed38a2cac7
|
@ -144,6 +144,7 @@ func finishNewLabel(text string, standalone bool) *label {
|
||||||
controlbase: c,
|
controlbase: c,
|
||||||
standalone: standalone,
|
standalone: standalone,
|
||||||
}
|
}
|
||||||
|
l.fpreferredSize = l.labelpreferredSize
|
||||||
l.supercommitResize = l.fcommitResize
|
l.supercommitResize = l.fcommitResize
|
||||||
l.fcommitResize = l.labelcommitResize
|
l.fcommitResize = l.labelcommitResize
|
||||||
return l
|
return l
|
||||||
|
@ -167,10 +168,15 @@ func (l *label) SetText(text string) {
|
||||||
|
|
||||||
const (
|
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
|
||||||
labelYOffset = 3
|
labelYOffset = 3
|
||||||
// TODO the label is offset slightly by default...
|
// TODO the label is offset slightly by default...
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (l *label) labelpreferredSize(d *sizing) (width, height int) {
|
||||||
|
return int(l.textlen), fromdlgunitsY(labelHeight, d)
|
||||||
|
}
|
||||||
|
|
||||||
func (l *label) labelcommitResize(c *allocation, d *sizing) {
|
func (l *label) labelcommitResize(c *allocation, d *sizing) {
|
||||||
if !l.standalone {
|
if !l.standalone {
|
||||||
yoff := fromdlgunitsY(labelYOffset, d)
|
yoff := fromdlgunitsY(labelYOffset, d)
|
||||||
|
|
Loading…
Reference in New Issue