mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 18:45:23 -04:00
cleanup code a bit
This commit is contained in:
parent
ed71eaa588
commit
ab6df2cc7a
65
src/Menus.c
65
src/Menus.c
@ -49,19 +49,15 @@ struct SimpleButtonDesc { int x, y; const char* title; Widget_LeftClick onClick;
|
|||||||
*--------------------------------------------------------Menu base--------------------------------------------------------*
|
*--------------------------------------------------------Menu base--------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static void Menu_Button(void* s, int i, struct ButtonWidget* btn, int width, const String* text, const FontDesc* font, Widget_LeftClick onClick, int horAnchor, int verAnchor, int x, int y) {
|
static void Menu_Button(void* s, int i, struct ButtonWidget* btn, int width, const String* text, const FontDesc* font, Widget_LeftClick onClick, int horAnchor, int verAnchor, int x, int y) {
|
||||||
struct Menu* menu = (struct Menu*)s;
|
ButtonWidget_Make(btn, width, onClick, horAnchor, verAnchor, x, y);
|
||||||
ButtonWidget_Create(btn, width, text, font, onClick);
|
ButtonWidget_Set(btn, text, font);
|
||||||
|
((struct Menu*)s)->widgets[i] = (struct Widget*)btn;
|
||||||
menu->widgets[i] = (struct Widget*)btn;
|
|
||||||
Widget_SetLocation(menu->widgets[i], horAnchor, verAnchor, x, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Menu_Label(void* s, int i, struct TextWidget* label, const String* text, const FontDesc* font, int horAnchor, int verAnchor, int x, int y) {
|
static void Menu_Label(void* s, int i, struct TextWidget* label, const String* text, const FontDesc* font, int horAnchor, int verAnchor, int x, int y) {
|
||||||
struct Menu* menu = (struct Menu*)s;
|
TextWidget_Make(label, horAnchor, verAnchor, x, y);
|
||||||
TextWidget_Create(label, text, font);
|
TextWidget_Set(label, text, font);
|
||||||
|
((struct Menu*)s)->widgets[i] = (struct Widget*)label;
|
||||||
menu->widgets[i] = (struct Widget*)label;
|
|
||||||
Widget_SetLocation(menu->widgets[i], horAnchor, verAnchor, x, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Menu_Input(void* s, int i, struct MenuInputWidget* input, int width, const String* text, FontDesc* font, struct MenuInputDesc* desc, int horAnchor, int verAnchor, int x, int y) {
|
static void Menu_Input(void* s, int i, struct MenuInputWidget* input, int width, const String* text, FontDesc* font, struct MenuInputDesc* desc, int horAnchor, int verAnchor, int x, int y) {
|
||||||
@ -81,8 +77,7 @@ static void Menu_Back(void* s, int i, struct ButtonWidget* btn, const char* labe
|
|||||||
|
|
||||||
CC_NOINLINE static void Menu_MakeBack(struct ButtonWidget* btn, Widget_LeftClick onClick) {
|
CC_NOINLINE static void Menu_MakeBack(struct ButtonWidget* btn, Widget_LeftClick onClick) {
|
||||||
int width = Gui_ClassicMenu ? 400 : 200;
|
int width = Gui_ClassicMenu ? 400 : 200;
|
||||||
ButtonWidget_Make(btn, width, onClick);
|
ButtonWidget_Make(btn, width, onClick, ANCHOR_CENTRE, ANCHOR_MAX, 0, 25);
|
||||||
Widget_SetLocation(btn, ANCHOR_CENTRE, ANCHOR_MAX, 0, 25);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CC_NOINLINE static void Menu_MakeTitleFont(FontDesc* font) {
|
CC_NOINLINE static void Menu_MakeTitleFont(FontDesc* font) {
|
||||||
@ -416,21 +411,20 @@ static void ListScreen_Init(void* screen) {
|
|||||||
s->currentIndex = 0;
|
s->currentIndex = 0;
|
||||||
|
|
||||||
for (i = 0; i < LIST_SCREEN_ITEMS; i++) {
|
for (i = 0; i < LIST_SCREEN_ITEMS; i++) {
|
||||||
ButtonWidget_Make(&s->buttons[i], 300, s->EntryClick);
|
ButtonWidget_Make(&s->buttons[i], 300, s->EntryClick,
|
||||||
Widget_SetLocation(&s->buttons[i], ANCHOR_CENTRE, ANCHOR_CENTRE, 0, (i - 2) * 50);
|
ANCHOR_CENTRE, ANCHOR_CENTRE, 0, (i - 2) * 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonWidget_Make(&s->left, 40, ListScreen_MoveBackwards);
|
ButtonWidget_Make(&s->left, 40, ListScreen_MoveBackwards,
|
||||||
ButtonWidget_Make(&s->right, 40, ListScreen_MoveForwards);
|
ANCHOR_CENTRE, ANCHOR_CENTRE, -220, 0);
|
||||||
TextWidget_Make(&s->title);
|
ButtonWidget_Make(&s->right, 40, ListScreen_MoveForwards,
|
||||||
TextWidget_Make(&s->page);
|
ANCHOR_CENTRE, ANCHOR_CENTRE, 220, 0);
|
||||||
|
TextWidget_Make(&s->title,
|
||||||
|
ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -155);
|
||||||
|
TextWidget_Make(&s->page,
|
||||||
|
ANCHOR_CENTRE, ANCHOR_MAX, 0, 75);
|
||||||
|
|
||||||
Menu_MakeBack(&s->done, Menu_SwitchPause);
|
Menu_MakeBack(&s->done, Menu_SwitchPause);
|
||||||
|
|
||||||
Widget_SetLocation(&s->left, ANCHOR_CENTRE, ANCHOR_CENTRE, -220, 0);
|
|
||||||
Widget_SetLocation(&s->right, ANCHOR_CENTRE, ANCHOR_CENTRE, 220, 0);
|
|
||||||
Widget_SetLocation(&s->title, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -155);
|
|
||||||
Widget_SetLocation(&s->page, ANCHOR_CENTRE, ANCHOR_MAX, 0, 75);
|
|
||||||
|
|
||||||
Menu_MakeTitleFont(&s->font);
|
Menu_MakeTitleFont(&s->font);
|
||||||
s->LoadEntries(s);
|
s->LoadEntries(s);
|
||||||
}
|
}
|
||||||
@ -670,13 +664,12 @@ static void OptionsGroupScreen_Init(void* screen) {
|
|||||||
s->selectedI = -1;
|
s->selectedI = -1;
|
||||||
|
|
||||||
for (i = 0; i < Array_Elems(optsGroup_btns); i++) {
|
for (i = 0; i < Array_Elems(optsGroup_btns); i++) {
|
||||||
ButtonWidget_Make(&s->buttons[i], 300, optsGroup_btns[i].onClick);
|
ButtonWidget_Make(&s->buttons[i], 300, optsGroup_btns[i].onClick,
|
||||||
Widget_SetLocation(&s->buttons[i], ANCHOR_CENTRE, ANCHOR_CENTRE, optsGroup_btns[i].x, optsGroup_btns[i].y);
|
ANCHOR_CENTRE, ANCHOR_CENTRE, optsGroup_btns[i].x, optsGroup_btns[i].y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu_MakeBack(&s->done, Menu_SwitchPause);
|
Menu_MakeBack(&s->done, Menu_SwitchPause);
|
||||||
TextWidget_Make(&s->desc);
|
TextWidget_Make(&s->desc, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 100);
|
||||||
Widget_SetLocation(&s->desc, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OptionsGroupScreen_Free(void* screen) {
|
static void OptionsGroupScreen_Free(void* screen) {
|
||||||
@ -1024,17 +1017,15 @@ static void GenLevelScreen_Input(struct GenLevelScreen* s, int i, int y, bool se
|
|||||||
input->base.MenuClick = GenLevelScreen_InputClick;
|
input->base.MenuClick = GenLevelScreen_InputClick;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GenLevelScreen_Label(struct GenLevelScreen* s, int i, int x, int y, const char* title) {
|
static void GenLevelScreen_Label(struct GenLevelScreen* s, int i, int y, const char* title) {
|
||||||
struct TextWidget* label = &s->labels[i];
|
struct TextWidget* label = &s->labels[i];
|
||||||
PackedCol col = PACKEDCOL_CONST(224, 224, 224, 255);
|
PackedCol col = PACKEDCOL_CONST(224, 224, 224, 255);
|
||||||
|
|
||||||
String text = String_FromReadonly(title);
|
String text = String_FromReadonly(title);
|
||||||
Menu_Label(s, i + 4, label, &text, &s->textFont,
|
Menu_Label(s, i + 4, label, &text, &s->textFont,
|
||||||
ANCHOR_CENTRE, ANCHOR_CENTRE, x, y);
|
ANCHOR_CENTRE_MAX, ANCHOR_CENTRE, 110, y);
|
||||||
|
|
||||||
label->col = col;
|
label->col = col;
|
||||||
label->xOffset = -110 - label->width / 2;
|
|
||||||
Widget_Reposition(label);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool GenLevelScreen_KeyDown(void* screen, Key key) {
|
static bool GenLevelScreen_KeyDown(void* screen, Key key) {
|
||||||
@ -1064,10 +1055,10 @@ static void GenLevelScreen_ContextRecreated(void* screen) {
|
|||||||
GenLevelScreen_Input(s, 2, 0, false, World.Length);
|
GenLevelScreen_Input(s, 2, 0, false, World.Length);
|
||||||
GenLevelScreen_Input(s, 3, 40, true, 0);
|
GenLevelScreen_Input(s, 3, 40, true, 0);
|
||||||
|
|
||||||
GenLevelScreen_Label(s, 0, -150, -80, "Width:");
|
GenLevelScreen_Label(s, 0, -80, "Width:");
|
||||||
GenLevelScreen_Label(s, 1, -150, -40, "Height:");
|
GenLevelScreen_Label(s, 1, -40, "Height:");
|
||||||
GenLevelScreen_Label(s, 2, -150, 0, "Length:");
|
GenLevelScreen_Label(s, 2, 0, "Length:");
|
||||||
GenLevelScreen_Label(s, 3, -140, 40, "Seed:");
|
GenLevelScreen_Label(s, 3, 40, "Seed:");
|
||||||
|
|
||||||
Menu_Label(s, 8, &s->labels[4], &title, &s->textFont,
|
Menu_Label(s, 8, &s->labels[4], &title, &s->textFont,
|
||||||
ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -130);
|
ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -130);
|
||||||
|
@ -350,8 +350,7 @@ static void StatusScreen_ContextRecreated(void* screen) {
|
|||||||
Drawer2D_MakeFont(&s->font, 16, FONT_STYLE_NORMAL);
|
Drawer2D_MakeFont(&s->font, 16, FONT_STYLE_NORMAL);
|
||||||
|
|
||||||
y = 2;
|
y = 2;
|
||||||
TextWidget_Make(line1);
|
TextWidget_Make(line1, ANCHOR_MIN, ANCHOR_MIN, 2, y);
|
||||||
Widget_SetLocation(line1, ANCHOR_MIN, ANCHOR_MIN, 2, y);
|
|
||||||
line1->reducePadding = true;
|
line1->reducePadding = true;
|
||||||
StatusScreen_Update(s, 1.0);
|
StatusScreen_Update(s, 1.0);
|
||||||
|
|
||||||
@ -360,8 +359,7 @@ static void StatusScreen_ContextRecreated(void* screen) {
|
|||||||
s->posAtlas.tex.Y = y;
|
s->posAtlas.tex.Y = y;
|
||||||
|
|
||||||
y += s->posAtlas.tex.Height;
|
y += s->posAtlas.tex.Height;
|
||||||
TextWidget_Make(line2);
|
TextWidget_Make(line2, ANCHOR_MIN, ANCHOR_MIN, 2, y);
|
||||||
Widget_SetLocation(line2, ANCHOR_MIN, ANCHOR_MIN, 2, y);
|
|
||||||
line2->reducePadding = true;
|
line2->reducePadding = true;
|
||||||
|
|
||||||
if (Game_ClassicMode) {
|
if (Game_ClassicMode) {
|
||||||
@ -507,10 +505,8 @@ static void LoadingScreen_DrawBackground(void) {
|
|||||||
static void LoadingScreen_Init(void* screen) {
|
static void LoadingScreen_Init(void* screen) {
|
||||||
struct LoadingScreen* s = (struct LoadingScreen*)screen;
|
struct LoadingScreen* s = (struct LoadingScreen*)screen;
|
||||||
|
|
||||||
TextWidget_Make(&s->title);
|
TextWidget_Make(&s->title, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -31);
|
||||||
Widget_SetLocation(&s->title, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -31);
|
TextWidget_Make(&s->message, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 17);
|
||||||
TextWidget_Make(&s->message);
|
|
||||||
Widget_SetLocation(&s->message, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 17);
|
|
||||||
|
|
||||||
Gfx_SetFog(false);
|
Gfx_SetFog(false);
|
||||||
Event_RegisterFloat(&WorldEvents.Loading, s, LoadingScreen_MapLoading);
|
Event_RegisterFloat(&WorldEvents.Loading, s, LoadingScreen_MapLoading);
|
||||||
@ -734,8 +730,7 @@ static void HUDScreen_ConstructWidgets(struct HUDScreen* s) {
|
|||||||
Widget_SetLocation(&s->clientStatus, ANCHOR_MIN, ANCHOR_MAX, 10, yOffset);
|
Widget_SetLocation(&s->clientStatus, ANCHOR_MIN, ANCHOR_MAX, 10, yOffset);
|
||||||
Elem_Init(&s->clientStatus);
|
Elem_Init(&s->clientStatus);
|
||||||
|
|
||||||
TextWidget_Create(&s->announcement, &String_Empty, &s->announcementFont);
|
TextWidget_Make(&s->announcement, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -Window_Height / 4);
|
||||||
Widget_SetLocation(&s->announcement, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -Window_Height / 4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HUDScreen_SetInitialMessages(struct HUDScreen* s) {
|
static void HUDScreen_SetInitialMessages(struct HUDScreen* s) {
|
||||||
@ -1327,13 +1322,11 @@ static void DisconnectScreen_ContextRecreated(void* screen) {
|
|||||||
|
|
||||||
static void DisconnectScreen_Init(void* screen) {
|
static void DisconnectScreen_Init(void* screen) {
|
||||||
struct DisconnectScreen* s = (struct DisconnectScreen*)screen;
|
struct DisconnectScreen* s = (struct DisconnectScreen*)screen;
|
||||||
TextWidget_Make(&s->title);
|
TextWidget_Make(&s->title, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -30);
|
||||||
Widget_SetLocation(&s->title, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -30);
|
TextWidget_Make(&s->message, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 10);
|
||||||
TextWidget_Make(&s->message);
|
|
||||||
Widget_SetLocation(&s->message, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 10);
|
|
||||||
|
|
||||||
ButtonWidget_Make(&s->reconnect, 300, NULL);
|
ButtonWidget_Make(&s->reconnect, 300, NULL,
|
||||||
Widget_SetLocation(&s->reconnect, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 80);
|
ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 80);
|
||||||
s->reconnect.disabled = !s->canReconnect;
|
s->reconnect.disabled = !s->canReconnect;
|
||||||
|
|
||||||
/* NOTE: changing VSync can't be done within frame, causes crash on some GPUs */
|
/* NOTE: changing VSync can't be done within frame, causes crash on some GPUs */
|
||||||
|
@ -54,11 +54,12 @@ static struct WidgetVTABLE TextWidget_VTABLE = {
|
|||||||
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
||||||
TextWidget_Reposition,
|
TextWidget_Reposition,
|
||||||
};
|
};
|
||||||
void TextWidget_Make(struct TextWidget* w) {
|
void TextWidget_Make(struct TextWidget* w, uint8_t horAnchor, uint8_t verAnchor, int xOffset, int yOffset) {
|
||||||
PackedCol col = PACKEDCOL_WHITE;
|
PackedCol col = PACKEDCOL_WHITE;
|
||||||
Widget_Reset(w);
|
Widget_Reset(w);
|
||||||
w->VTABLE = &TextWidget_VTABLE;
|
w->VTABLE = &TextWidget_VTABLE;
|
||||||
w->col = col;
|
w->col = col;
|
||||||
|
Widget_SetLocation(w, horAnchor, verAnchor, xOffset, yOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWidget_Set(struct TextWidget* w, const String* text, const FontDesc* font) {
|
void TextWidget_Set(struct TextWidget* w, const String* text, const FontDesc* font) {
|
||||||
@ -87,11 +88,6 @@ void TextWidget_SetConst(struct TextWidget* w, const char* text, const FontDesc*
|
|||||||
TextWidget_Set(w, &str, font);
|
TextWidget_Set(w, &str, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextWidget_Create(struct TextWidget* w, const String* text, const FontDesc* font) {
|
|
||||||
TextWidget_Make(w);
|
|
||||||
TextWidget_Set(w, text, font);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------ButtonWidget-------------------------------------------------------*
|
*------------------------------------------------------ButtonWidget-------------------------------------------------------*
|
||||||
@ -161,12 +157,13 @@ static struct WidgetVTABLE ButtonWidget_VTABLE = {
|
|||||||
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
||||||
ButtonWidget_Reposition,
|
ButtonWidget_Reposition,
|
||||||
};
|
};
|
||||||
void ButtonWidget_Make(struct ButtonWidget* w, int minWidth, Widget_LeftClick onClick) {
|
void ButtonWidget_Make(struct ButtonWidget* w, int minWidth, Widget_LeftClick onClick, uint8_t horAnchor, uint8_t verAnchor, int xOffset, int yOffset) {
|
||||||
Widget_Reset(w);
|
Widget_Reset(w);
|
||||||
w->VTABLE = &ButtonWidget_VTABLE;
|
w->VTABLE = &ButtonWidget_VTABLE;
|
||||||
w->optName = NULL;
|
w->optName = NULL;
|
||||||
w->minWidth = minWidth;
|
w->minWidth = minWidth;
|
||||||
w->MenuClick = onClick;
|
w->MenuClick = onClick;
|
||||||
|
Widget_SetLocation(w, horAnchor, verAnchor, xOffset, yOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonWidget_Set(struct ButtonWidget* w, const String* text, const FontDesc* font) {
|
void ButtonWidget_Set(struct ButtonWidget* w, const String* text, const FontDesc* font) {
|
||||||
@ -191,11 +188,6 @@ void ButtonWidget_SetConst(struct ButtonWidget* w, const char* text, const FontD
|
|||||||
ButtonWidget_Set(w, &str, font);
|
ButtonWidget_Set(w, &str, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonWidget_Create(struct ButtonWidget* w, int minWidth, const String* text, const FontDesc* font, Widget_LeftClick onClick) {
|
|
||||||
ButtonWidget_Make(w, minWidth, onClick);
|
|
||||||
ButtonWidget_Set(w, text, font);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------ScrollbarWidget-----------------------------------------------------*
|
*-----------------------------------------------------ScrollbarWidget-----------------------------------------------------*
|
||||||
@ -256,7 +248,7 @@ static bool ScrollbarWidget_MouseDown(void* widget, int x, int y, MouseButton bt
|
|||||||
struct ScrollbarWidget* w = (struct ScrollbarWidget*)widget;
|
struct ScrollbarWidget* w = (struct ScrollbarWidget*)widget;
|
||||||
int posY, height;
|
int posY, height;
|
||||||
|
|
||||||
if (w->draggingMouse) return true;
|
if (w->draggingMouse) return true;
|
||||||
if (btn != MOUSE_LEFT) return false;
|
if (btn != MOUSE_LEFT) return false;
|
||||||
if (x < w->x || x >= w->x + w->width) return false;
|
if (x < w->x || x >= w->x + w->width) return false;
|
||||||
|
|
||||||
@ -2094,7 +2086,6 @@ static void PlayerListWidget_TabEntryRemoved(void* widget, int id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void PlayerListWidget_Init(void* widget) {
|
static void PlayerListWidget_Init(void* widget) {
|
||||||
static const String title = String_FromConst("Connected players:");
|
|
||||||
struct PlayerListWidget* w = (struct PlayerListWidget*)widget;
|
struct PlayerListWidget* w = (struct PlayerListWidget*)widget;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
@ -2103,9 +2094,9 @@ static void PlayerListWidget_Init(void* widget) {
|
|||||||
PlayerListWidget_AddName(w, (EntityID)id, -1);
|
PlayerListWidget_AddName(w, (EntityID)id, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerListWidget_SortAndReposition(w);
|
PlayerListWidget_SortAndReposition(w);
|
||||||
TextWidget_Create(&w->title, &title, w->font);
|
TextWidget_Make(&w->title, ANCHOR_CENTRE, ANCHOR_MIN, 0, 0);
|
||||||
Widget_SetLocation(&w->title, ANCHOR_CENTRE, ANCHOR_MIN, 0, 0);
|
TextWidget_SetConst(&w->title, "Connected players:", w->font);
|
||||||
|
|
||||||
Event_RegisterInt(&TabListEvents.Added, w, PlayerListWidget_TabEntryAdded);
|
Event_RegisterInt(&TabListEvents.Added, w, PlayerListWidget_TabEntryAdded);
|
||||||
Event_RegisterInt(&TabListEvents.Changed, w, PlayerListWidget_TabEntryChanged);
|
Event_RegisterInt(&TabListEvents.Changed, w, PlayerListWidget_TabEntryChanged);
|
||||||
|
@ -16,14 +16,13 @@ struct TextWidget {
|
|||||||
bool reducePadding;
|
bool reducePadding;
|
||||||
PackedCol col;
|
PackedCol col;
|
||||||
};
|
};
|
||||||
/* Resets state of the given text widget to default. */
|
/* Initialises a text widget. */
|
||||||
CC_NOINLINE void TextWidget_Make(struct TextWidget* w);
|
CC_NOINLINE void TextWidget_Make(struct TextWidget* w,
|
||||||
|
uint8_t horAnchor, uint8_t verAnchor, int xOffset, int yOffset);
|
||||||
/* Draws the given text into a texture, then updates the position and size of this widget. */
|
/* Draws the given text into a texture, then updates the position and size of this widget. */
|
||||||
CC_NOINLINE void TextWidget_Set(struct TextWidget* w, const String* text, const FontDesc* font);
|
CC_NOINLINE void TextWidget_Set(struct TextWidget* w, const String* text, const FontDesc* font);
|
||||||
/* Shorthand for TextWidget_Set using String_FromReadonly */
|
/* Shorthand for TextWidget_Set using String_FromReadonly */
|
||||||
CC_NOINLINE void TextWidget_SetConst(struct TextWidget* w, const char* text, const FontDesc* font);
|
CC_NOINLINE void TextWidget_SetConst(struct TextWidget* w, const char* text, const FontDesc* font);
|
||||||
/* Shorthand for TextWidget_Make then TextWidget_Set */
|
|
||||||
CC_NOINLINE void TextWidget_Create(struct TextWidget* w, const String* text, const FontDesc* font);
|
|
||||||
|
|
||||||
|
|
||||||
typedef void (*Button_Get)(String* raw);
|
typedef void (*Button_Get)(String* raw);
|
||||||
@ -38,14 +37,13 @@ struct ButtonWidget {
|
|||||||
Button_Get GetValue;
|
Button_Get GetValue;
|
||||||
Button_Set SetValue;
|
Button_Set SetValue;
|
||||||
};
|
};
|
||||||
/* Resets state of the given button widget to default. */
|
/* Initialises a button widget. */
|
||||||
CC_NOINLINE void ButtonWidget_Make(struct ButtonWidget* w, int minWidth, Widget_LeftClick onClick);
|
CC_NOINLINE void ButtonWidget_Make(struct ButtonWidget* w, int minWidth, Widget_LeftClick onClick,
|
||||||
|
uint8_t horAnchor, uint8_t verAnchor, int xOffset, int yOffset);
|
||||||
/* Draws the given text into a texture, then updates the position and size of this widget. */
|
/* Draws the given text into a texture, then updates the position and size of this widget. */
|
||||||
CC_NOINLINE void ButtonWidget_Set(struct ButtonWidget* w, const String* text, const FontDesc* font);
|
CC_NOINLINE void ButtonWidget_Set(struct ButtonWidget* w, const String* text, const FontDesc* font);
|
||||||
/* Shorthand for ButtonWidget_Set using String_FromReadonly */
|
/* Shorthand for ButtonWidget_Set using String_FromReadonly */
|
||||||
CC_NOINLINE void ButtonWidget_SetConst(struct ButtonWidget* w, const char* text, const FontDesc* font);
|
CC_NOINLINE void ButtonWidget_SetConst(struct ButtonWidget* w, const char* text, const FontDesc* font);
|
||||||
/* Resets state of the given button widget, then calls ButtonWidget_Set */
|
|
||||||
CC_NOINLINE void ButtonWidget_Create(struct ButtonWidget* w, int minWidth, const String* text, const FontDesc* font, Widget_LeftClick onClick);
|
|
||||||
|
|
||||||
/* Clickable and draggable scrollbar. */
|
/* Clickable and draggable scrollbar. */
|
||||||
struct ScrollbarWidget {
|
struct ScrollbarWidget {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user