Fixed Area test time label weirdness by making Labels truncate their text instead of word-wrapping on all platforms. This doesn't explain GTK+/Wayland, alas.

This commit is contained in:
Pietro Gagliardi 2014-04-13 18:05:07 -04:00
parent e4c27a4a72
commit fb50badf00
5 changed files with 24 additions and 6 deletions

View File

@ -203,7 +203,11 @@ var _emptystring = [1]C.gchar{0}
var emptystring = &_emptystring[0]
func gtk_label_new() *C.GtkWidget {
return C.gtk_label_new(emptystring)
label := C.gtk_label_new(emptystring)
C.gtk_label_set_line_wrap(togtklabel(label), C.FALSE)
// TODO explicitly set line wrap mode as well?
// TODO explicitly disable ellipsizing
return label
// TODO left-justify?
}

View File

@ -7,6 +7,7 @@ import (
)
// A Label is a static line of text used to mark other controls.
// Label text is drawn on a single line; text that does not fit is truncated.
type Label struct {
lock sync.Mutex
created bool

View File

@ -79,6 +79,8 @@ var (
_setEditable = sel_getUid("setEditable:")
_setBordered = sel_getUid("setBordered:")
_setDrawsBackground = sel_getUid("setDrawsBackground:")
_cell = sel_getUid("cell")
_setLineBreakMode = sel_getUid("setLineBreakMode:")
_setStyle = sel_getUid("setStyle:")
_setControlSize = sel_getUid("setControlSize:")
_setIndeterminate = sel_getUid("setIndeterminate:")
@ -281,11 +283,25 @@ var classTypes = [nctypes]*classData{
},
c_label: &classData{
make: func(parentWindow C.id, alternate bool) C.id {
const (
_NSLineBreakByWordWrapping = iota
_NSLineBreakByCharWrapping
_NSLineBreakByClipping
_NSLineBreakByTruncatingHead
_NSLineBreakByTruncatingTail
_NSLineBreakByTruncatingMiddle
)
label := C.objc_msgSend_noargs(_NSTextField, _alloc)
label = initWithDummyFrame(label)
C.objc_msgSend_bool(label, _setEditable, C.BOOL(C.NO))
C.objc_msgSend_bool(label, _setBordered, C.BOOL(C.NO))
C.objc_msgSend_bool(label, _setDrawsBackground, C.BOOL(C.NO))
// this disables both word wrap AND ellipsizing in one fell swoop
// we have to send to the control's cell for this
C.objc_msgSend_uint(C.objc_msgSend_noargs(label, _cell),
_setLineBreakMode, _NSLineBreakByClipping)
// for a multiline label, we either use WordWrapping and send setTruncatesLastVisibleLine: to disable ellipsizing OR use one of those ellipsizing styles
applyStandardControlFont(label)
addControl(parentWindow, label)
return label

View File

@ -82,7 +82,8 @@ var classTypes = [nctypes]*classData{
},
c_label: &classData{
name: "STATIC",
style: _SS_NOPREFIX | controlstyle,
// TODO add no-ellipsizing flags if I didn't do so already
style: _SS_NOPREFIX | _SS_LEFTNOWORDWRAP | controlstyle,
xstyle: 0 | controlxstyle,
},
c_listbox: &classData{

View File

@ -1,10 +1,6 @@
important things:
- NSComboBox scans the entered text to see if it matches one of the items and returns the index of that item if it does; find out how to suppress this so that it returns -1 unless the item was chosen from the list (like the other platforms)
- make sure mouse events trigger when we move the mouse over an Area with a button held on OS X
- area test time label weirdness - this indicates bugs in Stack
- does not show full time initally on Windows; it does after you resize the window
- does not show initially on OS X; it shows up once you resize, and even shows up after you resize back to the original size
- I think both bugs and the GTK+ Wayland bug below are related...
super ultra important things:
- window sizes are inconsistent and wrong: we need to see on which platforms the titlebars/borders/etc. count...