Launcher: Truly fixed font selection scrolling now...

This commit is contained in:
Alex Duchesne 2021-04-22 15:32:26 -04:00
parent 604ed69788
commit 6894ea35fd
4 changed files with 12 additions and 7 deletions

View File

@ -119,12 +119,15 @@ static rg_glyph_t get_glyph(const rg_font_t *font, int points, int c)
return out;
}
bool rg_gui_set_font_type(uint8_t type)
bool rg_gui_set_font_type(int type)
{
// if (type > fonts_count - 1)
// return false;
if (type < 0)
type += fonts_count;
font_info.type = type % fonts_count;
if (type < 0 || type > fonts_count - 1)
return false;
font_info.type = type;
font_info.font = fonts[font_info.type];
font_info.points = (font_info.type < 3) ? (8 + font_info.type * 4) : font_info.font->height;
font_info.width = RG_MAX(font_info.font->width, 4);

View File

@ -101,7 +101,7 @@ struct dialog_option_s
void rg_gui_init(void);
bool rg_gui_set_theme(const dialog_theme_t *new_theme);
bool rg_gui_set_font_type(uint8_t type);
bool rg_gui_set_font_type(int type);
font_info_t rg_gui_get_font_info(void);
rg_rect_t rg_gui_calc_text_size(const char *text, uint32_t flags);
rg_rect_t rg_gui_draw_text(int x_pos, int y_pos, int width, const char *text, uint16_t color_fg, uint16_t color_bg, uint32_t flags);

View File

@ -21,12 +21,13 @@ static dialog_return_t font_type_cb(dialog_option_t *option, dialog_event_t even
font_info_t info = rg_gui_get_font_info();
if (event == RG_DIALOG_PREV) {
rg_gui_set_font_type(info.type > 0 ? info.type - 1 : 0xFF);
rg_gui_set_font_type((int)info.type - 1);
info = rg_gui_get_font_info();
gui_redraw();
}
if (event == RG_DIALOG_NEXT) {
rg_gui_set_font_type(rg_gui_get_font_info().type + 1);
if (!rg_gui_set_font_type((int)info.type + 1))
rg_gui_set_font_type(0);
info = rg_gui_get_font_info();
gui_redraw();
}

View File

@ -61,6 +61,7 @@
"smsplusgx",
"supergraphx"
],
"files.trimTrailingWhitespace": true,
"files.exclude": {
"**/build": true,
"root": true