Mostly fixed Labels on Windows being offset slightly; need to finish the fix by making it not apply to standalone Labels and adding comments.
This commit is contained in:
parent
21dbda72e2
commit
f24e177d99
|
@ -20,8 +20,9 @@ type sizing struct {
|
|||
sizingbase
|
||||
|
||||
// for size calculations
|
||||
baseX C.int
|
||||
baseY C.int
|
||||
baseX C.int
|
||||
baseY C.int
|
||||
internalLeading C.LONG
|
||||
|
||||
// for the actual resizing
|
||||
// possibly the HDWP
|
||||
|
@ -105,12 +106,14 @@ const (
|
|||
|
||||
func (c *container) beginResize() (d *sizing) {
|
||||
var baseX, baseY C.int
|
||||
var internalLeading C.LONG
|
||||
|
||||
d = new(sizing)
|
||||
|
||||
C.calculateBaseUnits(c.hwnd, &baseX, &baseY)
|
||||
C.calculateBaseUnits(c.hwnd, &baseX, &baseY, &internalLeading)
|
||||
d.baseX = baseX
|
||||
d.baseY = baseY
|
||||
d.internalLeading = internalLeading
|
||||
|
||||
if spaced {
|
||||
d.xmargin = fromdlgunitsX(marginDialogUnits, d)
|
||||
|
|
|
@ -81,6 +81,8 @@ func (l *label) commitResize(c *allocation, d *sizing) {
|
|||
c.y += yoff
|
||||
c.height -= yoff
|
||||
}
|
||||
c.y -= int(d.internalLeading)
|
||||
c.height += int(d.internalLeading)
|
||||
basecommitResize(l, c, d)
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
/* TODO figure out where these should go */
|
||||
|
||||
void calculateBaseUnits(HWND hwnd, int *baseX, int *baseY)
|
||||
void calculateBaseUnits(HWND hwnd, int *baseX, int *baseY, LONG *internalLeading)
|
||||
{
|
||||
HDC dc;
|
||||
HFONT prevFont;
|
||||
|
@ -21,6 +21,7 @@ void calculateBaseUnits(HWND hwnd, int *baseX, int *baseY)
|
|||
xpanic("error getting text metrics for preferred size calculations", GetLastError());
|
||||
*baseX = (int) tm.tmAveCharWidth; /* TODO not optimal; third reference below has better way */
|
||||
*baseY = (int) tm.tmHeight;
|
||||
*internalLeading = tm.tmInternalLeading;
|
||||
if (SelectObject(dc, prevFont) != controlFont)
|
||||
xpanic("error restoring previous font into device context after preferred size calculations", GetLastError());
|
||||
if (ReleaseDC(hwnd, dc) == 0)
|
||||
|
|
|
@ -69,7 +69,7 @@ extern HBRUSH hollowBrush;
|
|||
extern DWORD initWindows(char **);
|
||||
|
||||
/* sizing_windows.c */
|
||||
extern void calculateBaseUnits(HWND, int *, int *);
|
||||
extern void calculateBaseUnits(HWND, int *, int *, LONG *);
|
||||
extern void moveWindow(HWND, int, int, int, int);
|
||||
extern LONG controlTextLength(HWND, LPWSTR);
|
||||
|
||||
|
|
|
@ -87,15 +87,17 @@ func (tw *testwin) make(done chan struct{}) {
|
|||
NewTextField(),
|
||||
NewPasswordField(),
|
||||
NewTable(reflect.TypeOf(struct{A,B,C int}{})),
|
||||
NewStandaloneLabel("hello"))
|
||||
NewStandaloneLabel("hello ÉÀÔ"))
|
||||
tw.t.Append("Pref Height", tw.sph)
|
||||
stack1 := NewHorizontalStack(NewLabel("Test"), NewTextField())
|
||||
stack1.SetStretchy(1)
|
||||
stack2 := NewHorizontalStack(NewLabel("Test 2"),
|
||||
NewTable(reflect.TypeOf(struct{A,B,C int}{})))
|
||||
stack2 := NewHorizontalStack(NewLabel("ÉÀÔ"), NewTextField())
|
||||
stack2.SetStretchy(1)
|
||||
tw.s = NewVerticalStack(stack1, stack2)
|
||||
tw.s.SetStretchy(1)
|
||||
stack3 := NewHorizontalStack(NewLabel("Test 2"),
|
||||
NewTable(reflect.TypeOf(struct{A,B,C int}{})))
|
||||
stack3.SetStretchy(1)
|
||||
tw.s = NewVerticalStack(stack1, stack2, stack3)
|
||||
tw.s.SetStretchy(2)
|
||||
tw.t.Append("Stack", tw.s)
|
||||
tw.l = NewStandaloneLabel("hello")
|
||||
tw.t.Append("Label", tw.l)
|
||||
|
|
Loading…
Reference in New Issue