libui: add API for setting a background color for uiArea. (TODO: do for GTK)
make window background black.
This commit is contained in:
parent
b96ac8e000
commit
8e6d834f13
|
@ -334,6 +334,7 @@ _UI_EXTERN void uiAreaScrollTo(uiArea *a, double x, double y, double width, doub
|
|||
// TODO release capture?
|
||||
_UI_EXTERN void uiAreaBeginUserWindowMove(uiArea *a);
|
||||
_UI_EXTERN void uiAreaBeginUserWindowResize(uiArea *a, uiWindowResizeEdge edge);
|
||||
_UI_EXTERN void uiAreaSetBackgroundColor(uiArea *a, int r, int g, int b);
|
||||
_UI_EXTERN uiArea *uiNewArea(uiAreaHandler *ah);
|
||||
_UI_EXTERN uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@ struct uiArea {
|
|||
BOOL inside;
|
||||
BOOL tracking;
|
||||
|
||||
int bgR, bgG, bgB;
|
||||
|
||||
ID2D1HwndRenderTarget *rt;
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -313,13 +313,6 @@ void OnAreaDraw(uiAreaHandler* handler, uiArea* area, uiAreaDrawParams* params)
|
|||
uiDrawBitmapDraw(params->Context, ScreenBitmap, &top, &TopScreenRect);
|
||||
uiDrawRestore(params->Context);
|
||||
|
||||
/*uiDrawMatrix blirg;
|
||||
uiDrawMatrixSetIdentity(&blirg);
|
||||
uiDrawMatrixTranslate(&blirg, -BottomScreenRect.X, -BottomScreenRect.Y);
|
||||
uiDrawMatrixRotate(&blirg, 0, 0, -M_PI/2.0f);//3.14);
|
||||
uiDrawMatrixTranslate(&blirg, BottomScreenRect.X, BottomScreenRect.Y+BottomScreenRect.Height);
|
||||
//uiDrawMatrixScale(&blirg, 128, 192, 2, 2);
|
||||
uiDrawTransform(params->Context, &blirg);*/
|
||||
uiDrawSave(params->Context);
|
||||
uiDrawTransform(params->Context, &BottomScreenTrans);
|
||||
uiDrawBitmapDraw(params->Context, ScreenBitmap, &bot, &BottomScreenRect);
|
||||
|
@ -422,6 +415,9 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt)
|
|||
for (int i = 0; i < 12; i++)
|
||||
if (evt->Scancode == Config::KeyMapping[i])
|
||||
KeyInputMask &= ~(1<<i);
|
||||
|
||||
//if (evt->Scancode == 0x58) // F12
|
||||
// NDS::debug(0);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -1081,6 +1077,7 @@ int main(int argc, char** argv)
|
|||
MainDrawArea = uiNewArea(&areahandler);
|
||||
uiWindowSetChild(MainWindow, uiControl(MainDrawArea));
|
||||
uiControlSetMinSize(uiControl(MainDrawArea), 256, 384);
|
||||
uiAreaSetBackgroundColor(MainDrawArea, 0, 0, 0); // TODO: make configurable?
|
||||
|
||||
EmuRunning = 2;
|
||||
RunningSomething = false;
|
||||
|
|
Loading…
Reference in New Issue