use children[0] for the hitbox in PtkClickable
This commit is contained in:
parent
3231124346
commit
db65f8d5bf
3 changed files with 3 additions and 9 deletions
|
@ -59,7 +59,6 @@ PTK_COMPONENT_DEFINE(PtkEllipse,
|
|||
typedef void (*MouseButtonCallback)(const int button, const int action, const int mods);
|
||||
|
||||
PTK_COMPONENT_DEFINE(PtkClickable,
|
||||
PtkHandle hitbox;
|
||||
MouseButtonCallback on_press;
|
||||
);
|
||||
|
||||
|
|
|
@ -190,9 +190,10 @@ PtkHandle ptk_clickable(PtkHandle hitbox, const MouseButtonCallback on_press) {
|
|||
PtkClickable *ret = malloc(sizeof(PtkClickable));
|
||||
*ret = (PtkClickable){
|
||||
.type = PTK_COMPONENT_TYPE_CLICKABLE,
|
||||
.hitbox = hitbox,
|
||||
.children = PTK_LIST_NEW(PtkHandle, 1),
|
||||
.on_press = on_press,
|
||||
};
|
||||
PTK_LIST_ADD(PtkHandle, ret->children, hitbox);
|
||||
|
||||
return (PtkHandle)ret;
|
||||
}
|
||||
|
|
|
@ -90,12 +90,6 @@ void vk_component(PtkHandle component) {
|
|||
|
||||
PTK_LIST_ADD(PtkHandle, m_components, component);
|
||||
|
||||
if (component->type == PTK_COMPONENT_TYPE_CLICKABLE) {
|
||||
PtkClickable *c = (PtkClickable *)component;
|
||||
vk_component(c->hitbox);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (component->type) {
|
||||
case PTK_COMPONENT_TYPE_TRIANGLE: {
|
||||
triangle((PtkTriangle *)component, 0);
|
||||
|
@ -162,7 +156,7 @@ bool intersects(const PtkHandle component, const PtkPos point) {
|
|||
case PTK_COMPONENT_TYPE_ELLIPSE:
|
||||
return ellipse_intersects(*(PtkEllipse *)component, point);
|
||||
case PTK_COMPONENT_TYPE_CLICKABLE:
|
||||
return intersects(((PtkClickable *)component)->hitbox, point);
|
||||
return intersects(component->children.data[0], point);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue