mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-02 20:18:12 +00:00
extend fancy string lists to include per-node rasterization flags, to correctly mix flags from various fonts; pull command tables into the vocabulary map & accelerate lookups; drive icons/display-strings for commands with vocabulary map; plug in commands/fstrs to command evaluations in watch windows
This commit is contained in:
+40
-42
@@ -45,9 +45,9 @@ dr_hash_from_string(String8 string)
|
||||
//~ rjf: Fancy String Type Functions
|
||||
|
||||
internal void
|
||||
dr_fancy_string_list_push(Arena *arena, DR_FancyStringList *list, DR_FancyString *str)
|
||||
dr_fstrs_push(Arena *arena, DR_FStrList *list, DR_FStr *str)
|
||||
{
|
||||
DR_FancyStringNode *n = push_array_no_zero(arena, DR_FancyStringNode, 1);
|
||||
DR_FStrNode *n = push_array_no_zero(arena, DR_FStrNode, 1);
|
||||
MemoryCopyStruct(&n->v, str);
|
||||
SLLQueuePush(list->first, list->last, n);
|
||||
list->node_count += 1;
|
||||
@@ -55,7 +55,21 @@ dr_fancy_string_list_push(Arena *arena, DR_FancyStringList *list, DR_FancyString
|
||||
}
|
||||
|
||||
internal void
|
||||
dr_fancy_string_list_concat_in_place(DR_FancyStringList *dst, DR_FancyStringList *to_push)
|
||||
dr_fstrs_push_new_(Arena *arena, DR_FStrList *list, DR_FStrParams *params, DR_FStrParams *overrides, String8 string)
|
||||
{
|
||||
DR_FStr fstr = {string, *params};
|
||||
for(U64 idx = 0; idx < sizeof(DR_FStrParams); idx += 1)
|
||||
{
|
||||
if(((U8 *)overrides)[idx] != 0)
|
||||
{
|
||||
((U8 *)&fstr.params)[idx] = ((U8 *)overrides)[idx];
|
||||
}
|
||||
}
|
||||
dr_fstrs_push(arena, list, &fstr);
|
||||
}
|
||||
|
||||
internal void
|
||||
dr_fstrs_concat_in_place(DR_FStrList *dst, DR_FStrList *to_push)
|
||||
{
|
||||
if(dst->last != 0 && to_push->first != 0)
|
||||
{
|
||||
@@ -71,27 +85,27 @@ dr_fancy_string_list_concat_in_place(DR_FancyStringList *dst, DR_FancyStringList
|
||||
MemoryZeroStruct(to_push);
|
||||
}
|
||||
|
||||
internal DR_FancyStringList
|
||||
dr_fancy_string_list_copy(Arena *arena, DR_FancyStringList *src)
|
||||
internal DR_FStrList
|
||||
dr_fstrs_copy(Arena *arena, DR_FStrList *src)
|
||||
{
|
||||
DR_FancyStringList dst = {0};
|
||||
for(DR_FancyStringNode *src_n = src->first; src_n != 0; src_n = src_n->next)
|
||||
DR_FStrList dst = {0};
|
||||
for(DR_FStrNode *src_n = src->first; src_n != 0; src_n = src_n->next)
|
||||
{
|
||||
DR_FancyString fstr = src_n->v;
|
||||
DR_FStr fstr = src_n->v;
|
||||
fstr.string = push_str8_copy(arena, fstr.string);
|
||||
dr_fancy_string_list_push(arena, &dst, &fstr);
|
||||
dr_fstrs_push(arena, &dst, &fstr);
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
internal String8
|
||||
dr_string_from_fancy_string_list(Arena *arena, DR_FancyStringList *list)
|
||||
dr_string_from_fstrs(Arena *arena, DR_FStrList *list)
|
||||
{
|
||||
String8 result = {0};
|
||||
result.size = list->total_size;
|
||||
result.str = push_array_no_zero(arena, U8, result.size);
|
||||
U64 idx = 0;
|
||||
for(DR_FancyStringNode *n = list->first; n != 0; n = n->next)
|
||||
for(DR_FStrNode *n = list->first; n != 0; n = n->next)
|
||||
{
|
||||
MemoryCopy(result.str+idx, n->v.string.str, n->v.string.size);
|
||||
idx += n->v.string.size;
|
||||
@@ -99,19 +113,19 @@ dr_string_from_fancy_string_list(Arena *arena, DR_FancyStringList *list)
|
||||
return result;
|
||||
}
|
||||
|
||||
internal DR_FancyRunList
|
||||
dr_fancy_run_list_from_fancy_string_list(Arena *arena, F32 tab_size_px, FNT_RasterFlags flags, DR_FancyStringList *strs)
|
||||
internal DR_FRunList
|
||||
dr_fruns_from_fstrs(Arena *arena, F32 tab_size_px, DR_FStrList *strs)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
DR_FancyRunList run_list = {0};
|
||||
DR_FRunList run_list = {0};
|
||||
F32 base_align_px = 0;
|
||||
for(DR_FancyStringNode *n = strs->first; n != 0; n = n->next)
|
||||
for(DR_FStrNode *n = strs->first; n != 0; n = n->next)
|
||||
{
|
||||
DR_FancyRunNode *dst_n = push_array(arena, DR_FancyRunNode, 1);
|
||||
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;
|
||||
DR_FRunNode *dst_n = push_array(arena, DR_FRunNode, 1);
|
||||
dst_n->v.run = fnt_push_run_from_string(arena, n->v.params.font, n->v.params.size, base_align_px, tab_size_px, n->v.params.raster_flags, n->v.string);
|
||||
dst_n->v.color = n->v.params.color;
|
||||
dst_n->v.underline_thickness = n->v.params.underline_thickness;
|
||||
dst_n->v.strikethrough_thickness = n->v.params.strikethrough_thickness;
|
||||
SLLQueuePush(run_list.first, run_list.last, dst_n);
|
||||
run_list.node_count += 1;
|
||||
run_list.dim.x += dst_n->v.run.dim.x;
|
||||
@@ -122,22 +136,6 @@ dr_fancy_run_list_from_fancy_string_list(Arena *arena, F32 tab_size_px, FNT_Rast
|
||||
return run_list;
|
||||
}
|
||||
|
||||
internal DR_FancyRunList
|
||||
dr_fancy_run_list_copy(Arena *arena, DR_FancyRunList *src)
|
||||
{
|
||||
DR_FancyRunList dst = {0};
|
||||
for(DR_FancyRunNode *src_n = src->first; src_n != 0; src_n = src_n->next)
|
||||
{
|
||||
DR_FancyRunNode *dst_n = push_array(arena, DR_FancyRunNode, 1);
|
||||
SLLQueuePush(dst.first, dst.last, dst_n);
|
||||
MemoryCopyStruct(&dst_n->v, &src_n->v);
|
||||
dst_n->v.run.pieces = fnt_piece_array_copy(arena, &src_n->v.run.pieces);
|
||||
dst.node_count += 1;
|
||||
}
|
||||
dst.dim = src->dim;
|
||||
return dst;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Top-Level API
|
||||
//
|
||||
@@ -468,7 +466,7 @@ dr_sub_bucket(DR_Bucket *bucket)
|
||||
//- rjf: text
|
||||
|
||||
internal void
|
||||
dr_truncated_fancy_run_list(Vec2F32 p, DR_FancyRunList *list, F32 max_x, FNT_Run trailer_run)
|
||||
dr_truncated_fancy_run_list(Vec2F32 p, DR_FRunList *list, F32 max_x, FNT_Run trailer_run)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
|
||||
@@ -480,9 +478,9 @@ dr_truncated_fancy_run_list(Vec2F32 p, DR_FancyRunList *list, F32 max_x, FNT_Run
|
||||
B32 trailer_found = 0;
|
||||
Vec4F32 last_color = {0};
|
||||
U64 byte_off = 0;
|
||||
for(DR_FancyRunNode *n = list->first; n != 0; n = n->next)
|
||||
for(DR_FRunNode *n = list->first; n != 0; n = n->next)
|
||||
{
|
||||
DR_FancyRun *fr = &n->v;
|
||||
DR_FRun *fr = &n->v;
|
||||
Rng1F32 pixel_range = {0};
|
||||
{
|
||||
pixel_range.min = 100000;
|
||||
@@ -571,7 +569,7 @@ dr_truncated_fancy_run_list(Vec2F32 p, DR_FancyRunList *list, F32 max_x, FNT_Run
|
||||
}
|
||||
|
||||
internal void
|
||||
dr_truncated_fancy_run_fuzzy_matches(Vec2F32 p, DR_FancyRunList *list, F32 max_x, FuzzyMatchRangeList *ranges, Vec4F32 color)
|
||||
dr_truncated_fancy_run_fuzzy_matches(Vec2F32 p, DR_FRunList *list, F32 max_x, FuzzyMatchRangeList *ranges, Vec4F32 color)
|
||||
{
|
||||
for(FuzzyMatchRangeNode *match_n = ranges->first; match_n != 0; match_n = match_n->next)
|
||||
{
|
||||
@@ -586,9 +584,9 @@ dr_truncated_fancy_run_fuzzy_matches(Vec2F32 p, DR_FancyRunList *list, F32 max_x
|
||||
F32 advance = 0;
|
||||
F32 ascent = 0;
|
||||
F32 descent = 0;
|
||||
for(DR_FancyRunNode *fr_n = list->first; fr_n != 0; fr_n = fr_n->next)
|
||||
for(DR_FRunNode *fr_n = list->first; fr_n != 0; fr_n = fr_n->next)
|
||||
{
|
||||
DR_FancyRun *fr = &fr_n->v;
|
||||
DR_FRun *fr = &fr_n->v;
|
||||
FNT_Run *run = &fr->run;
|
||||
ascent = run->ascent;
|
||||
descent = run->descent;
|
||||
|
||||
+37
-30
@@ -7,35 +7,42 @@
|
||||
////////////////////////////////
|
||||
//~ rjf: Fancy String Types
|
||||
|
||||
typedef struct DR_FancyString DR_FancyString;
|
||||
struct DR_FancyString
|
||||
typedef struct DR_FStrParams DR_FStrParams;
|
||||
struct DR_FStrParams
|
||||
{
|
||||
FNT_Tag font;
|
||||
String8 string;
|
||||
FNT_RasterFlags raster_flags;
|
||||
Vec4F32 color;
|
||||
F32 size;
|
||||
F32 underline_thickness;
|
||||
F32 strikethrough_thickness;
|
||||
};
|
||||
|
||||
typedef struct DR_FancyStringNode DR_FancyStringNode;
|
||||
struct DR_FancyStringNode
|
||||
typedef struct DR_FStr DR_FStr;
|
||||
struct DR_FStr
|
||||
{
|
||||
DR_FancyStringNode *next;
|
||||
DR_FancyString v;
|
||||
String8 string;
|
||||
DR_FStrParams params;
|
||||
};
|
||||
|
||||
typedef struct DR_FancyStringList DR_FancyStringList;
|
||||
struct DR_FancyStringList
|
||||
typedef struct DR_FStrNode DR_FStrNode;
|
||||
struct DR_FStrNode
|
||||
{
|
||||
DR_FancyStringNode *first;
|
||||
DR_FancyStringNode *last;
|
||||
DR_FStrNode *next;
|
||||
DR_FStr v;
|
||||
};
|
||||
|
||||
typedef struct DR_FStrList DR_FStrList;
|
||||
struct DR_FStrList
|
||||
{
|
||||
DR_FStrNode *first;
|
||||
DR_FStrNode *last;
|
||||
U64 node_count;
|
||||
U64 total_size;
|
||||
};
|
||||
|
||||
typedef struct DR_FancyRun DR_FancyRun;
|
||||
struct DR_FancyRun
|
||||
typedef struct DR_FRun DR_FRun;
|
||||
struct DR_FRun
|
||||
{
|
||||
FNT_Run run;
|
||||
Vec4F32 color;
|
||||
@@ -43,18 +50,18 @@ struct DR_FancyRun
|
||||
F32 strikethrough_thickness;
|
||||
};
|
||||
|
||||
typedef struct DR_FancyRunNode DR_FancyRunNode;
|
||||
struct DR_FancyRunNode
|
||||
typedef struct DR_FRunNode DR_FRunNode;
|
||||
struct DR_FRunNode
|
||||
{
|
||||
DR_FancyRunNode *next;
|
||||
DR_FancyRun v;
|
||||
DR_FRunNode *next;
|
||||
DR_FRun v;
|
||||
};
|
||||
|
||||
typedef struct DR_FancyRunList DR_FancyRunList;
|
||||
struct DR_FancyRunList
|
||||
typedef struct DR_FRunList DR_FRunList;
|
||||
struct DR_FRunList
|
||||
{
|
||||
DR_FancyRunNode *first;
|
||||
DR_FancyRunNode *last;
|
||||
DR_FRunNode *first;
|
||||
DR_FRunNode *last;
|
||||
U64 node_count;
|
||||
Vec2F32 dim;
|
||||
};
|
||||
@@ -108,13 +115,13 @@ internal U64 dr_hash_from_string(String8 string);
|
||||
////////////////////////////////
|
||||
//~ rjf: Fancy String Type Functions
|
||||
|
||||
internal void dr_fancy_string_list_push(Arena *arena, DR_FancyStringList *list, DR_FancyString *str);
|
||||
#define dr_fancy_string_list_push_new(arena, list, font_, size_, color_, string_, ...) dr_fancy_string_list_push((arena), (list), &(DR_FancyString){.font = (font_), .string = (string_), .color = (color_), .size = (size_), __VA_ARGS__})
|
||||
internal void dr_fancy_string_list_concat_in_place(DR_FancyStringList *dst, DR_FancyStringList *to_push);
|
||||
internal DR_FancyStringList dr_fancy_string_list_copy(Arena *arena, DR_FancyStringList *src);
|
||||
internal String8 dr_string_from_fancy_string_list(Arena *arena, DR_FancyStringList *list);
|
||||
internal DR_FancyRunList dr_fancy_run_list_from_fancy_string_list(Arena *arena, F32 tab_size_px, FNT_RasterFlags flags, DR_FancyStringList *strs);
|
||||
internal DR_FancyRunList dr_fancy_run_list_copy(Arena *arena, DR_FancyRunList *src);
|
||||
internal void dr_fstrs_push(Arena *arena, DR_FStrList *list, DR_FStr *str);
|
||||
internal void dr_fstrs_push_new_(Arena *arena, DR_FStrList *list, DR_FStrParams *params, DR_FStrParams *overrides, String8 string);
|
||||
#define dr_fstrs_push_new(arena, list, params, string, ...) dr_fstrs_push_new_((arena), (list), (params), &(DR_FStrParams){.size = 0, __VA_ARGS__}, (string))
|
||||
internal void dr_fstrs_concat_in_place(DR_FStrList *dst, DR_FStrList *to_push);
|
||||
internal DR_FStrList dr_fstrs_copy(Arena *arena, DR_FStrList *src);
|
||||
internal String8 dr_string_from_fstrs(Arena *arena, DR_FStrList *list);
|
||||
internal DR_FRunList dr_fruns_from_fstrs(Arena *arena, F32 tab_size_px, DR_FStrList *strs);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Top-Level API
|
||||
@@ -185,8 +192,8 @@ internal void dr_sub_bucket(DR_Bucket *bucket);
|
||||
//~ rjf: Draw Call Helpers
|
||||
|
||||
//- rjf: text
|
||||
internal void dr_truncated_fancy_run_list(Vec2F32 p, DR_FancyRunList *list, F32 max_x, FNT_Run trailer_run);
|
||||
internal void dr_truncated_fancy_run_fuzzy_matches(Vec2F32 p, DR_FancyRunList *list, F32 max_x, FuzzyMatchRangeList *ranges, Vec4F32 color);
|
||||
internal void dr_truncated_fancy_run_list(Vec2F32 p, DR_FRunList *list, F32 max_x, FNT_Run trailer_run);
|
||||
internal void dr_truncated_fancy_run_fuzzy_matches(Vec2F32 p, DR_FRunList *list, F32 max_x, FuzzyMatchRangeList *ranges, Vec4F32 color);
|
||||
internal void dr_text_run(Vec2F32 p, Vec4F32 color, FNT_Run run);
|
||||
internal void dr_text(FNT_Tag font, F32 size, F32 base_align_px, F32 tab_size_px, FNT_RasterFlags flags, Vec2F32 p, Vec4F32 color, String8 string);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user