@@ -1549,6 +1549,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
1549
1549
{
1550
1550
ws -> focused_panel = panel ;
1551
1551
ws -> menu_bar_focused = 0 ;
1552
+ ws -> query_view_selected = 0 ;
1552
1553
}
1553
1554
}break ;
1554
1555
@@ -4943,6 +4944,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
4943
4944
view -> query_mark = txt_pt (1 , 1 );
4944
4945
}
4945
4946
ws -> query_view_stack_top = view ;
4947
+ ws -> query_view_selected = 1 ;
4946
4948
view -> next = & df_g_nil_view ;
4947
4949
4948
4950
scratch_end (scratch );
@@ -4954,23 +4956,43 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
4954
4956
//
4955
4957
{
4956
4958
F32 rate = 1 - pow_f32 (2 , (-40.f * df_dt ()));
4957
- F32 query_view_t_target = !df_view_is_nil (ws -> query_view_stack_top );
4958
- F32 diff = abs_f32 (query_view_t_target - ws -> query_view_t );
4959
- if (diff > 0.005f )
4959
+
4960
+ // rjf: animate query view selection transition
4960
4961
{
4961
- df_gfx_request_frame ();
4962
+ F32 target = (F32 )!!ws -> query_view_selected ;
4963
+ F32 diff = abs_f32 (target - ws -> query_view_selected_t );
4964
+ if (diff > 0.005f )
4965
+ {
4966
+ df_gfx_request_frame ();
4967
+ if (diff < 0.005f )
4968
+ {
4969
+ ws -> query_view_selected_t = target ;
4970
+ }
4971
+ ws -> query_view_selected_t += (target - ws -> query_view_selected_t ) * rate ;
4972
+ }
4962
4973
}
4963
- if (diff < 0.005f )
4974
+
4975
+ // rjf: animate query view open/close transition
4964
4976
{
4965
- ws -> query_view_t = query_view_t_target ;
4977
+ F32 query_view_t_target = !df_view_is_nil (ws -> query_view_stack_top );
4978
+ F32 diff = abs_f32 (query_view_t_target - ws -> query_view_t );
4979
+ if (diff > 0.005f )
4980
+ {
4981
+ df_gfx_request_frame ();
4982
+ }
4983
+ if (diff < 0.005f )
4984
+ {
4985
+ ws -> query_view_t = query_view_t_target ;
4986
+ }
4987
+ ws -> query_view_t += (query_view_t_target - ws -> query_view_t ) * rate ;
4966
4988
}
4967
- ws -> query_view_t += (query_view_t_target - ws -> query_view_t ) * rate ;
4968
4989
}
4969
4990
4970
4991
////////////////////////////
4971
4992
//- rjf: build query
4972
4993
//
4973
- if (!df_view_is_nil (ws -> query_view_stack_top )) UI_Focus ((window_is_focused && !ui_any_ctx_menu_is_open () && !ws -> menu_bar_focused ) ? UI_FocusKind_On : UI_FocusKind_Off )
4994
+ if (!df_view_is_nil (ws -> query_view_stack_top ))
4995
+ UI_Focus ((window_is_focused && !ui_any_ctx_menu_is_open () && !ws -> menu_bar_focused && ws -> query_view_selected ) ? UI_FocusKind_On : UI_FocusKind_Off )
4974
4996
{
4975
4997
DF_View * view = ws -> query_view_stack_top ;
4976
4998
DF_CmdSpec * cmd_spec = ws -> query_cmd_spec ;
@@ -5043,8 +5065,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
5043
5065
str8_lit ("###query_text_input" ));
5044
5066
if (sig .pressed )
5045
5067
{
5046
- DF_CmdParams p = df_cmd_params_from_window (ws );
5047
- df_push_cmd__root (& p , df_cmd_spec_from_core_cmd_kind (DF_CoreCmdKind_FocusPanel ));
5068
+ ws -> query_view_selected = 1 ;
5048
5069
}
5049
5070
}
5050
5071
}
@@ -5059,17 +5080,18 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
5059
5080
}
5060
5081
5061
5082
//- rjf: query submission
5083
+ if ((ui_is_focus_active () || (window_is_focused && !ui_any_ctx_menu_is_open () && !ws -> menu_bar_focused && !ws -> query_view_selected )) &&
5084
+ os_key_press (events , ws -> os , 0 , OS_Key_Esc ))
5085
+ {
5086
+ DF_CmdParams params = df_cmd_params_from_window (ws );
5087
+ df_push_cmd__root (& params , df_cmd_spec_from_core_cmd_kind (DF_CoreCmdKind_CancelQuery ));
5088
+ }
5062
5089
if (ui_is_focus_active ())
5063
5090
{
5064
- DF_View * view = ws -> query_view_stack_top ;
5065
- if (os_key_press (events , ws -> os , 0 , OS_Key_Esc ))
5066
- {
5067
- DF_CmdParams params = df_cmd_params_from_window (ws );
5068
- df_push_cmd__root (& params , df_cmd_spec_from_core_cmd_kind (DF_CoreCmdKind_CancelQuery ));
5069
- }
5070
- else if (os_key_press (events , ws -> os , 0 , OS_Key_Return ))
5091
+ if (os_key_press (events , ws -> os , 0 , OS_Key_Return ))
5071
5092
{
5072
5093
Temp scratch = scratch_begin (& arena , 1 );
5094
+ DF_View * view = ws -> query_view_stack_top ;
5073
5095
DF_CmdParams params = df_cmd_params_from_window (ws );
5074
5096
DF_CtrlCtx ctrl_ctx = df_ctrl_ctx_from_view (ws , view );
5075
5097
String8 error = df_cmd_params_apply_spec_query (scratch .arena , & ctrl_ctx , & params , ws -> query_cmd_spec , str8 (view -> query_buffer , view -> query_string_size ));
@@ -5090,13 +5112,12 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
5090
5112
UI_Signal sig = ui_signal_from_box (query_container_box );
5091
5113
if (sig .pressed )
5092
5114
{
5093
- DF_CmdParams p = df_cmd_params_from_window (ws );
5094
- df_push_cmd__root (& p , df_cmd_spec_from_core_cmd_kind (DF_CoreCmdKind_FocusPanel ));
5115
+ ws -> query_view_selected = 1 ;
5095
5116
}
5096
5117
}
5097
5118
5098
5119
//- rjf: build darkening overlay for rest of screen
5099
- UI_BackgroundColor (mix_4f32 (df_rgba_from_theme_color (DF_ThemeColor_InactivePanelOverlay ), v4f32 (0 , 0 , 0 , 0 ), 1 - ws -> query_view_t ))
5120
+ UI_BackgroundColor (mix_4f32 (df_rgba_from_theme_color (DF_ThemeColor_InactivePanelOverlay ), v4f32 (0 , 0 , 0 , 0 ), 1 - ws -> query_view_selected_t ))
5100
5121
UI_Rect (window_rect )
5101
5122
{
5102
5123
ui_build_box_from_key (UI_BoxFlag_DrawBackground , ui_key_zero ());
@@ -5202,7 +5223,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
5202
5223
if (!df_panel_is_nil (panel -> first )) {continue ;}
5203
5224
B32 panel_is_focused = (window_is_focused &&
5204
5225
!ws -> menu_bar_focused &&
5205
- !query_is_open &&
5226
+ ( !query_is_open || ! ws -> query_view_selected ) &&
5206
5227
!ui_any_ctx_menu_is_open () &&
5207
5228
!hover_eval_is_open &&
5208
5229
ws -> focused_panel == panel );
0 commit comments