From 3821b46a71b7c8d8fe9d51913a06d27d4f91215b Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Mon, 9 May 2016 11:12:49 -0400 Subject: [PATCH] fix scrolling commands --- 4coder_default_bindings.cpp | 4 +--- 4ed.cpp | 26 ++++++++++++++------------ 4ed_gui.cpp | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/4coder_default_bindings.cpp b/4coder_default_bindings.cpp index d229131e..7385b8f2 100644 --- a/4coder_default_bindings.cpp +++ b/4coder_default_bindings.cpp @@ -3,15 +3,13 @@ #include "4coder_default_include.cpp" -unsigned char blink_t = 0; - // NOTE(allen|a3.3): All of your custom ids should be enumerated // as shown here, they may start at 0, and you can only have // 2^24 of them so don't be wasteful! enum My_Maps{ my_code_map, - my_html_map, // for testing + my_html_map, my_empty_map1, my_empty_map2, my_maps_count diff --git a/4ed.cpp b/4ed.cpp index d325d58b..6a82f493 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -3492,15 +3492,6 @@ App_Step_Sig(app_step){ if (time_stamp > 0){ file->state.last_sys_write_time = time_stamp; -#if 0 - File_Sync_State prev_sync = buffer_get_sync(file); - file->state.sync = buffer_get_sync(file); - if (file->state.last_sys_write_time != file->state.last_4ed_write_time){ - if (file->state.sync != prev_sync){ - app_result.redraw = 1; - } - } -#endif } } } @@ -3959,9 +3950,7 @@ App_Step_Sig(app_step){ for (dll_items(panel, used_panels)){ view = panel->view; if (view->current_scroll){ - GUI_Scroll_Vars vars = {0}; - gui_get_scroll_vars(&view->gui_target, view->showing_ui, &vars); - view->current_scroll->region = vars.region; + gui_get_scroll_vars(&view->gui_target, view->showing_ui, view->current_scroll); } } } @@ -4488,6 +4477,19 @@ App_Step_Sig(app_step){ } } + // NOTE(allen): post scroll vars back to the view's gui targets + { + View *view; + Panel *panel, *used_panels; + used_panels = &models->layout.used_sentinel; + for (dll_items(panel, used_panels)){ + view = panel->view; + if (view->current_scroll){ + gui_post_scroll_vars(&view->gui_target, view->current_scroll); + } + } + } + // NOTE(allen): send style change messages if the style has changed if (models->global_font.font_changed){ models->global_font.font_changed = 0; diff --git a/4ed_gui.cpp b/4ed_gui.cpp index 467bccb9..1d4b4c8a 100644 --- a/4ed_gui.cpp +++ b/4ed_gui.cpp @@ -613,6 +613,12 @@ gui_id_scrollbar_bottom(){ return(id); } +internal b32 +gui_scroll_eq(GUI_Scroll_Vars *a, GUI_Scroll_Vars *b){ + b32 result = (memcmp(a, b, sizeof(*a)) == 0); + return(result); +} + // TODO(allen): Rethink this a little, seems like there are two separate things we want to do here: // Getting the updated scroll vars, and telling the user when scrolling actions occur. internal b32 @@ -635,6 +641,15 @@ gui_get_scroll_vars(GUI_Target *target, u32 scroll_id, GUI_Scroll_Vars *vars_out return(result); } +internal void +gui_post_scroll_vars(GUI_Target *target, GUI_Scroll_Vars *vars_in){ + if (!gui_scroll_eq(vars_in, &target->scroll_updated)){ + target->scroll_updated = *vars_in; + target->animating = 1; + target->active = gui_id_scrollbar(); + } +} + internal void gui_begin_scrollable(GUI_Target *target, u32 scroll_id, GUI_Scroll_Vars scroll_vars, f32 delta){ GUI_Header *h;