From efc042af3e8b45bd4fc190a5a39d65d4a5e4d587 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Thu, 21 Apr 2016 23:28:00 -0400 Subject: [PATCH] debugging scroll bar crap --- 4ed_file_view.cpp | 12 ++++-------- 4ed_gui.cpp | 10 ++++++++++ build.bat | 6 +++--- build_all.bat | 6 +++--- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 8e86e3e3..8eb8305a 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -3620,15 +3620,13 @@ step_file_view(System_Functions *system, View *view, b32 is_active){ Models *models = view->models; f32 min_target_y = view->file_scroll.min_y; - f32 max_target_y = view->file_scroll.max_y; - - b32 debug = 1; gui_begin_top_level(target); { gui_do_top_bar(target); - if (debug){ +#if 0 + { char prompt_space[256]; char text_space[256]; String prompt, text; @@ -3648,6 +3646,7 @@ step_file_view(System_Functions *system, View *view, b32 is_active){ int_to_str((int)view->gui_target.scroll_updated.target_y, &text); gui_do_text_field(target, prompt, text); } +#endif if (view->showing_ui == VUI_None){ gui_begin_overlap(target); @@ -3684,10 +3683,7 @@ step_file_view(System_Functions *system, View *view, b32 is_active){ } gui_begin_scrollable(target, view->showing_ui, view->file_scroll, delta); - - if (view->file_scroll.scroll_y < min_target_y) view->file_scroll.scroll_y = min_target_y; - if (view->file_scroll.scroll_y > max_target_y) view->file_scroll.scroll_y = max_target_y; - + gui_do_file(target); gui_end_scrollable(target); diff --git a/4ed_gui.cpp b/4ed_gui.cpp index 39f4cd0d..03772ff8 100644 --- a/4ed_gui.cpp +++ b/4ed_gui.cpp @@ -410,6 +410,13 @@ gui_get_scroll_vars(GUI_Target *target, u32 scroll_id, GUI_Scroll_Vars *vars_out b32 result = 0; if (target->scroll_id == scroll_id){ *vars_out = target->scroll_updated; + + if (vars_out->target_y < vars_out->min_y) vars_out->target_y = vars_out->min_y; + if (vars_out->target_y > vars_out->max_y) vars_out->target_y = vars_out->max_y; + + if (vars_out->scroll_y < vars_out->min_y) vars_out->scroll_y = vars_out->min_y; + if (vars_out->scroll_y > vars_out->max_y) vars_out->scroll_y = vars_out->max_y; + if (gui_id_eq(target->active, gui_id_scrollbar())){ result = 1; } @@ -727,6 +734,9 @@ gui_interpret(GUI_Target *target, GUI_Session *session, GUI_Header *h){ always_give_to_user = 1; session->suggested_min_y = -(f32)(session->clip_rect.y0 - session->rect.y0); session->suggested_max_y = (f32)(session->scrollable_items_bottom - session->full_rect.y1 * .5f); + if (session->suggested_max_y < 0){ + session->suggested_max_y = 0; + } break; } diff --git a/build.bat b/build.bat index de341b76..d796a480 100644 --- a/build.bat +++ b/build.bat @@ -1,5 +1,5 @@ @echo off -REM "w:\4ed\misc\build_exp.bat" /Zi -"w:\4ed\misc\build_all.bat" /DFRED_SUPER /DFRED_NOT_PACKAGE /Zi -REM "w:\4ed\misc\build_all.bat" /O2 /Zi +REM "build_exp.bat" /Zi +"build_all.bat" /DFRED_SUPER /DFRED_NOT_PACKAGE /Zi +REM "build_all.bat" /O2 /Zi diff --git a/build_all.bat b/build_all.bat index dece185d..296fc1a9 100644 --- a/build_all.bat +++ b/build_all.bat @@ -8,7 +8,7 @@ set ICON=..\res\icon.res set DEFINES= pushd ..\meta -cl %WARNINGOPS% ..\code\4ed_metagen.cpp /Femetagen +cl %OPTS% ..\code\4ed_metagen.cpp /Femetagen popd pushd ..\code "..\meta\metagen" @@ -18,9 +18,9 @@ pushd ..\build call "..\code\buildsuper.bat" ..\code\4coder_custom.cpp set EXPORTS=/EXPORT:app_get_functions -cl %WARNINGOPS% %INCLUDES% %DEFINES% ..\code\4ed_app_target.cpp %* /Fe4ed_app /LD /link /INCREMENTAL:NO /OPT:REF %EXPORTS% +cl %OPTS% %INCLUDES% %DEFINES% ..\code\4ed_app_target.cpp %* /Fe4ed_app /LD /link /INCREMENTAL:NO /OPT:REF %EXPORTS% -cl %WARNINGOPS% %INCLUDES% %DEFINES% ..\code\win32_4ed.cpp %LIBS% %ICON% %* /Fe4ed +cl %OPTS% %INCLUDES% %DEFINES% ..\code\win32_4ed.cpp %LIBS% %ICON% %* /Fe4ed popd