[melonDS] uiAreaSetBackgroundColor
This commit is contained in:
parent
5bd78c1932
commit
3ea407f050
1
ui.h
1
ui.h
|
@ -343,6 +343,7 @@ _UI_EXTERN void uiAreaScrollTo(uiArea *a, double x, double y, double width, doub
|
||||||
// TODO release capture?
|
// TODO release capture?
|
||||||
_UI_EXTERN void uiAreaBeginUserWindowMove(uiArea *a);
|
_UI_EXTERN void uiAreaBeginUserWindowMove(uiArea *a);
|
||||||
_UI_EXTERN void uiAreaBeginUserWindowResize(uiArea *a, uiWindowResizeEdge edge);
|
_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 *uiNewArea(uiAreaHandler *ah);
|
||||||
_UI_EXTERN uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height);
|
_UI_EXTERN uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height);
|
||||||
|
|
||||||
|
|
17
unix/area.c
17
unix/area.c
|
@ -37,6 +37,7 @@ struct uiArea {
|
||||||
GtkWidget *areaWidget;
|
GtkWidget *areaWidget;
|
||||||
GtkDrawingArea *drawingArea;
|
GtkDrawingArea *drawingArea;
|
||||||
areaWidget *area;
|
areaWidget *area;
|
||||||
|
int bgR, bgG, bgB;
|
||||||
|
|
||||||
uiAreaHandler *ah;
|
uiAreaHandler *ah;
|
||||||
|
|
||||||
|
@ -133,6 +134,11 @@ static gboolean areaWidget_draw(GtkWidget *w, cairo_t *cr)
|
||||||
dp.ClipWidth = clipX1 - clipX0;
|
dp.ClipWidth = clipX1 - clipX0;
|
||||||
dp.ClipHeight = clipY1 - clipY0;
|
dp.ClipHeight = clipY1 - clipY0;
|
||||||
|
|
||||||
|
if (a->bgR != -1) {
|
||||||
|
cairo_set_source_rgb(cr, a->bgR/255.0, a->bgG/255.0, a->bgB/255.0);
|
||||||
|
cairo_paint(cr);
|
||||||
|
}
|
||||||
|
|
||||||
// no need to save or restore the graphics state to reset transformations; GTK+ does that for us
|
// no need to save or restore the graphics state to reset transformations; GTK+ does that for us
|
||||||
(*(a->ah->Draw))(a->ah, a, &dp);
|
(*(a->ah->Draw))(a->ah, a, &dp);
|
||||||
|
|
||||||
|
@ -496,6 +502,13 @@ static void areaWidget_class_init(areaWidgetClass *class)
|
||||||
|
|
||||||
uiUnixControlAllDefaults(uiArea)
|
uiUnixControlAllDefaults(uiArea)
|
||||||
|
|
||||||
|
void uiAreaSetBackgroundColor(uiArea *a, int r, int g, int b)
|
||||||
|
{
|
||||||
|
a->bgR = r;
|
||||||
|
a->bgG = g;
|
||||||
|
a->bgB = b;
|
||||||
|
}
|
||||||
|
|
||||||
void uiAreaSetSize(uiArea *a, int width, int height)
|
void uiAreaSetSize(uiArea *a, int width, int height)
|
||||||
{
|
{
|
||||||
if (!a->scrolling)
|
if (!a->scrolling)
|
||||||
|
@ -603,6 +616,8 @@ uiArea *uiNewArea(uiAreaHandler *ah)
|
||||||
|
|
||||||
a->widget = a->areaWidget;
|
a->widget = a->areaWidget;
|
||||||
|
|
||||||
|
uiAreaSetBackgroundColor(a, -1, -1, -1);
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -629,6 +644,8 @@ uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height)
|
||||||
|
|
||||||
a->widget = a->swidget;
|
a->widget = a->swidget;
|
||||||
|
|
||||||
|
uiAreaSetBackgroundColor(a, -1, -1, -1);
|
||||||
|
|
||||||
gtk_container_add(a->scontainer, a->areaWidget);
|
gtk_container_add(a->scontainer, a->areaWidget);
|
||||||
// and make the area visible; only the scrolled window's visibility is controlled by libui
|
// and make the area visible; only the scrolled window's visibility is controlled by libui
|
||||||
gtk_widget_show(a->areaWidget);
|
gtk_widget_show(a->areaWidget);
|
||||||
|
|
|
@ -160,6 +160,13 @@ void uiAreaBeginUserWindowResize(uiArea *a, uiWindowResizeEdge edge)
|
||||||
wParam, 0);
|
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 *uiNewArea(uiAreaHandler *ah)
|
||||||
{
|
{
|
||||||
uiArea *a;
|
uiArea *a;
|
||||||
|
@ -177,6 +184,8 @@ uiArea *uiNewArea(uiAreaHandler *ah)
|
||||||
hInstance, a,
|
hInstance, a,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
|
uiAreaSetBackgroundColor(a, -1, -1, -1);
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,6 +208,8 @@ uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height)
|
||||||
hInstance, a,
|
hInstance, a,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
|
uiAreaSetBackgroundColor(a, -1, -1, -1);
|
||||||
|
|
||||||
// set initial scrolling parameters
|
// set initial scrolling parameters
|
||||||
areaUpdateScroll(a);
|
areaUpdateScroll(a);
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ struct uiArea {
|
||||||
BOOL inside;
|
BOOL inside;
|
||||||
BOOL tracking;
|
BOOL tracking;
|
||||||
|
|
||||||
|
int bgR, bgG, bgB;
|
||||||
|
|
||||||
ID2D1HwndRenderTarget *rt;
|
ID2D1HwndRenderTarget *rt;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -40,14 +40,21 @@ static HRESULT doPaint(uiArea *a, ID2D1RenderTarget *rt, RECT *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);
|
if (a->bgR != -1) {
|
||||||
bgcolor.r = ((float) GetRValue(bgcolorref)) / 255.0;
|
bgcolor.r = ((float) a->bgR) / 255.0;
|
||||||
// due to utter apathy on Microsoft's part, GetGValue() does not work with MSVC's Run-Time Error Checks
|
bgcolor.g = ((float) a->bgG) / 255.0;
|
||||||
// it has not worked since 2008 and they have *never* fixed it
|
bgcolor.b = ((float) a->bgB) / 255.0;
|
||||||
// TODO now that -RTCc has just been deprecated entirely, should we switch back?
|
bgcolor.a = 1.0;
|
||||||
bgcolor.g = ((float) ((BYTE) ((bgcolorref & 0xFF00) >> 8))) / 255.0;
|
} else {
|
||||||
bgcolor.b = ((float) GetBValue(bgcolorref)) / 255.0;
|
bgcolorref = GetSysColor(COLOR_BTNFACE);
|
||||||
bgcolor.a = 1.0;
|
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);
|
rt->Clear(&bgcolor);
|
||||||
|
|
||||||
(*(ah->Draw))(ah, a, &dp);
|
(*(ah->Draw))(ah, a, &dp);
|
||||||
|
|
Loading…
Reference in New Issue