diff --git a/src/df/core/df_core.mdesk b/src/df/core/df_core.mdesk index ace28f6e..dc42a31b 100644 --- a/src/df/core/df_core.mdesk +++ b/src/df/core/df_core.mdesk @@ -315,6 +315,7 @@ DF_CoreCmdTable:// | | | //- rjf: watch expressions {ToggleWatchExpression 0 Null Nil 0 0 0 0 0 0 Binoculars "toggle_watch_expr" "Toggle Watch Expression" "Adds or removes an expression to an opened watch view." "" } {ToggleWatchExpressionAtCursor 0 Null Nil 0 0 0 0 0 0 Binoculars "toggle_watch_expr_at_cursor" "Toggle Watch Expression At Cursor" "Adds or removes the expression that the cursor or selection is currently over to an opened watch view." "" } + {ToggleWatchExpressionAtMouse 0 Null Nil 0 0 0 0 0 0 Binoculars "toggle_watch_expr_at_mouse" "Toggle Watch Expression At Mouse" "Adds or removes the expression that the mouse is currently over to an opened watch view." "" } //- rjf: memory view parameterization {SetColumns 0 Index Nil 0 0 0 0 1 1 Thumbnails "set_columns" "Set Columns" "Sets the number of columns for a memory view." "" } @@ -507,7 +508,7 @@ DF_CoreViewRuleTable: { {Null null "" - - - - "" - "" "" } {Array array "array" - - x - "Array" x "x:{expr}" "Specifies that a pointer points to N elements, rather than only 1." } - {Slice slice "slice" - - x - "Slice" x "" "Specifies a struct of {data, len} should be rendered as a slice." } + {Slice slice "slice" - - x - "Slice" x "" "Specifies that a pointer within a struct, also containing an integer, points to the number of elements encoded by the integer." } {List list "list" - - - x "List" x "x:{member}" "Specifies that some struct, union, or class forms the top of a linked list, and the member which points at the following element in the list." } {ByteSwap bswap "bswap" x - x - "Byte Swap" x "" "Specifies that all integer primitives should be byte-swapped, such that their endianness is reversed." } {BaseDec base_dec "dec" x - - - "Decimal Base (Base 10)" x "" "Specifies that all integral evaluations should appear in base-10 form." } @@ -524,6 +525,7 @@ DF_CoreViewRuleTable: {Bitmap bitmap "bitmap" - x - x "Bitmap" x "x:{'w':expr, 'h':expr, 'fmt':tex2dformat}" "Displays as a bitmap, interpreting the data as raw pixel data." } {Geo geo "geo" - x - x "Geometry" x "x:{'count':expr, 'vertices_base':expr, 'vertices_size':expr}" "Displays as geometry, interpreting the data as vertex data." } {OdinMap odin_map "odin_map" - x - x "Odin map" x "" "Specifies that a struct should be rendered as an Odin map type." } + {OdinSlice odin_slice "odin_slice" - - x - "Odin slice" x "" "Specifies a struct of {data, len} should be rendered as a slice (odin's)." } } //////////////////////////////// diff --git a/src/df/core/generated/df_core.meta.c b/src/df/core/generated/df_core.meta.c index 8d96e429..a62f7655 100644 --- a/src/df/core/generated/df_core.meta.c +++ b/src/df/core/generated/df_core.meta.c @@ -209,7 +209,7 @@ DF_CoreCmdKind_Null, DF_CoreCmdKind_Null, }; -DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[220] = +DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[221] = { { str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp(""), (DF_CmdSpecFlag_OmitFromLists*1), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Null}, { str8_lit_comp("exit"), str8_lit_comp("Exits the debugger."), str8_lit_comp("quit,close,abort"), str8_lit_comp("Exit"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_X}, @@ -364,6 +364,7 @@ DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[220] = { str8_lit_comp("goto_name_at_cursor"), str8_lit_comp("Searches for the text at the cursor as a file, a symbol in debug info, and more, then jumps to it if possible."), str8_lit_comp(""), str8_lit_comp("Go To Name At Cursor"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Null}, { str8_lit_comp("toggle_watch_expr"), str8_lit_comp("Adds or removes an expression to an opened watch view."), str8_lit_comp(""), str8_lit_comp("Toggle Watch Expression"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Binoculars}, { str8_lit_comp("toggle_watch_expr_at_cursor"), str8_lit_comp("Adds or removes the expression that the cursor or selection is currently over to an opened watch view."), str8_lit_comp(""), str8_lit_comp("Toggle Watch Expression At Cursor"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Binoculars}, +{ str8_lit_comp("toggle_watch_expr_at_mouse"), str8_lit_comp("Adds or removes the expression that the mouse is currently over to an opened watch view."), str8_lit_comp(""), str8_lit_comp("Toggle Watch Expression At Mouse"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Binoculars}, { str8_lit_comp("set_columns"), str8_lit_comp("Sets the number of columns for a memory view."), str8_lit_comp(""), str8_lit_comp("Set Columns"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Index, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*1)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*1)}, DF_IconKind_Thumbnails}, { str8_lit_comp("toggle_address_visibility"), str8_lit_comp("Toggles the visibility of addresses in a disassembly view."), str8_lit_comp(""), str8_lit_comp("Toggle Address Visibility"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Thumbnails}, { str8_lit_comp("toggle_code_bytes_visibility"), str8_lit_comp("Toggles the visibility of machine code bytes in a disassembly view."), str8_lit_comp(""), str8_lit_comp("Toggle Code Bytes Visibility"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Thumbnails}, @@ -433,11 +434,11 @@ DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[220] = { str8_lit_comp("log_marker"), str8_lit_comp("Logs a marker in the application log, to denote specific points in time within the log."), str8_lit_comp(""), str8_lit_comp("Log Marker"), (DF_CmdSpecFlag_OmitFromLists*0), {DF_CmdParamSlot_Null, DF_EntityKind_Nil, (DF_CmdQueryFlag_AllowFiles*0)|(DF_CmdQueryFlag_AllowFolders*0)|(DF_CmdQueryFlag_CodeInput*0)|(DF_CmdQueryFlag_KeepOldInput*0)|(DF_CmdQueryFlag_SelectOldInput*0)|(DF_CmdQueryFlag_Required*0)}, DF_IconKind_Null}, }; -DF_CoreViewRuleSpecInfo df_g_core_view_rule_spec_info_table[19] = +DF_CoreViewRuleSpecInfo df_g_core_view_rule_spec_info_table[20] = { {str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp(""), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*0)|(DF_CoreViewRuleSpecInfoFlag_EvalResolution*0)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*0), 0, 0, }, {str8_lit_comp("array"), str8_lit_comp("Array"), str8_lit_comp("x:{expr}"), str8_lit_comp("Specifies that a pointer points to N elements, rather than only 1."), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*0)|(DF_CoreViewRuleSpecInfoFlag_EvalResolution*1)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*0), DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_NAME(array) , 0, }, -{str8_lit_comp("slice"), str8_lit_comp("Slice"), str8_lit_comp(""), str8_lit_comp("Specifies a struct of {data, len} should be rendered as a slice."), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*0)|(DF_CoreViewRuleSpecInfoFlag_EvalResolution*1)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*0), DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_NAME(slice) , 0, }, +{str8_lit_comp("slice"), str8_lit_comp("Slice"), str8_lit_comp(""), str8_lit_comp("Specifies that a pointer within a struct, also containing an integer, points to the number of elements encoded by the integer."), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*0)|(DF_CoreViewRuleSpecInfoFlag_EvalResolution*1)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*0), DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_NAME(slice) , 0, }, {str8_lit_comp("list"), str8_lit_comp("List"), str8_lit_comp("x:{member}"), str8_lit_comp("Specifies that some struct, union, or class forms the top of a linked list, and the member which points at the following element in the list."), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*0)|(DF_CoreViewRuleSpecInfoFlag_EvalResolution*0)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*1), 0, DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_NAME(list) , }, {str8_lit_comp("bswap"), str8_lit_comp("Byte Swap"), str8_lit_comp(""), str8_lit_comp("Specifies that all integer primitives should be byte-swapped, such that their endianness is reversed."), (DF_CoreViewRuleSpecInfoFlag_Inherited*1)|(DF_CoreViewRuleSpecInfoFlag_Expandable*0)|(DF_CoreViewRuleSpecInfoFlag_EvalResolution*1)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*0), DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_NAME(bswap) , 0, }, {str8_lit_comp("dec"), str8_lit_comp("Decimal Base (Base 10)"), str8_lit_comp(""), str8_lit_comp("Specifies that all integral evaluations should appear in base-10 form."), (DF_CoreViewRuleSpecInfoFlag_Inherited*1)|(DF_CoreViewRuleSpecInfoFlag_Expandable*0)|(DF_CoreViewRuleSpecInfoFlag_EvalResolution*0)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*0), 0, 0, }, @@ -454,6 +455,7 @@ DF_CoreViewRuleSpecInfo df_g_core_view_rule_spec_info_table[19] = {str8_lit_comp("bitmap"), str8_lit_comp("Bitmap"), str8_lit_comp("x:{'w':expr, 'h':expr, 'fmt':tex2dformat}"), str8_lit_comp("Displays as a bitmap, interpreting the data as raw pixel data."), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*1)|(DF_CoreViewRuleSpecInfoFlag_EvalResolution*0)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*1), 0, DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_NAME(bitmap) , }, {str8_lit_comp("geo"), str8_lit_comp("Geometry"), str8_lit_comp("x:{'count':expr, 'vertices_base':expr, 'vertices_size':expr}"), str8_lit_comp("Displays as geometry, interpreting the data as vertex data."), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*1)|(DF_CoreViewRuleSpecInfoFlag_EvalResolution*0)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*1), 0, DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_NAME(geo) , }, {str8_lit_comp("odin_map"), str8_lit_comp("Odin map"), str8_lit_comp(""), str8_lit_comp("Specifies that a struct should be rendered as an Odin map type."), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*1)|(DF_CoreViewRuleSpecInfoFlag_EvalResolution*0)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*1), 0, DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_NAME(odin_map) , }, +{str8_lit_comp("odin_slice"), str8_lit_comp("Odin slice"), str8_lit_comp(""), str8_lit_comp("Specifies a struct of {data, len} should be rendered as a slice (odin's)."), (DF_CoreViewRuleSpecInfoFlag_Inherited*0)|(DF_CoreViewRuleSpecInfoFlag_Expandable*0)|(DF_CoreViewRuleSpecInfoFlag_EvalResolution*1)|(DF_CoreViewRuleSpecInfoFlag_VizBlockProd*0), DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_NAME(odin_slice) , 0, }, }; String8 df_g_icon_kind_text_table[69] = diff --git a/src/df/core/generated/df_core.meta.h b/src/df/core/generated/df_core.meta.h index e30aca43..492e2e44 100644 --- a/src/df/core/generated/df_core.meta.h +++ b/src/df/core/generated/df_core.meta.h @@ -200,6 +200,7 @@ DF_CoreCmdKind_GoToName, DF_CoreCmdKind_GoToNameAtCursor, DF_CoreCmdKind_ToggleWatchExpression, DF_CoreCmdKind_ToggleWatchExpressionAtCursor, +DF_CoreCmdKind_ToggleWatchExpressionAtMouse, DF_CoreCmdKind_SetColumns, DF_CoreCmdKind_ToggleAddressVisibility, DF_CoreCmdKind_ToggleCodeBytesVisibility, @@ -365,6 +366,7 @@ DF_CoreViewRuleKind_Graph, DF_CoreViewRuleKind_Bitmap, DF_CoreViewRuleKind_Geo, DF_CoreViewRuleKind_OdinMap, +DF_CoreViewRuleKind_OdinSlice, DF_CoreViewRuleKind_COUNT, } DF_CoreViewRuleKind; @@ -429,6 +431,7 @@ U64 inline_unwind_index; DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_DEF(array); DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_DEF(slice); DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_DEF(bswap); +DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_DEF(odin_slice); DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(list); DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(only); DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(omit); diff --git a/src/df/gfx/df_gfx.c b/src/df/gfx/df_gfx.c index 49515ebd..6a2a4f68 100644 --- a/src/df/gfx/df_gfx.c +++ b/src/df/gfx/df_gfx.c @@ -1038,6 +1038,14 @@ df_window_open(Vec2F32 size, OS_Handle preferred_monitor, DF_CfgSrc cfg_src) window->query_cmd_arena = arena_alloc(); window->query_cmd_spec = &df_g_nil_cmd_spec; window->query_view_stack_top = &df_g_nil_view; + window->last_dpi = os_dpi_from_window(window->os); + for(EachEnumVal(DF_SettingCode, code)) + { + if(df_g_setting_code_default_is_per_window_table[code]) + { + window->setting_vals[code] = df_g_setting_code_default_val_table[code]; + } + } if(df_gfx_state->first_window == 0) { DF_FontSlot english_font_slots[] = {DF_FontSlot_Main, DF_FontSlot_Code}; @@ -1065,17 +1073,17 @@ df_window_open(Vec2F32 size, OS_Handle preferred_monitor, DF_CfgSrc cfg_src) f_push_run_from_string(scratch.arena, df_font_from_slot(icon_font_slot), df_font_size_from_slot(window, icon_font_slot), - 0, 0, F_RunFlag_Smooth, + 0, 0, F_RasterFlag_Smooth, df_g_icon_kind_text_table[icon_kind]); f_push_run_from_string(scratch.arena, df_font_from_slot(icon_font_slot), df_font_size_from_slot(window, DF_FontSlot_Main), - 0, 0, F_RunFlag_Smooth, + 0, 0, F_RasterFlag_Smooth, df_g_icon_kind_text_table[icon_kind]); f_push_run_from_string(scratch.arena, df_font_from_slot(icon_font_slot), df_font_size_from_slot(window, DF_FontSlot_Code), - 0, 0, F_RunFlag_Smooth, + 0, 0, F_RasterFlag_Smooth, df_g_icon_kind_text_table[icon_kind]); scratch_end(scratch); } @@ -1291,23 +1299,27 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) //- rjf: font sizes case DF_CoreCmdKind_IncUIFontScale: { - ws->main_font_size_delta += 1/200.f; - ws->main_font_size_delta = ClampTop(ws->main_font_size_delta, +0.3f); + ws->setting_vals[DF_SettingCode_MainFontSize].set = 1; + ws->setting_vals[DF_SettingCode_MainFontSize].s32 += 1; + ws->setting_vals[DF_SettingCode_MainFontSize].s32 = clamp_1s32(df_g_setting_code_s32_range_table[DF_SettingCode_MainFontSize], ws->setting_vals[DF_SettingCode_MainFontSize].s32); }break; case DF_CoreCmdKind_DecUIFontScale: { - ws->main_font_size_delta -= 1/200.f; - ws->main_font_size_delta = ClampBot(ws->main_font_size_delta, -0.075f); + ws->setting_vals[DF_SettingCode_MainFontSize].set = 1; + ws->setting_vals[DF_SettingCode_MainFontSize].s32 -= 1; + ws->setting_vals[DF_SettingCode_MainFontSize].s32 = clamp_1s32(df_g_setting_code_s32_range_table[DF_SettingCode_MainFontSize], ws->setting_vals[DF_SettingCode_MainFontSize].s32); }break; case DF_CoreCmdKind_IncCodeFontScale: { - ws->code_font_size_delta += 1/200.f; - ws->code_font_size_delta = ClampTop(ws->code_font_size_delta, +0.3f); + ws->setting_vals[DF_SettingCode_CodeFontSize].set = 1; + ws->setting_vals[DF_SettingCode_CodeFontSize].s32 += 1; + ws->setting_vals[DF_SettingCode_CodeFontSize].s32 = clamp_1s32(df_g_setting_code_s32_range_table[DF_SettingCode_CodeFontSize], ws->setting_vals[DF_SettingCode_CodeFontSize].s32); }break; case DF_CoreCmdKind_DecCodeFontScale: { - ws->code_font_size_delta -= 1/200.f; - ws->code_font_size_delta = ClampBot(ws->code_font_size_delta, -0.075f); + ws->setting_vals[DF_SettingCode_CodeFontSize].set = 1; + ws->setting_vals[DF_SettingCode_CodeFontSize].s32 -= 1; + ws->setting_vals[DF_SettingCode_CodeFontSize].s32 = clamp_1s32(df_g_setting_code_s32_range_table[DF_SettingCode_CodeFontSize], ws->setting_vals[DF_SettingCode_CodeFontSize].s32); }break; //- rjf: panel creation @@ -3448,6 +3460,79 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) } } + ////////////////////////////// + //- rjf: compute ui palettes from theme + // + { + DF_Theme *current = &df_gfx_state->cfg_theme; + for(EachEnumVal(DF_PaletteCode, code)) + { + ws->cfg_palettes[code].null = v4f32(1, 0, 1, 1); + ws->cfg_palettes[code].cursor = current->colors[DF_ThemeColor_Cursor]; + ws->cfg_palettes[code].selection = current->colors[DF_ThemeColor_SelectionOverlay]; + } + ws->cfg_palettes[DF_PaletteCode_Base].background = current->colors[DF_ThemeColor_BaseBackground]; + ws->cfg_palettes[DF_PaletteCode_Base].text = current->colors[DF_ThemeColor_Text]; + ws->cfg_palettes[DF_PaletteCode_Base].text_weak = current->colors[DF_ThemeColor_TextWeak]; + ws->cfg_palettes[DF_PaletteCode_Base].border = current->colors[DF_ThemeColor_BaseBorder]; + ws->cfg_palettes[DF_PaletteCode_MenuBar].background = current->colors[DF_ThemeColor_MenuBarBackground]; + ws->cfg_palettes[DF_PaletteCode_MenuBar].text = current->colors[DF_ThemeColor_Text]; + ws->cfg_palettes[DF_PaletteCode_MenuBar].text_weak = current->colors[DF_ThemeColor_TextWeak]; + ws->cfg_palettes[DF_PaletteCode_MenuBar].border = current->colors[DF_ThemeColor_MenuBarBorder]; + ws->cfg_palettes[DF_PaletteCode_Floating].background = current->colors[DF_ThemeColor_FloatingBackground]; + ws->cfg_palettes[DF_PaletteCode_Floating].text = current->colors[DF_ThemeColor_Text]; + ws->cfg_palettes[DF_PaletteCode_Floating].text_weak = current->colors[DF_ThemeColor_TextWeak]; + ws->cfg_palettes[DF_PaletteCode_Floating].border = current->colors[DF_ThemeColor_FloatingBorder]; + ws->cfg_palettes[DF_PaletteCode_ImplicitButton].background = current->colors[DF_ThemeColor_ImplicitButtonBackground]; + ws->cfg_palettes[DF_PaletteCode_ImplicitButton].text = current->colors[DF_ThemeColor_Text]; + ws->cfg_palettes[DF_PaletteCode_ImplicitButton].text_weak = current->colors[DF_ThemeColor_TextWeak]; + ws->cfg_palettes[DF_PaletteCode_ImplicitButton].border = current->colors[DF_ThemeColor_ImplicitButtonBorder]; + ws->cfg_palettes[DF_PaletteCode_PlainButton].background = current->colors[DF_ThemeColor_PlainButtonBackground]; + ws->cfg_palettes[DF_PaletteCode_PlainButton].text = current->colors[DF_ThemeColor_Text]; + ws->cfg_palettes[DF_PaletteCode_PlainButton].text_weak = current->colors[DF_ThemeColor_TextWeak]; + ws->cfg_palettes[DF_PaletteCode_PlainButton].border = current->colors[DF_ThemeColor_PlainButtonBorder]; + ws->cfg_palettes[DF_PaletteCode_PositivePopButton].background = current->colors[DF_ThemeColor_PositivePopButtonBackground]; + ws->cfg_palettes[DF_PaletteCode_PositivePopButton].text = current->colors[DF_ThemeColor_Text]; + ws->cfg_palettes[DF_PaletteCode_PositivePopButton].text_weak = current->colors[DF_ThemeColor_TextWeak]; + ws->cfg_palettes[DF_PaletteCode_PositivePopButton].border = current->colors[DF_ThemeColor_PositivePopButtonBorder]; + ws->cfg_palettes[DF_PaletteCode_NegativePopButton].background = current->colors[DF_ThemeColor_NegativePopButtonBackground]; + ws->cfg_palettes[DF_PaletteCode_NegativePopButton].text = current->colors[DF_ThemeColor_Text]; + ws->cfg_palettes[DF_PaletteCode_NegativePopButton].text_weak = current->colors[DF_ThemeColor_TextWeak]; + ws->cfg_palettes[DF_PaletteCode_NegativePopButton].border = current->colors[DF_ThemeColor_NegativePopButtonBorder]; + ws->cfg_palettes[DF_PaletteCode_NeutralPopButton].background = current->colors[DF_ThemeColor_NeutralPopButtonBackground]; + ws->cfg_palettes[DF_PaletteCode_NeutralPopButton].text = current->colors[DF_ThemeColor_Text]; + ws->cfg_palettes[DF_PaletteCode_NeutralPopButton].text_weak = current->colors[DF_ThemeColor_TextWeak]; + ws->cfg_palettes[DF_PaletteCode_NeutralPopButton].border = current->colors[DF_ThemeColor_NeutralPopButtonBorder]; + ws->cfg_palettes[DF_PaletteCode_ScrollBarButton].background = current->colors[DF_ThemeColor_ScrollBarButtonBackground]; + ws->cfg_palettes[DF_PaletteCode_ScrollBarButton].text = current->colors[DF_ThemeColor_Text]; + ws->cfg_palettes[DF_PaletteCode_ScrollBarButton].text_weak = current->colors[DF_ThemeColor_TextWeak]; + ws->cfg_palettes[DF_PaletteCode_ScrollBarButton].border = current->colors[DF_ThemeColor_ScrollBarButtonBorder]; + ws->cfg_palettes[DF_PaletteCode_Tab].background = current->colors[DF_ThemeColor_TabBackground]; + ws->cfg_palettes[DF_PaletteCode_Tab].text = current->colors[DF_ThemeColor_Text]; + ws->cfg_palettes[DF_PaletteCode_Tab].text_weak = current->colors[DF_ThemeColor_TextWeak]; + ws->cfg_palettes[DF_PaletteCode_Tab].border = current->colors[DF_ThemeColor_TabBorder]; + ws->cfg_palettes[DF_PaletteCode_TabInactive].background = current->colors[DF_ThemeColor_TabBackgroundInactive]; + ws->cfg_palettes[DF_PaletteCode_TabInactive].text = current->colors[DF_ThemeColor_Text]; + ws->cfg_palettes[DF_PaletteCode_TabInactive].text_weak = current->colors[DF_ThemeColor_TextWeak]; + ws->cfg_palettes[DF_PaletteCode_TabInactive].border = current->colors[DF_ThemeColor_TabBorderInactive]; + ws->cfg_palettes[DF_PaletteCode_DropSiteOverlay].background = current->colors[DF_ThemeColor_DropSiteOverlay]; + ws->cfg_palettes[DF_PaletteCode_DropSiteOverlay].text = current->colors[DF_ThemeColor_DropSiteOverlay]; + ws->cfg_palettes[DF_PaletteCode_DropSiteOverlay].text_weak = current->colors[DF_ThemeColor_DropSiteOverlay]; + ws->cfg_palettes[DF_PaletteCode_DropSiteOverlay].border = current->colors[DF_ThemeColor_DropSiteOverlay]; + if(df_setting_val_from_code(0, DF_SettingCode_OpaqueBackgrounds).s32) + { + for(EachEnumVal(DF_PaletteCode, code)) + { + if(ws->cfg_palettes[code].background.x != 0 || + ws->cfg_palettes[code].background.y != 0 || + ws->cfg_palettes[code].background.z != 0) + { + ws->cfg_palettes[code].background.w = 1; + } + } + } + } + ////////////////////////////// //- rjf: build UI // @@ -3483,30 +3568,35 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) // rjf: build widget palette info UI_WidgetPaletteInfo widget_palette_info = {0}; { - widget_palette_info.tooltip_palette = df_palette_from_code(DF_PaletteCode_Floating); - widget_palette_info.ctx_menu_palette = df_palette_from_code(DF_PaletteCode_Floating); - widget_palette_info.scrollbar_palette = df_palette_from_code(DF_PaletteCode_ScrollBarButton); + widget_palette_info.tooltip_palette = df_palette_from_code(ws, DF_PaletteCode_Floating); + widget_palette_info.ctx_menu_palette = df_palette_from_code(ws, DF_PaletteCode_Floating); + widget_palette_info.scrollbar_palette = df_palette_from_code(ws, DF_PaletteCode_ScrollBarButton); } // rjf: build animation info UI_AnimationInfo animation_info = {0}; { - if(df_setting_val_from_code(DF_SettingCode_HoverAnimations).s32) {animation_info.flags |= UI_AnimationInfoFlag_HotAnimations;} - if(df_setting_val_from_code(DF_SettingCode_PressAnimations).s32) {animation_info.flags |= UI_AnimationInfoFlag_ActiveAnimations;} - if(df_setting_val_from_code(DF_SettingCode_FocusAnimations).s32) {animation_info.flags |= UI_AnimationInfoFlag_FocusAnimations;} - if(df_setting_val_from_code(DF_SettingCode_TooltipAnimations).s32) {animation_info.flags |= UI_AnimationInfoFlag_TooltipAnimations;} - if(df_setting_val_from_code(DF_SettingCode_MenuAnimations).s32) {animation_info.flags |= UI_AnimationInfoFlag_ContextMenuAnimations;} - if(df_setting_val_from_code(DF_SettingCode_ScrollingAnimations).s32) {animation_info.flags |= UI_AnimationInfoFlag_ScrollingAnimations;} + if(df_setting_val_from_code(ws, DF_SettingCode_HoverAnimations).s32) {animation_info.flags |= UI_AnimationInfoFlag_HotAnimations;} + if(df_setting_val_from_code(ws, DF_SettingCode_PressAnimations).s32) {animation_info.flags |= UI_AnimationInfoFlag_ActiveAnimations;} + if(df_setting_val_from_code(ws, DF_SettingCode_FocusAnimations).s32) {animation_info.flags |= UI_AnimationInfoFlag_FocusAnimations;} + if(df_setting_val_from_code(ws, DF_SettingCode_TooltipAnimations).s32) {animation_info.flags |= UI_AnimationInfoFlag_TooltipAnimations;} + if(df_setting_val_from_code(ws, DF_SettingCode_MenuAnimations).s32) {animation_info.flags |= UI_AnimationInfoFlag_ContextMenuAnimations;} + if(df_setting_val_from_code(ws, DF_SettingCode_ScrollingAnimations).s32) {animation_info.flags |= UI_AnimationInfoFlag_ScrollingAnimations;} } // rjf: begin & push initial stack values ui_begin_build(ws->os, &events, &icon_info, &widget_palette_info, &animation_info, df_dt(), df_dt()); ui_push_font(main_font); ui_push_font_size(main_font_size); + ui_push_text_padding(main_font_size*0.3f); ui_push_pref_width(ui_em(20.f, 1)); ui_push_pref_height(ui_em(2.75f, 1.f)); - ui_push_palette(df_palette_from_code(DF_PaletteCode_Base)); + ui_push_palette(df_palette_from_code(ws, DF_PaletteCode_Base)); ui_push_blur_size(10.f); + F_RasterFlags text_raster_flags = 0; + if(df_setting_val_from_code(ws, DF_SettingCode_SmoothUIText).s32) {text_raster_flags |= F_RasterFlag_Smooth;} + if(df_setting_val_from_code(ws, DF_SettingCode_HintUIText).s32) {text_raster_flags |= F_RasterFlag_Hinted;} + ui_push_text_raster_flags(text_raster_flags); } //////////////////////////// @@ -3551,7 +3641,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) UI_Size main_width = ui_top_pref_width(); UI_Size main_height = ui_top_pref_height(); UI_TextAlign main_text_align = ui_top_text_alignment(); - DF_Palette(DF_PaletteCode_Tab) + DF_Palette(ws, DF_PaletteCode_Tab) UI_Tooltip UI_PrefWidth(main_width) UI_PrefHeight(main_height) @@ -3570,7 +3660,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) DF_IconKind icon_kind = df_icon_kind_from_view(view); UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_PrefWidth(ui_em(2.5f, 1.f)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_label(df_g_icon_kind_text_table[icon_kind]); @@ -3600,7 +3690,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) DF_IconKind icon_kind = df_g_entity_kind_icon_kind_table[entity->kind]; UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_label(df_g_icon_kind_text_table[icon_kind]); ui_label(display_name); @@ -3729,7 +3819,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) //////////////////////////// //- rjf: universal ctx menus // - DF_Palette(DF_PaletteCode_Floating) + DF_Palette(ws, DF_PaletteCode_Floating) { Temp scratch = scratch_begin(&arena, 1); @@ -3745,8 +3835,8 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) //- rjf: code ctx menu UI_CtxMenu(ws->code_ctx_menu_key) - UI_PrefWidth(ui_em(30.f, 1.f)) - DF_Palette(DF_PaletteCode_ImplicitButton) + UI_PrefWidth(ui_em(40.f, 1.f)) + DF_Palette(ws, DF_PaletteCode_ImplicitButton) { TXT_Scope *txt_scope = txt_scope_open(); HS_Scope *hs_scope = hs_scope_open(); @@ -3900,8 +3990,8 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) //- rjf: entity menu UI_CtxMenu(ws->entity_ctx_menu_key) - UI_PrefWidth(ui_em(30.f, 1.f)) - DF_Palette(DF_PaletteCode_ImplicitButton) + UI_PrefWidth(ui_em(40.f, 1.f)) + DF_Palette(ws, DF_PaletteCode_ImplicitButton) { DF_Entity *entity = df_entity_from_handle(ws->entity_ctx_menu_entity); DF_IconKind entity_icon = df_g_entity_kind_icon_kind_table[entity->kind]; @@ -3915,7 +4005,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) ui_spacer(ui_em(1.f, 1.f)); UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_PrefWidth(ui_em(2.f, 1.f)) UI_PrefHeight(ui_pct(1, 0)) UI_TextAlignment(UI_TextAlign_Center) @@ -3937,7 +4027,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) } } - DF_Palette(DF_PaletteCode_Floating) ui_divider(ui_em(1.f, 1.f)); + DF_Palette(ws, DF_PaletteCode_Floating) ui_divider(ui_em(1.f, 1.f)); // rjf: name editor if(op_flags & DF_EntityOpFlag_Rename) @@ -4108,7 +4198,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) if(op_flags & DF_EntityOpFlag_Freeze) { B32 is_frozen = df_entity_is_frozen(entity); - ui_set_next_palette(df_palette_from_code(is_frozen ? DF_PaletteCode_NegativePopButton : DF_PaletteCode_PositivePopButton)); + ui_set_next_palette(df_palette_from_code(ws, is_frozen ? DF_PaletteCode_NegativePopButton : DF_PaletteCode_PositivePopButton)); if(is_frozen && ui_clicked(df_icon_buttonf(DF_IconKind_Locked, 0, "Thaw###freeze_thaw"))) { DF_CmdParams params = df_cmd_params_from_window(ws); @@ -4352,7 +4442,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) }break; } - DF_Palette(DF_PaletteCode_Floating) ui_divider(ui_em(1.f, 1.f)); + DF_Palette(ws, DF_PaletteCode_Floating) ui_divider(ui_em(1.f, 1.f)); // rjf: color editor { @@ -4413,7 +4503,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) } UI_Row UI_Padding(ui_pct(1, 0)) UI_PrefWidth(ui_em(16.f, 1.f)) UI_CornerRadius(8.f) UI_TextAlignment(UI_TextAlign_Center) - DF_Palette(DF_PaletteCode_Floating) + DF_Palette(ws, DF_PaletteCode_Floating) { if(ui_clicked(df_icon_buttonf(DF_IconKind_Trash, 0, "Remove Color###color_toggle"))) { @@ -4441,9 +4531,10 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) } //- rjf: tab menu - UI_CtxMenu(ws->tab_ctx_menu_key) UI_PrefWidth(ui_em(25.f, 1.f)) UI_CornerRadius(0) - DF_Palette(DF_PaletteCode_ImplicitButton) + UI_CtxMenu(ws->tab_ctx_menu_key) UI_PrefWidth(ui_em(40.f, 1.f)) UI_CornerRadius(0) + DF_Palette(ws, DF_PaletteCode_ImplicitButton) { + DF_Panel *panel = df_panel_from_handle(ws->tab_ctx_menu_panel); DF_View *view = df_view_from_handle(ws->tab_ctx_menu_view); DF_IconKind view_icon = df_icon_kind_from_view(view); DF_Entity *entity = df_entity_from_handle(view->entity); @@ -4456,7 +4547,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) ui_spacer(ui_em(1.f, 1.f)); UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_PrefWidth(ui_em(2.f, 1.f)) UI_PrefHeight(ui_pct(1, 0)) UI_TextAlignment(UI_TextAlign_Center) @@ -4465,7 +4556,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) UI_PrefWidth(ui_text_dim(10, 1)) ui_label(display_name); } - DF_Palette(DF_PaletteCode_Floating) ui_divider(ui_em(1.f, 1.f)); + DF_Palette(ws, DF_PaletteCode_Floating) ui_divider(ui_em(1.f, 1.f)); // rjf: copy name if(ui_clicked(df_icon_buttonf(DF_IconKind_Clipboard, 0, "Copy Name"))) @@ -4530,11 +4621,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) // rjf: close tab if(ui_clicked(df_icon_buttonf(DF_IconKind_X, 0, "Close Tab"))) { - DF_CmdParams params = df_cmd_params_from_window(ws); - { - params.view = df_handle_from_view(view); - df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_View); - } + DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_CloseTab)); ui_ctx_menu_close(); } @@ -4552,7 +4639,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) { Vec2F32 window_dim = dim_2f32(window_rect); UI_Box *bg_box = &ui_g_nil_box; - UI_Palette *palette = ui_build_palette(df_palette_from_code(DF_PaletteCode_Floating)); + UI_Palette *palette = ui_build_palette(df_palette_from_code(ws, DF_PaletteCode_Floating)); palette->background.w *= df_gfx_state->confirm_t; UI_Rect(window_rect) UI_ChildLayoutAxis(Axis2_X) @@ -4574,14 +4661,14 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) ui_ctx_menu_close(); UI_WidthFill UI_PrefHeight(ui_children_sum(1.f)) UI_Column UI_Padding(ui_pct(1, 0)) { - UI_RunFlags(F_RunFlag_Smooth) UI_FontSize(ui_top_font_size()*2.f) UI_PrefHeight(ui_em(3.f, 1.f)) ui_label(df_gfx_state->confirm_title); + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_FontSize(ui_top_font_size()*2.f) UI_PrefHeight(ui_em(3.f, 1.f)) ui_label(df_gfx_state->confirm_title); UI_PrefHeight(ui_em(3.f, 1.f)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_label(df_gfx_state->confirm_msg); ui_spacer(ui_em(1.5f, 1.f)); UI_Row UI_Padding(ui_pct(1.f, 0.f)) UI_WidthFill UI_PrefHeight(ui_em(5.f, 1.f)) { UI_CornerRadius00(ui_top_font_size()*0.25f) UI_CornerRadius01(ui_top_font_size()*0.25f) - DF_Palette(DF_PaletteCode_NeutralPopButton) + DF_Palette(ws, DF_PaletteCode_NeutralPopButton) if(ui_clicked(ui_buttonf("OK")) || (ui_key_match(bg_box->default_nav_focus_hot_key, ui_key_zero()) && ui_slot_press(UI_EventActionSlot_Accept))) { DF_CmdParams p = df_cmd_params_zero(); @@ -4790,7 +4877,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) { // rjf: animate target # of rows { - F32 rate = df_setting_val_from_code(DF_SettingCode_MenuAnimations).s32 ? (1 - pow_f32(2, (-60.f * df_dt()))) : 1.f; + F32 rate = df_setting_val_from_code(ws, DF_SettingCode_MenuAnimations).s32 ? (1 - pow_f32(2, (-60.f * df_dt()))) : 1.f; F32 target = Min((F32)item_array.count, 16.f); if(abs_f32(target - ws->autocomp_num_visible_rows_t) > 0.01f) { @@ -4805,7 +4892,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) // rjf: animate open { - F32 rate = df_setting_val_from_code(DF_SettingCode_MenuAnimations).s32 ? 1 - pow_f32(2, (-60.f * df_dt())) : 1.f; + F32 rate = df_setting_val_from_code(ws, DF_SettingCode_MenuAnimations).s32 ? 1 - pow_f32(2, (-60.f * df_dt())) : 1.f; F32 diff = 1.f-ws->autocomp_open_t; ws->autocomp_open_t += diff*rate; if(abs_f32(diff) < 0.05f) @@ -4834,6 +4921,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) UI_Focus(UI_FocusKind_On) UI_Squish(0.25f-0.25f*ws->autocomp_open_t) UI_Transparency(1.f-ws->autocomp_open_t) + DF_Palette(ws, DF_PaletteCode_Floating) { autocomp_box = ui_build_box_from_stringf(UI_BoxFlag_DefaultFocusNavY| UI_BoxFlag_Clickable| @@ -4857,14 +4945,14 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) UI_Font(df_font_from_slot(DF_FontSlot_Code)) UI_HoverCursor(OS_Cursor_HandPoint) UI_Focus(UI_FocusKind_Null) - DF_Palette(DF_PaletteCode_ImplicitButton) + DF_Palette(ws, DF_PaletteCode_ImplicitButton) UI_Padding(ui_em(1.f, 1.f)) { for(U64 idx = 0; idx < item_array.count; idx += 1) { DF_AutoCompListerItem *item = &item_array.v[idx]; 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); - UI_Parent(item_box) + UI_Parent(item_box) UI_Padding(ui_em(1.f, 1.f)) { UI_WidthFill { @@ -4914,7 +5002,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) os_window_push_custom_edges(ws->os, window_edge_px); os_window_push_custom_title_bar(ws->os, dim_2f32(top_bar_rect).y); ui_set_next_flags(UI_BoxFlag_DefaultFocusNav|UI_BoxFlag_DisableFocusOverlay); - DF_Palette(DF_PaletteCode_MenuBar) + DF_Palette(ws, DF_PaletteCode_MenuBar) UI_Focus((ws->menu_bar_focused && window_is_focused && !ui_any_ctx_menu_is_open() && !hover_eval_is_open) ? UI_FocusKind_On : UI_FocusKind_Null) UI_Pane(top_bar_rect, str8_lit("###top_bar")) UI_WidthFill UI_Row @@ -4947,10 +5035,10 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) { // rjf: file menu UI_Key file_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_file_menu_key_")); - DF_Palette(DF_PaletteCode_Floating) + DF_Palette(ws, DF_PaletteCode_Floating) UI_CtxMenu(file_menu_key) - UI_PrefWidth(ui_em(40.f, 1.f)) - DF_Palette(DF_PaletteCode_ImplicitButton) + UI_PrefWidth(ui_em(50.f, 1.f)) + DF_Palette(ws, DF_PaletteCode_ImplicitButton) { DF_CoreCmdKind cmds[] = { @@ -4974,10 +5062,10 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) // rjf: window menu UI_Key window_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_window_menu_key_")); - DF_Palette(DF_PaletteCode_Floating) + DF_Palette(ws, DF_PaletteCode_Floating) UI_CtxMenu(window_menu_key) - UI_PrefWidth(ui_em(40.f, 1.f)) - DF_Palette(DF_PaletteCode_ImplicitButton) + UI_PrefWidth(ui_em(50.f, 1.f)) + DF_Palette(ws, DF_PaletteCode_ImplicitButton) { DF_CoreCmdKind cmds[] = { @@ -4997,10 +5085,10 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) // rjf: panel menu UI_Key panel_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_panel_menu_key_")); - DF_Palette(DF_PaletteCode_Floating) + DF_Palette(ws, DF_PaletteCode_Floating) UI_CtxMenu(panel_menu_key) - UI_PrefWidth(ui_em(40.f, 1.f)) - DF_Palette(DF_PaletteCode_ImplicitButton) + UI_PrefWidth(ui_em(50.f, 1.f)) + DF_Palette(ws, DF_PaletteCode_ImplicitButton) { DF_CoreCmdKind cmds[] = { @@ -5040,10 +5128,10 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) // rjf: view menu UI_Key view_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_view_menu_key_")); - DF_Palette(DF_PaletteCode_Floating) + DF_Palette(ws, DF_PaletteCode_Floating) UI_CtxMenu(view_menu_key) - UI_PrefWidth(ui_em(40.f, 1.f)) - DF_Palette(DF_PaletteCode_ImplicitButton) + UI_PrefWidth(ui_em(50.f, 1.f)) + DF_Palette(ws, DF_PaletteCode_ImplicitButton) { DF_CoreCmdKind cmds[] = { @@ -5097,10 +5185,10 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) // rjf: targets menu UI_Key targets_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_targets_menu_key_")); - DF_Palette(DF_PaletteCode_Floating) + DF_Palette(ws, DF_PaletteCode_Floating) UI_CtxMenu(targets_menu_key) - UI_PrefWidth(ui_em(40.f, 1.f)) - DF_Palette(DF_PaletteCode_ImplicitButton) + UI_PrefWidth(ui_em(50.f, 1.f)) + DF_Palette(ws, DF_PaletteCode_ImplicitButton) { Temp scratch = scratch_begin(&arena, 1); DF_CoreCmdKind cmds[] = @@ -5117,7 +5205,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) }; Assert(ArrayCount(codepoints) == ArrayCount(cmds)); df_cmd_list_menu_buttons(ws, ArrayCount(cmds), cmds, codepoints); - DF_Palette(DF_PaletteCode_Floating) ui_divider(ui_em(1.f, 1.f)); + DF_Palette(ws, DF_PaletteCode_Floating) ui_divider(ui_em(1.f, 1.f)); DF_EntityList targets_list = df_query_cached_entity_list_with_kind(DF_EntityKind_Target); for(DF_EntityNode *n = targets_list.first; n != 0; n = n->next) { @@ -5145,10 +5233,10 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) // rjf: ctrl menu UI_Key ctrl_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_ctrl_menu_key_")); - DF_Palette(DF_PaletteCode_Floating) + DF_Palette(ws, DF_PaletteCode_Floating) UI_CtxMenu(ctrl_menu_key) - UI_PrefWidth(ui_em(40.f, 1.f)) - DF_Palette(DF_PaletteCode_ImplicitButton) + UI_PrefWidth(ui_em(50.f, 1.f)) + DF_Palette(ws, DF_PaletteCode_ImplicitButton) { DF_CoreCmdKind cmds[] = { @@ -5180,10 +5268,10 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) // rjf: help menu UI_Key help_menu_key = ui_key_from_string(ui_key_zero(), str8_lit("_help_menu_key_")); - DF_Palette(DF_PaletteCode_Floating) + DF_Palette(ws, DF_PaletteCode_Floating) UI_CtxMenu(help_menu_key) - UI_PrefWidth(ui_em(60.f, 1.f)) - DF_Palette(DF_PaletteCode_ImplicitButton) + UI_PrefWidth(ui_em(50.f, 1.f)) + DF_Palette(ws, DF_PaletteCode_ImplicitButton) { UI_Row UI_TextAlignment(UI_TextAlign_Center) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_label(str8_lit(BUILD_TITLE_STRING_LITERAL)); @@ -5205,7 +5293,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) DF_CmdSpec *spec = df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_RunCommand); UI_Flags(UI_BoxFlag_DrawBorder) UI_TextAlignment(UI_TextAlign_Center) - df_cmd_binding_button(spec); + df_cmd_binding_buttons(spec); } ui_spacer(ui_em(0.25f, 1.f)); UI_Row UI_TextAlignment(UI_TextAlign_Center) ui_label(str8_lit("Submit issues to the GitHub at:")); @@ -5329,7 +5417,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) // rjf: conversion task visualization UI_PrefWidth(ui_text_dim(10, 1)) UI_HeightFill - DF_Palette(DF_PaletteCode_NeutralPopButton) + DF_Palette(ws, DF_PaletteCode_NeutralPopButton) { Temp scratch = scratch_begin(&arena, 1); DF_EntityList tasks = df_query_cached_entity_list_with_kind(DF_EntityKind_ConversionTask); @@ -5361,7 +5449,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) UI_PrefWidth(ui_em(2.25f, 1)) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(ui_top_font_size()*0.85f) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) { Temp scratch = scratch_begin(&arena, 1); DF_EntityList targets = df_push_active_target_list(scratch.arena); @@ -5618,7 +5706,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) ui_spacer(ui_pct(1, 0)); // rjf: loaded user viz - if(do_user_prof) DF_Palette(DF_PaletteCode_NeutralPopButton) + if(do_user_prof) DF_Palette(ws, DF_PaletteCode_NeutralPopButton) { ui_set_next_pref_width(ui_children_sum(1)); ui_set_next_child_layout_axis(Axis2_X); @@ -5635,7 +5723,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) String8 user_path = df_cfg_path_from_src(DF_CfgSrc_User); user_path = str8_chop_last_dot(user_path); UI_Font(df_font_from_slot(DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) ui_label(df_g_icon_kind_text_table[DF_IconKind_Person]); ui_label(str8_skip_last_slash(user_path)); } @@ -5655,7 +5743,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) } // rjf: loaded project viz - if(do_user_prof) DF_Palette(DF_PaletteCode_NeutralPopButton) + if(do_user_prof) DF_Palette(ws, DF_PaletteCode_NeutralPopButton) { ui_set_next_pref_width(ui_children_sum(1)); ui_set_next_child_layout_axis(Axis2_X); @@ -5671,7 +5759,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) { String8 prof_path = df_cfg_path_from_src(DF_CfgSrc_Project); prof_path = str8_chop_last_dot(prof_path); - UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_RunFlags(F_RunFlag_Smooth) + UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_TextRasterFlags(F_RasterFlag_Smooth) ui_label(df_g_icon_kind_text_table[DF_IconKind_Briefcase]); ui_label(str8_skip_last_slash(prof_path)); } @@ -5703,7 +5791,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) max_sig = df_icon_buttonf(DF_IconKind_Window, 0, "##maximize"); } UI_PrefWidth(ui_px(button_dim, 1.f)) - DF_Palette(DF_PaletteCode_NegativePopButton) + DF_Palette(ws, DF_PaletteCode_NegativePopButton) { cls_sig = df_icon_buttonf(DF_IconKind_X, 0, "##close"); } @@ -5735,9 +5823,9 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) { B32 is_running = df_ctrl_targets_running() && df_ctrl_last_run_frame_idx() < df_frame_index(); CTRL_Event stop_event = df_ctrl_last_stop_event(); - UI_Palette *positive_scheme = df_palette_from_code(DF_PaletteCode_PositivePopButton); - UI_Palette *running_scheme = df_palette_from_code(DF_PaletteCode_NeutralPopButton); - UI_Palette *negative_scheme = df_palette_from_code(DF_PaletteCode_NegativePopButton); + UI_Palette *positive_scheme = df_palette_from_code(ws, DF_PaletteCode_PositivePopButton); + UI_Palette *running_scheme = df_palette_from_code(ws, DF_PaletteCode_NeutralPopButton); + UI_Palette *negative_scheme = df_palette_from_code(ws, DF_PaletteCode_NegativePopButton); UI_Palette *palette = running_scheme; if(!is_running) { @@ -5808,7 +5896,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) UI_PrefWidth(ui_em(2.25f, 1.f)) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) ui_label(df_g_icon_kind_text_table[icon]); } UI_PrefWidth(ui_text_dim(10, 1)) ui_label(explanation); @@ -5825,7 +5913,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) UI_Flags(UI_BoxFlag_DrawBackground) UI_TextAlignment(UI_TextAlign_Center) UI_CornerRadius(4) - DF_Palette(DF_PaletteCode_NeutralPopButton) + DF_Palette(ws, DF_PaletteCode_NeutralPopButton) ui_labelf("Currently rebinding \"%S\" hotkey", df_gfx_state->bind_change_cmd_spec->info.display_name); } @@ -5845,7 +5933,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) { UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) ui_label(df_g_icon_kind_text_table[DF_IconKind_WarningBig]); ui_label(error_string); } @@ -5911,7 +5999,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) //- rjf: animate query info // { - F32 rate = df_setting_val_from_code(DF_SettingCode_MenuAnimations).s32 ? 1 - pow_f32(2, (-60.f * df_dt())) : 1.f; + F32 rate = df_setting_val_from_code(ws, DF_SettingCode_MenuAnimations).s32 ? 1 - pow_f32(2, (-60.f * df_dt())) : 1.f; // rjf: animate query view selection transition { @@ -5949,7 +6037,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) // 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 && ws->query_view_selected) ? UI_FocusKind_On : UI_FocusKind_Off) - DF_Palette(DF_PaletteCode_Floating) + DF_Palette(ws, DF_PaletteCode_Floating) { DF_View *view = ws->query_view_stack_top; DF_CmdSpec *cmd_spec = ws->query_cmd_spec; @@ -6004,17 +6092,15 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) ui_set_next_flags(UI_BoxFlag_DrawDropShadow|UI_BoxFlag_DrawBorder); UI_Row { - UI_PrefWidth(ui_text_dim(10.f, 1.f)) + UI_PrefWidth(ui_text_dim(0.f, 1.f)) UI_Padding(ui_em(1.f, 1.f)) { - ui_spacer(ui_em(0.5f, 1.f)); DF_IconKind icon_kind = ws->query_cmd_spec->info.canonical_icon_kind; if(icon_kind != DF_IconKind_Null) { - UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_RunFlags(F_RunFlag_Smooth) + UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_TextRasterFlags(F_RasterFlag_Smooth) ui_label(df_g_icon_kind_text_table[icon_kind]); } ui_labelf("%S", ws->query_cmd_spec->info.display_name); - ui_spacer(ui_em(0.5f, 1.f)); } UI_Font((query->flags & DF_CmdQueryFlag_CodeInput) ? df_font_from_slot(DF_FontSlot_Code) : ui_top_font()) { @@ -6035,14 +6121,14 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) ws->query_view_selected = 1; } } - UI_PrefWidth(ui_em(5.f, 1.f)) UI_Focus(UI_FocusKind_Off) DF_Palette(DF_PaletteCode_PositivePopButton) + UI_PrefWidth(ui_em(5.f, 1.f)) UI_Focus(UI_FocusKind_Off) DF_Palette(ws, DF_PaletteCode_PositivePopButton) { if(ui_clicked(df_icon_buttonf(DF_IconKind_RightArrow, 0, "##complete_query"))) { query_completed = 1; } } - UI_PrefWidth(ui_em(3.f, 1.f)) UI_Focus(UI_FocusKind_Off) DF_Palette(DF_PaletteCode_PlainButton) + UI_PrefWidth(ui_em(3.f, 1.f)) UI_Focus(UI_FocusKind_Off) DF_Palette(ws, DF_PaletteCode_PlainButton) { if(ui_clicked(df_icon_buttonf(DF_IconKind_X, 0, "##cancel_query"))) { @@ -6095,7 +6181,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) } //- rjf: build darkening overlay for rest of screen - UI_Palette(ui_build_palette(ui_top_palette(), .background = mix_4f32(df_rgba_from_theme_color(DF_ThemeColor_InactivePanelOverlay), v4f32(0, 0, 0, 0), 1-ws->query_view_selected_t))) + UI_Palette(ui_build_palette(0, .background = mix_4f32(df_rgba_from_theme_color(DF_ThemeColor_InactivePanelOverlay), v4f32(0, 0, 0, 0), 1-ws->query_view_selected_t))) UI_Rect(window_rect) { ui_build_box_from_key(UI_BoxFlag_DrawBackground, ui_key_zero()); @@ -6153,7 +6239,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) if(build_hover_eval && ws->hover_eval_string.size != 0 && hover_eval_is_open) UI_Font(df_font_from_slot(DF_FontSlot_Code)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Main)) - DF_Palette(DF_PaletteCode_Floating) + DF_Palette(ws, DF_PaletteCode_Floating) { Temp scratch = scratch_begin(&arena, 1); DI_Scope *scope = di_scope_open(); @@ -6186,7 +6272,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) { // rjf: animate height { - F32 fish_rate = df_setting_val_from_code(DF_SettingCode_MenuAnimations).s32 ? 1 - pow_f32(2, (-60.f * df_dt())) : 1.f; + F32 fish_rate = df_setting_val_from_code(ws, DF_SettingCode_MenuAnimations).s32 ? 1 - pow_f32(2, (-60.f * df_dt())) : 1.f; F32 hover_eval_container_height_target = row_height * Min(30, viz_blocks.total_visual_row_count); ws->hover_eval_num_visible_rows_t += (hover_eval_container_height_target - ws->hover_eval_num_visible_rows_t) * fish_rate; if(abs_f32(hover_eval_container_height_target - ws->hover_eval_num_visible_rows_t) > 0.5f) @@ -6201,7 +6287,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) // rjf: animate open { - F32 fish_rate = df_setting_val_from_code(DF_SettingCode_MenuAnimations).s32 ? 1 - pow_f32(2, (-60.f * df_dt())) : 1.f; + F32 fish_rate = df_setting_val_from_code(ws, DF_SettingCode_MenuAnimations).s32 ? 1 - pow_f32(2, (-60.f * df_dt())) : 1.f; F32 diff = 1.f - ws->hover_eval_open_t; ws->hover_eval_open_t += diff*fish_rate; if(abs_f32(diff) < 0.01f) @@ -6302,7 +6388,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) UI_PrefWidth(ui_em(1.5f, 1)) UI_Flags(UI_BoxFlag_DrawSideLeft*(row->depth>0) | UI_BoxFlag_DrawTextWeak) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) ui_label(df_g_icon_kind_text_table[DF_IconKind_Dot]); } UI_WidthFill @@ -6523,7 +6609,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) future_split_rect.p1.v[axis] += drop_site_major_dim_px; future_split_rect.p0.v[axis2_flip(axis)] = panel_rect.p0.v[axis2_flip(axis)]; future_split_rect.p1.v[axis2_flip(axis)] = panel_rect.p1.v[axis2_flip(axis)]; - UI_Rect(future_split_rect) DF_Palette(DF_PaletteCode_DropSiteOverlay) + UI_Rect(future_split_rect) DF_Palette(ws, DF_PaletteCode_DropSiteOverlay) { ui_build_box_from_key(UI_BoxFlag_DrawBackground, ui_key_zero()); } @@ -6608,7 +6694,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) future_split_rect.p1.v[split_axis] += drop_site_major_dim_px; future_split_rect.p0.v[axis2_flip(split_axis)] = child_rect.p0.v[axis2_flip(split_axis)]; future_split_rect.p1.v[axis2_flip(split_axis)] = child_rect.p1.v[axis2_flip(split_axis)]; - UI_Rect(future_split_rect) DF_Palette(DF_PaletteCode_DropSiteOverlay) + UI_Rect(future_split_rect) DF_Palette(ws, DF_PaletteCode_DropSiteOverlay) { ui_build_box_from_key(UI_BoxFlag_DrawBackground, ui_key_zero()); } @@ -6716,7 +6802,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) //- rjf: animate panels // { - F32 rate = df_setting_val_from_code(DF_SettingCode_MenuAnimations).s32 ? 1 - pow_f32(2, (-50.f * df_dt())) : 1.f; + F32 rate = df_setting_val_from_code(ws, DF_SettingCode_MenuAnimations).s32 ? 1 - pow_f32(2, (-50.f * df_dt())) : 1.f; Vec2F32 content_rect_dim = dim_2f32(content_rect); for(DF_Panel *panel = ws->root_panel; !df_panel_is_nil(panel); panel = df_panel_rec_df_pre(panel).next) { @@ -6899,10 +6985,10 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) UI_Box *row_or_column = ui_build_box_from_key(0, ui_key_zero()); UI_Parent(row_or_column) UI_Padding(ui_px(padding, 1.f)) { if(split_side == Side_Min) { ui_set_next_flags(UI_BoxFlag_DrawBackground); } - DF_Palette(DF_PaletteCode_DropSiteOverlay) ui_build_box_from_key(UI_BoxFlag_DrawBorder, ui_key_zero()); + DF_Palette(ws, DF_PaletteCode_DropSiteOverlay) ui_build_box_from_key(UI_BoxFlag_DrawBorder, ui_key_zero()); ui_spacer(ui_px(padding, 1.f)); if(split_side == Side_Max) { ui_set_next_flags(UI_BoxFlag_DrawBackground); } - DF_Palette(DF_PaletteCode_DropSiteOverlay) ui_build_box_from_key(UI_BoxFlag_DrawBorder, ui_key_zero()); + DF_Palette(ws, DF_PaletteCode_DropSiteOverlay) ui_build_box_from_key(UI_BoxFlag_DrawBorder, ui_key_zero()); } } } @@ -6912,7 +6998,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) { ui_set_next_child_layout_axis(split_axis); UI_Box *row_or_column = ui_build_box_from_key(0, ui_key_zero()); - UI_Parent(row_or_column) UI_Padding(ui_px(padding, 1.f)) DF_Palette(DF_PaletteCode_DropSiteOverlay) + UI_Parent(row_or_column) UI_Padding(ui_px(padding, 1.f)) DF_Palette(ws, DF_PaletteCode_DropSiteOverlay) { ui_build_box_from_key(UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawBackground, ui_key_zero()); } @@ -6955,7 +7041,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) Vec2F32 panel_center = center_2f32(panel_rect); future_split_rect.v[side_flip(split_side)].v[split_axis] = panel_center.v[split_axis]; } - UI_Rect(future_split_rect) DF_Palette(DF_PaletteCode_DropSiteOverlay) + UI_Rect(future_split_rect) DF_Palette(ws, DF_PaletteCode_DropSiteOverlay) { ui_build_box_from_key(UI_BoxFlag_DrawBackground, ui_key_zero()); } @@ -7004,7 +7090,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) UI_PrefWidth(ui_em(2.f, 1.f)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) ui_label(df_g_icon_kind_text_table[DF_IconKind_Find]); UI_PrefWidth(ui_text_dim(10, 1)) { @@ -7040,7 +7126,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) // if(panel != ws->focused_panel) { - UI_Palette(ui_build_palette(ui_top_palette(), .background = df_rgba_from_theme_color(DF_ThemeColor_InactivePanelOverlay))) + UI_Palette(ui_build_palette(0, .background = df_rgba_from_theme_color(DF_ThemeColor_InactivePanelOverlay))) UI_Rect(content_rect) { ui_build_box_from_key(UI_BoxFlag_DrawBackground, ui_key_zero()); @@ -7318,7 +7404,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) ui_spacer(ui_em(0.2f, 1.f)); UI_CornerRadius00(corner_radius) UI_CornerRadius10(corner_radius) - DF_Palette(DF_PaletteCode_DropSiteOverlay) + DF_Palette(ws, DF_PaletteCode_DropSiteOverlay) { ui_build_box_from_key(UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawBorder, ui_key_zero()); } @@ -7343,11 +7429,11 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) UI_Box *tab_column_box = ui_build_box_from_stringf(!is_changing_panel_boundaries*UI_BoxFlag_AnimatePosX, "tab_column_%p", view); // rjf: build tab container box - UI_Parent(tab_column_box) UI_PrefHeight(ui_px(tab_bar_vheight, 1)) DF_Palette(view_is_selected ? DF_PaletteCode_Tab : DF_PaletteCode_TabInactive) + UI_Parent(tab_column_box) UI_PrefHeight(ui_px(tab_bar_vheight, 1)) DF_Palette(ws, view_is_selected ? DF_PaletteCode_Tab : DF_PaletteCode_TabInactive) { if(panel->tab_side == Side_Max) { - ui_spacer(ui_px(tab_bar_rv_diff, 1.f)); + ui_spacer(ui_px(tab_bar_rv_diff-1.f, 1.f)); } else { @@ -7372,7 +7458,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_TextAlignment(UI_TextAlign_Center) UI_PrefWidth(ui_em(1.75f, 1.f)) ui_label(df_g_icon_kind_text_table[icon_kind]); @@ -7426,7 +7512,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) UI_PrefWidth(ui_em(2.35f, 1.f)) UI_TextAlignment(UI_TextAlign_Center) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)*0.75f) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_Flags(UI_BoxFlag_DrawTextWeak) UI_CornerRadius00(0) UI_CornerRadius01(0) @@ -7465,6 +7551,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) else if(ui_right_clicked(sig)) { ui_ctx_menu_open(ws->tab_ctx_menu_key, sig.box->key, v2f32(0, sig.box->rect.y1 - sig.box->rect.y0)); + ws->tab_ctx_menu_panel = df_handle_from_panel(panel); ws->tab_ctx_menu_view = df_handle_from_view(view); } else if(ui_middle_clicked(sig)) @@ -7496,15 +7583,24 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) UI_PrefHeight(ui_px(tab_bar_vheight, 1.f)) UI_Column { - ui_spacer(ui_px(tab_bar_rv_diff/2.f, 1.f)); - UI_CornerRadius00(corner_radius) - UI_CornerRadius10(corner_radius) + if(panel->tab_side == Side_Max) + { + ui_spacer(ui_px(tab_bar_rv_diff-1.f, 1.f)); + } + else + { + ui_spacer(ui_px(1.f, 1.f)); + } + UI_CornerRadius00(panel->tab_side == Side_Min ? corner_radius : 0) + UI_CornerRadius10(panel->tab_side == Side_Min ? corner_radius : 0) + UI_CornerRadius01(panel->tab_side == Side_Max ? corner_radius : 0) + UI_CornerRadius11(panel->tab_side == Side_Max ? corner_radius : 0) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(ui_top_font_size()) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_HoverCursor(OS_Cursor_HandPoint) - DF_Palette(DF_PaletteCode_ImplicitButton) + DF_Palette(ws, DF_PaletteCode_ImplicitButton) { UI_Box *add_new_box = ui_build_box_from_stringf(UI_BoxFlag_DrawBackground| UI_BoxFlag_DrawText| @@ -7575,7 +7671,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) DF_Panel *drag_panel = df_panel_from_handle(df_g_drag_drop_payload.panel); if(!df_view_is_nil(view) && active_drop_site != 0) { - DF_Palette(DF_PaletteCode_DropSiteOverlay) UI_Rect(tab_bar_rect) + DF_Palette(ws, DF_PaletteCode_DropSiteOverlay) UI_Rect(tab_bar_rect) ui_build_box_from_key(UI_BoxFlag_DrawBackground, ui_key_zero()); } @@ -7634,7 +7730,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) { // rjf: vis { - DF_Palette(DF_PaletteCode_DropSiteOverlay) UI_Rect(content_rect) + DF_Palette(ws, DF_PaletteCode_DropSiteOverlay) UI_Rect(content_rect) ui_build_box_from_key(UI_BoxFlag_DrawBackground, ui_key_zero()); } @@ -7715,8 +7811,8 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) } view->loading_t += (view->loading_t_target - view->loading_t) * rate; view->is_filtering_t += ((F32)!!view->is_filtering - view->is_filtering_t) * fast_rate; - view->scroll_pos.x.off -= view->scroll_pos.x.off * (df_setting_val_from_code(DF_SettingCode_ScrollingAnimations).s32 ? fast_rate : 1.f); - view->scroll_pos.y.off -= view->scroll_pos.y.off * (df_setting_val_from_code(DF_SettingCode_ScrollingAnimations).s32 ? fast_rate : 1.f); + view->scroll_pos.x.off -= view->scroll_pos.x.off * (df_setting_val_from_code(ws, DF_SettingCode_ScrollingAnimations).s32 ? fast_rate : 1.f); + view->scroll_pos.y.off -= view->scroll_pos.y.off * (df_setting_val_from_code(ws, DF_SettingCode_ScrollingAnimations).s32 ? fast_rate : 1.f); if(abs_f32(view->scroll_pos.x.off) < 0.01f) { view->scroll_pos.x.off = 0; @@ -7800,9 +7896,9 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) } ////////////////////////////// - //- rjf: attach autocomp box to root + //- rjf: attach autocomp box to root, or hide if it has not been renewed // - if(!ui_box_is_nil(autocomp_box)) + if(!ui_box_is_nil(autocomp_box) && ws->autocomp_last_frame_idx+1 >= df_frame_index()+1) { UI_Box *autocomp_root_box = ui_box_from_key(ws->autocomp_root_key); if(!ui_box_is_nil(autocomp_root_box)) @@ -7820,6 +7916,17 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) } } } + else if(!ui_box_is_nil(autocomp_box) && ws->autocomp_last_frame_idx+1 < df_frame_index()+1) + { + UI_Box *autocomp_root_box = ui_box_from_key(ws->autocomp_root_key); + if(!ui_box_is_nil(autocomp_root_box)) + { + Vec2F32 size = autocomp_box->fixed_size; + Rng2F32 window_rect = os_client_rect_from_window(ws->os); + autocomp_box->fixed_position = v2f32(window_rect.x1, window_rect.y1); + autocomp_box->rect = r2f32(autocomp_box->fixed_position, add_2f32(autocomp_box->fixed_position, size)); + } + } ////////////////////////////// //- rjf: hover eval cancelling @@ -7922,7 +8029,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) } // rjf: blur background - if(box->flags & UI_BoxFlag_DrawBackgroundBlur && df_setting_val_from_code(DF_SettingCode_BackgroundBlur).s32) + if(box->flags & UI_BoxFlag_DrawBackgroundBlur && df_setting_val_from_code(ws, DF_SettingCode_BackgroundBlur).s32) { R_PassParams_Blur *params = d_blur(box->rect, box->blur_size*(1-box->transparency), 0); MemoryCopyArray(params->corner_radii, box->corner_radii); @@ -7933,7 +8040,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) { // rjf: main rectangle { - R_Rect2DInst *inst = d_rect(pad_2f32(box->rect, 1.5f), box->palette->colors[UI_ColorCode_Background], 0, 0, 1.f); + R_Rect2DInst *inst = d_rect(pad_2f32(box->rect, 1), box->palette->colors[UI_ColorCode_Background], 0, 0, 1.f); MemoryCopyArray(inst->corner_radii, box->corner_radii); } @@ -8146,7 +8253,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) { Vec4F32 color = df_rgba_from_theme_color(DF_ThemeColor_Hover); color.w *= b->hot_t; - R_Rect2DInst *inst = d_rect(pad_2f32(b->rect, 1.f), color, 0, 1.f, 1.f); + R_Rect2DInst *inst = d_rect(pad_2f32(b->rect, 1), color, 0, 1.f, 1.f); MemoryCopyArray(inst->corner_radii, b->corner_radii); } } @@ -8259,6 +8366,18 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) //- rjf: scratch debug mouse drawing if(DEV_scratch_mouse_draw) { +#if 1 + Vec2F32 p = add_2f32(os_mouse_from_window(ws->os), v2f32(30, 0)); + d_rect(os_client_rect_from_window(ws->os), v4f32(0, 0, 0, 0.9f), 0, 0, 0); + F_Run trailer_run = f_push_run_from_string(scratch.arena, df_font_from_slot(DF_FontSlot_Main), 16.f, 0, 0, 0, str8_lit("...")); + D_FancyStringList strs = {0}; + D_FancyString str = {df_font_from_slot(DF_FontSlot_Main), str8_lit("Shift + F5"), v4f32(1, 1, 1, 1), 72.f, 0.f}; + d_fancy_string_list_push(scratch.arena, &strs, &str); + D_FancyRunList runs = d_fancy_run_list_from_fancy_string_list(scratch.arena, 0, F_RasterFlag_Smooth, &strs); + d_truncated_fancy_run_list(p, &runs, 1000000.f, trailer_run); + d_rect(r2f32(p, add_2f32(p, runs.dim)), v4f32(1, 0, 0, 0.5f), 0, 1, 0); + d_rect(r2f32(sub_2f32(p, v2f32(4, 4)), add_2f32(p, v2f32(4, 4))), v4f32(1, 0, 1, 1), 0, 0, 0); +#else Vec2F32 p = add_2f32(os_mouse_from_window(ws->os), v2f32(30, 0)); d_rect(os_client_rect_from_window(ws->os), v4f32(0, 0, 0, 0.4f), 0, 0, 0); D_FancyStringList strs = {0}; @@ -8274,6 +8393,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) d_truncated_fancy_run_list(p, &runs, limit, trailer_run); d_rect(r2f32p(p.x+limit, 0, p.x+limit+2.f, 1000), v4f32(1, 0, 0, 1), 0, 0, 0); df_gfx_request_frame(); +#endif } scratch_end(scratch); @@ -9546,9 +9666,9 @@ df_theme_color_from_txt_token_kind(TXT_TokenKind kind) //- rjf: code -> palette internal UI_Palette * -df_palette_from_code(DF_PaletteCode code) +df_palette_from_code(DF_Window *ws, DF_PaletteCode code) { - UI_Palette *result = &df_gfx_state->cfg_palettes[code]; + UI_Palette *result = &ws->cfg_palettes[code]; return result; } @@ -9566,23 +9686,34 @@ df_font_size_from_slot(DF_Window *ws, DF_FontSlot slot) { F32 result = 0; F32 dpi = os_dpi_from_window(ws->os); + if(dpi != ws->last_dpi) + { + F32 old_dpi = ws->last_dpi; + F32 new_dpi = dpi; + ws->last_dpi = dpi; + S32 *pt_sizes[] = + { + &ws->setting_vals[DF_SettingCode_MainFontSize].s32, + &ws->setting_vals[DF_SettingCode_CodeFontSize].s32, + }; + for(U64 idx = 0; idx < ArrayCount(pt_sizes); idx += 1) + { + F32 ratio = pt_sizes[idx][0] / old_dpi; + F32 new_pt_size = ratio*new_dpi; + pt_sizes[idx][0] = (S32)new_pt_size; + } + } switch(slot) { - default: - case DF_FontSlot_Main: - { - F32 size_at_96dpi = 10.f; - result = dpi * ((size_at_96dpi / 96.f) + ws->main_font_size_delta); - }break; case DF_FontSlot_Code: { - F32 size_at_96dpi = 10.f; - result = dpi * ((size_at_96dpi / 96.f) + ws->code_font_size_delta); + result = (F32)ws->setting_vals[DF_SettingCode_CodeFontSize].s32; }break; + default: + case DF_FontSlot_Main: case DF_FontSlot_Icons: { - F32 size_at_96dpi = 10.f; - result = dpi * ((size_at_96dpi / 96.f) + ws->main_font_size_delta); + result = (F32)ws->setting_vals[DF_SettingCode_MainFontSize].s32; }break; } return result; @@ -9591,15 +9722,22 @@ df_font_size_from_slot(DF_Window *ws, DF_FontSlot slot) //- rjf: settings internal DF_SettingVal -df_setting_val_from_code(DF_SettingCode code) +df_setting_val_from_code(DF_Window *optional_window, DF_SettingCode code) { DF_SettingVal result = {0}; - for(EachEnumVal(DF_CfgSrc, src)) + if(optional_window != 0) { - if(df_gfx_state->cfg_setting_vals[src][code].set) + result = optional_window->setting_vals[code]; + } + if(result.set == 0) + { + for(EachEnumVal(DF_CfgSrc, src)) { - result = df_gfx_state->cfg_setting_vals[src][code]; - break; + if(df_gfx_state->cfg_setting_vals[src][code].set) + { + result = df_gfx_state->cfg_setting_vals[src][code]; + break; + } } } return result; @@ -9646,9 +9784,16 @@ df_cfg_strings_from_gfx(Arena *arena, String8 root_path, DF_CfgSrc source) os_window_is_fullscreen(window->os) ? " fullscreen" : "", os_window_is_maximized(window->os) ? " maximized" : ""); str8_list_pushf(arena, &strs, " monitor: \"%S\"\n", monitor_name); - str8_list_pushf(arena, &strs, " size: (%i %i)\n", (int)size.x, (int)size.y); - str8_list_pushf(arena, &strs, " code_font_size_delta: %.5f\n", window->code_font_size_delta); - str8_list_pushf(arena, &strs, " main_font_size_delta: %.5f\n", window->main_font_size_delta); + str8_list_pushf(arena, &strs, " size: (%i %i)\n", (int)size.x, (int)size.y); + str8_list_pushf(arena, &strs, " dpi: %f\n", os_dpi_from_window(window->os)); + for(EachEnumVal(DF_SettingCode, code)) + { + DF_SettingVal current = window->setting_vals[code]; + if(current.set) + { + str8_list_pushf(arena, &strs, " %S: %i\n", df_g_setting_code_lower_string_table[code], current.s32); + } + } { DF_PanelRec rec = {0}; S32 indentation = 2; @@ -9900,18 +10045,22 @@ df_cfg_strings_from_gfx(Arena *arena, String8 root_path, DF_CfgSrc source) str8_list_push(arena, &strs, str8_lit("\n")); } - //- rjf: serialize settings + //- rjf: serialize global settings { B32 first = 1; for(EachEnumVal(DF_SettingCode, code)) { + if(df_g_setting_code_default_is_per_window_table[code]) + { + continue; + } DF_SettingVal current = df_gfx_state->cfg_setting_vals[source][code]; if(current.set) { if(first) { first = 0; - str8_list_push(arena, &strs, str8_lit("/// settings //////////////////////////////////////////////////////////////////\n")); + str8_list_push(arena, &strs, str8_lit("/// global settings ///////////////////////////////////////////////////////////\n")); str8_list_push(arena, &strs, str8_lit("\n")); } str8_list_pushf(arena, &strs, "%S: %i\n", df_g_setting_code_lower_string_table[code], current.s32); @@ -10055,6 +10204,189 @@ df_stop_explanation_string_icon_from_ctrl_event(Arena *arena, CTRL_Event *event, //////////////////////////////// //~ rjf: UI Widgets: Fancy Buttons +internal void +df_cmd_binding_buttons(DF_CmdSpec *spec) +{ + Temp scratch = scratch_begin(0, 0); + DF_BindingList bindings = df_bindings_from_spec(scratch.arena, spec); + + //- rjf: build buttons for each binding + for(DF_BindingNode *n = bindings.first; n != 0; n = n->next) + { + DF_Binding binding = n->binding; + B32 rebinding_active_for_this_binding = (df_gfx_state->bind_change_active && + df_gfx_state->bind_change_cmd_spec == spec && + df_gfx_state->bind_change_binding.key == binding.key && + df_gfx_state->bind_change_binding.flags == binding.flags); + + //- rjf: grab all conflicts + DF_CmdSpecList specs_with_binding = df_cmd_spec_list_from_binding(scratch.arena, binding); + B32 has_conflicts = 0; + for(DF_CmdSpecNode *n = specs_with_binding.first; n != 0; n = n->next) + { + if(n->spec != spec) + { + has_conflicts = 1; + break; + } + } + + //- rjf: form binding string + String8 keybinding_str = {0}; + { + if(binding.key != OS_Key_Null) + { + String8List mods = os_string_list_from_event_flags(scratch.arena, binding.flags); + String8 key = os_g_key_display_string_table[binding.key]; + str8_list_push(scratch.arena, &mods, key); + StringJoin join = {0}; + join.sep = str8_lit(" + "); + keybinding_str = str8_list_join(scratch.arena, &mods, &join); + } + else + { + keybinding_str = str8_lit("- no binding -"); + } + } + + //- rjf: form color palette + UI_Palette *palette = ui_top_palette(); + if(has_conflicts || rebinding_active_for_this_binding) + { + palette = push_array(ui_build_arena(), UI_Palette, 1); + MemoryCopyStruct(palette, ui_top_palette()); + if(has_conflicts) + { + palette->colors[UI_ColorCode_Text] = df_rgba_from_theme_color(DF_ThemeColor_TextNegative); + palette->colors[UI_ColorCode_TextWeak] = df_rgba_from_theme_color(DF_ThemeColor_TextNegative); + } + if(rebinding_active_for_this_binding) + { + palette->colors[UI_ColorCode_Border] = df_rgba_from_theme_color(DF_ThemeColor_Focus); + palette->colors[UI_ColorCode_Background] = df_rgba_from_theme_color(DF_ThemeColor_Focus); + palette->colors[UI_ColorCode_Background].w *= 0.25f; + } + } + + //- rjf: build box + ui_set_next_hover_cursor(OS_Cursor_HandPoint); + ui_set_next_text_alignment(UI_TextAlign_Center); + ui_set_next_palette(palette); + ui_set_next_group_key(ui_key_zero()); + ui_set_next_pref_width(ui_text_dim(ui_top_font_size()*1.f, 1)); + UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText| + UI_BoxFlag_Clickable| + UI_BoxFlag_DrawActiveEffects| + UI_BoxFlag_DrawHotEffects| + UI_BoxFlag_DrawBorder| + UI_BoxFlag_DrawBackground, + "%S###bind_btn_%p_%x_%x", keybinding_str, spec, binding.key, binding.flags); + + //- rjf: interaction + UI_Signal sig = ui_signal_from_box(box); + { + // rjf: click => toggle activity + if(!df_gfx_state->bind_change_active && ui_clicked(sig)) + { + if((binding.key == OS_Key_Esc || binding.key == OS_Key_Delete) && binding.flags == 0) + { + DF_CmdParams p = df_cmd_params_zero(); + p.string = str8_lit("Cannot rebind; this command uses a reserved keybinding."); + df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Error)); + } + else + { + df_gfx_state->bind_change_active = 1; + df_gfx_state->bind_change_cmd_spec = spec; + df_gfx_state->bind_change_binding = binding; + } + } + else if(df_gfx_state->bind_change_active && ui_clicked(sig)) + { + df_gfx_state->bind_change_active = 0; + } + + // rjf: hover w/ conflicts => show conflicts + if(ui_hovering(sig) && has_conflicts) UI_Tooltip + { + UI_PrefWidth(ui_children_sum(1)) df_error_label(str8_lit("This binding conflicts with those for:")); + for(DF_CmdSpecNode *n = specs_with_binding.first; n != 0; n = n->next) + { + if(n->spec != spec) + { + ui_labelf("%S", n->spec->info.display_name); + } + } + } + } + + //- rjf: delete button + if(rebinding_active_for_this_binding) + UI_PrefWidth(ui_em(2.5f, 1.f)) + UI_Palette(ui_build_palette(ui_top_palette(), + .background = df_rgba_from_theme_color(DF_ThemeColor_NegativePopButtonBackground), + .border = df_rgba_from_theme_color(DF_ThemeColor_NegativePopButtonBorder), + .text = df_rgba_from_theme_color(DF_ThemeColor_Text))) + { + ui_set_next_group_key(ui_key_zero()); + UI_Signal sig = df_icon_button(DF_IconKind_X, 0, str8_lit("###delete_binding")); + if(ui_clicked(sig)) + { + df_unbind_spec(spec, binding); + df_gfx_state->bind_change_active = 0; + } + } + + //- rjf: space + ui_spacer(ui_em(1.f, 1.f)); + } + + //- rjf: build "add new binding" button + UI_Font(df_font_from_slot(DF_FontSlot_Icons)) + { + UI_Palette *palette = ui_top_palette(); + B32 adding_new_binding = (df_gfx_state->bind_change_active && + df_gfx_state->bind_change_cmd_spec == spec && + df_gfx_state->bind_change_binding.key == OS_Key_Null && + df_gfx_state->bind_change_binding.flags == 0); + if(adding_new_binding) + { + palette = ui_build_palette(ui_top_palette()); + palette->colors[UI_ColorCode_Border] = df_rgba_from_theme_color(DF_ThemeColor_Focus); + palette->colors[UI_ColorCode_Background] = df_rgba_from_theme_color(DF_ThemeColor_Focus); + palette->colors[UI_ColorCode_Background].w *= 0.25f; + } + ui_set_next_hover_cursor(OS_Cursor_HandPoint); + ui_set_next_text_alignment(UI_TextAlign_Center); + ui_set_next_group_key(ui_key_zero()); + ui_set_next_pref_width(ui_text_dim(ui_top_font_size()*1.f, 1)); + ui_set_next_palette(palette); + UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText| + UI_BoxFlag_Clickable| + UI_BoxFlag_DrawActiveEffects| + UI_BoxFlag_DrawHotEffects| + UI_BoxFlag_DrawBorder| + UI_BoxFlag_DrawBackground, + "%S###add_binding", df_g_icon_kind_text_table[DF_IconKind_Add]); + UI_Signal sig = ui_signal_from_box(box); + if(ui_clicked(sig)) + { + if(!df_gfx_state->bind_change_active && ui_clicked(sig)) + { + df_gfx_state->bind_change_active = 1; + df_gfx_state->bind_change_cmd_spec = spec; + MemoryZeroStruct(&df_gfx_state->bind_change_binding); + } + else if(df_gfx_state->bind_change_active && ui_clicked(sig)) + { + df_gfx_state->bind_change_active = 0; + } + } + } + + scratch_end(scratch); +} + internal void df_cmd_binding_button(DF_CmdSpec *spec) { @@ -10185,7 +10517,7 @@ df_cmd_spec_button(DF_CmdSpec *spec) if(canonical_icon != DF_IconKind_Null) { UI_Font(df_font_from_slot(DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_PrefWidth(ui_em(2.f, 1.f)) UI_TextAlignment(UI_TextAlign_Center) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) @@ -10199,10 +10531,14 @@ df_cmd_spec_button(DF_CmdSpec *spec) UI_FastpathCodepoint(box->fastpath_codepoint) ui_label(spec->info.display_name); ui_spacer(ui_pct(1, 0)); - UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + ui_set_next_flags(UI_BoxFlag_Clickable); + ui_set_next_group_key(ui_key_zero()); + UI_PrefWidth(ui_children_sum(1)) + UI_NamedRow(str8_lit("###bindings")) + UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_FastpathCodepoint(0) { - df_cmd_binding_button(spec); + df_cmd_binding_buttons(spec); } } } @@ -10256,7 +10592,7 @@ df_icon_button(DF_IconKind kind, FuzzyMatchRangeList *matches, String8 string) } UI_TextAlignment(UI_TextAlign_Center) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_PrefWidth(ui_em(2.f, 1.f)) UI_PrefHeight(ui_pct(1, 0)) UI_FlagsAdd(UI_BoxFlag_DisableTextTrunc|UI_BoxFlag_DrawTextWeak) @@ -10299,10 +10635,10 @@ df_icon_buttonf(DF_IconKind kind, FuzzyMatchRangeList *matches, char *fmt, ...) } internal void -df_entity_tooltips(DF_Entity *entity) +df_entity_tooltips(DF_Window *ws, DF_Entity *entity) { Temp scratch = scratch_begin(0, 0); - DF_Palette(DF_PaletteCode_Floating) switch(entity->kind) + DF_Palette(ws, DF_PaletteCode_Floating) switch(entity->kind) { default:{}break; case DF_EntityKind_File: @@ -10349,7 +10685,7 @@ df_entity_tooltips(DF_Entity *entity) { UI_PrefWidth(ui_em(1.5f, 1.f)) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) ui_label(df_g_icon_kind_text_table[icon_kind]); UI_PrefWidth(ui_text_dim(10, 1)) ui_label(explanation); } @@ -10470,7 +10806,7 @@ df_entity_desc_button(DF_Window *ws, DF_Entity *entity, FuzzyMatchRangeList *nam DF_Entity *selected_thread = df_entity_from_handle(ctrl_ctx.thread); if(selected_thread == entity) { - palette = df_palette_from_code(DF_PaletteCode_NeutralPopButton); + palette = df_palette_from_code(ws, DF_PaletteCode_NeutralPopButton); } if(stopped_thread == entity && (stop_event.cause == CTRL_EventCause_UserBreakpoint || @@ -10478,16 +10814,16 @@ df_entity_desc_button(DF_Window *ws, DF_Entity *entity, FuzzyMatchRangeList *nam stop_event.cause == CTRL_EventCause_InterruptedByTrap || stop_event.cause == CTRL_EventCause_InterruptedByHalt)) { - palette = df_palette_from_code(DF_PaletteCode_NegativePopButton); + palette = df_palette_from_code(ws, DF_PaletteCode_NegativePopButton); } } if(entity->cfg_src == DF_CfgSrc_CommandLine) { - palette = df_palette_from_code(DF_PaletteCode_NeutralPopButton); + palette = df_palette_from_code(ws, DF_PaletteCode_NeutralPopButton); } else if(entity->kind == DF_EntityKind_Target && entity->b32 != 0) { - palette = df_palette_from_code(DF_PaletteCode_NeutralPopButton); + palette = df_palette_from_code(ws, DF_PaletteCode_NeutralPopButton); } ui_set_next_palette(palette); ui_set_next_hover_cursor(OS_Cursor_HandPoint); @@ -10515,7 +10851,7 @@ df_entity_desc_button(DF_Window *ws, DF_Entity *entity, FuzzyMatchRangeList *nam UI_TextAlignment(UI_TextAlign_Center) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_PrefWidth(ui_em(1.875f, 1.f)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_label(df_g_icon_kind_text_table[icon]); @@ -10527,7 +10863,7 @@ df_entity_desc_button(DF_Window *ws, DF_Entity *entity, FuzzyMatchRangeList *nam UI_Box *info_box = &ui_g_nil_box; UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) { info_box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DrawTextWeak|UI_BoxFlag_Clickable, "%S###%p_temp_info", df_g_icon_kind_text_table[DF_IconKind_Info], entity); } @@ -10612,7 +10948,7 @@ df_entity_desc_button(DF_Window *ws, DF_Entity *entity, FuzzyMatchRangeList *nam { if(ui_hovering(sig) && !df_drag_is_active()) { - df_entity_tooltips(entity); + df_entity_tooltips(ws, entity); } // rjf: click => fastpath or dropdown for this entity @@ -10671,7 +11007,7 @@ df_entity_src_loc_button(DF_Window *ws, DF_Entity *entity, TxtPt point) UI_TextAlignment(UI_TextAlign_Center) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) ui_label(df_g_icon_kind_text_table[icon]); ui_labelf("%S:%I64d:%I64d", filename, point.line, point.column); } @@ -10716,6 +11052,8 @@ struct DF_ThreadBoxDrawExtData F32 alive_t; B32 is_selected; B32 is_frozen; + B32 do_lines; + B32 do_glow; }; internal UI_BOX_CUSTOM_DRAW(df_thread_box_draw_extensions) @@ -10723,7 +11061,7 @@ internal UI_BOX_CUSTOM_DRAW(df_thread_box_draw_extensions) DF_ThreadBoxDrawExtData *u = (DF_ThreadBoxDrawExtData *)box->custom_draw_user_data; // rjf: draw line before next-to-execute line - if(df_setting_val_from_code(DF_SettingCode_ThreadLines).s32) + if(u->do_lines) { R_Rect2DInst *inst = d_rect(r2f32p(box->parent->parent->parent->rect.x0, box->parent->rect.y0 - box->font_size*0.125f, @@ -10748,7 +11086,7 @@ internal UI_BOX_CUSTOM_DRAW(df_thread_box_draw_extensions) } // rjf: draw slight fill on selected thread - if(u->is_selected && df_setting_val_from_code(DF_SettingCode_ThreadGlow).s32) + if(u->is_selected && u->do_glow) { Vec4F32 weak_thread_color = u->thread_color; weak_thread_color.w *= 0.3f; @@ -10767,7 +11105,7 @@ internal UI_BOX_CUSTOM_DRAW(df_thread_box_draw_extensions) F32 lock_icon_off = ui_top_font_size()*0.2f; Vec4F32 lock_icon_color = df_rgba_from_theme_color(DF_ThemeColor_TextNegative); d_text(df_font_from_slot(DF_FontSlot_Icons), - box->font_size, 0, 0, F_RunFlag_Smooth, + box->font_size, 0, 0, F_RasterFlag_Smooth, v2f32((box->rect.x0 + box->rect.x1)/2 + lock_icon_off/2, box->rect.y0 + lock_icon_off/2), lock_icon_color, @@ -10781,6 +11119,8 @@ struct DF_BreakpointBoxDrawExtData Vec4F32 color; F32 alive_t; F32 remap_px_delta; + B32 do_lines; + B32 do_glow; }; internal UI_BOX_CUSTOM_DRAW(df_bp_box_draw_extensions) @@ -10788,7 +11128,7 @@ internal UI_BOX_CUSTOM_DRAW(df_bp_box_draw_extensions) DF_BreakpointBoxDrawExtData *u = (DF_BreakpointBoxDrawExtData *)box->custom_draw_user_data; // rjf: draw line before next-to-execute line - if(df_setting_val_from_code(DF_SettingCode_BreakpointLines).s32) + if(u->do_lines) { R_Rect2DInst *inst = d_rect(r2f32p(box->parent->parent->parent->rect.x0, box->parent->rect.y0 - box->font_size*0.125f, @@ -10800,7 +11140,7 @@ internal UI_BOX_CUSTOM_DRAW(df_bp_box_draw_extensions) } // rjf: draw slight fill - if(df_setting_val_from_code(DF_SettingCode_BreakpointGlow).s32) + if(u->do_glow) { Vec4F32 weak_thread_color = u->color; weak_thread_color.w *= 0.3f; @@ -10830,7 +11170,7 @@ internal UI_BOX_CUSTOM_DRAW(df_bp_box_draw_extensions) bp_center.x + remap_bar_thickness, bp_center.y + ClampBot(remap_px_delta, 0) + remap_bar_thickness), remap_color, 2.f, 0, 1.f); - d_text(box->font, box->font_size, 0, 0, F_RunFlag_Smooth, + d_text(box->font, box->font_size, 0, 0, F_RasterFlag_Smooth, v2f32(bp_text_pos.x, bp_center.y + remap_px_delta), remap_color, @@ -10859,8 +11199,8 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ df_rgba_from_theme_color(DF_ThemeColor_LineInfoBackground2), df_rgba_from_theme_color(DF_ThemeColor_LineInfoBackground3), }; - UI_Palette *margin_palette = df_palette_from_code(DF_PaletteCode_Floating); - UI_Palette *margin_contents_palette = ui_build_palette(df_palette_from_code(DF_PaletteCode_Floating)); + UI_Palette *margin_palette = df_palette_from_code(ws, DF_PaletteCode_Floating); + UI_Palette *margin_contents_palette = ui_build_palette(df_palette_from_code(ws, DF_PaletteCode_Floating)); margin_contents_palette->background = v4f32(0, 0, 0, 0); F32 line_num_padding_px = ui_top_font_size()*1.f; @@ -10983,7 +11323,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ ui_set_next_hover_cursor(OS_Cursor_UpDownLeftRight); ui_set_next_font(df_font_from_slot(DF_FontSlot_Icons)); ui_set_next_font_size(params->font_size); - ui_set_next_run_flags(F_RunFlag_Smooth); + ui_set_next_text_raster_flags(F_RasterFlag_Smooth); ui_set_next_pref_width(ui_pct(1, 0)); ui_set_next_pref_height(ui_pct(1, 0)); ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = color)); @@ -11003,6 +11343,8 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ u->alive_t = thread->alive_t; u->is_selected = (thread == selected_thread); u->is_frozen = df_entity_is_frozen(thread); + u->do_lines = df_setting_val_from_code(ws, DF_SettingCode_ThreadLines).s32; + u->do_glow = df_setting_val_from_code(ws, DF_SettingCode_ThreadGlow).s32; ui_box_equip_custom_draw(thread_box, df_thread_box_draw_extensions, u); // rjf: fill out progress t (progress into range of current line's @@ -11034,7 +11376,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ // rjf: hover tooltips if(ui_hovering(thread_sig) && !df_drag_is_active()) { - df_entity_tooltips(thread); + df_entity_tooltips(ws, thread); } // rjf: ip right-click menu @@ -11138,7 +11480,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ ui_set_next_hover_cursor(OS_Cursor_UpDownLeftRight); ui_set_next_font(df_font_from_slot(DF_FontSlot_Icons)); ui_set_next_font_size(params->font_size); - ui_set_next_run_flags(F_RunFlag_Smooth); + ui_set_next_text_raster_flags(F_RasterFlag_Smooth); ui_set_next_pref_width(ui_pct(1, 0)); ui_set_next_pref_height(ui_pct(1, 0)); ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = color)); @@ -11189,7 +11531,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ // rjf: hover tooltips if(ui_hovering(thread_sig) && !df_drag_is_active()) { - df_entity_tooltips(thread); + df_entity_tooltips(ws, thread); } // rjf: ip right-click menu @@ -11239,6 +11581,8 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ { bp_draw->color = bp_color; bp_draw->alive_t = bp->alive_t; + bp_draw->do_lines = df_setting_val_from_code(ws, DF_SettingCode_BreakpointLines).s32; + bp_draw->do_glow = df_setting_val_from_code(ws, DF_SettingCode_BreakpointGlow).s32; if(!df_entity_is_nil(df_entity_from_handle(df_interact_regs()->file))) { DF_LineList *lines = ¶ms->line_infos[line_idx]; @@ -11257,7 +11601,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ // rjf: build box for breakpoint ui_set_next_font(df_font_from_slot(DF_FontSlot_Icons)); ui_set_next_font_size(params->font_size * 1.f); - ui_set_next_run_flags(F_RunFlag_Smooth); + ui_set_next_text_raster_flags(F_RasterFlag_Smooth); ui_set_next_hover_cursor(OS_Cursor_HandPoint); ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = bp_color)); ui_set_next_text_alignment(UI_TextAlign_Center); @@ -11276,7 +11620,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ // rjf: bp hovering if(ui_hovering(bp_sig) && !df_drag_is_active()) { - df_entity_tooltips(bp); + df_entity_tooltips(ws, bp); } // rjf: click => remove breakpoint @@ -11318,7 +11662,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ // rjf: build box for watch ui_set_next_font(df_font_from_slot(DF_FontSlot_Icons)); ui_set_next_font_size(params->font_size * 1.f); - ui_set_next_run_flags(F_RunFlag_Smooth); + ui_set_next_text_raster_flags(F_RasterFlag_Smooth); ui_set_next_hover_cursor(OS_Cursor_HandPoint); ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = color)); ui_set_next_text_alignment(UI_TextAlign_Center); @@ -11336,7 +11680,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ // rjf: watch hovering if(ui_hovering(pin_sig) && !df_drag_is_active()) { - df_entity_tooltips(pin); + df_entity_tooltips(ws, pin); } // rjf: click => remove pin @@ -11405,6 +11749,8 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ UI_PrefHeight(ui_px(params->line_height_px, 1.f)) UI_Font(params->font) UI_FontSize(params->font_size) + UI_TextRasterFlags((!!df_setting_val_from_code(ws, DF_SettingCode_SmoothCodeText).s32 * F_RasterFlag_Smooth)| + (!!df_setting_val_from_code(ws, DF_SettingCode_HintCodeText).s32 * F_RasterFlag_Hinted)) UI_CornerRadius(0) { U64 line_idx = 0; @@ -11450,7 +11796,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ //- rjf: build background for line numbers & margins // { - UI_Parent(top_container_box) DF_Palette(DF_PaletteCode_Floating) + UI_Parent(top_container_box) DF_Palette(ws, DF_PaletteCode_Floating) { ui_set_next_pref_width(ui_px(params->priority_margin_width_px + params->catchall_margin_width_px + params->line_num_width_px, 1)); ui_set_next_pref_height(ui_px(params->line_height_px*(dim_1s64(params->line_num_range)+1), 1.f)); @@ -11530,7 +11876,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ UI_Parent(box) UI_PrefWidth(ui_text_dim(10, 1)) { UI_Font(df_font_from_slot(DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) ui_label(df_g_icon_kind_text_table[DF_IconKind_WarningBig]); ui_label(explanation); } @@ -11552,7 +11898,12 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ line_num += 1, line_idx += 1) { DF_EntityList pins = params->line_pins[line_idx]; - if(pins.count != 0) UI_Parent(line_extras_boxes[line_idx]) UI_Font(params->font) UI_FontSize(params->font_size) UI_PrefHeight(ui_px(params->line_height_px, 1.f)) + if(pins.count != 0) UI_Parent(line_extras_boxes[line_idx]) + UI_Font(params->font) + UI_FontSize(params->font_size) + UI_TextRasterFlags((!!df_setting_val_from_code(ws, DF_SettingCode_SmoothCodeText).s32 * F_RasterFlag_Smooth)| + (!!df_setting_val_from_code(ws, DF_SettingCode_HintCodeText).s32 * F_RasterFlag_Hinted)) + UI_PrefHeight(ui_px(params->line_height_px, 1.f)) { for(DF_EntityNode *n = pins.first; n != 0; n = n->next) { @@ -11582,7 +11933,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ } UI_PrefWidth(ui_em(1.5f, 1.f)) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_Palette(ui_build_palette(ui_top_palette(), .text = pin_color)) UI_TextAlignment(UI_TextAlign_Center) UI_Flags(UI_BoxFlag_DisableTextTrunc) @@ -11984,6 +12335,8 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ UI_PrefHeight(ui_px(params->line_height_px, 1.f)) UI_Font(params->font) UI_FontSize(params->font_size) + UI_TextRasterFlags((!!df_setting_val_from_code(ws, DF_SettingCode_SmoothCodeText).s32 * F_RasterFlag_Smooth)| + (!!df_setting_val_from_code(ws, DF_SettingCode_HintCodeText).s32 * F_RasterFlag_Hinted)) UI_CornerRadius(0) { U64 line_idx = 0; @@ -11993,7 +12346,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ String8 line_string = params->line_text[line_idx]; Rng1U64 line_range = params->line_ranges[line_idx]; TXT_TokenArray *line_tokens = ¶ms->line_tokens[line_idx]; - ui_set_next_text_padding(line_num_padding_px-2); + ui_set_next_text_padding(line_num_padding_px); UI_Key line_key = ui_key_from_stringf(top_container_box->key, "ln_%I64x", line_num); Vec4F32 line_bg_color = line_bg_colors[line_idx]; if(line_bg_color.w != 0) @@ -12206,10 +12559,10 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ }; Rng2F32 select_rect = { - line_box->rect.x0+line_num_padding_px+select_column_pixel_off_range.min, - floorf(line_box->rect.y0) - 1.f, + line_box->rect.x0+line_num_padding_px+select_column_pixel_off_range.min-2.f, + floor_f32(line_box->rect.y0) - 1.f, line_box->rect.x0+line_num_padding_px+select_column_pixel_off_range.max+2.f, - ceilf(line_box->rect.y1) + 1.f, + ceil_f32(line_box->rect.y1) + 1.f, }; Vec4F32 color = n->color; if(!is_focused) @@ -12235,9 +12588,9 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ F32 cursor_thickness = ClampBot(4.f, line_box->font_size/6.f); Rng2F32 cursor_rect = { - ui_box_text_position(line_box).x+cursor_off_pixels, + ui_box_text_position(line_box).x+cursor_off_pixels-cursor_thickness/2.f, line_box->rect.y0-params->font_size*0.25f, - ui_box_text_position(line_box).x+cursor_off_pixels+cursor_thickness, + ui_box_text_position(line_box).x+cursor_off_pixels+cursor_thickness/2.f, line_box->rect.y1+params->font_size*0.25f, }; d_rect(cursor_rect, df_rgba_from_theme_color(is_focused ? DF_ThemeColor_Cursor : DF_ThemeColor_CursorInactive), 1.f, 0, 1.f); @@ -12490,7 +12843,7 @@ df_error_label(String8 string) UI_Parent(box) UI_Palette(ui_build_palette(ui_top_palette(), .text = df_rgba_from_theme_color(DF_ThemeColor_TextNegative), .text_weak = df_rgba_from_theme_color(DF_ThemeColor_TextNegative))) { ui_set_next_font(df_font_from_slot(DF_FontSlot_Icons)); - ui_set_next_run_flags(F_RunFlag_Smooth); + ui_set_next_text_raster_flags(F_RasterFlag_Smooth); ui_set_next_text_alignment(UI_TextAlign_Center); ui_set_next_flags(UI_BoxFlag_DrawTextWeak); UI_PrefWidth(ui_em(2.25f, 1.f)) ui_label(df_g_icon_kind_text_table[DF_IconKind_WarningBig]); @@ -12512,7 +12865,7 @@ df_help_label(String8 string) { result = 1; ui_set_next_font(df_font_from_slot(DF_FontSlot_Icons)); - ui_set_next_run_flags(F_RunFlag_Smooth); + ui_set_next_text_raster_flags(F_RasterFlag_Smooth); ui_set_next_text_alignment(UI_TextAlign_Center); UI_Box *help_hoverer = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawHotEffects, "###help_hoverer_%S", string); ui_box_equip_display_string(help_hoverer, df_g_icon_kind_text_table[DF_IconKind_QuestionMark]); @@ -12745,7 +13098,7 @@ df_line_edit(DF_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_Flags(UI_BoxFlag_DrawSideLeft) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) ui_label(df_g_icon_kind_text_table[DF_IconKind_Dot]); } @@ -13272,7 +13625,7 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds) //- rjf: animate confirmation { - F32 rate = df_setting_val_from_code(DF_SettingCode_MenuAnimations).s32 ? 1 - pow_f32(2, (-10.f * df_dt())) : 1.f; + F32 rate = df_setting_val_from_code(0, DF_SettingCode_MenuAnimations).s32 ? 1 - pow_f32(2, (-10.f * df_dt())) : 1.f; B32 confirm_open = df_gfx_state->confirm_active; df_gfx_state->confirm_t += rate * ((F32)!!confirm_open-df_gfx_state->confirm_t); if(abs_f32(df_gfx_state->confirm_t - (F32)!!confirm_open) > 0.005f) @@ -13349,8 +13702,17 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds) //- rjf: windows case DF_CoreCmdKind_OpenWindow: { + DF_Window *originating_window = df_window_from_handle(params.window); + if(originating_window == 0) + { + originating_window = df_gfx_state->first_window; + } OS_Handle preferred_monitor = {0}; - df_window_open(v2f32(1280, 720), preferred_monitor, DF_CfgSrc_User); + DF_Window *new_ws = df_window_open(v2f32(1280, 720), preferred_monitor, DF_CfgSrc_User); + if(originating_window) + { + MemoryCopy(new_ws->setting_vals, originating_window->setting_vals, sizeof(DF_SettingVal)*DF_SettingCode_COUNT); + } }break; case DF_CoreCmdKind_CloseWindow: { @@ -13575,8 +13937,8 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds) Axis2 top_level_split_axis = Axis2_X; OS_Handle preferred_monitor = os_primary_monitor(); Vec2F32 size = {0}; - F32 code_font_size_delta = 0.f; - F32 main_font_size_delta = 0.f; + F32 dpi = 0.f; + DF_SettingVal setting_vals[DF_SettingCode_COUNT] = {0}; { for(DF_CfgNode *n = window_node->first; n != &df_g_nil_cfg_node; n = n->next) { @@ -13634,18 +13996,34 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds) size.x = (F32)x_u64; size.y = (F32)y_u64; } - DF_CfgNode *code_font_size_delta_cfg = df_cfg_node_child_from_string(window_node, str8_lit("code_font_size_delta"), StringMatchFlag_CaseInsensitive); - DF_CfgNode *main_font_size_delta_cfg = df_cfg_node_child_from_string(window_node, str8_lit("main_font_size_delta"), StringMatchFlag_CaseInsensitive); - String8 code_font_size_delta_cfg_string = df_string_from_cfg_node_children(scratch.arena, code_font_size_delta_cfg); - String8 main_font_size_delta_cfg_string = df_string_from_cfg_node_children(scratch.arena, main_font_size_delta_cfg); - code_font_size_delta = (F32)f64_from_str8(code_font_size_delta_cfg_string); - main_font_size_delta = (F32)f64_from_str8(main_font_size_delta_cfg_string); + DF_CfgNode *dpi_cfg = df_cfg_node_child_from_string(window_node, str8_lit("dpi"), StringMatchFlag_CaseInsensitive); + String8 dpi_cfg_string = df_string_from_cfg_node_children(scratch.arena, dpi_cfg); + dpi = f64_from_str8(dpi_cfg_string); + for(EachEnumVal(DF_SettingCode, code)) + { + DF_CfgNode *cfg = df_cfg_node_child_from_string(window_node, df_g_setting_code_lower_string_table[code], StringMatchFlag_CaseInsensitive); + if(cfg != &df_g_nil_cfg_node) + { + S64 val_s64 = 0; + try_s64_from_str8_c_rules(cfg->first->string, &val_s64); + setting_vals[code].set = 1; + setting_vals[code].s32 = (S32)val_s64; + setting_vals[code].s32 = clamp_1s32(df_g_setting_code_s32_range_table[code], setting_vals[code].s32); + } + } } // rjf: open window DF_Window *ws = df_window_open(size, preferred_monitor, window_node->source); - ws->code_font_size_delta = code_font_size_delta; - ws->main_font_size_delta = main_font_size_delta; + if(dpi != 0.f) { ws->last_dpi = dpi; } + for(EachEnumVal(DF_SettingCode, code)) + { + if(setting_vals[code].set == 0 && df_g_setting_code_default_is_per_window_table[code]) + { + setting_vals[code] = df_g_setting_code_default_val_table[code]; + } + } + MemoryCopy(ws->setting_vals, setting_vals, sizeof(setting_vals[0])*ArrayCount(setting_vals)); // rjf: build panel tree DF_CfgNode *cfg_panels = df_cfg_node_child_from_string(window_node, str8_lit("panels"), StringMatchFlag_CaseInsensitive); @@ -14191,77 +14569,6 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds) } } - //- rjf: compute ui color schemes from theme - { - DF_Theme *current = &df_gfx_state->cfg_theme; - for(EachEnumVal(DF_PaletteCode, code)) - { - df_gfx_state->cfg_palettes[code].null = v4f32(1, 0, 1, 1); - df_gfx_state->cfg_palettes[code].cursor = current->colors[DF_ThemeColor_Cursor]; - df_gfx_state->cfg_palettes[code].selection = current->colors[DF_ThemeColor_SelectionOverlay]; - } - df_gfx_state->cfg_palettes[DF_PaletteCode_Base].background = current->colors[DF_ThemeColor_BaseBackground]; - df_gfx_state->cfg_palettes[DF_PaletteCode_Base].text = current->colors[DF_ThemeColor_Text]; - df_gfx_state->cfg_palettes[DF_PaletteCode_Base].text_weak = current->colors[DF_ThemeColor_TextWeak]; - df_gfx_state->cfg_palettes[DF_PaletteCode_Base].border = current->colors[DF_ThemeColor_BaseBorder]; - df_gfx_state->cfg_palettes[DF_PaletteCode_MenuBar].background = current->colors[DF_ThemeColor_MenuBarBackground]; - df_gfx_state->cfg_palettes[DF_PaletteCode_MenuBar].text = current->colors[DF_ThemeColor_Text]; - df_gfx_state->cfg_palettes[DF_PaletteCode_MenuBar].text_weak = current->colors[DF_ThemeColor_TextWeak]; - df_gfx_state->cfg_palettes[DF_PaletteCode_MenuBar].border = current->colors[DF_ThemeColor_MenuBarBorder]; - df_gfx_state->cfg_palettes[DF_PaletteCode_Floating].background = current->colors[DF_ThemeColor_FloatingBackground]; - df_gfx_state->cfg_palettes[DF_PaletteCode_Floating].text = current->colors[DF_ThemeColor_Text]; - df_gfx_state->cfg_palettes[DF_PaletteCode_Floating].text_weak = current->colors[DF_ThemeColor_TextWeak]; - df_gfx_state->cfg_palettes[DF_PaletteCode_Floating].border = current->colors[DF_ThemeColor_FloatingBorder]; - df_gfx_state->cfg_palettes[DF_PaletteCode_ImplicitButton].background = current->colors[DF_ThemeColor_ImplicitButtonBackground]; - df_gfx_state->cfg_palettes[DF_PaletteCode_ImplicitButton].text = current->colors[DF_ThemeColor_Text]; - df_gfx_state->cfg_palettes[DF_PaletteCode_ImplicitButton].text_weak = current->colors[DF_ThemeColor_TextWeak]; - df_gfx_state->cfg_palettes[DF_PaletteCode_ImplicitButton].border = current->colors[DF_ThemeColor_ImplicitButtonBorder]; - df_gfx_state->cfg_palettes[DF_PaletteCode_PlainButton].background = current->colors[DF_ThemeColor_PlainButtonBackground]; - df_gfx_state->cfg_palettes[DF_PaletteCode_PlainButton].text = current->colors[DF_ThemeColor_Text]; - df_gfx_state->cfg_palettes[DF_PaletteCode_PlainButton].text_weak = current->colors[DF_ThemeColor_TextWeak]; - df_gfx_state->cfg_palettes[DF_PaletteCode_PlainButton].border = current->colors[DF_ThemeColor_PlainButtonBorder]; - df_gfx_state->cfg_palettes[DF_PaletteCode_PositivePopButton].background = current->colors[DF_ThemeColor_PositivePopButtonBackground]; - df_gfx_state->cfg_palettes[DF_PaletteCode_PositivePopButton].text = current->colors[DF_ThemeColor_Text]; - df_gfx_state->cfg_palettes[DF_PaletteCode_PositivePopButton].text_weak = current->colors[DF_ThemeColor_TextWeak]; - df_gfx_state->cfg_palettes[DF_PaletteCode_PositivePopButton].border = current->colors[DF_ThemeColor_PositivePopButtonBorder]; - df_gfx_state->cfg_palettes[DF_PaletteCode_NegativePopButton].background = current->colors[DF_ThemeColor_NegativePopButtonBackground]; - df_gfx_state->cfg_palettes[DF_PaletteCode_NegativePopButton].text = current->colors[DF_ThemeColor_Text]; - df_gfx_state->cfg_palettes[DF_PaletteCode_NegativePopButton].text_weak = current->colors[DF_ThemeColor_TextWeak]; - df_gfx_state->cfg_palettes[DF_PaletteCode_NegativePopButton].border = current->colors[DF_ThemeColor_NegativePopButtonBorder]; - df_gfx_state->cfg_palettes[DF_PaletteCode_NeutralPopButton].background = current->colors[DF_ThemeColor_NeutralPopButtonBackground]; - df_gfx_state->cfg_palettes[DF_PaletteCode_NeutralPopButton].text = current->colors[DF_ThemeColor_Text]; - df_gfx_state->cfg_palettes[DF_PaletteCode_NeutralPopButton].text_weak = current->colors[DF_ThemeColor_TextWeak]; - df_gfx_state->cfg_palettes[DF_PaletteCode_NeutralPopButton].border = current->colors[DF_ThemeColor_NeutralPopButtonBorder]; - df_gfx_state->cfg_palettes[DF_PaletteCode_ScrollBarButton].background = current->colors[DF_ThemeColor_ScrollBarButtonBackground]; - df_gfx_state->cfg_palettes[DF_PaletteCode_ScrollBarButton].text = current->colors[DF_ThemeColor_Text]; - df_gfx_state->cfg_palettes[DF_PaletteCode_ScrollBarButton].text_weak = current->colors[DF_ThemeColor_TextWeak]; - df_gfx_state->cfg_palettes[DF_PaletteCode_ScrollBarButton].border = current->colors[DF_ThemeColor_ScrollBarButtonBorder]; - df_gfx_state->cfg_palettes[DF_PaletteCode_Tab].background = current->colors[DF_ThemeColor_TabBackground]; - df_gfx_state->cfg_palettes[DF_PaletteCode_Tab].text = current->colors[DF_ThemeColor_Text]; - df_gfx_state->cfg_palettes[DF_PaletteCode_Tab].text_weak = current->colors[DF_ThemeColor_TextWeak]; - df_gfx_state->cfg_palettes[DF_PaletteCode_Tab].border = current->colors[DF_ThemeColor_TabBorder]; - df_gfx_state->cfg_palettes[DF_PaletteCode_TabInactive].background = current->colors[DF_ThemeColor_TabBackgroundInactive]; - df_gfx_state->cfg_palettes[DF_PaletteCode_TabInactive].text = current->colors[DF_ThemeColor_Text]; - df_gfx_state->cfg_palettes[DF_PaletteCode_TabInactive].text_weak = current->colors[DF_ThemeColor_TextWeak]; - df_gfx_state->cfg_palettes[DF_PaletteCode_TabInactive].border = current->colors[DF_ThemeColor_TabBorderInactive]; - df_gfx_state->cfg_palettes[DF_PaletteCode_DropSiteOverlay].background = current->colors[DF_ThemeColor_DropSiteOverlay]; - df_gfx_state->cfg_palettes[DF_PaletteCode_DropSiteOverlay].text = current->colors[DF_ThemeColor_DropSiteOverlay]; - df_gfx_state->cfg_palettes[DF_PaletteCode_DropSiteOverlay].text_weak = current->colors[DF_ThemeColor_DropSiteOverlay]; - df_gfx_state->cfg_palettes[DF_PaletteCode_DropSiteOverlay].border = current->colors[DF_ThemeColor_DropSiteOverlay]; - if(df_setting_val_from_code(DF_SettingCode_OpaqueBackgrounds).s32) - { - for(EachEnumVal(DF_PaletteCode, code)) - { - if(df_gfx_state->cfg_palettes[code].background.x != 0 || - df_gfx_state->cfg_palettes[code].background.y != 0 || - df_gfx_state->cfg_palettes[code].background.z != 0) - { - df_gfx_state->cfg_palettes[code].background.w = 1; - } - } - } - } - //- rjf: animate alive-transitions for entities { F32 rate = 1.f - pow_f32(2.f, -20.f*df_dt()); diff --git a/src/df/gfx/df_gfx.h b/src/df/gfx/df_gfx.h index 94edcca0..0f54dc64 100644 --- a/src/df/gfx/df_gfx.h +++ b/src/df/gfx/df_gfx.h @@ -555,10 +555,13 @@ struct DF_Window OS_Handle os; R_Handle r; UI_State *ui; - F32 code_font_size_delta; - F32 main_font_size_delta; + F32 last_dpi; B32 window_temporarily_focused_ipc; + // rjf: config/settings + DF_SettingVal setting_vals[DF_SettingCode_COUNT]; + UI_Palette cfg_palettes[DF_PaletteCode_COUNT]; // derivative from theme + // rjf: view state delta history DF_StateDeltaHistory *view_state_hist; @@ -591,6 +594,7 @@ struct DF_Window // rjf: tab context menu state UI_Key tab_ctx_menu_key; + DF_Handle tab_ctx_menu_panel; DF_Handle tab_ctx_menu_view; // rjf: autocomplete lister state @@ -626,7 +630,6 @@ struct DF_Window Vec2F32 hover_eval_spawn_pos; String8 hover_eval_string; - // rjf: hover eval timer U64 hover_eval_first_frame_idx; U64 hover_eval_last_frame_idx; @@ -785,10 +788,9 @@ struct DF_GfxState Arena *cfg_code_font_path_arena; String8 cfg_main_font_path; String8 cfg_code_font_path; - F_Tag cfg_font_tags[DF_FontSlot_COUNT]; // derivative from font paths - UI_Palette cfg_palettes[DF_PaletteCode_COUNT]; // derivative from theme + F_Tag cfg_font_tags[DF_FontSlot_COUNT]; // derivative from font paths - // rjf: settings + // rjf: global settings DF_SettingVal cfg_setting_vals[DF_CfgSrc_COUNT][DF_SettingCode_COUNT]; // rjf: icon texture @@ -1038,14 +1040,14 @@ internal Vec4F32 df_rgba_from_theme_color(DF_ThemeColor color); internal DF_ThemeColor df_theme_color_from_txt_token_kind(TXT_TokenKind kind); //- rjf: code -> palette -internal UI_Palette *df_palette_from_code(DF_PaletteCode code); +internal UI_Palette *df_palette_from_code(DF_Window *ws, DF_PaletteCode code); //- rjf: fonts/sizes internal F_Tag df_font_from_slot(DF_FontSlot slot); internal F32 df_font_size_from_slot(DF_Window *ws, DF_FontSlot slot); //- rjf: settings -internal DF_SettingVal df_setting_val_from_code(DF_SettingCode code); +internal DF_SettingVal df_setting_val_from_code(DF_Window *optional_window, DF_SettingCode code); //- rjf: config serialization internal int df_qsort_compare__cfg_string_bindings(DF_StringBindingPair *a, DF_StringBindingPair *b); @@ -1060,18 +1062,19 @@ internal String8 df_stop_explanation_string_icon_from_ctrl_event(Arena *arena, C //////////////////////////////// //~ rjf: UI Building Helpers -#define DF_Palette(code) UI_Palette(df_palette_from_code(code)) +#define DF_Palette(ws, code) UI_Palette(df_palette_from_code((ws), (code))) //////////////////////////////// //~ rjf: UI Widgets: Fancy Buttons +internal void df_cmd_binding_buttons(DF_CmdSpec *spec); internal void df_cmd_binding_button(DF_CmdSpec *spec); internal UI_Signal df_menu_bar_button(String8 string); internal UI_Signal df_cmd_spec_button(DF_CmdSpec *spec); internal void df_cmd_list_menu_buttons(DF_Window *ws, U64 count, DF_CoreCmdKind *cmds, U32 *fastpath_codepoints); internal UI_Signal df_icon_button(DF_IconKind kind, FuzzyMatchRangeList *matches, String8 string); internal UI_Signal df_icon_buttonf(DF_IconKind kind, FuzzyMatchRangeList *matches, char *fmt, ...); -internal void df_entity_tooltips(DF_Entity *entity); +internal void df_entity_tooltips(DF_Window *ws, DF_Entity *entity); internal UI_Signal df_entity_desc_button(DF_Window *ws, DF_Entity *entity, FuzzyMatchRangeList *name_matches, String8 fuzzy_query, B32 is_implicit); internal void df_entity_src_loc_button(DF_Window *ws, DF_Entity *entity, TxtPt point); diff --git a/src/df/gfx/df_gfx.mdesk b/src/df/gfx/df_gfx.mdesk index 4426bd48..dec7153e 100644 --- a/src/df/gfx/df_gfx.mdesk +++ b/src/df/gfx/df_gfx.mdesk @@ -155,6 +155,7 @@ DF_DefaultBindingTable: //- rjf: watch expressions { "toggle_watch_expr_at_cursor" W 0 0 alt } + { "toggle_watch_expr_at_mouse" D ctrl 0 0 } { "toggle_watch_pin_at_cursor" F9 ctrl 0 0 } //- rjf: breakpoints @@ -548,22 +549,28 @@ DF_ThemeColorVersionRemapTable: //////////////////////////////// //~ rjf: Settings -@table(name name_lower display_string default_s32 s32_min s32_max) +@table(name name_lower display_string default_per_window default_s32 s32_min s32_max) DF_SettingTable: { - {HoverAnimations hover_animations "Hover Animations" 1 0 1 } - {PressAnimations press_animations "Press Animations" 1 0 1 } - {FocusAnimations focus_animations "Focus Animations" 1 0 1 } - {TooltipAnimations tooltip_animations "Tooltip Animations" 1 0 1 } - {MenuAnimations menu_animations "Menu Animations" 1 0 1 } - {ScrollingAnimations scrolling_animations "Scrolling Animations" 1 0 1 } - {BackgroundBlur background_blur "Background Blur" 1 0 1 } - {ThreadLines thread_lines "Thread Lines" 1 0 1 } - {BreakpointLines breakpoint_lines "Breakpoint Lines" 1 0 1 } - {ThreadGlow thread_glow "Thread Glow" 1 0 1 } - {BreakpointGlow breakpoint_glow "Breakpoint Glow" 1 0 1 } - {OpaqueBackgrounds opaque_backgrounds "Opaque Backgrounds" 0 0 1 } - {TabWidth tab_width "Tab Width" 4 1 32 } + {HoverAnimations hover_animations "Hover Animations" 0 1 0 1 } + {PressAnimations press_animations "Press Animations" 0 1 0 1 } + {FocusAnimations focus_animations "Focus Animations" 0 1 0 1 } + {TooltipAnimations tooltip_animations "Tooltip Animations" 0 1 0 1 } + {MenuAnimations menu_animations "Menu Animations" 0 1 0 1 } + {ScrollingAnimations scrolling_animations "Scrolling Animations" 0 1 0 1 } + {BackgroundBlur background_blur "Background Blur" 0 1 0 1 } + {ThreadLines thread_lines "Thread Lines" 0 1 0 1 } + {BreakpointLines breakpoint_lines "Breakpoint Lines" 0 1 0 1 } + {ThreadGlow thread_glow "Thread Glow" 0 1 0 1 } + {BreakpointGlow breakpoint_glow "Breakpoint Glow" 0 1 0 1 } + {OpaqueBackgrounds opaque_backgrounds "Opaque Backgrounds" 0 0 0 1 } + {TabWidth tab_width "Tab Width" 0 4 1 32 } + {MainFontSize main_font_size "Main Font Size" 1 12 6 72 } + {CodeFontSize code_font_size "Code Font Size" 1 12 6 72 } + {SmoothUIText smooth_ui_text "Smooth UI Text" 1 1 0 1 } + {SmoothCodeText smooth_code_text "Smooth Code Text" 1 0 0 1 } + {HintUIText hint_ui_text "Hint UI Text" 1 1 0 1 } + {HintCodeText hint_code_text "Hint Code Text" 1 1 0 1 } } @enum DF_SettingCode: @@ -582,6 +589,11 @@ DF_SettingTable: @expand(DF_SettingTable a) `str8_lit_comp("$(a.name_lower)")` } +@data(B8) df_g_setting_code_default_is_per_window_table: +{ + @expand(DF_SettingTable a) `$(a.default_per_window)` +} + @data(DF_SettingVal) df_g_setting_code_default_val_table: { @expand(DF_SettingTable a) `{1, $(a.default_s32)}` diff --git a/src/df/gfx/df_view_rules.c b/src/df/gfx/df_view_rules.c index 92c6ce61..2a09e772 100644 --- a/src/df/gfx/df_view_rules.c +++ b/src/df/gfx/df_view_rules.c @@ -39,6 +39,14 @@ DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_DEF(array) return eval; } +//////////////////////////////// +//~ rjf: "slice" + +DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_DEF(slice) +{ + return eval; +} + //////////////////////////////// //~ rjf: "list" @@ -459,8 +467,7 @@ df_view_rule_hooks__disasm_topology_info_from_cfg(DI_Scope *scope, DF_CtrlCtx *c } //////////////////////////////// -//~ bill: "slice" - +//~ bill: "slice" (odin-lang) internal TG_Member *tg_member_from_name(TG_MemberArray array, String8 name, StringMatchFlags flags) { @@ -489,7 +496,7 @@ internal U64 df_evaluate_integer_from_eval(EVAL_ParseCtx *parse_ctx, DF_CtrlCtx return 0; } -DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_DEF(slice) +DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_DEF(odin_slice) { TG_Key type_key = eval.type_key; TG_Kind type_kind = tg_kind_from_key(type_key); @@ -1137,7 +1144,7 @@ DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(text) } code_slice_params.font = df_font_from_slot(DF_FontSlot_Code); code_slice_params.font_size = ui_top_font_size(); - code_slice_params.tab_size = f_column_size_from_tag_size(code_slice_params.font, code_slice_params.font_size)*df_setting_val_from_code(DF_SettingCode_TabWidth).s32; + code_slice_params.tab_size = f_column_size_from_tag_size(code_slice_params.font, code_slice_params.font_size)*df_setting_val_from_code(ws, DF_SettingCode_TabWidth).s32; code_slice_params.line_height_px = ui_top_font_size()*1.5f; code_slice_params.priority_margin_width_px = 0; code_slice_params.catchall_margin_width_px = 0; @@ -1300,7 +1307,7 @@ DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(disasm) } code_slice_params.font = df_font_from_slot(DF_FontSlot_Code); code_slice_params.font_size = ui_top_font_size(); - code_slice_params.tab_size = f_column_size_from_tag_size(code_slice_params.font, code_slice_params.font_size)*df_setting_val_from_code(DF_SettingCode_TabWidth).s32; + code_slice_params.tab_size = f_column_size_from_tag_size(code_slice_params.font, code_slice_params.font_size)*df_setting_val_from_code(ws, DF_SettingCode_TabWidth).s32; code_slice_params.line_height_px = ui_top_font_size()*1.5f; code_slice_params.priority_margin_width_px = 0; code_slice_params.catchall_margin_width_px = 0; diff --git a/src/df/gfx/df_views.c b/src/df/gfx/df_views.c index 1071476a..8f1ae273 100644 --- a/src/df/gfx/df_views.c +++ b/src/df/gfx/df_views.c @@ -450,6 +450,10 @@ df_code_view_cmds(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewStat arena_clear(cv->find_text_arena); cv->find_text_bwd = push_str8_copy(cv->find_text_arena, cmd->params.string); }break; + case DF_CoreCmdKind_ToggleWatchExpressionAtMouse: + { + cv->watch_expr_at_mouse = 1; + }break; } } } @@ -469,7 +473,7 @@ df_code_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewSta DF_CtrlCtx ctrl_ctx = df_ctrl_ctx_from_view(ws, view); F_Tag code_font = df_font_from_slot(DF_FontSlot_Code); F32 code_font_size = df_font_size_from_slot(ws, DF_FontSlot_Code); - F32 code_tab_size = f_column_size_from_tag_size(code_font, code_font_size)*df_setting_val_from_code(DF_SettingCode_TabWidth).s32; + F32 code_tab_size = f_column_size_from_tag_size(code_font, code_font_size)*df_setting_val_from_code(ws, DF_SettingCode_TabWidth).s32; F_Metrics code_font_metrics = f_metrics_from_tag_size(code_font, code_font_size); F32 code_line_height = ceil_f32(f_line_height_from_metrics(&code_font_metrics) * 1.5f); F32 big_glyph_advance = f_dim_from_tag_size_string(code_font, code_font_size, 0, 0, str8_lit("H")).x; @@ -974,6 +978,16 @@ df_code_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewSta df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_GoToName)); } + //- rjf: watch expr at mouse + if(cv->watch_expr_at_mouse) + { + cv->watch_expr_at_mouse = 0; + DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); + params.string = txt_string_from_info_data_txt_rng(text_info, text_data, sig.mouse_expr_rng); + df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_String); + df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ToggleWatchExpression)); + } + //- rjf: selected text on single line, no query? -> set search text if(!txt_pt_match(view->cursor, view->mark) && view->cursor.line == view->mark.line && search_query.size == 0) { @@ -2951,7 +2965,7 @@ DF_VIEW_UI_FUNCTION_DEF(Empty) UI_TextAlignment(UI_TextAlign_Center) UI_PrefWidth(ui_em(15.f, 1.f)) UI_CornerRadius(ui_top_font_size()/2.f) - DF_Palette(DF_PaletteCode_NegativePopButton) + DF_Palette(ws, DF_PaletteCode_NegativePopButton) { if(ui_clicked(df_icon_buttonf(DF_IconKind_X, 0, "Close Panel"))) { @@ -3025,7 +3039,7 @@ DF_VIEW_UI_FUNCTION_DEF(GettingStarted) UI_TextAlignment(UI_TextAlign_Center) UI_PrefWidth(ui_em(22.f, 1.f)) UI_CornerRadius(ui_top_font_size()/2.f) - DF_Palette(DF_PaletteCode_NeutralPopButton) + DF_Palette(ws, DF_PaletteCode_NeutralPopButton) if(ui_clicked(df_icon_buttonf(DF_IconKind_Add, 0, "Add Target"))) { DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); @@ -3047,7 +3061,7 @@ DF_VIEW_UI_FUNCTION_DEF(GettingStarted) UI_TextAlignment(UI_TextAlign_Center) UI_PrefWidth(ui_em(22.f, 1.f)) UI_CornerRadius(ui_top_font_size()/2.f) - DF_Palette(DF_PaletteCode_PositivePopButton) + DF_Palette(ws, DF_PaletteCode_PositivePopButton) { if(ui_clicked(df_icon_buttonf(DF_IconKind_Play, 0, "Launch %S", target_name))) { @@ -3094,7 +3108,7 @@ DF_VIEW_UI_FUNCTION_DEF(GettingStarted) { ui_labelf("use"); DF_CmdSpec *spec = df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_RunCommand); - UI_Flags(UI_BoxFlag_DrawBorder) UI_TextAlignment(UI_TextAlign_Center) df_cmd_binding_button(spec); + UI_Flags(UI_BoxFlag_DrawBorder) UI_TextAlignment(UI_TextAlign_Center) df_cmd_binding_buttons(spec); ui_labelf("to open command menu"); } } @@ -3202,7 +3216,7 @@ DF_VIEW_UI_FUNCTION_DEF(Commands) UI_Column UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_HeightFill UI_TextAlignment(UI_TextAlign_Center) @@ -3234,10 +3248,15 @@ DF_VIEW_UI_FUNCTION_DEF(Commands) ui_box_equip_fuzzy_match_ranges(desc_box, &item->desc_match_ranges); } - //- rjf: binding - UI_PrefWidth(ui_pct(0.15f, 1.f)) UI_HeightFill UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) + //- rjf: bindings + 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_em(1.5f, 1.f)) { - df_cmd_binding_button(item->cmd_spec); + ui_set_next_flags(UI_BoxFlag_Clickable); + UI_NamedRow(str8_lit("binding_row")) UI_Padding(ui_em(1.f, 1.f)) + { + df_cmd_binding_buttons(item->cmd_spec); + } } } @@ -3596,7 +3615,7 @@ DF_VIEW_UI_FUNCTION_DEF(FileSystem) // rjf: icons UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_PrefWidth(ui_em(3.f, 1.f)) UI_TextAlignment(UI_TextAlign_Center) { @@ -3645,7 +3664,7 @@ DF_VIEW_UI_FUNCTION_DEF(FileSystem) // rjf: icon to signify directory UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_PrefWidth(ui_em(3.f, 1.f)) UI_TextAlignment(UI_TextAlign_Center) { @@ -3834,7 +3853,7 @@ DF_VIEW_UI_FUNCTION_DEF(SystemProcesses) // rjf: icon UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_PrefWidth(ui_em(3.f, 1.f)) UI_TextAlignment(UI_TextAlign_Center) { @@ -4008,7 +4027,7 @@ DF_VIEW_UI_FUNCTION_DEF(EntityLister) UI_TextAlignment(UI_TextAlign_Center) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_text_dim(10, 1)) ui_label(df_g_icon_kind_text_table[icon_kind]); @@ -5531,11 +5550,11 @@ DF_VIEW_UI_FUNCTION_DEF(Scheduler) UI_Palette *palette = ui_top_palette(); if(frozen) { - palette = df_palette_from_code(DF_PaletteCode_NegativePopButton); + palette = df_palette_from_code(ws, DF_PaletteCode_NegativePopButton); } else { - palette = df_palette_from_code(DF_PaletteCode_PositivePopButton); + palette = df_palette_from_code(ws, DF_PaletteCode_PositivePopButton); } UI_Signal sig = {0}; UI_Palette(palette) sig = df_icon_buttonf(frozen ? DF_IconKind_Locked : DF_IconKind_Unlocked, 0, "###lock_%p", entity); @@ -5588,7 +5607,7 @@ DF_VIEW_UI_FUNCTION_DEF(Scheduler) } UI_TableCellSized(ui_em(2.25f, 1.f)) UI_FocusHot((row_is_selected && cursor.x == 4) ? UI_FocusKind_On : UI_FocusKind_Off) { - DF_Palette(DF_PaletteCode_NegativePopButton) + DF_Palette(ws, DF_PaletteCode_NegativePopButton) if(ui_clicked(df_icon_buttonf(DF_IconKind_X, 0, "###kill"))) { DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); @@ -5763,7 +5782,7 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack) UI_TableCell UI_Font(df_font_from_slot(DF_FontSlot_Icons)) UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_WidthFill UI_TextAlignment(UI_TextAlign_Center) UI_FocusHot((row_selected && cs->cursor.x == 0) ? UI_FocusKind_On : UI_FocusKind_Off) @@ -6490,7 +6509,7 @@ DF_VIEW_UI_FUNCTION_DEF(Code) UI_Palette(ui_build_palette(ui_top_palette(), .text = df_rgba_from_theme_color(DF_ThemeColor_TextNegative))) { UI_Font(df_font_from_slot(DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) ui_label(df_g_icon_kind_text_table[DF_IconKind_WarningBig]); ui_labelf("Could not find \"%S\".", full_path); } @@ -6500,7 +6519,7 @@ DF_VIEW_UI_FUNCTION_DEF(Code) UI_CornerRadius(ui_top_font_size()/3) UI_PrefWidth(ui_text_dim(10, 1)) UI_Focus(UI_FocusKind_On) - DF_Palette(DF_PaletteCode_NeutralPopButton) + DF_Palette(ws, DF_PaletteCode_NeutralPopButton) if(ui_clicked(ui_buttonf("Find alternative..."))) { DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); @@ -6553,7 +6572,7 @@ DF_VIEW_UI_FUNCTION_DEF(Code) UI_Box *box = &ui_g_nil_box; UI_Palette(ui_build_palette(ui_top_palette(), .text = df_rgba_from_theme_color(DF_ThemeColor_TextNegative))) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) { box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_Clickable, "%S###file_ood_warning", df_g_icon_kind_text_table[DF_IconKind_WarningBig]); } @@ -8490,7 +8509,7 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) DF_ThemeColor color_ctx_menu_color; Vec4F32 color_ctx_menu_color_hsva; DF_ThemePreset preset_apply_confirm; - B32 category_collapsed[DF_SettingsItemKind_COUNT]; + B32 category_opened[DF_SettingsItemKind_COUNT]; }; DF_SettingsViewState *sv = df_view_user_state(view, DF_SettingsViewState); if(!sv->initialized) @@ -8506,24 +8525,28 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) { DF_SettingsItemList items_list = {0}; - //- rjf: settings header + //- rjf: global settings header if(query.size == 0) { DF_SettingsItemNode *n = push_array(scratch.arena, DF_SettingsItemNode, 1); SLLQueuePush(items_list.first, items_list.last, n); items_list.count += 1; n->v.kind = DF_SettingsItemKind_CategoryHeader; - n->v.string = str8_lit("Interface Settings"); - n->v.icon_kind = sv->category_collapsed[DF_SettingsItemKind_Setting] ? DF_IconKind_RightCaret : DF_IconKind_DownCaret; - n->v.category = DF_SettingsItemKind_Setting; + n->v.string = str8_lit("Global Interface Settings"); + n->v.icon_kind = sv->category_opened[DF_SettingsItemKind_GlobalSetting] ? DF_IconKind_DownCaret : DF_IconKind_RightCaret; + n->v.category = DF_SettingsItemKind_GlobalSetting; } - //- rjf: gather all settings - if(!sv->category_collapsed[DF_SettingsItemKind_Setting] || query.size != 0) + //- rjf: gather all global settings + if(sv->category_opened[DF_SettingsItemKind_GlobalSetting] || query.size != 0) { for(EachEnumVal(DF_SettingCode, code)) { - String8 kind_string = str8_lit("Interface"); + if(df_g_setting_code_default_is_per_window_table[code]) + { + continue; + } + String8 kind_string = str8_lit("Global Interface Setting"); String8 string = df_g_setting_code_display_string_table[code]; FuzzyMatchRangeList kind_string_matches = fuzzy_match_find(scratch.arena, query, kind_string); FuzzyMatchRangeList string_matches = fuzzy_match_find(scratch.arena, query, string); @@ -8533,7 +8556,49 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) DF_SettingsItemNode *n = push_array(scratch.arena, DF_SettingsItemNode, 1); SLLQueuePush(items_list.first, items_list.last, n); items_list.count += 1; - n->v.kind = DF_SettingsItemKind_Setting; + n->v.kind = DF_SettingsItemKind_GlobalSetting; + n->v.kind_string = kind_string; + n->v.string = string; + n->v.kind_string_matches = kind_string_matches; + n->v.string_matches = string_matches; + n->v.icon_kind = DF_IconKind_Window; + n->v.code = code; + } + } + } + + //- rjf: window settings header + if(query.size == 0) + { + DF_SettingsItemNode *n = push_array(scratch.arena, DF_SettingsItemNode, 1); + SLLQueuePush(items_list.first, items_list.last, n); + items_list.count += 1; + n->v.kind = DF_SettingsItemKind_CategoryHeader; + n->v.string = str8_lit("Window Interface Settings"); + n->v.icon_kind = sv->category_opened[DF_SettingsItemKind_WindowSetting] ? DF_IconKind_DownCaret : DF_IconKind_RightCaret; + n->v.category = DF_SettingsItemKind_WindowSetting; + } + + //- rjf: gather all window settings + if(sv->category_opened[DF_SettingsItemKind_WindowSetting] || query.size != 0) + { + for(EachEnumVal(DF_SettingCode, code)) + { + if(!df_g_setting_code_default_is_per_window_table[code]) + { + continue; + } + String8 kind_string = str8_lit("Window Interface Setting"); + String8 string = df_g_setting_code_display_string_table[code]; + FuzzyMatchRangeList kind_string_matches = fuzzy_match_find(scratch.arena, query, kind_string); + FuzzyMatchRangeList string_matches = fuzzy_match_find(scratch.arena, query, string); + if(string_matches.count == string_matches.needle_part_count || + kind_string_matches.count == kind_string_matches.needle_part_count) + { + DF_SettingsItemNode *n = push_array(scratch.arena, DF_SettingsItemNode, 1); + SLLQueuePush(items_list.first, items_list.last, n); + items_list.count += 1; + n->v.kind = DF_SettingsItemKind_WindowSetting; n->v.kind_string = kind_string; n->v.string = string; n->v.kind_string_matches = kind_string_matches; @@ -8552,12 +8617,12 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) items_list.count += 1; n->v.kind = DF_SettingsItemKind_CategoryHeader; n->v.string = str8_lit("Theme Presets"); - n->v.icon_kind = sv->category_collapsed[DF_SettingsItemKind_ThemePreset] ? DF_IconKind_RightCaret : DF_IconKind_DownCaret; + n->v.icon_kind = sv->category_opened[DF_SettingsItemKind_ThemePreset] ? DF_IconKind_DownCaret : DF_IconKind_RightCaret; n->v.category = DF_SettingsItemKind_ThemePreset; } //- rjf: gather theme presets - if(!sv->category_collapsed[DF_SettingsItemKind_ThemePreset] || query.size != 0) + if(sv->category_opened[DF_SettingsItemKind_ThemePreset] || query.size != 0) { for(EachEnumVal(DF_ThemePreset, preset)) { @@ -8590,12 +8655,12 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) items_list.count += 1; n->v.kind = DF_SettingsItemKind_CategoryHeader; n->v.string = str8_lit("Theme Colors"); - n->v.icon_kind = sv->category_collapsed[DF_SettingsItemKind_ThemeColor] ? DF_IconKind_RightCaret : DF_IconKind_DownCaret; + n->v.icon_kind = sv->category_opened[DF_SettingsItemKind_ThemeColor] ? DF_IconKind_DownCaret : DF_IconKind_RightCaret; n->v.category = DF_SettingsItemKind_ThemeColor; } //- rjf: gather all theme colors - if(!sv->category_collapsed[DF_SettingsItemKind_ThemeColor] || query.size != 0) + if(sv->category_opened[DF_SettingsItemKind_ThemeColor] || query.size != 0) { for(EachNonZeroEnumVal(DF_ThemeColor, color)) { @@ -8660,7 +8725,7 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) color < DF_ThemeColor_COUNT; color = (DF_ThemeColor)(color+1)) { - DF_Palette(DF_PaletteCode_Floating) + DF_Palette(ws, DF_PaletteCode_Floating) UI_CtxMenu(color_ctx_menu_keys[color]) UI_Padding(ui_em(1.5f, 1.f)) UI_PrefWidth(ui_em(28.5f, 1)) UI_PrefHeight(ui_children_sum(1.f)) @@ -8864,6 +8929,7 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) S32 slider_s32_val = 0; F32 slider_pct = 0.f; UI_BoxFlags flags = UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawHotEffects|UI_BoxFlag_DrawActiveEffects; + DF_SettingVal *val_table = &df_gfx_state->cfg_setting_vals[DF_CfgSrc_User][0]; switch(item->kind) { case DF_SettingsItemKind_COUNT:{}break; @@ -8889,20 +8955,22 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) { rgba = df_rgba_from_theme_color(item->color); }break; - case DF_SettingsItemKind_Setting: + case DF_SettingsItemKind_WindowSetting: {val_table = &ws->setting_vals[0];}goto setting; + case DF_SettingsItemKind_GlobalSetting:{}goto setting; + setting:; { s32_range = df_g_setting_code_s32_range_table[item->code]; if(s32_range.min != 0 || s32_range.max != 1) { cursor = OS_Cursor_LeftRight; is_slider = 1; - slider_s32_val = df_setting_val_from_code(item->code).s32; + slider_s32_val = val_table[item->code].s32; slider_pct = (F32)(slider_s32_val - s32_range.min) / dim_1s32(s32_range); } else { is_toggler = 1; - is_toggled = !!df_setting_val_from_code(item->code).s32; + is_toggled = !!val_table[item->code].s32; } }break; } @@ -8926,11 +8994,11 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) { UI_PrefWidth(ui_em(2.f, 1.f)) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_Palette(ui_build_palette(ui_top_palette(), .text = rgba)) ui_label(df_g_icon_kind_text_table[item->icon_kind]); } - if(item->kind_string.size != 0) UI_PrefWidth(ui_text_dim(10, 1)) + if(query.size != 0 && item->kind_string.size != 0) UI_PrefWidth(ui_text_dim(10, 1)) { UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DrawTextWeak, "%S", item->kind_string); ui_box_equip_fuzzy_match_ranges(box, &item->kind_string_matches); @@ -8942,9 +9010,7 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) } if(is_slider) UI_PrefWidth(ui_text_dim(10, 1)) { - UI_Font(df_font_from_slot(DF_FontSlot_Code)) - UI_RunFlags(F_RunFlag_Smooth) - UI_Flags(UI_BoxFlag_DrawTextWeak) + UI_Flags(UI_BoxFlag_DrawTextWeak) ui_labelf("(%i)", slider_s32_val); UI_PrefWidth(ui_pct(slider_pct, 1.f)) UI_HeightFill UI_FixedX(0) UI_FixedY(0) UI_Palette(ui_build_palette(ui_top_palette(), .background = df_rgba_from_theme_color(DF_ThemeColor_HighlightOverlay))) @@ -8955,7 +9021,7 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) ui_spacer(ui_pct(1, 0)); UI_PrefWidth(ui_em(2.5f, 1.f)) UI_Font(df_font_from_slot(DF_FontSlot_Icons)) - UI_RunFlags(F_RunFlag_Smooth) + UI_TextRasterFlags(F_RasterFlag_Smooth) UI_Flags(UI_BoxFlag_DrawTextWeak) ui_label(df_g_icon_kind_text_table[is_toggled ? DF_IconKind_CheckFilled : DF_IconKind_CheckHollow]); } @@ -8963,7 +9029,7 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) { ui_spacer(ui_pct(1, 0)); UI_PrefWidth(ui_text_dim(10, 1)) - DF_Palette(DF_PaletteCode_NegativePopButton) + DF_Palette(ws, DF_PaletteCode_NegativePopButton) UI_CornerRadius(ui_top_font_size()*0.5f) UI_FontSize(ui_top_font_size()*0.9f) ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DrawBackground, "Click Again To Apply"); @@ -8985,12 +9051,14 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) DF_CmdParams p = df_cmd_params_from_panel(ws, panel); df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel)); } - if(item->kind == DF_SettingsItemKind_Setting && is_toggler && ui_clicked(sig)) + if((item->kind == DF_SettingsItemKind_GlobalSetting || item->kind == DF_SettingsItemKind_WindowSetting) && + is_toggler && ui_clicked(sig)) { - df_gfx_state->cfg_setting_vals[DF_CfgSrc_User][item->code].s32 ^= 1; - df_gfx_state->cfg_setting_vals[DF_CfgSrc_User][item->code].set = 1; + val_table[item->code].s32 ^= 1; + val_table[item->code].set = 1; } - if(item->kind == DF_SettingsItemKind_Setting && is_slider && ui_dragging(sig)) + if((item->kind == DF_SettingsItemKind_GlobalSetting || item->kind == DF_SettingsItemKind_WindowSetting) && + is_slider && ui_dragging(sig)) { if(ui_pressed(sig)) { @@ -9000,8 +9068,8 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) Vec2F32 delta = ui_drag_delta(); S32 pst_drag_val = pre_drag_val + (S32)(delta.x/(ui_top_font_size()*2.f)); pst_drag_val = clamp_1s32(s32_range, pst_drag_val); - df_gfx_state->cfg_setting_vals[DF_CfgSrc_User][item->code].s32 = pst_drag_val; - df_gfx_state->cfg_setting_vals[DF_CfgSrc_User][item->code].set = 1; + val_table[item->code].s32 = pst_drag_val; + val_table[item->code].set = 1; } if(item->kind == DF_SettingsItemKind_ThemePreset && ui_clicked(sig)) { @@ -9026,7 +9094,7 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) } if(item->kind == DF_SettingsItemKind_CategoryHeader && ui_pressed(sig)) { - sv->category_collapsed[item->category] ^= 1; + sv->category_opened[item->category] ^= 1; } } } @@ -9056,7 +9124,7 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) //- rjf: build preset ctx menu UI_Key preset_ctx_menu_key = ui_key_from_stringf(ui_key_zero(), "%p_preset_ctx_menu", view); - DF_Palette(DF_PaletteCode_Floating) UI_CtxMenu(preset_ctx_menu_key) UI_PrefWidth(ui_em(30.f, 1.f)) + DF_Palette(ws, DF_PaletteCode_Floating) UI_CtxMenu(preset_ctx_menu_key) UI_PrefWidth(ui_em(30.f, 1.f)) { for(DF_ThemePreset preset = (DF_ThemePreset)0; preset < DF_ThemePreset_COUNT; @@ -9092,7 +9160,7 @@ DF_VIEW_UI_FUNCTION_DEF(Settings) color < DF_ThemeColor_COUNT; color = (DF_ThemeColor)(color+1)) { - DF_Palette(DF_PaletteCode_Floating) + DF_Palette(ws, DF_PaletteCode_Floating) UI_CtxMenu(color_ctx_menu_keys[color]) UI_Padding(ui_em(1.5f, 1.f)) UI_PrefWidth(ui_em(28.5f, 1)) UI_PrefHeight(ui_children_sum(1.f)) diff --git a/src/df/gfx/df_views.h b/src/df/gfx/df_views.h index 88e7ed5e..02440d89 100644 --- a/src/df/gfx/df_views.h +++ b/src/df/gfx/df_views.h @@ -388,6 +388,7 @@ struct DF_CodeViewState S64 goto_line_num; B32 center_cursor; B32 contain_cursor; + B32 watch_expr_at_mouse; Arena *find_text_arena; String8 find_text_fwd; String8 find_text_bwd; @@ -440,7 +441,8 @@ struct DF_MemoryViewState typedef enum DF_SettingsItemKind { DF_SettingsItemKind_CategoryHeader, - DF_SettingsItemKind_Setting, + DF_SettingsItemKind_GlobalSetting, + DF_SettingsItemKind_WindowSetting, DF_SettingsItemKind_ThemeColor, DF_SettingsItemKind_ThemePreset, DF_SettingsItemKind_COUNT diff --git a/src/df/gfx/generated/df_gfx.meta.c b/src/df/gfx/generated/df_gfx.meta.c index 271dc359..6698cbe2 100644 --- a/src/df/gfx/generated/df_gfx.meta.c +++ b/src/df/gfx/generated/df_gfx.meta.c @@ -4,7 +4,7 @@ //- GENERATED CODE C_LINKAGE_BEGIN -DF_StringBindingPair df_g_default_binding_table[105] = +DF_StringBindingPair df_g_default_binding_table[106] = { {str8_lit_comp("kill_all"), {OS_Key_F5, 0 |OS_EventFlag_Shift }}, {str8_lit_comp("step_into_inst"), {OS_Key_F11, 0 |OS_EventFlag_Alt}}, @@ -104,6 +104,7 @@ DF_StringBindingPair df_g_default_binding_table[105] = {str8_lit_comp("goto_name"), {OS_Key_J, 0 |OS_EventFlag_Ctrl }}, {str8_lit_comp("goto_name_at_cursor"), {OS_Key_F12, 0 }}, {str8_lit_comp("toggle_watch_expr_at_cursor"), {OS_Key_W, 0 |OS_EventFlag_Alt}}, +{str8_lit_comp("toggle_watch_expr_at_mouse"), {OS_Key_D, 0 |OS_EventFlag_Ctrl }}, {str8_lit_comp("toggle_watch_pin_at_cursor"), {OS_Key_F9, 0 |OS_EventFlag_Ctrl }}, {str8_lit_comp("toggle_breakpoint_cursor"), {OS_Key_F9, 0 }}, {str8_lit_comp("add_target"), {OS_Key_T, 0 |OS_EventFlag_Ctrl }}, @@ -1188,7 +1189,7 @@ str8_lit_comp("thread_error"), str8_lit_comp("breakpoint"), }; -String8 df_g_setting_code_display_string_table[13] = +String8 df_g_setting_code_display_string_table[19] = { str8_lit_comp("Hover Animations"), str8_lit_comp("Press Animations"), @@ -1203,9 +1204,15 @@ str8_lit_comp("Thread Glow"), str8_lit_comp("Breakpoint Glow"), str8_lit_comp("Opaque Backgrounds"), str8_lit_comp("Tab Width"), +str8_lit_comp("Main Font Size"), +str8_lit_comp("Code Font Size"), +str8_lit_comp("Smooth UI Text"), +str8_lit_comp("Smooth Code Text"), +str8_lit_comp("Hint UI Text"), +str8_lit_comp("Hint Code Text"), }; -String8 df_g_setting_code_lower_string_table[13] = +String8 df_g_setting_code_lower_string_table[19] = { str8_lit_comp("hover_animations"), str8_lit_comp("press_animations"), @@ -1220,9 +1227,38 @@ str8_lit_comp("thread_glow"), str8_lit_comp("breakpoint_glow"), str8_lit_comp("opaque_backgrounds"), str8_lit_comp("tab_width"), +str8_lit_comp("main_font_size"), +str8_lit_comp("code_font_size"), +str8_lit_comp("smooth_ui_text"), +str8_lit_comp("smooth_code_text"), +str8_lit_comp("hint_ui_text"), +str8_lit_comp("hint_code_text"), }; -DF_SettingVal df_g_setting_code_default_val_table[13] = +B8 df_g_setting_code_default_is_per_window_table[19] = +{ +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +1, +1, +1, +1, +1, +1, +}; + +DF_SettingVal df_g_setting_code_default_val_table[19] = { {1, 1}, {1, 1}, @@ -1237,9 +1273,15 @@ DF_SettingVal df_g_setting_code_default_val_table[13] = {1, 1}, {1, 0}, {1, 4}, +{1, 12}, +{1, 12}, +{1, 1}, +{1, 0}, +{1, 1}, +{1, 1}, }; -Rng1S32 df_g_setting_code_s32_range_table[13] = +Rng1S32 df_g_setting_code_s32_range_table[19] = { {0, 1}, {0, 1}, @@ -1254,6 +1296,12 @@ Rng1S32 df_g_setting_code_s32_range_table[13] = {0, 1}, {0, 1}, {1, 32}, +{6, 72}, +{6, 72}, +{0, 1}, +{0, 1}, +{0, 1}, +{0, 1}, }; C_LINKAGE_END diff --git a/src/df/gfx/generated/df_gfx.meta.h b/src/df/gfx/generated/df_gfx.meta.h index b8f23ae9..7852f72f 100644 --- a/src/df/gfx/generated/df_gfx.meta.h +++ b/src/df/gfx/generated/df_gfx.meta.h @@ -151,6 +151,12 @@ DF_SettingCode_ThreadGlow, DF_SettingCode_BreakpointGlow, DF_SettingCode_OpaqueBackgrounds, DF_SettingCode_TabWidth, +DF_SettingCode_MainFontSize, +DF_SettingCode_CodeFontSize, +DF_SettingCode_SmoothUIText, +DF_SettingCode_SmoothCodeText, +DF_SettingCode_HintUIText, +DF_SettingCode_HintCodeText, DF_SettingCode_COUNT, } DF_SettingCode; @@ -320,7 +326,7 @@ DF_VIEW_UI_FUNCTION_DEF(bitmap); DF_VIEW_UI_FUNCTION_DEF(odin_map); DF_VIEW_UI_FUNCTION_DEF(geo); C_LINKAGE_BEGIN -extern DF_StringBindingPair df_g_default_binding_table[105]; +extern DF_StringBindingPair df_g_default_binding_table[106]; extern String8 df_g_binding_version_remap_old_name_table[5]; extern String8 df_g_binding_version_remap_new_name_table[5]; extern DF_ViewSpecInfo df_g_gfx_view_kind_spec_info_table[31]; @@ -343,10 +349,11 @@ extern Vec4F32 df_g_theme_preset_colors__far_manager[75]; extern Vec4F32* df_g_theme_preset_colors_table[9]; extern String8 df_g_theme_color_display_string_table[75]; extern String8 df_g_theme_color_cfg_string_table[75]; -extern String8 df_g_setting_code_display_string_table[13]; -extern String8 df_g_setting_code_lower_string_table[13]; -extern DF_SettingVal df_g_setting_code_default_val_table[13]; -extern Rng1S32 df_g_setting_code_s32_range_table[13]; +extern String8 df_g_setting_code_display_string_table[19]; +extern String8 df_g_setting_code_lower_string_table[19]; +extern B8 df_g_setting_code_default_is_per_window_table[19]; +extern DF_SettingVal df_g_setting_code_default_val_table[19]; +extern Rng1S32 df_g_setting_code_s32_range_table[19]; read_only global U8 df_g_icon_font_bytes__data[] = { 0x00,0x01,0x00,0x00,0x00,0x0f,0x00,0x80,0x00,0x03,0x00,0x70,0x47,0x53,0x55,0x42,0x20,0x8b,0x25,0x7a,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x54,0x4f,0x53,0x2f,0x32,0x56,0x44,0x49,0xa0,0x00,0x00,0x01,0x50,0x00,0x00,0x00,0x60,0x63,0x6d,0x61,0x70,0x2a,0x09,0xe2,0xc2,0x00,0x00,0x01,0xb0,0x00,0x00,0x05,0xec,0x63,0x76,0x74,0x20, diff --git a/src/draw/draw.c b/src/draw/draw.c index 222ed34e..3768bc88 100644 --- a/src/draw/draw.c +++ b/src/draw/draw.c @@ -87,7 +87,7 @@ d_string_from_fancy_string_list(Arena *arena, D_FancyStringList *list) } internal D_FancyRunList -d_fancy_run_list_from_fancy_string_list(Arena *arena, F32 tab_size_px, F_RunFlags flags, D_FancyStringList *strs) +d_fancy_run_list_from_fancy_string_list(Arena *arena, F32 tab_size_px, F_RasterFlags flags, D_FancyStringList *strs) { ProfBeginFunction(); D_FancyRunList run_list = {0}; @@ -104,11 +104,6 @@ d_fancy_run_list_from_fancy_string_list(Arena *arena, F32 tab_size_px, F_RunFlag run_list.dim.x += dst_n->v.run.dim.x; run_list.dim.y = Max(run_list.dim.y, dst_n->v.run.dim.y); base_align_px += dst_n->v.run.dim.x; - if(n->next != 0) - { - run_list.dim.x -= dst_n->v.run.end_pad; - base_align_px -= dst_n->v.run.end_pad; - } } ProfEnd(); return run_list; @@ -465,7 +460,7 @@ d_truncated_fancy_run_list(Vec2F32 p, D_FancyRunList *list, F32 max_x, F_Run tra ProfBeginFunction(); //- rjf: total advance > max? -> enable trailer - B32 trailer_enabled = (list->dim.x >= max_x && trailer_run.dim.x < max_x); + B32 trailer_enabled = (list->dim.x > max_x && trailer_run.dim.x < max_x); //- rjf: draw runs F32 advance = 0; @@ -483,18 +478,17 @@ d_truncated_fancy_run_list(Vec2F32 p, D_FancyRunList *list, F32 max_x, F_Run tra F_Piece *piece_first = fr->run.pieces.v; F_Piece *piece_opl = piece_first + fr->run.pieces.count; F32 pre_advance = advance; - F32 last_piece_end_pad = 0; last_color = fr->color; for(F_Piece *piece = piece_first; piece < piece_opl; piece += 1) { - if(trailer_enabled && advance + piece->advance >= (max_x - trailer_run.dim.x)) + if(trailer_enabled && advance + piece->advance > (max_x - trailer_run.dim.x)) { trailer_found = 1; break; } - if(!trailer_enabled && advance + piece->advance >= max_x) + if(!trailer_enabled && advance + piece->advance > max_x) { goto end_draw; } @@ -508,18 +502,17 @@ d_truncated_fancy_run_list(Vec2F32 p, D_FancyRunList *list, F32 max_x, F_Run tra if(!r_handle_match(texture, r_handle_zero())) { d_img(dst, src, texture, fr->color, 0, 0, 0); - //d_rect(dst, v4f32(1, 0, 0, 1), 0, 1.f, 0.f); + //d_rect(dst, v4f32(0, 1, 0, 0.5f), 0, 1.f, 0.f); } advance += piece->advance; - last_piece_end_pad = ((F32)piece->offset.x+(F32)dim_2s16(piece->subrect).x) - piece->advance; pixel_range.min = Min(pre_advance, pixel_range.min); pixel_range.max = Max(advance, pixel_range.max); } if(fr->underline_thickness > 0) { - d_rect(r2f32p(p.x + pixel_range.min + 1.f, + d_rect(r2f32p(p.x + pixel_range.min, p.y+fr->run.descent+fr->run.descent/8, - p.x + pixel_range.max + last_piece_end_pad/2, + p.x + pixel_range.max, p.y+fr->run.descent+fr->run.descent/8+fr->underline_thickness), fr->color, 0, 0, 0.8f); } @@ -591,9 +584,8 @@ d_truncated_fancy_run_fuzzy_matches(Vec2F32 p, D_FancyRunList *list, F32 max_x, F_Piece *piece = &run->pieces.v[piece_idx]; if(contains_1u64(byte_range, byte_off)) { - F32 pre_advance = advance+piece->offset.x; - F32 post_advance = advance+piece->advance; - last_piece_end_pad = ((F32)piece->offset.x+(F32)dim_2s16(piece->subrect).x) - piece->advance; + F32 pre_advance = advance + piece->offset.x; + F32 post_advance = advance + piece->advance; pixel_range.min = Min(pre_advance, pixel_range.min); pixel_range.max = Max(post_advance, pixel_range.max); } @@ -603,8 +595,10 @@ d_truncated_fancy_run_fuzzy_matches(Vec2F32 p, D_FancyRunList *list, F32 max_x, } if(pixel_range.min < pixel_range.max) { - Rng2F32 rect = r2f32p(p.x + pixel_range.min, p.y - descent - ascent, - p.x + pixel_range.max + last_piece_end_pad/2, p.y - descent - ascent + list->dim.y); + Rng2F32 rect = r2f32p(p.x + pixel_range.min - ascent/4.f, + p.y - descent - ascent - ascent/8.f, + p.x + pixel_range.max + ascent/4.f, + p.y - descent - ascent + ascent/8.f + list->dim.y); rect.x0 = Min(rect.x0, p.x+max_x); rect.x1 = Min(rect.x1, p.x+max_x); d_rect(rect, color, (descent+ascent)/4.f, 0, 1.f); @@ -638,143 +632,10 @@ d_text_run(Vec2F32 p, Vec4F32 color, F_Run run) } internal void -d_truncated_text_run(Vec2F32 p, Vec4F32 color, F32 max_x, F_Run text_run, F_Run trailer_run) -{ - B32 truncated = 0; - B32 set_truncation = 0; - F32 truncation_p = p.x; - F32 max_x_minus_ellipses = max_x - trailer_run.dim.x; - F32 available_space = max_x - p.x; - - // rjf: find last piece before truncation - B32 truncation_needed = 0; - F_Piece *last_piece_before_truncation = 0; - F32 truncation_offset = 0; - if(available_space > text_run.dim.x || available_space > trailer_run.dim.x) - { - F32 advance = 0; - F_Piece *text_run_first = text_run.pieces.v; - F_Piece *text_run_opl = text_run_first + text_run.pieces.count; - for(F_Piece *piece = text_run_first; - piece < text_run_opl; - piece += 1) - { - Rng2F32 src = r2f32p((F32)piece->subrect.x0, (F32)piece->subrect.y0, (F32)piece->subrect.x1, (F32)piece->subrect.y1); - Vec2F32 size = dim_2f32(src); - Rng2F32 dst = r2f32p(p.x + piece->offset.x + advance, - p.y + piece->offset.y, - p.x + piece->offset.x + advance + size.x, - p.y + piece->offset.y + size.y); - advance += piece->advance; - if(last_piece_before_truncation == 0 && p.x + advance > max_x_minus_ellipses) - { - truncation_offset = advance - piece->advance; - last_piece_before_truncation = piece; - } - if(p.x + advance > max_x) - { - truncation_needed = 1; - } - } - } - - // rjf: draw pieces - if(available_space > text_run.dim.x || available_space > trailer_run.dim.x) - { - F32 advance = 0; - F_Piece *text_run_first = text_run.pieces.v; - F_Piece *text_run_opl = text_run_first + text_run.pieces.count; - for(F_Piece *piece = text_run_first; - piece < text_run_opl; - piece += 1) - { - if(truncation_needed && piece == last_piece_before_truncation) - { - break; - } - R_Handle texture = piece->texture; - Rng2F32 src = r2f32p((F32)piece->subrect.x0, (F32)piece->subrect.y0, (F32)piece->subrect.x1, (F32)piece->subrect.y1); - Vec2F32 size = dim_2f32(src); - Rng2F32 dst = r2f32p(p.x + piece->offset.x + advance, - p.y + piece->offset.y, - p.x + piece->offset.x + advance + size.x, - p.y + piece->offset.y + size.y); - if(size.x != 0 && size.y != 0 && !r_handle_match(texture, r_handle_zero())) - { - d_img(dst, src, texture, color, 0, 0, 0); - } - advance += piece->advance; - } - } - - // rjf: draw truncation ellipses - if(truncation_needed && last_piece_before_truncation != 0) - { - Vec2F32 ellipses_p = {p.x + truncation_offset, p.y}; - Vec4F32 ellipses_color = color; - F32 advance = 0; - F_Piece *trailer_run_first = trailer_run.pieces.v; - F_Piece *trailer_run_opl = trailer_run_first + trailer_run.pieces.count; - for(F_Piece *piece = trailer_run_first; - piece < trailer_run_opl; - piece += 1) - { - R_Handle texture = piece->texture; - Rng2F32 src = r2f32p((F32)piece->subrect.x0, (F32)piece->subrect.y0, (F32)piece->subrect.x1, (F32)piece->subrect.y1); - Vec2F32 size = dim_2f32(src); - Rng2F32 dst = r2f32p(ellipses_p.x + piece->offset.x + advance, - ellipses_p.y + piece->offset.y, - ellipses_p.x + piece->offset.x + advance + size.x, - ellipses_p.y + piece->offset.y + size.y); - if(size.x != 0 && size.y != 0 && !r_handle_match(texture, r_handle_zero())) - { - d_img(dst, src, texture, ellipses_color, 0, 0, 0); - } - ellipses_color.w *= 0.5f; - advance += piece->advance; - } - } -} - -internal void -d_text(F_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, F_RunFlags flags, Vec2F32 p, Vec4F32 color, String8 string) +d_text(F_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, F_RasterFlags flags, Vec2F32 p, Vec4F32 color, String8 string) { Temp scratch = scratch_begin(0, 0); F_Run run = f_push_run_from_string(scratch.arena, font, size, base_align_px, tab_size_px, flags, string); d_text_run(p, color, run); scratch_end(scratch); } - -internal void -d_textf(F_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, F_RunFlags flags, Vec2F32 p, Vec4F32 color, char *fmt, ...) -{ - Temp scratch = scratch_begin(0, 0); - va_list args; - va_start(args, fmt); - String8 string = push_str8fv(scratch.arena, fmt, args); - va_end(args); - d_text(font, size, base_align_px, tab_size_px, flags, p, color, string); - scratch_end(scratch); -} - -internal void -d_truncated_text(F_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, F_RunFlags flags, Vec2F32 p, Vec4F32 color, F32 max_x, String8 string) -{ - Temp scratch = scratch_begin(0, 0); - F_Run run = f_push_run_from_string(scratch.arena, font, size, base_align_px, tab_size_px, flags, string); - F_Run ellipses_run = f_push_run_from_string(scratch.arena, font, size, base_align_px, tab_size_px, 0, str8_lit("...")); - d_truncated_text_run(p, color, max_x, run, ellipses_run); - scratch_end(scratch); -} - -internal void -d_truncated_textf(F_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, F_RunFlags flags, Vec2F32 p, Vec4F32 color, F32 max_x, char *fmt, ...) -{ - Temp scratch = scratch_begin(0, 0); - va_list args; - va_start(args, fmt); - String8 string = push_str8f(scratch.arena, fmt, args); - d_truncated_text(font, size, base_align_px, tab_size_px, flags, p, color, max_x, string); - va_end(args); - scratch_end(scratch); -} diff --git a/src/draw/draw.h b/src/draw/draw.h index fbc12ca7..f93627f8 100644 --- a/src/draw/draw.h +++ b/src/draw/draw.h @@ -111,7 +111,7 @@ internal U64 d_hash_from_string(String8 string); internal void d_fancy_string_list_push(Arena *arena, D_FancyStringList *list, D_FancyString *str); internal void d_fancy_string_list_concat_in_place(D_FancyStringList *dst, D_FancyStringList *to_push); internal String8 d_string_from_fancy_string_list(Arena *arena, D_FancyStringList *list); -internal D_FancyRunList d_fancy_run_list_from_fancy_string_list(Arena *arena, F32 tab_size_px, F_RunFlags flags, D_FancyStringList *strs); +internal D_FancyRunList d_fancy_run_list_from_fancy_string_list(Arena *arena, F32 tab_size_px, F_RasterFlags flags, D_FancyStringList *strs); internal D_FancyRunList d_fancy_run_list_copy(Arena *arena, D_FancyRunList *src); //////////////////////////////// @@ -186,10 +186,6 @@ internal void d_sub_bucket(D_Bucket *bucket); internal void d_truncated_fancy_run_list(Vec2F32 p, D_FancyRunList *list, F32 max_x, F_Run trailer_run); internal void d_truncated_fancy_run_fuzzy_matches(Vec2F32 p, D_FancyRunList *list, F32 max_x, FuzzyMatchRangeList *ranges, Vec4F32 color); internal void d_text_run(Vec2F32 p, Vec4F32 color, F_Run run); -internal void d_truncated_text_run(Vec2F32 p, Vec4F32 color, F32 max_x, F_Run text_run, F_Run trailer_run); -internal void d_text(F_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, F_RunFlags flags, Vec2F32 p, Vec4F32 color, String8 string); -internal void d_textf(F_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, F_RunFlags flags, Vec2F32 p, Vec4F32 color, char *fmt, ...); -internal void d_truncated_text(F_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, F_RunFlags flags, Vec2F32 p, Vec4F32 color, F32 max_x, String8 string); -internal void d_truncated_textf(F_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, F_RunFlags flags, Vec2F32 p, Vec4F32 color, F32 max_x, char *fmt, ...); +internal void d_text(F_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, F_RasterFlags flags, Vec2F32 p, Vec4F32 color, String8 string); #endif // DRAW_H diff --git a/src/font_cache/font_cache.c b/src/font_cache/font_cache.c index cba57a03..68d0b14e 100644 --- a/src/font_cache/font_cache.c +++ b/src/font_cache/font_cache.c @@ -520,7 +520,7 @@ f_piece_array_copy(Arena *arena, F_PieceArray *src) //~ rjf: Rasterization Cache internal F_Hash2StyleRasterCacheNode * -f_hash2style_from_tag_size_flags(F_Tag tag, F32 size, F_RunFlags flags) +f_hash2style_from_tag_size_flags(F_Tag tag, F32 size, F_RasterFlags flags) { //- rjf: tag * size -> style hash U64 style_hash = {0}; @@ -571,7 +571,7 @@ f_hash2style_from_tag_size_flags(F_Tag tag, F32 size, F_RunFlags flags) } internal F_Run -f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, F_RunFlags flags, String8 string) +f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, F_RasterFlags flags, String8 string) { ProfBeginFunction(); @@ -579,13 +579,13 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32 F_Hash2StyleRasterCacheNode *hash2style_node = f_hash2style_from_tag_size_flags(tag, size, flags); //- rjf: decode string & produce run pieces + B32 first = 1; F_PieceChunkList piece_chunks = {0}; Vec2F32 dim = {0}; - F32 last_piece_end_pad = 0; B32 font_handle_mapped_on_miss = 0; FP_Handle font_handle = {0}; U64 piece_substring_start_idx = 0; - for(U64 idx = 0; idx < string.size;) + for(U64 idx = 0; idx < string.size; first = 0) { //- rjf: decode next codepoint & get piece substring, or continuation rule String8 piece_substring; @@ -692,7 +692,10 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32 FP_RasterResult raster = {0}; if(size > 0) { - raster = fp_raster(scratch.arena, font_handle, floor_f32(size), (flags & F_RunFlag_Smooth) ? FP_RasterMode_Smooth : FP_RasterMode_Sharp, piece_substring); + FP_RasterFlags fp_flags = 0; + if(flags & F_RasterFlag_Smooth) { fp_flags |= FP_RasterFlag_Smooth; } + if(flags & F_RasterFlag_Hinted) { fp_flags |= FP_RasterFlag_Hinted; } + raster = fp_raster(scratch.arena, font_handle, floor_f32(size), flags, piece_substring); } // rjf: allocate portion of an atlas to upload the rasterization @@ -705,7 +708,7 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32 for(F_Atlas *atlas = f_state->first_atlas;; atlas = atlas->next, num_atlases += 1) { // rjf: create atlas if needed - if(atlas == 0 && num_atlases < 16) + if(atlas == 0 && num_atlases < 64) { atlas = push_array(f_state->arena, F_Atlas, 1); DLLPushBack(f_state->first_atlas, f_state->last_atlas, atlas); @@ -742,10 +745,10 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32 { Rng2S32 subregion = { - chosen_atlas_region.x0 + 1, - chosen_atlas_region.y0 + 1, - chosen_atlas_region.x0 + raster.atlas_dim.x + 1, - chosen_atlas_region.y0 + raster.atlas_dim.y + 1 + chosen_atlas_region.x0, + chosen_atlas_region.y0, + chosen_atlas_region.x0 + raster.atlas_dim.x, + chosen_atlas_region.y0 + raster.atlas_dim.y }; r_fill_tex2d_region(chosen_atlas->texture, subregion, raster.atlas); } @@ -768,11 +771,10 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32 } if(info != 0) { - info->subrect = chosen_atlas_region; - info->bounding_box = raster.bounding_box; - info->atlas_num = chosen_atlas_num; + info->subrect = chosen_atlas_region; + info->atlas_num = chosen_atlas_num; info->raster_dim = raster.atlas_dim; - info->advance = raster.advance; + info->advance = raster.advance; } } @@ -818,13 +820,11 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32 info->subrect.y0 + info->raster_dim.y); piece->advance = advance; piece->decode_size = piece_substring.size; - piece->offset = v2s16(0, -hash2style_node->ascent - 4); + piece->offset = v2s16(0, -(hash2style_node->ascent + hash2style_node->descent)); } base_align_px += advance; dim.x += piece->advance; dim.y = Max(dim.y, info->raster_dim.y); - last_piece_end_pad = ((F32)piece->offset.x+(F32)dim_2s16(info->bounding_box).x) - piece->advance; - last_piece_end_pad = ClampBot(0, last_piece_end_pad); } } } @@ -842,8 +842,6 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32 run.pieces = f_piece_array_from_chunk_list(arena, &piece_chunks); } run.dim = dim; - run.dim.x += last_piece_end_pad; - run.end_pad = last_piece_end_pad; run.ascent = hash2style_node->ascent; run.descent = hash2style_node->descent; } diff --git a/src/font_cache/font_cache.h b/src/font_cache/font_cache.h index c2042676..79abcc36 100644 --- a/src/font_cache/font_cache.h +++ b/src/font_cache/font_cache.h @@ -7,10 +7,11 @@ //////////////////////////////// //~ rjf: Rasterization Flags -typedef U32 F_RunFlags; +typedef U32 F_RasterFlags; enum { - F_RunFlag_Smooth = (1<<0), + F_RasterFlag_Smooth = (1<<0), + F_RasterFlag_Hinted = (1<<1), }; //////////////////////////////// @@ -71,7 +72,6 @@ struct F_Run { F_PieceArray pieces; Vec2F32 dim; - F32 end_pad; F32 ascent; F32 descent; }; @@ -103,7 +103,6 @@ typedef struct F_RasterCacheInfo F_RasterCacheInfo; struct F_RasterCacheInfo { Rng2S16 subrect; - Rng2S16 bounding_box; Vec2S16 raster_dim; S16 atlas_num; F32 advance; @@ -249,8 +248,8 @@ internal F_PieceArray f_piece_array_copy(Arena *arena, F_PieceArray *src); //////////////////////////////// //~ rjf: Rasterization Cache -internal F_Hash2StyleRasterCacheNode *f_hash2style_from_tag_size_flags(F_Tag tag, F32 size, F_RunFlags flags); -internal F_Run f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, F_RunFlags flags, String8 string); +internal F_Hash2StyleRasterCacheNode *f_hash2style_from_tag_size_flags(F_Tag tag, F32 size, F_RasterFlags flags); +internal F_Run f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, F_RasterFlags flags, String8 string); internal String8List f_wrapped_string_lines_from_font_size_string_max(Arena *arena, F_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, String8 string, F32 max); internal Vec2F32 f_dim_from_tag_size_string(F_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, String8 string); internal Vec2F32 f_dim_from_tag_size_string_list(F_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, String8List list); diff --git a/src/font_provider/dwrite/font_provider_dwrite.c b/src/font_provider/dwrite/font_provider_dwrite.c index 7050323a..fe378ab1 100644 --- a/src/font_provider/dwrite/font_provider_dwrite.c +++ b/src/font_provider/dwrite/font_provider_dwrite.c @@ -188,7 +188,7 @@ fp_init(void) //- rjf: make base rendering params error = IDWriteFactory_CreateRenderingParams(fp_dwrite_state->factory, &fp_dwrite_state->base_rendering_params); - //- rjf: make sharp rendering params + //- rjf: make sharp-hinted rendering params { FLOAT gamma = IDWriteRenderingParams_GetGamma(fp_dwrite_state->base_rendering_params); FLOAT enhanced_contrast = IDWriteRenderingParams_GetEnhancedContrast(fp_dwrite_state->base_rendering_params); @@ -202,7 +202,7 @@ fp_init(void) DWRITE_PIXEL_GEOMETRY_FLAT, DWRITE_RENDERING_MODE_GDI_NATURAL, DWRITE_GRID_FIT_MODE_ENABLED, - (IDWriteRenderingParams2 **)&fp_dwrite_state->rendering_params[FP_RasterMode_Sharp]); + (IDWriteRenderingParams2 **)&fp_dwrite_state->rendering_params_sharp_hinted); } else { @@ -212,7 +212,63 @@ fp_init(void) 0.f, DWRITE_PIXEL_GEOMETRY_FLAT, DWRITE_RENDERING_MODE_GDI_NATURAL, - &fp_dwrite_state->rendering_params[FP_RasterMode_Sharp]); + &fp_dwrite_state->rendering_params_sharp_hinted); + } + } + + //- rjf: make sharp-unhinted rendering params + { + FLOAT gamma = IDWriteRenderingParams_GetGamma(fp_dwrite_state->base_rendering_params); + FLOAT enhanced_contrast = IDWriteRenderingParams_GetEnhancedContrast(fp_dwrite_state->base_rendering_params); + if(fp_dwrite_state->dwrite2_is_supported) + { + error = IDWriteFactory2_CreateCustomRenderingParams2((IDWriteFactory2 *)fp_dwrite_state->factory, + gamma, + enhanced_contrast, + enhanced_contrast, + 0.f, + DWRITE_PIXEL_GEOMETRY_FLAT, + DWRITE_RENDERING_MODE_GDI_NATURAL, + DWRITE_GRID_FIT_MODE_DISABLED, + (IDWriteRenderingParams2 **)&fp_dwrite_state->rendering_params_sharp_unhinted); + } + else + { + error = IDWriteFactory_CreateCustomRenderingParams(fp_dwrite_state->factory, + gamma, + enhanced_contrast, + 0.f, + DWRITE_PIXEL_GEOMETRY_FLAT, + DWRITE_RENDERING_MODE_GDI_NATURAL, + &fp_dwrite_state->rendering_params_sharp_unhinted); + } + } + + //- rjf: make smooth-hinted rendering params + { + FLOAT gamma = IDWriteRenderingParams_GetGamma(fp_dwrite_state->base_rendering_params); + FLOAT enhanced_contrast = IDWriteRenderingParams_GetEnhancedContrast(fp_dwrite_state->base_rendering_params); + if(fp_dwrite_state->dwrite2_is_supported) + { + error = IDWriteFactory2_CreateCustomRenderingParams2((IDWriteFactory2 *)fp_dwrite_state->factory, + gamma, + enhanced_contrast, + enhanced_contrast, + 0.f, + DWRITE_PIXEL_GEOMETRY_FLAT, + DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC, + DWRITE_GRID_FIT_MODE_ENABLED, + (IDWriteRenderingParams2 **)&fp_dwrite_state->rendering_params_smooth_hinted); + } + else + { + error = IDWriteFactory_CreateCustomRenderingParams(fp_dwrite_state->factory, + gamma, + enhanced_contrast, + 0.f, + DWRITE_PIXEL_GEOMETRY_FLAT, + DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC, + &fp_dwrite_state->rendering_params_smooth_hinted); } } @@ -230,7 +286,7 @@ fp_init(void) DWRITE_PIXEL_GEOMETRY_FLAT, DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC, DWRITE_GRID_FIT_MODE_DISABLED, - (IDWriteRenderingParams2 **)&fp_dwrite_state->rendering_params[FP_RasterMode_Smooth]); + (IDWriteRenderingParams2 **)&fp_dwrite_state->rendering_params_smooth_unhinted); } else { @@ -240,7 +296,7 @@ fp_init(void) 0.f, DWRITE_PIXEL_GEOMETRY_FLAT, DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC, - &fp_dwrite_state->rendering_params[FP_RasterMode_Smooth]); + &fp_dwrite_state->rendering_params_smooth_unhinted); } } @@ -336,7 +392,7 @@ fp_metrics_from_font(FP_Handle handle) } fp_hook NO_ASAN FP_RasterResult -fp_raster(Arena *arena, FP_Handle font_handle, F32 size, FP_RasterMode mode, String8 string) +fp_raster(Arena *arena, FP_Handle font_handle, F32 size, FP_RasterFlags flags, String8 string) { ProfBeginFunction(); Temp scratch = scratch_begin(&arena, 1); @@ -372,21 +428,30 @@ fp_raster(Arena *arena, FP_Handle font_handle, F32 size, FP_RasterMode mode, Str //- rjf: derive info from metrics F32 advance = 0; Vec2S16 atlas_dim = {0}; + F32 left_side_bearing = 0; + F32 right_side_bearing = 0; if(font.face != 0) { atlas_dim.y = (S16)((96.f/72.f) * size * (font_metrics.ascent + font_metrics.descent) / design_units_per_em); for(U64 idx = 0; idx < glyphs_count; idx += 1) { DWRITE_GLYPH_METRICS *glyph_metrics = glyphs_metrics + idx; - F32 glyph_advance_width = (96.f/72.f) * size * glyph_metrics->advanceWidth / design_units_per_em; - F32 glyph_advance_height = (96.f/72.f) * size * glyph_metrics->advanceHeight / design_units_per_em; + F32 glyph_advance_width = (96.f/72.f) * size * glyph_metrics->advanceWidth / design_units_per_em; + F32 glyph_advance_height = (96.f/72.f) * size * glyph_metrics->advanceHeight / design_units_per_em; advance += glyph_advance_width; atlas_dim.x = Max(atlas_dim.x, (S16)(advance+1)); + if(idx == 0) + { + left_side_bearing = (96.f/72.f) * size * glyph_metrics->leftSideBearing / design_units_per_em; + } + if(idx+1 == glyphs_count) + { + right_side_bearing = (96.f/72.f) * size * glyph_metrics->rightSideBearing / design_units_per_em; + } } + atlas_dim.x -= right_side_bearing; atlas_dim.x += 7; atlas_dim.x -= atlas_dim.x%8; - atlas_dim.x += 4; - atlas_dim.y += 4; } //- rjf: make dwrite bitmap for rendering @@ -411,10 +476,9 @@ fp_raster(Arena *arena, FP_Handle font_handle, F32 size, FP_RasterMode mode, Str } //- rjf: draw glyph run - Vec2F32 draw_p = {1, (F32)atlas_dim.y - 2.f}; + Vec2F32 draw_p = {0, (F32)atlas_dim.y}; if(font.face != 0) { - F32 ascent = (96.f/72.f)*size * font_metrics.ascent / design_units_per_em; F32 descent = (96.f/72.f)*size * font_metrics.descent / design_units_per_em; draw_p.y -= descent; } @@ -429,10 +493,19 @@ fp_raster(Arena *arena, FP_Handle font_handle, F32 size, FP_RasterMode mode, Str RECT bounding_box = {0}; if(font.face != 0) { + IDWriteRenderingParams *rendering_params = fp_dwrite_state->rendering_params_sharp_hinted; + switch(flags) + { + default:{}break; + case 0:{rendering_params = fp_dwrite_state->rendering_params_sharp_unhinted;}break; + case FP_RasterFlag_Hinted:{rendering_params = fp_dwrite_state->rendering_params_sharp_hinted;}break; + case FP_RasterFlag_Smooth:{rendering_params = fp_dwrite_state->rendering_params_smooth_unhinted;}break; + case FP_RasterFlag_Smooth|FP_RasterFlag_Hinted:{rendering_params = fp_dwrite_state->rendering_params_smooth_hinted;}break; + } error = IDWriteBitmapRenderTarget_DrawGlyphRun(render_target, draw_p.x, draw_p.y, DWRITE_MEASURING_MODE_NATURAL, &glyph_run, - fp_dwrite_state->rendering_params[mode], + rendering_params, fg_color, &bounding_box); } @@ -453,7 +526,6 @@ fp_raster(Arena *arena, FP_Handle font_handle, F32 size, FP_RasterMode mode, Str result.atlas_dim = atlas_dim; result.atlas = push_array_no_zero(arena, U8, atlas_dim.x*atlas_dim.y*4); result.advance = floor_f32(advance); - result.bounding_box = r2s16p(bounding_box.left, bounding_box.top, bounding_box.right, bounding_box.bottom); // rjf: fill atlas { diff --git a/src/font_provider/dwrite/font_provider_dwrite.h b/src/font_provider/dwrite/font_provider_dwrite.h index cd4a75f2..f4533c7a 100644 --- a/src/font_provider/dwrite/font_provider_dwrite.h +++ b/src/font_provider/dwrite/font_provider_dwrite.h @@ -255,7 +255,10 @@ struct FP_DWrite_State B32 dwrite2_is_supported; IDWriteFactory *factory; IDWriteRenderingParams *base_rendering_params; - IDWriteRenderingParams *rendering_params[FP_RasterMode_COUNT]; + IDWriteRenderingParams *rendering_params_sharp_hinted; + IDWriteRenderingParams *rendering_params_sharp_unhinted; + IDWriteRenderingParams *rendering_params_smooth_hinted; + IDWriteRenderingParams *rendering_params_smooth_unhinted; IDWriteGdiInterop *gdi_interop; Vec2S32 bitmap_render_target_dim; IDWriteBitmapRenderTarget *bitmap_render_target; diff --git a/src/font_provider/font_provider.h b/src/font_provider/font_provider.h index 5377b453..6d6c3f5b 100644 --- a/src/font_provider/font_provider.h +++ b/src/font_provider/font_provider.h @@ -9,13 +9,12 @@ //////////////////////////////// //~ rjf: Types -typedef enum FP_RasterMode +typedef U32 FP_RasterFlags; +enum { - FP_RasterMode_Sharp, - FP_RasterMode_Smooth, - FP_RasterMode_COUNT -} -FP_RasterMode; + FP_RasterFlag_Smooth = (1<<0), + FP_RasterFlag_Hinted = (1<<1), +}; typedef struct FP_Handle FP_Handle; struct FP_Handle @@ -39,7 +38,6 @@ struct FP_RasterResult Vec2S16 atlas_dim; void *atlas; F32 advance; - Rng2S16 bounding_box; }; //////////////////////////////// @@ -56,6 +54,6 @@ fp_hook FP_Handle fp_font_open(String8 path); fp_hook FP_Handle fp_font_open_from_static_data_string(String8 *data_ptr); fp_hook void fp_font_close(FP_Handle handle); fp_hook FP_Metrics fp_metrics_from_font(FP_Handle font); -fp_hook NO_ASAN FP_RasterResult fp_raster(Arena *arena, FP_Handle font, F32 size, FP_RasterMode mode, String8 string); +fp_hook NO_ASAN FP_RasterResult fp_raster(Arena *arena, FP_Handle font, F32 size, FP_RasterFlags flags, String8 string); #endif // FONT_PROVIDER_H diff --git a/src/raddbg/raddbg.h b/src/raddbg/raddbg.h index 7cf9d53b..67c19d74 100644 --- a/src/raddbg/raddbg.h +++ b/src/raddbg/raddbg.h @@ -8,7 +8,6 @@ // [ ] inline breakpoint hit_count // [ ] to count hit counts, resolve all bps to addresses, check addresses // against stopper thread's -// [ ] editing multiple bindings for commands // [ ] theme lister -> fonts & font sizes // [ ] "Browse..." buttons should adopt a more relevant starting search path, // if possible @@ -112,10 +111,6 @@ // [ ] lock icon // [ ] "rotation arrow" icon next to executables // -// [ ] I LOVE ALT-W to add watch under cursor, but I would prefer to have it -// add what's under the MOUSE cursor instead of the keyboard cursor. Can -// we get a command for that so I can bind ALT-W to that instead? -// // [ ] For theme editing, when you hove the mouse over a theme color entry and // it highlights that entry, it might help to temporarily change that // color to white (or the inverse of the background color, or whatever) so @@ -410,6 +405,10 @@ // sometimes both source code and menu/tab/watch font size, sometimes // just menu/tab/watch font size not source size. // [x] colors: fill out rest of theme presets for new theme setup +// [x] I LOVE ALT-W to add watch under cursor, but I would prefer to have it +// add what's under the MOUSE cursor instead of the keyboard cursor. Can +// we get a command for that so I can bind ALT-W to that instead? +// [x] editing multiple bindings for commands #ifndef RADDBG_H #define RADDBG_H diff --git a/src/ui/generated/ui.meta.c b/src/ui/generated/ui.meta.c index 6f0d82e5..fb76a2a7 100644 --- a/src/ui/generated/ui.meta.c +++ b/src/ui/generated/ui.meta.c @@ -23,7 +23,7 @@ #define UI_HoverCursor(v) DeferLoop(ui_push_hover_cursor(v), ui_pop_hover_cursor()) #define UI_Font(v) DeferLoop(ui_push_font(v), ui_pop_font()) #define UI_FontSize(v) DeferLoop(ui_push_font_size(v), ui_pop_font_size()) -#define UI_RunFlags(v) DeferLoop(ui_push_run_flags(v), ui_pop_run_flags()) +#define UI_TextRasterFlags(v) DeferLoop(ui_push_text_raster_flags(v), ui_pop_text_raster_flags()) #define UI_TabSize(v) DeferLoop(ui_push_tab_size(v), ui_pop_tab_size()) #define UI_CornerRadius00(v) DeferLoop(ui_push_corner_radius_00(v), ui_pop_corner_radius_00()) #define UI_CornerRadius01(v) DeferLoop(ui_push_corner_radius_01(v), ui_pop_corner_radius_01()) @@ -52,7 +52,7 @@ internal F32 ui_top_squish(void) { UI_StackTopImpl(ui_state, Squish, squish) } internal OS_Cursor ui_top_hover_cursor(void) { UI_StackTopImpl(ui_state, HoverCursor, hover_cursor) } internal F_Tag ui_top_font(void) { UI_StackTopImpl(ui_state, Font, font) } internal F32 ui_top_font_size(void) { UI_StackTopImpl(ui_state, FontSize, font_size) } -internal F_RunFlags ui_top_run_flags(void) { UI_StackTopImpl(ui_state, RunFlags, run_flags) } +internal F_RasterFlags ui_top_text_raster_flags(void) { UI_StackTopImpl(ui_state, TextRasterFlags, text_raster_flags) } internal F32 ui_top_tab_size(void) { UI_StackTopImpl(ui_state, TabSize, tab_size) } internal F32 ui_top_corner_radius_00(void) { UI_StackTopImpl(ui_state, CornerRadius00, corner_radius_00) } internal F32 ui_top_corner_radius_01(void) { UI_StackTopImpl(ui_state, CornerRadius01, corner_radius_01) } @@ -80,7 +80,7 @@ internal F32 ui_bottom_squish(void) { UI_StackBottomImpl(ui_state, Squish, squis internal OS_Cursor ui_bottom_hover_cursor(void) { UI_StackBottomImpl(ui_state, HoverCursor, hover_cursor) } internal F_Tag ui_bottom_font(void) { UI_StackBottomImpl(ui_state, Font, font) } internal F32 ui_bottom_font_size(void) { UI_StackBottomImpl(ui_state, FontSize, font_size) } -internal F_RunFlags ui_bottom_run_flags(void) { UI_StackBottomImpl(ui_state, RunFlags, run_flags) } +internal F_RasterFlags ui_bottom_text_raster_flags(void) { UI_StackBottomImpl(ui_state, TextRasterFlags, text_raster_flags) } internal F32 ui_bottom_tab_size(void) { UI_StackBottomImpl(ui_state, TabSize, tab_size) } internal F32 ui_bottom_corner_radius_00(void) { UI_StackBottomImpl(ui_state, CornerRadius00, corner_radius_00) } internal F32 ui_bottom_corner_radius_01(void) { UI_StackBottomImpl(ui_state, CornerRadius01, corner_radius_01) } @@ -108,7 +108,7 @@ internal F32 ui_push_squish(F32 v) { UI_StackPushImpl(ui_state, Squish, squish, internal OS_Cursor ui_push_hover_cursor(OS_Cursor v) { UI_StackPushImpl(ui_state, HoverCursor, hover_cursor, OS_Cursor, v) } internal F_Tag ui_push_font(F_Tag v) { UI_StackPushImpl(ui_state, Font, font, F_Tag, v) } internal F32 ui_push_font_size(F32 v) { UI_StackPushImpl(ui_state, FontSize, font_size, F32, v) } -internal F_RunFlags ui_push_run_flags(F_RunFlags v) { UI_StackPushImpl(ui_state, RunFlags, run_flags, F_RunFlags, v) } +internal F_RasterFlags ui_push_text_raster_flags(F_RasterFlags v) { UI_StackPushImpl(ui_state, TextRasterFlags, text_raster_flags, F_RasterFlags, v) } internal F32 ui_push_tab_size(F32 v) { UI_StackPushImpl(ui_state, TabSize, tab_size, F32, v) } internal F32 ui_push_corner_radius_00(F32 v) { UI_StackPushImpl(ui_state, CornerRadius00, corner_radius_00, F32, v) } internal F32 ui_push_corner_radius_01(F32 v) { UI_StackPushImpl(ui_state, CornerRadius01, corner_radius_01, F32, v) } @@ -136,7 +136,7 @@ internal F32 ui_pop_squish(void) { UI_StackPopImpl(ui_state, Squish, squish) } internal OS_Cursor ui_pop_hover_cursor(void) { UI_StackPopImpl(ui_state, HoverCursor, hover_cursor) } internal F_Tag ui_pop_font(void) { UI_StackPopImpl(ui_state, Font, font) } internal F32 ui_pop_font_size(void) { UI_StackPopImpl(ui_state, FontSize, font_size) } -internal F_RunFlags ui_pop_run_flags(void) { UI_StackPopImpl(ui_state, RunFlags, run_flags) } +internal F_RasterFlags ui_pop_text_raster_flags(void) { UI_StackPopImpl(ui_state, TextRasterFlags, text_raster_flags) } internal F32 ui_pop_tab_size(void) { UI_StackPopImpl(ui_state, TabSize, tab_size) } internal F32 ui_pop_corner_radius_00(void) { UI_StackPopImpl(ui_state, CornerRadius00, corner_radius_00) } internal F32 ui_pop_corner_radius_01(void) { UI_StackPopImpl(ui_state, CornerRadius01, corner_radius_01) } @@ -164,7 +164,7 @@ internal F32 ui_set_next_squish(F32 v) { UI_StackSetNextImpl(ui_state, Squish, s internal OS_Cursor ui_set_next_hover_cursor(OS_Cursor v) { UI_StackSetNextImpl(ui_state, HoverCursor, hover_cursor, OS_Cursor, v) } internal F_Tag ui_set_next_font(F_Tag v) { UI_StackSetNextImpl(ui_state, Font, font, F_Tag, v) } internal F32 ui_set_next_font_size(F32 v) { UI_StackSetNextImpl(ui_state, FontSize, font_size, F32, v) } -internal F_RunFlags ui_set_next_run_flags(F_RunFlags v) { UI_StackSetNextImpl(ui_state, RunFlags, run_flags, F_RunFlags, v) } +internal F_RasterFlags ui_set_next_text_raster_flags(F_RasterFlags v) { UI_StackSetNextImpl(ui_state, TextRasterFlags, text_raster_flags, F_RasterFlags, v) } internal F32 ui_set_next_tab_size(F32 v) { UI_StackSetNextImpl(ui_state, TabSize, tab_size, F32, v) } internal F32 ui_set_next_corner_radius_00(F32 v) { UI_StackSetNextImpl(ui_state, CornerRadius00, corner_radius_00, F32, v) } internal F32 ui_set_next_corner_radius_01(F32 v) { UI_StackSetNextImpl(ui_state, CornerRadius01, corner_radius_01, F32, v) } diff --git a/src/ui/generated/ui.meta.h b/src/ui/generated/ui.meta.h index 9573288f..db58d743 100644 --- a/src/ui/generated/ui.meta.h +++ b/src/ui/generated/ui.meta.h @@ -25,7 +25,7 @@ typedef struct UI_SquishNode UI_SquishNode; struct UI_SquishNode{UI_SquishNode * typedef struct UI_HoverCursorNode UI_HoverCursorNode; struct UI_HoverCursorNode{UI_HoverCursorNode *next; OS_Cursor v;}; typedef struct UI_FontNode UI_FontNode; struct UI_FontNode{UI_FontNode *next; F_Tag v;}; typedef struct UI_FontSizeNode UI_FontSizeNode; struct UI_FontSizeNode{UI_FontSizeNode *next; F32 v;}; -typedef struct UI_RunFlagsNode UI_RunFlagsNode; struct UI_RunFlagsNode{UI_RunFlagsNode *next; F_RunFlags v;}; +typedef struct UI_TextRasterFlagsNode UI_TextRasterFlagsNode; struct UI_TextRasterFlagsNode{UI_TextRasterFlagsNode *next; F_RasterFlags v;}; typedef struct UI_TabSizeNode UI_TabSizeNode; struct UI_TabSizeNode{UI_TabSizeNode *next; F32 v;}; typedef struct UI_CornerRadius00Node UI_CornerRadius00Node; struct UI_CornerRadius00Node{UI_CornerRadius00Node *next; F32 v;}; typedef struct UI_CornerRadius01Node UI_CornerRadius01Node; struct UI_CornerRadius01Node{UI_CornerRadius01Node *next; F32 v;}; @@ -56,7 +56,7 @@ UI_SquishNode squish_nil_stack_top;\ UI_HoverCursorNode hover_cursor_nil_stack_top;\ UI_FontNode font_nil_stack_top;\ UI_FontSizeNode font_size_nil_stack_top;\ -UI_RunFlagsNode run_flags_nil_stack_top;\ +UI_TextRasterFlagsNode text_raster_flags_nil_stack_top;\ UI_TabSizeNode tab_size_nil_stack_top;\ UI_CornerRadius00Node corner_radius_00_nil_stack_top;\ UI_CornerRadius01Node corner_radius_01_nil_stack_top;\ @@ -86,14 +86,14 @@ state->squish_nil_stack_top.v = 0;\ state->hover_cursor_nil_stack_top.v = OS_Cursor_Pointer;\ state->font_nil_stack_top.v = f_tag_zero();\ state->font_size_nil_stack_top.v = 24.f;\ -state->run_flags_nil_stack_top.v = 0;\ +state->text_raster_flags_nil_stack_top.v = F_RasterFlag_Hinted;\ state->tab_size_nil_stack_top.v = 24.f*4.f;\ state->corner_radius_00_nil_stack_top.v = 0;\ state->corner_radius_01_nil_stack_top.v = 0;\ state->corner_radius_10_nil_stack_top.v = 0;\ state->corner_radius_11_nil_stack_top.v = 0;\ state->blur_size_nil_stack_top.v = 0;\ -state->text_padding_nil_stack_top.v = 2;\ +state->text_padding_nil_stack_top.v = 0;\ state->text_alignment_nil_stack_top.v = UI_TextAlign_Left;\ #define UI_DeclStacks \ @@ -118,7 +118,7 @@ struct { UI_SquishNode *top; F32 bottom_val; UI_SquishNode *free; B32 auto_pop; struct { UI_HoverCursorNode *top; OS_Cursor bottom_val; UI_HoverCursorNode *free; B32 auto_pop; } hover_cursor_stack;\ struct { UI_FontNode *top; F_Tag bottom_val; UI_FontNode *free; B32 auto_pop; } font_stack;\ struct { UI_FontSizeNode *top; F32 bottom_val; UI_FontSizeNode *free; B32 auto_pop; } font_size_stack;\ -struct { UI_RunFlagsNode *top; F_RunFlags bottom_val; UI_RunFlagsNode *free; B32 auto_pop; } run_flags_stack;\ +struct { UI_TextRasterFlagsNode *top; F_RasterFlags bottom_val; UI_TextRasterFlagsNode *free; B32 auto_pop; } text_raster_flags_stack;\ struct { UI_TabSizeNode *top; F32 bottom_val; UI_TabSizeNode *free; B32 auto_pop; } tab_size_stack;\ struct { UI_CornerRadius00Node *top; F32 bottom_val; UI_CornerRadius00Node *free; B32 auto_pop; } corner_radius_00_stack;\ struct { UI_CornerRadius01Node *top; F32 bottom_val; UI_CornerRadius01Node *free; B32 auto_pop; } corner_radius_01_stack;\ @@ -148,14 +148,14 @@ state->squish_stack.top = &state->squish_nil_stack_top; state->squish_stack.bott state->hover_cursor_stack.top = &state->hover_cursor_nil_stack_top; state->hover_cursor_stack.bottom_val = OS_Cursor_Pointer; state->hover_cursor_stack.free = 0; state->hover_cursor_stack.auto_pop = 0;\ state->font_stack.top = &state->font_nil_stack_top; state->font_stack.bottom_val = f_tag_zero(); state->font_stack.free = 0; state->font_stack.auto_pop = 0;\ state->font_size_stack.top = &state->font_size_nil_stack_top; state->font_size_stack.bottom_val = 24.f; state->font_size_stack.free = 0; state->font_size_stack.auto_pop = 0;\ -state->run_flags_stack.top = &state->run_flags_nil_stack_top; state->run_flags_stack.bottom_val = 0; state->run_flags_stack.free = 0; state->run_flags_stack.auto_pop = 0;\ +state->text_raster_flags_stack.top = &state->text_raster_flags_nil_stack_top; state->text_raster_flags_stack.bottom_val = F_RasterFlag_Hinted; state->text_raster_flags_stack.free = 0; state->text_raster_flags_stack.auto_pop = 0;\ state->tab_size_stack.top = &state->tab_size_nil_stack_top; state->tab_size_stack.bottom_val = 24.f*4.f; state->tab_size_stack.free = 0; state->tab_size_stack.auto_pop = 0;\ state->corner_radius_00_stack.top = &state->corner_radius_00_nil_stack_top; state->corner_radius_00_stack.bottom_val = 0; state->corner_radius_00_stack.free = 0; state->corner_radius_00_stack.auto_pop = 0;\ state->corner_radius_01_stack.top = &state->corner_radius_01_nil_stack_top; state->corner_radius_01_stack.bottom_val = 0; state->corner_radius_01_stack.free = 0; state->corner_radius_01_stack.auto_pop = 0;\ state->corner_radius_10_stack.top = &state->corner_radius_10_nil_stack_top; state->corner_radius_10_stack.bottom_val = 0; state->corner_radius_10_stack.free = 0; state->corner_radius_10_stack.auto_pop = 0;\ state->corner_radius_11_stack.top = &state->corner_radius_11_nil_stack_top; state->corner_radius_11_stack.bottom_val = 0; state->corner_radius_11_stack.free = 0; state->corner_radius_11_stack.auto_pop = 0;\ state->blur_size_stack.top = &state->blur_size_nil_stack_top; state->blur_size_stack.bottom_val = 0; state->blur_size_stack.free = 0; state->blur_size_stack.auto_pop = 0;\ -state->text_padding_stack.top = &state->text_padding_nil_stack_top; state->text_padding_stack.bottom_val = 2; state->text_padding_stack.free = 0; state->text_padding_stack.auto_pop = 0;\ +state->text_padding_stack.top = &state->text_padding_nil_stack_top; state->text_padding_stack.bottom_val = 0; state->text_padding_stack.free = 0; state->text_padding_stack.auto_pop = 0;\ state->text_alignment_stack.top = &state->text_alignment_nil_stack_top; state->text_alignment_stack.bottom_val = UI_TextAlign_Left; state->text_alignment_stack.free = 0; state->text_alignment_stack.auto_pop = 0;\ #define UI_AutoPopStacks(state) \ @@ -178,7 +178,7 @@ if(state->squish_stack.auto_pop) { ui_pop_squish(); state->squish_stack.auto_pop if(state->hover_cursor_stack.auto_pop) { ui_pop_hover_cursor(); state->hover_cursor_stack.auto_pop = 0; }\ if(state->font_stack.auto_pop) { ui_pop_font(); state->font_stack.auto_pop = 0; }\ if(state->font_size_stack.auto_pop) { ui_pop_font_size(); state->font_size_stack.auto_pop = 0; }\ -if(state->run_flags_stack.auto_pop) { ui_pop_run_flags(); state->run_flags_stack.auto_pop = 0; }\ +if(state->text_raster_flags_stack.auto_pop) { ui_pop_text_raster_flags(); state->text_raster_flags_stack.auto_pop = 0; }\ if(state->tab_size_stack.auto_pop) { ui_pop_tab_size(); state->tab_size_stack.auto_pop = 0; }\ if(state->corner_radius_00_stack.auto_pop) { ui_pop_corner_radius_00(); state->corner_radius_00_stack.auto_pop = 0; }\ if(state->corner_radius_01_stack.auto_pop) { ui_pop_corner_radius_01(); state->corner_radius_01_stack.auto_pop = 0; }\ @@ -207,7 +207,7 @@ internal F32 ui_top_squish(void); internal OS_Cursor ui_top_hover_cursor(void); internal F_Tag ui_top_font(void); internal F32 ui_top_font_size(void); -internal F_RunFlags ui_top_run_flags(void); +internal F_RasterFlags ui_top_text_raster_flags(void); internal F32 ui_top_tab_size(void); internal F32 ui_top_corner_radius_00(void); internal F32 ui_top_corner_radius_01(void); @@ -235,7 +235,7 @@ internal F32 ui_bottom_squish(void); internal OS_Cursor ui_bottom_hover_cursor(void); internal F_Tag ui_bottom_font(void); internal F32 ui_bottom_font_size(void); -internal F_RunFlags ui_bottom_run_flags(void); +internal F_RasterFlags ui_bottom_text_raster_flags(void); internal F32 ui_bottom_tab_size(void); internal F32 ui_bottom_corner_radius_00(void); internal F32 ui_bottom_corner_radius_01(void); @@ -263,7 +263,7 @@ internal F32 ui_push_squish(F32 v); internal OS_Cursor ui_push_hover_cursor(OS_Cursor v); internal F_Tag ui_push_font(F_Tag v); internal F32 ui_push_font_size(F32 v); -internal F_RunFlags ui_push_run_flags(F_RunFlags v); +internal F_RasterFlags ui_push_text_raster_flags(F_RasterFlags v); internal F32 ui_push_tab_size(F32 v); internal F32 ui_push_corner_radius_00(F32 v); internal F32 ui_push_corner_radius_01(F32 v); @@ -291,7 +291,7 @@ internal F32 ui_pop_squish(void); internal OS_Cursor ui_pop_hover_cursor(void); internal F_Tag ui_pop_font(void); internal F32 ui_pop_font_size(void); -internal F_RunFlags ui_pop_run_flags(void); +internal F_RasterFlags ui_pop_text_raster_flags(void); internal F32 ui_pop_tab_size(void); internal F32 ui_pop_corner_radius_00(void); internal F32 ui_pop_corner_radius_01(void); @@ -319,7 +319,7 @@ internal F32 ui_set_next_squish(F32 v); internal OS_Cursor ui_set_next_hover_cursor(OS_Cursor v); internal F_Tag ui_set_next_font(F_Tag v); internal F32 ui_set_next_font_size(F32 v); -internal F_RunFlags ui_set_next_run_flags(F_RunFlags v); +internal F_RasterFlags ui_set_next_text_raster_flags(F_RasterFlags v); internal F32 ui_set_next_tab_size(F32 v); internal F32 ui_set_next_corner_radius_00(F32 v); internal F32 ui_set_next_corner_radius_01(F32 v); diff --git a/src/ui/ui.mdesk b/src/ui/ui.mdesk index 1f1e3a6a..8740fe4b 100644 --- a/src/ui/ui.mdesk +++ b/src/ui/ui.mdesk @@ -42,7 +42,7 @@ UI_StackTable: //- rjf: font { Font font F_Tag `f_tag_zero()` } { FontSize font_size F32 24.f } - { RunFlags run_flags F_RunFlags 0 } + { TextRasterFlags text_raster_flags F_RasterFlags F_RasterFlag_Hinted } { TabSize tab_size F32 `24.f*4.f` } //- rjf: corner radii @@ -55,7 +55,7 @@ UI_StackTable: { BlurSize blur_size F32 0 } //- rjf: text parameters - { TextPadding text_padding F32 2 } + { TextPadding text_padding F32 0 } { TextAlignment text_alignment UI_TextAlign UI_TextAlign_Left } } diff --git a/src/ui/ui_basic_widgets.c b/src/ui/ui_basic_widgets.c index 5fe1ed9d..6c73ec30 100644 --- a/src/ui/ui_basic_widgets.c +++ b/src/ui/ui_basic_widgets.c @@ -142,21 +142,21 @@ internal UI_BOX_CUSTOM_DRAW(ui_line_edit_draw) String8 edited_string = draw_data->edited_string; TxtPt cursor = draw_data->cursor; TxtPt mark = draw_data->mark; - F32 cursor_pixel_off = f_dim_from_tag_size_string(font, font_size, 0, tab_size, str8_prefix(edited_string, cursor.column-1)).x + font_size/8.f; - F32 mark_pixel_off = f_dim_from_tag_size_string(font, font_size, 0, tab_size, str8_prefix(edited_string, mark.column-1)).x + font_size/8.f; + F32 cursor_pixel_off = f_dim_from_tag_size_string(font, font_size, 0, tab_size, str8_prefix(edited_string, cursor.column-1)).x; + F32 mark_pixel_off = f_dim_from_tag_size_string(font, font_size, 0, tab_size, str8_prefix(edited_string, mark.column-1)).x; F32 cursor_thickness = ClampBot(4.f, font_size/6.f); Rng2F32 cursor_rect = { - text_position.x-cursor_thickness*0.40f + cursor_pixel_off, + text_position.x + cursor_pixel_off - cursor_thickness*0.50f, box->rect.y0+4.f, - text_position.x+cursor_thickness*0.60f + cursor_pixel_off, + text_position.x + cursor_pixel_off + cursor_thickness*0.50f, box->rect.y1-4.f, }; Rng2F32 mark_rect = { - text_position.x-cursor_thickness*0.40f + mark_pixel_off, + text_position.x + mark_pixel_off - cursor_thickness*0.50f, box->rect.y0+2.f, - text_position.x+cursor_thickness*0.60f + mark_pixel_off, + text_position.x + mark_pixel_off + cursor_thickness*0.50f, box->rect.y1-2.f, }; Rng2F32 select_rect = union_2f32(cursor_rect, mark_rect); @@ -843,41 +843,43 @@ ui_alpha_pickerf(F32 *out_alpha, char *fmt, ...) //////////////////////////////// //~ rjf: Simple Layout Widgets -internal UI_Signal ui_row_begin(void) { return ui_named_row_begin(str8_lit("")); } -internal void ui_row_end(void) { ui_named_row_end(); } -internal UI_Signal ui_column_begin(void) { return ui_named_column_begin(str8_lit("")); } -internal void ui_column_end(void) { ui_named_column_end(); } +internal UI_Box *ui_row_begin(void) { return ui_named_row_begin(str8_lit("")); } +internal UI_Signal ui_row_end(void) { return ui_named_row_end(); } +internal UI_Box *ui_column_begin(void) { return ui_named_column_begin(str8_lit("")); } +internal UI_Signal ui_column_end(void) { return ui_named_column_end(); } -internal UI_Signal +internal UI_Box * ui_named_row_begin(String8 string) { ui_set_next_child_layout_axis(Axis2_X); UI_Box *box = ui_build_box_from_string(0, string); ui_push_parent(box); - UI_Signal result = ui_signal_from_box(box); - return result; -} - -internal void -ui_named_row_end(void) -{ - ui_pop_parent(); + return box; } internal UI_Signal +ui_named_row_end(void) +{ + UI_Box *box = ui_pop_parent(); + UI_Signal sig = ui_signal_from_box(box); + return sig; +} + +internal UI_Box * ui_named_column_begin(String8 string) { ui_set_next_child_layout_axis(Axis2_Y); UI_Box *box = ui_build_box_from_string(0, string); ui_push_parent(box); - UI_Signal result = ui_signal_from_box(box); - return result; + return box; } -internal void +internal UI_Signal ui_named_column_end(void) { - ui_pop_parent(); + UI_Box *box = ui_pop_parent(); + UI_Signal sig = ui_signal_from_box(box); + return sig; } //////////////////////////////// diff --git a/src/ui/ui_basic_widgets.h b/src/ui/ui_basic_widgets.h index b500e187..a3a3464d 100644 --- a/src/ui/ui_basic_widgets.h +++ b/src/ui/ui_basic_widgets.h @@ -116,14 +116,14 @@ internal UI_Signal ui_alpha_pickerf(F32 *out_alpha, char *fmt, ...); //////////////////////////////// //~ rjf: Simple Layout Widgets -internal UI_Signal ui_row_begin(void); -internal void ui_row_end(void); -internal UI_Signal ui_column_begin(void); -internal void ui_column_end(void); -internal UI_Signal ui_named_row_begin(String8 string); -internal void ui_named_row_end(void); -internal UI_Signal ui_named_column_begin(String8 string); -internal void ui_named_column_end(void); +internal UI_Box *ui_row_begin(void); +internal UI_Signal ui_row_end(void); +internal UI_Box *ui_column_begin(void); +internal UI_Signal ui_column_end(void); +internal UI_Box *ui_named_row_begin(String8 string); +internal UI_Signal ui_named_row_end(void); +internal UI_Box *ui_named_column_begin(String8 string); +internal UI_Signal ui_named_column_end(void); //////////////////////////////// //~ rjf: Floating Panes diff --git a/src/ui/ui_core.c b/src/ui/ui_core.c index 311f49dc..32075443 100644 --- a/src/ui/ui_core.c +++ b/src/ui/ui_core.c @@ -1418,7 +1418,7 @@ ui_end_build(void) String8 box_display_string = ui_box_display_string(b); Vec2F32 text_pos = ui_box_text_position(b); Vec2F32 drawn_text_dim = b->display_string_runs.dim; - B32 text_is_truncated = (drawn_text_dim.x + text_pos.x >= rect.x1); + B32 text_is_truncated = (drawn_text_dim.x + text_pos.x > rect.x1); B32 mouse_is_hovering = contains_2f32(r2f32p(text_pos.x, rect.y0, Min(text_pos.x+drawn_text_dim.x, rect.x1), @@ -1484,7 +1484,7 @@ ui_calc_sizes_standalone__in_place_rec(UI_Box *root, Axis2 axis) { F32 padding = root->pref_size[axis].value; F32 text_size = root->display_string_runs.dim.x; - root->fixed_size.v[axis] = padding + text_size; + root->fixed_size.v[axis] = padding + text_size + root->text_padding*2; }break; } @@ -1733,10 +1733,10 @@ ui_layout_position__in_place_rec(UI_Box *root, Axis2 axis) child->rect.p0.v[axis] = root->rect.p0.v[axis] + child->fixed_position.v[axis] - !(child->flags&(UI_BoxFlag_SkipViewOffX<view_off.v[axis]); } child->rect.p1.v[axis] = child->rect.p0.v[axis] + child->fixed_size.v[axis]; - child->rect.p0.x = floorf(child->rect.p0.x); - child->rect.p0.y = floorf(child->rect.p0.y); - child->rect.p1.x = floorf(child->rect.p1.x); - child->rect.p1.y = floorf(child->rect.p1.y); + child->rect.p0.x = floor_f32(child->rect.p0.x); + child->rect.p0.y = floor_f32(child->rect.p0.y); + child->rect.p1.x = floor_f32(child->rect.p1.x); + child->rect.p1.y = floor_f32(child->rect.p1.y); // rjf: grab new position F32 new_position = Min(child->rect.p0.v[axis], child->rect.p1.v[axis]); @@ -1795,7 +1795,7 @@ ui_tooltip_begin_base(void) ui_push_parent(ui_root_from_state(ui_state)); ui_push_parent(ui_state->tooltip_root); ui_push_flags(0); - ui_push_run_flags(0); + ui_push_text_raster_flags(ui_bottom_text_raster_flags()); ui_push_palette(ui_bottom_palette()); } @@ -1803,7 +1803,7 @@ internal void ui_tooltip_end_base(void) { ui_pop_palette(); - ui_pop_run_flags(); + ui_pop_text_raster_flags(); ui_pop_flags(); ui_pop_parent(); ui_pop_parent(); @@ -2218,7 +2218,7 @@ ui_build_box_from_key(UI_BoxFlags flags, UI_Key key) box->font = ui_state->font_stack.top->v; box->font_size = ui_state->font_size_stack.top->v; box->tab_size = ui_state->tab_size_stack.top->v; - box->run_flags = ui_state->run_flags_stack.top->v; + box->text_raster_flags = ui_state->text_raster_flags_stack.top->v; box->corner_radii[Corner_00] = ui_state->corner_radius_00_stack.top->v; box->corner_radii[Corner_01] = ui_state->corner_radius_01_stack.top->v; box->corner_radii[Corner_10] = ui_state->corner_radius_10_stack.top->v; @@ -2308,7 +2308,7 @@ ui_box_equip_display_string(UI_Box *box, String8 string) String8 display_string = ui_box_display_string(box); D_FancyStringNode fancy_string_n = {0, {box->font, display_string, box->palette->colors[text_color_code], box->font_size, 0, 0}}; D_FancyStringList fancy_strings = {&fancy_string_n, &fancy_string_n, 1}; - box->display_string_runs = d_fancy_run_list_from_fancy_string_list(ui_build_arena(), box->tab_size, box->run_flags, &fancy_strings); + box->display_string_runs = d_fancy_run_list_from_fancy_string_list(ui_build_arena(), box->tab_size, box->text_raster_flags, &fancy_strings); } else if(box->flags & UI_BoxFlag_DrawText && box->flags & UI_BoxFlag_DrawTextFastpathCodepoint && box->fastpath_codepoint != 0) { @@ -2323,13 +2323,13 @@ ui_box_equip_display_string(UI_Box *box, String8 string) D_FancyStringNode cdp_fancy_string_n = {&pst_fancy_string_n, {box->font, str8_substr(display_string, r1u64(fpcp_pos, fpcp_pos+fpcp.size)), box->palette->colors[text_color_code], box->font_size, 3.f, 0}}; D_FancyStringNode pre_fancy_string_n = {&cdp_fancy_string_n, {box->font, str8_prefix(display_string, fpcp_pos), box->palette->colors[text_color_code], box->font_size, 0, 0}}; D_FancyStringList fancy_strings = {&pre_fancy_string_n, &pst_fancy_string_n, 3}; - box->display_string_runs = d_fancy_run_list_from_fancy_string_list(ui_build_arena(), box->tab_size, box->run_flags, &fancy_strings); + box->display_string_runs = d_fancy_run_list_from_fancy_string_list(ui_build_arena(), box->tab_size, box->text_raster_flags, &fancy_strings); } else { D_FancyStringNode fancy_string_n = {0, {box->font, display_string, box->palette->colors[UI_ColorCode_Text], box->font_size, 0, 0}}; D_FancyStringList fancy_strings = {&fancy_string_n, &fancy_string_n, 1}; - box->display_string_runs = d_fancy_run_list_from_fancy_string_list(ui_build_arena(), box->tab_size, box->run_flags, &fancy_strings); + box->display_string_runs = d_fancy_run_list_from_fancy_string_list(ui_build_arena(), box->tab_size, box->text_raster_flags, &fancy_strings); } scratch_end(scratch); } @@ -2341,7 +2341,7 @@ ui_box_equip_display_fancy_strings(UI_Box *box, D_FancyStringList *strings) { box->flags |= UI_BoxFlag_HasDisplayString; box->string = d_string_from_fancy_string_list(ui_build_arena(), strings); - box->display_string_runs = d_fancy_run_list_from_fancy_string_list(ui_build_arena(), box->tab_size, box->run_flags, strings); + box->display_string_runs = d_fancy_run_list_from_fancy_string_list(ui_build_arena(), box->tab_size, box->text_raster_flags, strings); } internal inline void @@ -2400,28 +2400,32 @@ ui_box_text_position(UI_Box *box) F_Tag font = box->font; F32 font_size = box->font_size; F_Metrics font_metrics = f_metrics_from_tag_size(font, font_size); - result.y = floor_f32((box->rect.p0.y + box->rect.p1.y)/2.f + (font_metrics.capital_height/2) - font_metrics.line_gap/2); + result.y = floor_f32((box->rect.p0.y + box->rect.p1.y)/2.f) + font_metrics.capital_height/2.f; + if(!f_tag_match(font, ui_icon_font())) + { + result.y += font_metrics.descent/2; + } switch(box->text_align) { default: case UI_TextAlign_Left: { - result.x = box->rect.p0.x + 2.f + box->text_padding; + result.x = box->rect.p0.x + box->text_padding; }break; case UI_TextAlign_Center: { Vec2F32 text_dim = box->display_string_runs.dim; - result.x = round_f32((box->rect.p0.x + box->rect.p1.x)/2 - text_dim.x/2) - 1.f; + result.x = floor_f32((box->rect.p0.x + box->rect.p1.x)/2 - text_dim.x/2); result.x = ClampBot(result.x, box->rect.x0); }break; case UI_TextAlign_Right: { Vec2F32 text_dim = box->display_string_runs.dim; - result.x = round_f32((box->rect.p1.x) - text_dim.x); + result.x = round_f32((box->rect.p1.x) - text_dim.x - box->text_padding); result.x = ClampBot(result.x, box->rect.x0); }break; } - result.x = floorf(result.x); + result.x = floor_f32(result.x); return result; } diff --git a/src/ui/ui_core.h b/src/ui/ui_core.h index 2dc8c391..959b3d36 100644 --- a/src/ui/ui_core.h +++ b/src/ui/ui_core.h @@ -404,7 +404,7 @@ struct UI_Box F_Tag font; F32 font_size; F32 tab_size; - F_RunFlags run_flags; + F_RasterFlags text_raster_flags; F32 corner_radii[Corner_COUNT]; F32 blur_size; F32 transparency; @@ -851,7 +851,7 @@ internal F32 ui_top_squish(void); internal OS_Cursor ui_top_hover_cursor(void); internal F_Tag ui_top_font(void); internal F32 ui_top_font_size(void); -internal F_RunFlags ui_top_run_flags(void); +internal F_RasterFlags ui_top_text_raster_flags(void); internal F32 ui_top_tab_size(void); internal F32 ui_top_corner_radius_00(void); internal F32 ui_top_corner_radius_01(void); @@ -879,7 +879,7 @@ internal F32 ui_bottom_squish(void); internal OS_Cursor ui_bottom_hover_cursor(void); internal F_Tag ui_bottom_font(void); internal F32 ui_bottom_font_size(void); -internal F_RunFlags ui_bottom_run_flags(void); +internal F_RasterFlags ui_bottom_text_raster_flags(void); internal F32 ui_bottom_tab_size(void); internal F32 ui_bottom_corner_radius_00(void); internal F32 ui_bottom_corner_radius_01(void); @@ -907,7 +907,7 @@ internal F32 ui_push_squish(F32 v); internal OS_Cursor ui_push_hover_cursor(OS_Cursor v); internal F_Tag ui_push_font(F_Tag v); internal F32 ui_push_font_size(F32 v); -internal F_RunFlags ui_push_run_flags(F_RunFlags v); +internal F_RasterFlags ui_push_text_raster_flags(F_RasterFlags v); internal F32 ui_push_tab_size(F32 v); internal F32 ui_push_corner_radius_00(F32 v); internal F32 ui_push_corner_radius_01(F32 v); @@ -935,7 +935,7 @@ internal F32 ui_pop_squish(void); internal OS_Cursor ui_pop_hover_cursor(void); internal F_Tag ui_pop_font(void); internal F32 ui_pop_font_size(void); -internal F_RunFlags ui_pop_run_flags(void); +internal F_RasterFlags ui_pop_text_raster_flags(void); internal F32 ui_pop_tab_size(void); internal F32 ui_pop_corner_radius_00(void); internal F32 ui_pop_corner_radius_01(void); @@ -963,7 +963,7 @@ internal F32 ui_set_next_squish(F32 v); internal OS_Cursor ui_set_next_hover_cursor(OS_Cursor v); internal F_Tag ui_set_next_font(F_Tag v); internal F32 ui_set_next_font_size(F32 v); -internal F_RunFlags ui_set_next_run_flags(F_RunFlags v); +internal F_RasterFlags ui_set_next_text_raster_flags(F_RasterFlags v); internal F32 ui_set_next_tab_size(F32 v); internal F32 ui_set_next_corner_radius_00(F32 v); internal F32 ui_set_next_corner_radius_01(F32 v); @@ -1006,7 +1006,7 @@ internal void ui_pop_corner_radius(void); #define UI_HoverCursor(v) DeferLoop(ui_push_hover_cursor(v), ui_pop_hover_cursor()) #define UI_Font(v) DeferLoop(ui_push_font(v), ui_pop_font()) #define UI_FontSize(v) DeferLoop(ui_push_font_size(v), ui_pop_font_size()) -#define UI_RunFlags(v) DeferLoop(ui_push_run_flags(v), ui_pop_run_flags()) +#define UI_TextRasterFlags(v) DeferLoop(ui_push_text_raster_flags(v), ui_pop_text_raster_flags()) #define UI_TabSize(v) DeferLoop(ui_push_tab_size(v), ui_pop_tab_size()) #define UI_CornerRadius00(v) DeferLoop(ui_push_corner_radius_00(v), ui_pop_corner_radius_00()) #define UI_CornerRadius01(v) DeferLoop(ui_push_corner_radius_01(v), ui_pop_corner_radius_01())