Simplify the immediate mode functions and move node
connection logic to the application level
This commit is contained in:
21
include/ui.h
21
include/ui.h
@@ -16,6 +16,8 @@
|
||||
#define NODE_WIDTH 70
|
||||
#define NODE_HEIGHT 20
|
||||
|
||||
#define DEFAULT_NOODLE_LENGTH 60
|
||||
|
||||
typedef enum ui_elem_type ui_elem_type;
|
||||
typedef struct ui_elem ui_elem;
|
||||
typedef struct ui_ctx ui_ctx;
|
||||
@@ -43,19 +45,6 @@ struct ui_elem_colours {
|
||||
colour border;
|
||||
};
|
||||
|
||||
typedef struct ui_noodle_elem ui_noodle_elem;
|
||||
struct ui_noodle_elem {
|
||||
line noodle;
|
||||
u64 connected_node;
|
||||
};
|
||||
|
||||
typedef struct ui_node_elem ui_node_elem;
|
||||
struct ui_node_elem {
|
||||
rect rec;
|
||||
ui_noodle_elem *noodles;
|
||||
u64 inputs;
|
||||
};
|
||||
|
||||
struct ui_ctx {
|
||||
u64 count;
|
||||
i64 hovered;
|
||||
@@ -75,7 +64,9 @@ 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);
|
||||
ui_node_elem ui_node(const window *wnd, ui_ctx *ctx, ui_node_elem node,
|
||||
ui_elem_colours colours);
|
||||
bool ui_node(const window *wnd, ui_ctx *ctx, rect rect,
|
||||
ui_elem_colours colours);
|
||||
bool ui_noodle(const window *wnd, ui_ctx *ctx, line ln, ui_elem_colours colours,
|
||||
rect parent_node);
|
||||
|
||||
#endif // !UI_H
|
||||
|
||||
Reference in New Issue
Block a user