2018-03-26 05:19:08 +00:00
|
|
|
/*
|
|
|
|
* Mr. 4th Dimention - Allen Webster
|
|
|
|
*
|
2018-08-04 02:41:38 +00:00
|
|
|
* ??.??.2018
|
2018-03-26 05:19:08 +00:00
|
|
|
*
|
|
|
|
* View GUI layouts and implementations
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TOP
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
2019-02-26 19:59:57 +00:00
|
|
|
internal GUI_Scroll_Vars
|
|
|
|
do_step_file_view(System_Functions *system, Models *models, View *view, i32_Rect rect, b32 is_active, f32 dt, GUI_Scroll_Vars scroll){
|
2019-02-27 05:49:35 +00:00
|
|
|
#if 0
|
2019-02-10 09:18:34 +00:00
|
|
|
i32 line_height = view->line_height;
|
2018-07-14 01:13:05 +00:00
|
|
|
|
2019-02-10 09:18:34 +00:00
|
|
|
if (!view->hide_file_bar){
|
2018-11-20 08:18:54 +00:00
|
|
|
i32_Rect top_bar_rect = {};
|
2018-07-14 01:13:05 +00:00
|
|
|
top_bar_rect.x0 = rect.x0;
|
|
|
|
top_bar_rect.y0 = rect.y0;
|
|
|
|
top_bar_rect.x1 = rect.x1;
|
|
|
|
top_bar_rect.y1 = rect.y0 + line_height + 2;
|
|
|
|
rect.y0 = top_bar_rect.y1;
|
|
|
|
}
|
2019-02-10 09:18:34 +00:00
|
|
|
view->file_region = rect;
|
2018-03-26 05:19:08 +00:00
|
|
|
|
2018-08-04 02:41:38 +00:00
|
|
|
i32 bar_count = 0;
|
2019-02-10 09:18:34 +00:00
|
|
|
for (Query_Slot *slot = view->query_set.used_slot;
|
2018-08-04 02:41:38 +00:00
|
|
|
slot != 0;
|
|
|
|
slot = slot->next, ++bar_count);
|
2019-02-10 09:18:34 +00:00
|
|
|
view->widget_height = (f32)bar_count*(view->line_height + 2);
|
2019-02-27 05:49:35 +00:00
|
|
|
#endif
|
2018-03-26 05:19:08 +00:00
|
|
|
|
2019-02-27 05:49:35 +00:00
|
|
|
Editing_File *file = view->file;
|
2018-11-09 02:16:11 +00:00
|
|
|
|
2019-02-10 07:48:07 +00:00
|
|
|
// TODO(allen): do(eliminate the built in paste_effect)
|
2018-11-09 02:16:11 +00:00
|
|
|
if (!file->is_loading && file->state.paste_effect.seconds_down > 0.f){
|
|
|
|
file->state.paste_effect.seconds_down -= dt;
|
2019-02-26 19:59:57 +00:00
|
|
|
models->animate_next_frame = true;
|
2018-07-14 01:13:05 +00:00
|
|
|
}
|
|
|
|
|
2019-02-10 07:48:07 +00:00
|
|
|
// NOTE(allen): call scroll rule hook
|
2019-02-26 19:59:57 +00:00
|
|
|
b32 is_new_target = (scroll.target_x != view->prev_target.x || scroll.target_y != view->prev_target.y);
|
2019-02-10 07:48:07 +00:00
|
|
|
|
2019-02-26 19:59:57 +00:00
|
|
|
f32 target_x = (f32)scroll.target_x;
|
|
|
|
f32 target_y = (f32)scroll.target_y;
|
2019-02-10 07:48:07 +00:00
|
|
|
|
2019-02-10 09:18:34 +00:00
|
|
|
View_ID view_id = view_get_id(&models->live_set, view);
|
2019-02-26 19:59:57 +00:00
|
|
|
if (models->scroll_rule(target_x, target_y, &scroll.scroll_x, &scroll.scroll_y, view_id, is_new_target, dt)){
|
|
|
|
models->animate_next_frame = true;
|
2018-03-26 05:19:08 +00:00
|
|
|
}
|
|
|
|
|
2019-02-26 19:59:57 +00:00
|
|
|
view->prev_target.x = scroll.target_x;
|
|
|
|
view->prev_target.y = scroll.target_y;
|
2019-02-10 07:48:07 +00:00
|
|
|
|
2019-02-26 19:59:57 +00:00
|
|
|
return(scroll);
|
2018-03-26 05:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
|
|
|
internal void
|
|
|
|
intbar_draw_string(System_Functions *system, Render_Target *target, File_Bar *bar, String str, u32 char_color){
|
2019-02-24 22:54:57 +00:00
|
|
|
Vec2 p = bar->pos + bar->text_shift;
|
|
|
|
bar->pos.x += draw_string(system, target, bar->font_id, str, p, char_color);
|
2018-03-26 05:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
internal void
|
|
|
|
draw_file_bar(System_Functions *system, Render_Target *target, View *view, Models *models, Editing_File *file, i32_Rect rect){
|
2019-02-25 23:42:13 +00:00
|
|
|
File_Bar bar = {};
|
|
|
|
Color_Table color_table = models->color_table;
|
2018-03-26 05:19:08 +00:00
|
|
|
|
2019-02-25 23:42:13 +00:00
|
|
|
u32 back_color = color_table.vals[Stag_Bar];
|
|
|
|
u32 base_color = color_table.vals[Stag_Base];
|
|
|
|
u32 pop1_color = color_table.vals[Stag_Pop1];
|
|
|
|
u32 pop2_color = color_table.vals[Stag_Pop2];
|
2018-03-26 05:19:08 +00:00
|
|
|
|
|
|
|
bar.rect = rect;
|
|
|
|
|
|
|
|
if (target != 0){
|
|
|
|
bar.font_id = file->settings.font_id;
|
2019-02-24 22:54:57 +00:00
|
|
|
bar.pos = V2(bar.rect.p0);
|
|
|
|
bar.text_shift = V2(0.f, 2.f);
|
2018-03-26 05:19:08 +00:00
|
|
|
|
|
|
|
draw_rectangle(target, bar.rect, back_color);
|
|
|
|
|
|
|
|
Assert(file != 0);
|
|
|
|
|
|
|
|
intbar_draw_string(system, target, &bar, file->unique_name.name, base_color);
|
|
|
|
intbar_draw_string(system, target, &bar, lit(" -"), base_color);
|
|
|
|
|
|
|
|
if (file->is_loading){
|
|
|
|
intbar_draw_string(system, target, &bar, lit(" loading"), base_color);
|
|
|
|
}
|
|
|
|
else{
|
2019-02-09 22:48:53 +00:00
|
|
|
File_Edit_Positions edit_pos = view_get_edit_pos(view);
|
2019-02-27 05:49:35 +00:00
|
|
|
Full_Cursor cursor = file_compute_cursor(system, view->file, seek_pos(edit_pos.cursor_pos));
|
2019-02-10 00:20:55 +00:00
|
|
|
|
2018-03-26 05:19:08 +00:00
|
|
|
char bar_space[526];
|
|
|
|
String bar_text = make_fixed_width_string(bar_space);
|
|
|
|
append_ss (&bar_text, lit(" L#"));
|
2019-02-10 00:20:55 +00:00
|
|
|
append_int_to_str(&bar_text, cursor.line);
|
2018-03-26 05:19:08 +00:00
|
|
|
append_ss (&bar_text, lit(" C#"));
|
2019-02-10 00:20:55 +00:00
|
|
|
append_int_to_str(&bar_text, cursor.character);
|
2018-03-26 05:19:08 +00:00
|
|
|
|
|
|
|
append_ss(&bar_text, lit(" -"));
|
|
|
|
|
|
|
|
if (file->settings.dos_write_mode){
|
|
|
|
append_ss(&bar_text, lit(" dos"));
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
append_ss(&bar_text, lit(" nix"));
|
|
|
|
}
|
|
|
|
|
|
|
|
intbar_draw_string(system, target, &bar, bar_text, base_color);
|
|
|
|
|
|
|
|
|
|
|
|
if (file->state.still_lexing){
|
|
|
|
intbar_draw_string(system, target, &bar, lit(" parsing"), pop1_color);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (file->state.dirty){
|
2019-02-25 23:49:16 +00:00
|
|
|
case DirtyState_UnsavedChanges:
|
|
|
|
{
|
|
|
|
intbar_draw_string(system, target, &bar, lit(" *"), pop2_color);
|
|
|
|
}break;
|
|
|
|
|
2018-03-26 05:19:08 +00:00
|
|
|
case DirtyState_UnloadedChanges:
|
|
|
|
{
|
|
|
|
intbar_draw_string(system, target, &bar, lit(" !"), pop2_color);
|
|
|
|
}break;
|
|
|
|
|
2019-02-25 23:49:16 +00:00
|
|
|
case DirtyState_UnsavedChangesAndUnloadedChanges:
|
2018-03-26 05:19:08 +00:00
|
|
|
{
|
2019-02-25 23:49:16 +00:00
|
|
|
intbar_draw_string(system, target, &bar, lit(" *!"), pop2_color);
|
2018-03-26 05:19:08 +00:00
|
|
|
}break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-22 23:45:24 +00:00
|
|
|
internal void
|
2018-11-09 02:16:11 +00:00
|
|
|
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){
|
2019-02-27 05:49:35 +00:00
|
|
|
Editing_File *file = view->file;
|
2018-03-26 05:19:08 +00:00
|
|
|
Assert(file != 0);
|
|
|
|
|
2018-07-14 01:13:05 +00:00
|
|
|
draw_push_clip(target, rect);
|
2019-02-26 19:59:57 +00:00
|
|
|
|
2019-02-10 09:18:34 +00:00
|
|
|
if (!view->ui_mode){
|
2018-07-14 01:13:05 +00:00
|
|
|
if (file_is_ready(file)){
|
2019-02-27 05:49:35 +00:00
|
|
|
Rect_i32 file_region = view_get_file_region(models, view);
|
|
|
|
render_loaded_file_in_view(system, view, models, file_region, is_active, target);
|
2018-07-14 01:13:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
2019-02-26 19:59:57 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-07-14 01:13:05 +00:00
|
|
|
draw_pop_clip(target);
|
2018-03-26 05:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// BOTTOM
|
|
|
|
|