Use platform windows for windowing instead of custom draggable window system
This commit is contained in:
@@ -15,38 +15,17 @@
|
||||
|
||||
#define UI_WIDGET_MAX_DROPDOWN_ITEMS 32
|
||||
#define UI_WIDGET_MAX_TEXT_INPUTS 16
|
||||
#define UI_WIDGET_MAX_WINDOWS 16
|
||||
|
||||
struct UI_ModalState {
|
||||
B32 active;
|
||||
U32 id; // Hash of the modal's string ID
|
||||
S32 result; // Button index pressed, -1 = pending
|
||||
};
|
||||
|
||||
struct UI_WindowSlot {
|
||||
U32 id; // Hash of the window's string ID (0 = unused)
|
||||
Vec2F32 position;
|
||||
Vec2F32 size;
|
||||
B32 open;
|
||||
S16 z_order;
|
||||
};
|
||||
|
||||
struct UI_KnobDragState {
|
||||
U32 dragging_id; // Hash of the knob being dragged (0 = none)
|
||||
U32 dragging_id; // Hash of the knob being dragged (0 = none)
|
||||
F32 drag_start_y; // Mouse Y when drag started
|
||||
F32 drag_start_x; // Mouse X when drag started (for h-slider)
|
||||
F32 value_at_start; // Value when drag started
|
||||
B32 was_shift; // Shift state last frame (to re-anchor on change)
|
||||
U32 last_click_id; // Knob hash of last click (for F64-click detection)
|
||||
U32 last_click_id; // Knob hash of last click (for F64-click detection)
|
||||
S32 last_click_frame; // Frame number of last click
|
||||
};
|
||||
|
||||
struct UI_DragState {
|
||||
U32 dragging_id; // Window ID currently being dragged (0 = none)
|
||||
Vec2F32 drag_anchor; // Mouse position when drag started
|
||||
Vec2F32 pos_anchor; // Window position when drag started
|
||||
};
|
||||
|
||||
struct UI_WidgetState {
|
||||
// Text input focus
|
||||
U32 focused_id; // Clay element ID hash of the focused text input (0 = none)
|
||||
@@ -58,8 +37,8 @@ struct UI_WidgetState {
|
||||
S32 sel_end; // Selection extent (moves with cursor)
|
||||
|
||||
// Tab cycling: registered text input IDs in order of declaration
|
||||
U32 text_input_ids[UI_WIDGET_MAX_TEXT_INPUTS];
|
||||
S32 text_input_count;
|
||||
U32 text_input_ids[UI_WIDGET_MAX_TEXT_INPUTS];
|
||||
S32 text_input_count;
|
||||
B32 tab_pressed; // True on the frame Tab was pressed
|
||||
|
||||
// Dropdown
|
||||
@@ -71,15 +50,6 @@ struct UI_WidgetState {
|
||||
// Click detection
|
||||
B32 mouse_clicked; // true on the frame mouse transitions from up->down
|
||||
|
||||
// Modal state
|
||||
UI_ModalState modal;
|
||||
|
||||
// Window state
|
||||
UI_WindowSlot windows[UI_WIDGET_MAX_WINDOWS];
|
||||
S32 window_count;
|
||||
S16 next_z;
|
||||
UI_DragState drag;
|
||||
|
||||
// Knob drag state
|
||||
UI_KnobDragState knob_drag;
|
||||
|
||||
@@ -134,22 +104,12 @@ B32 ui_text_input(const char *id, char *buf, S32 buf_size);
|
||||
// options is an array of label strings, count is the number of options.
|
||||
B32 ui_dropdown(const char *id, const char **options, S32 count, S32 *selected);
|
||||
|
||||
// Modal dialog. Returns button index pressed (0-based), -1 if pending, -2 if Escape dismissed.
|
||||
// Call every frame while active — it draws the overlay and dialog box.
|
||||
S32 ui_modal(const char *id, const char *title, const char *message,
|
||||
const char **buttons, S32 button_count);
|
||||
B32 ui_modal_is_active();
|
||||
|
||||
// Tab bar. Renders a row of tabs with active/inactive states.
|
||||
// Returns the currently selected index. Clicking an inactive tab updates *selected.
|
||||
S32 ui_tab_bar(const char *id, const char **labels, S32 count, S32 *selected);
|
||||
|
||||
// Draggable floating window. content_fn is called inside the window body each frame.
|
||||
// *open is set to 0 when the close button is clicked. Returns true while window is open.
|
||||
// Content function type (used by popup windows)
|
||||
typedef void (*UI_WindowContentFn)(void *user_data);
|
||||
B32 ui_window(const char *id, const char *title, B32 *open,
|
||||
Vec2F32 initial_pos, Vec2F32 initial_size,
|
||||
UI_WindowContentFn content_fn, void *user_data);
|
||||
|
||||
// Knob / potentiometer. Vertical drag to change value.
|
||||
// unsigned (is_signed=0): value in [0, max_val]
|
||||
|
||||
Reference in New Issue
Block a user