diff --git a/src/jinete/jintern.cpp b/src/jinete/jintern.cpp index ad847d251..5baeaf87c 100644 --- a/src/jinete/jintern.cpp +++ b/src/jinete/jintern.cpp @@ -113,7 +113,7 @@ bool _ji_is_valid_widget(JWidget widget) (*widgets)[widget->id]->id == widget->id); } -void _ji_set_font_of_all_widgets(struct FONT *f) +void _ji_set_font_of_all_widgets(FONT* f) { size_t c; @@ -122,18 +122,26 @@ void _ji_set_font_of_all_widgets(struct FONT *f) if (_ji_is_valid_widget((*widgets)[c])) (*widgets)[c]->setFont(f); - /* then we can reinitialize the theme of each widget */ - for (c=0; csize(); c++) - if (_ji_is_valid_widget((*widgets)[c])) - jwidget_init_theme((*widgets)[c]); +} - /* remap the windows */ +void _ji_reinit_theme_in_all_widgets() +{ + size_t c; + + // Then we can reinitialize the theme of each widget + for (c=0; csize(); c++) + if (_ji_is_valid_widget((*widgets)[c])) { + (*widgets)[c]->theme = ji_get_theme(); + jwidget_init_theme((*widgets)[c]); + } + + // Remap the windows for (c=0; csize(); c++) if (_ji_is_valid_widget((*widgets)[c])) { if ((*widgets)[c]->type == JI_FRAME) static_cast((*widgets)[c])->remap_window(); } - /* refresh the screen */ + // Refresh the screen jmanager_refresh_screen(); } diff --git a/src/jinete/jintern.h b/src/jinete/jintern.h index b46deec2d..0151fb12b 100644 --- a/src/jinete/jintern.h +++ b/src/jinete/jintern.h @@ -48,7 +48,8 @@ void _ji_add_widget(JWidget widget); void _ji_remove_widget(JWidget widget); bool _ji_is_valid_widget(JWidget widget); -void _ji_set_font_of_all_widgets(struct FONT *f); +void _ji_set_font_of_all_widgets(FONT* f); +void _ji_reinit_theme_in_all_widgets(); ////////////////////////////////////////////////////////////////////// // jwindow.c diff --git a/src/modules/gui.cpp b/src/modules/gui.cpp index 374232567..0606983b5 100644 --- a/src/modules/gui.cpp +++ b/src/modules/gui.cpp @@ -146,6 +146,8 @@ static JList icon_buttons; static bool double_buffering; static int screen_scaling; +static void reload_default_font(); + /* load & save graphics configuration */ static void load_gui_config(int& w, int& h, int& bpp, bool& fullscreen, bool& maximized); static void save_gui_config(); @@ -523,6 +525,7 @@ void gui_feedback() void gui_setup_screen(bool reload_font) { bool regen = false; + bool reinit = false; // Double buffering is required when screen scaling is used double_buffering = (screen_scaling > 1); @@ -554,18 +557,25 @@ void gui_setup_screen(bool reload_font) regen = true; } - if (reload_font) + if (reload_font) { reload_default_font(); + reinit = true; + } // Regenerate the theme - if (regen) + if (regen) { ji_regen_theme(); + reinit = true; + } + + if (reinit) + _ji_reinit_theme_in_all_widgets(); // Set the configuration save_gui_config(); } -void reload_default_font() +static void reload_default_font() { JTheme theme = ji_get_theme(); const char *user_font; diff --git a/src/modules/gui.h b/src/modules/gui.h index 1f83313d0..551974e4d 100644 --- a/src/modules/gui.h +++ b/src/modules/gui.h @@ -73,8 +73,6 @@ void gui_run(); void gui_feedback(); void gui_setup_screen(bool reload_font); -void reload_default_font(); - void load_window_pos(Widget* window, const char *section); void save_window_pos(Widget* window, const char *section);