Skip to content

Commit 2ccd549

Browse files
Allow for text to be created with an arbitrarily colored background
1 parent 17c6be1 commit 2ccd549

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

GUI.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ namespace
306306
template<> constexpr auto draw_text<const char*> = &al_draw_text;
307307
template<> constexpr auto draw_text<const ALLEGRO_USTR*> = &al_draw_ustr;
308308

309-
void draw_border(const ALLEGRO_FONT* font, ALLEGRO_COLOR color, float x, float y, int flags, auto ustr)
309+
void draw_color_border(const ALLEGRO_FONT* font, ALLEGRO_COLOR text_color, ALLEGRO_COLOR border_color, float x, float y, int flags, auto ustr)
310310
{
311311
using T = decltype(ustr);
312312
int xx = 0;
@@ -321,8 +321,13 @@ namespace
321321
else if (flags & ALLEGRO_ALIGN_RIGHT) {
322322
xx -= ww;
323323
}
324-
al_draw_filled_rectangle(x + xx, y, x + xx + ww, y + hh, al_map_rgba_f(0.0, 0.0, 0.0, 0.75));
325-
draw_text<T>(font, color, x, y, flags, ustr);
324+
al_draw_filled_rectangle(x + xx, y, x + xx + ww, y + hh, border_color);
325+
draw_text<T>(font, text_color, x, y, flags, ustr);
326+
}
327+
328+
void draw_border(const ALLEGRO_FONT* font, ALLEGRO_COLOR color, float x, float y, int flags, auto ustr)
329+
{
330+
draw_color_border(font, color, al_map_rgba_f(0.0, 0.0, 0.0, 0.75), x, y, flags, ustr);
326331
}
327332
}
328333

@@ -336,6 +341,16 @@ void draw_ustr_border(const ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, fl
336341
draw_border(font, color, x, y, flags, ustr);
337342
}
338343

344+
void draw_color_text_border(const ALLEGRO_FONT* font, ALLEGRO_COLOR text_color, ALLEGRO_COLOR border_color, float x, float y, int flags, const char* ustr)
345+
{
346+
draw_color_border(font, text_color, border_color, x, y, flags, ustr);
347+
}
348+
349+
void draw_color_ustr_border(const ALLEGRO_FONT* font, ALLEGRO_COLOR text_color, ALLEGRO_COLOR border_color, float x, float y, int flags, const ALLEGRO_USTR* ustr)
350+
{
351+
draw_color_border(font, text_color, border_color, x, y, flags, ustr);
352+
}
353+
339354
namespace
340355
{
341356
void draw_report_border(const ALLEGRO_FONT* font, float x, float y, int flags, const df::report* report)

GUI.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ void paintboard();
1414
void draw_textf_border(const ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int flags, const char *format, ...);
1515
void draw_text_border(const ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int flags, const char *ustr);
1616
void draw_ustr_border(const ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int flags, const ALLEGRO_USTR *ustr);
17+
void draw_color_text_border(const ALLEGRO_FONT* font, ALLEGRO_COLOR text_color, ALLEGRO_COLOR border_color, float x, float y, int flags, const char* ustr);
18+
void draw_color_ustr_border(const ALLEGRO_FONT* font, ALLEGRO_COLOR text_color, ALLEGRO_COLOR border_color, float x, float y, int flags, const ALLEGRO_USTR* ustr);
1719
ALLEGRO_BITMAP* getImgFile(int index);
1820
void flushImgFiles();
1921
//returns index into getImgFile. Will only create new bitmaps when needed

0 commit comments

Comments
 (0)