refactor from per-box ui input state to global input state w/ per-box capture propagation
This commit is contained in:
parent
b2a9b3091d
commit
d7c42d2462
@ -1149,7 +1149,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
|
|
||||||
V_TextboxDeltaList text_input_deltas = Zi;
|
V_TextboxDeltaList text_input_deltas = Zi;
|
||||||
|
|
||||||
frame->has_mouse_focus = UI_IsKeyNil(ui_frame->hot_box) || UI_MatchKey(ui_frame->hot_box, vis_game_box);
|
frame->has_mouse_focus = UI_IsKeyNil(ui_frame->top_hot_box) || UI_MatchKey(ui_frame->top_hot_box, vis_game_box);
|
||||||
frame->has_keyboard_focus = 1;
|
frame->has_keyboard_focus = 1;
|
||||||
Vec2 mouse_delta = Zi;
|
Vec2 mouse_delta = Zi;
|
||||||
{
|
{
|
||||||
@ -3839,7 +3839,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Insert ghost tab
|
// Insert ghost tab
|
||||||
if (V.dragging_window && UI_Hovered(panel->key))
|
if (V.dragging_window && UI_HotAbsolute(panel->key))
|
||||||
{
|
{
|
||||||
DrawableTab *left = 0;
|
DrawableTab *left = 0;
|
||||||
DrawableTab *right = first_drawable_tab;
|
DrawableTab *right = first_drawable_tab;
|
||||||
@ -4272,7 +4272,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
UI_SetNext(AxisSize, UI_PIX(divider_size, 1), .axis = !panel->axis);
|
UI_SetNext(AxisSize, UI_PIX(divider_size, 1), .axis = !panel->axis);
|
||||||
UI_BuildBoxEx(panel->divider_key);
|
UI_BuildBoxEx(panel->divider_key);
|
||||||
|
|
||||||
if (UI_TargetHot(panel->divider_key) || UI_Held(panel->divider_key, Button_M1))
|
if (UI_HotAbsolute(panel->divider_key) || UI_Held(panel->divider_key, Button_M1))
|
||||||
{
|
{
|
||||||
if (panel->axis == Axis_X)
|
if (panel->axis == Axis_X)
|
||||||
{
|
{
|
||||||
@ -4347,6 +4347,12 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
{
|
{
|
||||||
UI_Push(Tag, HashF("developer command palette"));
|
UI_Push(Tag, HashF("developer command palette"));
|
||||||
|
|
||||||
|
// FIXME: Remove this
|
||||||
|
if (frame->tick == 1)
|
||||||
|
{
|
||||||
|
palette->pos = VEC2(1000, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
UI_Size total_width = UI_FNT(40, 1);
|
UI_Size total_width = UI_FNT(40, 1);
|
||||||
UI_Size total_height = UI_FNT(30, 1);
|
UI_Size total_height = UI_FNT(30, 1);
|
||||||
UI_Size header_height = UI_FNT(1.3, 1);
|
UI_Size header_height = UI_FNT(1.3, 1);
|
||||||
@ -4570,7 +4576,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
has_focus = 0;
|
has_focus = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UI_TargetHot(search_box))
|
if (UI_HotAbsolute(search_box))
|
||||||
{
|
{
|
||||||
WND_SetCursor(window_frame, WND_CursorKind_Text);
|
WND_SetCursor(window_frame, WND_CursorKind_Text);
|
||||||
}
|
}
|
||||||
@ -4948,7 +4954,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
{
|
{
|
||||||
new_tweak_str = tweak_var.initial;
|
new_tweak_str = tweak_var.initial;
|
||||||
}
|
}
|
||||||
if (UI_TargetHot(reset_key))
|
if (UI_HotAbsolute(reset_key))
|
||||||
{
|
{
|
||||||
WND_SetCursor(window_frame, WND_CursorKind_Hand);
|
WND_SetCursor(window_frame, WND_CursorKind_Hand);
|
||||||
}
|
}
|
||||||
@ -5040,7 +5046,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
UI_Key slider_key = UI_KeyF("tweak slider");
|
UI_Key slider_key = UI_KeyF("tweak slider");
|
||||||
UI_Key marker_key = UI_KeyF("tweak slider marker");
|
UI_Key marker_key = UI_KeyF("tweak slider marker");
|
||||||
|
|
||||||
b32 is_hot = UI_TargetHot(slider_key) || UI_TargetHot(marker_key);
|
b32 is_hot = UI_HotAbsolute(slider_key) || UI_HotAbsolute(marker_key);
|
||||||
b32 is_active = UI_Held(slider_key, Button_M1) || UI_Held(marker_key, Button_M1);
|
b32 is_active = UI_Held(slider_key, Button_M1) || UI_Held(marker_key, Button_M1);
|
||||||
f32 hot = MaxF32(UI_Hot(slider_key), UI_Hot(marker_key));
|
f32 hot = MaxF32(UI_Hot(slider_key), UI_Hot(marker_key));
|
||||||
|
|
||||||
@ -5157,7 +5163,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
pressed_color.w = 0.2;
|
pressed_color.w = 0.2;
|
||||||
f32 hotkey_hot = UI_Hot(hotkey_box);
|
f32 hotkey_hot = UI_Hot(hotkey_box);
|
||||||
f32 hotkey_active = UI_Active(hotkey_box);
|
f32 hotkey_active = UI_Active(hotkey_box);
|
||||||
f32 hotkey_hovered = UI_Hovered(hotkey_box);
|
f32 hotkey_hovered = UI_HotAbsolute(hotkey_box);
|
||||||
hotkey_color = LerpSrgb(hotkey_color, hovered_color, hotkey_hot);
|
hotkey_color = LerpSrgb(hotkey_color, hovered_color, hotkey_hot);
|
||||||
hotkey_color = LerpSrgb(hotkey_color, pressed_color, hotkey_active * hotkey_hovered);
|
hotkey_color = LerpSrgb(hotkey_color, pressed_color, hotkey_active * hotkey_hovered);
|
||||||
hotkey_border_color = LerpSrgb(hotkey_border_color, Rgb32(0x0078a6), hotkey_hot);
|
hotkey_border_color = LerpSrgb(hotkey_border_color, Rgb32(0x0078a6), hotkey_hot);
|
||||||
@ -5546,6 +5552,8 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if (profiler->is_dragging && !prev_frame->profiler.is_dragging)
|
// if (profiler->is_dragging && !prev_frame->profiler.is_dragging)
|
||||||
// {
|
// {
|
||||||
// profiler->drag_view_ns = profiler->view_ns;
|
// profiler->drag_view_ns = profiler->view_ns;
|
||||||
@ -5637,11 +5645,12 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
//- Main
|
//- Main
|
||||||
if (do_break)
|
if (do_break)
|
||||||
{
|
{
|
||||||
UI_SetNext(DebugBreakFlags, UI_DebugBreakFlag_BuildReport);
|
UI_SetNext(DebugBreakFlags, UI_DebugBreakFlag_BuildFeedback);
|
||||||
UI_SetNext(Text, Lit("MAIN"));
|
UI_SetNext(Text, Lit("MAIN"));
|
||||||
}
|
}
|
||||||
UI_SetNext(Height, main_height);
|
UI_SetNext(Height, main_height);
|
||||||
UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_CaptureThroughChildren);
|
UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_CaptureThroughChildren);
|
||||||
|
// UI_SetNext(Flags, UI_BoxFlag_CaptureMouse);
|
||||||
UI_PushDF(Parent, UI_BuildColumnEx(main_box))
|
UI_PushDF(Parent, UI_BuildColumnEx(main_box))
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -5803,6 +5812,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
UI_Key zone_box = UI_KeyF("Zone %F", FmtUint(zone_idx));
|
UI_Key zone_box = UI_KeyF("Zone %F", FmtUint(zone_idx));
|
||||||
|
|
||||||
Vec4 zone_color = zone->color;
|
Vec4 zone_color = zone->color;
|
||||||
|
zone_color = LerpSrgb(zone_color, Color_Cyan, UI_Hot(zone_box));
|
||||||
|
|
||||||
// Vec4 zone_color_bd = Zi;
|
// Vec4 zone_color_bd = Zi;
|
||||||
// zone_color_bd
|
// zone_color_bd
|
||||||
@ -5815,11 +5825,11 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
Vec2 zone_pos = VEC2(zone_offset_px, 0);
|
Vec2 zone_pos = VEC2(zone_offset_px, 0);
|
||||||
UI_Size zone_width = UI_PIX(zone_len_px, 1);
|
UI_Size zone_width = UI_PIX(zone_len_px, 1);
|
||||||
|
|
||||||
|
|
||||||
if (do_break && UI_TargetHovered(zone_box))
|
|
||||||
{
|
|
||||||
UI_SetNext(DebugBreakFlags, UI_DebugBreakFlag_BuildReport);
|
|
||||||
UI_SetNext(Text, StringF(frame->arena, "ZONE %F", FmtUint(zone_idx)));
|
UI_SetNext(Text, StringF(frame->arena, "ZONE %F", FmtUint(zone_idx)));
|
||||||
|
// if (do_break && UI_IsMouseHovered(zone_box))
|
||||||
|
if (do_break && zone_idx == 0)
|
||||||
|
{
|
||||||
|
UI_SetNext(DebugBreakFlags, UI_DebugBreakFlag_BuildFeedback | UI_DebugBreakFlag_CheckCursorHover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -5829,6 +5839,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
UI_SetNext(BackgroundColor, zone_color);
|
UI_SetNext(BackgroundColor, zone_color);
|
||||||
UI_SetNext(FloatingPos, zone_pos);
|
UI_SetNext(FloatingPos, zone_pos);
|
||||||
UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_NoFloatingClampX | UI_BoxFlag_NoFloatingClampY | UI_BoxFlag_CaptureMouse);
|
UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_NoFloatingClampX | UI_BoxFlag_NoFloatingClampY | UI_BoxFlag_CaptureMouse);
|
||||||
|
// UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_NoFloatingClampX | UI_BoxFlag_NoFloatingClampY);
|
||||||
UI_PushDF(Parent, UI_BuildBoxEx(zone_box))
|
UI_PushDF(Parent, UI_BuildBoxEx(zone_box))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
1097
src/ui/ui_core.c
1097
src/ui/ui_core.c
File diff suppressed because it is too large
Load Diff
101
src/ui/ui_core.h
101
src/ui/ui_core.h
@ -102,15 +102,16 @@ Enum(UI_BoxFlag)
|
|||||||
Enum(UI_DebugBreakFlag)
|
Enum(UI_DebugBreakFlag)
|
||||||
{
|
{
|
||||||
UI_DebugBreakFlag_None = 0,
|
UI_DebugBreakFlag_None = 0,
|
||||||
UI_DebugBreakFlag_BuildReport = (1 << 0),
|
UI_DebugBreakFlag_CheckCursorHover = (1 << 0),
|
||||||
UI_DebugBreakFlag_PrepLayout = (1 << 1),
|
UI_DebugBreakFlag_BuildFeedback = (1 << 1),
|
||||||
UI_DebugBreakFlag_IndependentSolve = (1 << 2),
|
UI_DebugBreakFlag_PrepLayout = (1 << 2),
|
||||||
UI_DebugBreakFlag_UpwardsDependentSolveLayoutAxis = (1 << 3),
|
UI_DebugBreakFlag_IndependentSolve = (1 << 3),
|
||||||
UI_DebugBreakFlag_DownwardsDependentSolve = (1 << 4),
|
UI_DebugBreakFlag_UpwardsDependentSolveLayoutAxis = (1 << 4),
|
||||||
UI_DebugBreakFlag_UpwardsDependentSolveNonLayoutAxis = (1 << 5),
|
UI_DebugBreakFlag_DownwardsDependentSolve = (1 << 5),
|
||||||
UI_DebugBreakFlag_SolveViolations = (1 << 6),
|
UI_DebugBreakFlag_UpwardsDependentSolveNonLayoutAxis = (1 << 6),
|
||||||
UI_DebugBreakFlag_FinalSolve = (1 << 7),
|
UI_DebugBreakFlag_SolveViolations = (1 << 7),
|
||||||
UI_DebugBreakFlag_BuildGpuData = (1 << 8),
|
UI_DebugBreakFlag_FinalSolve = (1 << 8),
|
||||||
|
UI_DebugBreakFlag_BuildGpuData = (1 << 9),
|
||||||
|
|
||||||
UI_DebugBreakFlag_All = 0xFFFFFFFF
|
UI_DebugBreakFlag_All = 0xFFFFFFFF
|
||||||
};
|
};
|
||||||
@ -225,28 +226,23 @@ Struct(UI_InputState)
|
|||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Report types
|
//~ Feedback types
|
||||||
|
|
||||||
// Struct(UI_BoxReport)
|
Struct(UI_Feedback)
|
||||||
// {
|
{
|
||||||
// Rng2 screen_rect;
|
Rng2 screen_rect;
|
||||||
// Vec2 screen_anchor;
|
Vec2 screen_anchor;
|
||||||
|
|
||||||
// b32 is_hovered;
|
b32 active_absolute;
|
||||||
// b32 is_hot;
|
b32 hot_absolute;
|
||||||
|
b32 exists_absolute;
|
||||||
|
|
||||||
// f32 exists;
|
f32 active_smooth;
|
||||||
// f32 hovered;
|
f32 hot_smooth;
|
||||||
// f32 hot;
|
f32 exists_smooth;
|
||||||
// f32 active;
|
|
||||||
// f64 misc;
|
|
||||||
// };
|
|
||||||
|
|
||||||
// Struct(UI_BoxReports)
|
f64 misc_smooth;
|
||||||
// {
|
};
|
||||||
// UI_BoxReport draw; // Box data used for last render
|
|
||||||
// UI_BoxReport drag; // Box data during last mouse button down event
|
|
||||||
// };
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Command types
|
//~ Command types
|
||||||
@ -255,7 +251,6 @@ Enum(UI_CmdKind)
|
|||||||
{
|
{
|
||||||
UI_CmdKind_None,
|
UI_CmdKind_None,
|
||||||
UI_CmdKind_BuildBox,
|
UI_CmdKind_BuildBox,
|
||||||
UI_CmdKind_Signal,
|
|
||||||
UI_CmdKind_SetRawTexture,
|
UI_CmdKind_SetRawTexture,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -300,12 +295,6 @@ Struct(UI_Cmd)
|
|||||||
{
|
{
|
||||||
UI_BoxDesc box;
|
UI_BoxDesc box;
|
||||||
struct
|
struct
|
||||||
{
|
|
||||||
UI_Key key;
|
|
||||||
Button button;
|
|
||||||
UI_ButtonState button_state;
|
|
||||||
} signal;
|
|
||||||
struct
|
|
||||||
{
|
{
|
||||||
UI_Key key;
|
UI_Key key;
|
||||||
G_TextureRef tex;
|
G_TextureRef tex;
|
||||||
@ -368,6 +357,12 @@ Struct(UI_Box)
|
|||||||
f32 rounding_tr;
|
f32 rounding_tr;
|
||||||
f32 rounding_br;
|
f32 rounding_br;
|
||||||
f32 rounding_bl;
|
f32 rounding_bl;
|
||||||
|
|
||||||
|
//- Feedback
|
||||||
|
b32 mouse_hovered;
|
||||||
|
b32 mouse_captured;
|
||||||
|
UI_Feedback feedback;
|
||||||
|
UI_Feedback drag_feedback;
|
||||||
};
|
};
|
||||||
|
|
||||||
Struct(UI_BoxBin)
|
Struct(UI_BoxBin)
|
||||||
@ -424,12 +419,12 @@ Struct(UI_Frame)
|
|||||||
// Input
|
// Input
|
||||||
Vec2 cursor_pos;
|
Vec2 cursor_pos;
|
||||||
Vec2 drag_cursor_pos;
|
Vec2 drag_cursor_pos;
|
||||||
UI_InputState input_state;
|
UI_InputState input;
|
||||||
UI_InputState drag_input_state;
|
UI_InputState drag_input;
|
||||||
|
|
||||||
UI_Key top_hovered_box;
|
UI_Key top_hovered_box;
|
||||||
UI_Key hot_box;
|
UI_Key top_hot_box;
|
||||||
UI_Key active_box;
|
UI_Key top_active_box;
|
||||||
|
|
||||||
// Cmds
|
// Cmds
|
||||||
UI_FrameFlag frame_flags;
|
UI_FrameFlag frame_flags;
|
||||||
@ -554,7 +549,6 @@ UI_Key UI_BuildBoxEx(UI_Key semantic_key);
|
|||||||
#define UI_BuildBox() UI_BuildBoxEx(UI_NilKey)
|
#define UI_BuildBox() UI_BuildBoxEx(UI_NilKey)
|
||||||
|
|
||||||
void UI_SetRawTexture(UI_Key key, G_TextureRef tex, Rng2 uv);
|
void UI_SetRawTexture(UI_Key key, G_TextureRef tex, Rng2 uv);
|
||||||
UI_ButtonState *UI_SignalButton(UI_Key key, Button button);
|
|
||||||
|
|
||||||
#if IsRtcEnabled
|
#if IsRtcEnabled
|
||||||
#define UI_DebugBreak(box, target_flags) do { if (box->desc.debug_break_flags & target_flags) { DEBUGBREAK; } } while (0)
|
#define UI_DebugBreak(box, target_flags) do { if (box->desc.debug_break_flags & target_flags) { DEBUGBREAK; } } while (0)
|
||||||
@ -562,7 +556,6 @@ UI_ButtonState *UI_SignalButton(UI_Key key, Button button);
|
|||||||
#define UI_DebugBreak(...)
|
#define UI_DebugBreak(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Begin frame
|
//~ Begin frame
|
||||||
|
|
||||||
@ -578,30 +571,30 @@ Arena *UI_FrameArena(void);
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Feedback
|
//~ Feedback
|
||||||
|
|
||||||
|
//- Passive
|
||||||
|
|
||||||
|
b32 UI_IsButtonPassive(Button button);
|
||||||
|
|
||||||
//- Input
|
//- Input
|
||||||
|
|
||||||
i32 UI_Downs(UI_Key key, Button button);
|
|
||||||
b32 UI_Held(UI_Key key, Button button);
|
b32 UI_Held(UI_Key key, Button button);
|
||||||
b32 UI_Ups(UI_Key key, Button button);
|
i32 UI_Downs(UI_Key key, Button button);
|
||||||
b32 UI_Presses(UI_Key key, Button button);
|
i32 UI_Ups(UI_Key key, Button button);
|
||||||
|
i32 UI_Presses(UI_Key key, Button button);
|
||||||
|
|
||||||
//- Interaction
|
//- Interaction
|
||||||
|
|
||||||
f32 UI_Exists(UI_Key key);
|
|
||||||
f32 UI_TargetExists(UI_Key key);
|
|
||||||
|
|
||||||
f32 UI_Hovered(UI_Key key);
|
|
||||||
f32 UI_TargetHovered(UI_Key key);
|
|
||||||
|
|
||||||
f32 UI_Active(UI_Key key);
|
f32 UI_Active(UI_Key key);
|
||||||
f32 UI_TargetActive(UI_Key key);
|
b32 UI_ActiveAbsolute(UI_Key key);
|
||||||
|
|
||||||
f32 UI_Hot(UI_Key key);
|
f32 UI_Hot(UI_Key key);
|
||||||
f32 UI_TargetHot(UI_Key key);
|
b32 UI_HotAbsolute(UI_Key key);
|
||||||
|
|
||||||
f32 UI_Misc(UI_Key key);
|
f32 UI_Exists(UI_Key key);
|
||||||
f32 UI_DragMisc(UI_Key key);
|
b32 UI_ExistsAbsolute(UI_Key);
|
||||||
f32 UI_TargetMisc(UI_Key key);
|
|
||||||
|
f64 UI_Misc(UI_Key key);
|
||||||
|
f64 UI_DragMisc(UI_Key key);
|
||||||
|
|
||||||
//- Layout
|
//- Layout
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user