And added a proper invalidateRect().

This commit is contained in:
Pietro Gagliardi 2016-05-17 12:41:41 -04:00
parent 473e0c9b69
commit 8a1fe1f48a
7 changed files with 12 additions and 10 deletions

View File

@ -89,8 +89,7 @@ void uiAreaSetSize(uiArea *a, intmax_t width, intmax_t height)
void uiAreaQueueRedrawAll(uiArea *a) void uiAreaQueueRedrawAll(uiArea *a)
{ {
// don't erase the background; we do that ourselves in doPaint() // don't erase the background; we do that ourselves in doPaint()
if (InvalidateRect(a->hwnd, NULL, FALSE) == 0) invalidateRect(a->hwnd, NULL, FALSE);
logLastError(L"error queueing uiArea redraw");
} }
void uiAreaScrollTo(uiArea *a, double x, double y, double width, double height) void uiAreaScrollTo(uiArea *a, double x, double y, double width, double height)

View File

@ -127,6 +127,5 @@ void areaDrawOnResize(uiArea *a, RECT *newClient)
// according to Rick Brewster, we must always redraw the entire client area after calling ID2D1RenderTarget::Resize() (see http://stackoverflow.com/a/33222983/3408572) // according to Rick Brewster, we must always redraw the entire client area after calling ID2D1RenderTarget::Resize() (see http://stackoverflow.com/a/33222983/3408572)
// we used to have a uiAreaHandler.RedrawOnResize() method to decide this; now you know why we don't anymore // we used to have a uiAreaHandler.RedrawOnResize() method to decide this; now you know why we don't anymore
if (InvalidateRect(a->hwnd, NULL, TRUE) == 0) invalidateRect(a->hwnd, NULL, TRUE);
logLastError(L"error redrawing area on resize");
} }

View File

@ -33,8 +33,7 @@ static void scrollto(uiArea *a, int which, struct scrollParams *p, intmax_t pos)
// Direct2D doesn't have a method for scrolling the existing contents of a render target. // Direct2D doesn't have a method for scrolling the existing contents of a render target.
// We'll have to just invalidate everything and hope for the best. // We'll have to just invalidate everything and hope for the best.
if (InvalidateRect(a->hwnd, NULL, FALSE) == 0) invalidateRect(a->hwnd, NULL, FALSE);
logLastError(L"error invalidating uiArea after scrolling");
*(p->pos) = pos; *(p->pos) = pos;

View File

@ -134,8 +134,7 @@ void uiColorButtonSetColor(uiColorButton *b, double r, double g, double bl, doub
b->g = g; b->g = g;
b->b = bl; b->b = bl;
b->a = a; b->a = a;
// TODO don't we have a helper function for this? invalidateRect(b->hwnd, NULL, TRUE);
InvalidateRect(b->hwnd, NULL, TRUE);
} }
void uiColorButtonOnChanged(uiColorButton *b, void (*f)(uiColorButton *, void *), void *data) void uiColorButtonOnChanged(uiColorButton *b, void (*f)(uiColorButton *, void *), void *data)

View File

@ -174,8 +174,7 @@ static WCHAR *fontStyleName(struct fontCollection *fc, IDWriteFont *font)
static void queueRedrawSampleText(struct fontDialog *f) static void queueRedrawSampleText(struct fontDialog *f)
{ {
// TODO TRUE? // TODO TRUE?
if (InvalidateRect(f->sampleBox, NULL, TRUE) == 0) invalidateRect(f->sampleBox, NULL, TRUE);
logLastError(L"error queueing a redraw of the font dialog's sample text");
} }
static void styleChanged(struct fontDialog *f) static void styleChanged(struct fontDialog *f)

View File

@ -65,6 +65,7 @@ extern HWND parentOf(HWND child);
extern HWND parentToplevel(HWND child); extern HWND parentToplevel(HWND child);
extern void setWindowInsertAfter(HWND hwnd, HWND insertAfter); extern void setWindowInsertAfter(HWND hwnd, HWND insertAfter);
extern HWND getDlgItem(HWND hwnd, int id); extern HWND getDlgItem(HWND hwnd, int id);
extern void invalidateRect(HWND hwnd, RECT *r, BOOL erase);
// text.cpp // text.cpp
extern WCHAR *windowTextAndLen(HWND hwnd, LRESULT *len); extern WCHAR *windowTextAndLen(HWND hwnd, LRESULT *len);

View File

@ -130,3 +130,9 @@ HWND getDlgItem(HWND hwnd, int id)
logLastError(L"error getting dialog item handle"); logLastError(L"error getting dialog item handle");
return out; return out;
} }
void invalidateRect(HWND hwnd, RECT *r, BOOL erase)
{
if (InvalidateRect(hwnd, r, erase) == 0)
logLastError(L"error invalidating window rect");
}