top level render caller controlling layout directly

master
Allen Webster 2019-03-31 11:55:26 -07:00
parent 028f96b633
commit a552b0168f
15 changed files with 633 additions and 332 deletions

View File

@ -630,50 +630,6 @@ STRUCT File_Attributes{
u64 last_write_time;
};
/* DOC(Buffer_Summary acts as a handle to a buffer and describes the state of the buffer.)
DOC_SEE(Access_Flag)
DOC_SEE(Dirty_State) */
STRUCT Buffer_Summary{
/* DOC(This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder. When this field is false the summary is referred to as a "null summary".) */
b32 exists;
/* DOC(If this is not a null summary, this field indicates whether the buffer has finished loading.) */
b32 ready;
/* DOC(If this is not a null summary this field is the id of the associated buffer. If this is a null summary then buffer_id is 0.) */
Buffer_ID buffer_id;
/* DOC(If this is not a null summary, this field contains flags describing the protection status of the buffer.) */
Access_Flag lock_flags;
/* DOC(TODO) */
Buffer_Edit_Handler *edit_handler;
/* DOC(If this is not a null summary, this field specifies the number of bytes in the buffer.) */
i32 size;
/* DOC(If this is not a null summary, this field specifies the number of lines in the buffer.) */
i32 line_count;
/* DOC(If this is not a null summary, this field specifies the file name associated to this buffer.) */
char *file_name;
/* DOC(This field specifies the length of the file_name string.) */
i32 file_name_len;
/* DOC(If this is not a null summary, this field specifies the name of the buffer.) */
char *buffer_name;
/* DOC(This field specifies the length of the buffer_name string.) */
i32 buffer_name_len;
/* DOC(This field indicates the dirty state of the buffer.) */
Dirty_State dirty;
/* DOC(If this is not a null summary, this field indicates whether the buffer is set to lex tokens.) */
b32 is_lexed;
/* DOC(If this is not a null summary, this field indicates whether the buffer has up to date tokens available. If this field is false, it may simply mean the tokens are still being generated in a background task and will be available later. If that is the case, is_lexed will be true to indicate that the buffer is trying to get it's tokens up to date.) */
b32 tokens_are_ready;
/* DOC(If this is not a null summary, this field specifies the id of the command map for this buffer.) */
i32 map_id;
/* DOC(If this is not a null summary, this field indicates whether the buffer 'prefers' wrapped lines.) */
b32 unwrapped_lines;
};
/*
DOC(A markers is a location in a buffer that, once placed, is effected by edits the same way characters are effected. In particular if an edit occurs in a location in the buffer before a marker, the marker is shifted forward or backward so that it remains on the same character.)
DOC_SEE(buffer_add_markers)
@ -1067,14 +1023,6 @@ STRUCT Frame_Info{
TYPEDEF_FUNC void Render_Callback(struct Application_Links *app);
STRUCT Render_Parameters{
Frame_Info frame;
View_ID view_id;
Range on_screen_range;
Rect_i32 buffer_region;
Render_Callback *do_core_render;
};
/* DOC(Hook_IDs name the various hooks in 4coder, these hooks use the Hook_Function signature.)
DOC_SEE(Hook_Function) */
ENUM(i32, Hook_ID){
@ -1125,8 +1073,8 @@ ENUM(i32, Special_Hook_ID){
TYPEDEF_FUNC i32 Command_Caller_Hook_Function(struct Application_Links *app, Generic_Command cmd);
#define COMMAND_CALLER_HOOK(name) i32 name(struct Application_Links *app, Generic_Command cmd)
TYPEDEF_FUNC void Render_Caller_Function(struct Application_Links *app, Render_Parameters render_params);
#define RENDER_CALLER_SIG(name) void name(struct Application_Links *app, Render_Parameters render_params)
TYPEDEF_FUNC void Render_Caller_Function(struct Application_Links *app, Frame_Info frame_info);
#define RENDER_CALLER_SIG(name) void name(struct Application_Links *app, Frame_Info frame_info)
TYPEDEF_FUNC i32 Hook_Function(struct Application_Links *app);
#define HOOK_SIG(name) i32 name(struct Application_Links *app)

View File

@ -3,7 +3,7 @@
*
* In order to keep your layer on the old API you don't have to do anything, this provides wrappers
* idential to the 4.0.30 API.
* In order to transition your entire layer over to the 4.0.31 API define 'REMOVE_TRANSITION_HELPER' and fix errors.
* In order to transition your entire layer over to the 4.0.31 API define 'REMOVE_TRANSITION_HELPER_31' and fix errors.
* Or you can do it step by step by removing a few wrappers at a time.
* This transition helper will be removed in a future version so it is recommended to get off sooner or laster.
*
@ -22,10 +22,41 @@
// TOP
#if !defined(REMOVE_TRANSITION_HELPER)
#if !defined(REMOVE_TRANSITION_HELPER_31)
typedef b32 bool32;
static b32
get_buffer_summary(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_Summary *buffer){
b32 result = false;
if (buffer_exists(app, buffer_id)){
Access_Flag buffer_access_flags = 0;
buffer_get_access_flags(app, buffer_id, &buffer_access_flags);
if ((buffer_access_flags & ~access) == 0){
result = true;
buffer->exists = true;
buffer->ready = buffer_ready(app, buffer_id);
buffer->buffer_id = buffer_id;
buffer_get_size(app, buffer_id, &buffer->size);
buffer_get_line_count(app, buffer_id, &buffer->line_count);
String file_name = make_fixed_width_string(buffer->file_name);
buffer_get_file_name(app, buffer_id, &file_name, 0);
buffer->file_name_len = file_name.size;
String buffer_name = make_fixed_width_string(buffer->buffer_name);
buffer_get_unique_buffer_name(app, buffer_id, &buffer_name, 0);
buffer->buffer_name_len = buffer_name.size;
buffer_get_dirty_state(app, buffer_id, &buffer->dirty);
buffer_get_setting(app, buffer_id, BufferSetting_Lex, &buffer->is_lexed);
buffer->tokens_are_ready = buffer_tokens_are_ready(app, buffer_id);
buffer_get_setting(app, buffer_id, BufferSetting_MapID, &buffer->map_id);
buffer_get_setting(app, buffer_id, BufferSetting_WrapLine, &buffer->unwrapped_lines);
buffer->unwrapped_lines = !buffer->unwrapped_lines;
buffer->lock_flags = buffer_access_flags;
}
}
return(result);
}
static b32
exec_system_command(Application_Links *app, View_Summary *view, Buffer_Identifier buffer_id,
char *path, int32_t path_len, char *command, i32 command_len, Command_Line_Interface_Flag flags){
@ -312,7 +343,7 @@ static View_Summary
get_view_first(Application_Links *app, Access_Flag access){
View_Summary view = {};
View_ID view_id = 0;
if (get_view_first(app, access, &view_id)){
if (get_view_next(app, 0, access, &view_id)){
get_view_summary(app, view_id, access, &view);
}
return(view);

View File

@ -0,0 +1,71 @@
/*
* Helpers for the API transition from 4.0.30 to 4.0.31
*
* In order to keep your layer on the old API you don't have to do anything, this provides wrappers
* idential to the 4.0.30 API.
* In order to transition your entire layer over to the 4.0.31 API define 'REMOVE_TRANSITION_HELPER_31' and fix errors.
* Or you can do it step by step by removing a few wrappers at a time.
* This transition helper will be removed in a future version so it is recommended to get off sooner or laster.
*
* Tips on transitioning:
*
* Wrather than just try to inline this code everywhere, you can simplify things quite a lot by storing references
* to buffers and views and Buffer_ID and View_ID instead of Buffer_Summary and View_Summary.
* Just get the summaries when you need information in those structures.
*
* You will make your code simpler if you stick to String as much as possible, but whenever you want to you can switch
* to any string type you have to String by calling make_string(char_ptr, length) or make_string_slowly(null_terminated_c_str).
* To pull the char ptr and length out of a String named "string": string.str and str.size.
* If you need a null terminated string from a String use get_null_terminated in 4coder_helper.cpp
*
*/
// TOP
#if !defined(REMOVE_TRANSITION_HELPER_31)
/* DOC(Buffer_Summary acts as a handle to a buffer and describes the state of the buffer.)
DOC_SEE(Access_Flag)
DOC_SEE(Dirty_State) */
STRUCT Buffer_Summary{
/* DOC(This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder. When this field is false the summary is referred to as a "null summary".) */
b32 exists;
/* DOC(If this is not a null summary, this field indicates whether the buffer has finished loading.) */
b32 ready;
/* DOC(If this is not a null summary this field is the id of the associated buffer. If this is a null summary then buffer_id is 0.) */
Buffer_ID buffer_id;
/* DOC(If this is not a null summary, this field contains flags describing the protection status of the buffer.) */
Access_Flag lock_flags;
/* DOC(If this is not a null summary, this field specifies the number of bytes in the buffer.) */
i32 size;
/* DOC(If this is not a null summary, this field specifies the number of lines in the buffer.) */
i32 line_count;
/* DOC(If this is not a null summary, this field specifies the file name associated to this buffer.) */
char file_name[256];
/* DOC(This field specifies the length of the file_name string.) */
i32 file_name_len;
/* DOC(If this is not a null summary, this field specifies the name of the buffer.) */
char buffer_name[256];
/* DOC(This field specifies the length of the buffer_name string.) */
i32 buffer_name_len;
/* DOC(This field indicates the dirty state of the buffer.) */
Dirty_State dirty;
/* DOC(If this is not a null summary, this field indicates whether the buffer is set to lex tokens.) */
b32 is_lexed;
/* DOC(If this is not a null summary, this field indicates whether the buffer has up to date tokens available. If this field is false, it may simply mean the tokens are still being generated in a background task and will be available later. If that is the case, is_lexed will be true to indicate that the buffer is trying to get it's tokens up to date.) */
b32 tokens_are_ready;
/* DOC(If this is not a null summary, this field specifies the id of the command map for this buffer.) */
i32 map_id;
/* DOC(If this is not a null summary, this field indicates whether the buffer 'prefers' wrapped lines.) */
b32 unwrapped_lines;
};
#endif
// BOTTOM

View File

@ -127,16 +127,11 @@ typedef double f64;
#define min_u32 ((u32)0)
#define min_u64 ((u64)0)
static f32
max_f32_proc(void){
union{
u32 x;
f32 f;
} c;
c.x = 0x7f800000;
return(c.f);
}
static const f32 max_f32 = max_f32_proc();
static const f32 max_f32 = 3.4028234e+38f;
static const f32 min_f32 = 1.1754943e-38f;
static const f64 max_f64 = 1.7976931348623157e+308;
static const f64 min_f64 = 2.2250738585072014e-308;
////////////////////////////////

View File

@ -315,17 +315,39 @@ GET_VIEW_BUFFER_REGION_SIG(default_view_buffer_region){
return(sub_region);
}
struct View_Render_Parameters{
View_ID view_id;
Range on_screen_range;
Rect_i32 buffer_rect;
};
static void
default_buffer_render_caller(Application_Links *app, Render_Parameters render_params){
View_Summary view = get_view(app, render_params.view_id, AccessAll);
default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View_ID view_id, Rect_i32 view_inner_rect){
Buffer_ID buffer_id = 0;
view_get_buffer(app, view_id, AccessAll, &buffer_id);
Rect_i32 sub_region = i32R(0, 0, rect_width(view_inner_rect), rect_height(view_inner_rect));
sub_region = default_view_buffer_region(app, view_id, sub_region);
Rect_i32 buffer_rect = {};
buffer_rect.p0 = view_inner_rect.p0 + sub_region.p0;
buffer_rect.p1 = view_inner_rect.p0 + sub_region.p1;
buffer_rect.x1 = clamp_top(buffer_rect.x1, view_inner_rect.x1);
buffer_rect.y1 = clamp_top(buffer_rect.y1, view_inner_rect.y1);
buffer_rect.x0 = clamp_top(buffer_rect.x0, buffer_rect.x1);
buffer_rect.y0 = clamp_top(buffer_rect.y0, buffer_rect.y1);
Range on_screen_range = {};
compute_render_layout(app, view_id, buffer_id, buffer_rect, &on_screen_range);
View_Summary view = get_view(app, view_id, AccessAll);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessAll);
View_Summary active_view = get_active_view(app, AccessAll);
b32 is_active_view = (active_view.view_id == render_params.view_id);
b32 is_active_view = (active_view.view_id == view_id);
f32 line_height = view.line_height;
Arena *arena = context_get_arena(app);
Temp_Memory_Arena temp = begin_temp_memory(arena);
Temp_Memory_Arena major_temp = begin_temp_memory(arena);
static Managed_Scope render_scope = 0;
if (render_scope == 0){
@ -338,7 +360,7 @@ default_buffer_render_caller(Application_Links *app, Render_Parameters render_pa
// NOTE(allen): Filebar
{
b32 showing_file_bar = false;
if (view_get_setting(app, render_params.view_id, ViewSetting_ShowFileBar, &showing_file_bar)){
if (view_get_setting(app, view_id, ViewSetting_ShowFileBar, &showing_file_bar)){
if (showing_file_bar){
Rect_f32 bar = r_cursor;
bar.y1 = bar.y0 + line_height + 2.f;
@ -410,7 +432,7 @@ default_buffer_render_caller(Application_Links *app, Render_Parameters render_pa
Query_Bar *space[32];
Query_Bar_Ptr_Array query_bars = {};
query_bars.ptrs = space;
if (get_active_query_bars(app, render_params.view_id, ArrayCount(space), &query_bars)){
if (get_active_query_bars(app, view_id, ArrayCount(space), &query_bars)){
for (i32 i = 0; i < query_bars.count; i += 1){
Query_Bar *query_bar = query_bars.ptrs[i];
@ -456,17 +478,17 @@ default_buffer_render_caller(Application_Links *app, Render_Parameters render_pa
Fancy_Color line_color = fancy_id(Stag_Line_Numbers_Text);
Full_Cursor cursor = {};
view_compute_cursor(app, render_params.view_id, seek_pos(render_params.on_screen_range.first), &cursor);
for (;cursor.pos <= render_params.on_screen_range.one_past_last;){
view_compute_cursor(app, view_id, seek_pos(on_screen_range.first), &cursor);
for (;cursor.pos <= on_screen_range.one_past_last;){
Vec2 p = panel_space_from_view_space(cursor.wrapped_p, view.scroll_vars.scroll_p);
p += V2(render_params.buffer_region.p0);
p += V2(buffer_rect.p0);
p.x = left_margin.x0;
Temp_Memory_Arena temp = begin_temp_memory(arena);
Fancy_String *line_string = push_fancy_stringf(arena, line_color, "%*d", line_count_digit_count, cursor.line);
draw_fancy_string(app, font_id, line_string, p, Stag_Margin_Active, 0);
end_temp_memory(temp);
i32 next_line = cursor.line + 1;
view_compute_cursor(app, render_params.view_id, seek_line_char(next_line, 1), &cursor);
view_compute_cursor(app, view_id, seek_line_char(next_line, 1), &cursor);
if (cursor.line < next_line){
break;
}
@ -481,16 +503,16 @@ default_buffer_render_caller(Application_Links *app, Render_Parameters render_pa
// NOTE(allen): Scan for TODOs and NOTEs
{
Temp_Memory temp = begin_temp_memory(scratch);
i32 text_size = render_params.on_screen_range.one_past_last - render_params.on_screen_range.first;
i32 text_size = on_screen_range.one_past_last - on_screen_range.first;
char *text = push_array(scratch, char, text_size);
buffer_read_range(app, &buffer, render_params.on_screen_range.first, render_params.on_screen_range.one_past_last, text);
buffer_read_range(app, &buffer, on_screen_range.first, on_screen_range.one_past_last, text);
Highlight_Record *records = push_array(scratch, Highlight_Record, 0);
String tail = make_string(text, text_size);
for (i32 i = 0; i < text_size; tail.str += 1, tail.size -= 1, i += 1){
if (match_part(tail, make_lit_string("NOTE"))){
Highlight_Record *record = push_array(scratch, Highlight_Record, 1);
record->first = i + render_params.on_screen_range.first;
record->first = i + on_screen_range.first;
record->one_past_last = record->first + 4;
record->color = Stag_Text_Cycle_2;
tail.str += 3;
@ -499,7 +521,7 @@ default_buffer_render_caller(Application_Links *app, Render_Parameters render_pa
}
else if (match_part(tail, make_lit_string("TODO"))){
Highlight_Record *record = push_array(scratch, Highlight_Record, 1);
record->first = i + render_params.on_screen_range.first;
record->first = i + on_screen_range.first;
record->one_past_last = record->first + 4;
record->color = Stag_Text_Cycle_1;
tail.str += 3;
@ -664,7 +686,7 @@ default_buffer_render_caller(Application_Links *app, Render_Parameters render_pa
mark_enclosures(app, scratch, render_scope, &buffer, pos, FindScope_Paren, VisualType_CharacterBlocks, 0, colors, color_count);
}
render_params.do_core_render(app);
draw_render_layout(app, view_id);
// NOTE(allen): FPS HUD
if (show_fps_hud){
@ -673,10 +695,10 @@ default_buffer_render_caller(Application_Links *app, Render_Parameters render_pa
static f32 history_animation_dt[history_depth] = {};
static i32 history_frame_index[history_depth] = {};
i32 wrapped_index = render_params.frame.index%history_depth;
history_literal_dt[wrapped_index] = render_params.frame.literal_dt;
history_animation_dt[wrapped_index] = render_params.frame.animation_dt;
history_frame_index[wrapped_index] = render_params.frame.index;
i32 wrapped_index = frame_info.index%history_depth;
history_literal_dt[wrapped_index] = frame_info.literal_dt;
history_animation_dt[wrapped_index] = frame_info.animation_dt;
history_frame_index[wrapped_index] = frame_info.index;
Rect_f32 hud_rect = f32R(view.render_region);
hud_rect.y0 = hud_rect.y1 - view.line_height*(f32)(history_depth);
@ -730,7 +752,7 @@ default_buffer_render_caller(Application_Links *app, Render_Parameters render_pa
}
}
end_temp_memory(temp);
end_temp_memory(major_temp);
managed_scope_clear_self_all_dependent_scopes(app, render_scope);
}
@ -756,12 +778,12 @@ get_margin_color(i32 level){
}
static void
default_ui_render_caller(Application_Links *app, Render_Parameters render_params){
default_ui_render_caller(Application_Links *app, View_ID view_id){
UI_Data *ui_data = 0;
Arena *ui_arena = 0;
if (view_get_ui_data(app, render_params.view_id, ViewGetUIFlag_KeepDataAsIs, &ui_data, &ui_arena)){
if (view_get_ui_data(app, view_id, ViewGetUIFlag_KeepDataAsIs, &ui_data, &ui_arena)){
View_Summary view = {};
if (get_view_summary(app, render_params.view_id, AccessAll, &view)){
if (get_view_summary(app, view_id, AccessAll, &view)){
Rect_f32 rect_f32 = f32R(view.render_region);
GUI_Scroll_Vars ui_scroll = view.scroll_vars;
@ -806,12 +828,33 @@ default_ui_render_caller(Application_Links *app, Render_Parameters render_params
}
}
RENDER_CALLER_SIG(default_render_caller){
if (view_is_in_ui_mode(app, render_params.view_id)){
default_ui_render_caller(app, render_params);
static void
default_render_view(Application_Links *app, Frame_Info frame_info, View_ID view_id, b32 is_active){
Rect_i32 view_rect = {};
view_get_region(app, view_id, &view_rect);
Rect_i32 inner = get_inner_rect(view_rect, 3);
draw_rectangle(app, f32R(view_rect), get_margin_color(is_active?UIActivation_Active:UIActivation_None));
draw_rectangle(app, f32R(inner), Stag_Back);
draw_clip_push(app, f32R(inner));
draw_coordinate_center_push(app, V2(inner.p0));
if (view_is_in_ui_mode(app, view_id)){
default_ui_render_caller(app, view_id);
}
else{
default_buffer_render_caller(app, render_params);
default_buffer_render_caller(app, frame_info, view_id, inner);
}
draw_clip_pop(app);
draw_coordinate_center_pop(app);
}
RENDER_CALLER_SIG(default_render_caller){
View_ID active_view_id = 0;
get_active_view(app, AccessAll, &active_view_id);
View_ID view_id = 0;
for (get_view_next(app, 0, AccessAll, &view_id);
view_id != 0;
get_view_next(app, view_id, AccessAll, &view_id)){
default_render_view(app, frame_info, view_id, (active_view_id == view_id));
}
}

View File

@ -24,6 +24,7 @@
#include "4coder_lib/4coder_utf8.h"
#include "4coder_lib/4cpp_lexer.h"
#include "4coder_api_transition_30_31.h"
#include "4coder_helper.h"
#include "4coder_fancy.h"

View File

@ -14,7 +14,6 @@ struct Application_Links;
#define GET_BUFFER_COUNT_SIG(n) i32 n(Application_Links *app)
#define GET_BUFFER_FIRST_SIG(n) b32 n(Application_Links *app, Access_Flag access, Buffer_ID *buffer_id_out)
#define GET_BUFFER_NEXT_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_ID *buffer_id_out)
#define GET_BUFFER_SUMMARY_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_Summary *buffer_summary_out)
#define GET_BUFFER_BY_NAME_SIG(n) b32 n(Application_Links *app, String name, Access_Flag access, Buffer_ID *buffer_id_out)
#define GET_BUFFER_BY_FILE_NAME_SIG(n) b32 n(Application_Links *app, String file_name, Access_Flag access, Buffer_ID *buffer_id_out)
#define BUFFER_READ_RANGE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 one_past_last, char *out)
@ -45,12 +44,12 @@ struct Application_Links;
#define BUFFER_KILL_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Buffer_Kill_Flag flags, Buffer_Kill_Result *result)
#define BUFFER_REOPEN_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags, Buffer_Reopen_Result *result)
#define BUFFER_GET_FILE_ATTRIBUTES_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, File_Attributes *attributes_out)
#define GET_VIEW_FIRST_SIG(n) b32 n(Application_Links *app, Access_Flag access, View_ID *view_id_out)
#define GET_VIEW_NEXT_SIG(n) b32 n(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out)
#define GET_VIEW_PREV_SIG(n) b32 n(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out)
#define GET_VIEW_SUMMARY_SIG(n) b32 n(Application_Links *app, View_ID view_id, Access_Flag access, View_Summary *view_summary_out)
#define GET_ACTIVE_VIEW_SIG(n) b32 n(Application_Links *app, Access_Flag access, View_ID *view_id_out)
#define GET_ACTIVE_PANEL_SIG(n) b32 n(Application_Links *app, Panel_ID *panel_id_out)
#define VIEW_GET_BUFFER_SIG(n) b32 n(Application_Links *app, View_ID view_id, Access_Flag access, Buffer_ID *buffer_id_out)
#define VIEW_GET_PANEL_SIG(n) b32 n(Application_Links *app, View_ID view_id, Panel_ID *panel_id_out)
#define PANEL_GET_VIEW_SIG(n) b32 n(Application_Links *app, Panel_ID panel_id, View_ID *view_id_out)
#define PANEL_IS_SPLIT_SIG(n) b32 n(Application_Links *app, Panel_ID panel_id)
@ -63,6 +62,7 @@ struct Application_Links;
#define PANEL_GET_MAX_SIG(n) b32 n(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out)
#define PANEL_GET_MARGIN_SIG(n) b32 n(Application_Links *app, Panel_ID panel_id, i32_Rect *margins_out)
#define VIEW_CLOSE_SIG(n) b32 n(Application_Links *app, View_ID view_id)
#define VIEW_GET_REGION_SIG(n) b32 n(Application_Links *app, View_ID view_id, Rect_i32 *region_out)
#define VIEW_GET_BUFFER_REGION_SIG(n) b32 n(Application_Links *app, View_ID view_id, Rect_i32 *region_out)
#define VIEW_SET_ACTIVE_SIG(n) b32 n(Application_Links *app, View_ID view_id)
#define VIEW_GET_SETTING_SIG(n) b32 n(Application_Links *app, View_ID view_id, View_Setting_ID setting, i32 *value_out)
@ -158,11 +158,15 @@ struct Application_Links;
#define GET_MICROSECONDS_TIMESTAMP_SIG(n) Microsecond_Time_Stamp n(Application_Links *app)
#define DRAW_STRING_SIG(n) Vec2 n(Application_Links *app, Face_ID font_id, String str, Vec2 point, int_color color, u32 flags, Vec2 delta)
#define GET_STRING_ADVANCE_SIG(n) f32 n(Application_Links *app, Face_ID font_id, String str)
#define DRAW_RECTANGLE_SIG(n) void n(Application_Links *app, f32_Rect rect, int_color color)
#define DRAW_RECTANGLE_SIG(n) void n(Application_Links *app, Rect_f32 rect, int_color color)
#define DRAW_RECTANGLE_OUTLINE_SIG(n) void n(Application_Links *app, f32_Rect rect, int_color color)
#define DRAW_CLIP_PUSH_SIG(n) void n(Application_Links *app, f32_Rect clip_box)
#define DRAW_CLIP_POP_SIG(n) f32_Rect n(Application_Links *app)
#define DRAW_COORDINATE_CENTER_PUSH_SIG(n) void n(Application_Links *app, Vec2 point)
#define DRAW_COORDINATE_CENTER_POP_SIG(n) Vec2 n(Application_Links *app)
#define GET_DEFAULT_FONT_FOR_VIEW_SIG(n) Face_ID n(Application_Links *app, View_ID view_id)
#define COMPUTE_RENDER_LAYOUT_SIG(n) b32 n(Application_Links *app, View_ID view_id, Buffer_ID buffer_id, Rect_i32 rect, Range *on_screen_range_out)
#define DRAW_RENDER_LAYOUT_SIG(n) void n(Application_Links *app, View_ID view_id)
#define OPEN_COLOR_PICKER_SIG(n) void n(Application_Links *app, color_picker *picker)
#define ANIMATE_IN_N_MILLISECONDS_SIG(n) void n(Application_Links *app, u32 n)
#define FIND_ALL_IN_RANGE_INSENSITIVE_SIG(n) Found_String_List n(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 end, String key, Partition *memory)
@ -182,7 +186,6 @@ typedef CREATE_PARSE_CONTEXT_SIG(Create_Parse_Context_Function);
typedef GET_BUFFER_COUNT_SIG(Get_Buffer_Count_Function);
typedef GET_BUFFER_FIRST_SIG(Get_Buffer_First_Function);
typedef GET_BUFFER_NEXT_SIG(Get_Buffer_Next_Function);
typedef GET_BUFFER_SUMMARY_SIG(Get_Buffer_Summary_Function);
typedef GET_BUFFER_BY_NAME_SIG(Get_Buffer_By_Name_Function);
typedef GET_BUFFER_BY_FILE_NAME_SIG(Get_Buffer_By_File_Name_Function);
typedef BUFFER_READ_RANGE_SIG(Buffer_Read_Range_Function);
@ -213,12 +216,12 @@ typedef BUFFER_SAVE_SIG(Buffer_Save_Function);
typedef BUFFER_KILL_SIG(Buffer_Kill_Function);
typedef BUFFER_REOPEN_SIG(Buffer_Reopen_Function);
typedef BUFFER_GET_FILE_ATTRIBUTES_SIG(Buffer_Get_File_Attributes_Function);
typedef GET_VIEW_FIRST_SIG(Get_View_First_Function);
typedef GET_VIEW_NEXT_SIG(Get_View_Next_Function);
typedef GET_VIEW_PREV_SIG(Get_View_Prev_Function);
typedef GET_VIEW_SUMMARY_SIG(Get_View_Summary_Function);
typedef GET_ACTIVE_VIEW_SIG(Get_Active_View_Function);
typedef GET_ACTIVE_PANEL_SIG(Get_Active_Panel_Function);
typedef VIEW_GET_BUFFER_SIG(View_Get_Buffer_Function);
typedef VIEW_GET_PANEL_SIG(View_Get_Panel_Function);
typedef PANEL_GET_VIEW_SIG(Panel_Get_View_Function);
typedef PANEL_IS_SPLIT_SIG(Panel_Is_Split_Function);
@ -231,6 +234,7 @@ typedef PANEL_GET_CHILD_SIG(Panel_Get_Child_Function);
typedef PANEL_GET_MAX_SIG(Panel_Get_Max_Function);
typedef PANEL_GET_MARGIN_SIG(Panel_Get_Margin_Function);
typedef VIEW_CLOSE_SIG(View_Close_Function);
typedef VIEW_GET_REGION_SIG(View_Get_Region_Function);
typedef VIEW_GET_BUFFER_REGION_SIG(View_Get_Buffer_Region_Function);
typedef VIEW_SET_ACTIVE_SIG(View_Set_Active_Function);
typedef VIEW_GET_SETTING_SIG(View_Get_Setting_Function);
@ -330,7 +334,11 @@ typedef DRAW_RECTANGLE_SIG(Draw_Rectangle_Function);
typedef DRAW_RECTANGLE_OUTLINE_SIG(Draw_Rectangle_Outline_Function);
typedef DRAW_CLIP_PUSH_SIG(Draw_Clip_Push_Function);
typedef DRAW_CLIP_POP_SIG(Draw_Clip_Pop_Function);
typedef DRAW_COORDINATE_CENTER_PUSH_SIG(Draw_Coordinate_Center_Push_Function);
typedef DRAW_COORDINATE_CENTER_POP_SIG(Draw_Coordinate_Center_Pop_Function);
typedef GET_DEFAULT_FONT_FOR_VIEW_SIG(Get_Default_Font_For_View_Function);
typedef COMPUTE_RENDER_LAYOUT_SIG(Compute_Render_Layout_Function);
typedef DRAW_RENDER_LAYOUT_SIG(Draw_Render_Layout_Function);
typedef OPEN_COLOR_PICKER_SIG(Open_Color_Picker_Function);
typedef ANIMATE_IN_N_MILLISECONDS_SIG(Animate_In_N_Milliseconds_Function);
typedef FIND_ALL_IN_RANGE_INSENSITIVE_SIG(Find_All_In_Range_Insensitive_Function);
@ -352,7 +360,6 @@ Create_Parse_Context_Function *create_parse_context;
Get_Buffer_Count_Function *get_buffer_count;
Get_Buffer_First_Function *get_buffer_first;
Get_Buffer_Next_Function *get_buffer_next;
Get_Buffer_Summary_Function *get_buffer_summary;
Get_Buffer_By_Name_Function *get_buffer_by_name;
Get_Buffer_By_File_Name_Function *get_buffer_by_file_name;
Buffer_Read_Range_Function *buffer_read_range;
@ -383,12 +390,12 @@ Buffer_Save_Function *buffer_save;
Buffer_Kill_Function *buffer_kill;
Buffer_Reopen_Function *buffer_reopen;
Buffer_Get_File_Attributes_Function *buffer_get_file_attributes;
Get_View_First_Function *get_view_first;
Get_View_Next_Function *get_view_next;
Get_View_Prev_Function *get_view_prev;
Get_View_Summary_Function *get_view_summary;
Get_Active_View_Function *get_active_view;
Get_Active_Panel_Function *get_active_panel;
View_Get_Buffer_Function *view_get_buffer;
View_Get_Panel_Function *view_get_panel;
Panel_Get_View_Function *panel_get_view;
Panel_Is_Split_Function *panel_is_split;
@ -401,6 +408,7 @@ Panel_Get_Child_Function *panel_get_child;
Panel_Get_Max_Function *panel_get_max;
Panel_Get_Margin_Function *panel_get_margin;
View_Close_Function *view_close;
View_Get_Region_Function *view_get_region;
View_Get_Buffer_Region_Function *view_get_buffer_region;
View_Set_Active_Function *view_set_active;
View_Get_Setting_Function *view_get_setting;
@ -500,7 +508,11 @@ Draw_Rectangle_Function *draw_rectangle;
Draw_Rectangle_Outline_Function *draw_rectangle_outline;
Draw_Clip_Push_Function *draw_clip_push;
Draw_Clip_Pop_Function *draw_clip_pop;
Draw_Coordinate_Center_Push_Function *draw_coordinate_center_push;
Draw_Coordinate_Center_Pop_Function *draw_coordinate_center_pop;
Get_Default_Font_For_View_Function *get_default_font_for_view;
Compute_Render_Layout_Function *compute_render_layout;
Draw_Render_Layout_Function *draw_render_layout;
Open_Color_Picker_Function *open_color_picker;
Animate_In_N_Milliseconds_Function *animate_in_n_milliseconds;
Find_All_In_Range_Insensitive_Function *find_all_in_range_insensitive;
@ -521,7 +533,6 @@ Create_Parse_Context_Function *create_parse_context_;
Get_Buffer_Count_Function *get_buffer_count_;
Get_Buffer_First_Function *get_buffer_first_;
Get_Buffer_Next_Function *get_buffer_next_;
Get_Buffer_Summary_Function *get_buffer_summary_;
Get_Buffer_By_Name_Function *get_buffer_by_name_;
Get_Buffer_By_File_Name_Function *get_buffer_by_file_name_;
Buffer_Read_Range_Function *buffer_read_range_;
@ -552,12 +563,12 @@ Buffer_Save_Function *buffer_save_;
Buffer_Kill_Function *buffer_kill_;
Buffer_Reopen_Function *buffer_reopen_;
Buffer_Get_File_Attributes_Function *buffer_get_file_attributes_;
Get_View_First_Function *get_view_first_;
Get_View_Next_Function *get_view_next_;
Get_View_Prev_Function *get_view_prev_;
Get_View_Summary_Function *get_view_summary_;
Get_Active_View_Function *get_active_view_;
Get_Active_Panel_Function *get_active_panel_;
View_Get_Buffer_Function *view_get_buffer_;
View_Get_Panel_Function *view_get_panel_;
Panel_Get_View_Function *panel_get_view_;
Panel_Is_Split_Function *panel_is_split_;
@ -570,6 +581,7 @@ Panel_Get_Child_Function *panel_get_child_;
Panel_Get_Max_Function *panel_get_max_;
Panel_Get_Margin_Function *panel_get_margin_;
View_Close_Function *view_close_;
View_Get_Region_Function *view_get_region_;
View_Get_Buffer_Region_Function *view_get_buffer_region_;
View_Set_Active_Function *view_set_active_;
View_Get_Setting_Function *view_get_setting_;
@ -669,7 +681,11 @@ Draw_Rectangle_Function *draw_rectangle_;
Draw_Rectangle_Outline_Function *draw_rectangle_outline_;
Draw_Clip_Push_Function *draw_clip_push_;
Draw_Clip_Pop_Function *draw_clip_pop_;
Draw_Coordinate_Center_Push_Function *draw_coordinate_center_push_;
Draw_Coordinate_Center_Pop_Function *draw_coordinate_center_pop_;
Get_Default_Font_For_View_Function *get_default_font_for_view_;
Compute_Render_Layout_Function *compute_render_layout_;
Draw_Render_Layout_Function *draw_render_layout_;
Open_Color_Picker_Function *open_color_picker_;
Animate_In_N_Milliseconds_Function *animate_in_n_milliseconds_;
Find_All_In_Range_Insensitive_Function *find_all_in_range_insensitive_;
@ -698,7 +714,6 @@ app_links->create_parse_context_ = Create_Parse_Context;\
app_links->get_buffer_count_ = Get_Buffer_Count;\
app_links->get_buffer_first_ = Get_Buffer_First;\
app_links->get_buffer_next_ = Get_Buffer_Next;\
app_links->get_buffer_summary_ = Get_Buffer_Summary;\
app_links->get_buffer_by_name_ = Get_Buffer_By_Name;\
app_links->get_buffer_by_file_name_ = Get_Buffer_By_File_Name;\
app_links->buffer_read_range_ = Buffer_Read_Range;\
@ -729,12 +744,12 @@ app_links->buffer_save_ = Buffer_Save;\
app_links->buffer_kill_ = Buffer_Kill;\
app_links->buffer_reopen_ = Buffer_Reopen;\
app_links->buffer_get_file_attributes_ = Buffer_Get_File_Attributes;\
app_links->get_view_first_ = Get_View_First;\
app_links->get_view_next_ = Get_View_Next;\
app_links->get_view_prev_ = Get_View_Prev;\
app_links->get_view_summary_ = Get_View_Summary;\
app_links->get_active_view_ = Get_Active_View;\
app_links->get_active_panel_ = Get_Active_Panel;\
app_links->view_get_buffer_ = View_Get_Buffer;\
app_links->view_get_panel_ = View_Get_Panel;\
app_links->panel_get_view_ = Panel_Get_View;\
app_links->panel_is_split_ = Panel_Is_Split;\
@ -747,6 +762,7 @@ app_links->panel_get_child_ = Panel_Get_Child;\
app_links->panel_get_max_ = Panel_Get_Max;\
app_links->panel_get_margin_ = Panel_Get_Margin;\
app_links->view_close_ = View_Close;\
app_links->view_get_region_ = View_Get_Region;\
app_links->view_get_buffer_region_ = View_Get_Buffer_Region;\
app_links->view_set_active_ = View_Set_Active;\
app_links->view_get_setting_ = View_Get_Setting;\
@ -846,7 +862,11 @@ app_links->draw_rectangle_ = Draw_Rectangle;\
app_links->draw_rectangle_outline_ = Draw_Rectangle_Outline;\
app_links->draw_clip_push_ = Draw_Clip_Push;\
app_links->draw_clip_pop_ = Draw_Clip_Pop;\
app_links->draw_coordinate_center_push_ = Draw_Coordinate_Center_Push;\
app_links->draw_coordinate_center_pop_ = Draw_Coordinate_Center_Pop;\
app_links->get_default_font_for_view_ = Get_Default_Font_For_View;\
app_links->compute_render_layout_ = Compute_Render_Layout;\
app_links->draw_render_layout_ = Draw_Render_Layout;\
app_links->open_color_picker_ = Open_Color_Picker;\
app_links->animate_in_n_milliseconds_ = Animate_In_N_Milliseconds;\
app_links->find_all_in_range_insensitive_ = Find_All_In_Range_Insensitive;\
@ -867,7 +887,6 @@ static Parse_Context_ID create_parse_context(Application_Links *app, Parser_Stri
static i32 get_buffer_count(Application_Links *app){return(app->get_buffer_count(app));}
static b32 get_buffer_first(Application_Links *app, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_first(app, access, buffer_id_out));}
static b32 get_buffer_next(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_next(app, buffer_id, access, buffer_id_out));}
static b32 get_buffer_summary(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_Summary *buffer_summary_out){return(app->get_buffer_summary(app, buffer_id, access, buffer_summary_out));}
static b32 get_buffer_by_name(Application_Links *app, String name, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_by_name(app, name, access, buffer_id_out));}
static b32 get_buffer_by_file_name(Application_Links *app, String file_name, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_by_file_name(app, file_name, access, buffer_id_out));}
static b32 buffer_read_range(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 one_past_last, char *out){return(app->buffer_read_range(app, buffer_id, start, one_past_last, out));}
@ -898,12 +917,12 @@ static b32 buffer_save(Application_Links *app, Buffer_ID buffer_id, String file_
static b32 buffer_kill(Application_Links *app, Buffer_ID buffer_id, Buffer_Kill_Flag flags, Buffer_Kill_Result *result){return(app->buffer_kill(app, buffer_id, flags, result));}
static b32 buffer_reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags, Buffer_Reopen_Result *result){return(app->buffer_reopen(app, buffer_id, flags, result));}
static b32 buffer_get_file_attributes(Application_Links *app, Buffer_ID buffer_id, File_Attributes *attributes_out){return(app->buffer_get_file_attributes(app, buffer_id, attributes_out));}
static b32 get_view_first(Application_Links *app, Access_Flag access, View_ID *view_id_out){return(app->get_view_first(app, access, view_id_out));}
static b32 get_view_next(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out){return(app->get_view_next(app, view_id, access, view_id_out));}
static b32 get_view_prev(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out){return(app->get_view_prev(app, view_id, access, view_id_out));}
static b32 get_view_summary(Application_Links *app, View_ID view_id, Access_Flag access, View_Summary *view_summary_out){return(app->get_view_summary(app, view_id, access, view_summary_out));}
static b32 get_active_view(Application_Links *app, Access_Flag access, View_ID *view_id_out){return(app->get_active_view(app, access, view_id_out));}
static b32 get_active_panel(Application_Links *app, Panel_ID *panel_id_out){return(app->get_active_panel(app, panel_id_out));}
static b32 view_get_buffer(Application_Links *app, View_ID view_id, Access_Flag access, Buffer_ID *buffer_id_out){return(app->view_get_buffer(app, view_id, access, buffer_id_out));}
static b32 view_get_panel(Application_Links *app, View_ID view_id, Panel_ID *panel_id_out){return(app->view_get_panel(app, view_id, panel_id_out));}
static b32 panel_get_view(Application_Links *app, Panel_ID panel_id, View_ID *view_id_out){return(app->panel_get_view(app, panel_id, view_id_out));}
static b32 panel_is_split(Application_Links *app, Panel_ID panel_id){return(app->panel_is_split(app, panel_id));}
@ -916,6 +935,7 @@ static b32 panel_get_child(Application_Links *app, Panel_ID panel_id, Panel_Chil
static b32 panel_get_max(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out){return(app->panel_get_max(app, panel_id, panel_id_out));}
static b32 panel_get_margin(Application_Links *app, Panel_ID panel_id, i32_Rect *margins_out){return(app->panel_get_margin(app, panel_id, margins_out));}
static b32 view_close(Application_Links *app, View_ID view_id){return(app->view_close(app, view_id));}
static b32 view_get_region(Application_Links *app, View_ID view_id, Rect_i32 *region_out){return(app->view_get_region(app, view_id, region_out));}
static b32 view_get_buffer_region(Application_Links *app, View_ID view_id, Rect_i32 *region_out){return(app->view_get_buffer_region(app, view_id, region_out));}
static b32 view_set_active(Application_Links *app, View_ID view_id){return(app->view_set_active(app, view_id));}
static b32 view_get_setting(Application_Links *app, View_ID view_id, View_Setting_ID setting, i32 *value_out){return(app->view_get_setting(app, view_id, setting, value_out));}
@ -1011,11 +1031,15 @@ static b32 set_window_title(Application_Links *app, String title){return(app->se
static Microsecond_Time_Stamp get_microseconds_timestamp(Application_Links *app){return(app->get_microseconds_timestamp(app));}
static Vec2 draw_string(Application_Links *app, Face_ID font_id, String str, Vec2 point, int_color color, u32 flags, Vec2 delta){return(app->draw_string(app, font_id, str, point, color, flags, delta));}
static f32 get_string_advance(Application_Links *app, Face_ID font_id, String str){return(app->get_string_advance(app, font_id, str));}
static void draw_rectangle(Application_Links *app, f32_Rect rect, int_color color){(app->draw_rectangle(app, rect, color));}
static void draw_rectangle(Application_Links *app, Rect_f32 rect, int_color color){(app->draw_rectangle(app, rect, color));}
static void draw_rectangle_outline(Application_Links *app, f32_Rect rect, int_color color){(app->draw_rectangle_outline(app, rect, color));}
static void draw_clip_push(Application_Links *app, f32_Rect clip_box){(app->draw_clip_push(app, clip_box));}
static f32_Rect draw_clip_pop(Application_Links *app){return(app->draw_clip_pop(app));}
static void draw_coordinate_center_push(Application_Links *app, Vec2 point){(app->draw_coordinate_center_push(app, point));}
static Vec2 draw_coordinate_center_pop(Application_Links *app){return(app->draw_coordinate_center_pop(app));}
static Face_ID get_default_font_for_view(Application_Links *app, View_ID view_id){return(app->get_default_font_for_view(app, view_id));}
static b32 compute_render_layout(Application_Links *app, View_ID view_id, Buffer_ID buffer_id, Rect_i32 rect, Range *on_screen_range_out){return(app->compute_render_layout(app, view_id, buffer_id, rect, on_screen_range_out));}
static void draw_render_layout(Application_Links *app, View_ID view_id){(app->draw_render_layout(app, view_id));}
static void open_color_picker(Application_Links *app, color_picker *picker){(app->open_color_picker(app, picker));}
static void animate_in_n_milliseconds(Application_Links *app, u32 n){(app->animate_in_n_milliseconds(app, n));}
static Found_String_List find_all_in_range_insensitive(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 end, String key, Partition *memory){return(app->find_all_in_range_insensitive(app, buffer_id, start, end, key, memory));}
@ -1036,7 +1060,6 @@ static Parse_Context_ID create_parse_context(Application_Links *app, Parser_Stri
static i32 get_buffer_count(Application_Links *app){return(app->get_buffer_count_(app));}
static b32 get_buffer_first(Application_Links *app, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_first_(app, access, buffer_id_out));}
static b32 get_buffer_next(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_next_(app, buffer_id, access, buffer_id_out));}
static b32 get_buffer_summary(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_Summary *buffer_summary_out){return(app->get_buffer_summary_(app, buffer_id, access, buffer_summary_out));}
static b32 get_buffer_by_name(Application_Links *app, String name, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_by_name_(app, name, access, buffer_id_out));}
static b32 get_buffer_by_file_name(Application_Links *app, String file_name, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_by_file_name_(app, file_name, access, buffer_id_out));}
static b32 buffer_read_range(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 one_past_last, char *out){return(app->buffer_read_range_(app, buffer_id, start, one_past_last, out));}
@ -1067,12 +1090,12 @@ static b32 buffer_save(Application_Links *app, Buffer_ID buffer_id, String file_
static b32 buffer_kill(Application_Links *app, Buffer_ID buffer_id, Buffer_Kill_Flag flags, Buffer_Kill_Result *result){return(app->buffer_kill_(app, buffer_id, flags, result));}
static b32 buffer_reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags, Buffer_Reopen_Result *result){return(app->buffer_reopen_(app, buffer_id, flags, result));}
static b32 buffer_get_file_attributes(Application_Links *app, Buffer_ID buffer_id, File_Attributes *attributes_out){return(app->buffer_get_file_attributes_(app, buffer_id, attributes_out));}
static b32 get_view_first(Application_Links *app, Access_Flag access, View_ID *view_id_out){return(app->get_view_first_(app, access, view_id_out));}
static b32 get_view_next(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out){return(app->get_view_next_(app, view_id, access, view_id_out));}
static b32 get_view_prev(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out){return(app->get_view_prev_(app, view_id, access, view_id_out));}
static b32 get_view_summary(Application_Links *app, View_ID view_id, Access_Flag access, View_Summary *view_summary_out){return(app->get_view_summary_(app, view_id, access, view_summary_out));}
static b32 get_active_view(Application_Links *app, Access_Flag access, View_ID *view_id_out){return(app->get_active_view_(app, access, view_id_out));}
static b32 get_active_panel(Application_Links *app, Panel_ID *panel_id_out){return(app->get_active_panel_(app, panel_id_out));}
static b32 view_get_buffer(Application_Links *app, View_ID view_id, Access_Flag access, Buffer_ID *buffer_id_out){return(app->view_get_buffer_(app, view_id, access, buffer_id_out));}
static b32 view_get_panel(Application_Links *app, View_ID view_id, Panel_ID *panel_id_out){return(app->view_get_panel_(app, view_id, panel_id_out));}
static b32 panel_get_view(Application_Links *app, Panel_ID panel_id, View_ID *view_id_out){return(app->panel_get_view_(app, panel_id, view_id_out));}
static b32 panel_is_split(Application_Links *app, Panel_ID panel_id){return(app->panel_is_split_(app, panel_id));}
@ -1085,6 +1108,7 @@ static b32 panel_get_child(Application_Links *app, Panel_ID panel_id, Panel_Chil
static b32 panel_get_max(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out){return(app->panel_get_max_(app, panel_id, panel_id_out));}
static b32 panel_get_margin(Application_Links *app, Panel_ID panel_id, i32_Rect *margins_out){return(app->panel_get_margin_(app, panel_id, margins_out));}
static b32 view_close(Application_Links *app, View_ID view_id){return(app->view_close_(app, view_id));}
static b32 view_get_region(Application_Links *app, View_ID view_id, Rect_i32 *region_out){return(app->view_get_region_(app, view_id, region_out));}
static b32 view_get_buffer_region(Application_Links *app, View_ID view_id, Rect_i32 *region_out){return(app->view_get_buffer_region_(app, view_id, region_out));}
static b32 view_set_active(Application_Links *app, View_ID view_id){return(app->view_set_active_(app, view_id));}
static b32 view_get_setting(Application_Links *app, View_ID view_id, View_Setting_ID setting, i32 *value_out){return(app->view_get_setting_(app, view_id, setting, value_out));}
@ -1180,11 +1204,15 @@ static b32 set_window_title(Application_Links *app, String title){return(app->se
static Microsecond_Time_Stamp get_microseconds_timestamp(Application_Links *app){return(app->get_microseconds_timestamp_(app));}
static Vec2 draw_string(Application_Links *app, Face_ID font_id, String str, Vec2 point, int_color color, u32 flags, Vec2 delta){return(app->draw_string_(app, font_id, str, point, color, flags, delta));}
static f32 get_string_advance(Application_Links *app, Face_ID font_id, String str){return(app->get_string_advance_(app, font_id, str));}
static void draw_rectangle(Application_Links *app, f32_Rect rect, int_color color){(app->draw_rectangle_(app, rect, color));}
static void draw_rectangle(Application_Links *app, Rect_f32 rect, int_color color){(app->draw_rectangle_(app, rect, color));}
static void draw_rectangle_outline(Application_Links *app, f32_Rect rect, int_color color){(app->draw_rectangle_outline_(app, rect, color));}
static void draw_clip_push(Application_Links *app, f32_Rect clip_box){(app->draw_clip_push_(app, clip_box));}
static f32_Rect draw_clip_pop(Application_Links *app){return(app->draw_clip_pop_(app));}
static void draw_coordinate_center_push(Application_Links *app, Vec2 point){(app->draw_coordinate_center_push_(app, point));}
static Vec2 draw_coordinate_center_pop(Application_Links *app){return(app->draw_coordinate_center_pop_(app));}
static Face_ID get_default_font_for_view(Application_Links *app, View_ID view_id){return(app->get_default_font_for_view_(app, view_id));}
static b32 compute_render_layout(Application_Links *app, View_ID view_id, Buffer_ID buffer_id, Rect_i32 rect, Range *on_screen_range_out){return(app->compute_render_layout_(app, view_id, buffer_id, rect, on_screen_range_out));}
static void draw_render_layout(Application_Links *app, View_ID view_id){(app->draw_render_layout_(app, view_id));}
static void open_color_picker(Application_Links *app, color_picker *picker){(app->open_color_picker_(app, picker));}
static void animate_in_n_milliseconds(Application_Links *app, u32 n){(app->animate_in_n_milliseconds_(app, n));}
static Found_String_List find_all_in_range_insensitive(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 end, String key, Partition *memory){return(app->find_all_in_range_insensitive_(app, buffer_id, start, end, key, memory));}

View File

@ -631,7 +631,7 @@ get_view_last(Application_Links *app, Access_Flag access, View_ID *view_id_out){
static View_ID
get_next_view_looped_all_panels(Application_Links *app, View_ID view_id, Access_Flag access){
if (!get_view_next(app, view_id, access, &view_id)){
if (!get_view_first(app, access, &view_id)){
if (!get_view_next(app, 0, access, &view_id)){
view_id = 0;
}
}

17
4ed.cpp
View File

@ -1453,13 +1453,14 @@ App_Step_Sig(app_step){
animation_dt = literal_dt;
}
Frame_Info frame = {};
frame.index = models->frame_counter;
frame.literal_dt = literal_dt;
frame.animation_dt = animation_dt;
{
Color_Table color_table = models->fallback_color_table;
if (models->modify_color_table != 0){
Frame_Info frame = {};
frame.index = models->frame_counter;
frame.literal_dt = literal_dt;
frame.animation_dt = animation_dt;
color_table = models->modify_color_table(&models->app_links, frame);
if (color_table.count < models->fallback_color_table.count){
block_copy(models->fallback_color_table.vals, color_table.vals, color_table.count*sizeof(*color_table.vals));
@ -1470,7 +1471,13 @@ App_Step_Sig(app_step){
}
begin_render_section(target, system, models->frame_counter, literal_dt, animation_dt);
models->in_render_mode = true;
if (models->render_caller != 0){
models->render_caller(&models->app_links, frame);
}
#if 0
Panel *active_panel = layout_get_active_panel(layout);
View *active_view = active_panel->view;
@ -1510,7 +1517,9 @@ App_Step_Sig(app_step){
draw_rectangle(target, i32R( full.x0, inner.y0, inner.x0, inner.y1), margin_color);
draw_rectangle(target, i32R(inner.x1, inner.y0, full.x1, inner.y1), margin_color);
}
#endif
models->in_render_mode = false;
end_render_section(target, system);
}

View File

@ -16,35 +16,6 @@ access_test(u32 lock_flags, u32 access_flags){
return((lock_flags & ~access_flags) == 0);
}
internal void
fill_buffer_summary(Buffer_Summary *buffer, Editing_File *file, Working_Set *working_set){
block_zero_struct(buffer);
if (!file->is_dummy){
buffer->exists = 1;
buffer->ready = file_is_ready(file);
buffer->buffer_id = file->id.id;
buffer->size = buffer_size(&file->state.buffer);
buffer->line_count = file->state.buffer.line_count;
buffer->file_name_len = file->canon.name.size;
buffer->file_name = file->canon.name.str;
buffer->buffer_name_len = file->unique_name.name.size;
buffer->buffer_name = file->unique_name.name.str;
buffer->dirty = file->state.dirty;
buffer->is_lexed = file->settings.tokens_exist;
buffer->tokens_are_ready = file_tokens_are_ready(file);
buffer->map_id = file->settings.base_map_id;
buffer->unwrapped_lines = file->settings.unwrapped_lines;
buffer->lock_flags = file_get_access_flags(file);
}
}
internal void
fill_view_summary(System_Functions *system, View_Summary *view, View *vptr, Live_Views *live_set, Working_Set *working_set){
block_zero_struct(view);
@ -691,12 +662,16 @@ DOC_SEE(get_buffer_first)
*buffer_id_out = file->id.id;
result = true;
}
else{
*buffer_id_out = 0;
}
return(result);
}
#if 0
// TODO(allen): redocument
API_EXPORT b32
Get_Buffer_Summary(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_Summary *buffer_summary_out)
//Get_Buffer_Summary(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_Summary *buffer_summary_out)
/*
DOC_PARAM(buffer_id, The parameter buffer_id specifies which buffer to try to get.)
DOC_PARAM(access, The access parameter determines what levels of protection this call can access.)
@ -715,6 +690,7 @@ DOC_SEE(Buffer_ID)
}
return(result);
}
#endif
// TODO(allen): redocument
API_EXPORT b32
@ -1872,36 +1848,6 @@ get_view_prev__inner(Layout *layout, View *view){
return(view);
}
// TODO(allen): replace this with get_view_next(app, 0, access, view_id_out);
// TODO(allen): redocument
API_EXPORT b32
Get_View_First(Application_Links *app, Access_Flag access, View_ID *view_id_out)
/*
DOC_PARAM(access, The access parameter determines what levels of protection this call can access.)
DOC_RETURN(This call returns the summary of the first view in a view loop.)
DOC(
This call begins a loop across all the open views.
If the View_Summary returned is a null summary, the loop is finished.
Views should not be closed or opened durring a view loop.
)
DOC_SEE(Access_Flag)
DOC_SEE(get_view_next)
*/{
Models *models = (Models*)app->cmd_context;
Layout *layout = &models->layout;
View *view = get_view_next__inner(layout, 0);
for (;view != 0 && !access_test(view_get_access_flags(view), access);){
view = get_view_next__inner(layout, view);
}
b32 result = false;
if (view != 0){
*view_id_out = view_get_id(&models->live_set, view);
result = true;
}
return(result);
}
// TODO(allen): redocument
API_EXPORT b32
Get_View_Next(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out)
@ -1930,6 +1876,9 @@ DOC_SEE(get_view_first)
*view_id_out = view_get_id(&models->live_set, view);
result = true;
}
else{
*view_id_out = 0;
}
return(result);
}
@ -2009,6 +1958,21 @@ Get_Active_Panel(Application_Links *app, Panel_ID *panel_id_out){
return(result);
}
API_EXPORT b32
View_Get_Buffer(Application_Links *app, View_ID view_id, Access_Flag access, Buffer_ID *buffer_id_out){
Models *models = (Models*)app->cmd_context;
View *view = imp_get_view(models, view_id);
b32 result = false;
if (view_api_check_view(view)){
Editing_File *file = view->file;
if (buffer_api_check_file(file, access)){
*buffer_id_out = file->id.id;
result = true;
}
}
return(result);
}
API_EXPORT b32
View_Get_Panel(Application_Links *app, View_ID view_id, Panel_ID *panel_id_out){
Models *models = (Models*)app->cmd_context;
@ -2238,13 +2202,25 @@ in the system, the call will fail.)
return(result);
}
API_EXPORT b32
View_Get_Region(Application_Links *app, View_ID view_id, Rect_i32 *region_out){
Models *models = (Models*)app->cmd_context;
View *view = imp_get_view(models, view_id);
b32 result = false;
if (view_api_check_view(view)){
*region_out = view->panel->rect_full;
result = true;
}
return(result);
}
API_EXPORT b32
View_Get_Buffer_Region(Application_Links *app, View_ID view_id, Rect_i32 *region_out){
Models *models = (Models*)app->cmd_context;
View *view = imp_get_view(models, view_id);
b32 result = false;
if (view_api_check_view(view)){
*region_out = view_get_file_region(models, view);
*region_out = view_get_buffer_rect(models, view);
result = true;
}
return(result);
@ -4454,16 +4430,39 @@ DOC(Returns a microsecond resolution timestamp.)
}
internal Vec2
draw_helper__view_space_to_screen_space(Models *models, Vec2 point){
i32_Rect region = models->render_view_rect;
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);
}
internal Vec2
draw_helper__models_space_to_screen_space(Models *models, Vec2 point){
Vec2 c = models_get_coordinate_center(models);
return(point + c);
}
internal f32_Rect
draw_helper__models_space_to_screen_space(Models *models, f32_Rect rect){
Vec2 c = models_get_coordinate_center(models);
rect.p0 += c;
rect.p1 += c;
return(rect);
}
internal Vec2
draw_helper__view_space_to_screen_space(View *view, Vec2 point){
i32_Rect region = view->render.view_rect;
point.x += (f32)region.x0;
point.y += (f32)region.y0;
return(point);
}
internal f32_Rect
draw_helper__view_space_to_screen_space(Models *models, f32_Rect rect){
i32_Rect region = models->render_view_rect;
draw_helper__view_space_to_screen_space(View *view, f32_Rect rect){
i32_Rect region = view->render.view_rect;
f32 x_corner = (f32)region.x0;
f32 y_corner = (f32)region.y0;
rect.x0 += x_corner;
@ -4474,16 +4473,16 @@ draw_helper__view_space_to_screen_space(Models *models, f32_Rect rect){
}
internal Vec2
draw_helper__screen_space_to_view_space(Models *models, Vec2 point){
i32_Rect region = models->render_view_rect;
draw_helper__screen_space_to_view_space(View *view, Vec2 point){
i32_Rect region = view->render.view_rect;
point.x -= (f32)region.x0;
point.y -= (f32)region.y0;
return(point);
}
internal f32_Rect
draw_helper__screen_space_to_view_space(Models *models, f32_Rect rect){
i32_Rect region = models->render_view_rect;
draw_helper__screen_space_to_view_space(View *view, f32_Rect rect){
i32_Rect region = view->render.view_rect;
f32 x_corner = (f32)region.x0;
f32 y_corner = (f32)region.y0;
rect.x0 -= x_corner;
@ -4502,13 +4501,13 @@ Draw_String(Application_Links *app, Face_ID font_id, String str, Vec2 point, int
{
Vec2 result = point;
Models *models = (Models*)app->cmd_context;
if (models->render_view == 0){
if (models->target == 0){
f32 width = font_string_width(models->system, models->target, font_id, str);
result += delta*width;
}
else{
Color_Table color_table = models->color_table;
point = draw_helper__view_space_to_screen_space(models, point);
point = draw_helper__models_space_to_screen_space(models, point);
u32 actual_color = finalize_color(color_table, color);
f32 width = draw_string(models->system, models->target, font_id, str, point, actual_color, flags, delta);
result += delta*width;
@ -4524,11 +4523,11 @@ Get_String_Advance(Application_Links *app, Face_ID font_id, String str)
}
API_EXPORT void
Draw_Rectangle(Application_Links *app, f32_Rect rect, int_color color){
Draw_Rectangle(Application_Links *app, Rect_f32 rect, int_color color){
Models *models = (Models*)app->cmd_context;
if (models->render_view != 0){
if (models->in_render_mode){
Color_Table color_table = models->color_table;
rect = draw_helper__view_space_to_screen_space(models, rect);
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);
}
@ -4538,13 +4537,9 @@ API_EXPORT void
Draw_Rectangle_Outline(Application_Links *app, f32_Rect rect, int_color color)
{
Models *models = (Models*)app->cmd_context;
if (models->render_view != 0){
if (models->in_render_mode){
Color_Table color_table = models->color_table;
//Style *style = &models->styles.styles[0];
//Theme *theme_data = &style->theme;
rect = draw_helper__view_space_to_screen_space(models, rect);
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);
}
@ -4553,7 +4548,7 @@ Draw_Rectangle_Outline(Application_Links *app, f32_Rect rect, int_color color)
API_EXPORT void
Draw_Clip_Push(Application_Links *app, f32_Rect clip_box){
Models *models = (Models*)app->cmd_context;
clip_box = draw_helper__view_space_to_screen_space(models, clip_box);
clip_box = draw_helper__models_space_to_screen_space(models, clip_box);
render_push_clip(models->target, i32R(clip_box));
}
@ -4561,7 +4556,27 @@ API_EXPORT f32_Rect
Draw_Clip_Pop(Application_Links *app){
Models *models = (Models*)app->cmd_context;
f32_Rect result = f32R(render_pop_clip(models->target));
result = draw_helper__screen_space_to_view_space(models, result);
return(result);
}
API_EXPORT 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_EXPORT 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);
}
@ -4576,11 +4591,142 @@ Get_Default_Font_For_View(Application_Links *app, View_ID view_id)
return(face_id);
}
API_EXPORT b32
Compute_Render_Layout(Application_Links *app, View_ID view_id, Buffer_ID buffer_id, Rect_i32 rect, Range *on_screen_range_out){
Models *models = (Models*)app->cmd_context;
System_Functions *system = models->system;
View *view = imp_get_view(models, view_id);
Editing_File *file = imp_get_file(models, buffer_id);
b32 result = false;
if (view_api_check_view(view) && buffer_api_check_file(file)){
i32 line_height = view->line_height;
f32 max_x = (f32)file->settings.display_width;
i32 max_y = rect.y1 - rect.y0 + line_height;
f32 left_side_space = 0;
// TODO(allen): Don't force me to over-allocate! Write a looser buffer render thingy,
// or just stop doing that nonsense all together.
f32 screen_width = (f32)rect_width(rect);
f32 screen_height = (f32)rect_height(rect);
f32 smallest_char_width = 6.f;
f32 smallest_char_height = 8.f;
i32 max = (i32)(screen_width*screen_height/(smallest_char_width*smallest_char_height))*2;
if (view->layout_arena.app == 0){
view->layout_arena = make_arena(app);
}
else{
arena_release_all(&view->layout_arena);
}
Buffer_Render_Item *items = push_array(&view->layout_arena, Buffer_Render_Item, max);
b32 wrapped = !file->settings.unwrapped_lines;
Face_ID font_id = file->settings.font_id;
Font_Pointers font = system->font.get_pointers_by_id(font_id);
File_Edit_Positions edit_pos = view_get_edit_pos(view);
f32 scroll_x = edit_pos.scroll.scroll_x;
f32 scroll_y = edit_pos.scroll.scroll_y;
Full_Cursor render_cursor = view_get_render_cursor(system, view);
i32 item_count = 0;
i32 end_pos = 0;
{
Buffer_Render_Params params;
params.buffer = &file->state.buffer;
params.items = items;
params.max = max;
params.count = &item_count;
params.port_x = (f32)rect.x0 + left_side_space;
params.port_y = (f32)rect.y0;
params.clip_w = view_width(models, view) - left_side_space;
params.scroll_x = scroll_x;
params.scroll_y = scroll_y;
params.width = max_x;
params.height = (f32)max_y;
params.start_cursor = render_cursor;
params.wrapped = wrapped;
params.system = system;
params.font = font;
params.virtual_white = file->settings.virtual_white;
params.wrap_slashes = file->settings.wrap_indicator;
Buffer_Render_State state = {};
Buffer_Layout_Stop stop = {};
f32 line_shift = 0.f;
b32 do_wrap = false;
i32 wrap_unit_end = 0;
b32 first_wrap_determination = true;
i32 wrap_array_index = 0;
do{
stop = buffer_render_data(&state, params, line_shift, do_wrap, wrap_unit_end);
switch (stop.status){
case BLStatus_NeedWrapDetermination:
{
if (first_wrap_determination){
wrap_array_index = binary_search(file->state.wrap_positions, stop.pos, 0, file->state.wrap_position_count);
++wrap_array_index;
if (file->state.wrap_positions[wrap_array_index] == stop.pos){
do_wrap = true;
wrap_unit_end = file->state.wrap_positions[wrap_array_index];
}
else{
do_wrap = false;
wrap_unit_end = file->state.wrap_positions[wrap_array_index];
}
first_wrap_determination = false;
}
else{
Assert(stop.pos == wrap_unit_end);
do_wrap = true;
++wrap_array_index;
wrap_unit_end = file->state.wrap_positions[wrap_array_index];
}
}break;
case BLStatus_NeedWrapLineShift:
case BLStatus_NeedLineShift:
{
line_shift = file->state.line_indents[stop.wrap_line_index];
}break;
}
}while(stop.status != BLStatus_Finished);
end_pos = state.i;
}
Range range = {render_cursor.pos, end_pos};
view->render.view_rect = view->panel->rect_inner;
view->render.buffer_rect = rect;
view->render.cursor = render_cursor;
view->render.range = range;
view->render.items = items;
view->render.item_count = item_count;
*on_screen_range_out = range;
}
return(result);
}
API_EXPORT void
Draw_Render_Layout(Application_Links *app, View_ID view_id){
Models *models = (Models*)app->cmd_context;
View *view = imp_get_view(models, view_id);
if (view_api_check_view(view) && models->target != 0){
render_loaded_file_in_view__inner(models, models->target, view, view->render.buffer_rect,
view->render.cursor, view->render.range,
view->render.items, view->render.item_count);
arena_release_all(&view->layout_arena);
}
}
API_EXPORT void
Open_Color_Picker(Application_Links *app, color_picker *picker)
/*
DOC(Opens a color picker using the parameters in the supplied structure.)
*/
{
Models *models = (Models*)app->cmd_context;
System_Functions *system = models->system;

View File

@ -117,8 +117,13 @@ struct Models{
Application_Step_Input *input;
Key_Event_Data key;
// Render Context
Render_Target *target;
b32 in_render_mode;
// TODO(allen): endless stack?
Vec2 coordinate_center_stack[32];
i32 coordinate_center_stack_top;
#if 0
View *render_view;
i32_Rect render_view_rect;
i32_Rect render_buffer_rect;
@ -126,6 +131,7 @@ struct Models{
Range render_range;
Buffer_Render_Item *render_items;
i32 render_item_count;
#endif
};
////////////////////////////////

View File

@ -167,8 +167,10 @@ struct Buffer_Render_Item{
i32 index;
u32 codepoint;
u32 flags;
f32 x0, y0;
f32 x1, y1;
f32 x0;
f32 y0;
f32 x1;
f32 y1;
};
struct Render_Item_Write{

View File

@ -87,7 +87,7 @@ view_set_edit_pos(View *view, File_Edit_Positions edit_pos){
////////////////////////////////
internal Rect_i32
view_get_file_region(Models *models, View *view){
view_get_buffer_rect(Models *models, View *view){
Rect_i32 region = {};
if (models->get_view_buffer_region != 0){
Rect_i32 rect = view->panel->rect_inner;
@ -108,12 +108,12 @@ view_get_file_region(Models *models, View *view){
internal i32
view_width(Models *models, View *view){
return(rect_width(view_get_file_region(models, view)));
return(rect_width(view_get_buffer_rect(models, view)));
}
internal i32
view_height(Models *models, View *view){
return(rect_height(view_get_file_region(models, view)));
return(rect_height(view_get_buffer_rect(models, view)));
}
internal Vec2_i32
@ -1195,6 +1195,7 @@ render_loaded_file_in_view__inner(Models *models, Render_Target *target, View *v
}
}
#if 0
internal void
dont_do_core_render(Application_Links *app){}
@ -1212,6 +1213,7 @@ do_core_render(Application_Links *app){
render_loaded_file_in_view__inner(models, target, view, rect, render_cursor, on_screen_range, items, item_count);
draw_pop_clip(target);
}
#endif
internal Full_Cursor
view_get_render_cursor(System_Functions *system, View *view, f32 scroll_y){
@ -1242,6 +1244,7 @@ view_get_render_cursor_target(System_Functions *system, View *view){
return(view_get_render_cursor(system, view, scroll_y));
}
#if 0
internal void
view_call_render_caller(Models *models, Render_Target *target, View *view,
i32_Rect rect, Full_Cursor render_cursor, Range on_screen_range, Buffer_Render_Item *items, i32 item_count, Render_Callback *core_render){
@ -1255,136 +1258,22 @@ view_call_render_caller(Models *models, Render_Target *target, View *view,
models->render_items = items;
models->render_item_count = item_count;
Frame_Info frame = {};
frame.index = target->frame_index;
frame.literal_dt = target->literal_dt;
frame.animation_dt = target->animation_dt;
#if 0
Render_Parameters params = {};
params.view_id = view_id;
params.on_screen_range = on_screen_range;
params.frame.index = target->frame_index;
params.frame.literal_dt = target->literal_dt;
params.frame.animation_dt = target->animation_dt;
params.buffer_region = rect;
params.do_core_render = core_render;
models->render_caller(&models->app_links, params);
#endif
models->render_caller(&models->app_links, frame);
models->render_view = 0;
}
}
internal void
render_loaded_file_in_view(System_Functions *system, View *view, Models *models, i32_Rect rect, b32 is_active, Render_Target *target){
Editing_File *file = view->file;
i32 line_height = view->line_height;
f32 max_x = (f32)file->settings.display_width;
i32 max_y = rect.y1 - rect.y0 + line_height;
Assert(file != 0);
Assert(!file->is_dummy);
Assert(buffer_good(&file->state.buffer));
Partition *part = &models->mem.part;
Temp_Memory temp = begin_temp_memory(part);
push_align(part, 4);
f32 left_side_space = 0;
i32 max = part_remaining(part)/sizeof(Buffer_Render_Item);
Buffer_Render_Item *items = push_array(part, Buffer_Render_Item, 0);
b32 wrapped = !file->settings.unwrapped_lines;
Face_ID font_id = file->settings.font_id;
Font_Pointers font = system->font.get_pointers_by_id(font_id);
File_Edit_Positions edit_pos = view_get_edit_pos(view);
f32 scroll_x = edit_pos.scroll.scroll_x;
f32 scroll_y = edit_pos.scroll.scroll_y;
Full_Cursor render_cursor = view_get_render_cursor(system, view);
i32 item_count = 0;
i32 end_pos = 0;
{
Buffer_Render_Params params;
params.buffer = &file->state.buffer;
params.items = items;
params.max = max;
params.count = &item_count;
params.port_x = (f32)rect.x0 + left_side_space;
params.port_y = (f32)rect.y0;
params.clip_w = view_width(models, view) - left_side_space;
params.scroll_x = scroll_x;
params.scroll_y = scroll_y;
params.width = max_x;
params.height = (f32)max_y;
params.start_cursor = render_cursor;
params.wrapped = wrapped;
params.system = system;
params.font = font;
params.virtual_white = file->settings.virtual_white;
params.wrap_slashes = file->settings.wrap_indicator;
Buffer_Render_State state = {};
Buffer_Layout_Stop stop = {};
f32 line_shift = 0.f;
b32 do_wrap = false;
i32 wrap_unit_end = 0;
b32 first_wrap_determination = true;
i32 wrap_array_index = 0;
do{
stop = buffer_render_data(&state, params, line_shift, do_wrap, wrap_unit_end);
switch (stop.status){
case BLStatus_NeedWrapDetermination:
{
if (first_wrap_determination){
wrap_array_index = binary_search(file->state.wrap_positions, stop.pos, 0, file->state.wrap_position_count);
++wrap_array_index;
if (file->state.wrap_positions[wrap_array_index] == stop.pos){
do_wrap = true;
wrap_unit_end = file->state.wrap_positions[wrap_array_index];
}
else{
do_wrap = false;
wrap_unit_end = file->state.wrap_positions[wrap_array_index];
}
first_wrap_determination = false;
}
else{
Assert(stop.pos == wrap_unit_end);
do_wrap = true;
++wrap_array_index;
wrap_unit_end = file->state.wrap_positions[wrap_array_index];
}
}break;
case BLStatus_NeedWrapLineShift:
case BLStatus_NeedLineShift:
{
line_shift = file->state.line_indents[stop.wrap_line_index];
}break;
}
}while(stop.status != BLStatus_Finished);
end_pos = state.i;
}
push_array(part, Buffer_Render_Item, item_count);
Range on_screen_range = {};
on_screen_range.first = render_cursor.pos;
on_screen_range.one_past_last = end_pos;
////////////////////////////////
if (models->render_caller != 0){
view_call_render_caller(models, target, view, rect, render_cursor, on_screen_range, items, item_count, do_core_render);
}
else{
render_loaded_file_in_view__inner(models, target, view, rect, render_cursor, on_screen_range, items, item_count);
}
end_temp_memory(temp);
}
#endif
// BOTTOM

View File

@ -46,6 +46,19 @@ struct View{
i32 line_height;
Query_Set query_set;
// Render Context
Arena layout_arena;
struct{
i32_Rect view_rect;
i32_Rect buffer_rect;
Full_Cursor cursor;
Range range;
Buffer_Render_Item *items;
i32 item_count;
} render;
#if 0
f32 widget_height;
#endif

View File

@ -38,6 +38,7 @@ do_step_file_view(System_Functions *system, Models *models, View *view, i32_Rect
////////////////////////////////
#if 0
internal void
do_render_file_view(System_Functions *system, View *view, Models *models, GUI_Scroll_Vars *scroll, View *active, i32_Rect rect, b32 is_active, Render_Target *target){
Editing_File *file = view->file;
@ -45,17 +46,135 @@ do_render_file_view(System_Functions *system, View *view, Models *models, GUI_Sc
draw_push_clip(target, rect);
if (!view->ui_mode){
if (file_is_ready(file)){
Rect_i32 file_region = view_get_file_region(models, view);
render_loaded_file_in_view(system, view, models, file_region, is_active, target);
Rect_i32 buffer_rect = view_get_buffer_rect(models, view);
//render_loaded_file_in_view(system, view, models, buffer_rect, is_active, target);
Editing_File *file = view->file;
i32 line_height = view->line_height;
f32 max_x = (f32)file->settings.display_width;
i32 max_y = buffer_rect.y1 - buffer_rect.y0 + line_height;
Assert(file != 0);
Assert(!file->is_dummy);
Assert(buffer_good(&file->state.buffer));
Partition *part = &models->mem.part;
Temp_Memory temp = begin_temp_memory(part);
push_align(part, 4);
f32 left_side_space = 0;
i32 max = part_remaining(part)/sizeof(Buffer_Render_Item);
Buffer_Render_Item *items = push_array(part, Buffer_Render_Item, 0);
b32 wrapped = !file->settings.unwrapped_lines;
Face_ID font_id = file->settings.font_id;
Font_Pointers font = system->font.get_pointers_by_id(font_id);
File_Edit_Positions edit_pos = view_get_edit_pos(view);
f32 scroll_x = edit_pos.scroll.scroll_x;
f32 scroll_y = edit_pos.scroll.scroll_y;
Full_Cursor render_cursor = view_get_render_cursor(system, view);
i32 item_count = 0;
i32 end_pos = 0;
{
Buffer_Render_Params params;
params.buffer = &file->state.buffer;
params.items = items;
params.max = max;
params.count = &item_count;
params.port_x = (f32)buffer_rect.x0 + left_side_space;
params.port_y = (f32)buffer_rect.y0;
params.clip_w = view_width(models, view) - left_side_space;
params.scroll_x = scroll_x;
params.scroll_y = scroll_y;
params.width = max_x;
params.height = (f32)max_y;
params.start_cursor = render_cursor;
params.wrapped = wrapped;
params.system = system;
params.font = font;
params.virtual_white = file->settings.virtual_white;
params.wrap_slashes = file->settings.wrap_indicator;
Buffer_Render_State state = {};
Buffer_Layout_Stop stop = {};
f32 line_shift = 0.f;
b32 do_wrap = false;
i32 wrap_unit_end = 0;
b32 first_wrap_determination = true;
i32 wrap_array_index = 0;
do{
stop = buffer_render_data(&state, params, line_shift, do_wrap, wrap_unit_end);
switch (stop.status){
case BLStatus_NeedWrapDetermination:
{
if (first_wrap_determination){
wrap_array_index = binary_search(file->state.wrap_positions, stop.pos, 0, file->state.wrap_position_count);
++wrap_array_index;
if (file->state.wrap_positions[wrap_array_index] == stop.pos){
do_wrap = true;
wrap_unit_end = file->state.wrap_positions[wrap_array_index];
}
else{
do_wrap = false;
wrap_unit_end = file->state.wrap_positions[wrap_array_index];
}
first_wrap_determination = false;
}
else{
Assert(stop.pos == wrap_unit_end);
do_wrap = true;
++wrap_array_index;
wrap_unit_end = file->state.wrap_positions[wrap_array_index];
}
}break;
case BLStatus_NeedWrapLineShift:
case BLStatus_NeedLineShift:
{
line_shift = file->state.line_indents[stop.wrap_line_index];
}break;
}
}while(stop.status != BLStatus_Finished);
end_pos = state.i;
}
push_array(part, Buffer_Render_Item, item_count);
Range on_screen_range = {};
on_screen_range.first = render_cursor.pos;
on_screen_range.one_past_last = end_pos;
////////////////////////////////
if (models->render_caller != 0){
view_call_render_caller(models, target, view, buffer_rect, render_cursor, on_screen_range, items, item_count, do_core_render);
}
else{
render_loaded_file_in_view__inner(models, target, view, buffer_rect, render_cursor, on_screen_range, items, item_count);
}
end_temp_memory(temp);
}
}
else{
Full_Cursor render_cursor = {};
Range on_screen_range = {};
view_call_render_caller(models, target, view, rect, render_cursor, on_screen_range, 0, 0, dont_do_core_render);
if (models->render_caller != 0){
view_call_render_caller(models, target, view, buffer_rect, render_cursor, on_screen_range, 0, 0, dont_do_core_render);
}
}
draw_pop_clip(target);
}
#endif
// BOTTOM