Implemented redrawing on scrolling and adjusting scrolling on resizing and actually implemented scrolled drawing correctly on uiArea on Windows.
This commit is contained in:
parent
a922551b78
commit
af374ed859
|
@ -40,6 +40,7 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
|
||||||
if (GetClientRect(a->hwnd, &client) == 0)
|
if (GetClientRect(a->hwnd, &client) == 0)
|
||||||
logLastError("error getting client rect of uiArea for WM_WINDOWPOSCHANGED handling in areaWndProc()");
|
logLastError("error getting client rect of uiArea for WM_WINDOWPOSCHANGED handling in areaWndProc()");
|
||||||
areaDrawOnResize(a, &client);
|
areaDrawOnResize(a, &client);
|
||||||
|
areaScrollOnResize(a, &client);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ extern void areaDrawOnResize(uiArea *, RECT *);
|
||||||
|
|
||||||
// areascroll.c
|
// areascroll.c
|
||||||
extern BOOL areaDoScroll(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult);
|
extern BOOL areaDoScroll(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult);
|
||||||
|
extern void areaScrollOnResize(uiArea *, RECT *);
|
||||||
extern void areaUpdateScroll(uiArea *a);
|
extern void areaUpdateScroll(uiArea *a);
|
||||||
|
|
||||||
// areaevents.c
|
// areaevents.c
|
||||||
|
|
|
@ -30,8 +30,9 @@ static HRESULT doPaint(uiArea *a, ID2D1RenderTarget *rt, RECT *clip)
|
||||||
ZeroMemory(&scrollTransform, sizeof (D2D1_MATRIX_3X2_F));
|
ZeroMemory(&scrollTransform, sizeof (D2D1_MATRIX_3X2_F));
|
||||||
scrollTransform._11 = 1;
|
scrollTransform._11 = 1;
|
||||||
scrollTransform._22 = 1;
|
scrollTransform._22 = 1;
|
||||||
scrollTransform._31 = a->hscrollpos;
|
// negative because we want nonzero scroll positions to move the drawing area up/left
|
||||||
scrollTransform._32 = a->vscrollpos;
|
scrollTransform._31 = -a->hscrollpos;
|
||||||
|
scrollTransform._32 = -a->vscrollpos;
|
||||||
ID2D1RenderTarget_SetTransform(rt, &scrollTransform);
|
ID2D1RenderTarget_SetTransform(rt, &scrollTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ struct scrollParams {
|
||||||
static void scrollto(uiArea *a, int which, struct scrollParams *p, intmax_t pos)
|
static void scrollto(uiArea *a, int which, struct scrollParams *p, intmax_t pos)
|
||||||
{
|
{
|
||||||
SCROLLINFO si;
|
SCROLLINFO si;
|
||||||
intmax_t xamount, yamount;
|
|
||||||
|
|
||||||
// note that the pos < 0 check is /after/ the p->length - p->pagesize check
|
// note that the pos < 0 check is /after/ the p->length - p->pagesize check
|
||||||
// it used to be /before/; this was actually a bug in Raymond Chen's original algorithm: if there are fewer than a page's worth of items, p->length - p->pagesize will be negative and our content draw at the bottom of the window
|
// it used to be /before/; this was actually a bug in Raymond Chen's original algorithm: if there are fewer than a page's worth of items, p->length - p->pagesize will be negative and our content draw at the bottom of the window
|
||||||
|
@ -32,19 +31,10 @@ static void scrollto(uiArea *a, int which, struct scrollParams *p, intmax_t pos)
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
|
||||||
// negative because ScrollWindowEx() is "backwards"
|
// Direct2D doesn't have a method for scrolling the existing contents of a render target.
|
||||||
xamount = -(pos - *(p->pos));
|
// We'll have to just invalidate everything and hope for the best.
|
||||||
yamount = 0;
|
if (InvalidateRect(a->hwnd, NULL, FALSE) == 0)
|
||||||
if (which == SB_VERT) {
|
logLastError("error invalidating uiArea after scrolling in scrollto()");
|
||||||
yamount = xamount;
|
|
||||||
xamount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO this isn't safe with Direct2D
|
|
||||||
// if (ScrollWindowEx(a->hwnd, xamount, yamount,
|
|
||||||
// NULL, NULL, NULL, NULL,
|
|
||||||
// SW_ERASE | SW_INVALIDATE) == ERROR)
|
|
||||||
// logLastError("error scrolling area in scrollto()");
|
|
||||||
|
|
||||||
*(p->pos) = pos;
|
*(p->pos) = pos;
|
||||||
|
|
||||||
|
@ -247,7 +237,10 @@ BOOL areaDoScroll(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *l
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO do we need an areaScrollOnResize()?
|
void areaScrollOnResize(uiArea *a, RECT *client)
|
||||||
|
{
|
||||||
|
areaUpdateScroll(a);
|
||||||
|
}
|
||||||
|
|
||||||
void areaUpdateScroll(uiArea *a)
|
void areaUpdateScroll(uiArea *a)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue