Revert "Switch to using DeferWindowPos() in Windows resizes. It doesn't optimize anything just yet (because it's still recursively invoked), but it can be optimized later (by not responding to container resizes and only using container updates); and more important, it puts (most of) the resizing invocations in one place."
Decided not to make the code that much more complicated.
This reverts commit f6fdf932e1
.
This commit is contained in:
parent
f6fdf932e1
commit
9f8d16b26a
|
@ -35,23 +35,17 @@ struct uiWindowsMakeControlParams {
|
||||||
void uiWindowsMakeControl(uiControl *c, uiWindowsMakeControlParams *p);
|
void uiWindowsMakeControl(uiControl *c, uiWindowsMakeControlParams *p);
|
||||||
|
|
||||||
// This contains the Windows-specific parts of the uiSizing structure.
|
// This contains the Windows-specific parts of the uiSizing structure.
|
||||||
// dwp contains the HDWP to issue a resize request to.
|
|
||||||
// You only need to worry about it if you are implementing your own Resize().
|
|
||||||
// baseX and baseY are the dialog base units.
|
// baseX and baseY are the dialog base units.
|
||||||
// internalLeading is the standard control font's internal leading; labels in uiForms use this for correct Y positioning.
|
// internalLeading is the standard control font's internal leading; labels in uiForms use this for correct Y positioning.
|
||||||
struct uiSizingSys {
|
struct uiSizingSys {
|
||||||
HDWP dwp;
|
|
||||||
int baseX;
|
int baseX;
|
||||||
int baseY;
|
int baseY;
|
||||||
LONG internalLeading;
|
LONG internalLeading;
|
||||||
};
|
};
|
||||||
// Use these in your PreferredSize() implementation with baseX and baseY.
|
// Use these in your preferredSize() implementation with baseX and baseY.
|
||||||
#define uiDlgUnitsToX(dlg, baseX) MulDiv((dlg), baseX, 4)
|
#define uiDlgUnitsToX(dlg, baseX) MulDiv((dlg), baseX, 4)
|
||||||
#define uiDlgUnitsToY(dlg, baseY) MulDiv((dlg), baseY, 8)
|
#define uiDlgUnitsToY(dlg, baseY) MulDiv((dlg), baseY, 8)
|
||||||
|
|
||||||
// Use this in your Resize() implementation.
|
|
||||||
void uiWindowsResizeHWND(HWND hwnd, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d);
|
|
||||||
|
|
||||||
// and use this if you need the text of the window width
|
// and use this if you need the text of the window width
|
||||||
extern intmax_t uiWindowsWindowTextWidth(HWND hwnd);
|
extern intmax_t uiWindowsWindowTextWidth(HWND hwnd);
|
||||||
|
|
||||||
|
|
|
@ -127,15 +127,7 @@ static HRESULT resize(uiContainer *cc, RECT *r)
|
||||||
d.xPadding = uiDlgUnitsToX(winXPadding, sys.baseX);
|
d.xPadding = uiDlgUnitsToX(winXPadding, sys.baseX);
|
||||||
d.yPadding = uiDlgUnitsToY(winYPadding, sys.baseY);
|
d.yPadding = uiDlgUnitsToY(winYPadding, sys.baseY);
|
||||||
d.sys = &sys;
|
d.sys = &sys;
|
||||||
|
|
||||||
// 32 is an arbitrary number to start with, just to be safe
|
|
||||||
d.sys->dwp = BeginDeferWindowPos(32);
|
|
||||||
if (d.sys->dwp == NULL)
|
|
||||||
logLastError("error beginning resize in resize()");
|
|
||||||
uiContainerResizeChildren(cc, r->left, r->top, r->right - r->left, r->bottom - r->top, &d);
|
uiContainerResizeChildren(cc, r->left, r->top, r->right - r->left, r->bottom - r->top, &d);
|
||||||
if (EndDeferWindowPos(d.sys->dwp) == 0)
|
|
||||||
logLastError("error ending resize in resize()");
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +301,8 @@ static void containerResize(uiControl *cc, intmax_t x, intmax_t y, intmax_t widt
|
||||||
{
|
{
|
||||||
struct container *c = (struct container *) (cc->Internal);
|
struct container *c = (struct container *) (cc->Internal);
|
||||||
|
|
||||||
uiWindowsResizeHWND(c->hwnd, x, y, width, height, d);
|
if (MoveWindow(c->hwnd, x, y, width, height, TRUE) == 0)
|
||||||
|
logLastError("error resizing uiContainer in containerResize()");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int containerVisible(uiControl *cc)
|
static int containerVisible(uiControl *cc)
|
||||||
|
|
|
@ -56,7 +56,8 @@ static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, i
|
||||||
{
|
{
|
||||||
struct singleHWND *s = (struct singleHWND *) (c->Internal);
|
struct singleHWND *s = (struct singleHWND *) (c->Internal);
|
||||||
|
|
||||||
uiWindowsResizeHWND(s->hwnd, x, y, width, height, d);
|
if (MoveWindow(s->hwnd, x, y, width, height, TRUE) == 0)
|
||||||
|
logLastError("error moving control in singleResize()");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int singleVisible(uiControl *c)
|
static int singleVisible(uiControl *c)
|
||||||
|
@ -206,10 +207,3 @@ void uiWindowsControlSetText(uiControl *c, const char *text)
|
||||||
logLastError("error setting control text in uiWindowsControlSetText()");
|
logLastError("error setting control text in uiWindowsControlSetText()");
|
||||||
uiFree(wtext);
|
uiFree(wtext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiWindowsResizeHWND(HWND hwnd, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d)
|
|
||||||
{
|
|
||||||
d->sys->dwp = DeferWindowPos(d->sys->dwp, hwnd, NULL, x, y, width, height, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);
|
|
||||||
if (d->sys->dwp == NULL)
|
|
||||||
logLastError("error queuing window for resize in uiWindowsResizeHWND()");
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue