(Lakka) Use theme font + responsive font size

This commit is contained in:
Jean-André Santoni 2014-11-07 15:05:59 +01:00
parent 7c81cabe83
commit 82e67e7605
9 changed files with 75 additions and 14 deletions

View File

@ -370,7 +370,7 @@ typedef struct video_poke_interface
void (*set_texture_enable)(void *data, bool enable, bool full_screen);
#endif
void (*set_osd_msg)(void *data, const char *msg,
const struct font_params *params);
const struct font_params *params, void *font);
void (*show_mouse)(void *data, bool state);
void (*grab_mouse_toggle)(void *data);

View File

@ -3021,7 +3021,7 @@ static void gl_apply_state_changes(void *data)
}
static void gl_set_osd_msg(void *data, const char *msg,
const struct font_params *params)
const struct font_params *params, void *font)
{
gl_t *gl = (gl_t*)data;
if (!gl)
@ -3030,7 +3030,7 @@ static void gl_set_osd_msg(void *data, const char *msg,
if (gl->font_driver && gl->font_handle)
{
context_bind_hw_render(gl, false);
gl->font_driver->render_msg(gl->font_handle, msg, params);
gl->font_driver->render_msg(font ? font : gl->font_handle, msg, params);
context_bind_hw_render(gl, true);
}
}

View File

@ -671,7 +671,7 @@ void sdl2_poke_texture_enable(void *data, bool enable, bool full_screen)
vid->menu.active = enable;
}
void sdl2_poke_set_osd_msg(void *data, const char *msg, const struct font_params *params)
void sdl2_poke_set_osd_msg(void *data, const char *msg, const struct font_params *params, void *font)
{
sdl2_video_t *vid = (sdl2_video_t*)data;
sdl2_render_msg(vid, msg);

View File

@ -262,10 +262,22 @@ static void thread_loop(void *data)
if (thr->poke && thr->poke->set_osd_msg)
thr->poke->set_osd_msg(thr->driver_data,
thr->cmd_data.osd_message.msg,
&thr->cmd_data.osd_message.params);
&thr->cmd_data.osd_message.params, NULL);
thread_reply(thr, CMD_POKE_SET_OSD_MSG);
break;
case CMD_FONT_INIT:
if (thr->cmd_data.font_init.method)
thr->cmd_data.font_init.return_value =
thr->cmd_data.font_init.method
(thr->cmd_data.font_init.font_driver,
thr->cmd_data.font_init.font_handle,
thr->cmd_data.font_init.video_data,
thr->cmd_data.font_init.font_path,
thr->cmd_data.font_init.font_size);
thread_reply(thr, CMD_FONT_INIT);
break;
case CMD_CUSTOM_COMMAND:
if (thr->cmd_data.custom_command.method)
thr->cmd_data.custom_command.return_value =
@ -724,7 +736,8 @@ static void thread_set_texture_enable(void *data, bool state, bool full_screen)
}
#endif
static void thread_set_osd_msg(void *data, const char *msg, const struct font_params *params)
static void thread_set_osd_msg(void *data, const char *msg,
const struct font_params *params, void *font)
{
thread_video_t *thr = (thread_video_t*)data;
@ -735,7 +748,7 @@ static void thread_set_osd_msg(void *data, const char *msg, const struct font_pa
#endif
{
if (thr->poke && thr->poke->set_osd_msg)
thr->poke->set_osd_msg(thr->driver_data, msg, params);
thr->poke->set_osd_msg(thr->driver_data, msg, params, font);
}
#if 0
else

View File

@ -55,6 +55,7 @@ enum thread_cmd
#endif
CMD_POKE_SET_ASPECT_RATIO,
CMD_POKE_SET_OSD_MSG,
CMD_FONT_INIT,
CMD_CUSTOM_COMMAND,
CMD_DUMMY = INT_MAX
@ -158,6 +159,16 @@ typedef struct thread_video
int return_value;
} custom_command;
struct
{
bool (*method)(void*, void*, void*, const char*, float);
void *font_driver;
void *font_handle;
void *video_data;
const char *font_path;
float font_size;
bool return_value;
} font_init;
} cmd_data;

View File

@ -61,7 +61,7 @@ static void glui_blit_line(float x, float y, const char *message, bool green)
if (driver.video_data && driver.video_poke
&& driver.video_poke->set_osd_msg)
driver.video_poke->set_osd_msg(driver.video_data,
message, &params);
message, &params, NULL);
}
static void glui_render_background(bool force_transparency)

View File

