simplify gui scroll vars, switch things which should ints over to ints
parent
357125c8b2
commit
7b4705be60
|
@ -467,15 +467,10 @@ STRUCT GUI_Scroll_Vars{
|
|||
float scroll_y;
|
||||
/* DOC(The target y position to which the view is moving. If scroll_y is not the same value, then it is still sliding to the target by the smooth scroll rule.) */
|
||||
int32_t target_y;
|
||||
/* DOC(The previous value of target y. This value should be ignored as it is the "vestigial" remain of a system that will not be around much longer.) */
|
||||
int32_t prev_target_y;
|
||||
|
||||
/* DOC(The current actual x position of the view scroll.) */
|
||||
float scroll_x;
|
||||
/* DOC(The target x position to which the view is moving. If scroll_x is not the same value, then it is still sliding to the target by the smooth scroll rule.) */
|
||||
int32_t target_x;
|
||||
/* DOC(The previous value of target x. This value should be ignored as it is the "vestigial" remain of a system that will not be around much longer.) */
|
||||
int32_t prev_target_x;
|
||||
};
|
||||
|
||||
/* DOC(The Buffer_Seek_Type is is used in a Buffer_Seek to identify which coordinates are suppose to be used for the seek.)
|
||||
|
|
4
4ed.cpp
4
4ed.cpp
|
@ -984,7 +984,7 @@ App_Step_Sig(app_step){
|
|||
|
||||
// NOTE(allen): reorganizing panels on screen
|
||||
Vec2_i32 prev_dim = layout_get_root_size(&models->layout);
|
||||
Vec2_i32 current_dim = V2(target->width, target->height);
|
||||
Vec2_i32 current_dim = V2i32(target->width, target->height);
|
||||
layout_set_root_size(&models->layout, current_dim);
|
||||
|
||||
// NOTE(allen): First frame initialization
|
||||
|
@ -1132,7 +1132,7 @@ App_Step_Sig(app_step){
|
|||
Panel *mouse_panel = 0;
|
||||
Panel *divider_panel = 0;
|
||||
b32 mouse_in_margin = false;
|
||||
Vec2_i32 mouse = V2(input->mouse.x, input->mouse.y);
|
||||
Vec2_i32 mouse = V2i32(input->mouse.x, input->mouse.y);
|
||||
{
|
||||
for (Panel *panel = layout_get_first_open_panel(layout);
|
||||
panel != 0;
|
||||
|
|
|
@ -44,7 +44,6 @@ edit_fix_markers__write_workspace_markers(Dynamic_Workspace *workspace, Buffer_I
|
|||
node != 0;
|
||||
node = node->next){
|
||||
if (node->buffer_id != buffer_id) continue;
|
||||
|
||||
Marker *markers = (Marker*)(node + 1);
|
||||
Assert(sizeof(*markers) == node->std_header.item_size);
|
||||
i32 count = node->std_header.count;
|
||||
|
@ -94,11 +93,11 @@ edit_fix_markers__compute_scroll_y(i32 line_height, i32 old_y_val, f32 new_y_val
|
|||
|
||||
internal void
|
||||
edit_fix_markers(System_Functions *system, Models *models, Editing_File *file, Edit_Array edits){
|
||||
Assert(edits.count > 0);
|
||||
|
||||
Partition *part = &models->mem.part;
|
||||
Layout *layout = &models->layout;
|
||||
|
||||
Assert(edits.count > 0);
|
||||
|
||||
Temp_Memory cursor_temp = begin_temp_memory(part);
|
||||
|
||||
Lifetime_Object *file_lifetime_object = file->lifetime_object;
|
||||
|
|
|
@ -23,7 +23,6 @@ struct File_Edit_Positions{
|
|||
GUI_Scroll_Vars scroll;
|
||||
i32 cursor_pos;
|
||||
f32 preferred_x;
|
||||
//i32 scroll_i;
|
||||
};
|
||||
|
||||
// TODO(NAME): do(replace Text_Effect with markers over time)
|
||||
|
|
99
4ed_math.h
99
4ed_math.h
|
@ -209,7 +209,7 @@ V4(f32 x, f32 y, f32 z, f32 w){
|
|||
}
|
||||
|
||||
internal Vec2_i32
|
||||
V2(i32 x, i32 y){
|
||||
V2i32(i32 x, i32 y){
|
||||
Vec2_i32 result = {};
|
||||
result.x = x;
|
||||
result.y = y;
|
||||
|
@ -217,7 +217,7 @@ V2(i32 x, i32 y){
|
|||
}
|
||||
|
||||
internal Vec3_i32
|
||||
V3(i32 x, i32 y, i32 z){
|
||||
V3i32(i32 x, i32 y, i32 z){
|
||||
Vec3_i32 result = {};
|
||||
result.x = x;
|
||||
result.y = y;
|
||||
|
@ -226,7 +226,7 @@ V3(i32 x, i32 y, i32 z){
|
|||
}
|
||||
|
||||
internal Vec4_i32
|
||||
V4(i32 x, i32 y, i32 z, i32 w){
|
||||
V4i32(i32 x, i32 y, i32 z, i32 w){
|
||||
Vec4_i32 result = {};
|
||||
result.x = x;
|
||||
result.y = y;
|
||||
|
@ -734,12 +734,14 @@ rgba_to_hsla(Vec4 rgba){
|
|||
|
||||
internal Vec4
|
||||
hsla_to_rgba(Vec4 hsla){
|
||||
if (hsla.h >= 1.f) hsla.h = 0.f;
|
||||
Vec4 rgba = {};
|
||||
if (hsla.h >= 1.f){
|
||||
hsla.h = 0.f;
|
||||
}
|
||||
f32 C = (1.f - ABS(2*hsla.z - 1.f))*hsla.y;
|
||||
f32 X = C*(1.f-ABS(MOD(hsla.x*6.f, 2)-1.f));
|
||||
f32 m = hsla.z - C*.5f;
|
||||
i32 H = floor32(hsla.x*6.f);
|
||||
Vec4 rgba = {};
|
||||
rgba.a = hsla.a;
|
||||
switch (H){
|
||||
case 0: rgba.r = C; rgba.g = X; rgba.b = 0; break;
|
||||
|
@ -760,7 +762,7 @@ hsla_to_rgba(Vec4 hsla){
|
|||
//
|
||||
|
||||
internal i32_Rect
|
||||
i32R(int32_t l, int32_t t, int32_t r, int32_t b){
|
||||
i32R(i32 l, i32 t, i32 r, i32 b){
|
||||
i32_Rect rect = {};
|
||||
rect.x0 = l;
|
||||
rect.y0 = t;
|
||||
|
@ -771,45 +773,46 @@ i32R(int32_t l, int32_t t, int32_t r, int32_t b){
|
|||
|
||||
internal i32_Rect
|
||||
i32R(f32_Rect r){
|
||||
i32_Rect rect;
|
||||
rect.x0 = (int32_t)r.x0;
|
||||
rect.y0 = (int32_t)r.y0;
|
||||
rect.x1 = (int32_t)r.x1;
|
||||
rect.y1 = (int32_t)r.y1;
|
||||
i32_Rect rect = {};
|
||||
rect.x0 = (i32)r.x0;
|
||||
rect.y0 = (i32)r.y0;
|
||||
rect.x1 = (i32)r.x1;
|
||||
rect.y1 = (i32)r.y1;
|
||||
return(rect);
|
||||
}
|
||||
|
||||
internal f32_Rect
|
||||
f32R(float l, float t, float r, float b){
|
||||
f32_Rect rect;
|
||||
rect.x0 = l; rect.y0 = t;
|
||||
rect.x1 = r; rect.y1 = b;
|
||||
f32R(f32 l, f32 t, f32 r, f32 b){
|
||||
f32_Rect rect = {};
|
||||
rect.x0 = l;
|
||||
rect.y0 = t;
|
||||
rect.x1 = r;
|
||||
rect.y1 = b;
|
||||
return(rect);
|
||||
}
|
||||
|
||||
internal f32_Rect
|
||||
f32R(i32_Rect r){
|
||||
f32_Rect rect;
|
||||
rect.x0 = (float)r.x0;
|
||||
rect.y0 = (float)r.y0;
|
||||
rect.x1 = (float)r.x1;
|
||||
rect.y1 = (float)r.y1;
|
||||
f32_Rect rect = {};
|
||||
rect.x0 = (f32)r.x0;
|
||||
rect.y0 = (f32)r.y0;
|
||||
rect.x1 = (f32)r.x1;
|
||||
rect.y1 = (f32)r.y1;
|
||||
return(rect);
|
||||
}
|
||||
|
||||
internal int32_t
|
||||
internal i32
|
||||
rect_equal(i32_Rect r1, i32_Rect r2){
|
||||
int32_t result = (r1.x0 == r2.x0 && r1.y0 == r2.y0 && r1.x1 == r2.x1 && r1.y1 == r2.y1);
|
||||
return(result);
|
||||
return(r1.x0 == r2.x0 && r1.y0 == r2.y0 && r1.x1 == r2.x1 && r1.y1 == r2.y1);
|
||||
}
|
||||
|
||||
internal int32_t
|
||||
hit_check(int32_t x, int32_t y, int32_t x0, int32_t y0, int32_t x1, int32_t y1){
|
||||
internal i32
|
||||
hit_check(i32 x, i32 y, i32 x0, i32 y0, i32 x1, i32 y1){
|
||||
return(x >= x0 && x < x1 && y >= y0 && y < y1);
|
||||
}
|
||||
|
||||
internal int32_t
|
||||
hit_check(int32_t x, int32_t y, i32_Rect rect){
|
||||
internal i32
|
||||
hit_check(i32 x, i32 y, i32_Rect rect){
|
||||
return(hit_check(x, y, rect.x0, rect.y0, rect.x1, rect.y1));
|
||||
}
|
||||
|
||||
|
@ -833,26 +836,40 @@ get_inner_rect(f32_Rect outer, f32 margin){
|
|||
return(r);
|
||||
}
|
||||
|
||||
internal int32_t
|
||||
internal i32
|
||||
rect_height(i32_Rect rect){
|
||||
return(rect.y1 - rect.y0);
|
||||
}
|
||||
|
||||
internal i32
|
||||
rect_width(i32_Rect rect){
|
||||
return(rect.x1 - rect.x0);
|
||||
}
|
||||
|
||||
internal i32
|
||||
fits_inside(i32_Rect rect, i32_Rect outer){
|
||||
return(rect.x0 >= outer.x0 && rect.x1 <= outer.x1 && rect.y0 >= outer.y0 && rect.y1 <= outer.y1);
|
||||
}
|
||||
|
||||
internal int32_t
|
||||
interval_overlap(float a0, float a1, float b0, float b1){
|
||||
if ((a0 <= b0 && b0 < a1) || (b0 <= a0 && a0 < b1)){
|
||||
return(true);
|
||||
}
|
||||
return(false);
|
||||
internal i32
|
||||
interval_overlap(f32 a0, f32 a1, f32 b0, f32 b1){
|
||||
return(a0 < b1 && b0 < a1);
|
||||
}
|
||||
|
||||
internal int32_t
|
||||
rect_opverlap(f32_Rect a, f32_Rect b){
|
||||
if (interval_overlap(a.x0, a.x1, b.x0, b.x1) &&
|
||||
interval_overlap(a.y0, a.y1, b.y0, b.y1)){
|
||||
return(true);
|
||||
}
|
||||
return(false);
|
||||
internal i32
|
||||
rect_overlap(f32_Rect a, f32_Rect b){
|
||||
return(interval_overlap(a.x0, a.x1, b.x0, b.x1) &&
|
||||
interval_overlap(a.y0, a.y1, b.y0, b.y1));
|
||||
}
|
||||
|
||||
internal f32
|
||||
rect_height(f32_Rect rect){
|
||||
return(rect.y1 - rect.y0);
|
||||
}
|
||||
|
||||
internal f32
|
||||
rect_width(f32_Rect rect){
|
||||
return(rect.x1 - rect.x0);
|
||||
}
|
||||
|
||||
// BOTTOM
|
||||
|
|
112
4ed_view.cpp
112
4ed_view.cpp
|
@ -71,62 +71,49 @@ view_set_edit_pos(View *view, File_Edit_Positions edit_pos){
|
|||
|
||||
////////////////////////////////
|
||||
|
||||
// TODO(allen): Switch over to using an i32 for these.
|
||||
internal f32
|
||||
internal i32
|
||||
view_width(View *view){
|
||||
i32_Rect file_rect = view->transient.file_region;
|
||||
f32 result = (f32)(file_rect.x1 - file_rect.x0);
|
||||
return (result);
|
||||
return(rect_width(view->transient.file_region));
|
||||
}
|
||||
|
||||
internal f32
|
||||
internal i32
|
||||
view_height(View *view){
|
||||
i32_Rect file_rect = view->transient.file_region;
|
||||
f32 result = (f32)(file_rect.y1 - file_rect.y0);
|
||||
return (result);
|
||||
return(rect_height(view->transient.file_region));
|
||||
}
|
||||
|
||||
internal Vec2
|
||||
internal Vec2_i32
|
||||
view_get_cursor_xy(System_Functions *system, View *view){
|
||||
File_Edit_Positions edit_pos = view_get_edit_pos(view);
|
||||
i32 pos = edit_pos.cursor_pos;
|
||||
Full_Cursor cursor = file_compute_cursor(system, view->transient.file_data.file, seek_pos(pos));
|
||||
Vec2 result = {};
|
||||
Full_Cursor cursor = file_compute_cursor(system, view->transient.file_data.file, seek_pos(edit_pos.cursor_pos));
|
||||
Vec2_i32 result = {};
|
||||
if (view->transient.file_data.file->settings.unwrapped_lines){
|
||||
result = V2(cursor.unwrapped_x, cursor.unwrapped_y);
|
||||
result = V2i32((i32)cursor.unwrapped_x, (i32)cursor.unwrapped_y);
|
||||
}
|
||||
else{
|
||||
result = V2(cursor.wrapped_x, cursor.wrapped_y);
|
||||
result = V2i32((i32)cursor.wrapped_x, (i32)cursor.wrapped_y);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal Cursor_Limits
|
||||
view_cursor_limits(View *view){
|
||||
i32 line_height = view->transient.line_height;
|
||||
i32 visible_height = view_height(view);
|
||||
Cursor_Limits limits = {};
|
||||
|
||||
f32 line_height = (f32)view->transient.line_height;
|
||||
f32 visible_height = view_height(view);
|
||||
|
||||
limits.max = visible_height - line_height*3.f;
|
||||
limits.min = line_height * 2;
|
||||
|
||||
limits.max = visible_height - line_height*3;
|
||||
limits.min = line_height*2;
|
||||
if (limits.max - limits.min <= line_height){
|
||||
if (visible_height >= line_height){
|
||||
limits.max = visible_height - line_height;
|
||||
limits.min = -line_height;
|
||||
}
|
||||
else{
|
||||
limits.max = visible_height;
|
||||
limits.min = -line_height;
|
||||
}
|
||||
limits.min = 0;
|
||||
}
|
||||
|
||||
limits.max = (limits.max > 0)?(limits.max):(0);
|
||||
limits.min = (limits.min > 0)?(limits.min):(0);
|
||||
|
||||
limits.delta = clamp_top(line_height*3.f, (limits.max - limits.min)*.5f);
|
||||
|
||||
limits.max = clamp_bottom(0, limits.max);
|
||||
limits.min = clamp(0, limits.min, limits.max);
|
||||
limits.delta = clamp_top(line_height*5, (limits.max - limits.min + 1)/2);
|
||||
return(limits);
|
||||
}
|
||||
|
||||
|
@ -166,49 +153,38 @@ view_lock_flags(View *view){
|
|||
////////////////////////////////
|
||||
|
||||
internal b32
|
||||
view_move_view_to_cursor(System_Functions *system, View *view, GUI_Scroll_Vars *scroll, b32 center_view){
|
||||
b32 result = 0;
|
||||
f32 max_x = view_width(view);
|
||||
view_move_view_to_cursor(System_Functions *system, View *view, GUI_Scroll_Vars *scroll){
|
||||
b32 result = false;
|
||||
i32 max_x = view_width(view);
|
||||
i32 max_y = view_compute_max_target_y(view);
|
||||
|
||||
Vec2 cursor = view_get_cursor_xy(system, view);
|
||||
Vec2_i32 cursor = view_get_cursor_xy(system, view);
|
||||
|
||||
GUI_Scroll_Vars scroll_vars = *scroll;
|
||||
i32 target_x = scroll_vars.target_x;
|
||||
i32 target_y = scroll_vars.target_y;
|
||||
|
||||
Cursor_Limits limits = view_cursor_limits(view);
|
||||
|
||||
if (cursor.y > target_y + limits.max){
|
||||
if (center_view){
|
||||
target_y = round32(cursor.y - limits.max*.5f);
|
||||
}
|
||||
else{
|
||||
target_y = ceil32(cursor.y - limits.max + limits.delta);
|
||||
}
|
||||
target_y = cursor.y - limits.max + limits.delta;
|
||||
}
|
||||
if (cursor.y < target_y + limits.min){
|
||||
if (center_view){
|
||||
target_y = round32(cursor.y - limits.max*.5f);
|
||||
}
|
||||
else{
|
||||
target_y = floor32(cursor.y - limits.delta - limits.min);
|
||||
}
|
||||
target_y = cursor.y - limits.delta - limits.min;
|
||||
}
|
||||
|
||||
target_y = clamp(0, target_y, max_y);
|
||||
|
||||
if (cursor.x >= target_x + max_x){
|
||||
target_x = ceil32(cursor.x - max_x/2);
|
||||
target_x = cursor.x - max_x/2;
|
||||
}
|
||||
else if (cursor.x < target_x){
|
||||
target_x = floor32(Max(0, cursor.x - max_x/2));
|
||||
target_x = clamp_bottom(0, cursor.x - max_x/2);
|
||||
}
|
||||
|
||||
if (target_x != scroll_vars.target_x || target_y != scroll_vars.target_y){
|
||||
scroll->target_x = target_x;
|
||||
scroll->target_y = target_y;
|
||||
result = 1;
|
||||
result = true;
|
||||
}
|
||||
|
||||
return(result);
|
||||
|
@ -262,7 +238,7 @@ view_set_cursor(System_Functions *system, View *view, Full_Cursor cursor, b32 se
|
|||
file_edit_positions_set_cursor(&edit_pos, cursor, set_preferred_x, unwrapped_lines);
|
||||
view_set_edit_pos(view, edit_pos);
|
||||
GUI_Scroll_Vars scroll = edit_pos.scroll;
|
||||
if (view_move_view_to_cursor(system, view, &scroll, 0)){
|
||||
if (view_move_view_to_cursor(system, view, &scroll)){
|
||||
edit_pos.scroll = scroll;
|
||||
view_set_edit_pos(view, edit_pos);
|
||||
}
|
||||
|
@ -290,25 +266,6 @@ view_set_cursor_and_scroll(View *view, Full_Cursor cursor, b32 set_preferred_x,
|
|||
view_set_edit_pos(view, edit_pos);
|
||||
}
|
||||
|
||||
internal Relative_Scrolling
|
||||
view_get_relative_scrolling(System_Functions *system, View *view){
|
||||
Vec2 cursor = view_get_cursor_xy(system, view);
|
||||
File_Edit_Positions edit_pos = view_get_edit_pos(view);
|
||||
Relative_Scrolling result = {};
|
||||
result.scroll_y = cursor.y - edit_pos.scroll.scroll_y;
|
||||
result.target_y = cursor.y - edit_pos.scroll.target_y;
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal void
|
||||
view_set_relative_scrolling(System_Functions *system, View *view, Relative_Scrolling scrolling){
|
||||
Vec2 cursor = view_get_cursor_xy(system, view);
|
||||
File_Edit_Positions edit_pos = view_get_edit_pos(view);
|
||||
edit_pos.scroll.scroll_y = cursor.y - scrolling.scroll_y;
|
||||
edit_pos.scroll.target_y = round32(clamp_bottom(0.f, cursor.y - scrolling.target_y));
|
||||
view_set_edit_pos(view, edit_pos);
|
||||
}
|
||||
|
||||
internal void
|
||||
view_cursor_move(System_Functions *system, View *view, i32 pos){
|
||||
Editing_File *file = view->transient.file_data.file;
|
||||
|
@ -377,7 +334,6 @@ file_is_viewed(Layout *layout, Editing_File *file){
|
|||
internal void
|
||||
adjust_views_looking_at_file_to_new_cursor(System_Functions *system, Models *models, Editing_File *file){
|
||||
Layout *layout = &models->layout;
|
||||
|
||||
for (Panel *panel = layout_get_first_open_panel(layout);
|
||||
panel != 0;
|
||||
panel = layout_get_next_open_panel(layout, panel)){
|
||||
|
@ -398,7 +354,6 @@ file_full_remeasure(System_Functions *system, Models *models, Editing_File *file
|
|||
adjust_views_looking_at_file_to_new_cursor(system, models, file);
|
||||
|
||||
Layout *layout = &models->layout;
|
||||
|
||||
for (Panel *panel = layout_get_first_open_panel(layout);
|
||||
panel != 0;
|
||||
panel = layout_get_next_open_panel(layout, panel)){
|
||||
|
@ -491,9 +446,7 @@ finalize_color(Theme *theme_data, u32 color){
|
|||
}
|
||||
|
||||
internal void
|
||||
get_visual_markers(Partition *arena, Dynamic_Workspace *workspace,
|
||||
Range range, Buffer_ID buffer_id, i32 view_index,
|
||||
Theme *theme_data){
|
||||
get_visual_markers(Partition *arena, Dynamic_Workspace *workspace, Range range, Buffer_ID buffer_id, i32 view_index, Theme *theme_data){
|
||||
View_ID view_id = view_index + 1;
|
||||
for (Managed_Buffer_Markers_Header *node = workspace->buffer_markers_list.first;
|
||||
node != 0;
|
||||
|
@ -564,8 +517,9 @@ get_visual_markers(Partition *arena, Dynamic_Workspace *workspace,
|
|||
if (range_b.first > range_b.one_past_last){
|
||||
Swap(i32, range_b.first, range_b.one_past_last);
|
||||
}
|
||||
if (!((range.min - range_b.max <= 0) &&
|
||||
(range.max - range_b.min >= 0))) continue;
|
||||
if (!((range.min - range_b.max <= 0) && (range.max - range_b.min >= 0))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Render_Marker *render_marker = push_array(arena, Render_Marker, 1);
|
||||
render_marker->type = type;
|
||||
|
@ -1185,9 +1139,7 @@ do_core_render(Application_Links *app){
|
|||
Range on_screen_range = models->render_range;
|
||||
Buffer_Render_Item *items = models->render_items;
|
||||
i32 item_count = models->render_item_count;
|
||||
render_loaded_file_in_view__inner(models, target, view,
|
||||
rect, render_cursor, on_screen_range,
|
||||
items, item_count);
|
||||
render_loaded_file_in_view__inner(models, target, view, rect, render_cursor, on_screen_range, items, item_count);
|
||||
}
|
||||
|
||||
internal Full_Cursor
|
||||
|
|
16
4ed_view.h
16
4ed_view.h
|
@ -46,6 +46,7 @@ struct View_Transient{
|
|||
UI_Quit_Function_Type *ui_quit;
|
||||
UI_Control ui_control;
|
||||
GUI_Scroll_Vars ui_scroll;
|
||||
Vec2_i32 prev_target;
|
||||
i32 ui_map_id;
|
||||
|
||||
b32 hide_scrollbar;
|
||||
|
@ -61,8 +62,6 @@ struct View_Transient{
|
|||
|
||||
Query_Set query_set;
|
||||
f32 widget_height;
|
||||
|
||||
b32 reinit_scrolling;
|
||||
};
|
||||
|
||||
struct View{
|
||||
|
@ -79,9 +78,9 @@ struct Live_Views{
|
|||
};
|
||||
|
||||
struct Cursor_Limits{
|
||||
f32 min;
|
||||
f32 max;
|
||||
f32 delta;
|
||||
i32 min;
|
||||
i32 max;
|
||||
i32 delta;
|
||||
};
|
||||
|
||||
enum{
|
||||
|
@ -111,13 +110,6 @@ struct Shift_Information{
|
|||
i32 amount;
|
||||
};
|
||||
|
||||
struct Relative_Scrolling{
|
||||
f32 scroll_x;
|
||||
f32 scroll_y;
|
||||
f32 target_x;
|
||||
f32 target_y;
|
||||
};
|
||||
|
||||
struct File_Bar{
|
||||
f32 pos_x;
|
||||
f32 pos_y;
|
||||
|
|
|
@ -48,9 +48,8 @@ global_const Style_Color_Edit colors_to_edit[] = {
|
|||
|
||||
internal Input_Process_Result
|
||||
do_step_file_view(System_Functions *system, View *view, Models *models, i32_Rect rect, b32 is_active, f32 dt, GUI_Scroll_Vars scroll, i32 max_y){
|
||||
scroll.target_y = clamp(0, scroll.target_y, max_y);
|
||||
|
||||
Input_Process_Result result = {};
|
||||
scroll.target_y = clamp(0, scroll.target_y, max_y);
|
||||
result.scroll = scroll;
|
||||
|
||||
i32 line_height = view->transient.line_height;
|
||||
|
@ -63,6 +62,7 @@ do_step_file_view(System_Functions *system, View *view, Models *models, i32_Rect
|
|||
top_bar_rect.y1 = rect.y0 + line_height + 2;
|
||||
rect.y0 = top_bar_rect.y1;
|
||||
}
|
||||
view->transient.file_region = rect;
|
||||
|
||||
i32 bar_count = 0;
|
||||
for (Query_Slot *slot = view->transient.query_set.used_slot;
|
||||
|
@ -72,61 +72,26 @@ do_step_file_view(System_Functions *system, View *view, Models *models, i32_Rect
|
|||
|
||||
Editing_File *file = view->transient.file_data.file;
|
||||
|
||||
if (!view->transient.ui_mode){
|
||||
view->transient.file_region = rect;
|
||||
|
||||
if (view->transient.reinit_scrolling){
|
||||
view->transient.reinit_scrolling = false;
|
||||
result.is_animating = true;
|
||||
|
||||
i32 target_x = 0;
|
||||
i32 target_y = 0;
|
||||
if (file_is_ready(file)){
|
||||
Vec2 cursor = view_get_cursor_xy(system, view);
|
||||
|
||||
f32 width = view_width(view);
|
||||
f32 height = view_height(view);
|
||||
|
||||
if (cursor.x >= target_x + width){
|
||||
target_x = round32(cursor.x - width*.35f);
|
||||
}
|
||||
|
||||
target_y = clamp_bottom(0, floor32(cursor.y - height*.5f));
|
||||
}
|
||||
|
||||
result.scroll.target_y = target_y;
|
||||
result.scroll.scroll_y = (f32)target_y;
|
||||
result.scroll.prev_target_y = -1000;
|
||||
|
||||
result.scroll.target_x = target_x;
|
||||
result.scroll.scroll_x = (f32)target_x;
|
||||
result.scroll.prev_target_x = -1000;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(allen): do(eliminate the built in paste_effect)
|
||||
if (!file->is_loading && file->state.paste_effect.seconds_down > 0.f){
|
||||
file->state.paste_effect.seconds_down -= dt;
|
||||
result.is_animating = true;
|
||||
}
|
||||
|
||||
{
|
||||
GUI_Scroll_Vars scroll_vars = result.scroll;
|
||||
b32 is_new_target = (scroll_vars.target_x != scroll_vars.prev_target_x ||
|
||||
scroll_vars.target_y != scroll_vars.prev_target_y);
|
||||
|
||||
f32 target_x = (f32)scroll_vars.target_x;
|
||||
f32 target_y = (f32)scroll_vars.target_y;
|
||||
|
||||
if (models->scroll_rule(target_x, target_y, &scroll_vars.scroll_x, &scroll_vars.scroll_y, (view->persistent.id) + 1, is_new_target, dt)){
|
||||
result.is_animating = true;
|
||||
}
|
||||
|
||||
scroll_vars.prev_target_x = scroll_vars.target_x;
|
||||
scroll_vars.prev_target_y = scroll_vars.target_y;
|
||||
|
||||
result.scroll = scroll_vars;
|
||||
// NOTE(allen): call scroll rule hook
|
||||
b32 is_new_target = (result.scroll.target_x != view->transient.prev_target.x ||
|
||||
result.scroll.target_y != view->transient.prev_target.y);
|
||||
|
||||
f32 target_x = (f32)result.scroll.target_x;
|
||||
f32 target_y = (f32)result.scroll.target_y;
|
||||
|
||||
if (models->scroll_rule(target_x, target_y, &result.scroll.scroll_x, &result.scroll.scroll_y, (view->persistent.id) + 1, is_new_target, dt)){
|
||||
result.is_animating = true;
|
||||
}
|
||||
|
||||
view->transient.prev_target.x = result.scroll.target_x;
|
||||
view->transient.prev_target.y = result.scroll.target_y;
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
@ -322,7 +287,7 @@ do_render_file_view(System_Functions *system, View *view, Models *models, GUI_Sc
|
|||
}break;
|
||||
}
|
||||
|
||||
if (rect_opverlap(item_rect, rect_f32)){
|
||||
if (rect_overlap(item_rect, rect_f32)){
|
||||
switch (item->type){
|
||||
case UIType_Option:
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue