Support drawing a node with connection that can be modified by user

This commit is contained in:
2024-02-20 00:18:53 +00:00
parent d73275f04c
commit 10ba3d642d
4 changed files with 55 additions and 30 deletions

View File

@@ -3,7 +3,6 @@
#include "aliases/aliases.h"
#include "ui.h"
#include "window.h"
#define MAX_NODES 1024
@@ -25,7 +24,7 @@ union node_data {
};
struct node {
rect rec;
ui_node_elem node;
ui_elem_colours colours;
node_type type;
node_data data;

View File

@@ -14,11 +14,11 @@
#define NODE_WIDTH 70
#define NODE_HEIGHT 20
typedef enum ui_elemype ui_elemype;
typedef enum ui_elem_type ui_elem_type;
typedef struct ui_elem ui_elem;
typedef struct ui_ctx ui_ctx;
enum ui_elemype {
enum ui_elem_type {
UI_ELEM_NODE,
UI_ELEM_BUTTON,
@@ -28,7 +28,7 @@ enum ui_elemype {
struct ui_elem {
u64 id;
rect rect;
ui_elemype type;
ui_elem_type type;
};
typedef struct ui_elem_colours ui_elem_colours;
@@ -37,6 +37,12 @@ struct ui_elem_colours {
colour border;
};
typedef struct ui_node_elem ui_node_elem;
struct ui_node_elem {
line noodle;
rect rec;
};
struct ui_ctx {
u64 count;
i64 hovered;
@@ -55,9 +61,7 @@ void reset_ui_ctx(ui_ctx *ctx);
void handle_ui_events(const window *wnd, ui_ctx *ctx, const SDL_Event *event);
bool ui_button(const window *wnd, ui_ctx *ctx, rect rect,
ui_elem_colours colours);
rect ui_node(const window *wnd, ui_ctx *ctx, rect rect,
ui_elem_colours colours);
line ui_noodle(const window *wnd, ui_ctx *ctx, line ln,
ui_elem_colours colours);
ui_node_elem ui_node(const window *wnd, ui_ctx *ctx, ui_node_elem node,
ui_elem_colours colours);
#endif // !UI_H