Skip to content

Commit f3ea970

Browse files
committed
UI: set widget default colours from output
1 parent 3a59e22 commit f3ea970

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/ui/form.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ extern "C" void v_create_form(var_p_t var) {
282282
}
283283

284284
if (hasInputs) {
285+
set_input_defaults(out->getColor(), out->getBackgroundColor());
285286
map_set(var, arg);
286287
var_p_t v_focus = map_get(var, FORM_FOCUS);
287288
unsigned i_focus = v_focus != NULL ? v_getint(v_focus) : -1;

src/ui/inputs.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ extern System *g_system;
2121
FormList *activeList = NULL;
2222
FormInput *focusInput = NULL;
2323
FormEditInput *focusEdit = NULL;
24+
int background = DEFAULT_BACKGROUND;
25+
int foreground = DEFAULT_FOREGROUND;
2426

2527
#define LINE_Y (_height - 2)
2628
#define LINE_W (_width - 2)
@@ -39,6 +41,11 @@ bool form_ui::optionSelected(int index) {
3941
return result;
4042
}
4143

44+
void set_input_defaults(int fg, int bg) {
45+
foreground = fg;
46+
background = bg;
47+
}
48+
4249
int get_color(var_p_t value, int def) {
4350
int result = def;
4451
if (value != NULL && value->type == V_INT) {
@@ -107,8 +114,8 @@ FormInput::FormInput(int x, int y, int w, int h) :
107114
_visible(true),
108115
_noFocus(false),
109116
_resizable(false),
110-
_bg(DEFAULT_BACKGROUND),
111-
_fg(DEFAULT_FOREGROUND),
117+
_bg(background),
118+
_fg(foreground),
112119
_onclick(0) {
113120
}
114121

src/ui/inputs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ namespace form_ui {
7575
bool optionSelected(int index);
7676
};
7777

78+
void set_input_defaults(int fg, int bg);
7879
int get_color(var_p_t value, int def);
7980

8081
struct IFormWidgetListModel {

0 commit comments

Comments
 (0)