mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 05:25:14 +00:00
DJUI: Made cursor hover location control-configurable
This commit is contained in:
parent
a89dd55081
commit
c0ec2caac1
6 changed files with 35 additions and 2 deletions
|
@ -81,6 +81,11 @@ void djui_base_set_alignment(struct DjuiBase* base, enum DjuiHAlign hAlign, enum
|
|||
// utility //
|
||||
/////////////
|
||||
|
||||
static void djui_base_get_cursor_hover_location(struct DjuiBase* base, f32* x, f32* y) {
|
||||
*x = (base->elem.x + base->elem.width * 3.0f / 4.0f);
|
||||
*y = (base->elem.y + base->elem.height * 3.0f / 4.0f);
|
||||
}
|
||||
|
||||
static void djui_base_clip(struct DjuiBase* base) {
|
||||
struct DjuiBase* parent = base->parent;
|
||||
struct DjuiBaseRect* comp = &base->comp;
|
||||
|
@ -363,6 +368,7 @@ void djui_base_init(struct DjuiBase* parent, struct DjuiBase* base, void(*render
|
|||
djui_base_set_enabled(base, true);
|
||||
djui_base_set_size(base, 64, 64);
|
||||
djui_base_set_color(base, 255, 255, 255, 255);
|
||||
base->get_cursor_hover_location = djui_base_get_cursor_hover_location;
|
||||
base->render = render;
|
||||
base->destroy = destroy;
|
||||
djui_base_add_child(parent, base);
|
||||
|
|
|
@ -44,6 +44,7 @@ struct DjuiBase {
|
|||
struct DjuiBaseRect clip;
|
||||
struct DjuiInteractable* interactable;
|
||||
s32 tag;
|
||||
void (*get_cursor_hover_location)(struct DjuiBase*, f32* x, f32* y);
|
||||
void (*on_child_render)(struct DjuiBase*, struct DjuiBase*);
|
||||
void (*on_render_pre)(struct DjuiBase*, bool*);
|
||||
void (*render)(struct DjuiBase*);
|
||||
|
|
|
@ -15,6 +15,13 @@ static void djui_checkbox_on_hover(struct DjuiBase* base) {
|
|||
djui_base_set_color(&checkbox->rectValue->base, 229, 241, 251, 255);
|
||||
}
|
||||
|
||||
static void djui_checkbox_get_cursor_hover_location(struct DjuiBase* base, f32* x, f32* y) {
|
||||
struct DjuiCheckbox* checkbox = (struct DjuiCheckbox*)base;
|
||||
struct DjuiBase* rectBase = &checkbox->rect->base;
|
||||
*x = (rectBase->elem.x + rectBase->elem.width * 3.0f / 4.0f);
|
||||
*y = (rectBase->elem.y + rectBase->elem.height * 3.0f / 4.0f);
|
||||
}
|
||||
|
||||
static void djui_checkbox_on_hover_end(struct DjuiBase* base) {
|
||||
djui_checkbox_set_default_style(base);
|
||||
}
|
||||
|
@ -78,5 +85,7 @@ struct DjuiCheckbox* djui_checkbox_create(struct DjuiBase* parent, const char* m
|
|||
|
||||
djui_checkbox_set_default_style(base);
|
||||
|
||||
base->get_cursor_hover_location = djui_checkbox_get_cursor_hover_location;
|
||||
|
||||
return checkbox;
|
||||
}
|
||||
|
|
|
@ -33,8 +33,7 @@ bool djui_cursor_inside_base(struct DjuiBase* base) {
|
|||
}
|
||||
|
||||
static void djui_cursor_base_hover_location(struct DjuiBase* base, f32* x, f32* y) {
|
||||
*x = (base->elem.x + base->elem.width * 3.0f / 4.0f);
|
||||
*y = (base->elem.y + base->elem.height * 3.0f / 4.0f);
|
||||
base->get_cursor_hover_location(base, x, y);
|
||||
}
|
||||
|
||||
void djui_cursor_input_controlled_center(struct DjuiBase* base) {
|
||||
|
|
|
@ -16,6 +16,13 @@ static void djui_selectionbox_set_default_style(struct DjuiBase* base) {
|
|||
djui_base_set_color(&selectionbox->text->base, 200, 200, 200, 255);
|
||||
}
|
||||
|
||||
static void djui_selectionbox_get_cursor_hover_location(struct DjuiBase* base, f32* x, f32* y) {
|
||||
struct DjuiSelectionbox* selectionbox = (struct DjuiSelectionbox*)base;
|
||||
struct DjuiBase* rectBase = &selectionbox->rect->base;
|
||||
*x = (rectBase->elem.x + rectBase->elem.width * 3.0f / 4.0f);
|
||||
*y = (rectBase->elem.y + rectBase->elem.height * 3.0f / 4.0f);
|
||||
}
|
||||
|
||||
static void djui_selectionbox_on_hover(struct DjuiBase* base) {
|
||||
struct DjuiSelectionbox* selectionbox = (struct DjuiSelectionbox*)base;
|
||||
f32 x = selectionbox->rect->base.elem.x;
|
||||
|
@ -119,5 +126,7 @@ struct DjuiSelectionbox* djui_selectionbox_create(struct DjuiBase* parent, const
|
|||
|
||||
djui_selectionbox_set_default_style(base);
|
||||
|
||||
base->get_cursor_hover_location = djui_selectionbox_get_cursor_hover_location;
|
||||
|
||||
return selectionbox;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,13 @@ static void djui_slider_set_default_style(struct DjuiBase* base) {
|
|||
djui_base_set_color(&slider->rectValue->base, 200, 200, 200, 255);
|
||||
}
|
||||
|
||||
static void djui_slider_get_cursor_hover_location(struct DjuiBase* base, f32* x, f32* y) {
|
||||
struct DjuiSlider* slider = (struct DjuiSlider*)base;
|
||||
struct DjuiBase* rectBase = &slider->rect->base;
|
||||
*x = (rectBase->elem.x + rectBase->elem.width * 3.0f / 4.0f);
|
||||
*y = (rectBase->elem.y + rectBase->elem.height * 3.0f / 4.0f);
|
||||
}
|
||||
|
||||
static void djui_slider_on_hover(struct DjuiBase* base) {
|
||||
struct DjuiSlider* slider = (struct DjuiSlider*)base;
|
||||
f32 x = slider->rect->base.elem.x;
|
||||
|
@ -143,5 +150,7 @@ struct DjuiSlider* djui_slider_create(struct DjuiBase* parent, const char* messa
|
|||
djui_slider_update_value(base);
|
||||
djui_slider_set_default_style(base);
|
||||
|
||||
base->get_cursor_hover_location = djui_slider_get_cursor_hover_location;
|
||||
|
||||
return slider;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue