diff --git a/src/pc/djui/djui_font.c b/src/pc/djui/djui_font.c index 0acdda320..96f408ddf 100644 --- a/src/pc/djui/djui_font.c +++ b/src/pc/djui/djui_font.c @@ -92,7 +92,7 @@ static const struct DjuiFont sDjuiFontTitle = { // font list // /////////////// -struct DjuiFont gDjuiFonts[] = { - sDjuiFontNormal, - sDjuiFontTitle, +const struct DjuiFont* gDjuiFonts[] = { + &sDjuiFontNormal, + &sDjuiFontTitle, }; \ No newline at end of file diff --git a/src/pc/djui/djui_font.h b/src/pc/djui/djui_font.h index fda22bfdd..8caa50238 100644 --- a/src/pc/djui/djui_font.h +++ b/src/pc/djui/djui_font.h @@ -14,4 +14,4 @@ struct DjuiFont { f32 (*char_width)(char); }; -extern struct DjuiFont gDjuiFonts[]; \ No newline at end of file +extern const struct DjuiFont* gDjuiFonts[]; \ No newline at end of file diff --git a/src/pc/djui/djui_inputbox.c b/src/pc/djui/djui_inputbox.c index fbc63c7da..3ac1c290b 100644 --- a/src/pc/djui/djui_inputbox.c +++ b/src/pc/djui/djui_inputbox.c @@ -68,8 +68,8 @@ static void djui_inputbox_on_hover_end(struct DjuiBase* base) { } static u16 djui_inputbox_get_cursor_index(struct DjuiInputbox* inputbox) { - struct DjuiBaseRect* comp = &inputbox->base.comp; - struct DjuiFont* font = &gDjuiFonts[0]; + struct DjuiBaseRect* comp = &inputbox->base.comp; + const struct DjuiFont* font = gDjuiFonts[0]; f32 cX = (gCursorX - (comp->x + inputbox->viewX)) / font->defaultFontScale; f32 x = 0; @@ -364,8 +364,8 @@ static void djui_inputbox_on_text_input(struct DjuiBase *base, char* text) { } static void djui_inputbox_render_char(struct DjuiInputbox* inputbox, char c, f32* drawX, f32* additionalShift) { - struct DjuiBaseRect* comp = &inputbox->base.comp; - struct DjuiFont* font = &gDjuiFonts[0]; + struct DjuiBaseRect* comp = &inputbox->base.comp; + const struct DjuiFont* font = gDjuiFonts[0]; f32 dX = comp->x + *drawX; f32 dY = comp->y + DJUI_INPUTBOX_YOFF; f32 dW = font->charWidth * font->defaultFontScale; @@ -385,7 +385,7 @@ static void djui_inputbox_render_char(struct DjuiInputbox* inputbox, char c, f32 } static void djui_inputbox_render_selection(struct DjuiInputbox* inputbox) { - struct DjuiFont* font = &gDjuiFonts[0]; + const struct DjuiFont* font = gDjuiFonts[0]; // make selection well formed u16 selection[2] = { 0 }; @@ -448,7 +448,7 @@ static void djui_inputbox_render_selection(struct DjuiInputbox* inputbox) { } static void djui_inputbox_keep_selection_in_view(struct DjuiInputbox* inputbox) { - struct DjuiFont* font = &gDjuiFonts[0]; + const struct DjuiFont* font = gDjuiFonts[0]; // calculate where our cursor is f32 cursorX = inputbox->viewX; @@ -468,7 +468,7 @@ static void djui_inputbox_keep_selection_in_view(struct DjuiInputbox* inputbox) static void djui_inputbox_render(struct DjuiBase* base) { struct DjuiInputbox* inputbox = (struct DjuiInputbox*)base; struct DjuiBaseRect* comp = &base->comp; - struct DjuiFont* font = &gDjuiFonts[0]; + const struct DjuiFont* font = gDjuiFonts[0]; djui_rect_render(base); // shift the viewing window to keep the selection in view diff --git a/src/pc/djui/djui_panel_debug.c b/src/pc/djui/djui_panel_debug.c index 23c2cae01..28886470e 100644 --- a/src/pc/djui/djui_panel_debug.c +++ b/src/pc/djui/djui_panel_debug.c @@ -51,7 +51,7 @@ void djui_panel_debug_create(void) { djui_base_set_color(&sDjuiText2->base, 255, 255, 255, 255); djui_text_set_drop_shadow(sDjuiText2, 255, 0, 0, 255); djui_text_set_alignment(sDjuiText2, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP); - djui_text_set_font(sDjuiText2, &gDjuiFonts[1]); + djui_text_set_font(sDjuiText2, gDjuiFonts[1]); struct DjuiText* alphabet = djui_text_create(&gDjuiRoot->base, "abcdefghijklmnopqrstuvwxyz\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n01234567890\nthe quick brown fox jumps over the lazy dog\ngeqkbnfjsortelydg\nTHE QUICK BROWN FOX JUMPS OVER THE LAZY DOG\nGEQKBNFJSORTELYDG"); djui_base_set_location(&alphabet->base, 0, 0); @@ -61,6 +61,6 @@ void djui_panel_debug_create(void) { djui_base_set_color(&alphabet->base, 255, 255, 255, 255); djui_text_set_drop_shadow(alphabet, 255, 0, 0, 255); djui_text_set_alignment(alphabet, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER); - djui_text_set_font(alphabet, &gDjuiFonts[1]); + djui_text_set_font(alphabet, gDjuiFonts[1]); djui_text_set_font_scale(alphabet, 64); } diff --git a/src/pc/djui/djui_panel_menu.c b/src/pc/djui/djui_panel_menu.c index da82b96c1..c4b57e5c4 100644 --- a/src/pc/djui/djui_panel_menu.c +++ b/src/pc/djui/djui_panel_menu.c @@ -21,8 +21,8 @@ struct DjuiThreePanel* djui_panel_menu_create(f32 bodyHeight, char* headerText) djui_base_set_color(&header->base, 255, 8, 0, 255); djui_base_set_location(&header->base, 0, DJUI_PANEL_HEADER_OFFSET); djui_text_set_alignment(header, DJUI_HALIGN_CENTER, DJUI_VALIGN_BOTTOM); - djui_text_set_font(header, &gDjuiFonts[1]); - djui_text_set_font_scale(header, gDjuiFonts[1].defaultFontScale); + djui_text_set_font(header, gDjuiFonts[1]); + djui_text_set_font_scale(header, gDjuiFonts[1]->defaultFontScale); struct DjuiFlowLayout* body = djui_flow_layout_create(&panel->base); djui_base_set_alignment(&body->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER); diff --git a/src/pc/djui/djui_text.c b/src/pc/djui/djui_text.c index a493b600f..19be44322 100644 --- a/src/pc/djui/djui_text.c +++ b/src/pc/djui/djui_text.c @@ -23,7 +23,7 @@ void djui_text_set_text(struct DjuiText* text, const char* message) { memcpy(text->message, message, sizeof(char) * (messageLen + 1)); } -void djui_text_set_font(struct DjuiText* text, struct DjuiFont* font) { +void djui_text_set_font(struct DjuiText* text, const struct DjuiFont* font) { text->font = font; } @@ -385,7 +385,7 @@ struct DjuiText* djui_text_create(struct DjuiBase* parent, const char* message) djui_base_init(parent, base, djui_text_render, djui_text_destroy); text->message = NULL; - djui_text_set_font(text, &gDjuiFonts[0]); + djui_text_set_font(text, gDjuiFonts[0]); djui_text_set_font_scale(text, text->font->defaultFontScale); djui_text_set_text(text, message); djui_text_set_alignment(text, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP); diff --git a/src/pc/djui/djui_text.h b/src/pc/djui/djui_text.h index 401eb3c14..7f15c5d75 100644 --- a/src/pc/djui/djui_text.h +++ b/src/pc/djui/djui_text.h @@ -5,7 +5,7 @@ struct DjuiText { struct DjuiBase base; char* message; - struct DjuiFont* font; + const struct DjuiFont* font; f32 fontScale; struct DjuiColor dropShadow; enum DjuiHAlign textHAlign; @@ -13,7 +13,7 @@ struct DjuiText { }; void djui_text_set_text(struct DjuiText* text, const char* message); -void djui_text_set_font(struct DjuiText* text, struct DjuiFont* font); +void djui_text_set_font(struct DjuiText* text, const struct DjuiFont* font); void djui_text_set_font_scale(struct DjuiText* text, f32 fontScale); void djui_text_set_drop_shadow(struct DjuiText* text, f32 r, f32 g, f32 b, f32 a); void djui_text_set_alignment(struct DjuiText* text, enum DjuiHAlign hAlign, enum DjuiVAlign vAlign);