Added label clamping.
This commit is contained in:
@ -14,6 +14,7 @@
|
||||
typedef struct {
|
||||
font_t *font;
|
||||
float fontSize;
|
||||
float maxWidth;
|
||||
fonttextinfo_t info;
|
||||
primitive_t primitive;
|
||||
} label_t;
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user