@ -123,7 +123,7 @@ static void lakka_draw_text(lakka_handle_t *lakka,
if (driver.video_data && driver.video_poke
&& driver.video_poke->set_osd_msg)
driver.video_poke->set_osd_msg(driver.video_data,
str, &params);
str, &params, lakka->font);
}
static void lakka_draw_background(bool force_transparency)
@ -654,12 +654,35 @@ static GLuint lakka_png_texture_load(const char* file_name)
thr->wait_reply_func(thr, CMD_CUSTOM_COMMAND);
return thr->cmd_data.custom_command.return_value;
}
return lakka_png_texture_load_(file_name);
}
static bool lakka_font_init_first(const gl_font_renderer_t **font_driver,
void **font_handle, void *video_data, const char *font_path,
float font_size)
{
if (g_settings.video.threaded
&& !g_extern.system.hw_render_callback.context_type)
{
thread_video_t *thr = (thread_video_t*)driver.video_data;
thr->cmd_data.font_init.method = gl_font_init_first;
thr->cmd_data.font_init.font_driver = font_driver;
thr->cmd_data.font_init.font_handle = font_handle;
thr->cmd_data.font_init.video_data = video_data;
thr->cmd_data.font_init.font_path = font_path;
thr->cmd_data.font_init.font_size = font_size;
thr->send_cmd_func(thr, CMD_FONT_INIT);
thr->wait_reply_func(thr, CMD_FONT_INIT);
return thr->cmd_data.font_init.return_value;
}
return gl_font_init_first(font_driver, font_handle, video_data,
font_path, font_size);
}
static void lakka_context_destroy(void *data)
{
int i, j, k;
@ -861,9 +884,10 @@ static void lakka_settings_context_reset(void)
static void lakka_context_reset(void *data)
{
int i, j, k;
char mediapath[PATH_MAX], themepath[PATH_MAX], iconpath[PATH_MAX];
char mediapath[PATH_MAX], themepath[PATH_MAX], iconpath[PATH_MAX], font_path[PATH_MAX];
lakka_handle_t *lakka = NULL;
menu_handle_t *menu = (menu_handle_t*)data;
gl_t *gl = NULL;
if (!menu)
return;
@ -873,6 +897,11 @@ static void lakka_context_reset(void *data)
if (!lakka)
return;
gl = (gl_t*)driver_video_resolve(NULL);
if (!gl)
return;
#if defined(HAVE_FBO) && defined(LAKKA_EFFECTS)
lakka_fbo_reset(lakka);
#endif
@ -884,6 +913,11 @@ static void lakka_context_reset(void *data)
fill_pathname_join(themepath, mediapath, THEME, sizeof(themepath));
fill_pathname_join(iconpath, themepath, lakka->icon_dir, sizeof(iconpath));
fill_pathname_slash(iconpath, sizeof(iconpath));
fill_pathname_join(font_path, themepath, "font.ttf", sizeof(font_path));
lakka_font_init_first(&gl->font_driver, &lakka->font, gl, font_path, lakka->font_size);
//gl_font_init_first(&gl->font_driver, &lakka->font, gl, font_path, lakka->font_size);
fill_pathname_join(lakka->textures[TEXTURE_BG].path, iconpath,
"bg.png", sizeof(lakka->textures[TEXTURE_BG].path));
@ -1204,14 +1238,15 @@ static void *lakka_init(void)
strlcpy(lakka->icon_dir, "256", sizeof(lakka->icon_dir));
lakka->icon_size = 128.0 * lakka->scale_factor;
lakka->font_size = 32.0 * lakka->scale_factor;
lakka->hspacing = 200.0 * lakka->scale_factor;
lakka->vspacing = 64.0 * lakka->scale_factor;
lakka->margin_left = 336.0 * lakka->scale_factor;
lakka->margin_top = (256+32) * lakka->scale_factor;
lakka->title_margin_left = 60 * lakka->scale_factor;
lakka->title_margin_top = 60 * lakka->scale_factor + g_settings.video.font_size/3;
lakka->title_margin_top = 60 * lakka->scale_factor + lakka->font_size/3;
lakka->label_margin_left = 85.0 * lakka->scale_factor;
lakka->label_margin_top = g_settings.video.font_size/3.0;
lakka->label_margin_top = lakka->font_size/3.0;
lakka->setting_margin_left = 600.0 * lakka->scale_factor;
lakka->depth = 0;

View File

@ -127,6 +127,8 @@ typedef struct lakka_handle
GLuint fbo;
GLuint fbo_color;
GLuint fbo_depth;
void *font;
int font_size;
} lakka_handle_t;
#endif /* MENU_DISP_LAKKA_H */

View File

@ -222,7 +222,7 @@ static void xmb_draw_text(const char *str, float x,
if (driver.video_data && driver.video_poke
&& driver.video_poke->set_osd_msg)
driver.video_poke->set_osd_msg(driver.video_data,
str, &params);
str, &params, NULL);
}
static void xmb_render_background(bool force_transparency)