Merge remote-tracking branch 'EpicGamesExt/dev' into odin

Had to change odin's slice view rule to odin slice since there is now an offical slice definition.

# Conflicts:
#	src/df/core/df_core.mdesk
#	src/df/core/generated/df_core.meta.c
This commit is contained in:
2024-07-03 21:31:26 -04:00
26 changed files with 1056 additions and 663 deletions
+3 -1
View File
@@ -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)." }
}
////////////////////////////////
+5 -3
View File
@@ -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] =
+3
View File
@@ -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);
+584 -277
View File
File diff suppressed because it is too large Load Diff
+13 -10
View File
@@ -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);
+26 -14
View File
@@ -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)}`
+12 -5
View File
@@ -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;
+121 -53
View File
@@ -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(&params, 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(&params, DF_CmdParamSlot_String);
df_push_cmd__root(&params, 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))
+3 -1
View File
@@ -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
+53 -5
View File
@@ -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
+12 -5
View File
@@ -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,
+14 -153
View File
@@ -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);
}
+2 -6
View File
@@ -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
+17 -19
View File
@@ -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;
}
+5 -6
View File
@@ -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);
+86 -14
View File
@@ -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
{
@@ -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;
+6 -8
View File
@@ -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
+4 -5
View File
@@ -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
+6 -6
View File
@@ -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) }
+13 -13
View File
@@ -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);
+2 -2
View File
@@ -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 }
}
+25 -23
View File
@@ -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;
}
////////////////////////////////
+8 -8
View File
@@ -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
+22 -18
View File
@@ -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<<axis))*floor_f32(root->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;
}
+7 -7
View File
@@ -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())