fix scrolling commands

master
Allen Webster 2016-05-09 11:12:49 -04:00
parent 0ec658baa8
commit 3821b46a71
3 changed files with 30 additions and 15 deletions

View File

@ -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

26
4ed.cpp
View File

@ -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;

View File

@ -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;