add optional command spec restriction to cmd param slot -> view spec table; eliminate mouse testing when windows are not focused

This commit is contained in:
Ryan Fleury
2024-01-30 09:14:59 -08:00
parent c61ff1910c
commit d139c2874c
5 changed files with 70 additions and 19 deletions
+23 -8
View File
@@ -647,12 +647,21 @@ df_view_spec_from_gfx_view_kind(DF_GfxViewKind gfx_view_kind)
}
internal DF_ViewSpec *
df_view_spec_from_cmd_param_slot(DF_CmdParamSlot slot)
df_view_spec_from_cmd_param_slot_spec(DF_CmdParamSlot slot, DF_CmdSpec *cmd_spec)
{
DF_ViewSpec *spec = df_gfx_state->cmd_param_slot_view_spec_table[slot];
if(spec == 0)
DF_ViewSpec *spec = &df_g_nil_view_spec;
for(DF_CmdParamSlotViewSpecRuleNode *n = df_gfx_state->cmd_param_slot_view_spec_table[slot].first;
n != 0;
n = n->next)
{
spec = &df_g_nil_view_spec;
if(cmd_spec == n->cmd_spec || df_cmd_spec_is_nil(n->cmd_spec))
{
spec = n->view_spec;
if(!df_cmd_spec_is_nil(n->cmd_spec))
{
break;
}
}
}
return spec;
}
@@ -5018,7 +5027,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
{
DF_CmdSpec *cmd_spec = ws->query_cmd_spec;
DF_CmdParamSlot first_missing_slot = cmd_spec->info.query.slot;
DF_ViewSpec *view_spec = df_view_spec_from_cmd_param_slot(first_missing_slot);
DF_ViewSpec *view_spec = df_view_spec_from_cmd_param_slot_spec(first_missing_slot, cmd_spec);
if(ws->query_view_stack_top->spec != view_spec ||
df_view_is_nil(ws->query_view_stack_top))
{
@@ -5766,7 +5775,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
// rjf: more precise drop-sites on tab bar
{
Vec2F32 mouse = os_mouse_from_window(ws->os);
Vec2F32 mouse = ui_mouse();
DF_View *view = df_view_from_handle(df_g_drag_drop_payload.view);
if(df_drag_is_active() && window_is_focused && contains_2f32(panel_rect, mouse) && !df_view_is_nil(view))
{
@@ -5842,7 +5851,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
//////////////////////////
//- rjf: less granular panel for tabs & entities drop-site
//
if(df_drag_is_active() && window_is_focused && contains_2f32(panel_rect, os_mouse_from_window(ws->os)))
if(df_drag_is_active() && window_is_focused && contains_2f32(panel_rect, ui_mouse()))
{
DF_DragDropPayload *payload = &df_g_drag_drop_payload;
DF_View *dragged_view = df_view_from_handle(payload->view);
@@ -10865,8 +10874,14 @@ df_gfx_init(OS_WindowRepaintFunctionType *window_repaint_entry_point, DF_StateDe
{
DF_CmdParamSlot slot = df_g_cmd_param_slot_2_view_spec_src_map[idx];
String8 view_spec_name = df_g_cmd_param_slot_2_view_spec_dst_map[idx];
String8 cmd_spec_name = df_g_cmd_param_slot_2_view_spec_cmd_map[idx];
DF_ViewSpec *view_spec = df_view_spec_from_string(view_spec_name);
df_gfx_state->cmd_param_slot_view_spec_table[slot] = view_spec;
DF_CmdSpec *cmd_spec = cmd_spec_name.size != 0 ? df_cmd_spec_from_string(cmd_spec_name) : &df_g_nil_cmd_spec;
DF_CmdParamSlotViewSpecRuleNode *n = push_array(df_gfx_state->arena, DF_CmdParamSlotViewSpecRuleNode, 1);
n->view_spec = view_spec;
n->cmd_spec = cmd_spec;
SLLQueuePush(df_gfx_state->cmd_param_slot_view_spec_table[slot].first, df_gfx_state->cmd_param_slot_view_spec_table[slot].last, n);
df_gfx_state->cmd_param_slot_view_spec_table[slot].count += 1;
}
}
+19 -3
View File
@@ -197,6 +197,22 @@ struct DF_ViewSpecInfoArray
U64 count;
};
typedef struct DF_CmdParamSlotViewSpecRuleNode DF_CmdParamSlotViewSpecRuleNode;
struct DF_CmdParamSlotViewSpecRuleNode
{
DF_CmdParamSlotViewSpecRuleNode *next;
DF_ViewSpec *view_spec;
DF_CmdSpec *cmd_spec;
};
typedef struct DF_CmdParamSlotViewSpecRuleList DF_CmdParamSlotViewSpecRuleList;
struct DF_CmdParamSlotViewSpecRuleList
{
DF_CmdParamSlotViewSpecRuleNode *first;
DF_CmdParamSlotViewSpecRuleNode *last;
U64 count;
};
////////////////////////////////
//~ rjf: View Types
@@ -709,8 +725,8 @@ struct DF_GfxState
DF_ViewRuleBlockSlot *view_rule_block_slots;
DF_ViewRuleBlockNode *free_view_rule_block_node;
// rjf: cmd param slot -> view spec table
DF_ViewSpec *cmd_param_slot_view_spec_table[DF_CmdParamSlot_COUNT];
// rjf: cmd param slot -> view spec rule table
DF_CmdParamSlotViewSpecRuleList cmd_param_slot_view_spec_table[DF_CmdParamSlot_COUNT];
// rjf: windows
OS_WindowRepaintFunctionType *repaint_hook;
@@ -891,7 +907,7 @@ internal U64 df_get_hovered_line_info_voff(void);
internal void df_register_view_specs(DF_ViewSpecInfoArray specs);
internal DF_ViewSpec *df_view_spec_from_string(String8 string);
internal DF_ViewSpec *df_view_spec_from_gfx_view_kind(DF_GfxViewKind gfx_view_kind);
internal DF_ViewSpec *df_view_spec_from_cmd_param_slot(DF_CmdParamSlot slot);
internal DF_ViewSpec *df_view_spec_from_cmd_param_slot_spec(DF_CmdParamSlot slot, DF_CmdSpec *cmd_spec);
////////////////////////////////
//~ rjf: View Rule Spec State Functions
+14 -7
View File
@@ -274,15 +274,16 @@ DF_CmdSpec2ViewSpecMap:
////////////////////////////////
//~ rjf: Command Parameter Slot -> View
@table(slot view_spec)
@table(slot view_spec opt_cmd_spec)
DF_CmdParamSlot2ViewSpecMap:
{
{Entity "entity_lister" }
{EntityList "entity_lister" }
{FilePath "file_system" }
{CmdSpec "commands" }
{ID "system_processes" }
{String "symbol_lister" }
{Entity "entity_lister" "" }
{EntityList "entity_lister" "" }
{FilePath "file_system" "" }
{CmdSpec "commands" "" }
{ID "system_processes" "" }
{String "symbol_lister" "goto_name" }
{String "symbol_lister" "function_breakpoint" }
}
////////////////////////////////
@@ -585,6 +586,12 @@ df_g_cmd_param_slot_2_view_spec_dst_map:
@expand(DF_CmdParamSlot2ViewSpecMap a) `str8_lit_comp("$(a.view_spec)"),`
}
@table_gen_data(type: String8, fallback:`{0}`)
df_g_cmd_param_slot_2_view_spec_cmd_map:
{
@expand(DF_CmdParamSlot2ViewSpecMap a) `str8_lit_comp("$(a.opt_cmd_spec)"),`
}
//- rjf: default bindings table
@table_gen_data(type: DF_StringBindingPair, fallback: `{0}`)
+13
View File
@@ -905,6 +905,7 @@ DF_CmdParamSlot_FilePath,
DF_CmdParamSlot_CmdSpec,
DF_CmdParamSlot_ID,
DF_CmdParamSlot_String,
DF_CmdParamSlot_String,
};
String8 df_g_cmd_param_slot_2_view_spec_dst_map[] =
@@ -915,6 +916,18 @@ str8_lit_comp("file_system"),
str8_lit_comp("commands"),
str8_lit_comp("system_processes"),
str8_lit_comp("symbol_lister"),
str8_lit_comp("symbol_lister"),
};
String8 df_g_cmd_param_slot_2_view_spec_cmd_map[] =
{
str8_lit_comp(""),
str8_lit_comp(""),
str8_lit_comp(""),
str8_lit_comp(""),
str8_lit_comp(""),
str8_lit_comp("goto_name"),
str8_lit_comp("function_breakpoint"),
};
DF_StringBindingPair df_g_default_binding_table[] =
+1 -1
View File
@@ -651,7 +651,7 @@ ui_begin_build(OS_EventList *events, OS_Handle window, UI_NavActionList *nav_act
ui_state->events = events;
ui_state->window = window;
ui_state->nav_actions = nav_actions;
ui_state->mouse = os_mouse_from_window(window);
ui_state->mouse = os_window_is_focused(window) ? os_mouse_from_window(window) : v2f32(-100, -100);
ui_state->animation_dt = animation_dt;
MemoryZeroStruct(&ui_state->icon_info);
ui_state->icon_info.icon_font = icon_info->icon_font;