diff options
author | StapleButter <thetotalworm@gmail.com> | 2017-11-23 19:28:06 +0100 |
---|---|---|
committer | StapleButter <thetotalworm@gmail.com> | 2017-11-23 19:28:06 +0100 |
commit | 8e6d834f13e21efe02eb540a9ca0cf1800e183de (patch) | |
tree | 392cc9265935cea991295b19d1f1bf606f6dc5ca /src/libui_sdl/libui/windows | |
parent | b96ac8e000536e9c3f498579abb319c6cfe3d022 (diff) |
libui: add API for setting a background color for uiArea. (TODO: do for GTK)
make window background black.
Diffstat (limited to 'src/libui_sdl/libui/windows')
-rw-r--r-- | src/libui_sdl/libui/windows/area.cpp | 13 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/area.hpp | 2 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/areadraw.cpp | 26 |
3 files changed, 33 insertions, 8 deletions
diff --git a/src/libui_sdl/libui/windows/area.cpp b/src/libui_sdl/libui/windows/area.cpp index 6bb8fe7..2185f25 100644 --- a/src/libui_sdl/libui/windows/area.cpp +++ b/src/libui_sdl/libui/windows/area.cpp @@ -167,6 +167,15 @@ void uiAreaBeginUserWindowResize(uiArea *a, uiWindowResizeEdge edge) wParam, 0); } + +void uiAreaSetBackgroundColor(uiArea *a, int r, int g, int b) +{ + a->bgR = r; + a->bgG = g; + a->bgB = b; +} + + uiArea *uiNewArea(uiAreaHandler *ah) { uiArea *a; @@ -184,6 +193,8 @@ uiArea *uiNewArea(uiAreaHandler *ah) hInstance, a, FALSE); + uiAreaSetBackgroundColor(a, -1, -1, -1); + return a; } @@ -206,6 +217,8 @@ uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height) hInstance, a, FALSE); + uiAreaSetBackgroundColor(a, -1, -1, -1); + // set initial scrolling parameters areaUpdateScroll(a); diff --git a/src/libui_sdl/libui/windows/area.hpp b/src/libui_sdl/libui/windows/area.hpp index 86a62de..add62dd 100644 --- a/src/libui_sdl/libui/windows/area.hpp +++ b/src/libui_sdl/libui/windows/area.hpp @@ -24,6 +24,8 @@ struct uiArea { BOOL inside; BOOL tracking; + int bgR, bgG, bgB; + ID2D1HwndRenderTarget *rt; }; diff --git a/src/libui_sdl/libui/windows/areadraw.cpp b/src/libui_sdl/libui/windows/areadraw.cpp index 7b3dc69..0bdf58a 100644 --- a/src/libui_sdl/libui/windows/areadraw.cpp +++ b/src/libui_sdl/libui/windows/areadraw.cpp @@ -40,14 +40,24 @@ static HRESULT doPaint(uiArea *a, ID2D1RenderTarget *rt, RECT *clip) // TODO only clear the clip area // TODO clear with actual background brush - bgcolorref = GetSysColor(COLOR_BTNFACE); - bgcolor.r = ((float) GetRValue(bgcolorref)) / 255.0; - // due to utter apathy on Microsoft's part, GetGValue() does not work with MSVC's Run-Time Error Checks - // it has not worked since 2008 and they have *never* fixed it - // TODO now that -RTCc has just been deprecated entirely, should we switch back? - bgcolor.g = ((float) ((BYTE) ((bgcolorref & 0xFF00) >> 8))) / 255.0; - bgcolor.b = ((float) GetBValue(bgcolorref)) / 255.0; - bgcolor.a = 1.0; + if (a->bgR != -1) + { + bgcolor.r = ((float) a->bgR) / 255.0; + bgcolor.g = ((float) a->bgG) / 255.0; + bgcolor.b = ((float) a->bgB) / 255.0; + bgcolor.a = 1.0; + } + else + { + bgcolorref = GetSysColor(COLOR_BTNFACE); + bgcolor.r = ((float) GetRValue(bgcolorref)) / 255.0; + // due to utter apathy on Microsoft's part, GetGValue() does not work with MSVC's Run-Time Error Checks + // it has not worked since 2008 and they have *never* fixed it + // TODO now that -RTCc has just been deprecated entirely, should we switch back? + bgcolor.g = ((float) ((BYTE) ((bgcolorref & 0xFF00) >> 8))) / 255.0; + bgcolor.b = ((float) GetBValue(bgcolorref)) / 255.0; + bgcolor.a = 1.0; + } rt->Clear(&bgcolor); (*(ah->Draw))(ah, a, &dp); |