mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 18:45:23 -04:00
Simpify button/text widget texture creation
This commit is contained in:
parent
add56ce622
commit
38bda8e1cd
@ -76,13 +76,12 @@ void TextWidget_Init(struct TextWidget* w) {
|
|||||||
void TextWidget_Set(struct TextWidget* w, const cc_string* text, struct FontDesc* font) {
|
void TextWidget_Set(struct TextWidget* w, const cc_string* text, struct FontDesc* font) {
|
||||||
struct DrawTextArgs args;
|
struct DrawTextArgs args;
|
||||||
Gfx_DeleteTexture(&w->tex.ID);
|
Gfx_DeleteTexture(&w->tex.ID);
|
||||||
|
DrawTextArgs_Make(&args, text, font, true);
|
||||||
|
Drawer2D_MakeTextTexture(&w->tex, &args);
|
||||||
|
|
||||||
if (Drawer2D_IsEmptyText(text)) {
|
/* Give text widget default height when text is empty */
|
||||||
w->tex.Width = 0;
|
if (!w->tex.Height) {
|
||||||
w->tex.Height = Drawer2D_FontHeight(font, true);
|
w->tex.Height = Drawer2D_FontHeight(font, true);
|
||||||
} else {
|
|
||||||
DrawTextArgs_Make(&args, text, font, true);
|
|
||||||
Drawer2D_MakeTextTexture(&w->tex, &args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
w->width = w->tex.Width; w->height = w->tex.Height;
|
w->width = w->tex.Width; w->height = w->tex.Height;
|
||||||
@ -233,13 +232,12 @@ void ButtonWidget_Init(struct ButtonWidget* w, int minWidth, Widget_LeftClick on
|
|||||||
void ButtonWidget_Set(struct ButtonWidget* w, const cc_string* text, struct FontDesc* font) {
|
void ButtonWidget_Set(struct ButtonWidget* w, const cc_string* text, struct FontDesc* font) {
|
||||||
struct DrawTextArgs args;
|
struct DrawTextArgs args;
|
||||||
Gfx_DeleteTexture(&w->tex.ID);
|
Gfx_DeleteTexture(&w->tex.ID);
|
||||||
|
DrawTextArgs_Make(&args, text, font, true);
|
||||||
|
Drawer2D_MakeTextTexture(&w->tex, &args);
|
||||||
|
|
||||||
if (Drawer2D_IsEmptyText(text)) {
|
/* Give button default height when text is empty */
|
||||||
w->tex.Width = 0;
|
if (!w->tex.Height) {
|
||||||
w->tex.Height = Drawer2D_FontHeight(font, true);
|
w->tex.Height = Drawer2D_FontHeight(font, true);
|
||||||
} else {
|
|
||||||
DrawTextArgs_Make(&args, text, font, true);
|
|
||||||
Drawer2D_MakeTextTexture(&w->tex, &args);
|
|
||||||
}
|
}
|
||||||
Widget_Layout(w);
|
Widget_Layout(w);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user