Took scrolling into account on uiArea with drawing (untested) and mouse events (tested). This is the preliminary work for moving scrolling from pixels to DIPs. But first, a test of scrolled drawing.
This commit is contained in:
parent
adc72c9d0b
commit
13fa2e213d
|
@ -8,7 +8,9 @@ static HRESULT doPaint(uiArea *a, ID2D1RenderTarget *rt, RECT *clip)
|
||||||
uiAreaDrawParams dp;
|
uiAreaDrawParams dp;
|
||||||
COLORREF bgcolorref;
|
COLORREF bgcolorref;
|
||||||
D2D1_COLOR_F bgcolor;
|
D2D1_COLOR_F bgcolor;
|
||||||
|
D2D1_MATRIX_3X2_F scrollTransform;
|
||||||
|
|
||||||
|
// no need to save or restore the graphics state to reset transformations; it's handled by resetTarget() in draw.c, called during the following
|
||||||
dp.Context = newContext(rt);
|
dp.Context = newContext(rt);
|
||||||
|
|
||||||
loadAreaSize(a, rt, &(dp.AreaWidth), &(dp.AreaHeight));
|
loadAreaSize(a, rt, &(dp.AreaWidth), &(dp.AreaHeight));
|
||||||
|
@ -17,9 +19,24 @@ static HRESULT doPaint(uiArea *a, ID2D1RenderTarget *rt, RECT *clip)
|
||||||
dp.ClipY = clip->top;
|
dp.ClipY = clip->top;
|
||||||
dp.ClipWidth = clip->right - clip->left;
|
dp.ClipWidth = clip->right - clip->left;
|
||||||
dp.ClipHeight = clip->bottom - clip->top;
|
dp.ClipHeight = clip->bottom - clip->top;
|
||||||
|
if (a->scrolling) {
|
||||||
|
dp.ClipX += a->hscrollpos;
|
||||||
|
dp.ClipY += a->vscrollpos;
|
||||||
|
}
|
||||||
|
|
||||||
ID2D1RenderTarget_BeginDraw(rt);
|
ID2D1RenderTarget_BeginDraw(rt);
|
||||||
|
|
||||||
|
if (a->scrolling) {
|
||||||
|
ZeroMemory(&scrollTransform, sizeof (D2D1_MATRIX_3X2_F));
|
||||||
|
scrollTransform._11 = 1;
|
||||||
|
scrollTransform._22 = 1;
|
||||||
|
scrollTransform._31 = a->hscrollpos;
|
||||||
|
scrollTransform._32 = a->vscrollpos;
|
||||||
|
ID2D1RenderTarget_SetTransform(rt, &scrollTransform);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO push axis aligned clip
|
||||||
|
|
||||||
// TODO only clear the clip area
|
// TODO only clear the clip area
|
||||||
// TODO clear with actual background brush
|
// TODO clear with actual background brush
|
||||||
bgcolorref = GetSysColor(COLOR_BTNFACE);
|
bgcolorref = GetSysColor(COLOR_BTNFACE);
|
||||||
|
@ -31,11 +48,12 @@ static HRESULT doPaint(uiArea *a, ID2D1RenderTarget *rt, RECT *clip)
|
||||||
bgcolor.a = 1.0;
|
bgcolor.a = 1.0;
|
||||||
ID2D1RenderTarget_Clear(rt, &bgcolor);
|
ID2D1RenderTarget_Clear(rt, &bgcolor);
|
||||||
|
|
||||||
// no need to save or restore the graphics state to reset transformations; it's handled by resetTarget() in draw.c, called by newContext() above
|
|
||||||
(*(ah->Draw))(ah, a, &dp);
|
(*(ah->Draw))(ah, a, &dp);
|
||||||
|
|
||||||
freeContext(dp.Context);
|
freeContext(dp.Context);
|
||||||
|
|
||||||
|
// TODO pop axis aligned clip
|
||||||
|
|
||||||
return ID2D1RenderTarget_EndDraw(rt, NULL, NULL);
|
return ID2D1RenderTarget_EndDraw(rt, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,12 @@ static void areaMouseEvent(uiArea *a, uintmax_t down, uintmax_t up, WPARAM wPar
|
||||||
ypix = (double) GET_Y_LPARAM(lParam);
|
ypix = (double) GET_Y_LPARAM(lParam);
|
||||||
// these are in pixels; we need points
|
// these are in pixels; we need points
|
||||||
pixelsToDIP(a, &xpix, &ypix);
|
pixelsToDIP(a, &xpix, &ypix);
|
||||||
|
me.X = xpix;
|
||||||
|
me.Y = ypix;
|
||||||
|
if (a->scrolling) {
|
||||||
|
me.X += a->hscrollpos;
|
||||||
|
me.Y += a->vscrollpos;
|
||||||
|
}
|
||||||
|
|
||||||
loadAreaSize(a, NULL, &(me.AreaWidth), &(me.AreaHeight));
|
loadAreaSize(a, NULL, &(me.AreaWidth), &(me.AreaHeight));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue