summaryrefslogtreecommitdiff
path: root/src/ui/widget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-07-25 14:24:06 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-07-25 14:24:06 +0300
commit570818dfd9f979a04375bbe0657139c62df34387 (patch)
tree96b39d2be9333c3d728ac89cb1c3054670c6585f /src/ui/widget.c
parent40421af6e6571b58b97b3e3372641de3b3ba60d8 (diff)
Widget: Drawing optional frames
Diffstat (limited to 'src/ui/widget.c')
-rw-r--r--src/ui/widget.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 69509e33..e83532d4 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -45,6 +45,7 @@ void init_Widget(iWidget *d) {
45 d->flags = 0; 45 d->flags = 0;
46 d->rect = zero_Rect(); 46 d->rect = zero_Rect();
47 d->bgColor = none_ColorId; 47 d->bgColor = none_ColorId;
48 d->frameColor = none_ColorId;
48 d->children = NULL; 49 d->children = NULL;
49 d->parent = NULL; 50 d->parent = NULL;
50 d->commandHandler = NULL; 51 d->commandHandler = NULL;
@@ -114,6 +115,10 @@ void setBackgroundColor_Widget(iWidget *d, int bgColor) {
114 d->bgColor = bgColor; 115 d->bgColor = bgColor;
115} 116}
116 117
118void setFrameColor_Widget(iWidget *d, int frameColor) {
119 d->frameColor = frameColor;
120}
121
117void setCommandHandler_Widget(iWidget *d, iBool (*handler)(iWidget *, const char *)) { 122void setCommandHandler_Widget(iWidget *d, iBool (*handler)(iWidget *, const char *)) {
118 d->commandHandler = handler; 123 d->commandHandler = handler;
119} 124}
@@ -392,10 +397,16 @@ iBool processEvent_Widget(iWidget *d, const SDL_Event *ev) {
392 397
393void draw_Widget(const iWidget *d) { 398void draw_Widget(const iWidget *d) {
394 if (d->flags & hidden_WidgetFlag) return; 399 if (d->flags & hidden_WidgetFlag) return;
395 if (d->bgColor >= 0) { 400 if (d->bgColor >= 0 || d->frameColor >= 0) {
401 const iRect rect = bounds_Widget(d);
396 iPaint p; 402 iPaint p;
397 init_Paint(&p); 403 init_Paint(&p);
398 fillRect_Paint(&p, bounds_Widget(d), d->bgColor); 404 if (d->bgColor >= 0) {
405 fillRect_Paint(&p, rect, d->bgColor);
406 }
407 if (d->frameColor >= 0) {
408 drawRect_Paint(&p, rect, d->frameColor);
409 }
399 } 410 }
400 iConstForEach(ObjectList, i, d->children) { 411 iConstForEach(ObjectList, i, d->children) {
401 const iWidget *child = constAs_Widget(i.object); 412 const iWidget *child = constAs_Widget(i.object);