Added label clamping.

This commit is contained in:
2021-09-08 23:16:22 -07:00
parent 13f0345ba0
commit ef366f7e5b
4 changed files with 5 additions and 2 deletions

View File

@ -14,6 +14,7 @@
typedef struct {
font_t *font;
float fontSize;
float maxWidth;
fonttextinfo_t info;
primitive_t primitive;
} label_t;

View File

@ -48,7 +48,7 @@ void sandboxSceneUpdate(sandboxscene_t *game, engine_t *engine) {
gridSetSize(&menu.menu.grid,
engine->render.width, engine->render.height,
engine->render.width, FONT_LINE_HEIGHT * fontGetScale(16.0f) * 3,
100.0f, FONT_LINE_HEIGHT * fontGetScale(16.0f) * 3,
0, 0
);
menu2Update(&menu.menu, engine);

View File

@ -10,6 +10,7 @@
void labelInit(label_t *label) {
label->fontSize = FONT_SIZE_DEFAULT;
label->font = NULL;
label->maxWidth = -1;
label->primitive.verticeCount = 0;
}
@ -20,7 +21,7 @@ void labelSetText(label_t *label, font_t *font, char *text) {
}
label->font = font;
fontTextClamp(font, &label->info, text, -1, label->fontSize);
fontTextClamp(font, &label->info, text, label->maxWidth, label->fontSize);
fontTextInit(font, &label->primitive, &label->info);
}

View File

@ -28,6 +28,7 @@ void _textMenuOnResize(
info->y = y;
info->width = width;
info->height = height;
label->maxWidth = width;
labelSetText(label, textMenu->font, textMenu->texts[i]);
}