All rendering working without coordinate center changes
parent
36d2be14a8
commit
41b6705e84
|
@ -2698,29 +2698,6 @@ get_microseconds_timestamp(Application_Links *app)
|
|||
return(system_now_time());
|
||||
}
|
||||
|
||||
function Vec2
|
||||
models_get_coordinate_center(Models *models){
|
||||
Vec2 result = {};
|
||||
if (models->coordinate_center_stack_top > 0){
|
||||
result = models->coordinate_center_stack[models->coordinate_center_stack_top - 1];
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
function Vec2
|
||||
draw_helper__models_space_to_screen_space(Models *models, Vec2 point){
|
||||
Vec2 c = models_get_coordinate_center(models);
|
||||
return(point + c);
|
||||
}
|
||||
|
||||
function Rect_f32
|
||||
draw_helper__models_space_to_screen_space(Models *models, Rect_f32 rect){
|
||||
Vec2 c = models_get_coordinate_center(models);
|
||||
rect.p0 += c;
|
||||
rect.p1 += c;
|
||||
return(rect);
|
||||
}
|
||||
|
||||
api(custom) function Vec2
|
||||
draw_string_oriented(Application_Links *app, Face_ID font_id, String_Const_u8 str, Vec2 point, int_color color, u32 flags, Vec2 delta)
|
||||
{
|
||||
|
@ -2733,7 +2710,6 @@ draw_string_oriented(Application_Links *app, Face_ID font_id, String_Const_u8 st
|
|||
}
|
||||
else{
|
||||
Color_Table color_table = models->color_table;
|
||||
point = draw_helper__models_space_to_screen_space(models, point);
|
||||
u32 actual_color = finalize_color(color_table, color);
|
||||
f32 width = draw_string(models->target, face, str, point, actual_color, flags, delta);
|
||||
result += delta*width;
|
||||
|
@ -2754,7 +2730,6 @@ draw_rectangle(Application_Links *app, Rect_f32 rect, int_color color){
|
|||
Models *models = (Models*)app->cmd_context;
|
||||
if (models->in_render_mode){
|
||||
Color_Table color_table = models->color_table;
|
||||
rect = draw_helper__models_space_to_screen_space(models, rect);
|
||||
u32 actual_color = finalize_color(color_table, color);
|
||||
draw_rectangle(models->target, rect, actual_color);
|
||||
}
|
||||
|
@ -2766,7 +2741,6 @@ draw_rectangle_outline(Application_Links *app, Rect_f32 rect, int_color color)
|
|||
Models *models = (Models*)app->cmd_context;
|
||||
if (models->in_render_mode){
|
||||
Color_Table color_table = models->color_table;
|
||||
rect = draw_helper__models_space_to_screen_space(models, rect);
|
||||
u32 actual_color = finalize_color(color_table, color);
|
||||
draw_rectangle_outline(models->target, rect, actual_color);
|
||||
}
|
||||
|
@ -2785,27 +2759,6 @@ draw_clip_pop(Application_Links *app){
|
|||
return(Rf32(draw_pop_clip(models->target)));
|
||||
}
|
||||
|
||||
api(custom) function void
|
||||
draw_coordinate_center_push(Application_Links *app, Vec2 point){
|
||||
Models *models = (Models*)app->cmd_context;
|
||||
if (models->coordinate_center_stack_top < ArrayCount(models->coordinate_center_stack)){
|
||||
point = draw_helper__models_space_to_screen_space(models, point);
|
||||
models->coordinate_center_stack[models->coordinate_center_stack_top] = point;
|
||||
models->coordinate_center_stack_top += 1;
|
||||
}
|
||||
}
|
||||
|
||||
api(custom) function Vec2
|
||||
draw_coordinate_center_pop(Application_Links *app){
|
||||
Models *models = (Models*)app->cmd_context;
|
||||
Vec2 result = {};
|
||||
if (models->coordinate_center_stack_top > 0){
|
||||
models->coordinate_center_stack_top -= 1;
|
||||
result = models->coordinate_center_stack[models->coordinate_center_stack_top];
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
api(custom) function Text_Layout_ID
|
||||
text_layout_create(Application_Links *app, Buffer_ID buffer_id, Rect_f32 rect, Buffer_Point buffer_point){
|
||||
Models *models = (Models*)app->cmd_context;
|
||||
|
@ -2855,9 +2808,6 @@ text_layout_region(Application_Links *app, Text_Layout_ID text_layout_id){
|
|||
Text_Layout *layout = text_layout_get(&models->text_layouts, text_layout_id);
|
||||
if (layout != 0){
|
||||
result = layout->rect;
|
||||
Vec2_f32 coordinate_center = models_get_coordinate_center(models);
|
||||
result.p0 -= coordinate_center;
|
||||
result.p1 -= coordinate_center;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
@ -2911,8 +2861,6 @@ text_layout_line_on_screen(Application_Links *app, Text_Layout_ID layout_id, i64
|
|||
|
||||
result += rect.y0 - layout->point.pixel_shift.y;
|
||||
result = range_intersect(result, rect_range_y(rect));
|
||||
Vec2_f32 coordinate_center = models_get_coordinate_center(models);
|
||||
result -= coordinate_center.y;
|
||||
}
|
||||
}
|
||||
else if (line_number < layout->visible_line_number_range.min){
|
||||
|
@ -2976,10 +2924,6 @@ text_layout_character_on_screen(Application_Links *app, Text_Layout_ID layout_id
|
|||
result.p0 += shift;
|
||||
result.p1 += shift;
|
||||
result = rect_intersect(rect, result);
|
||||
|
||||
Vec2_f32 coordinate_center = models_get_coordinate_center(models);
|
||||
result.p0 -= coordinate_center;
|
||||
result.p1 -= coordinate_center;
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
|
|
|
@ -127,9 +127,6 @@ struct Models{
|
|||
|
||||
Render_Target *target;
|
||||
b32 in_render_mode;
|
||||
// TODO(allen): endless stack?
|
||||
Vec2 coordinate_center_stack[32];
|
||||
i32 coordinate_center_stack_top;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
|
|
|
@ -319,11 +319,8 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View
|
|||
|
||||
f32 line_height = face_metrics.line_height;
|
||||
|
||||
Rect_f32 sub_region = Rf32(V2(0, 0), rect_dim(view_inner_rect));
|
||||
sub_region = default_view_buffer_region(app, view_id, sub_region);
|
||||
Rect_f32 buffer_rect = Rf32(V2(view_inner_rect.p0 + sub_region.p0),
|
||||
V2(view_inner_rect.p0 + sub_region.p1));
|
||||
buffer_rect = rect_intersect(buffer_rect, view_inner_rect);
|
||||
Rect_f32 sub_region = default_view_buffer_region(app, view_id, view_inner_rect);
|
||||
Rect_f32 buffer_rect = rect_intersect(sub_region, view_inner_rect);
|
||||
|
||||
Buffer_Scroll scroll = view_get_buffer_scroll(app, view_id);
|
||||
Buffer_Point buffer_point = scroll.position;
|
||||
|
@ -496,7 +493,6 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View
|
|||
|
||||
draw_clip_push(app, buffer_rect);
|
||||
draw_text_layout(app, text_layout_id);
|
||||
text_layout_free(app, text_layout_id);
|
||||
draw_clip_pop(app);
|
||||
|
||||
// NOTE(allen): FPS HUD
|
||||
|
@ -512,8 +508,6 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View
|
|||
history_frame_index[wrapped_index] = frame_info.index;
|
||||
|
||||
Rect_f32 hud_rect = view_get_screen_rect(app, view_id);
|
||||
hud_rect.p1 -= hud_rect.p0;
|
||||
hud_rect.p0 = V2(0.f, 0.f);
|
||||
hud_rect.y0 = hud_rect.y1 - line_height*(f32)(history_depth);
|
||||
draw_rectangle(app, hud_rect, 0xFF000000);
|
||||
draw_rectangle_outline(app, hud_rect, 0xFFFFFFFF);
|
||||
|
@ -558,9 +552,7 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View
|
|||
}
|
||||
|
||||
// NOTE(allen): Frame
|
||||
Rect_f32 r_cursor = view_get_screen_rect(app, view_id);
|
||||
r_cursor.p1 -= r_cursor.p0;
|
||||
r_cursor.p0 = V2(0.f,0.f);
|
||||
Rect_f32 r_cursor = view_inner_rect;
|
||||
|
||||
// NOTE(allen): Filebar
|
||||
b32 showing_file_bar = false;
|
||||
|
@ -651,46 +643,45 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View
|
|||
|
||||
// NOTE(allen): Line Numbers
|
||||
if (global_config.show_line_number_margins){
|
||||
i32 line_count = (i32)buffer_get_line_count(app, buffer);
|
||||
i32 line_count_digit_count = (i32)digit_count_from_integer(line_count, 10);
|
||||
i64 line_count = buffer_get_line_count(app, buffer);
|
||||
i64 line_count_digit_count = digit_count_from_integer(line_count, 10);
|
||||
// TODO(allen): I need a "digit width"
|
||||
f32 zero = get_string_advance(app, face_id, string_u8_litexpr("0"));
|
||||
f32 margin_width = (f32)line_count_digit_count*zero;
|
||||
f32 margin_width = ((f32)line_count_digit_count)*zero;
|
||||
|
||||
Rect_f32 left_margin = r_cursor;
|
||||
left_margin.x1 = left_margin.x0 + margin_width + 2;
|
||||
left_margin.x1 = left_margin.x0 + margin_width + 2.f;
|
||||
r_cursor.x0 = left_margin.x1;
|
||||
|
||||
draw_rectangle(app, left_margin, Stag_Line_Numbers_Back);
|
||||
|
||||
Rect_f32 clip_region = left_margin;
|
||||
clip_region.p0 += view_inner_rect.p0;
|
||||
clip_region.p1 += view_inner_rect.p0;
|
||||
draw_clip_push(app, clip_region);
|
||||
|
||||
Fancy_Color line_color = fancy_id(Stag_Line_Numbers_Text);
|
||||
|
||||
Buffer_Cursor cursor = view_compute_cursor(app, view_id, seek_pos(visible_range.first));
|
||||
i64 line_number = cursor.line;
|
||||
for (;cursor.pos <= visible_range.one_past_last;){
|
||||
Range_f32 line_y = text_layout_line_on_screen(app, text_layout_id, cursor.line);
|
||||
Vec2_f32 p = V2f32(left_margin.x1, line_y.min);
|
||||
Temp_Memory temp = begin_temp(scratch);
|
||||
Fancy_String *line_string = push_fancy_stringf(scratch, line_color, "%*lld", line_count_digit_count, cursor.line);
|
||||
draw_fancy_string(app, face_id, line_string, p, Stag_Margin_Active, 0);
|
||||
end_temp(temp);
|
||||
i64 next_line = cursor.line + 1;
|
||||
cursor = view_compute_cursor(app, view_id, seek_line_col(next_line, 1));
|
||||
if (cursor.line < next_line){
|
||||
if (line_number > line_count){
|
||||
break;
|
||||
}
|
||||
Range_f32 line_y = text_layout_line_on_screen(app, text_layout_id, line_number);
|
||||
Vec2_f32 p = V2f32(left_margin.x0, line_y.min);
|
||||
Temp_Memory_Block temp(scratch);
|
||||
Fancy_String *line_string = push_fancy_stringf(scratch, line_color, "%*lld", line_count_digit_count, line_number);
|
||||
draw_fancy_string(app, face_id, line_string, p, Stag_Margin_Active, 0);
|
||||
line_number += 1;
|
||||
}
|
||||
|
||||
draw_clip_pop(app);
|
||||
}
|
||||
|
||||
text_layout_free(app, text_layout_id);
|
||||
}
|
||||
|
||||
internal void
|
||||
default_ui_render_caller(Application_Links *app, View_ID view_id, Rect_f32 rect_f32, Face_ID face_id){
|
||||
default_ui_render_caller(Application_Links *app, View_ID view_id, Rect_f32 rect, Face_ID face_id){
|
||||
UI_Data *ui_data = 0;
|
||||
Arena *ui_arena = 0;
|
||||
if (view_get_ui_data(app, view_id, ViewGetUIFlag_KeepDataAsIs, &ui_data, &ui_arena)){
|
||||
|
@ -700,6 +691,8 @@ default_ui_render_caller(Application_Links *app, View_ID view_id, Rect_f32 rect_
|
|||
item != 0;
|
||||
item = item->next){
|
||||
Rect_f32 item_rect = Rf32(item->rect_outer);
|
||||
item_rect.p0 += rect.p0;
|
||||
item_rect.p1 += rect.p0;
|
||||
|
||||
switch (item->coordinates){
|
||||
case UICoordinates_ViewSpace:
|
||||
|
@ -711,7 +704,7 @@ default_ui_render_caller(Application_Links *app, View_ID view_id, Rect_f32 rect_
|
|||
{}break;
|
||||
}
|
||||
|
||||
if (rect_overlap(item_rect, rect_f32)){
|
||||
if (rect_overlap(item_rect, rect)){
|
||||
Rect_f32 inner = rect_inner(item_rect, (f32)item->inner_margin);
|
||||
|
||||
Face_Metrics metrics = get_face_metrics(app, face_id);
|
||||
|
@ -732,23 +725,7 @@ default_ui_render_caller(Application_Links *app, View_ID view_id, Rect_f32 rect_
|
|||
}
|
||||
}
|
||||
internal void
|
||||
default_ui_render_caller(Application_Links *app, View_ID view_id, Rect_f32 rect_f32){
|
||||
Buffer_ID buffer = view_get_buffer(app, view_id, AccessAll);
|
||||
Face_ID face_id = get_face_id(app, buffer);
|
||||
default_ui_render_caller(app, view_id, rect_f32, face_id);
|
||||
}
|
||||
internal void
|
||||
default_ui_render_caller(Application_Links *app, View_ID view_id, Face_ID face_id){
|
||||
Rect_f32 rect = view_get_screen_rect(app, view_id);
|
||||
rect.p1 -= rect.p0;
|
||||
rect.p0 = V2(0.f,0.f);
|
||||
default_ui_render_caller(app, view_id, rect, face_id);
|
||||
}
|
||||
internal void
|
||||
default_ui_render_caller(Application_Links *app, View_ID view){
|
||||
Rect_f32 rect = view_get_screen_rect(app, view);
|
||||
rect.p1 -= rect.p0;
|
||||
rect.p0 = V2(0.f,0.f);
|
||||
default_ui_render_caller(Application_Links *app, View_ID view, Rect_f32 rect){
|
||||
Buffer_ID buffer = view_get_buffer(app, view, AccessAll);
|
||||
Face_ID face_id = get_face_id(app, buffer);
|
||||
default_ui_render_caller(app, view, rect, face_id);
|
||||
|
@ -761,14 +738,13 @@ default_render_view(Application_Links *app, Frame_Info frame_info, View_ID view,
|
|||
draw_rectangle(app, view_rect, get_margin_color(is_active?UIActivation_Active:UIActivation_None));
|
||||
draw_rectangle(app, inner, Stag_Back);
|
||||
draw_clip_push(app, inner);
|
||||
draw_coordinate_center_push(app, inner.p0);
|
||||
|
||||
Managed_Scope scope = view_get_managed_scope(app, view);
|
||||
View_Render_Hook **hook_ptr = scope_attachment(app, scope, view_render_hook, View_Render_Hook*);
|
||||
|
||||
if (*hook_ptr == 0){
|
||||
if (view_is_in_ui_mode(app, view)){
|
||||
default_ui_render_caller(app, view);
|
||||
default_ui_render_caller(app, view, inner);
|
||||
}
|
||||
else{
|
||||
default_buffer_render_caller(app, frame_info, view, inner);
|
||||
|
@ -780,7 +756,6 @@ default_render_view(Application_Links *app, Frame_Info frame_info, View_ID view,
|
|||
}
|
||||
|
||||
draw_clip_pop(app);
|
||||
draw_coordinate_center_pop(app);
|
||||
}
|
||||
|
||||
RENDER_CALLER_SIG(default_render_caller){
|
||||
|
@ -794,7 +769,6 @@ RENDER_CALLER_SIG(default_render_caller){
|
|||
|
||||
HOOK_SIG(default_exit){
|
||||
// If this returns false it cancels the exit.
|
||||
|
||||
b32 result = true;
|
||||
|
||||
if (!allow_immediate_close_without_checking_for_changes){
|
||||
|
|
|
@ -168,8 +168,6 @@ vtable->draw_rectangle = draw_rectangle;
|
|||
vtable->draw_rectangle_outline = draw_rectangle_outline;
|
||||
vtable->draw_clip_push = draw_clip_push;
|
||||
vtable->draw_clip_pop = draw_clip_pop;
|
||||
vtable->draw_coordinate_center_push = draw_coordinate_center_push;
|
||||
vtable->draw_coordinate_center_pop = draw_coordinate_center_pop;
|
||||
vtable->text_layout_create = text_layout_create;
|
||||
vtable->text_layout_region = text_layout_region;
|
||||
vtable->text_layout_get_buffer = text_layout_get_buffer;
|
||||
|
@ -354,8 +352,6 @@ draw_rectangle = vtable->draw_rectangle;
|
|||
draw_rectangle_outline = vtable->draw_rectangle_outline;
|
||||
draw_clip_push = vtable->draw_clip_push;
|
||||
draw_clip_pop = vtable->draw_clip_pop;
|
||||
draw_coordinate_center_push = vtable->draw_coordinate_center_push;
|
||||
draw_coordinate_center_pop = vtable->draw_coordinate_center_pop;
|
||||
text_layout_create = vtable->text_layout_create;
|
||||
text_layout_region = vtable->text_layout_region;
|
||||
text_layout_get_buffer = vtable->text_layout_get_buffer;
|
||||
|
|
|
@ -166,8 +166,6 @@
|
|||
#define custom_draw_rectangle_outline_sig() void custom_draw_rectangle_outline(Application_Links* app, Rect_f32 rect, int_color color)
|
||||
#define custom_draw_clip_push_sig() void custom_draw_clip_push(Application_Links* app, Rect_f32 clip_box)
|
||||
#define custom_draw_clip_pop_sig() Rect_f32 custom_draw_clip_pop(Application_Links* app)
|
||||
#define custom_draw_coordinate_center_push_sig() void custom_draw_coordinate_center_push(Application_Links* app, Vec2 point)
|
||||
#define custom_draw_coordinate_center_pop_sig() Vec2 custom_draw_coordinate_center_pop(Application_Links* app)
|
||||
#define custom_text_layout_create_sig() Text_Layout_ID custom_text_layout_create(Application_Links* app, Buffer_ID buffer_id, Rect_f32 rect, Buffer_Point buffer_point)
|
||||
#define custom_text_layout_region_sig() Rect_f32 custom_text_layout_region(Application_Links* app, Text_Layout_ID text_layout_id)
|
||||
#define custom_text_layout_get_buffer_sig() Buffer_ID custom_text_layout_get_buffer(Application_Links* app, Text_Layout_ID text_layout_id)
|
||||
|
@ -348,8 +346,6 @@ typedef void custom_draw_rectangle_type(Application_Links* app, Rect_f32 rect, i
|
|||
typedef void custom_draw_rectangle_outline_type(Application_Links* app, Rect_f32 rect, int_color color);
|
||||
typedef void custom_draw_clip_push_type(Application_Links* app, Rect_f32 clip_box);
|
||||
typedef Rect_f32 custom_draw_clip_pop_type(Application_Links* app);
|
||||
typedef void custom_draw_coordinate_center_push_type(Application_Links* app, Vec2 point);
|
||||
typedef Vec2 custom_draw_coordinate_center_pop_type(Application_Links* app);
|
||||
typedef Text_Layout_ID custom_text_layout_create_type(Application_Links* app, Buffer_ID buffer_id, Rect_f32 rect, Buffer_Point buffer_point);
|
||||
typedef Rect_f32 custom_text_layout_region_type(Application_Links* app, Text_Layout_ID text_layout_id);
|
||||
typedef Buffer_ID custom_text_layout_get_buffer_type(Application_Links* app, Text_Layout_ID text_layout_id);
|
||||
|
@ -531,8 +527,6 @@ custom_draw_rectangle_type *draw_rectangle;
|
|||
custom_draw_rectangle_outline_type *draw_rectangle_outline;
|
||||
custom_draw_clip_push_type *draw_clip_push;
|
||||
custom_draw_clip_pop_type *draw_clip_pop;
|
||||
custom_draw_coordinate_center_push_type *draw_coordinate_center_push;
|
||||
custom_draw_coordinate_center_pop_type *draw_coordinate_center_pop;
|
||||
custom_text_layout_create_type *text_layout_create;
|
||||
custom_text_layout_region_type *text_layout_region;
|
||||
custom_text_layout_get_buffer_type *text_layout_get_buffer;
|
||||
|
@ -715,8 +709,6 @@ internal void draw_rectangle(Application_Links* app, Rect_f32 rect, int_color co
|
|||
internal void draw_rectangle_outline(Application_Links* app, Rect_f32 rect, int_color color);
|
||||
internal void draw_clip_push(Application_Links* app, Rect_f32 clip_box);
|
||||
internal Rect_f32 draw_clip_pop(Application_Links* app);
|
||||
internal void draw_coordinate_center_push(Application_Links* app, Vec2 point);
|
||||
internal Vec2 draw_coordinate_center_pop(Application_Links* app);
|
||||
internal Text_Layout_ID text_layout_create(Application_Links* app, Buffer_ID buffer_id, Rect_f32 rect, Buffer_Point buffer_point);
|
||||
internal Rect_f32 text_layout_region(Application_Links* app, Text_Layout_ID text_layout_id);
|
||||
internal Buffer_ID text_layout_get_buffer(Application_Links* app, Text_Layout_ID text_layout_id);
|
||||
|
@ -899,8 +891,6 @@ global custom_draw_rectangle_type *draw_rectangle = 0;
|
|||
global custom_draw_rectangle_outline_type *draw_rectangle_outline = 0;
|
||||
global custom_draw_clip_push_type *draw_clip_push = 0;
|
||||
global custom_draw_clip_pop_type *draw_clip_pop = 0;
|
||||
global custom_draw_coordinate_center_push_type *draw_coordinate_center_push = 0;
|
||||
global custom_draw_coordinate_center_pop_type *draw_coordinate_center_pop = 0;
|
||||
global custom_text_layout_create_type *text_layout_create = 0;
|
||||
global custom_text_layout_region_type *text_layout_region = 0;
|
||||
global custom_text_layout_get_buffer_type *text_layout_get_buffer = 0;
|
||||
|
|
|
@ -166,8 +166,6 @@ api(custom) function void draw_rectangle(Application_Links* app, Rect_f32 rect,
|
|||
api(custom) function void draw_rectangle_outline(Application_Links* app, Rect_f32 rect, int_color color);
|
||||
api(custom) function void draw_clip_push(Application_Links* app, Rect_f32 clip_box);
|
||||
api(custom) function Rect_f32 draw_clip_pop(Application_Links* app);
|
||||
api(custom) function void draw_coordinate_center_push(Application_Links* app, Vec2 point);
|
||||
api(custom) function Vec2 draw_coordinate_center_pop(Application_Links* app);
|
||||
api(custom) function Text_Layout_ID text_layout_create(Application_Links* app, Buffer_ID buffer_id, Rect_f32 rect, Buffer_Point buffer_point);
|
||||
api(custom) function Rect_f32 text_layout_region(Application_Links* app, Text_Layout_ID text_layout_id);
|
||||
api(custom) function Buffer_ID text_layout_get_buffer(Application_Links* app, Text_Layout_ID text_layout_id);
|
||||
|
|
Loading…
Reference in New Issue