Skip to content

Commit af7f571

Browse files
committed
adjust menu bar
1 parent 499fe63 commit af7f571

File tree

3 files changed

+94
-33
lines changed

3 files changed

+94
-33
lines changed

src/raddbg/raddbg_core.c

Lines changed: 69 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6622,32 +6622,36 @@ rd_window_frame(void)
66226622
{
66236623
rd_cmd_kind_info_table[RD_CmdKind_Open].string,
66246624
rd_cmd_kind_info_table[RD_CmdKind_Switch].string,
6625-
rd_cmd_kind_info_table[RD_CmdKind_OpenPalette].string,
6625+
{0},//-
66266626
rd_cmd_kind_info_table[RD_CmdKind_NewUser].string,
6627-
rd_cmd_kind_info_table[RD_CmdKind_NewProject].string,
66286627
rd_cmd_kind_info_table[RD_CmdKind_OpenUser].string,
6628+
rd_cmd_kind_info_table[RD_CmdKind_SaveUser].string,
6629+
rd_cmd_kind_info_table[RD_CmdKind_UserSettings].string,
6630+
{0},//-
6631+
rd_cmd_kind_info_table[RD_CmdKind_NewProject].string,
66296632
rd_cmd_kind_info_table[RD_CmdKind_OpenProject].string,
66306633
rd_cmd_kind_info_table[RD_CmdKind_OpenRecentProject].string,
6631-
rd_cmd_kind_info_table[RD_CmdKind_SaveUser].string,
66326634
rd_cmd_kind_info_table[RD_CmdKind_SaveProject].string,
6633-
rd_cmd_kind_info_table[RD_CmdKind_UserSettings].string,
66346635
rd_cmd_kind_info_table[RD_CmdKind_ProjectSettings].string,
6636+
{0},//-
66356637
rd_cmd_kind_info_table[RD_CmdKind_Exit].string,
66366638
};
66376639
U32 codepoints[] =
66386640
{
66396641
'o',
66406642
'i',
6641-
'n',
6643+
0,//-
66426644
'w',
6643-
'j',
66446645
'u',
6646+
's',
6647+
'e',
6648+
0,//-
6649+
'j',
66456650
'p',
66466651
'r',
6647-
's',
66486652
'a',
6649-
'e',
66506653
't',
6654+
0,//-
66516655
'x',
66526656
};
66536657
Assert(ArrayCount(codepoints) == ArrayCount(cmds));
@@ -6663,13 +6667,15 @@ rd_window_frame(void)
66636667
rd_cmd_kind_info_table[RD_CmdKind_OpenWindow].string,
66646668
rd_cmd_kind_info_table[RD_CmdKind_CloseWindow].string,
66656669
rd_cmd_kind_info_table[RD_CmdKind_ToggleFullscreen].string,
6670+
{0},//-
66666671
rd_cmd_kind_info_table[RD_CmdKind_WindowSettings].string,
66676672
};
66686673
U32 codepoints[] =
66696674
{
66706675
'w',
66716676
'c',
66726677
'f',
6678+
0,//-
66736679
's',
66746680
};
66756681
Assert(ArrayCount(codepoints) == ArrayCount(cmds));
@@ -6687,11 +6693,13 @@ rd_window_frame(void)
66876693
rd_cmd_kind_info_table[RD_CmdKind_NewPanelRight].string,
66886694
rd_cmd_kind_info_table[RD_CmdKind_NewPanelLeft].string,
66896695
rd_cmd_kind_info_table[RD_CmdKind_ClosePanel].string,
6690-
rd_cmd_kind_info_table[RD_CmdKind_RotatePanelColumns].string,
6696+
{0},//-
66916697
rd_cmd_kind_info_table[RD_CmdKind_NextPanel].string,
66926698
rd_cmd_kind_info_table[RD_CmdKind_PrevPanel].string,
6699+
{0},//-
66936700
rd_cmd_kind_info_table[RD_CmdKind_TabBarTop].string,
66946701
rd_cmd_kind_info_table[RD_CmdKind_TabBarBottom].string,
6702+
{0},//-
66956703
rd_cmd_kind_info_table[RD_CmdKind_ResetToDefaultPanels].string,
66966704
rd_cmd_kind_info_table[RD_CmdKind_ResetToCompactPanels].string,
66976705
rd_cmd_kind_info_table[RD_CmdKind_ResetToSimplePanels].string,
@@ -6702,12 +6710,14 @@ rd_window_frame(void)
67026710
'd',
67036711
'r',
67046712
'l',
6705-
'x',
6706-
'c',
6713+
'o',
6714+
0,//-
67076715
'n',
67086716
'p',
6717+
0,//-
67096718
0,
67106719
0,
6720+
0,//-
67116721
0,
67126722
0,
67136723
0,
@@ -6725,21 +6735,27 @@ rd_window_frame(void)
67256735
rd_cmd_kind_info_table[RD_CmdKind_OpenTab].string,
67266736
rd_cmd_kind_info_table[RD_CmdKind_CloseTab].string,
67276737
rd_cmd_kind_info_table[RD_CmdKind_DuplicateTab].string,
6738+
{0},//-
67286739
rd_cmd_kind_info_table[RD_CmdKind_MoveTabLeft].string,
67296740
rd_cmd_kind_info_table[RD_CmdKind_MoveTabRight].string,
6741+
{0},//-
67306742
rd_cmd_kind_info_table[RD_CmdKind_NextTab].string,
67316743
rd_cmd_kind_info_table[RD_CmdKind_PrevTab].string,
6744+
{0},//-
67326745
rd_cmd_kind_info_table[RD_CmdKind_TabSettings].string,
67336746
};
67346747
U32 codepoints[] =
67356748
{
67366749
'o',
67376750
'c',
67386751
'd',
6752+
0,//-
67396753
'l',
67406754
'r',
6755+
0,//-
67416756
'n',
67426757
'p',
6758+
0,//-
67436759
's',
67446760
};
67456761
Assert(ArrayCount(codepoints) == ArrayCount(cmds));
@@ -6778,9 +6794,11 @@ rd_window_frame(void)
67786794
rd_cmd_kind_info_table[D_CmdKind_KillAll].string,
67796795
rd_cmd_kind_info_table[D_CmdKind_Restart].string,
67806796
rd_cmd_kind_info_table[D_CmdKind_Halt].string,
6797+
{0},//-
67816798
rd_cmd_kind_info_table[D_CmdKind_StepInto].string,
67826799
rd_cmd_kind_info_table[D_CmdKind_StepOver].string,
67836800
rd_cmd_kind_info_table[D_CmdKind_StepOut].string,
6801+
{0},//-
67846802
rd_cmd_kind_info_table[D_CmdKind_Attach].string,
67856803
rd_cmd_kind_info_table[D_CmdKind_Detach].string,
67866804
};
@@ -6790,9 +6808,11 @@ rd_window_frame(void)
67906808
'k',
67916809
's',
67926810
'h',
6811+
0,//-
67936812
'i',
67946813
'o',
67956814
't',
6815+
0,//-
67966816
'a',
67976817
'd',
67986818
};
@@ -6816,23 +6836,44 @@ rd_window_frame(void)
68166836
ui_image(texture, R_Tex2DSampleKind_Linear, r2f32p(0, 0, texture_dim.x, texture_dim.y), v4f32(1, 1, 1, 1), 0, str8_lit(""));
68176837
}
68186838
ui_spacer(ui_em(1.f, 1.f));
6819-
UI_Row
6820-
UI_PrefWidth(ui_text_dim(10, 1))
6839+
CFG_KeyMapNodePtrList key_map_nodes = cfg_key_map_node_ptr_list_from_name(scratch.arena, rd_state->key_map, rd_cmd_kind_info_table[RD_CmdKind_OpenPalette].string);
6840+
CFG_Binding binding = {0};
6841+
String8 binding_str = {0};
6842+
if(key_map_nodes.first != 0)
6843+
{
6844+
binding = key_map_nodes.first->v->binding;
6845+
binding_str = os_string_from_modifiers_key(scratch.arena, binding.modifiers, binding.key);
6846+
}
6847+
UI_TagF(".")
6848+
UI_Row
68216849
UI_TextAlignment(UI_TextAlign_Center)
68226850
UI_Padding(ui_pct(1, 0))
68236851
{
6824-
ui_labelf("Search for commands and options by pressing ");
6825-
UI_Flags(UI_BoxFlag_DrawBorder)
6826-
UI_TextAlignment(UI_TextAlign_Center)
6827-
rd_cmd_binding_buttons(rd_cmd_kind_info_table[RD_CmdKind_OpenPalette].string, str8_zero(), 1);
6852+
UI_Signal sig = {0};
6853+
UI_PrefWidth(ui_children_sum(1))
6854+
UI_Flags(UI_BoxFlag_DrawBorder)
6855+
UI_CornerRadius(ui_top_font_size()*0.5f)
6856+
sig = ui_buttonf("###open_palette");
6857+
UI_Parent(sig.box) UI_PrefWidth(ui_text_dim(ui_top_font_size()*2.f, 1))
6858+
{
6859+
ui_labelf("Search for commands & settings");
6860+
if(binding_str.size != 0)
6861+
{
6862+
UI_TagF("weak") ui_labelf("(%S)", binding_str);
6863+
}
6864+
}
6865+
if(ui_clicked(sig))
6866+
{
6867+
rd_cmd(RD_CmdKind_RunCommand, .cmd_name = rd_cmd_kind_info_table[RD_CmdKind_OpenPalette].string);
6868+
}
68286869
}
68296870
ui_spacer(ui_em(1.f, 1.f));
68306871
UI_TagF("pop")
6831-
UI_Row UI_Padding(ui_pct(1, 0)) UI_TextAlignment(UI_TextAlign_Center) UI_PrefWidth(ui_text_dim(10, 1))
6872+
UI_Row UI_Padding(ui_pct(1, 0)) UI_TextAlignment(UI_TextAlign_Center) UI_PrefWidth(ui_text_dim(ui_top_font_size()*2.f, 1))
68326873
UI_CornerRadius(ui_top_font_size()*0.5f)
68336874
{
68346875
String8 url = str8_lit("https://github.com/EpicGamesExt/raddebugger/issues");
6835-
UI_Signal sig = ui_button(str8_lit("Submit Request, Issue, or Bug Report"));
6876+
UI_Signal sig = ui_button(str8_lit("Submit request, issue, or bug report"));
68366877
if(ui_clicked(sig))
68376878
{
68386879
os_open_in_browser(url);
@@ -8830,9 +8871,8 @@ rd_window_frame(void)
88308871
{
88318872
color.w *= b->hot_t;
88328873
}
8874+
color.w *= 0.01f;
88338875
R_Rect2DInst *inst = dr_rect(b_border_rect, color, 0, 1.f, 1.f);
8834-
inst->colors[Corner_01].w *= 0.2f;
8835-
inst->colors[Corner_11].w *= 0.2f;
88368876
MemoryCopyArray(inst->corner_radii, b_corner_radii);
88378877
}
88388878
}
@@ -14648,6 +14688,14 @@ rd_frame(void)
1464814688
String8 cmd_name = rd_regs()->cmd_name;
1464914689
RD_CmdKindInfo *cmd_kind_info = rd_cmd_kind_info_from_string(cmd_name);
1465014690

