Update node_t struct definition
This commit is contained in:
24
src/nodes.c
24
src/nodes.c
@@ -1,13 +1,33 @@
|
||||
#include "nodes.h"
|
||||
#include "aliases/aliases.h"
|
||||
#include "window.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct node_colours node_colours_t;
|
||||
struct node_colours {
|
||||
colour_t fill;
|
||||
colour_t border;
|
||||
};
|
||||
|
||||
INTERNAL node_colours_t colours[COUNT_NODE_TYPES] = {
|
||||
[NODE_TYPE_IO] =
|
||||
(node_colours_t){
|
||||
.fill = IO_NODE_FILL_COLOUR,
|
||||
.border = IO_NODE_BORDER_COLOUR,
|
||||
},
|
||||
[NODE_TYPE_OP] =
|
||||
(node_colours_t){
|
||||
.fill = OP_NODE_FILL_COLOUR,
|
||||
.border = OP_NODE_BORDER_COLOUR,
|
||||
},
|
||||
};
|
||||
|
||||
bool aabb(const node_t *node, i32 x, i32 y) {
|
||||
return x > node->rect.topleft.x && x <= node->rect.topleft.x + node->rect.w &&
|
||||
y > node->rect.topleft.y && y <= node->rect.topleft.y + node->rect.h;
|
||||
}
|
||||
|
||||
void draw_node(const window_t *wnd, const node_t *node) {
|
||||
fill_rect(wnd, &(node->rect), IO_NODE_FILL_COLOUR);
|
||||
draw_rect(wnd, &(node->rect), IO_NODE_BORDER_COLOUR);
|
||||
fill_rect(wnd, &(node->rect), colours[node->type].fill);
|
||||
draw_rect(wnd, &(node->rect), colours[node->type].border);
|
||||
}
|
||||
|
Reference in New Issue
Block a user