Adjust text in inputboxes

This commit is contained in:
MysterD 2023-04-02 15:34:47 -07:00
parent 072c36c558
commit 8f2f46fbdc
2 changed files with 6 additions and 2 deletions

View file

@ -19,7 +19,7 @@ static void djui_font_normal_render_char(char* c) {
}
static f32 djui_font_normal_char_width(char* c) {
if (*c == ' ') { return 0.30f; }
if (*c == ' ') { return 0.20f; }
extern const f32 font_normal_widths[];
return djui_unicode_get_sprite_width(c, font_normal_widths);
}

View file

@ -476,6 +476,10 @@ static bool djui_inputbox_render(struct DjuiBase* base) {
const struct DjuiFont* font = gDjuiFonts[0];
djui_rect_render(base);
// Shift the text away from the left side a tad
comp->x += 2;
comp->width -= 2;
// shift the viewing window to keep the selection in view
djui_inputbox_keep_selection_in_view(inputbox);
@ -483,7 +487,7 @@ static bool djui_inputbox_render(struct DjuiBase* base) {
f32 translatedX = comp->x + inputbox->viewX;
f32 translatedY = comp->y + DJUI_INPUTBOX_YOFF;
djui_gfx_position_translate(&translatedX, &translatedY);
create_dl_translation_matrix(DJUI_MTX_PUSH, (int)translatedX, (int)translatedY, 0);
create_dl_translation_matrix(DJUI_MTX_PUSH, translatedX, translatedY, 0);
// compute font size
f32 translatedFontSize = font->defaultFontScale;