DJUI: Added button style for back button

This commit is contained in:
MysterD 2021-06-28 18:25:06 -07:00
parent fc1db575bd
commit df20408a93
10 changed files with 21 additions and 2 deletions

View file

@ -2,11 +2,18 @@
static void djui_button_set_default_style(struct DjuiBase* base) {
struct DjuiButton* button = (struct DjuiButton*)base;
djui_base_set_border_color(base, 150, 150, 150, 255);
djui_base_set_color(&button->rect->base, 200, 200, 200, 255);
u8 borderBrightness = button->style ? 100 : 150;
u8 rectBrightness = button->style ? 150 : 222;
djui_base_set_border_color(base, borderBrightness, borderBrightness, borderBrightness, 255);
djui_base_set_color(&button->rect->base, rectBrightness, rectBrightness, rectBrightness, 255);
djui_base_set_location(&button->text->base, 0.0f, 0.0f);
}
void djui_button_set_style(struct DjuiButton* button, u8 style) {
button->style = style;
djui_button_set_default_style(&button->base);
}
static void djui_button_on_hover(struct DjuiBase* base) {
struct DjuiButton* button = (struct DjuiButton*)base;
djui_base_set_border_color(base, 0, 120, 215, 255);
@ -44,6 +51,7 @@ struct DjuiButton* djui_button_create(struct DjuiBase* parent, const char* messa
djui_interactable_create(base);
djui_interactable_hook_hover(base, djui_button_on_hover, djui_button_on_hover_end);
djui_interactable_hook_cursor_down(base, djui_button_on_cursor_down_begin, NULL, djui_button_on_cursor_down_end);
button->style = 0;
struct DjuiRect* rect = djui_rect_create(&button->base);
djui_base_set_size_type(&rect->base, DJUI_SVT_RELATIVE, DJUI_SVT_RELATIVE);

View file

@ -6,6 +6,9 @@ struct DjuiButton {
struct DjuiBase base;
struct DjuiRect* rect;
struct DjuiText* text;
u8 style;
};
void djui_button_set_style(struct DjuiButton* button, u8 style);
struct DjuiButton* djui_button_create(struct DjuiBase* parent, const char* message);

View file

@ -54,6 +54,7 @@ void djui_panel_camera_create(struct DjuiBase* caller) {
struct DjuiButton* button6 = djui_button_create(&body->base, "Back");
djui_base_set_size_type(&button6->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button6->base, 1.0f, 64);
djui_button_set_style(button6, 1);
djui_interactable_hook_click(&button6->base, djui_panel_menu_back);
}

View file

@ -41,6 +41,7 @@ void djui_panel_controls_create(struct DjuiBase* caller) {
struct DjuiButton* button6 = djui_button_create(&body->base, "Back");
djui_base_set_size_type(&button6->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button6->base, 1.0f, 64);
djui_button_set_style(button6, 1);
djui_interactable_hook_click(&button6->base, djui_panel_menu_back);
}

View file

@ -37,6 +37,7 @@ void djui_panel_display_create(struct DjuiBase* caller) {
struct DjuiButton* button6 = djui_button_create(&body->base, "Back");
djui_base_set_size_type(&button6->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button6->base, 1.0f, 64);
djui_button_set_style(button6, 1);
djui_interactable_hook_click(&button6->base, djui_panel_menu_back);
}

View file

@ -45,6 +45,7 @@ void djui_panel_host_create(struct DjuiBase* caller) {
djui_base_set_size_type(&button1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button1->base, 0.485f, 64);
djui_base_set_alignment(&button1->base, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP);
djui_button_set_style(button1, 1);
djui_interactable_hook_click(&button1->base, djui_panel_menu_back);
struct DjuiButton* button2 = djui_button_create(&rect1->base, "Host");

View file

@ -55,6 +55,7 @@ void djui_panel_host_message_create(struct DjuiBase* caller) {
djui_base_set_size_type(&button1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button1->base, 0.485f, 64);
djui_base_set_alignment(&button1->base, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP);
djui_button_set_style(button1, 1);
djui_interactable_hook_click(&button1->base, djui_panel_menu_back);
struct DjuiButton* button2 = djui_button_create(&rect1->base, "Host");

View file

@ -34,6 +34,7 @@ void djui_panel_main_create(struct DjuiBase* caller) {
struct DjuiButton* button4 = djui_button_create(&body->base, "Quit");
djui_base_set_size_type(&button4->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button4->base, 1.0f, 64);
djui_button_set_style(button4, 1);
djui_interactable_hook_click(&button4->base, djui_panel_quit_create);
}

View file

@ -37,6 +37,7 @@ void djui_panel_options_create(struct DjuiBase* caller) {
struct DjuiButton* button6 = djui_button_create(&body->base, "Back");
djui_base_set_size_type(&button6->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button6->base, 1.0f, 64);
djui_button_set_style(button6, 1);
djui_interactable_hook_click(&button6->base, djui_panel_menu_back);
}

View file

@ -30,6 +30,7 @@ void djui_panel_sound_create(struct DjuiBase* caller) {
struct DjuiButton* button6 = djui_button_create(&body->base, "Back");
djui_base_set_size_type(&button6->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button6->base, 1.0f, 64);
djui_button_set_style(button6, 1);
djui_interactable_hook_click(&button6->base, djui_panel_menu_back);
}