mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-13 07:32:23 -07:00
f -> fnt
This commit is contained in:
@@ -64,8 +64,8 @@ main_thread_base_entry_point(void (*entry_point)(CmdLine *cmdline), char **argum
|
||||
#if defined(GEO_CACHE_H) && !defined(GEO_INIT_MANUAL)
|
||||
geo_init();
|
||||
#endif
|
||||
#if defined(FONT_CACHE_H) && !defined(F_INIT_MANUAL)
|
||||
f_init();
|
||||
#if defined(FONT_CACHE_H) && !defined(FNT_INIT_MANUAL)
|
||||
fnt_init();
|
||||
#endif
|
||||
#if defined(DF_CORE_H) && !defined(DF_INIT_MANUAL)
|
||||
DF_StateDeltaHistory *hist = df_state_delta_history_alloc();
|
||||
|
||||
+98
-98
@@ -1173,36 +1173,36 @@ df_window_open(Vec2F32 size, OS_Handle preferred_monitor, DF_CfgSrc cfg_src)
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
DF_FontSlot slot = english_font_slots[idx];
|
||||
String8 sample_text = str8_lit("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()-_+=[{]}\\|;:'\",<.>/?");
|
||||
f_push_run_from_string(scratch.arena,
|
||||
df_font_from_slot(slot),
|
||||
df_font_size_from_slot(window, DF_FontSlot_Code),
|
||||
0, 0, 0,
|
||||
sample_text);
|
||||
f_push_run_from_string(scratch.arena,
|
||||
df_font_from_slot(slot),
|
||||
df_font_size_from_slot(window, DF_FontSlot_Main),
|
||||
0, 0, 0,
|
||||
sample_text);
|
||||
fnt_push_run_from_string(scratch.arena,
|
||||
df_font_from_slot(slot),
|
||||
df_font_size_from_slot(window, DF_FontSlot_Code),
|
||||
0, 0, 0,
|
||||
sample_text);
|
||||
fnt_push_run_from_string(scratch.arena,
|
||||
df_font_from_slot(slot),
|
||||
df_font_size_from_slot(window, DF_FontSlot_Main),
|
||||
0, 0, 0,
|
||||
sample_text);
|
||||
scratch_end(scratch);
|
||||
}
|
||||
for(DF_IconKind icon_kind = DF_IconKind_Null; icon_kind < DF_IconKind_COUNT; icon_kind = (DF_IconKind)(icon_kind+1))
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
f_push_run_from_string(scratch.arena,
|
||||
df_font_from_slot(icon_font_slot),
|
||||
df_font_size_from_slot(window, icon_font_slot),
|
||||
0, 0, F_RasterFlag_Smooth,
|
||||
df_g_icon_kind_text_table[icon_kind]);
|
||||
f_push_run_from_string(scratch.arena,
|
||||
df_font_from_slot(icon_font_slot),
|
||||
df_font_size_from_slot(window, DF_FontSlot_Main),
|
||||
0, 0, F_RasterFlag_Smooth,
|
||||
df_g_icon_kind_text_table[icon_kind]);
|
||||
f_push_run_from_string(scratch.arena,
|
||||
df_font_from_slot(icon_font_slot),
|
||||
df_font_size_from_slot(window, DF_FontSlot_Code),
|
||||
0, 0, F_RasterFlag_Smooth,
|
||||
df_g_icon_kind_text_table[icon_kind]);
|
||||
fnt_push_run_from_string(scratch.arena,
|
||||
df_font_from_slot(icon_font_slot),
|
||||
df_font_size_from_slot(window, icon_font_slot),
|
||||
0, 0, FNT_RasterFlag_Smooth,
|
||||
df_g_icon_kind_text_table[icon_kind]);
|
||||
fnt_push_run_from_string(scratch.arena,
|
||||
df_font_from_slot(icon_font_slot),
|
||||
df_font_size_from_slot(window, DF_FontSlot_Main),
|
||||
0, 0, FNT_RasterFlag_Smooth,
|
||||
df_g_icon_kind_text_table[icon_kind]);
|
||||
fnt_push_run_from_string(scratch.arena,
|
||||
df_font_from_slot(icon_font_slot),
|
||||
df_font_size_from_slot(window, DF_FontSlot_Code),
|
||||
0, 0, FNT_RasterFlag_Smooth,
|
||||
df_g_icon_kind_text_table[icon_kind]);
|
||||
scratch_end(scratch);
|
||||
}
|
||||
}
|
||||
@@ -3602,9 +3602,9 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
|
||||
//
|
||||
{
|
||||
// rjf: gather font info
|
||||
F_Tag main_font = df_font_from_slot(DF_FontSlot_Main);
|
||||
FNT_Tag main_font = df_font_from_slot(DF_FontSlot_Main);
|
||||
F32 main_font_size = df_font_size_from_slot(ws, DF_FontSlot_Main);
|
||||
F_Tag icon_font = df_font_from_slot(DF_FontSlot_Icons);
|
||||
FNT_Tag icon_font = df_font_from_slot(DF_FontSlot_Icons);
|
||||
|
||||
// rjf: build icon info
|
||||
UI_IconInfo icon_info = {0};
|
||||
@@ -3650,9 +3650,9 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
|
||||
ui_push_pref_height(ui_em(2.75f, 1.f));
|
||||
ui_push_palette(df_palette_from_code(ws, DF_PaletteCode_Base));
|
||||
ui_push_blur_size(10.f);
|
||||
F_RasterFlags text_raster_flags = 0;
|
||||
if(df_setting_val_from_code(ws, DF_SettingCode_SmoothUIText).s32) {text_raster_flags |= F_RasterFlag_Smooth;}
|
||||
if(df_setting_val_from_code(ws, DF_SettingCode_HintUIText).s32) {text_raster_flags |= F_RasterFlag_Hinted;}
|
||||
FNT_RasterFlags text_raster_flags = 0;
|
||||
if(df_setting_val_from_code(ws, DF_SettingCode_SmoothUIText).s32) {text_raster_flags |= FNT_RasterFlag_Smooth;}
|
||||
if(df_setting_val_from_code(ws, DF_SettingCode_HintUIText).s32) {text_raster_flags |= FNT_RasterFlag_Hinted;}
|
||||
ui_push_text_raster_flags(text_raster_flags);
|
||||
}
|
||||
|
||||
@@ -6356,8 +6356,8 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
|
||||
E_Eval row_eval = e_eval_from_expr(scratch.arena, row->expr);
|
||||
String8 row_expr_string = df_expr_string_from_viz_row(scratch.arena, row);
|
||||
String8 row_display_value = df_value_string_from_eval(scratch.arena, DF_EvalVizStringFlag_ReadOnlyDisplayRules, default_radix, ui_top_font(), ui_top_font_size(), 500.f, row_eval, row->member, row->cfg_table);
|
||||
expr_column_width_px = f_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, 0, row_expr_string).x + ui_top_font_size()*5.f;
|
||||
value_column_width_px = f_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, 0, row_display_value).x + ui_top_font_size()*5.f;
|
||||
expr_column_width_px = fnt_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, 0, row_expr_string).x + ui_top_font_size()*5.f;
|
||||
value_column_width_px = fnt_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, 0, row_display_value).x + ui_top_font_size()*5.f;
|
||||
F32 total_dim_px = (expr_column_width_px + value_column_width_px);
|
||||
width_px = Min(80.f*ui_top_font_size(), total_dim_px*1.5f);
|
||||
}
|
||||
@@ -8128,11 +8128,11 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
|
||||
v4f32(1, 0, 1, 1), 1, 0, 1);
|
||||
}
|
||||
F32 max_x = 100000.f;
|
||||
F_Run ellipses_run = {0};
|
||||
FNT_Run ellipses_run = {0};
|
||||
if(!(box->flags & UI_BoxFlag_DisableTextTrunc))
|
||||
{
|
||||
max_x = (box->rect.x1-text_position.x);
|
||||
ellipses_run = f_push_run_from_string(scratch.arena, box->font, box->font_size, 0, box->tab_size, 0, str8_lit("..."));
|
||||
ellipses_run = fnt_push_run_from_string(scratch.arena, box->font, box->font_size, 0, box->tab_size, 0, str8_lit("..."));
|
||||
}
|
||||
d_truncated_fancy_run_list(text_position, &box->display_string_runs, max_x, ellipses_run);
|
||||
if(box->flags & UI_BoxFlag_HasFuzzyMatchRanges)
|
||||
@@ -8351,11 +8351,11 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
|
||||
#if 1
|
||||
Vec2F32 p = add_2f32(os_mouse_from_window(ws->os), v2f32(30, 0));
|
||||
d_rect(os_client_rect_from_window(ws->os), v4f32(0, 0, 0, 0.9f), 0, 0, 0);
|
||||
F_Run trailer_run = f_push_run_from_string(scratch.arena, df_font_from_slot(DF_FontSlot_Main), 16.f, 0, 0, 0, str8_lit("..."));
|
||||
FNT_Run trailer_run = fnt_push_run_from_string(scratch.arena, df_font_from_slot(DF_FontSlot_Main), 16.f, 0, 0, 0, str8_lit("..."));
|
||||
D_FancyStringList strs = {0};
|
||||
D_FancyString str = {df_font_from_slot(DF_FontSlot_Main), str8_lit("Shift + F5"), v4f32(1, 1, 1, 1), 72.f, 0.f};
|
||||
d_fancy_string_list_push(scratch.arena, &strs, &str);
|
||||
D_FancyRunList runs = d_fancy_run_list_from_fancy_string_list(scratch.arena, 0, F_RasterFlag_Smooth, &strs);
|
||||
D_FancyRunList runs = d_fancy_run_list_from_fancy_string_list(scratch.arena, 0, FNT_RasterFlag_Smooth, &strs);
|
||||
d_truncated_fancy_run_list(p, &runs, 1000000.f, trailer_run);
|
||||
d_rect(r2f32(p, add_2f32(p, runs.dim)), v4f32(1, 0, 0, 0.5f), 0, 1, 0);
|
||||
d_rect(r2f32(sub_2f32(p, v2f32(4, 4)), add_2f32(p, v2f32(4, 4))), v4f32(1, 0, 1, 1), 0, 0, 0);
|
||||
@@ -8370,7 +8370,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
|
||||
D_FancyString str3 = {df_font_from_slot(DF_FontSlot_Code), str8_lit("very fancy text!"), v4f32(1, 0.8f, 0.4f, 1), 18.f, 4.f, 4.f};
|
||||
d_fancy_string_list_push(scratch.arena, &strs, &str3);
|
||||
D_FancyRunList runs = d_fancy_run_list_from_fancy_string_list(scratch.arena, 0, 0, &strs);
|
||||
F_Run trailer_run = f_push_run_from_string(scratch.arena, df_font_from_slot(DF_FontSlot_Main), 16.f, 0, 0, 0, str8_lit("..."));
|
||||
FNT_Run trailer_run = fnt_push_run_from_string(scratch.arena, df_font_from_slot(DF_FontSlot_Main), 16.f, 0, 0, 0, str8_lit("..."));
|
||||
F32 limit = 500.f + sin_f32(df_time_in_seconds()/10.f)*200.f;
|
||||
d_truncated_fancy_run_list(p, &runs, limit, trailer_run);
|
||||
d_rect(r2f32p(p.x+limit, 0, p.x+limit+2.f, 1000), v4f32(1, 0, 0, 1), 0, 0, 0);
|
||||
@@ -8397,7 +8397,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
|
||||
//~ rjf: Eval Viz
|
||||
|
||||
internal F32
|
||||
df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32 default_radix, F_Tag font, F32 font_size, F32 max_size, S32 depth, E_Eval eval, E_Member *member, DF_CfgTable *cfg_table, String8List *out)
|
||||
df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32 default_radix, FNT_Tag font, F32 font_size, F32 max_size, S32 depth, E_Eval eval, E_Member *member, DF_CfgTable *cfg_table, String8List *out)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
@@ -8443,7 +8443,7 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32
|
||||
{
|
||||
E_Eval value_eval = e_value_eval_from_eval(eval);
|
||||
String8 string = df_string_from_simple_typed_eval(arena, flags, radix, value_eval);
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, string).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, string).x;
|
||||
str8_list_push(arena, out, string);
|
||||
}break;
|
||||
|
||||
@@ -8494,8 +8494,8 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32
|
||||
case 4: {string = str8_from_32(arena, str32_cstring((U32 *)string_buffer));}break;
|
||||
}
|
||||
String8 string_escaped = df_escaped_from_raw_string(arena, string);
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, string_escaped).x;
|
||||
space_taken += 2*f_dim_from_tag_size_string(font, font_size, 0, 0, str8_lit("\"")).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, string_escaped).x;
|
||||
space_taken += 2*fnt_dim_from_tag_size_string(font, font_size, 0, 0, str8_lit("\"")).x;
|
||||
str8_list_push(arena, out, str8_lit("\""));
|
||||
str8_list_push(arena, out, string_escaped);
|
||||
str8_list_push(arena, out, str8_lit("\""));
|
||||
@@ -8509,7 +8509,7 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32
|
||||
{
|
||||
did_content = 1;
|
||||
str8_list_push(arena, out, symbol_name);
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, symbol_name).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, symbol_name).x;
|
||||
}
|
||||
|
||||
// rjf: special case: need symbol name, don't have one
|
||||
@@ -8521,7 +8521,7 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32
|
||||
did_content = 1;
|
||||
String8 string = str8_lit("???");
|
||||
str8_list_push(arena, out, string);
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, string).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, string).x;
|
||||
}
|
||||
|
||||
// rjf: descend for all other cases
|
||||
@@ -8538,7 +8538,7 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32
|
||||
{
|
||||
String8 ellipses = str8_lit("...");
|
||||
str8_list_push(arena, out, ellipses);
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, ellipses).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, ellipses).x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8550,16 +8550,16 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32
|
||||
if(did_content)
|
||||
{
|
||||
String8 ptr_prefix = str8_lit(" (");
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, ptr_prefix).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, ptr_prefix).x;
|
||||
str8_list_push(arena, out, ptr_prefix);
|
||||
}
|
||||
String8 string = df_string_from_simple_typed_eval(arena, flags, radix, value_eval);
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, string).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, string).x;
|
||||
str8_list_push(arena, out, string);
|
||||
if(did_content)
|
||||
{
|
||||
String8 close = str8_lit(")");
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, close).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, close).x;
|
||||
str8_list_push(arena, out, close);
|
||||
}
|
||||
}
|
||||
@@ -8615,8 +8615,8 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32
|
||||
case 4: {string = str8_from_32(arena, str32_cstring((U32 *)string_buffer));}break;
|
||||
}
|
||||
String8 string_escaped = df_escaped_from_raw_string(arena, string);
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, string_escaped).x;
|
||||
space_taken += 2*f_dim_from_tag_size_string(font, font_size, 0, 0, str8_lit("\"")).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, string_escaped).x;
|
||||
space_taken += 2*fnt_dim_from_tag_size_string(font, font_size, 0, 0, str8_lit("\"")).x;
|
||||
str8_list_push(arena, out, str8_lit("\""));
|
||||
str8_list_push(arena, out, string_escaped);
|
||||
str8_list_push(arena, out, str8_lit("\""));
|
||||
@@ -8631,7 +8631,7 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32
|
||||
{
|
||||
String8 bracket = str8_lit("[");
|
||||
str8_list_push(arena, out, bracket);
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, bracket).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, bracket).x;
|
||||
}
|
||||
|
||||
// rjf: build contents
|
||||
@@ -8645,13 +8645,13 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32
|
||||
if(idx+1 < array_count)
|
||||
{
|
||||
String8 comma = str8_lit(", ");
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, comma).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, comma).x;
|
||||
str8_list_push(arena, out, comma);
|
||||
}
|
||||
if(space_taken > max_size && idx+1 < array_count)
|
||||
{
|
||||
String8 ellipses = str8_lit("...");
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, ellipses).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, ellipses).x;
|
||||
str8_list_push(arena, out, ellipses);
|
||||
}
|
||||
}
|
||||
@@ -8660,14 +8660,14 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32
|
||||
{
|
||||
String8 ellipses = str8_lit("...");
|
||||
str8_list_push(arena, out, ellipses);
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, ellipses).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, ellipses).x;
|
||||
}
|
||||
|
||||
// rjf: ]
|
||||
{
|
||||
String8 bracket = str8_lit("]");
|
||||
str8_list_push(arena, out, bracket);
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, bracket).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, bracket).x;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
@@ -8684,7 +8684,7 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32
|
||||
{
|
||||
String8 brace = str8_lit("{");
|
||||
str8_list_push(arena, out, brace);
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, brace).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, brace).x;
|
||||
}
|
||||
|
||||
// rjf: content
|
||||
@@ -8701,13 +8701,13 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32
|
||||
if(member_idx+1 < filtered_data_members.count)
|
||||
{
|
||||
String8 comma = str8_lit(", ");
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, comma).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, comma).x;
|
||||
str8_list_push(arena, out, comma);
|
||||
}
|
||||
if(space_taken > max_size && member_idx+1 < filtered_data_members.count)
|
||||
{
|
||||
String8 ellipses = str8_lit("...");
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, ellipses).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, ellipses).x;
|
||||
str8_list_push(arena, out, ellipses);
|
||||
}
|
||||
}
|
||||
@@ -8716,14 +8716,14 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32
|
||||
{
|
||||
String8 ellipses = str8_lit("...");
|
||||
str8_list_push(arena, out, ellipses);
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, ellipses).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, ellipses).x;
|
||||
}
|
||||
|
||||
// rjf: close brace
|
||||
{
|
||||
String8 brace = str8_lit("}");
|
||||
str8_list_push(arena, out, brace);
|
||||
space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, brace).x;
|
||||
space_taken += fnt_dim_from_tag_size_string(font, font_size, 0, 0, brace).x;
|
||||
}
|
||||
}break;
|
||||
}
|
||||
@@ -8734,7 +8734,7 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32
|
||||
}
|
||||
|
||||
internal String8
|
||||
df_value_string_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32 default_radix, F_Tag font, F32 font_size, F32 max_size, E_Eval eval, E_Member *member, DF_CfgTable *cfg_table)
|
||||
df_value_string_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32 default_radix, FNT_Tag font, F32 font_size, F32 max_size, E_Eval eval, E_Member *member, DF_CfgTable *cfg_table)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
String8List strs = {0};
|
||||
@@ -9213,10 +9213,10 @@ df_palette_from_code(DF_Window *ws, DF_PaletteCode code)
|
||||
|
||||
//- rjf: fonts/sizes
|
||||
|
||||
internal F_Tag
|
||||
internal FNT_Tag
|
||||
df_font_from_slot(DF_FontSlot slot)
|
||||
{
|
||||
F_Tag result = df_gfx_state->cfg_font_tags[slot];
|
||||
FNT_Tag result = df_gfx_state->cfg_font_tags[slot];
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -9258,16 +9258,16 @@ df_font_size_from_slot(DF_Window *ws, DF_FontSlot slot)
|
||||
return result;
|
||||
}
|
||||
|
||||
internal F_RasterFlags
|
||||
internal FNT_RasterFlags
|
||||
df_raster_flags_from_slot(DF_Window *ws, DF_FontSlot slot)
|
||||
{
|
||||
F_RasterFlags flags = F_RasterFlag_Smooth|F_RasterFlag_Hinted;
|
||||
FNT_RasterFlags flags = FNT_RasterFlag_Smooth|FNT_RasterFlag_Hinted;
|
||||
switch(slot)
|
||||
{
|
||||
default:{}break;
|
||||
case DF_FontSlot_Icons:{flags = F_RasterFlag_Smooth;}break;
|
||||
case DF_FontSlot_Main: {flags = (!!df_setting_val_from_code(ws, DF_SettingCode_SmoothUIText).s32*F_RasterFlag_Smooth)|(!!df_setting_val_from_code(ws, DF_SettingCode_HintUIText).s32*F_RasterFlag_Hinted);}break;
|
||||
case DF_FontSlot_Code: {flags = (!!df_setting_val_from_code(ws, DF_SettingCode_SmoothCodeText).s32*F_RasterFlag_Smooth)|(!!df_setting_val_from_code(ws, DF_SettingCode_HintCodeText).s32*F_RasterFlag_Hinted);}break;
|
||||
case DF_FontSlot_Icons:{flags = FNT_RasterFlag_Smooth;}break;
|
||||
case DF_FontSlot_Main: {flags = (!!df_setting_val_from_code(ws, DF_SettingCode_SmoothUIText).s32*FNT_RasterFlag_Smooth)|(!!df_setting_val_from_code(ws, DF_SettingCode_HintUIText).s32*FNT_RasterFlag_Hinted);}break;
|
||||
case DF_FontSlot_Code: {flags = (!!df_setting_val_from_code(ws, DF_SettingCode_SmoothCodeText).s32*FNT_RasterFlag_Smooth)|(!!df_setting_val_from_code(ws, DF_SettingCode_HintCodeText).s32*FNT_RasterFlag_Hinted);}break;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
@@ -10674,7 +10674,7 @@ internal UI_BOX_CUSTOM_DRAW(df_thread_box_draw_extensions)
|
||||
F32 lock_icon_off = ui_top_font_size()*0.2f;
|
||||
Vec4F32 lock_icon_color = df_rgba_from_theme_color(DF_ThemeColor_TextNegative);
|
||||
d_text(df_font_from_slot(DF_FontSlot_Icons),
|
||||
box->font_size, 0, 0, F_RasterFlag_Smooth,
|
||||
box->font_size, 0, 0, FNT_RasterFlag_Smooth,
|
||||
v2f32((box->rect.x0 + box->rect.x1)/2 + lock_icon_off/2,
|
||||
box->rect.y0 + lock_icon_off/2),
|
||||
lock_icon_color,
|
||||
@@ -10726,11 +10726,11 @@ internal UI_BOX_CUSTOM_DRAW(df_bp_box_draw_extensions)
|
||||
if(u->remap_px_delta != 0)
|
||||
{
|
||||
F32 remap_px_delta = u->remap_px_delta;
|
||||
F32 circle_advance = f_dim_from_tag_size_string(box->font, box->font_size, 0, 0, df_g_icon_kind_text_table[DF_IconKind_CircleFilled]).x;
|
||||
F32 circle_advance = fnt_dim_from_tag_size_string(box->font, box->font_size, 0, 0, df_g_icon_kind_text_table[DF_IconKind_CircleFilled]).x;
|
||||
Vec2F32 bp_text_pos = ui_box_text_position(box);
|
||||
Vec2F32 bp_center = v2f32(bp_text_pos.x + circle_advance/2, bp_text_pos.y);
|
||||
F_Metrics icon_font_metrics = f_metrics_from_tag_size(box->font, box->font_size);
|
||||
F32 icon_font_line_height = f_line_height_from_metrics(&icon_font_metrics);
|
||||
FNT_Metrics icon_font_metrics = fnt_metrics_from_tag_size(box->font, box->font_size);
|
||||
F32 icon_font_line_height = fnt_line_height_from_metrics(&icon_font_metrics);
|
||||
F32 remap_bar_thickness = 0.3f*ui_top_font_size();
|
||||
Vec4F32 remap_color = u->color;
|
||||
remap_color.w *= 0.3f;
|
||||
@@ -10739,7 +10739,7 @@ internal UI_BOX_CUSTOM_DRAW(df_bp_box_draw_extensions)
|
||||
bp_center.x + remap_bar_thickness,
|
||||
bp_center.y + ClampBot(remap_px_delta, 0) - remap_bar_thickness),
|
||||
remap_color, 2.f, 0, 1.f);
|
||||
d_text(box->font, box->font_size, 0, 0, F_RasterFlag_Smooth,
|
||||
d_text(box->font, box->font_size, 0, 0, FNT_RasterFlag_Smooth,
|
||||
v2f32(bp_text_pos.x,
|
||||
bp_center.y + remap_px_delta),
|
||||
remap_color,
|
||||
@@ -10892,7 +10892,7 @@ df_code_slice(DF_Window *ws, DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *m
|
||||
ui_set_next_hover_cursor(OS_Cursor_UpDownLeftRight);
|
||||
ui_set_next_font(df_font_from_slot(DF_FontSlot_Icons));
|
||||
ui_set_next_font_size(params->font_size);
|
||||
ui_set_next_text_raster_flags(F_RasterFlag_Smooth);
|
||||
ui_set_next_text_raster_flags(FNT_RasterFlag_Smooth);
|
||||
ui_set_next_pref_width(ui_pct(1, 0));
|
||||
ui_set_next_pref_height(ui_pct(1, 0));
|
||||
ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = color));
|
||||
@@ -11049,7 +11049,7 @@ df_code_slice(DF_Window *ws, DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *m
|
||||
ui_set_next_hover_cursor(OS_Cursor_UpDownLeftRight);
|
||||
ui_set_next_font(df_font_from_slot(DF_FontSlot_Icons));
|
||||
ui_set_next_font_size(params->font_size);
|
||||
ui_set_next_text_raster_flags(F_RasterFlag_Smooth);
|
||||
ui_set_next_text_raster_flags(FNT_RasterFlag_Smooth);
|
||||
ui_set_next_pref_width(ui_pct(1, 0));
|
||||
ui_set_next_pref_height(ui_pct(1, 0));
|
||||
ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = color));
|
||||
@@ -11170,7 +11170,7 @@ df_code_slice(DF_Window *ws, DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *m
|
||||
// rjf: build box for breakpoint
|
||||
ui_set_next_font(df_font_from_slot(DF_FontSlot_Icons));
|
||||
ui_set_next_font_size(params->font_size * 1.f);
|
||||
ui_set_next_text_raster_flags(F_RasterFlag_Smooth);
|
||||
ui_set_next_text_raster_flags(FNT_RasterFlag_Smooth);
|
||||
ui_set_next_hover_cursor(OS_Cursor_HandPoint);
|
||||
ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = bp_color));
|
||||
ui_set_next_text_alignment(UI_TextAlign_Center);
|
||||
@@ -11231,7 +11231,7 @@ df_code_slice(DF_Window *ws, DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *m
|
||||
// rjf: build box for watch
|
||||
ui_set_next_font(df_font_from_slot(DF_FontSlot_Icons));
|
||||
ui_set_next_font_size(params->font_size * 1.f);
|
||||
ui_set_next_text_raster_flags(F_RasterFlag_Smooth);
|
||||
ui_set_next_text_raster_flags(FNT_RasterFlag_Smooth);
|
||||
ui_set_next_hover_cursor(OS_Cursor_HandPoint);
|
||||
ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = color));
|
||||
ui_set_next_text_alignment(UI_TextAlign_Center);
|
||||
@@ -11385,7 +11385,7 @@ df_code_slice(DF_Window *ws, DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *m
|
||||
line_num += 1, line_idx += 1)
|
||||
{
|
||||
String8 line_text = params->line_text[line_idx];
|
||||
F32 line_text_dim = f_dim_from_tag_size_string(params->font, params->font_size, 0, params->tab_size, line_text).x + params->line_num_width_px;
|
||||
F32 line_text_dim = fnt_dim_from_tag_size_string(params->font, params->font_size, 0, params->tab_size, line_text).x + params->line_num_width_px;
|
||||
line_extras_off[line_idx] = Max(line_text_dim, params->font_size*50);
|
||||
}
|
||||
}
|
||||
@@ -11533,7 +11533,7 @@ df_code_slice(DF_Window *ws, DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *m
|
||||
String8 line_string = (params->line_num_range.min <= line_num && line_num <= params->line_num_range.max) ? (params->line_text[mouse_y_line_idx]) : str8_zero();
|
||||
|
||||
// rjf: mouse x * string => column
|
||||
S64 column = f_char_pos_from_tag_size_string_p(params->font, params->font_size, 0, params->tab_size, line_string, mouse.x-text_container_box->rect.x0-params->line_num_width_px-line_num_padding_px)+1;
|
||||
S64 column = fnt_char_pos_from_tag_size_string_p(params->font, params->font_size, 0, params->tab_size, line_string, mouse.x-text_container_box->rect.x0-params->line_num_width_px-line_num_padding_px)+1;
|
||||
|
||||
// rjf: bundle
|
||||
mouse_pt = txt_pt(line_num, column);
|
||||
@@ -11737,7 +11737,7 @@ df_code_slice(DF_Window *ws, DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *m
|
||||
{
|
||||
U64 line_slice_idx = mouse_pt.line-params->line_num_range.min;
|
||||
String8 line_text = params->line_text[line_slice_idx];
|
||||
F32 expr_hoff_px = params->line_num_width_px + f_dim_from_tag_size_string(params->font, params->font_size, 0, params->tab_size, str8_prefix(line_text, selected_rng.min.column-1)).x;
|
||||
F32 expr_hoff_px = params->line_num_width_px + fnt_dim_from_tag_size_string(params->font, params->font_size, 0, params->tab_size, str8_prefix(line_text, selected_rng.min.column-1)).x;
|
||||
result.mouse_expr_rng = mouse_expr_rng = selected_rng;
|
||||
result.mouse_expr_baseline_pos = mouse_expr_baseline_pos = v2f32(text_container_box->rect.x0+expr_hoff_px,
|
||||
text_container_box->rect.y0+line_slice_idx*params->line_height_px + params->line_height_px*0.85f);
|
||||
@@ -11754,7 +11754,7 @@ df_code_slice(DF_Window *ws, DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *m
|
||||
Rng1U64 expr_off_rng = txt_expr_off_range_from_line_off_range_string_tokens(mouse_pt_off, line_range, line_text, &line_tokens);
|
||||
if(expr_off_rng.max != expr_off_rng.min)
|
||||
{
|
||||
F32 expr_hoff_px = params->line_num_width_px + f_dim_from_tag_size_string(params->font, params->font_size, 0, params->tab_size, str8_prefix(line_text, expr_off_rng.min-line_range.min)).x;
|
||||
F32 expr_hoff_px = params->line_num_width_px + fnt_dim_from_tag_size_string(params->font, params->font_size, 0, params->tab_size, str8_prefix(line_text, expr_off_rng.min-line_range.min)).x;
|
||||
result.mouse_expr_rng = mouse_expr_rng = txt_rng(txt_pt(mouse_pt.line, 1+(expr_off_rng.min-line_range.min)), txt_pt(mouse_pt.line, 1+(expr_off_rng.max-line_range.min)));
|
||||
result.mouse_expr_baseline_pos = mouse_expr_baseline_pos = v2f32(text_container_box->rect.x0+expr_hoff_px,
|
||||
text_container_box->rect.y0+line_slice_idx*params->line_height_px + params->line_height_px*0.85f);
|
||||
@@ -12055,8 +12055,8 @@ df_code_slice(DF_Window *ws, DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *m
|
||||
Rng1U64 match_range = r1u64(needle_pos, needle_pos+params->search_query.size);
|
||||
Rng1F32 match_column_pixel_off_range =
|
||||
{
|
||||
f_dim_from_tag_size_string(line_box->font, line_box->font_size, 0, params->tab_size, str8_prefix(line_string, match_range.min)).x,
|
||||
f_dim_from_tag_size_string(line_box->font, line_box->font_size, 0, params->tab_size, str8_prefix(line_string, match_range.max)).x,
|
||||
fnt_dim_from_tag_size_string(line_box->font, line_box->font_size, 0, params->tab_size, str8_prefix(line_string, match_range.min)).x,
|
||||
fnt_dim_from_tag_size_string(line_box->font, line_box->font_size, 0, params->tab_size, str8_prefix(line_string, match_range.max)).x,
|
||||
};
|
||||
Rng2F32 match_rect =
|
||||
{
|
||||
@@ -12110,8 +12110,8 @@ df_code_slice(DF_Window *ws, DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *m
|
||||
};
|
||||
Rng1F32 select_column_pixel_off_range =
|
||||
{
|
||||
f_dim_from_tag_size_string(line_box->font, line_box->font_size, 0, params->tab_size, str8_prefix(line_string, select_column_range_in_line.min-1)).x,
|
||||
f_dim_from_tag_size_string(line_box->font, line_box->font_size, 0, params->tab_size, str8_prefix(line_string, select_column_range_in_line.max-1)).x,
|
||||
fnt_dim_from_tag_size_string(line_box->font, line_box->font_size, 0, params->tab_size, str8_prefix(line_string, select_column_range_in_line.min-1)).x,
|
||||
fnt_dim_from_tag_size_string(line_box->font, line_box->font_size, 0, params->tab_size, str8_prefix(line_string, select_column_range_in_line.max-1)).x,
|
||||
};
|
||||
Rng2F32 select_rect =
|
||||
{
|
||||
@@ -12139,7 +12139,7 @@ df_code_slice(DF_Window *ws, DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *m
|
||||
if(cursor->line == line_num)
|
||||
{
|
||||
S64 column = cursor->column;
|
||||
Vec2F32 advance = f_dim_from_tag_size_string(line_box->font, line_box->font_size, 0, params->tab_size, str8_prefix(line_string, column-1));
|
||||
Vec2F32 advance = fnt_dim_from_tag_size_string(line_box->font, line_box->font_size, 0, params->tab_size, str8_prefix(line_string, column-1));
|
||||
F32 cursor_off_pixels = advance.x;
|
||||
F32 cursor_thickness = ClampBot(4.f, line_box->font_size/6.f);
|
||||
Rng2F32 cursor_rect =
|
||||
@@ -12463,7 +12463,7 @@ df_error_label(String8 string)
|
||||
UI_Parent(box) UI_Palette(ui_build_palette(ui_top_palette(), .text = df_rgba_from_theme_color(DF_ThemeColor_TextNegative), .text_weak = df_rgba_from_theme_color(DF_ThemeColor_TextNegative)))
|
||||
{
|
||||
ui_set_next_font(df_font_from_slot(DF_FontSlot_Icons));
|
||||
ui_set_next_text_raster_flags(F_RasterFlag_Smooth);
|
||||
ui_set_next_text_raster_flags(FNT_RasterFlag_Smooth);
|
||||
ui_set_next_text_alignment(UI_TextAlign_Center);
|
||||
ui_set_next_flags(UI_BoxFlag_DrawTextWeak);
|
||||
UI_PrefWidth(ui_em(2.25f, 1.f)) ui_label(df_g_icon_kind_text_table[DF_IconKind_WarningBig]);
|
||||
@@ -12485,7 +12485,7 @@ df_help_label(String8 string)
|
||||
{
|
||||
result = 1;
|
||||
ui_set_next_font(df_font_from_slot(DF_FontSlot_Icons));
|
||||
ui_set_next_text_raster_flags(F_RasterFlag_Smooth);
|
||||
ui_set_next_text_raster_flags(FNT_RasterFlag_Smooth);
|
||||
ui_set_next_text_alignment(UI_TextAlign_Center);
|
||||
UI_Box *help_hoverer = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DrawBorder|UI_BoxFlag_DrawHotEffects, "###help_hoverer_%S", string);
|
||||
ui_box_equip_display_string(help_hoverer, df_g_icon_kind_text_table[DF_IconKind_QuestionMark]);
|
||||
@@ -12946,7 +12946,7 @@ df_line_edit(DF_Window *ws, DF_LineEditFlags flags, S32 depth, FuzzyMatchRangeLi
|
||||
{
|
||||
String8 edit_string = str8(edit_buffer, edit_string_size_out[0]);
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
F32 total_text_width = f_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), edit_string).x;
|
||||
F32 total_text_width = fnt_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), edit_string).x;
|
||||
F32 total_editstr_width = total_text_width - !!(flags & (DF_LineEditFlag_Expander|DF_LineEditFlag_ExpanderSpace|DF_LineEditFlag_ExpanderPlaceholder)) * expander_size_px;
|
||||
ui_set_next_pref_width(ui_px(total_editstr_width+ui_top_font_size()*2, 0.f));
|
||||
UI_Box *editstr_box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DisableTextTrunc, "###editstr");
|
||||
@@ -13022,13 +13022,13 @@ df_line_edit(DF_Window *ws, DF_LineEditFlags flags, S32 depth, FuzzyMatchRangeLi
|
||||
draw_data->mark = *mark;
|
||||
ui_box_equip_custom_draw(editstr_box, ui_line_edit_draw, draw_data);
|
||||
mouse_pt = txt_pt(1, 1+ui_box_char_pos_from_xy(editstr_box, ui_mouse()));
|
||||
cursor_off = f_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), str8_prefix(edit_string, cursor->column-1)).x;
|
||||
cursor_off = fnt_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), str8_prefix(edit_string, cursor->column-1)).x;
|
||||
scratch_end(scratch);
|
||||
}
|
||||
else if((is_focus_active || is_focus_active_disabled) && !(flags & DF_LineEditFlag_CodeContents))
|
||||
{
|
||||
String8 edit_string = str8(edit_buffer, edit_string_size_out[0]);
|
||||
F32 total_text_width = f_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), edit_string).x;
|
||||
F32 total_text_width = fnt_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), edit_string).x;
|
||||
F32 total_editstr_width = total_text_width - !!(flags & (DF_LineEditFlag_Expander|DF_LineEditFlag_ExpanderSpace|DF_LineEditFlag_ExpanderPlaceholder)) * expander_size_px;
|
||||
ui_set_next_pref_width(ui_px(total_editstr_width+ui_top_font_size()*2, 0.f));
|
||||
UI_Box *editstr_box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DisableTextTrunc, "###editstr");
|
||||
@@ -13039,7 +13039,7 @@ df_line_edit(DF_Window *ws, DF_LineEditFlags flags, S32 depth, FuzzyMatchRangeLi
|
||||
ui_box_equip_display_string(editstr_box, edit_string);
|
||||
ui_box_equip_custom_draw(editstr_box, ui_line_edit_draw, draw_data);
|
||||
mouse_pt = txt_pt(1, 1+ui_box_char_pos_from_xy(editstr_box, ui_mouse()));
|
||||
cursor_off = f_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), str8_prefix(edit_string, cursor->column-1)).x;
|
||||
cursor_off = fnt_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), str8_prefix(edit_string, cursor->column-1)).x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13501,11 +13501,11 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
|
||||
|
||||
//- rjf: apply fonts
|
||||
{
|
||||
F_Tag defaults[DF_FontSlot_COUNT] =
|
||||
FNT_Tag defaults[DF_FontSlot_COUNT] =
|
||||
{
|
||||
f_tag_from_static_data_string(&df_g_default_main_font_bytes),
|
||||
f_tag_from_static_data_string(&df_g_default_code_font_bytes),
|
||||
f_tag_from_static_data_string(&df_g_icon_font_bytes),
|
||||
fnt_tag_from_static_data_string(&df_g_default_main_font_bytes),
|
||||
fnt_tag_from_static_data_string(&df_g_default_code_font_bytes),
|
||||
fnt_tag_from_static_data_string(&df_g_icon_font_bytes),
|
||||
};
|
||||
MemoryZeroArray(df_gfx_state->cfg_font_tags);
|
||||
{
|
||||
@@ -13529,16 +13529,16 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
|
||||
String8 main_font_path = path_absolute_dst_from_relative_dst_src(scratch.arena, main_font_relative_path, cfg_folder);
|
||||
if(os_file_path_exists(code_font_path) && !md_node_is_nil(code_font_node) && code_font_relative_path.size != 0)
|
||||
{
|
||||
df_gfx_state->cfg_font_tags[DF_FontSlot_Code] = f_tag_from_path(code_font_path);
|
||||
df_gfx_state->cfg_font_tags[DF_FontSlot_Code] = fnt_tag_from_path(code_font_path);
|
||||
}
|
||||
if(os_file_path_exists(main_font_path) && !md_node_is_nil(main_font_node) && main_font_relative_path.size != 0)
|
||||
{
|
||||
df_gfx_state->cfg_font_tags[DF_FontSlot_Main] = f_tag_from_path(main_font_path);
|
||||
df_gfx_state->cfg_font_tags[DF_FontSlot_Main] = fnt_tag_from_path(main_font_path);
|
||||
}
|
||||
}
|
||||
for(DF_FontSlot slot = (DF_FontSlot)0; slot < DF_FontSlot_COUNT; slot = (DF_FontSlot)(slot+1))
|
||||
{
|
||||
if(f_tag_match(f_tag_zero(), df_gfx_state->cfg_font_tags[slot]))
|
||||
if(fnt_tag_match(fnt_tag_zero(), df_gfx_state->cfg_font_tags[slot]))
|
||||
{
|
||||
df_gfx_state->cfg_font_tags[slot] = defaults[slot];
|
||||
}
|
||||
|
||||
+6
-6
@@ -469,7 +469,7 @@ struct DF_CodeSliceParams
|
||||
DI_KeyList relevant_dbgi_keys;
|
||||
|
||||
// rjf: visual parameters
|
||||
F_Tag font;
|
||||
FNT_Tag font;
|
||||
F32 font_size;
|
||||
F32 tab_size;
|
||||
String8 search_query;
|
||||
@@ -804,7 +804,7 @@ 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
|
||||
FNT_Tag cfg_font_tags[DF_FontSlot_COUNT]; // derivative from font paths
|
||||
|
||||
// rjf: global settings
|
||||
DF_SettingVal cfg_setting_vals[DF_CfgSrc_COUNT][DF_SettingCode_COUNT];
|
||||
@@ -1009,8 +1009,8 @@ internal void df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdLis
|
||||
////////////////////////////////
|
||||
//~ rjf: Eval Viz
|
||||
|
||||
internal F32 df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32 default_radix, F_Tag font, F32 font_size, F32 max_size, S32 depth, E_Eval eval, E_Member *member, DF_CfgTable *cfg_table, String8List *out);
|
||||
internal String8 df_value_string_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32 default_radix, F_Tag font, F32 font_size, F32 max_size, E_Eval eval, E_Member *member, DF_CfgTable *cfg_table);
|
||||
internal F32 df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32 default_radix, FNT_Tag font, F32 font_size, F32 max_size, S32 depth, E_Eval eval, E_Member *member, DF_CfgTable *cfg_table, String8List *out);
|
||||
internal String8 df_value_string_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32 default_radix, FNT_Tag font, F32 font_size, F32 max_size, E_Eval eval, E_Member *member, DF_CfgTable *cfg_table);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Hover Eval
|
||||
@@ -1055,9 +1055,9 @@ internal DF_ThemeColor df_theme_color_from_txt_token_kind(TXT_TokenKind kind);
|
||||
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 FNT_Tag df_font_from_slot(DF_FontSlot slot);
|
||||
internal F32 df_font_size_from_slot(DF_Window *ws, DF_FontSlot slot);
|
||||
internal F_RasterFlags df_raster_flags_from_slot(DF_Window *ws, DF_FontSlot slot);
|
||||
internal FNT_RasterFlags df_raster_flags_from_slot(DF_Window *ws, DF_FontSlot slot);
|
||||
|
||||
//- rjf: settings
|
||||
internal DF_SettingVal df_setting_val_from_code(DF_Window *optional_window, DF_SettingCode code);
|
||||
|
||||
+18
-18
@@ -78,12 +78,12 @@ df_code_view_build(Arena *arena, DF_Window *ws, DF_Panel *panel, DF_View *view,
|
||||
//////////////////////////////
|
||||
//- rjf: extract invariants
|
||||
//
|
||||
F_Tag code_font = df_font_from_slot(DF_FontSlot_Code);
|
||||
FNT_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(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;
|
||||
F32 code_tab_size = fnt_column_size_from_tag_size(code_font, code_font_size)*df_setting_val_from_code(ws, DF_SettingCode_TabWidth).s32;
|
||||
FNT_Metrics code_font_metrics = fnt_metrics_from_tag_size(code_font, code_font_size);
|
||||
F32 code_line_height = ceil_f32(fnt_line_height_from_metrics(&code_font_metrics) * 1.5f);
|
||||
F32 big_glyph_advance = fnt_dim_from_tag_size_string(code_font, code_font_size, 0, 0, str8_lit("H")).x;
|
||||
Vec2F32 panel_box_dim = dim_2f32(rect);
|
||||
F32 scroll_bar_dim = floor_f32(ui_top_font_size()*1.5f);
|
||||
Vec2F32 code_area_dim = v2f32(panel_box_dim.x - scroll_bar_dim, panel_box_dim.y - scroll_bar_dim);
|
||||
@@ -619,7 +619,7 @@ df_code_view_build(Arena *arena, DF_Window *ws, DF_Panel *panel, DF_View *view,
|
||||
{
|
||||
cv->center_cursor = 0;
|
||||
String8 cursor_line = str8_substr(text_data, text_info->lines_ranges[df_interact_regs()->cursor.line-1]);
|
||||
F32 cursor_advance = f_dim_from_tag_size_string(code_font, code_font_size, 0, code_tab_size, str8_prefix(cursor_line, df_interact_regs()->cursor.column-1)).x;
|
||||
F32 cursor_advance = fnt_dim_from_tag_size_string(code_font, code_font_size, 0, code_tab_size, str8_prefix(cursor_line, df_interact_regs()->cursor.column-1)).x;
|
||||
|
||||
// rjf: scroll x
|
||||
{
|
||||
@@ -642,7 +642,7 @@ df_code_view_build(Arena *arena, DF_Window *ws, DF_Panel *panel, DF_View *view,
|
||||
if(snap[Axis2_X])
|
||||
{
|
||||
String8 cursor_line = str8_substr(text_data, text_info->lines_ranges[df_interact_regs()->cursor.line-1]);
|
||||
S64 cursor_off = (S64)(f_dim_from_tag_size_string(code_font, code_font_size, 0, code_tab_size, str8_prefix(cursor_line, df_interact_regs()->cursor.column-1)).x + priority_margin_width_px + catchall_margin_width_px + line_num_width_px);
|
||||
S64 cursor_off = (S64)(fnt_dim_from_tag_size_string(code_font, code_font_size, 0, code_tab_size, str8_prefix(cursor_line, df_interact_regs()->cursor.column-1)).x + priority_margin_width_px + catchall_margin_width_px + line_num_width_px);
|
||||
Rng1S64 visible_pixel_range =
|
||||
{
|
||||
view->scroll_pos.x.idx,
|
||||
@@ -830,7 +830,7 @@ df_tbl_from_watch_view_point(DF_EvalVizBlockList *blocks, DF_WatchViewPoint pt)
|
||||
//- rjf: table coordinates -> strings
|
||||
|
||||
internal String8
|
||||
df_string_from_eval_viz_row_column(Arena *arena, DF_EvalView *ev, DF_EvalVizRow *row, DF_WatchViewColumn *col, B32 editable, U32 default_radix, F_Tag font, F32 font_size, F32 max_size_px)
|
||||
df_string_from_eval_viz_row_column(Arena *arena, DF_EvalView *ev, DF_EvalVizRow *row, DF_WatchViewColumn *col, B32 editable, U32 default_radix, FNT_Tag font, F32 font_size, F32 max_size_px)
|
||||
{
|
||||
String8 result = {0};
|
||||
switch(col->kind)
|
||||
@@ -997,7 +997,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
|
||||
//////////////////////////////
|
||||
//- rjf: unpack arguments
|
||||
//
|
||||
F_Tag code_font = df_font_from_slot(DF_FontSlot_Code);
|
||||
FNT_Tag code_font = df_font_from_slot(DF_FontSlot_Code);
|
||||
DF_Entity *thread = df_entity_from_handle(df_interact_regs()->thread);
|
||||
Architecture arch = df_architecture_from_entity(thread);
|
||||
CTRL_Unwind base_unwind = df_query_cached_unwind_from_thread(thread);
|
||||
@@ -3324,10 +3324,10 @@ DF_VIEW_UI_FUNCTION_DEF(commands)
|
||||
ui_set_next_pref_height(ui_pct(1, 0));
|
||||
UI_Column UI_Padding(ui_pct(1, 0))
|
||||
{
|
||||
F_Tag font = ui_top_font();
|
||||
FNT_Tag font = ui_top_font();
|
||||
F32 font_size = ui_top_font_size();
|
||||
F_Metrics font_metrics = f_metrics_from_tag_size(font, font_size);
|
||||
F32 font_line_height = f_line_height_from_metrics(&font_metrics);
|
||||
FNT_Metrics font_metrics = fnt_metrics_from_tag_size(font, font_size);
|
||||
F32 font_line_height = fnt_line_height_from_metrics(&font_metrics);
|
||||
String8 cmd_display_name = item->cmd_spec->info.display_name;
|
||||
String8 cmd_desc = item->cmd_spec->info.description;
|
||||
UI_Box *name_box = ui_build_box_from_stringf(UI_BoxFlag_DrawText, "%S##name_%p", cmd_display_name, item->cmd_spec);
|
||||
@@ -7497,9 +7497,9 @@ DF_VIEW_UI_FUNCTION_DEF(memory)
|
||||
//////////////////////////////
|
||||
//- rjf: unpack visual params
|
||||
//
|
||||
F_Tag font = df_font_from_slot(DF_FontSlot_Code);
|
||||
FNT_Tag font = df_font_from_slot(DF_FontSlot_Code);
|
||||
F32 font_size = df_font_size_from_slot(ws, DF_FontSlot_Code);
|
||||
F32 big_glyph_advance = f_dim_from_tag_size_string(font, font_size, 0, 0, str8_lit("H")).x;
|
||||
F32 big_glyph_advance = fnt_dim_from_tag_size_string(font, font_size, 0, 0, str8_lit("H")).x;
|
||||
F32 row_height_px = floor_f32(font_size*2.f);
|
||||
F32 cell_width_px = floor_f32(font_size*2.f * bytes_per_cell);
|
||||
F32 scroll_bar_dim = floor_f32(ui_top_font_size()*1.5f);
|
||||
@@ -8115,9 +8115,9 @@ DF_VIEW_UI_FUNCTION_DEF(memory)
|
||||
D_BucketScope(bucket)
|
||||
{
|
||||
Vec2F32 text_pos = ui_box_text_position(ascii_box);
|
||||
d_rect(r2f32p(text_pos.x + f_dim_from_tag_size_string(font, font_size, 0, 0, str8_prefix(ascii_text, selection_in_row.min+0-row_range_bytes.min)).x - font_size/8.f,
|
||||
d_rect(r2f32p(text_pos.x + fnt_dim_from_tag_size_string(font, font_size, 0, 0, str8_prefix(ascii_text, selection_in_row.min+0-row_range_bytes.min)).x - font_size/8.f,
|
||||
ascii_box->rect.y0,
|
||||
text_pos.x + f_dim_from_tag_size_string(font, font_size, 0, 0, str8_prefix(ascii_text, selection_in_row.max+1-row_range_bytes.min)).x + font_size/4.f,
|
||||
text_pos.x + fnt_dim_from_tag_size_string(font, font_size, 0, 0, str8_prefix(ascii_text, selection_in_row.max+1-row_range_bytes.min)).x + font_size/4.f,
|
||||
ascii_box->rect.y1),
|
||||
df_rgba_from_theme_color(DF_ThemeColor_SelectionOverlay),
|
||||
0, 0, 1.f);
|
||||
@@ -8131,9 +8131,9 @@ DF_VIEW_UI_FUNCTION_DEF(memory)
|
||||
{
|
||||
Vec2F32 text_pos = ui_box_text_position(ascii_box);
|
||||
Vec4F32 color = df_rgba_from_theme_color(DF_ThemeColor_HighlightOverlay);
|
||||
d_rect(r2f32p(text_pos.x + f_dim_from_tag_size_string(font, font_size, 0, 0, str8_prefix(ascii_text, mouse_hover_byte_num-1-row_range_bytes.min)).x - font_size/8.f,
|
||||
d_rect(r2f32p(text_pos.x + fnt_dim_from_tag_size_string(font, font_size, 0, 0, str8_prefix(ascii_text, mouse_hover_byte_num-1-row_range_bytes.min)).x - font_size/8.f,
|
||||
ascii_box->rect.y0,
|
||||
text_pos.x + f_dim_from_tag_size_string(font, font_size, 0, 0, str8_prefix(ascii_text, mouse_hover_byte_num+0-row_range_bytes.min)).x + font_size/4.f,
|
||||
text_pos.x + fnt_dim_from_tag_size_string(font, font_size, 0, 0, str8_prefix(ascii_text, mouse_hover_byte_num+0-row_range_bytes.min)).x + font_size/4.f,
|
||||
ascii_box->rect.y1),
|
||||
color,
|
||||
1.f, 3.f, 1.f);
|
||||
|
||||
@@ -173,7 +173,7 @@ internal DF_WatchViewPoint df_watch_view_point_from_tbl(DF_EvalVizBlockList *blo
|
||||
internal Vec2S64 df_tbl_from_watch_view_point(DF_EvalVizBlockList *blocks, DF_WatchViewPoint pt);
|
||||
|
||||
//- rjf: table coordinates -> strings
|
||||
internal String8 df_string_from_eval_viz_row_column(Arena *arena, DF_EvalView *ev, DF_EvalVizRow *row, DF_WatchViewColumn *col, B32 editable, U32 default_radix, F_Tag font, F32 font_size, F32 max_size_px);
|
||||
internal String8 df_string_from_eval_viz_row_column(Arena *arena, DF_EvalView *ev, DF_EvalVizRow *row, DF_WatchViewColumn *col, B32 editable, U32 default_radix, FNT_Tag font, F32 font_size, F32 max_size_px);
|
||||
|
||||
//- rjf: table coordinates -> text edit state
|
||||
internal DF_WatchViewTextEditState *df_watch_view_text_edit_state_from_pt(DF_WatchViewState *wv, DF_WatchViewPoint pt);
|
||||
|
||||
+18
-18
@@ -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_RasterFlags flags, D_FancyStringList *strs)
|
||||
d_fancy_run_list_from_fancy_string_list(Arena *arena, F32 tab_size_px, FNT_RasterFlags flags, D_FancyStringList *strs)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
D_FancyRunList run_list = {0};
|
||||
@@ -95,7 +95,7 @@ d_fancy_run_list_from_fancy_string_list(Arena *arena, F32 tab_size_px, F_RasterF
|
||||
for(D_FancyStringNode *n = strs->first; n != 0; n = n->next)
|
||||
{
|
||||
D_FancyRunNode *dst_n = push_array(arena, D_FancyRunNode, 1);
|
||||
dst_n->v.run = f_push_run_from_string(arena, n->v.font, n->v.size, base_align_px, tab_size_px, flags, n->v.string);
|
||||
dst_n->v.run = fnt_push_run_from_string(arena, n->v.font, n->v.size, base_align_px, tab_size_px, flags, n->v.string);
|
||||
dst_n->v.color = n->v.color;
|
||||
dst_n->v.underline_thickness = n->v.underline_thickness;
|
||||
dst_n->v.strikethrough_thickness = n->v.strikethrough_thickness;
|
||||
@@ -118,7 +118,7 @@ d_fancy_run_list_copy(Arena *arena, D_FancyRunList *src)
|
||||
D_FancyRunNode *dst_n = push_array(arena, D_FancyRunNode, 1);
|
||||
SLLQueuePush(dst.first, dst.last, dst_n);
|
||||
MemoryCopyStruct(&dst_n->v, &src_n->v);
|
||||
dst_n->v.run.pieces = f_piece_array_copy(arena, &src_n->v.run.pieces);
|
||||
dst_n->v.run.pieces = fnt_piece_array_copy(arena, &src_n->v.run.pieces);
|
||||
dst.node_count += 1;
|
||||
}
|
||||
dst.dim = src->dim;
|
||||
@@ -455,7 +455,7 @@ d_sub_bucket(D_Bucket *bucket)
|
||||
//- rjf: text
|
||||
|
||||
internal void
|
||||
d_truncated_fancy_run_list(Vec2F32 p, D_FancyRunList *list, F32 max_x, F_Run trailer_run)
|
||||
d_truncated_fancy_run_list(Vec2F32 p, D_FancyRunList *list, F32 max_x, FNT_Run trailer_run)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
|
||||
@@ -475,11 +475,11 @@ d_truncated_fancy_run_list(Vec2F32 p, D_FancyRunList *list, F32 max_x, F_Run tra
|
||||
pixel_range.min = 100000;
|
||||
pixel_range.max = 0;
|
||||
}
|
||||
F_Piece *piece_first = fr->run.pieces.v;
|
||||
F_Piece *piece_opl = piece_first + fr->run.pieces.count;
|
||||
FNT_Piece *piece_first = fr->run.pieces.v;
|
||||
FNT_Piece *piece_opl = piece_first + fr->run.pieces.count;
|
||||
F32 pre_advance = advance;
|
||||
last_color = fr->color;
|
||||
for(F_Piece *piece = piece_first;
|
||||
for(FNT_Piece *piece = piece_first;
|
||||
piece < piece_opl;
|
||||
piece += 1)
|
||||
{
|
||||
@@ -530,11 +530,11 @@ d_truncated_fancy_run_list(Vec2F32 p, D_FancyRunList *list, F32 max_x, F_Run tra
|
||||
//- rjf: draw trailer
|
||||
if(trailer_found)
|
||||
{
|
||||
F_Piece *piece_first = trailer_run.pieces.v;
|
||||
F_Piece *piece_opl = piece_first + trailer_run.pieces.count;
|
||||
FNT_Piece *piece_first = trailer_run.pieces.v;
|
||||
FNT_Piece *piece_opl = piece_first + trailer_run.pieces.count;
|
||||
F32 pre_advance = advance;
|
||||
Vec4F32 trailer_piece_color = last_color;
|
||||
for(F_Piece *piece = piece_first;
|
||||
for(FNT_Piece *piece = piece_first;
|
||||
piece < piece_opl;
|
||||
piece += 1)
|
||||
{
|
||||
@@ -576,12 +576,12 @@ d_truncated_fancy_run_fuzzy_matches(Vec2F32 p, D_FancyRunList *list, F32 max_x,
|
||||
for(D_FancyRunNode *fr_n = list->first; fr_n != 0; fr_n = fr_n->next)
|
||||
{
|
||||
D_FancyRun *fr = &fr_n->v;
|
||||
F_Run *run = &fr->run;
|
||||
FNT_Run *run = &fr->run;
|
||||
ascent = run->ascent;
|
||||
descent = run->descent;
|
||||
for(U64 piece_idx = 0; piece_idx < run->pieces.count; piece_idx += 1)
|
||||
{
|
||||
F_Piece *piece = &run->pieces.v[piece_idx];
|
||||
FNT_Piece *piece = &run->pieces.v[piece_idx];
|
||||
if(contains_1u64(byte_range, byte_off))
|
||||
{
|
||||
F32 pre_advance = advance + piece->offset.x;
|
||||
@@ -607,12 +607,12 @@ d_truncated_fancy_run_fuzzy_matches(Vec2F32 p, D_FancyRunList *list, F32 max_x,
|
||||
}
|
||||
|
||||
internal void
|
||||
d_text_run(Vec2F32 p, Vec4F32 color, F_Run run)
|
||||
d_text_run(Vec2F32 p, Vec4F32 color, FNT_Run run)
|
||||
{
|
||||
F32 advance = 0;
|
||||
F_Piece *piece_first = run.pieces.v;
|
||||
F_Piece *piece_opl = piece_first + run.pieces.count;
|
||||
for(F_Piece *piece = piece_first;
|
||||
FNT_Piece *piece_first = run.pieces.v;
|
||||
FNT_Piece *piece_opl = piece_first + run.pieces.count;
|
||||
for(FNT_Piece *piece = piece_first;
|
||||
piece < piece_opl;
|
||||
piece += 1)
|
||||
{
|
||||
@@ -632,10 +632,10 @@ d_text_run(Vec2F32 p, Vec4F32 color, F_Run run)
|
||||
}
|
||||
|
||||
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)
|
||||
d_text(FNT_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, FNT_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);
|
||||
FNT_Run run = fnt_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);
|
||||
}
|
||||
|
||||
+6
-6
@@ -10,7 +10,7 @@
|
||||
typedef struct D_FancyString D_FancyString;
|
||||
struct D_FancyString
|
||||
{
|
||||
F_Tag font;
|
||||
FNT_Tag font;
|
||||
String8 string;
|
||||
Vec4F32 color;
|
||||
F32 size;
|
||||
@@ -37,7 +37,7 @@ struct D_FancyStringList
|
||||
typedef struct D_FancyRun D_FancyRun;
|
||||
struct D_FancyRun
|
||||
{
|
||||
F_Run run;
|
||||
FNT_Run run;
|
||||
Vec4F32 color;
|
||||
F32 underline_thickness;
|
||||
F32 strikethrough_thickness;
|
||||
@@ -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_RasterFlags flags, D_FancyStringList *strs);
|
||||
internal D_FancyRunList d_fancy_run_list_from_fancy_string_list(Arena *arena, F32 tab_size_px, FNT_RasterFlags flags, D_FancyStringList *strs);
|
||||
internal D_FancyRunList d_fancy_run_list_copy(Arena *arena, D_FancyRunList *src);
|
||||
|
||||
////////////////////////////////
|
||||
@@ -183,9 +183,9 @@ internal void d_sub_bucket(D_Bucket *bucket);
|
||||
//~ rjf: Draw Call Helpers
|
||||
|
||||
//- rjf: text
|
||||
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_list(Vec2F32 p, D_FancyRunList *list, F32 max_x, FNT_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_text(F_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, F_RasterFlags flags, Vec2F32 p, Vec4F32 color, String8 string);
|
||||
internal void d_text_run(Vec2F32 p, Vec4F32 color, FNT_Run run);
|
||||
internal void d_text(FNT_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, FNT_RasterFlags flags, Vec2F32 p, Vec4F32 color, String8 string);
|
||||
|
||||
#endif // DRAW_H
|
||||
|
||||
+126
-126
@@ -10,16 +10,16 @@
|
||||
#include "third_party/blake2/blake2b.c"
|
||||
#endif
|
||||
|
||||
internal F_Hash
|
||||
f_hash_from_string(String8 string)
|
||||
internal U128
|
||||
fnt_hash_from_string(String8 string)
|
||||
{
|
||||
F_Hash result = {0};
|
||||
U128 result = {0};
|
||||
blake2b((U8 *)&result.u64[0], sizeof(result), string.str, string.size, 0, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal U64
|
||||
f_little_hash_from_string(String8 string)
|
||||
fnt_little_hash_from_string(String8 string)
|
||||
{
|
||||
U64 result = 5381;
|
||||
for(U64 i = 0; i < string.size; i += 1)
|
||||
@@ -30,7 +30,7 @@ f_little_hash_from_string(String8 string)
|
||||
}
|
||||
|
||||
internal Vec2S32
|
||||
f_vertex_from_corner(Corner corner)
|
||||
fnt_vertex_from_corner(Corner corner)
|
||||
{
|
||||
Vec2S32 result = {0};
|
||||
switch(corner)
|
||||
@@ -47,27 +47,27 @@ f_vertex_from_corner(Corner corner)
|
||||
////////////////////////////////
|
||||
//~ rjf: Font Tags
|
||||
|
||||
internal F_Tag
|
||||
f_tag_zero(void)
|
||||
internal FNT_Tag
|
||||
fnt_tag_zero(void)
|
||||
{
|
||||
F_Tag result = {0};
|
||||
FNT_Tag result = {0};
|
||||
return result;
|
||||
}
|
||||
|
||||
internal B32
|
||||
f_tag_match(F_Tag a, F_Tag b)
|
||||
fnt_tag_match(FNT_Tag a, FNT_Tag b)
|
||||
{
|
||||
return a.u64[0] == b.u64[0] && a.u64[1] == b.u64[1];
|
||||
}
|
||||
|
||||
internal FP_Handle
|
||||
f_handle_from_tag(F_Tag tag)
|
||||
fnt_handle_from_tag(FNT_Tag tag)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
U64 slot_idx = tag.u64[1] % f_state->font_hash_table_size;
|
||||
F_FontHashNode *existing_node = 0;
|
||||
FNT_FontHashNode *existing_node = 0;
|
||||
{
|
||||
for(F_FontHashNode *n = f_state->font_hash_table[slot_idx].first; n != 0 ; n = n->hash_next)
|
||||
for(FNT_FontHashNode *n = f_state->font_hash_table[slot_idx].first; n != 0 ; n = n->hash_next)
|
||||
{
|
||||
if(MemoryMatchStruct(&tag, &n->tag))
|
||||
{
|
||||
@@ -86,13 +86,13 @@ f_handle_from_tag(F_Tag tag)
|
||||
}
|
||||
|
||||
internal FP_Metrics
|
||||
f_fp_metrics_from_tag(F_Tag tag)
|
||||
fnt_fp_metrics_from_tag(FNT_Tag tag)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
U64 slot_idx = tag.u64[1] % f_state->font_hash_table_size;
|
||||
F_FontHashNode *existing_node = 0;
|
||||
FNT_FontHashNode *existing_node = 0;
|
||||
{
|
||||
for(F_FontHashNode *n = f_state->font_hash_table[slot_idx].first; n != 0 ; n = n->hash_next)
|
||||
for(FNT_FontHashNode *n = f_state->font_hash_table[slot_idx].first; n != 0 ; n = n->hash_next)
|
||||
{
|
||||
if(MemoryMatchStruct(&tag, &n->tag))
|
||||
{
|
||||
@@ -110,15 +110,15 @@ f_fp_metrics_from_tag(F_Tag tag)
|
||||
return result;
|
||||
}
|
||||
|
||||
internal F_Tag
|
||||
f_tag_from_path(String8 path)
|
||||
internal FNT_Tag
|
||||
fnt_tag_from_path(String8 path)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
|
||||
//- rjf: produce tag from hash of path
|
||||
F_Tag result = {0};
|
||||
FNT_Tag result = {0};
|
||||
{
|
||||
F_Hash hash = f_hash_from_string(path);
|
||||
U128 hash = fnt_hash_from_string(path);
|
||||
MemoryCopy(&result, &hash, sizeof(result));
|
||||
result.u64[1] |= bit64;
|
||||
}
|
||||
@@ -127,9 +127,9 @@ f_tag_from_path(String8 path)
|
||||
U64 slot_idx = result.u64[1] % f_state->font_hash_table_size;
|
||||
|
||||
//- rjf: slot * tag -> existing node
|
||||
F_FontHashNode *existing_node = 0;
|
||||
FNT_FontHashNode *existing_node = 0;
|
||||
{
|
||||
for(F_FontHashNode *n = f_state->font_hash_table[slot_idx].first; n != 0 ; n = n->hash_next)
|
||||
for(FNT_FontHashNode *n = f_state->font_hash_table[slot_idx].first; n != 0 ; n = n->hash_next)
|
||||
{
|
||||
if(MemoryMatchStruct(&result, &n->tag))
|
||||
{
|
||||
@@ -140,11 +140,11 @@ f_tag_from_path(String8 path)
|
||||
}
|
||||
|
||||
//- rjf: allocate & push new node if we don't have an existing one
|
||||
F_FontHashNode *new_node = 0;
|
||||
FNT_FontHashNode *new_node = 0;
|
||||
if(existing_node == 0)
|
||||
{
|
||||
F_FontHashSlot *slot = &f_state->font_hash_table[slot_idx];
|
||||
new_node = push_array(f_state->arena, F_FontHashNode, 1);
|
||||
FNT_FontHashSlot *slot = &f_state->font_hash_table[slot_idx];
|
||||
new_node = push_array(f_state->arena, FNT_FontHashNode, 1);
|
||||
new_node->tag = result;
|
||||
new_node->handle = fp_font_open(path);
|
||||
new_node->metrics = fp_metrics_from_font(new_node->handle);
|
||||
@@ -157,15 +157,15 @@ f_tag_from_path(String8 path)
|
||||
return result;
|
||||
}
|
||||
|
||||
internal F_Tag
|
||||
f_tag_from_static_data_string(String8 *data_ptr)
|
||||
internal FNT_Tag
|
||||
fnt_tag_from_static_data_string(String8 *data_ptr)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
|
||||
//- rjf: produce tag hash of ptr
|
||||
F_Tag result = {0};
|
||||
FNT_Tag result = {0};
|
||||
{
|
||||
F_Hash hash = f_hash_from_string(str8((U8 *)&data_ptr, sizeof(String8 *)));
|
||||
U128 hash = fnt_hash_from_string(str8((U8 *)&data_ptr, sizeof(String8 *)));
|
||||
MemoryCopy(&result, &hash, sizeof(result));
|
||||
result.u64[1] &= ~bit64;
|
||||
}
|
||||
@@ -174,9 +174,9 @@ f_tag_from_static_data_string(String8 *data_ptr)
|
||||
U64 slot_idx = result.u64[1] % f_state->font_hash_table_size;
|
||||
|
||||
//- rjf: slot * tag -> existing node
|
||||
F_FontHashNode *existing_node = 0;
|
||||
FNT_FontHashNode *existing_node = 0;
|
||||
{
|
||||
for(F_FontHashNode *n = f_state->font_hash_table[slot_idx].first; n != 0 ; n = n->hash_next)
|
||||
for(FNT_FontHashNode *n = f_state->font_hash_table[slot_idx].first; n != 0 ; n = n->hash_next)
|
||||
{
|
||||
if(MemoryMatchStruct(&result, &n->tag))
|
||||
{
|
||||
@@ -187,11 +187,11 @@ f_tag_from_static_data_string(String8 *data_ptr)
|
||||
}
|
||||
|
||||
//- rjf: allocate & push new node if we don't have an existing one
|
||||
F_FontHashNode *new_node = 0;
|
||||
FNT_FontHashNode *new_node = 0;
|
||||
if(existing_node == 0)
|
||||
{
|
||||
F_FontHashSlot *slot = &f_state->font_hash_table[slot_idx];
|
||||
new_node = push_array(f_state->arena, F_FontHashNode, 1);
|
||||
FNT_FontHashSlot *slot = &f_state->font_hash_table[slot_idx];
|
||||
new_node = push_array(f_state->arena, FNT_FontHashNode, 1);
|
||||
new_node->tag = result;
|
||||
new_node->handle = fp_font_open_from_static_data_string(data_ptr);
|
||||
new_node->metrics = fp_metrics_from_font(new_node->handle);
|
||||
@@ -205,15 +205,15 @@ f_tag_from_static_data_string(String8 *data_ptr)
|
||||
}
|
||||
|
||||
internal String8
|
||||
f_path_from_tag(F_Tag tag)
|
||||
fnt_path_from_tag(FNT_Tag tag)
|
||||
{
|
||||
//- rjf: tag -> slot index
|
||||
U64 slot_idx = tag.u64[1] % f_state->font_hash_table_size;
|
||||
|
||||
//- rjf: slot * tag -> existing node
|
||||
F_FontHashNode *existing_node = 0;
|
||||
FNT_FontHashNode *existing_node = 0;
|
||||
{
|
||||
for(F_FontHashNode *n = f_state->font_hash_table[slot_idx].first; n != 0 ; n = n->hash_next)
|
||||
for(FNT_FontHashNode *n = f_state->font_hash_table[slot_idx].first; n != 0 ; n = n->hash_next)
|
||||
{
|
||||
if(MemoryMatchStruct(&tag, &n->tag))
|
||||
{
|
||||
@@ -237,7 +237,7 @@ f_path_from_tag(F_Tag tag)
|
||||
//~ rjf: Atlas
|
||||
|
||||
internal Rng2S16
|
||||
f_atlas_region_alloc(Arena *arena, F_Atlas *atlas, Vec2S16 needed_size)
|
||||
fnt_atlas_region_alloc(Arena *arena, FNT_Atlas *atlas, Vec2S16 needed_size)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
|
||||
@@ -245,13 +245,13 @@ f_atlas_region_alloc(Arena *arena, F_Atlas *atlas, Vec2S16 needed_size)
|
||||
Vec2S16 region_p0 = {0};
|
||||
Vec2S16 region_sz = {0};
|
||||
Corner node_corner = Corner_Invalid;
|
||||
F_AtlasRegionNode *node = 0;
|
||||
FNT_AtlasRegionNode *node = 0;
|
||||
{
|
||||
Vec2S16 n_supported_size = atlas->root_dim;
|
||||
for(F_AtlasRegionNode *n = atlas->root, *next = 0; n != 0; n = next, next = 0)
|
||||
for(FNT_AtlasRegionNode *n = atlas->root, *next = 0; n != 0; n = next, next = 0)
|
||||
{
|
||||
// rjf: we've traversed to a taken node.
|
||||
if(n->flags & F_AtlasRegionNodeFlag_Taken)
|
||||
if(n->flags & FNT_AtlasRegionNodeFlag_Taken)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -269,14 +269,14 @@ f_atlas_region_alloc(Arena *arena, F_Atlas *atlas, Vec2S16 needed_size)
|
||||
Vec2S16 child_size = v2s16(n_supported_size.x/2, n_supported_size.y/2);
|
||||
|
||||
// rjf: find best next child
|
||||
F_AtlasRegionNode *best_child = 0;
|
||||
FNT_AtlasRegionNode *best_child = 0;
|
||||
if(child_size.x >= needed_size.x && child_size.y >= needed_size.y)
|
||||
{
|
||||
for(Corner corner = (Corner)0; corner < Corner_COUNT; corner = (Corner)(corner+1))
|
||||
{
|
||||
if(n->children[corner] == 0)
|
||||
{
|
||||
n->children[corner] = push_array(arena, F_AtlasRegionNode, 1);
|
||||
n->children[corner] = push_array(arena, FNT_AtlasRegionNode, 1);
|
||||
n->children[corner]->parent = n;
|
||||
n->children[corner]->max_free_size[Corner_00] =
|
||||
n->children[corner]->max_free_size[Corner_01] =
|
||||
@@ -288,7 +288,7 @@ f_atlas_region_alloc(Arena *arena, F_Atlas *atlas, Vec2S16 needed_size)
|
||||
{
|
||||
best_child = n->children[corner];
|
||||
node_corner = corner;
|
||||
Vec2S32 side_vertex = f_vertex_from_corner(corner);
|
||||
Vec2S32 side_vertex = fnt_vertex_from_corner(corner);
|
||||
region_p0.x += side_vertex.x*child_size.x;
|
||||
region_p0.y += side_vertex.y*child_size.y;
|
||||
break;
|
||||
@@ -313,15 +313,15 @@ f_atlas_region_alloc(Arena *arena, F_Atlas *atlas, Vec2S16 needed_size)
|
||||
//- rjf: we're taking the subtree rooted by `node`. mark up all parents
|
||||
if(node != 0 && node_corner != Corner_Invalid)
|
||||
{
|
||||
node->flags |= F_AtlasRegionNodeFlag_Taken;
|
||||
node->flags |= FNT_AtlasRegionNodeFlag_Taken;
|
||||
if(node->parent != 0)
|
||||
{
|
||||
MemoryZeroStruct(&node->parent->max_free_size[node_corner]);
|
||||
}
|
||||
for(F_AtlasRegionNode *p = node->parent; p != 0; p = p->parent)
|
||||
for(FNT_AtlasRegionNode *p = node->parent; p != 0; p = p->parent)
|
||||
{
|
||||
p->num_allocated_descendants += 1;
|
||||
F_AtlasRegionNode *parent = p->parent;
|
||||
FNT_AtlasRegionNode *parent = p->parent;
|
||||
if(parent != 0)
|
||||
{
|
||||
Corner p_corner = (p == parent->children[Corner_00] ? Corner_00 :
|
||||
@@ -354,7 +354,7 @@ f_atlas_region_alloc(Arena *arena, F_Atlas *atlas, Vec2S16 needed_size)
|
||||
}
|
||||
|
||||
internal void
|
||||
f_atlas_region_release(F_Atlas *atlas, Rng2S16 region)
|
||||
fnt_atlas_region_release(FNT_Atlas *atlas, Rng2S16 region)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
|
||||
@@ -363,12 +363,12 @@ f_atlas_region_release(F_Atlas *atlas, Rng2S16 region)
|
||||
|
||||
//- rjf: map region to associated node
|
||||
Vec2S16 calc_region_size = {0};
|
||||
F_AtlasRegionNode *node = 0;
|
||||
FNT_AtlasRegionNode *node = 0;
|
||||
Corner node_corner = Corner_Invalid;
|
||||
{
|
||||
Vec2S16 n_p0 = v2s16(0, 0);
|
||||
Vec2S16 n_sz = atlas->root_dim;
|
||||
for(F_AtlasRegionNode *n = atlas->root, *next = 0; n != 0; n = next)
|
||||
for(FNT_AtlasRegionNode *n = atlas->root, *next = 0; n != 0; n = next)
|
||||
{
|
||||
// rjf: is the region within this node's boundaries? (either this node, or a descendant)
|
||||
if(n_p0.x <= region.p0.x && region.p0.x < n_p0.x+n_sz.x &&
|
||||
@@ -410,7 +410,7 @@ f_atlas_region_release(F_Atlas *atlas, Rng2S16 region)
|
||||
node_corner = next_corner;
|
||||
n_sz.x /= 2;
|
||||
n_sz.y /= 2;
|
||||
Vec2S32 side_vertex = f_vertex_from_corner(node_corner);
|
||||
Vec2S32 side_vertex = fnt_vertex_from_corner(node_corner);
|
||||
n_p0.x += side_vertex.x*n_sz.x;
|
||||
n_p0.y += side_vertex.y*n_sz.y;
|
||||
}
|
||||
@@ -425,15 +425,15 @@ f_atlas_region_release(F_Atlas *atlas, Rng2S16 region)
|
||||
//- rjf: free node
|
||||
if(node != 0 && node_corner != Corner_Invalid)
|
||||
{
|
||||
node->flags &= ~F_AtlasRegionNodeFlag_Taken;
|
||||
node->flags &= ~FNT_AtlasRegionNodeFlag_Taken;
|
||||
if(node->parent != 0)
|
||||
{
|
||||
node->parent->max_free_size[node_corner] = calc_region_size;
|
||||
}
|
||||
for(F_AtlasRegionNode *p = node->parent; p != 0; p = p->parent)
|
||||
for(FNT_AtlasRegionNode *p = node->parent; p != 0; p = p->parent)
|
||||
{
|
||||
p->num_allocated_descendants -= 1;
|
||||
F_AtlasRegionNode *parent = p->parent;
|
||||
FNT_AtlasRegionNode *parent = p->parent;
|
||||
if(parent != 0)
|
||||
{
|
||||
Corner p_corner = (p == parent->children[Corner_00] ? Corner_00 :
|
||||
@@ -462,61 +462,61 @@ f_atlas_region_release(F_Atlas *atlas, Rng2S16 region)
|
||||
////////////////////////////////
|
||||
//~ rjf: Piece Type Functions
|
||||
|
||||
internal F_Piece *
|
||||
f_piece_chunk_list_push_new(Arena *arena, F_PieceChunkList *list, U64 cap)
|
||||
internal FNT_Piece *
|
||||
fnt_piece_chunk_list_push_new(Arena *arena, FNT_PieceChunkList *list, U64 cap)
|
||||
{
|
||||
F_PieceChunkNode *node = list->last;
|
||||
FNT_PieceChunkNode *node = list->last;
|
||||
if(node == 0 || node->count >= node->cap)
|
||||
{
|
||||
node = push_array(arena, F_PieceChunkNode, 1);
|
||||
node->v = push_array_no_zero(arena, F_Piece, cap);
|
||||
node = push_array(arena, FNT_PieceChunkNode, 1);
|
||||
node->v = push_array_no_zero(arena, FNT_Piece, cap);
|
||||
node->cap = cap;
|
||||
SLLQueuePush(list->first, list->last, node);
|
||||
list->node_count += 1;
|
||||
}
|
||||
F_Piece *result = node->v + node->count;
|
||||
FNT_Piece *result = node->v + node->count;
|
||||
node->count += 1;
|
||||
list->total_piece_count += 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
internal void
|
||||
f_piece_chunk_list_push(Arena *arena, F_PieceChunkList *list, U64 cap, F_Piece *piece)
|
||||
fnt_piece_chunk_list_push(Arena *arena, FNT_PieceChunkList *list, U64 cap, FNT_Piece *piece)
|
||||
{
|
||||
F_Piece *new_piece = f_piece_chunk_list_push_new(arena, list, cap);
|
||||
FNT_Piece *new_piece = fnt_piece_chunk_list_push_new(arena, list, cap);
|
||||
MemoryCopyStruct(new_piece, piece);
|
||||
}
|
||||
|
||||
internal F_PieceArray
|
||||
f_piece_array_from_chunk_list(Arena *arena, F_PieceChunkList *list)
|
||||
internal FNT_PieceArray
|
||||
fnt_piece_array_from_chunk_list(Arena *arena, FNT_PieceChunkList *list)
|
||||
{
|
||||
F_PieceArray array = {0};
|
||||
FNT_PieceArray array = {0};
|
||||
array.count = list->total_piece_count;
|
||||
array.v = push_array_no_zero(arena, F_Piece, array.count);
|
||||
array.v = push_array_no_zero(arena, FNT_Piece, array.count);
|
||||
U64 write_idx = 0;
|
||||
for(F_PieceChunkNode *node = list->first; node != 0; node = node->next)
|
||||
for(FNT_PieceChunkNode *node = list->first; node != 0; node = node->next)
|
||||
{
|
||||
MemoryCopy(array.v + write_idx, node->v, node->count * sizeof(F_Piece));
|
||||
MemoryCopy(array.v + write_idx, node->v, node->count * sizeof(FNT_Piece));
|
||||
write_idx += node->count;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
internal F_PieceArray
|
||||
f_piece_array_copy(Arena *arena, F_PieceArray *src)
|
||||
internal FNT_PieceArray
|
||||
fnt_piece_array_copy(Arena *arena, FNT_PieceArray *src)
|
||||
{
|
||||
F_PieceArray dst = {0};
|
||||
FNT_PieceArray dst = {0};
|
||||
dst.count = src->count;
|
||||
dst.v = push_array_no_zero(arena, F_Piece, dst.count);
|
||||
MemoryCopy(dst.v, src->v, sizeof(F_Piece)*dst.count);
|
||||
dst.v = push_array_no_zero(arena, FNT_Piece, dst.count);
|
||||
MemoryCopy(dst.v, src->v, sizeof(FNT_Piece)*dst.count);
|
||||
return dst;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Rasterization Cache
|
||||
|
||||
internal F_Hash2StyleRasterCacheNode *
|
||||
f_hash2style_from_tag_size_flags(F_Tag tag, F32 size, F_RasterFlags flags)
|
||||
internal FNT_Hash2StyleRasterCacheNode *
|
||||
fnt_hash2style_from_tag_size_flags(FNT_Tag tag, F32 size, FNT_RasterFlags flags)
|
||||
{
|
||||
//- rjf: tag * size -> style hash
|
||||
U64 style_hash = {0};
|
||||
@@ -529,16 +529,16 @@ f_hash2style_from_tag_size_flags(F_Tag tag, F32 size, F_RasterFlags flags)
|
||||
*(U64 *)(&size_f64),
|
||||
(U64)flags,
|
||||
};
|
||||
style_hash = f_little_hash_from_string(str8((U8 *)buffer, sizeof(buffer)));
|
||||
style_hash = fnt_little_hash_from_string(str8((U8 *)buffer, sizeof(buffer)));
|
||||
}
|
||||
|
||||
//- rjf: style hash -> style node
|
||||
F_Hash2StyleRasterCacheNode *hash2style_node = 0;
|
||||
FNT_Hash2StyleRasterCacheNode *hash2style_node = 0;
|
||||
{
|
||||
ProfBegin("style hash -> style node");
|
||||
U64 slot_idx = style_hash%f_state->hash2style_slots_count;
|
||||
F_Hash2StyleRasterCacheSlot *slot = &f_state->hash2style_slots[slot_idx];
|
||||
for(F_Hash2StyleRasterCacheNode *n = slot->first;
|
||||
FNT_Hash2StyleRasterCacheSlot *slot = &f_state->hash2style_slots[slot_idx];
|
||||
for(FNT_Hash2StyleRasterCacheNode *n = slot->first;
|
||||
n != 0;
|
||||
n = n->hash_next)
|
||||
{
|
||||
@@ -550,15 +550,15 @@ f_hash2style_from_tag_size_flags(F_Tag tag, F32 size, F_RasterFlags flags)
|
||||
}
|
||||
if(Unlikely(hash2style_node == 0))
|
||||
{
|
||||
F_Metrics metrics = f_metrics_from_tag_size(tag, size);
|
||||
hash2style_node = push_array(f_state->arena, F_Hash2StyleRasterCacheNode, 1);
|
||||
FNT_Metrics metrics = fnt_metrics_from_tag_size(tag, size);
|
||||
hash2style_node = push_array(f_state->arena, FNT_Hash2StyleRasterCacheNode, 1);
|
||||
DLLPushBack_NP(slot->first, slot->last, hash2style_node, hash_next, hash_prev);
|
||||
hash2style_node->style_hash = style_hash;
|
||||
hash2style_node->ascent = metrics.ascent;
|
||||
hash2style_node->descent= metrics.descent;
|
||||
hash2style_node->utf8_class1_direct_map = push_array_no_zero(f_state->arena, F_RasterCacheInfo, 256);
|
||||
hash2style_node->hash2info_slots_count = 1024;
|
||||
hash2style_node->hash2info_slots = push_array(f_state->arena, F_Hash2InfoRasterCacheSlot, hash2style_node->hash2info_slots_count);
|
||||
hash2style_node->hash2info_slots = push_array(f_state->arena, FNT_Hash2InfoRasterCacheSlot, hash2style_node->hash2info_slots_count);
|
||||
}
|
||||
ProfEnd();
|
||||
}
|
||||
@@ -566,17 +566,17 @@ f_hash2style_from_tag_size_flags(F_Tag tag, F32 size, F_RasterFlags flags)
|
||||
return hash2style_node;
|
||||
}
|
||||
|
||||
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 FNT_Run
|
||||
fnt_push_run_from_string(Arena *arena, FNT_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, FNT_RasterFlags flags, String8 string)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
|
||||
//- rjf: map tag/size to style node
|
||||
F_Hash2StyleRasterCacheNode *hash2style_node = f_hash2style_from_tag_size_flags(tag, size, flags);
|
||||
FNT_Hash2StyleRasterCacheNode *hash2style_node = fnt_hash2style_from_tag_size_flags(tag, size, flags);
|
||||
|
||||
//- rjf: decode string & produce run pieces
|
||||
B32 first = 1;
|
||||
F_PieceChunkList piece_chunks = {0};
|
||||
FNT_PieceChunkList piece_chunks = {0};
|
||||
Vec2F32 dim = {0};
|
||||
B32 font_handle_mapped_on_miss = 0;
|
||||
FP_Handle font_handle = {0};
|
||||
@@ -636,9 +636,9 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32
|
||||
// rjf: more general, slower path for other glyphs
|
||||
if(piece_substring.size > 1)
|
||||
{
|
||||
piece_hash = f_little_hash_from_string(piece_substring);
|
||||
piece_hash = fnt_little_hash_from_string(piece_substring);
|
||||
U64 slot_idx = piece_hash%hash2style_node->hash2info_slots_count;
|
||||
F_Hash2InfoRasterCacheSlot *slot = &hash2style_node->hash2info_slots[slot_idx];
|
||||
FNT_Hash2InfoRasterCacheSlot *slot = &hash2style_node->hash2info_slots[slot_idx];
|
||||
for(F_Hash2InfoRasterCacheNode *node = slot->first; node != 0; node = node->hash_next)
|
||||
{
|
||||
if(node->hash == piece_hash)
|
||||
@@ -665,9 +665,9 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32
|
||||
U64 font_slot_idx = tag.u64[1] % f_state->font_hash_table_size;
|
||||
|
||||
// rjf: tag * slot -> existing node
|
||||
F_FontHashNode *existing_node = 0;
|
||||
FNT_FontHashNode *existing_node = 0;
|
||||
{
|
||||
for(F_FontHashNode *n = f_state->font_hash_table[font_slot_idx].first; n != 0 ; n = n->hash_next)
|
||||
for(FNT_FontHashNode *n = f_state->font_hash_table[font_slot_idx].first; n != 0 ; n = n->hash_next)
|
||||
{
|
||||
if(MemoryMatchStruct(&n->tag, &tag))
|
||||
{
|
||||
@@ -689,27 +689,27 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32
|
||||
if(size > 0)
|
||||
{
|
||||
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; }
|
||||
if(flags & FNT_RasterFlag_Smooth) { fp_flags |= FP_RasterFlag_Smooth; }
|
||||
if(flags & FNT_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
|
||||
S16 chosen_atlas_num = 0;
|
||||
F_Atlas *chosen_atlas = 0;
|
||||
FNT_Atlas *chosen_atlas = 0;
|
||||
Rng2S16 chosen_atlas_region = {0};
|
||||
if(raster.atlas_dim.x != 0 && raster.atlas_dim.y != 0)
|
||||
{
|
||||
U64 num_atlases = 0;
|
||||
for(F_Atlas *atlas = f_state->first_atlas;; atlas = atlas->next, num_atlases += 1)
|
||||
for(FNT_Atlas *atlas = f_state->first_atlas;; atlas = atlas->next, num_atlases += 1)
|
||||
{
|
||||
// rjf: create atlas if needed
|
||||
if(atlas == 0 && num_atlases < 64)
|
||||
{
|
||||
atlas = push_array(f_state->arena, F_Atlas, 1);
|
||||
atlas = push_array(f_state->arena, FNT_Atlas, 1);
|
||||
DLLPushBack(f_state->first_atlas, f_state->last_atlas, atlas);
|
||||
atlas->root_dim = v2s16(1024, 1024);
|
||||
atlas->root = push_array(f_state->arena, F_AtlasRegionNode, 1);
|
||||
atlas->root = push_array(f_state->arena, FNT_AtlasRegionNode, 1);
|
||||
atlas->root->max_free_size[Corner_00] =
|
||||
atlas->root->max_free_size[Corner_01] =
|
||||
atlas->root->max_free_size[Corner_10] =
|
||||
@@ -721,7 +721,7 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32
|
||||
if(atlas != 0)
|
||||
{
|
||||
Vec2S16 needed_dimensions = v2s16(raster.atlas_dim.x + 2, raster.atlas_dim.y + 2);
|
||||
chosen_atlas_region = f_atlas_region_alloc(f_state->arena, atlas, needed_dimensions);
|
||||
chosen_atlas_region = fnt_atlas_region_alloc(f_state->arena, atlas, needed_dimensions);
|
||||
if(chosen_atlas_region.x1 != chosen_atlas_region.x0)
|
||||
{
|
||||
chosen_atlas = atlas;
|
||||
@@ -759,7 +759,7 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32
|
||||
else
|
||||
{
|
||||
U64 slot_idx = piece_hash%hash2style_node->hash2info_slots_count;
|
||||
F_Hash2InfoRasterCacheSlot *slot = &hash2style_node->hash2info_slots[slot_idx];
|
||||
FNT_Hash2InfoRasterCacheSlot *slot = &hash2style_node->hash2info_slots[slot_idx];
|
||||
F_Hash2InfoRasterCacheNode *node = push_array_no_zero(f_state->arena, F_Hash2InfoRasterCacheNode, 1);
|
||||
DLLPushBack_NP(slot->first, slot->last, node, hash_next, hash_prev);
|
||||
node->hash = piece_hash;
|
||||
@@ -782,12 +782,12 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32
|
||||
if(info != 0)
|
||||
{
|
||||
// rjf: find atlas
|
||||
F_Atlas *atlas = 0;
|
||||
FNT_Atlas *atlas = 0;
|
||||
{
|
||||
if(info->subrect.x1 != 0 && info->subrect.y1 != 0)
|
||||
{
|
||||
S32 num = 0;
|
||||
for(F_Atlas *a = f_state->first_atlas; a != 0; a = a->next, num += 1)
|
||||
for(FNT_Atlas *a = f_state->first_atlas; a != 0; a = a->next, num += 1)
|
||||
{
|
||||
if(info->atlas_num == num)
|
||||
{
|
||||
@@ -807,7 +807,7 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32
|
||||
|
||||
// rjf: push piece
|
||||
{
|
||||
F_Piece *piece = f_piece_chunk_list_push_new(arena, &piece_chunks, string.size);
|
||||
FNT_Piece *piece = fnt_piece_chunk_list_push_new(arena, &piece_chunks, string.size);
|
||||
{
|
||||
piece->texture = atlas ? atlas->texture : r_handle_zero();
|
||||
piece->subrect = r2s16p(info->subrect.x0,
|
||||
@@ -826,7 +826,7 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32
|
||||
}
|
||||
|
||||
//- rjf: tighten & return
|
||||
F_Run run = {0};
|
||||
FNT_Run run = {0};
|
||||
{
|
||||
if(piece_chunks.node_count == 1)
|
||||
{
|
||||
@@ -835,7 +835,7 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32
|
||||
}
|
||||
else
|
||||
{
|
||||
run.pieces = f_piece_array_from_chunk_list(arena, &piece_chunks);
|
||||
run.pieces = fnt_piece_array_from_chunk_list(arena, &piece_chunks);
|
||||
}
|
||||
run.dim = dim;
|
||||
run.ascent = hash2style_node->ascent;
|
||||
@@ -847,23 +847,23 @@ f_push_run_from_string(Arena *arena, F_Tag tag, F32 size, F32 base_align_px, F32
|
||||
}
|
||||
|
||||
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)
|
||||
fnt_wrapped_string_lines_from_font_size_string_max(Arena *arena, FNT_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, String8 string, F32 max)
|
||||
{
|
||||
String8List list = {0};
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
F_Run run = f_push_run_from_string(scratch.arena, font, size, base_align_px, tab_size_px, 0, string);
|
||||
FNT_Run run = fnt_push_run_from_string(scratch.arena, font, size, base_align_px, tab_size_px, 0, string);
|
||||
F32 off_px = 0;
|
||||
U64 off_bytes = 0;
|
||||
U64 line_start_off_bytes = 0;
|
||||
U64 line_end_off_bytes = 0;
|
||||
B32 seeking_word_end = 0;
|
||||
F32 word_start_off_px = 0;
|
||||
F_Piece *last_word_start_piece = 0;
|
||||
FNT_Piece *last_word_start_piece = 0;
|
||||
U64 last_word_start_off_bytes = 0;
|
||||
F_Piece *pieces_first = run.pieces.v;
|
||||
F_Piece *pieces_opl = run.pieces.v + run.pieces.count;
|
||||
for(F_Piece *piece = pieces_first, *next = 0; piece != 0 && piece <= pieces_opl; piece = next)
|
||||
FNT_Piece *pieces_first = run.pieces.v;
|
||||
FNT_Piece *pieces_opl = run.pieces.v + run.pieces.count;
|
||||
for(FNT_Piece *piece = pieces_first, *next = 0; piece != 0 && piece <= pieces_opl; piece = next)
|
||||
{
|
||||
if(piece != 0) {next = piece+1;}
|
||||
|
||||
@@ -960,12 +960,12 @@ f_wrapped_string_lines_from_font_size_string_max(Arena *arena, F_Tag font, F32 s
|
||||
}
|
||||
|
||||
internal Vec2F32
|
||||
f_dim_from_tag_size_string(F_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, String8 string)
|
||||
fnt_dim_from_tag_size_string(FNT_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, String8 string)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
Vec2F32 result = {0};
|
||||
F_Run run = f_push_run_from_string(scratch.arena, tag, size, base_align_px, tab_size_px, 0, string);
|
||||
FNT_Run run = fnt_push_run_from_string(scratch.arena, tag, size, base_align_px, tab_size_px, 0, string);
|
||||
result = run.dim;
|
||||
scratch_end(scratch);
|
||||
ProfEnd();
|
||||
@@ -973,13 +973,13 @@ f_dim_from_tag_size_string(F_Tag tag, F32 size, F32 base_align_px, F32 tab_size_
|
||||
}
|
||||
|
||||
internal Vec2F32
|
||||
f_dim_from_tag_size_string_list(F_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, String8List list)
|
||||
fnt_dim_from_tag_size_string_list(FNT_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, String8List list)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
Vec2F32 sum = {0};
|
||||
for(String8Node *n = list.first; n != 0; n = n->next)
|
||||
{
|
||||
Vec2F32 str_dim = f_dim_from_tag_size_string(tag, size, base_align_px, tab_size_px, n->string);
|
||||
Vec2F32 str_dim = fnt_dim_from_tag_size_string(tag, size, base_align_px, tab_size_px, n->string);
|
||||
sum.x += str_dim.x;
|
||||
sum.y = Max(sum.y, str_dim.y);
|
||||
}
|
||||
@@ -988,21 +988,21 @@ f_dim_from_tag_size_string_list(F_Tag tag, F32 size, F32 base_align_px, F32 tab_
|
||||
}
|
||||
|
||||
internal F32
|
||||
f_column_size_from_tag_size(F_Tag tag, F32 size)
|
||||
fnt_column_size_from_tag_size(FNT_Tag tag, F32 size)
|
||||
{
|
||||
F32 result = f_dim_from_tag_size_string(tag, size, 0, 0, str8_lit("H")).x;
|
||||
F32 result = fnt_dim_from_tag_size_string(tag, size, 0, 0, str8_lit("H")).x;
|
||||
return result;
|
||||
}
|
||||
|
||||
internal U64
|
||||
f_char_pos_from_tag_size_string_p(F_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, String8 string, F32 p)
|
||||
fnt_char_pos_from_tag_size_string_p(FNT_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, String8 string, F32 p)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
U64 best_offset_bytes = 0;
|
||||
F32 best_offset_px = inf32();
|
||||
U64 offset_bytes = 0;
|
||||
F32 offset_px = 0.f;
|
||||
F_Run run = f_push_run_from_string(scratch.arena, tag, size, base_align_px, tab_size_px, 0, string);
|
||||
FNT_Run run = fnt_push_run_from_string(scratch.arena, tag, size, base_align_px, tab_size_px, 0, string);
|
||||
for(U64 idx = 0; idx <= run.pieces.count; idx += 1)
|
||||
{
|
||||
F32 this_piece_offset_px = abs_f32(offset_px - p);
|
||||
@@ -1013,7 +1013,7 @@ f_char_pos_from_tag_size_string_p(F_Tag tag, F32 size, F32 base_align_px, F32 ta
|
||||
}
|
||||
if(idx < run.pieces.count)
|
||||
{
|
||||
F_Piece *piece = &run.pieces.v[idx];
|
||||
FNT_Piece *piece = &run.pieces.v[idx];
|
||||
offset_px += piece->advance;
|
||||
offset_bytes += piece->decode_size;
|
||||
}
|
||||
@@ -1025,12 +1025,12 @@ f_char_pos_from_tag_size_string_p(F_Tag tag, F32 size, F32 base_align_px, F32 ta
|
||||
////////////////////////////////
|
||||
//~ rjf: Metrics
|
||||
|
||||
internal F_Metrics
|
||||
f_metrics_from_tag_size(F_Tag tag, F32 size)
|
||||
internal FNT_Metrics
|
||||
fnt_metrics_from_tag_size(FNT_Tag tag, F32 size)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
FP_Metrics metrics = f_fp_metrics_from_tag(tag);
|
||||
F_Metrics result = {0};
|
||||
FP_Metrics metrics = fnt_fp_metrics_from_tag(tag);
|
||||
FNT_Metrics result = {0};
|
||||
{
|
||||
result.ascent = floor_f32(size) * metrics.ascent / metrics.design_units_per_em;
|
||||
result.descent = floor_f32(size) * metrics.descent / metrics.design_units_per_em;
|
||||
@@ -1042,7 +1042,7 @@ f_metrics_from_tag_size(F_Tag tag, F32 size)
|
||||
}
|
||||
|
||||
internal F32
|
||||
f_line_height_from_metrics(F_Metrics *metrics)
|
||||
fnt_line_height_from_metrics(FNT_Metrics *metrics)
|
||||
{
|
||||
return metrics->ascent + metrics->descent + metrics->line_gap;
|
||||
}
|
||||
@@ -1051,13 +1051,13 @@ f_line_height_from_metrics(F_Metrics *metrics)
|
||||
//~ rjf: Main Calls
|
||||
|
||||
internal void
|
||||
f_init(void)
|
||||
fnt_init(void)
|
||||
{
|
||||
Arena *arena = arena_alloc();
|
||||
f_state = push_array(arena, F_State, 1);
|
||||
f_state = push_array(arena, FNT_State, 1);
|
||||
f_state->arena = arena;
|
||||
f_state->font_hash_table_size = 64;
|
||||
f_state->font_hash_table = push_array(arena, F_FontHashSlot, f_state->font_hash_table_size);
|
||||
f_state->font_hash_table = push_array(arena, FNT_FontHashSlot, f_state->font_hash_table_size);
|
||||
f_state->hash2style_slots_count = 1024;
|
||||
f_state->hash2style_slots = push_array(arena, F_Hash2StyleRasterCacheSlot, f_state->hash2style_slots_count);
|
||||
f_state->hash2style_slots = push_array(arena, FNT_Hash2StyleRasterCacheSlot, f_state->hash2style_slots_count);
|
||||
}
|
||||
|
||||
+87
-93
@@ -7,24 +7,18 @@
|
||||
////////////////////////////////
|
||||
//~ rjf: Rasterization Flags
|
||||
|
||||
typedef U32 F_RasterFlags;
|
||||
typedef U32 FNT_RasterFlags;
|
||||
enum
|
||||
{
|
||||
F_RasterFlag_Smooth = (1<<0),
|
||||
F_RasterFlag_Hinted = (1<<1),
|
||||
FNT_RasterFlag_Smooth = (1<<0),
|
||||
FNT_RasterFlag_Hinted = (1<<1),
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Handles & Tags
|
||||
|
||||
typedef struct F_Hash F_Hash;
|
||||
struct F_Hash
|
||||
{
|
||||
U64 u64[2];
|
||||
};
|
||||
|
||||
typedef struct F_Tag F_Tag;
|
||||
struct F_Tag
|
||||
typedef struct FNT_Tag FNT_Tag;
|
||||
struct FNT_Tag
|
||||
{
|
||||
U64 u64[2];
|
||||
};
|
||||
@@ -32,8 +26,8 @@ struct F_Tag
|
||||
////////////////////////////////
|
||||
//~ rjf: Draw Package Types (For Cache Queries)
|
||||
|
||||
typedef struct F_Piece F_Piece;
|
||||
struct F_Piece
|
||||
typedef struct FNT_Piece FNT_Piece;
|
||||
struct FNT_Piece
|
||||
{
|
||||
R_Handle texture;
|
||||
Rng2S16 subrect;
|
||||
@@ -42,35 +36,35 @@ struct F_Piece
|
||||
U16 decode_size;
|
||||
};
|
||||
|
||||
typedef struct F_PieceChunkNode F_PieceChunkNode;
|
||||
struct F_PieceChunkNode
|
||||
typedef struct FNT_PieceChunkNode FNT_PieceChunkNode;
|
||||
struct FNT_PieceChunkNode
|
||||
{
|
||||
F_PieceChunkNode *next;
|
||||
F_Piece *v;
|
||||
FNT_PieceChunkNode *next;
|
||||
FNT_Piece *v;
|
||||
U64 count;
|
||||
U64 cap;
|
||||
};
|
||||
|
||||
typedef struct F_PieceChunkList F_PieceChunkList;
|
||||
struct F_PieceChunkList
|
||||
typedef struct FNT_PieceChunkList FNT_PieceChunkList;
|
||||
struct FNT_PieceChunkList
|
||||
{
|
||||
F_PieceChunkNode *first;
|
||||
F_PieceChunkNode *last;
|
||||
FNT_PieceChunkNode *first;
|
||||
FNT_PieceChunkNode *last;
|
||||
U64 node_count;
|
||||
U64 total_piece_count;
|
||||
};
|
||||
|
||||
typedef struct F_PieceArray F_PieceArray;
|
||||
struct F_PieceArray
|
||||
typedef struct FNT_PieceArray FNT_PieceArray;
|
||||
struct FNT_PieceArray
|
||||
{
|
||||
F_Piece *v;
|
||||
FNT_Piece *v;
|
||||
U64 count;
|
||||
};
|
||||
|
||||
typedef struct F_Run F_Run;
|
||||
struct F_Run
|
||||
typedef struct FNT_Run FNT_Run;
|
||||
struct FNT_Run
|
||||
{
|
||||
F_PieceArray pieces;
|
||||
FNT_PieceArray pieces;
|
||||
Vec2F32 dim;
|
||||
F32 ascent;
|
||||
F32 descent;
|
||||
@@ -79,21 +73,21 @@ struct F_Run
|
||||
////////////////////////////////
|
||||
//~ rjf: Font Path -> Handle * Metrics * Path Cache Types
|
||||
|
||||
typedef struct F_FontHashNode F_FontHashNode;
|
||||
struct F_FontHashNode
|
||||
typedef struct FNT_FontHashNode FNT_FontHashNode;
|
||||
struct FNT_FontHashNode
|
||||
{
|
||||
F_FontHashNode *hash_next;
|
||||
F_Tag tag;
|
||||
FNT_FontHashNode *hash_next;
|
||||
FNT_Tag tag;
|
||||
FP_Handle handle;
|
||||
FP_Metrics metrics;
|
||||
String8 path;
|
||||
};
|
||||
|
||||
typedef struct F_FontHashSlot F_FontHashSlot;
|
||||
struct F_FontHashSlot
|
||||
typedef struct FNT_FontHashSlot FNT_FontHashSlot;
|
||||
struct FNT_FontHashSlot
|
||||
{
|
||||
F_FontHashNode *first;
|
||||
F_FontHashNode *last;
|
||||
FNT_FontHashNode *first;
|
||||
FNT_FontHashNode *last;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
@@ -117,18 +111,18 @@ struct F_Hash2InfoRasterCacheNode
|
||||
F_RasterCacheInfo info;
|
||||
};
|
||||
|
||||
typedef struct F_Hash2InfoRasterCacheSlot F_Hash2InfoRasterCacheSlot;
|
||||
struct F_Hash2InfoRasterCacheSlot
|
||||
typedef struct FNT_Hash2InfoRasterCacheSlot FNT_Hash2InfoRasterCacheSlot;
|
||||
struct FNT_Hash2InfoRasterCacheSlot
|
||||
{
|
||||
F_Hash2InfoRasterCacheNode *first;
|
||||
F_Hash2InfoRasterCacheNode *last;
|
||||
};
|
||||
|
||||
typedef struct F_Hash2StyleRasterCacheNode F_Hash2StyleRasterCacheNode;
|
||||
struct F_Hash2StyleRasterCacheNode
|
||||
typedef struct FNT_Hash2StyleRasterCacheNode FNT_Hash2StyleRasterCacheNode;
|
||||
struct FNT_Hash2StyleRasterCacheNode
|
||||
{
|
||||
F_Hash2StyleRasterCacheNode *hash_next;
|
||||
F_Hash2StyleRasterCacheNode *hash_prev;
|
||||
FNT_Hash2StyleRasterCacheNode *hash_next;
|
||||
FNT_Hash2StyleRasterCacheNode *hash_prev;
|
||||
U64 style_hash;
|
||||
F32 ascent;
|
||||
F32 descent;
|
||||
@@ -136,50 +130,50 @@ struct F_Hash2StyleRasterCacheNode
|
||||
F_RasterCacheInfo *utf8_class1_direct_map;
|
||||
U64 utf8_class1_direct_map_mask[4];
|
||||
U64 hash2info_slots_count;
|
||||
F_Hash2InfoRasterCacheSlot *hash2info_slots;
|
||||
FNT_Hash2InfoRasterCacheSlot *hash2info_slots;
|
||||
};
|
||||
|
||||
typedef struct F_Hash2StyleRasterCacheSlot F_Hash2StyleRasterCacheSlot;
|
||||
struct F_Hash2StyleRasterCacheSlot
|
||||
typedef struct FNT_Hash2StyleRasterCacheSlot FNT_Hash2StyleRasterCacheSlot;
|
||||
struct FNT_Hash2StyleRasterCacheSlot
|
||||
{
|
||||
F_Hash2StyleRasterCacheNode *first;
|
||||
F_Hash2StyleRasterCacheNode *last;
|
||||
FNT_Hash2StyleRasterCacheNode *first;
|
||||
FNT_Hash2StyleRasterCacheNode *last;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Atlas Types
|
||||
|
||||
typedef U32 F_AtlasRegionNodeFlags;
|
||||
typedef U32 FNT_AtlasRegionNodeFlags;
|
||||
enum
|
||||
{
|
||||
F_AtlasRegionNodeFlag_Taken = (1<<0),
|
||||
FNT_AtlasRegionNodeFlag_Taken = (1<<0),
|
||||
};
|
||||
|
||||
typedef struct F_AtlasRegionNode F_AtlasRegionNode;
|
||||
struct F_AtlasRegionNode
|
||||
typedef struct FNT_AtlasRegionNode FNT_AtlasRegionNode;
|
||||
struct FNT_AtlasRegionNode
|
||||
{
|
||||
F_AtlasRegionNode *parent;
|
||||
F_AtlasRegionNode *children[Corner_COUNT];
|
||||
FNT_AtlasRegionNode *parent;
|
||||
FNT_AtlasRegionNode *children[Corner_COUNT];
|
||||
Vec2S16 max_free_size[Corner_COUNT];
|
||||
F_AtlasRegionNodeFlags flags;
|
||||
FNT_AtlasRegionNodeFlags flags;
|
||||
U64 num_allocated_descendants;
|
||||
};
|
||||
|
||||
typedef struct F_Atlas F_Atlas;
|
||||
struct F_Atlas
|
||||
typedef struct FNT_Atlas FNT_Atlas;
|
||||
struct FNT_Atlas
|
||||
{
|
||||
F_Atlas *next;
|
||||
F_Atlas *prev;
|
||||
FNT_Atlas *next;
|
||||
FNT_Atlas *prev;
|
||||
R_Handle texture;
|
||||
Vec2S16 root_dim;
|
||||
F_AtlasRegionNode *root;
|
||||
FNT_AtlasRegionNode *root;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Metrics
|
||||
|
||||
typedef struct F_Metrics F_Metrics;
|
||||
struct F_Metrics
|
||||
typedef struct FNT_Metrics FNT_Metrics;
|
||||
struct FNT_Metrics
|
||||
{
|
||||
F32 ascent;
|
||||
F32 descent;
|
||||
@@ -190,81 +184,81 @@ struct F_Metrics
|
||||
////////////////////////////////
|
||||
//~ rjf: Main State Type
|
||||
|
||||
typedef struct F_State F_State;
|
||||
struct F_State
|
||||
typedef struct FNT_State FNT_State;
|
||||
struct FNT_State
|
||||
{
|
||||
Arena *arena;
|
||||
|
||||
// rjf: font table
|
||||
U64 font_hash_table_size;
|
||||
F_FontHashSlot *font_hash_table;
|
||||
FNT_FontHashSlot *font_hash_table;
|
||||
|
||||
// rjf: hash -> raster cache table
|
||||
U64 hash2style_slots_count;
|
||||
F_Hash2StyleRasterCacheSlot *hash2style_slots;
|
||||
FNT_Hash2StyleRasterCacheSlot *hash2style_slots;
|
||||
|
||||
// rjf: atlas list
|
||||
F_Atlas *first_atlas;
|
||||
F_Atlas *last_atlas;
|
||||
FNT_Atlas *first_atlas;
|
||||
FNT_Atlas *last_atlas;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Globals
|
||||
|
||||
global F_State *f_state = 0;
|
||||
global FNT_State *f_state = 0;
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Basic Functions
|
||||
|
||||
internal F_Hash f_hash_from_string(String8 string);
|
||||
internal U64 f_little_hash_from_string(String8 string);
|
||||
internal Vec2S32 f_vertex_from_corner(Corner corner);
|
||||
internal U128 fnt_hash_from_string(String8 string);
|
||||
internal U64 fnt_little_hash_from_string(String8 string);
|
||||
internal Vec2S32 fnt_vertex_from_corner(Corner corner);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Font Tags
|
||||
|
||||
internal F_Tag f_tag_zero(void);
|
||||
internal B32 f_tag_match(F_Tag a, F_Tag b);
|
||||
internal FP_Handle f_handle_from_tag(F_Tag tag);
|
||||
internal FP_Metrics f_fp_metrics_from_tag(F_Tag tag);
|
||||
internal F_Tag f_tag_from_path(String8 path);
|
||||
internal F_Tag f_tag_from_static_data_string(String8 *data_ptr);
|
||||
internal String8 f_path_from_tag(F_Tag tag);
|
||||
internal FNT_Tag fnt_tag_zero(void);
|
||||
internal B32 fnt_tag_match(FNT_Tag a, FNT_Tag b);
|
||||
internal FP_Handle fnt_handle_from_tag(FNT_Tag tag);
|
||||
internal FP_Metrics fnt_fp_metrics_from_tag(FNT_Tag tag);
|
||||
internal FNT_Tag fnt_tag_from_path(String8 path);
|
||||
internal FNT_Tag fnt_tag_from_static_data_string(String8 *data_ptr);
|
||||
internal String8 fnt_path_from_tag(FNT_Tag tag);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Atlas
|
||||
|
||||
internal Rng2S16 f_atlas_region_alloc(Arena *arena, F_Atlas *atlas, Vec2S16 needed_size);
|
||||
internal void f_atlas_region_release(F_Atlas *atlas, Rng2S16 region);
|
||||
internal Rng2S16 fnt_atlas_region_alloc(Arena *arena, FNT_Atlas *atlas, Vec2S16 needed_size);
|
||||
internal void fnt_atlas_region_release(FNT_Atlas *atlas, Rng2S16 region);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Piece Type Functions
|
||||
|
||||
internal F_Piece *f_piece_chunk_list_push_new(Arena *arena, F_PieceChunkList *list, U64 cap);
|
||||
internal void f_piece_chunk_list_push(Arena *arena, F_PieceChunkList *list, U64 cap, F_Piece *piece);
|
||||
internal F_PieceArray f_piece_array_from_chunk_list(Arena *arena, F_PieceChunkList *list);
|
||||
internal F_PieceArray f_piece_array_copy(Arena *arena, F_PieceArray *src);
|
||||
internal FNT_Piece *fnt_piece_chunk_list_push_new(Arena *arena, FNT_PieceChunkList *list, U64 cap);
|
||||
internal void fnt_piece_chunk_list_push(Arena *arena, FNT_PieceChunkList *list, U64 cap, FNT_Piece *piece);
|
||||
internal FNT_PieceArray fnt_piece_array_from_chunk_list(Arena *arena, FNT_PieceChunkList *list);
|
||||
internal FNT_PieceArray fnt_piece_array_copy(Arena *arena, FNT_PieceArray *src);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Rasterization Cache
|
||||
|
||||
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);
|
||||
internal F32 f_column_size_from_tag_size(F_Tag tag, F32 size);
|
||||
internal U64 f_char_pos_from_tag_size_string_p(F_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, String8 string, F32 p);
|
||||
internal FNT_Hash2StyleRasterCacheNode *fnt_hash2style_from_tag_size_flags(FNT_Tag tag, F32 size, FNT_RasterFlags flags);
|
||||
internal FNT_Run fnt_push_run_from_string(Arena *arena, FNT_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, FNT_RasterFlags flags, String8 string);
|
||||
internal String8List fnt_wrapped_string_lines_from_font_size_string_max(Arena *arena, FNT_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, String8 string, F32 max);
|
||||
internal Vec2F32 fnt_dim_from_tag_size_string(FNT_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, String8 string);
|
||||
internal Vec2F32 fnt_dim_from_tag_size_string_list(FNT_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, String8List list);
|
||||
internal F32 fnt_column_size_from_tag_size(FNT_Tag tag, F32 size);
|
||||
internal U64 fnt_char_pos_from_tag_size_string_p(FNT_Tag tag, F32 size, F32 base_align_px, F32 tab_size_px, String8 string, F32 p);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Metrics
|
||||
|
||||
internal F_Metrics f_metrics_from_tag_size(F_Tag tag, F32 size);
|
||||
internal F32 f_line_height_from_metrics(F_Metrics *metrics);
|
||||
internal FNT_Metrics fnt_metrics_from_tag_size(FNT_Tag tag, F32 size);
|
||||
internal F32 fnt_line_height_from_metrics(FNT_Metrics *metrics);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Main Calls
|
||||
|
||||
internal void f_init(void);
|
||||
internal void fnt_init(void);
|
||||
|
||||
#endif // FONT_CACHE_H
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#define R_INIT_MANUAL 1
|
||||
#define TEX_INIT_MANUAL 1
|
||||
#define GEO_INIT_MANUAL 1
|
||||
#define F_INIT_MANUAL 1
|
||||
#define FNT_INIT_MANUAL 1
|
||||
#define DF_INIT_MANUAL 1
|
||||
#define DF_GFX_INIT_MANUAL 1
|
||||
|
||||
@@ -233,7 +233,7 @@ entry_point(CmdLine *cmd_line)
|
||||
r_init(cmd_line);
|
||||
tex_init();
|
||||
geo_init();
|
||||
f_init();
|
||||
fnt_init();
|
||||
DF_StateDeltaHistory *hist = df_state_delta_history_alloc();
|
||||
df_core_init(cmd_line, hist);
|
||||
df_gfx_init(update_and_render, df_state_delta_history());
|
||||
|
||||
+10
-10
@@ -52,9 +52,9 @@ internal F32 ui_top_transparency(void) { UI_StackTopImpl(ui_state, Transparency,
|
||||
internal UI_Palette* ui_top_palette(void) { UI_StackTopImpl(ui_state, Palette, palette) }
|
||||
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 FNT_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_RasterFlags ui_top_text_raster_flags(void) { UI_StackTopImpl(ui_state, TextRasterFlags, text_raster_flags) }
|
||||
internal FNT_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) }
|
||||
@@ -81,9 +81,9 @@ internal F32 ui_bottom_transparency(void) { UI_StackBottomImpl(ui_state, Transpa
|
||||
internal UI_Palette* ui_bottom_palette(void) { UI_StackBottomImpl(ui_state, Palette, palette) }
|
||||
internal F32 ui_bottom_squish(void) { UI_StackBottomImpl(ui_state, Squish, squish) }
|
||||
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 FNT_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_RasterFlags ui_bottom_text_raster_flags(void) { UI_StackBottomImpl(ui_state, TextRasterFlags, text_raster_flags) }
|
||||
internal FNT_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) }
|
||||
@@ -110,9 +110,9 @@ internal F32 ui_push_transparency(F32 v) { UI_StackPushImpl(ui_state, Transparen
|
||||
internal UI_Palette* ui_push_palette(UI_Palette* v) { UI_StackPushImpl(ui_state, Palette, palette, UI_Palette* , v) }
|
||||
internal F32 ui_push_squish(F32 v) { UI_StackPushImpl(ui_state, Squish, squish, F32, v) }
|
||||
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 FNT_Tag ui_push_font(FNT_Tag v) { UI_StackPushImpl(ui_state, Font, font, FNT_Tag, v) }
|
||||
internal F32 ui_push_font_size(F32 v) { UI_StackPushImpl(ui_state, FontSize, font_size, F32, v) }
|
||||
internal F_RasterFlags ui_push_text_raster_flags(F_RasterFlags v) { UI_StackPushImpl(ui_state, TextRasterFlags, text_raster_flags, F_RasterFlags, v) }
|
||||
internal FNT_RasterFlags ui_push_text_raster_flags(FNT_RasterFlags v) { UI_StackPushImpl(ui_state, TextRasterFlags, text_raster_flags, FNT_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) }
|
||||
@@ -139,9 +139,9 @@ internal F32 ui_pop_transparency(void) { UI_StackPopImpl(ui_state, Transparency,
|
||||
internal UI_Palette* ui_pop_palette(void) { UI_StackPopImpl(ui_state, Palette, palette) }
|
||||
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 FNT_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_RasterFlags ui_pop_text_raster_flags(void) { UI_StackPopImpl(ui_state, TextRasterFlags, text_raster_flags) }
|
||||
internal FNT_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) }
|
||||
@@ -168,9 +168,9 @@ internal F32 ui_set_next_transparency(F32 v) { UI_StackSetNextImpl(ui_state, Tra
|
||||
internal UI_Palette* ui_set_next_palette(UI_Palette* v) { UI_StackSetNextImpl(ui_state, Palette, palette, UI_Palette* , v) }
|
||||
internal F32 ui_set_next_squish(F32 v) { UI_StackSetNextImpl(ui_state, Squish, squish, F32, v) }
|
||||
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 FNT_Tag ui_set_next_font(FNT_Tag v) { UI_StackSetNextImpl(ui_state, Font, font, FNT_Tag, v) }
|
||||
internal F32 ui_set_next_font_size(F32 v) { UI_StackSetNextImpl(ui_state, FontSize, font_size, F32, 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 FNT_RasterFlags ui_set_next_text_raster_flags(FNT_RasterFlags v) { UI_StackSetNextImpl(ui_state, TextRasterFlags, text_raster_flags, FNT_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) }
|
||||
|
||||
+18
-18
@@ -24,9 +24,9 @@ typedef struct UI_TransparencyNode UI_TransparencyNode; struct UI_TransparencyNo
|
||||
typedef struct UI_PaletteNode UI_PaletteNode; struct UI_PaletteNode{UI_PaletteNode *next; UI_Palette* v;};
|
||||
typedef struct UI_SquishNode UI_SquishNode; struct UI_SquishNode{UI_SquishNode *next; F32 v;};
|
||||
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_FontNode UI_FontNode; struct UI_FontNode{UI_FontNode *next; FNT_Tag v;};
|
||||
typedef struct UI_FontSizeNode UI_FontSizeNode; struct UI_FontSizeNode{UI_FontSizeNode *next; F32 v;};
|
||||
typedef struct UI_TextRasterFlagsNode UI_TextRasterFlagsNode; struct UI_TextRasterFlagsNode{UI_TextRasterFlagsNode *next; F_RasterFlags v;};
|
||||
typedef struct UI_TextRasterFlagsNode UI_TextRasterFlagsNode; struct UI_TextRasterFlagsNode{UI_TextRasterFlagsNode *next; FNT_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;};
|
||||
@@ -87,9 +87,9 @@ state->transparency_nil_stack_top.v = 0;\
|
||||
state->palette_nil_stack_top.v = &ui_g_nil_palette;\
|
||||
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_nil_stack_top.v = fnt_tag_zero();\
|
||||
state->font_size_nil_stack_top.v = 24.f;\
|
||||
state->text_raster_flags_nil_stack_top.v = F_RasterFlag_Hinted;\
|
||||
state->text_raster_flags_nil_stack_top.v = FNT_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;\
|
||||
@@ -120,9 +120,9 @@ struct { UI_TransparencyNode *top; F32 bottom_val; UI_TransparencyNode *free; B3
|
||||
struct { UI_PaletteNode *top; UI_Palette* bottom_val; UI_PaletteNode *free; B32 auto_pop; } palette_stack;\
|
||||
struct { UI_SquishNode *top; F32 bottom_val; UI_SquishNode *free; B32 auto_pop; } squish_stack;\
|
||||
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_FontNode *top; FNT_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_TextRasterFlagsNode *top; F_RasterFlags bottom_val; UI_TextRasterFlagsNode *free; B32 auto_pop; } text_raster_flags_stack;\
|
||||
struct { UI_TextRasterFlagsNode *top; FNT_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;\
|
||||
@@ -151,9 +151,9 @@ state->transparency_stack.top = &state->transparency_nil_stack_top; state->trans
|
||||
state->palette_stack.top = &state->palette_nil_stack_top; state->palette_stack.bottom_val = &ui_g_nil_palette; state->palette_stack.free = 0; state->palette_stack.auto_pop = 0;\
|
||||
state->squish_stack.top = &state->squish_nil_stack_top; state->squish_stack.bottom_val = 0; state->squish_stack.free = 0; state->squish_stack.auto_pop = 0;\
|
||||
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_stack.top = &state->font_nil_stack_top; state->font_stack.bottom_val = fnt_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->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->text_raster_flags_stack.top = &state->text_raster_flags_nil_stack_top; state->text_raster_flags_stack.bottom_val = FNT_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;\
|
||||
@@ -212,9 +212,9 @@ internal F32 ui_top_transparency(void);
|
||||
internal UI_Palette* ui_top_palette(void);
|
||||
internal F32 ui_top_squish(void);
|
||||
internal OS_Cursor ui_top_hover_cursor(void);
|
||||
internal F_Tag ui_top_font(void);
|
||||
internal FNT_Tag ui_top_font(void);
|
||||
internal F32 ui_top_font_size(void);
|
||||
internal F_RasterFlags ui_top_text_raster_flags(void);
|
||||
internal FNT_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);
|
||||
@@ -241,9 +241,9 @@ internal F32 ui_bottom_transparency(void);
|
||||
internal UI_Palette* ui_bottom_palette(void);
|
||||
internal F32 ui_bottom_squish(void);
|
||||
internal OS_Cursor ui_bottom_hover_cursor(void);
|
||||
internal F_Tag ui_bottom_font(void);
|
||||
internal FNT_Tag ui_bottom_font(void);
|
||||
internal F32 ui_bottom_font_size(void);
|
||||
internal F_RasterFlags ui_bottom_text_raster_flags(void);
|
||||
internal FNT_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);
|
||||
@@ -270,9 +270,9 @@ internal F32 ui_push_transparency(F32 v);
|
||||
internal UI_Palette* ui_push_palette(UI_Palette* v);
|
||||
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 FNT_Tag ui_push_font(FNT_Tag v);
|
||||
internal F32 ui_push_font_size(F32 v);
|
||||
internal F_RasterFlags ui_push_text_raster_flags(F_RasterFlags v);
|
||||
internal FNT_RasterFlags ui_push_text_raster_flags(FNT_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);
|
||||
@@ -299,9 +299,9 @@ internal F32 ui_pop_transparency(void);
|
||||
internal UI_Palette* ui_pop_palette(void);
|
||||
internal F32 ui_pop_squish(void);
|
||||
internal OS_Cursor ui_pop_hover_cursor(void);
|
||||
internal F_Tag ui_pop_font(void);
|
||||
internal FNT_Tag ui_pop_font(void);
|
||||
internal F32 ui_pop_font_size(void);
|
||||
internal F_RasterFlags ui_pop_text_raster_flags(void);
|
||||
internal FNT_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);
|
||||
@@ -328,9 +328,9 @@ internal F32 ui_set_next_transparency(F32 v);
|
||||
internal UI_Palette* ui_set_next_palette(UI_Palette* v);
|
||||
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 FNT_Tag ui_set_next_font(FNT_Tag v);
|
||||
internal F32 ui_set_next_font_size(F32 v);
|
||||
internal F_RasterFlags ui_set_next_text_raster_flags(F_RasterFlags v);
|
||||
internal FNT_RasterFlags ui_set_next_text_raster_flags(FNT_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
@@ -41,9 +41,9 @@ UI_StackTable:
|
||||
{ HoverCursor hover_cursor OS_Cursor OS_Cursor_Pointer }
|
||||
|
||||
//- rjf: font
|
||||
{ Font font F_Tag `f_tag_zero()` }
|
||||
{ Font font FNT_Tag `fnt_tag_zero()` }
|
||||
{ FontSize font_size F32 24.f }
|
||||
{ TextRasterFlags text_raster_flags F_RasterFlags F_RasterFlag_Hinted }
|
||||
{ TextRasterFlags text_raster_flags FNT_RasterFlags FNT_RasterFlag_Hinted }
|
||||
{ TabSize tab_size F32 `24.f*4.f` }
|
||||
|
||||
//- rjf: corner radii
|
||||
|
||||
@@ -47,7 +47,7 @@ ui_label_multiline(F32 max, String8 string)
|
||||
ui_set_next_child_layout_axis(Axis2_Y);
|
||||
ui_set_next_pref_height(ui_children_sum(1));
|
||||
UI_Box *box = ui_build_box_from_key(0, ui_key_zero());
|
||||
String8List lines = f_wrapped_string_lines_from_font_size_string_max(scratch.arena, ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), string, max);
|
||||
String8List lines = fnt_wrapped_string_lines_from_font_size_string_max(scratch.arena, ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), string, max);
|
||||
for(String8Node *n = lines.first; n != 0; n = n->next)
|
||||
{
|
||||
ui_label(n->string);
|
||||
@@ -131,7 +131,7 @@ struct UI_LineEditDrawData
|
||||
internal UI_BOX_CUSTOM_DRAW(ui_line_edit_draw)
|
||||
{
|
||||
UI_LineEditDrawData *draw_data = (UI_LineEditDrawData *)user_data;
|
||||
F_Tag font = box->font;
|
||||
FNT_Tag font = box->font;
|
||||
F32 font_size = box->font_size;
|
||||
F32 tab_size = box->tab_size;
|
||||
Vec4F32 cursor_color = box->palette->colors[UI_ColorCode_Cursor];
|
||||
@@ -142,8 +142,8 @@ 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;
|
||||
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_pixel_off = fnt_dim_from_tag_size_string(font, font_size, 0, tab_size, str8_prefix(edited_string, cursor.column-1)).x;
|
||||
F32 mark_pixel_off = fnt_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 =
|
||||
{
|
||||
@@ -254,7 +254,7 @@ ui_line_edit(TxtPt *cursor, TxtPt *mark, U8 *edit_buffer, U64 edit_buffer_size,
|
||||
}
|
||||
else
|
||||
{
|
||||
F32 total_text_width = f_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), edit_string).x;
|
||||
F32 total_text_width = fnt_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), edit_string).x;
|
||||
ui_set_next_pref_width(ui_px(total_text_width+ui_top_font_size()*5, 1.f));
|
||||
UI_Box *editstr_box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DisableTextTrunc, "###editstr");
|
||||
UI_LineEditDrawData *draw_data = push_array(ui_build_arena(), UI_LineEditDrawData, 1);
|
||||
@@ -264,7 +264,7 @@ ui_line_edit(TxtPt *cursor, TxtPt *mark, U8 *edit_buffer, U64 edit_buffer_size,
|
||||
ui_box_equip_display_string(editstr_box, edit_string);
|
||||
ui_box_equip_custom_draw(editstr_box, ui_line_edit_draw, draw_data);
|
||||
mouse_pt = txt_pt(1, 1+ui_box_char_pos_from_xy(editstr_box, ui_mouse()));
|
||||
cursor_off = f_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), str8_prefix(edit_string, cursor->column-1)).x;
|
||||
cursor_off = fnt_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), str8_prefix(edit_string, cursor->column-1)).x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -494,7 +494,7 @@ ui_mouse(void)
|
||||
return ui_state->mouse;
|
||||
}
|
||||
|
||||
internal F_Tag
|
||||
internal FNT_Tag
|
||||
ui_icon_font(void)
|
||||
{
|
||||
return ui_state->icon_info.icon_font;
|
||||
@@ -1427,7 +1427,7 @@ ui_end_build(void)
|
||||
UI_BoxRec rec = {0};
|
||||
for(UI_Box *b = box; !ui_box_is_nil(b); rec = ui_box_rec_df_pre(b, box), b = rec.next)
|
||||
{
|
||||
if(b->flags & UI_BoxFlag_DrawText && b->flags & UI_BoxFlag_HasDisplayString && !f_tag_match(b->font, ui_icon_font()))
|
||||
if(b->flags & UI_BoxFlag_DrawText && b->flags & UI_BoxFlag_HasDisplayString && !fnt_tag_match(b->font, ui_icon_font()))
|
||||
{
|
||||
String8 display_string = ui_box_display_string(b);
|
||||
str8_list_push(scratch.arena, &strs, display_string);
|
||||
@@ -2457,11 +2457,11 @@ internal Vec2F32
|
||||
ui_box_text_position(UI_Box *box)
|
||||
{
|
||||
Vec2F32 result = {0};
|
||||
F_Tag font = box->font;
|
||||
FNT_Tag font = box->font;
|
||||
F32 font_size = box->font_size;
|
||||
F_Metrics font_metrics = f_metrics_from_tag_size(font, font_size);
|
||||
FNT_Metrics font_metrics = fnt_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.f;
|
||||
if(!f_tag_match(font, ui_icon_font()))
|
||||
if(!fnt_tag_match(font, ui_icon_font()))
|
||||
{
|
||||
result.y += font_metrics.descent/2;
|
||||
}
|
||||
@@ -2492,10 +2492,10 @@ ui_box_text_position(UI_Box *box)
|
||||
internal U64
|
||||
ui_box_char_pos_from_xy(UI_Box *box, Vec2F32 xy)
|
||||
{
|
||||
F_Tag font = box->font;
|
||||
FNT_Tag font = box->font;
|
||||
F32 font_size = box->font_size;
|
||||
String8 line = ui_box_display_string(box);
|
||||
U64 result = f_char_pos_from_tag_size_string_p(font, font_size, 0, box->tab_size, line, xy.x - ui_box_text_position(box).x);
|
||||
U64 result = fnt_char_pos_from_tag_size_string_p(font, font_size, 0, box->tab_size, line, xy.x - ui_box_text_position(box).x);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -27,7 +27,7 @@ UI_IconKind;
|
||||
typedef struct UI_IconInfo UI_IconInfo;
|
||||
struct UI_IconInfo
|
||||
{
|
||||
F_Tag icon_font;
|
||||
FNT_Tag icon_font;
|
||||
String8 icon_kind_text_map[UI_IconKind_COUNT];
|
||||
};
|
||||
|
||||
@@ -422,10 +422,10 @@ struct UI_Box
|
||||
UI_BoxCustomDrawFunctionType *custom_draw;
|
||||
void *custom_draw_user_data;
|
||||
UI_Palette *palette;
|
||||
F_Tag font;
|
||||
FNT_Tag font;
|
||||
F32 font_size;
|
||||
F32 tab_size;
|
||||
F_RasterFlags text_raster_flags;
|
||||
FNT_RasterFlags text_raster_flags;
|
||||
F32 corner_radii[Corner_COUNT];
|
||||
F32 blur_size;
|
||||
F32 transparency;
|
||||
@@ -745,7 +745,7 @@ internal UI_State *ui_get_selected_state(void);
|
||||
internal Arena * ui_build_arena(void);
|
||||
internal OS_Handle ui_window(void);
|
||||
internal Vec2F32 ui_mouse(void);
|
||||
internal F_Tag ui_icon_font(void);
|
||||
internal FNT_Tag ui_icon_font(void);
|
||||
internal String8 ui_icon_string_from_kind(UI_IconKind icon_kind);
|
||||
internal F32 ui_dt(void);
|
||||
|
||||
@@ -874,9 +874,9 @@ internal F32 ui_top_transparency(void);
|
||||
internal UI_Palette* ui_top_palette(void);
|
||||
internal F32 ui_top_squish(void);
|
||||
internal OS_Cursor ui_top_hover_cursor(void);
|
||||
internal F_Tag ui_top_font(void);
|
||||
internal FNT_Tag ui_top_font(void);
|
||||
internal F32 ui_top_font_size(void);
|
||||
internal F_RasterFlags ui_top_text_raster_flags(void);
|
||||
internal FNT_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);
|
||||
@@ -903,9 +903,9 @@ internal F32 ui_bottom_transparency(void);
|
||||
internal UI_Palette* ui_bottom_palette(void);
|
||||
internal F32 ui_bottom_squish(void);
|
||||
internal OS_Cursor ui_bottom_hover_cursor(void);
|
||||
internal F_Tag ui_bottom_font(void);
|
||||
internal FNT_Tag ui_bottom_font(void);
|
||||
internal F32 ui_bottom_font_size(void);
|
||||
internal F_RasterFlags ui_bottom_text_raster_flags(void);
|
||||
internal FNT_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);
|
||||
@@ -932,9 +932,9 @@ internal F32 ui_push_transparency(F32 v);
|
||||
internal UI_Palette* ui_push_palette(UI_Palette* v);
|
||||
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 FNT_Tag ui_push_font(FNT_Tag v);
|
||||
internal F32 ui_push_font_size(F32 v);
|
||||
internal F_RasterFlags ui_push_text_raster_flags(F_RasterFlags v);
|
||||
internal FNT_RasterFlags ui_push_text_raster_flags(FNT_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);
|
||||
@@ -961,9 +961,9 @@ internal F32 ui_pop_transparency(void);
|
||||
internal UI_Palette* ui_pop_palette(void);
|
||||
internal F32 ui_pop_squish(void);
|
||||
internal OS_Cursor ui_pop_hover_cursor(void);
|
||||
internal F_Tag ui_pop_font(void);
|
||||
internal FNT_Tag ui_pop_font(void);
|
||||
internal F32 ui_pop_font_size(void);
|
||||
internal F_RasterFlags ui_pop_text_raster_flags(void);
|
||||
internal FNT_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);
|
||||
@@ -990,9 +990,9 @@ internal F32 ui_set_next_transparency(F32 v);
|
||||
internal UI_Palette* ui_set_next_palette(UI_Palette* v);
|
||||
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 FNT_Tag ui_set_next_font(FNT_Tag v);
|
||||
internal F32 ui_set_next_font_size(F32 v);
|
||||
internal F_RasterFlags ui_set_next_text_raster_flags(F_RasterFlags v);
|
||||
internal FNT_RasterFlags ui_set_next_text_raster_flags(FNT_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);
|
||||
|
||||
Reference in New Issue
Block a user