From 29fc6f84c6437e5460d4e05cb0d4258ddc1e27bd Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Tue, 9 Oct 2018 16:51:45 -0700 Subject: [PATCH] Fixed endless animation in UI mode --- 4coder_combined_write_commands.cpp | 4 ++-- 4coder_generated/command_metadata.h | 2 +- 4ed.cpp | 21 +++++++++++++-------- 4ed_math.h | 8 +++++--- platform_win32/win32_4ed.cpp | 2 +- todo.txt | 3 ++- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/4coder_combined_write_commands.cpp b/4coder_combined_write_commands.cpp index c5b885c8..abdd8f3b 100644 --- a/4coder_combined_write_commands.cpp +++ b/4coder_combined_write_commands.cpp @@ -109,9 +109,9 @@ CUSTOM_DOC("At the cursor, insert a block comment.") } CUSTOM_COMMAND_SIG(write_zero_struct) -CUSTOM_DOC("At the cursor, insert a ' = {0};'.") +CUSTOM_DOC("At the cursor, insert a ' = {};'.") { - write_string(app, make_lit_string(" = {0};")); + write_string(app, make_lit_string(" = {};")); } //////////////////////////////// diff --git a/4coder_generated/command_metadata.h b/4coder_generated/command_metadata.h index b15a203e..5d6654d2 100644 --- a/4coder_generated/command_metadata.h +++ b/4coder_generated/command_metadata.h @@ -452,7 +452,7 @@ static Command_Metadata fcoder_metacmd_table[216] = { { PROC_LINKS(write_note, 0), "write_note", 10, "At the cursor, insert a '// NOTE' comment, includes user name if it was specified in config.4coder.", 99, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 99 }, { PROC_LINKS(write_todo, 0), "write_todo", 10, "At the cursor, insert a '// TODO' comment, includes user name if it was specified in config.4coder.", 99, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 87 }, { PROC_LINKS(write_underscore, 0), "write_underscore", 16, "Inserts an underscore.", 22, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 49 }, -{ PROC_LINKS(write_zero_struct, 0), "write_zero_struct", 17, "At the cursor, insert a ' = {0};'.", 34, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 111 }, +{ PROC_LINKS(write_zero_struct, 0), "write_zero_struct", 17, "At the cursor, insert a ' = {};'.", 33, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 111 }, }; static int32_t fcoder_metacmd_ID_allow_mouse = 0; static int32_t fcoder_metacmd_ID_auto_tab_line_at_cursor = 1; diff --git a/4ed.cpp b/4ed.cpp index ae164bdd..1defc37c 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -1199,12 +1199,11 @@ App_Step_Sig(app_step){ } // NOTE(allen): reorganizing panels on screen + i32 prev_width = models->layout.full_width; + i32 prev_height = models->layout.full_height; + i32 current_width = target->width; + i32 current_height = target->height; { - i32 prev_width = models->layout.full_width; - i32 prev_height = models->layout.full_height; - i32 current_width = target->width; - i32 current_height = target->height; - models->layout.full_width = current_width; models->layout.full_height = current_height; @@ -1244,8 +1243,12 @@ App_Step_Sig(app_step){ } if (input->mouse.x != models->prev_x || input->mouse.y != models->prev_y){ - mouse_event.keycode = key_mouse_move; - input->keys.keys[input->keys.count++] = mouse_event; + b32 was_in_window = hit_check(models->prev_x, models->prev_y, i32R(0, 0, prev_width, prev_height)); + b32 is_in_window = hit_check(input->mouse.x, input->mouse.y, i32R(0, 0, current_width, current_height)); + if (is_in_window || (was_in_window != is_in_window)){ + mouse_event.keycode = key_mouse_move; + input->keys.keys[input->keys.count++] = mouse_event; + } } if (models->animated_last_frame){ @@ -1682,7 +1685,9 @@ App_Step_Sig(app_step){ models->prev_command = cmd_bind; - app_result.animating = true; + if (key.keycode == key_animate){ + app_result.animating = true; + } } }break; diff --git a/4ed_math.h b/4ed_math.h index 7726c146..0bac6ac7 100644 --- a/4ed_math.h +++ b/4ed_math.h @@ -591,9 +591,11 @@ hsla_to_rgba(Vec4 hsla){ internal i32_Rect i32R(int32_t l, int32_t t, int32_t r, int32_t b){ - i32_Rect rect; - rect.x0 = l; rect.y0 = t; - rect.x1 = r; rect.y1 = b; + i32_Rect rect = {0}; + rect.x0 = l; + rect.y0 = t; + rect.x1 = r; + rect.y1 = b; return(rect); } diff --git a/platform_win32/win32_4ed.cpp b/platform_win32/win32_4ed.cpp index 169d87aa..27660a8a 100644 --- a/platform_win32/win32_4ed.cpp +++ b/platform_win32/win32_4ed.cpp @@ -1668,7 +1668,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS if (samount > 0) Sleep(samount); timer_end = Win32HighResolutionTime(); } - system_acquire_lock(FRAME_LOCK); + system_acquire_lock(FRAME_LOCK); timer_start = Win32HighResolutionTime(); // TODO(allen): Only rely on version right inside input? diff --git a/todo.txt b/todo.txt index 8f1259f0..1109d244 100644 --- a/todo.txt +++ b/todo.txt @@ -11,8 +11,9 @@ Bugs { [x] Crash when freeing marker object without visuals - [] High CPU usage in listers + [x] High CPU usage in listers [] Panel resizing doesn't work + [] Double free crash for markers object (not invaliding managed objects correctly?) [] Notepad like mode clicking to new view doesn't snap the mark [] Notepad like mode replacing text with cursor at end of selection in middle of long file [] Tab when no valid completions in open file lister