Split _ji_set_font_of_all_widgets() in _ji_reinit_theme_in_all_widgets().

This commit is contained in:
David Capello 2010-03-09 00:43:28 -02:00
parent 719374718d
commit c8b84732cd
4 changed files with 30 additions and 13 deletions

View File

@ -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; c<widgets->size(); 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; c<widgets->size(); 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; c<widgets->size(); c++)
if (_ji_is_valid_widget((*widgets)[c])) {
if ((*widgets)[c]->type == JI_FRAME)
static_cast<Frame*>((*widgets)[c])->remap_window();
}
/* refresh the screen */
// Refresh the screen
jmanager_refresh_screen();
}

View File

@ -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

View File

@ -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;

View File

@ -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);