mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-10 19:41:37 -07:00
dead code elimination
This commit is contained in:
@@ -4749,559 +4749,6 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
//- rjf: build listers
|
||||
//
|
||||
#if 0 // TODO(rjf): @cfg
|
||||
//- rjf: do query lister stack controls
|
||||
if(ws->top_query_lister != 0)
|
||||
{
|
||||
if(ui_slot_press(UI_EventActionSlot_Cancel))
|
||||
{
|
||||
rd_cmd(RD_CmdKind_CancelQuery);
|
||||
}
|
||||
if(ui_slot_press(UI_EventActionSlot_Accept))
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
RD_RegsScope()
|
||||
{
|
||||
//rd_regs_fill_slot_from_string(query->slot, str8(ws->query_input_buffer, ws->query_input_string_size));
|
||||
rd_cmd(RD_CmdKind_CompleteQuery);
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}
|
||||
}
|
||||
for(ListerTask *task = first_lister_task; task != 0; task = task->next)
|
||||
{
|
||||
DI_Scope *di_scope = di_scope_open();
|
||||
|
||||
//////////////////////////
|
||||
//- rjf: unpack
|
||||
//
|
||||
RD_Lister *lister = task->lister;
|
||||
RD_ListerFlags flags = lister->regs->lister_flags;
|
||||
UI_Box *anchor_box = ui_box_from_key(lister->regs->ui_key);
|
||||
|
||||
//////////////////////////
|
||||
//- rjf: parameters -> lister items
|
||||
//
|
||||
RD_ListerItemArray item_array = rd_lister_item_array_from_regs_needle_cursor_off(scratch.arena, lister->regs, str8(lister->input_buffer, lister->input_string_size), lister->input_cursor.column-1);
|
||||
|
||||
//////////////////////////
|
||||
//- rjf: selected item hash -> cursor
|
||||
//
|
||||
Vec2S64 cursor = {0};
|
||||
for EachIndex(idx, item_array.count)
|
||||
{
|
||||
RD_ListerItem *item = &item_array.v[idx];
|
||||
U64 hash = rd_hash_from_lister_item(item);
|
||||
if(hash == lister->selected_item_hash)
|
||||
{
|
||||
cursor.y = (S64)(idx+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
//- rjf: push autocompletion hint
|
||||
//
|
||||
if(1 <= cursor.y && cursor.y <= item_array.count)
|
||||
{
|
||||
RD_ListerItem *item = &item_array.v[cursor.y-1];
|
||||
if(item->flags & RD_ListerItemFlag_Autocompletion)
|
||||
{
|
||||
UI_Event evt = zero_struct;
|
||||
evt.kind = UI_EventKind_AutocompleteHint;
|
||||
evt.string = item->string;
|
||||
ui_event_list_push(ui_build_arena(), &ws->ui_events, &evt);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
//- rjf: animate values
|
||||
//
|
||||
F32 fast_rate = 1 - pow_f32(2, (-40.f * rd_state->frame_dt));
|
||||
F32 lister_open_t = ui_anim(ui_key_from_stringf(ui_key_zero(), "lister_open_%p", lister), 1.f);
|
||||
F32 lister_num_of_rows_t = ui_anim(ui_key_from_stringf(ui_key_zero(), "lister_num_of_rows_%p", lister), (F32)item_array.count);
|
||||
lister->scroll_pt.off -= lister->scroll_pt.off*fast_rate;
|
||||
|
||||
//////////////////////////
|
||||
//- rjf: unpack build parameters
|
||||
//
|
||||
F32 squish = (0.25f - 0.25f*lister_open_t);
|
||||
F32 transparency = (1.f - lister_open_t);
|
||||
F32 row_height_px = floor_f32(ui_top_font_size()*3.f);
|
||||
if(lister->regs->lister_flags & RD_ListerFlag_Descriptions)
|
||||
{
|
||||
row_height_px += floor_f32(ui_top_font_size()*3.f);
|
||||
}
|
||||
Vec2F32 content_rect_dim = dim_2f32(content_rect);
|
||||
Vec2F32 content_rect_center = center_2f32(content_rect);
|
||||
F32 line_edit_height_px = 0;
|
||||
if(lister->regs->lister_flags & RD_ListerFlag_LineEdit)
|
||||
{
|
||||
line_edit_height_px = floor_f32(ui_top_font_size()*3.f);
|
||||
}
|
||||
line_edit_height_px = Min(line_edit_height_px, row_height_px);
|
||||
F32 lister_height_max = content_rect_dim.y*0.9f;
|
||||
Vec2F32 lister_dim_px =
|
||||
{
|
||||
content_rect_dim.x*0.5f,
|
||||
line_edit_height_px + lister_num_of_rows_t*row_height_px,
|
||||
};
|
||||
if(!ui_box_is_nil(anchor_box) && flags & RD_ListerFlag_SizeByAnchor)
|
||||
{
|
||||
lister_dim_px.x = dim_2f32(anchor_box->rect).x;
|
||||
}
|
||||
else if(!ui_box_is_nil(anchor_box))
|
||||
{
|
||||
lister_dim_px.x = ui_top_font_size()*50.f;
|
||||
}
|
||||
lister_dim_px.x = Max(lister_dim_px.x, ui_top_font_size()*50.f);
|
||||
lister_dim_px.y = Min(lister_dim_px.y, lister_height_max);
|
||||
Vec2F32 lister_pos_px =
|
||||
{
|
||||
content_rect_center.x - lister_dim_px.x/2,
|
||||
content_rect_center.y - content_rect_dim.y*0.9f/2,
|
||||
};
|
||||
if(!ui_box_is_nil(anchor_box))
|
||||
{
|
||||
lister_pos_px = v2f32(anchor_box->rect.x0 + lister->regs->off_px.x,
|
||||
anchor_box->rect.y0 + lister->regs->off_px.y);
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
//- rjf: build top-level lister box
|
||||
//
|
||||
ui_set_next_fixed_x(lister_pos_px.x);
|
||||
ui_set_next_fixed_y(lister_pos_px.y);
|
||||
ui_set_next_pref_width(ui_px(lister_dim_px.x, 1.f));
|
||||
ui_set_next_pref_height(ui_px(lister_dim_px.y, 1.f));
|
||||
ui_set_next_child_layout_axis(Axis2_Y);
|
||||
ui_set_next_corner_radius_01(ui_top_font_size()*0.25f);
|
||||
ui_set_next_corner_radius_11(ui_top_font_size()*0.25f);
|
||||
UI_Focus(UI_FocusKind_On)
|
||||
UI_Squish(squish)
|
||||
UI_Transparency(transparency)
|
||||
{
|
||||
lister_box = ui_build_box_from_key(UI_BoxFlag_Clickable|
|
||||
UI_BoxFlag_Clip|
|
||||
UI_BoxFlag_RoundChildrenByParent|
|
||||
UI_BoxFlag_DisableFocusOverlay|
|
||||
UI_BoxFlag_DrawBorder|
|
||||
UI_BoxFlag_DrawBackgroundBlur|
|
||||
UI_BoxFlag_DrawDropShadow|
|
||||
UI_BoxFlag_DrawBackground,
|
||||
task->root_key);
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
//- rjf: build lister line edit
|
||||
//
|
||||
if(flags & RD_ListerFlag_LineEdit)
|
||||
UI_WidthFill
|
||||
UI_Parent(lister_box)
|
||||
UI_Focus(UI_FocusKind_On)
|
||||
RD_Font(RD_FontSlot_Code)
|
||||
{
|
||||
UI_PrefHeight(ui_px(line_edit_height_px, 1.f))
|
||||
{
|
||||
#if 0 // TODO(rjf): @cfg
|
||||
UI_Signal sig = rd_line_edit(RD_LineEditFlag_Border|RD_LineEditFlag_CodeContents,
|
||||
0,
|
||||
0,
|
||||
&lister->input_cursor,
|
||||
&lister->input_mark,
|
||||
lister->input_buffer,
|
||||
sizeof(lister->input_buffer),
|
||||
&lister->input_string_size,
|
||||
0,
|
||||
str8(lister->input_buffer, lister->input_string_size),
|
||||
str8_lit("###lister_text_input"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
//- rjf: build lister contents
|
||||
//
|
||||
UI_ScrollListParams params =
|
||||
{
|
||||
.flags = UI_ScrollListFlag_All,
|
||||
.dim_px = v2f32(lister_dim_px.x, lister_dim_px.y - line_edit_height_px),
|
||||
.row_height_px = row_height_px,
|
||||
.cursor_range = r2s64(v2s64(0, 0), v2s64(0, item_array.count)),
|
||||
.item_range = r1s64(0, item_array.count),
|
||||
.cursor_min_is_empty_selection[Axis2_Y] = 1,
|
||||
};
|
||||
Rng1S64 visible_row_range = {0};
|
||||
UI_ScrollListSignal scroll_list_signal = {0};
|
||||
UI_WidthFill UI_HeightFill
|
||||
UI_Parent(lister_box)
|
||||
UI_Focus(UI_FocusKind_On)
|
||||
UI_ScrollList(¶ms, &lister->scroll_pt, &cursor, 0, &visible_row_range, &scroll_list_signal)
|
||||
UI_Focus(UI_FocusKind_Null)
|
||||
{
|
||||
UI_HoverCursor(OS_Cursor_HandPoint)
|
||||
for(S64 idx = visible_row_range.min; 0 <= idx && idx < visible_row_range.max && idx < item_array.count; idx += 1)
|
||||
{
|
||||
RD_ListerItem *item = &item_array.v[idx];
|
||||
B32 item_is_selected = (idx == cursor.y-1);
|
||||
UI_FocusHot(item_is_selected ? UI_FocusKind_On : UI_FocusKind_Off)
|
||||
{
|
||||
//- rjf: build the top-level box for the item
|
||||
UI_Box *item_box = ui_build_box_from_stringf(UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawHotEffects|UI_BoxFlag_DrawActiveEffects|UI_BoxFlag_MouseClickable, "autocomp_%I64x", idx);
|
||||
|
||||
//- rjf: build item contents
|
||||
UI_Parent(item_box) UI_Padding(ui_em(1.f, 1.f))
|
||||
{
|
||||
// rjf: icon
|
||||
if(item->icon_kind != RD_IconKind_Null)
|
||||
UI_PrefWidth(ui_em(2.f, 1.f))
|
||||
UI_Column
|
||||
UI_Padding(ui_pct(1, 0))
|
||||
RD_Font(RD_FontSlot_Icons)
|
||||
{
|
||||
ui_label(rd_icon_kind_text_table[item->icon_kind]);
|
||||
}
|
||||
|
||||
// rjf: name / description
|
||||
UI_Column UI_Padding(ui_pct(1, 0)) UI_PrefHeight(ui_em(2.f, 1.f))
|
||||
{
|
||||
// rjf: name
|
||||
UI_WidthFill UI_Row UI_PrefWidth(ui_text_dim(1, 0)) UI_TextAlignment(UI_TextAlign_Center)
|
||||
{
|
||||
// rjf: display name
|
||||
RD_Font(item->flags & RD_ListerItemFlag_IsNonCode ? RD_FontSlot_Main : RD_FontSlot_Code)
|
||||
{
|
||||
UI_Box *box = item->flags & RD_ListerItemFlag_IsNonCode ? ui_label(item->display_name).box : rd_code_label(1.f, 0, ui_top_palette()->text, item->display_name);
|
||||
ui_box_equip_fuzzy_match_ranges(box, &item->display_name__matches);
|
||||
}
|
||||
|
||||
// rjf: kind name
|
||||
if(flags & RD_ListerFlag_KindLabel && item->kind_name.size != 0)
|
||||
{
|
||||
ui_spacer(ui_em(1.f, 1.f));
|
||||
UI_CornerRadius(ui_top_font_size()*0.5f)
|
||||
{
|
||||
ui_set_next_pref_width(ui_children_sum(1));
|
||||
ui_set_next_flags(UI_BoxFlag_DrawBorder);
|
||||
UI_Row UI_Padding(ui_em(0.5f, 1.f)) UI_TagF("weak")
|
||||
{
|
||||
UI_Box *box = ui_build_box_from_key(UI_BoxFlag_DrawText, ui_key_zero());
|
||||
ui_box_equip_display_string(box, item->kind_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: description
|
||||
if(flags & RD_ListerFlag_Descriptions)
|
||||
{
|
||||
if(item->description.size != 0) UI_WidthFill UI_Row UI_PrefWidth(ui_text_dim(1, 0)) UI_TagF("weak")
|
||||
{
|
||||
UI_Box *box = ui_label(item->description).box;
|
||||
ui_box_equip_fuzzy_match_ranges(box, &item->description__matches);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: bindings
|
||||
if(item->flags & RD_ListerItemFlag_Bindings) UI_Focus(UI_FocusKind_Off)
|
||||
{
|
||||
ui_set_next_flags(UI_BoxFlag_Clickable);
|
||||
UI_PrefWidth(ui_children_sum(1.f)) UI_HeightFill UI_NamedColumn(str8_lit("binding_column")) UI_Padding(ui_px(row_height_px/4.f, 0.f))
|
||||
{
|
||||
ui_set_next_flags(UI_BoxFlag_Clickable);
|
||||
UI_NamedRow(str8_lit("binding_row"))
|
||||
{
|
||||
rd_cmd_binding_buttons(item->string);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: do interaction with top-level item
|
||||
UI_Signal item_sig = ui_signal_from_box(item_box);
|
||||
if(ui_clicked(item_sig))
|
||||
{
|
||||
#if 0 // TODO(rjf): @cfg_lister
|
||||
UI_Event move_back_evt = zero_struct;
|
||||
move_back_evt.kind = UI_EventKind_Navigate;
|
||||
move_back_evt.flags = UI_EventFlag_KeepMark;
|
||||
move_back_evt.delta_2s32.x = -(S32)query_word.size;
|
||||
ui_event_list_push(ui_build_arena(), &ws->ui_events, &move_back_evt);
|
||||
UI_Event paste_evt = zero_struct;
|
||||
paste_evt.kind = UI_EventKind_Text;
|
||||
paste_evt.string = item->string;
|
||||
ui_event_list_push(ui_build_arena(), &ws->ui_events, &paste_evt);
|
||||
lister_box->default_nav_focus_hot_key = lister_box->default_nav_focus_active_key = lister_box->default_nav_focus_next_hot_key = lister_box->default_nav_focus_next_active_key = ui_key_zero();
|
||||
#endif
|
||||
}
|
||||
else if(item_box->flags & UI_BoxFlag_FocusHot && !(item_box->flags & UI_BoxFlag_FocusHotDisabled))
|
||||
{
|
||||
UI_Event evt = zero_struct;
|
||||
evt.kind = UI_EventKind_AutocompleteHint;
|
||||
evt.string = item->string;
|
||||
ui_event_list_push(ui_build_arena(), &ws->ui_events, &evt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
//- rjf: cursor -> selected item hash
|
||||
//
|
||||
if(1 <= cursor.y && cursor.y <= item_array.count)
|
||||
{
|
||||
RD_ListerItem *item = &item_array.v[cursor.y-1];
|
||||
U64 hash = rd_hash_from_lister_item(item);
|
||||
lister->selected_item_hash = hash;
|
||||
}
|
||||
else
|
||||
{
|
||||
lister->selected_item_hash = 0;
|
||||
}
|
||||
|
||||
di_scope_close(di_scope);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0 // TODO(rjf): @cfg_lister
|
||||
////////////////////////////
|
||||
//- rjf: prepare query state for the in-progress query command
|
||||
//
|
||||
if(ws->query_cmd_name.size != 0)
|
||||
{
|
||||
RD_CmdKindInfo *cmd_kind_info = rd_cmd_kind_info_from_string(ws->query_cmd_name);
|
||||
RD_RegSlot missing_slot = cmd_kind_info->query.slot;
|
||||
|
||||
//- rjf: if our input is stale, w.r.t. the current query command, initialize input state
|
||||
if(ws->query_input_gen < ws->query_cmd_gen)
|
||||
{
|
||||
ws->query_input_gen = ws->query_cmd_gen;
|
||||
String8 default_query_input = {0};
|
||||
ws->query_input_string_size = Min(sizeof(ws->query_input_buffer), default_query_input.size);
|
||||
MemoryCopy(ws->query_input_buffer, default_query_input.str, ws->query_input_string_size);
|
||||
ws->query_input_cursor = ws->query_input_mark = txt_pt(1, ws->query_input_string_size+1);
|
||||
}
|
||||
|
||||
#if 0 // TODO(rjf): @cfg_lister (query state prep)
|
||||
String8 query_view_name = cmd_kind_info->query.view_name;
|
||||
if(query_view_name.size == 0)
|
||||
{
|
||||
switch(missing_slot)
|
||||
{
|
||||
default:{}break;
|
||||
case RD_RegSlot_Thread:
|
||||
case RD_RegSlot_Module:
|
||||
case RD_RegSlot_Process:
|
||||
case RD_RegSlot_Machine:
|
||||
case RD_RegSlot_CtrlEntity:{query_view_name = rd_view_rule_kind_info_table[RD_ViewRuleKind_CtrlEntityLister].string;}break;
|
||||
case RD_RegSlot_Entity: {query_view_name = rd_view_rule_kind_info_table[RD_ViewRuleKind_EntityLister].string;}break;
|
||||
case RD_RegSlot_EntityList:{query_view_name = rd_view_rule_kind_info_table[RD_ViewRuleKind_EntityLister].string;}break;
|
||||
case RD_RegSlot_FilePath: {query_view_name = rd_view_rule_kind_info_table[RD_ViewRuleKind_FileSystem].string;}break;
|
||||
case RD_RegSlot_PID: {query_view_name = rd_view_rule_kind_info_table[RD_ViewRuleKind_SystemProcesses].string;}break;
|
||||
}
|
||||
}
|
||||
RD_ViewRuleInfo *view_spec = rd_view_rule_info_from_string(query_view_name);
|
||||
if(!str8_match(ws->query_view_stack_top->string, view_spec->string, 0) ||
|
||||
ws->query_view_stack_top == &rd_nil_cfg)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
|
||||
// rjf: clear existing query stack
|
||||
rd_cfg_release(ws->query_view_stack_top);
|
||||
|
||||
// rjf: determine default query
|
||||
String8 default_query = {0};
|
||||
switch(missing_slot)
|
||||
{
|
||||
default:
|
||||
if(cmd_kind_info->query.flags & RD_QueryFlag_KeepOldInput)
|
||||
{
|
||||
default_query = rd_push_search_string(scratch.arena);
|
||||
}break;
|
||||
case RD_RegSlot_FilePath:
|
||||
{
|
||||
default_query = path_normalized_from_string(scratch.arena, rd_state->current_path);
|
||||
default_query = push_str8f(scratch.arena, "%S/", default_query);
|
||||
}break;
|
||||
}
|
||||
|
||||
// rjf: construct & push new view
|
||||
RD_Cfg *bucket = rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("transient"));
|
||||
RD_Cfg *view = rd_cfg_new(bucket, view_spec->string);
|
||||
RD_Cfg *filter = rd_cfg_new(view, str8_lit("filter"));
|
||||
rd_cfg_new(filter, default_query);
|
||||
RD_ViewState *view_state = rd_view_state_from_cfg(view);
|
||||
view_state->filter_cursor = txt_pt(1, default_query.size+1);
|
||||
if(cmd_kind_info->query.flags & RD_QueryFlag_SelectOldInput)
|
||||
{
|
||||
view_state->filter_mark = txt_pt(1, 1);
|
||||
}
|
||||
ws->query_view_stack_top = view;
|
||||
ws->query_view_selected = 1;
|
||||
|
||||
scratch_end(scratch);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
//- rjf: build query
|
||||
//
|
||||
if(query_is_open)
|
||||
UI_Focus((window_is_focused && !ui_any_ctx_menu_is_open() && !ws->menu_bar_focused && ws->query_input_selected) ? UI_FocusKind_On : UI_FocusKind_Off)
|
||||
RD_Palette(RD_PaletteCode_Floating)
|
||||
{
|
||||
String8 query_cmd_name = ws->query_cmd_name;
|
||||
RD_CmdKindInfo *query_cmd_info = rd_cmd_kind_info_from_string(query_cmd_name);
|
||||
RD_Query *query = &query_cmd_info->query;
|
||||
F32 query_view_t = ui_anim(ui_key_from_stringf(ui_key_zero(), "###%p_query_view_t", ws), 1.f);
|
||||
F32 query_squish = 0.25f - query_view_t*0.25f;
|
||||
F32 query_transparency = 1.f - query_view_t;
|
||||
|
||||
//- rjf: calculate rectangles
|
||||
Vec2F32 window_center = center_2f32(window_rect);
|
||||
Vec2F32 query_input_dim = v2f32(dim_2f32(window_rect).x*0.5f, ui_top_font_size()*3.f);
|
||||
F32 query_input_margin = ui_top_font_size()*8.f;
|
||||
Rng2F32 query_input_rect = r2f32p(window_center.x - query_input_dim.x/2,
|
||||
window_rect.y0 + query_input_margin,
|
||||
window_center.x + query_input_dim.x/2,
|
||||
window_rect.y0 + query_input_margin + query_input_dim.y);
|
||||
|
||||
//- rjf: build floating query container
|
||||
UI_Box *query_container_box = &ui_nil_box;
|
||||
UI_Rect(query_input_rect)
|
||||
UI_CornerRadius00(ui_top_font_size()*0.2f)
|
||||
UI_CornerRadius10(ui_top_font_size()*0.2f)
|
||||
UI_ChildLayoutAxis(Axis2_Y)
|
||||
UI_Squish(query_squish)
|
||||
UI_Transparency(query_transparency)
|
||||
{
|
||||
query_container_box = ui_build_box_from_stringf(UI_BoxFlag_Floating|
|
||||
UI_BoxFlag_AllowOverflow|
|
||||
UI_BoxFlag_Clickable|
|
||||
UI_BoxFlag_Clip|
|
||||
UI_BoxFlag_DisableFocusOverlay|
|
||||
UI_BoxFlag_DrawBorder|
|
||||
UI_BoxFlag_DrawBackground|
|
||||
UI_BoxFlag_DrawBackgroundBlur|
|
||||
UI_BoxFlag_DrawDropShadow,
|
||||
"query_container");
|
||||
}
|
||||
|
||||
//- rjf: set up autocompletion lister info
|
||||
if(ui_is_focus_active())
|
||||
{
|
||||
rd_set_autocomp_lister_query(.anchor_key = query_container_box->key,
|
||||
.anchor_off = v2f32(0, dim_2f32(query_container_box->rect).y - dim_2f32(query_container_box->rect).y*(1-query_view_t)*0.25f - 2.f),
|
||||
.flags = 0xffffffff,
|
||||
.input = str8(ws->query_input_buffer, ws->query_input_string_size),
|
||||
.cursor_off = ws->query_input_cursor.column-1,
|
||||
.squish = query_squish,
|
||||
.transparency= query_transparency);
|
||||
}
|
||||
|
||||
//- rjf: build query text input
|
||||
B32 query_completed = 0;
|
||||
B32 query_cancelled = 0;
|
||||
UI_Parent(query_container_box)
|
||||
UI_WidthFill UI_HeightFill
|
||||
UI_Focus(UI_FocusKind_On)
|
||||
{
|
||||
ui_set_next_flags(UI_BoxFlag_DrawDropShadow|UI_BoxFlag_DrawBorder);
|
||||
UI_Row
|
||||
{
|
||||
UI_PrefWidth(ui_text_dim(0.f, 1.f)) UI_Padding(ui_em(1.f, 1.f))
|
||||
{
|
||||
RD_IconKind icon_kind = query_cmd_info->icon_kind;
|
||||
if(icon_kind != RD_IconKind_Null)
|
||||
{
|
||||
RD_Font(RD_FontSlot_Icons) ui_label(rd_icon_kind_text_table[icon_kind]);
|
||||
}
|
||||
ui_labelf("%S", query_cmd_info->display_name);
|
||||
}
|
||||
RD_Font((query->flags & RD_QueryFlag_CodeInput) ? RD_FontSlot_Code : RD_FontSlot_Main)
|
||||
UI_TextPadding(ui_top_font_size()*0.5f)
|
||||
{
|
||||
UI_Signal sig = rd_line_edit(RD_LineEditFlag_Border|
|
||||
(RD_LineEditFlag_CodeContents * !!(query->flags & RD_QueryFlag_CodeInput)),
|
||||
0,
|
||||
0,
|
||||
&ws->query_input_cursor,
|
||||
&ws->query_input_mark,
|
||||
ws->query_input_buffer,
|
||||
sizeof(ws->query_input_buffer),
|
||||
&ws->query_input_string_size,
|
||||
0,
|
||||
str8(ws->query_input_buffer, ws->query_input_string_size),
|
||||
str8_lit("###query_text_input"));
|
||||
if(ui_pressed(sig))
|
||||
{
|
||||
ws->query_input_selected = 1;
|
||||
}
|
||||
}
|
||||
UI_PrefWidth(ui_em(5.f, 1.f)) UI_Focus(UI_FocusKind_Off) RD_Palette(RD_PaletteCode_PositivePopButton)
|
||||
{
|
||||
if(ui_clicked(rd_icon_buttonf(RD_IconKind_RightArrow, 0, "##complete_query")))
|
||||
{
|
||||
query_completed = 1;
|
||||
}
|
||||
}
|
||||
UI_PrefWidth(ui_em(3.f, 1.f)) UI_Focus(UI_FocusKind_Off) RD_Palette(RD_PaletteCode_PlainButton)
|
||||
{
|
||||
if(ui_clicked(rd_icon_buttonf(RD_IconKind_X, 0, "##cancel_query")))
|
||||
{
|
||||
query_cancelled = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: query submission
|
||||
if(((ui_is_focus_active() || (window_is_focused && !ui_any_ctx_menu_is_open() && !ws->menu_bar_focused && !ws->query_input_selected)) &&
|
||||
ui_slot_press(UI_EventActionSlot_Cancel)) || query_cancelled)
|
||||
{
|
||||
rd_cmd(RD_CmdKind_CancelQuery);
|
||||
}
|
||||
if((ui_is_focus_active() && ui_slot_press(UI_EventActionSlot_Accept)) || query_completed)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
RD_RegsScope()
|
||||
{
|
||||
rd_regs_fill_slot_from_string(query->slot, str8(ws->query_input_buffer, ws->query_input_string_size));
|
||||
rd_cmd(RD_CmdKind_CompleteQuery);
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
//- rjf: take fallthrough interaction in query view
|
||||
{
|
||||
UI_Signal sig = ui_signal_from_box(query_container_box);
|
||||
if(ui_pressed(sig))
|
||||
{
|
||||
ws->query_input_selected = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ws->query_input_selected = 0;
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
//- rjf: darken lower layer ui when query is selected
|
||||
//
|
||||
F32 query_input_selected_t = ui_anim(ui_key_from_stringf(ui_key_zero(), "%p_query_input_selected", ws), (F32)!!ws->query_input_selected);
|
||||
UI_Palette(ui_build_palette(0, .background = mix_4f32(rd_rgba_from_theme_color(RD_ThemeColor_InactivePanelOverlay), v4f32(0, 0, 0, 0), 1-query_input_selected_t)))
|
||||
UI_Rect(window_rect)
|
||||
{
|
||||
ui_build_box_from_key(UI_BoxFlag_DrawBackground, ui_key_zero());
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////
|
||||
//- rjf: top-level registers context menu
|
||||
//
|
||||
@@ -7372,66 +6819,6 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The
|
||||
ui_signal_from_box(catchall_drop_site);
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
//- rjf: build filtering box
|
||||
//
|
||||
#if 0 // TODO(rjf): @cfg
|
||||
{
|
||||
RD_Cfg *view = selected_tab;
|
||||
RD_ViewRuleInfo *view_rule_info = rd_view_rule_info_from_string(view->string);
|
||||
RD_ViewState *view_state = rd_view_state_from_cfg(view);
|
||||
UI_Focus(UI_FocusKind_On) RD_RegsScope(.view = view->id)
|
||||
{
|
||||
if(view_state->is_filtering && ui_is_focus_active() && ui_slot_press(UI_EventActionSlot_Accept))
|
||||
{
|
||||
rd_cmd(RD_CmdKind_ApplyFilter);
|
||||
}
|
||||
if(view_state->is_filtering || selected_tab_is_filtering_t > 0.01f)
|
||||
{
|
||||
UI_Box *filter_box = &ui_nil_box;
|
||||
UI_Rect(filter_rect)
|
||||
{
|
||||
ui_set_next_child_layout_axis(Axis2_X);
|
||||
filter_box = ui_build_box_from_stringf(UI_BoxFlag_DrawBackground|UI_BoxFlag_Clip|UI_BoxFlag_DrawBorder, "filter_box_%p", view);
|
||||
}
|
||||
UI_Parent(filter_box) UI_WidthFill UI_HeightFill
|
||||
{
|
||||
UI_PrefWidth(ui_em(3.f, 1.f))
|
||||
UI_TagF("weak")
|
||||
RD_Font(RD_FontSlot_Icons)
|
||||
UI_TextAlignment(UI_TextAlign_Center)
|
||||
ui_label(rd_icon_kind_text_table[RD_IconKind_Find]);
|
||||
UI_PrefWidth(ui_text_dim(10, 1))
|
||||
{
|
||||
ui_label(str8_lit("Filter"));
|
||||
}
|
||||
ui_spacer(ui_em(0.5f, 1.f));
|
||||
RD_Font(view_rule_info->flags & RD_ViewRuleInfoFlag_FilterIsCode ? RD_FontSlot_Code : RD_FontSlot_Main)
|
||||
UI_Focus(view_state->is_filtering ? UI_FocusKind_On : UI_FocusKind_Off)
|
||||
UI_TextPadding(ui_top_font_size()*0.5f)
|
||||
{
|
||||
UI_Signal sig = rd_line_edit(RD_LineEditFlag_CodeContents*!!(view_rule_info->flags & RD_ViewRuleInfoFlag_FilterIsCode),
|
||||
0,
|
||||
0,
|
||||
&view_state->filter_cursor,
|
||||
&view_state->filter_mark,
|
||||
view_state->filter_buffer,
|
||||
sizeof(view_state->filter_buffer),
|
||||
&view_state->filter_string_size,
|
||||
0,
|
||||
str8(view_state->filter_buffer, view_state->filter_string_size),
|
||||
str8_lit("###filter_text_input"));
|
||||
if(ui_pressed(sig))
|
||||
{
|
||||
rd_cmd(RD_CmdKind_FocusPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////////////////
|
||||
//- rjf: panel not selected? -> darken
|
||||
//
|
||||
@@ -7540,40 +6927,6 @@ ws->cfg_palettes[RD_PaletteCode_##name].selection = current->colors[RD_The
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
//- rjf: take events to automatically start/end filtering, if applicable
|
||||
//
|
||||
#if 0 // TODO(rjf): @cfg
|
||||
UI_Focus(UI_FocusKind_On)
|
||||
{
|
||||
RD_Cfg *view = selected_tab;
|
||||
RD_ViewState *view_state = selected_tab_view_state;
|
||||
RD_ViewRuleInfo *view_rule_info = rd_view_rule_info_from_string(view->string);
|
||||
if(ui_is_focus_active() && view_rule_info->flags & RD_ViewRuleInfoFlag_TypingAutomaticallyFilters && !view_state->is_filtering)
|
||||
{
|
||||
for(UI_Event *evt = 0; ui_next_event(&evt);)
|
||||
{
|
||||
if(evt->flags & UI_EventFlag_Paste)
|
||||
{
|
||||
ui_eat_event(evt);
|
||||
rd_cmd(RD_CmdKind_Filter);
|
||||
rd_cmd(RD_CmdKind_Paste);
|
||||
}
|
||||
else if(evt->string.size != 0 && evt->kind == UI_EventKind_Text)
|
||||
{
|
||||
ui_eat_event(evt);
|
||||
rd_cmd(RD_CmdKind_Filter);
|
||||
rd_cmd(RD_CmdKind_InsertText, .string = evt->string);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(view_rule_info->flags & RD_ViewRuleInfoFlag_CanFilter && (view_state->filter_string_size != 0 || view_state->is_filtering) && ui_is_focus_active() && ui_slot_press(UI_EventActionSlot_Cancel))
|
||||
{
|
||||
rd_cmd(RD_CmdKind_ClearFilter);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////////////////
|
||||
//- rjf: consume panel fallthrough interaction events
|
||||
//
|
||||
@@ -12148,19 +11501,6 @@ rd_frame(void)
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
//- rjf: sanitize the window/panel/tab tree structure
|
||||
//
|
||||
{
|
||||
// TODO(rjf): @cfg_panels in the past, we had a spot in the rd_window_frame,
|
||||
// which ensured to select tabs, if a panel had tabs but had none
|
||||
// selected, and if a panel had a selected tab but it was project-filtered.
|
||||
// this is effectively just fixing up unexpected malformations of the
|
||||
// panel tree - because we are adopting some number of new possibilities
|
||||
// of this via the cfg change, we can just actually do a single fixup
|
||||
// point here.
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
//- rjf: process top-level graphical commands
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user