14691+
// rjf: close existing context menus
14692+
{
14693+
CFG_Node *window = cfg_node_from_id(rd_regs()->window);
14694+
RD_WindowState *ws = rd_window_state_from_cfg(window);
14695+
ui_ctx_menu_close();
14696+
ws->menu_bar_focused = 0;
14697+
}
14698+
1465114699
// rjf: floating queries -> set up window to build immediate-mode top-level query
1465214700
CFG_Node *view = &cfg_nil_node;
1465314701
B32 is_floating = (cmd_name.size == 0 || cmd_kind_info->query.flags & RD_QueryFlag_Floating);

src/raddbg/raddbg_widgets.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -964,17 +964,24 @@ internal void
964964
rd_cmd_list_menu_buttons(U64 count, String8 *cmd_names, U32 *fastpath_codepoints)
965965
{
966966
Temp scratch = scratch_begin(0, 0);
967-
for(U64 idx = 0; idx < count; idx += 1)
967+
for EachIndex(idx, count)
968968
{
969-
ui_set_next_fastpath_codepoint(fastpath_codepoints[idx]);
970-
UI_Signal sig = rd_cmd_spec_button(cmd_names[idx]);
971-
if(ui_clicked(sig))
969+
if(cmd_names[idx].size == 0)
972970
{
973-
rd_cmd(RD_CmdKind_RunCommand, .cmd_name = cmd_names[idx]);
974-
ui_ctx_menu_close();
975-
CFG_Node *window = cfg_node_from_id(rd_regs()->window);
976-
RD_WindowState *ws = rd_window_state_from_cfg(window);
977-
ws->menu_bar_focused = 0;
971+
UI_TagF("floating") ui_divider(ui_em(1.f, 1.f));
972+
}
973+
else
974+
{
975+
ui_set_next_fastpath_codepoint(fastpath_codepoints[idx]);
976+
UI_Signal sig = rd_cmd_spec_button(cmd_names[idx]);
977+
if(ui_clicked(sig))
978+
{
979+
rd_cmd(RD_CmdKind_RunCommand, .cmd_name = cmd_names[idx]);
980+
ui_ctx_menu_close();
981+
CFG_Node *window = cfg_node_from_id(rd_regs()->window);
982+
RD_WindowState *ws = rd_window_state_from_cfg(window);
983+
ws->menu_bar_focused = 0;
984+
}
978985
}
979986
}
980987
scratch_end(scratch);

src/ui/ui_basic_widgets.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ ui_divider(UI_Size size)
1111
ui_set_next_pref_size(parent->child_layout_axis, size);
1212
ui_set_next_child_layout_axis(parent->child_layout_axis);
1313
UI_Box *box = ui_build_box_from_key(0, ui_key_zero());
14-
UI_Parent(box) UI_PrefSize(parent->child_layout_axis, ui_pct(1, 0))
14+
UI_Parent(box) UI_Padding(ui_pct(0.5f, 0.5f))
15+
UI_PrefSize(parent->child_layout_axis, ui_em(0.1f, 1.f))
16+
UI_BackgroundColor(ui_color_from_name(str8_lit("border")))
1517
{
16-
ui_build_box_from_key(UI_BoxFlag_DrawSideBottom, ui_key_zero());
17-
ui_build_box_from_key(0, ui_key_zero());
18+
ui_set_next_child_layout_axis(axis2_flip(parent->child_layout_axis));
19+
UI_Box *spacing_parent = ui_build_box_from_key(0, ui_key_zero());
20+
UI_Parent(spacing_parent) UI_Padding(ui_em(1.f, 1.f)) UI_PrefSize(axis2_flip(parent->child_layout_axis), ui_pct(1, 0))
21+
{
22+
ui_build_box_from_key(UI_BoxFlag_DrawBackground, ui_key_zero());
23+
}
1824
}
1925
}
2026

0 commit comments

Comments
 (0)