Update readme, add potentiometer controls
This commit is contained in:
@@ -31,6 +31,15 @@ struct UI_WindowSlot {
|
||||
int16_t z_order;
|
||||
};
|
||||
|
||||
struct UI_KnobDragState {
|
||||
uint32_t dragging_id; // Hash of the knob being dragged (0 = none)
|
||||
F32 drag_start_y; // Mouse Y when drag started
|
||||
F32 value_at_start; // Value when drag started
|
||||
B32 was_shift; // Shift state last frame (to re-anchor on change)
|
||||
uint32_t last_click_id; // Knob hash of last click (for double-click detection)
|
||||
S32 last_click_frame; // Frame number of last click
|
||||
};
|
||||
|
||||
struct UI_DragState {
|
||||
uint32_t dragging_id; // Window ID currently being dragged (0 = none)
|
||||
Vec2F32 drag_anchor; // Mouse position when drag started
|
||||
@@ -69,6 +78,16 @@ struct UI_WidgetState {
|
||||
S32 window_count;
|
||||
int16_t next_z;
|
||||
UI_DragState drag;
|
||||
|
||||
// Knob drag state
|
||||
UI_KnobDragState knob_drag;
|
||||
|
||||
// Knob text edit state
|
||||
uint32_t knob_edit_id; // Hash of knob in text edit mode (0 = none)
|
||||
char knob_edit_buf[32]; // Text buffer for numeric entry
|
||||
S32 knob_edit_cursor; // Cursor position in edit buffer
|
||||
S32 knob_edit_sel_start; // Selection anchor
|
||||
S32 knob_edit_sel_end; // Selection extent
|
||||
};
|
||||
|
||||
extern UI_WidgetState g_wstate;
|
||||
@@ -130,3 +149,12 @@ 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]
|
||||
// signed (is_signed=1): value in [-max_val, +max_val]
|
||||
// default_val: value restored on double-click.
|
||||
// editable: if true, clicking the value text opens a text input for direct entry.
|
||||
// Hold Shift while dragging for fine control.
|
||||
// Returns true if value changed this frame.
|
||||
B32 ui_knob(const char *id, const char *label, F32 *value, F32 max_val, B32 is_signed, F32 default_val, B32 editable = 0);
|
||||
|
||||
Reference in New Issue
Block a user