Handle ui_noodle return states and start introducing connected nodes
This commit is contained in:
parent
a68d6997a5
commit
f2faa56e5f
@ -171,10 +171,32 @@ i32 run_main_loop(void) {
|
||||
*ln = line_from_origin(origin, new_angle, DEFAULT_NOODLE_LENGTH);
|
||||
}
|
||||
|
||||
if (ui_noodle(main_window, &(comp.ctx), *ln, node_elem->colours,
|
||||
switch (ui_noodle(main_window, &(comp.ctx), *ln, node_elem->colours,
|
||||
node_elem->rec)) {
|
||||
case NOODLE_ACTION_DRAGGING:
|
||||
ln->p0.x += comp.ctx.rel_x;
|
||||
ln->p0.y += comp.ctx.rel_y;
|
||||
break;
|
||||
case NOODLE_ACTION_RELEASED:
|
||||
for (u64 k = 0; k < comp.count; ++k) {
|
||||
if (k == i) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const node *nd = &(comp.nodes[k]);
|
||||
|
||||
if (aabb(nd->rec, comp.ctx.mouse_x, comp.ctx.mouse_y)) {
|
||||
point p0 = {nd->rec.topleft.x + nd->rec.w / 2,
|
||||
nd->rec.topleft.y + nd->rec.h / 2};
|
||||
|
||||
ln->p0 = p0;
|
||||
} else {
|
||||
ln->p0 = ln->p1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (delta_multiplier > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user