Fixed the ID2D1RenderTarget::GetSize() madness a *SECOND* time. Urgh. Also removed a now-irrelevant TODO.
This commit is contained in:
parent
6d06e15390
commit
4edcddce14
1
ui.h
1
ui.h
|
@ -280,7 +280,6 @@ typedef struct uiDrawContext uiDrawContext;
|
|||
struct uiAreaHandler {
|
||||
void (*Draw)(uiAreaHandler *, uiArea *, uiAreaDrawParams *);
|
||||
// TODO document that resizes cause a full redraw for non-scrolling areas; implementation-defined for scrolling areas
|
||||
// TODO if the scrollbars disappear the histogram example won't recognize points in the correct spot until the area is resized
|
||||
void (*MouseEvent)(uiAreaHandler *, uiArea *, uiAreaMouseEvent *);
|
||||
// TODO document that on first show if the mouse is already in the uiArea then one gets sent with left=0
|
||||
// TODO what about when the area is hidden and then shown again?
|
||||
|
|
|
@ -7,6 +7,22 @@ uiWindowsDefineControl(
|
|||
uiAreaType // type function
|
||||
)
|
||||
|
||||
// I love COM interfaces that actually only work on C++
|
||||
// ID2D1RenderTarget::GetSize is defined as returninig a structure
|
||||
// with stdcall, this means it's an extra last argument
|
||||
// the compiler tries to return it directly, and crashes
|
||||
// I originally thought this was a bug in MinGW-w64, but it turns out it also affects MSVC! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64384
|
||||
// So we have to work around it.
|
||||
// TODO is the return type correct? or should we just use C++?
|
||||
void renderTargetGetSize(ID2D1RenderTarget *rt, D2D1_SIZE_F *size)
|
||||
{
|
||||
typedef void (STDMETHODCALLTYPE *fptr)(ID2D1RenderTarget *, D2D1_SIZE_F *);
|
||||
fptr f;
|
||||
|
||||
f = (fptr) (rt->lpVtbl->GetSize);
|
||||
(*f)(rt, size);
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
uiArea *a;
|
||||
|
|
|
@ -24,6 +24,9 @@ struct uiArea {
|
|||
ID2D1HwndRenderTarget *rt;
|
||||
};
|
||||
|
||||
// area.c
|
||||
extern void renderTargetGetSize(ID2D1RenderTarget *rt, D2D1_SIZE_F *size);
|
||||
|
||||
// areadraw.h
|
||||
extern BOOL areaDoDraw(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult);
|
||||
extern void areaDrawOnResize(uiArea *, RECT *);
|
||||
|
|
|
@ -15,7 +15,7 @@ static HRESULT doPaint(uiArea *a, ID2D1RenderTarget *rt, RECT *clip)
|
|||
dp.AreaWidth = 0;
|
||||
dp.AreaHeight = 0;
|
||||
if (!a->scrolling) {
|
||||
size = ID2D1RenderTarget_GetSize(rt);
|
||||
renderTargetGetSize(rt, &size);
|
||||
dp.AreaWidth = size.width;
|
||||
dp.AreaHeight = size.height;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ static void areaMouseEvent(uiArea *a, uintmax_t down, uintmax_t up, WPARAM wPar
|
|||
me.AreaWidth = 0;
|
||||
me.AreaHeight = 0;
|
||||
if (!a->scrolling) {
|
||||
size = ID2D1HwndRenderTarget_GetSize(a->rt);
|
||||
renderTargetGetSize((ID2D1RenderTarget *) (a->rt), &size);
|
||||
me.AreaWidth = size.width;
|
||||
me.AreaHeight = size.height;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue