scrollbar may be toggled, file remeasure now tied to file region not panel region

master
Allen Webster 2016-05-19 18:04:01 -04:00
parent 2800352ee6
commit c8c62dca58
5 changed files with 51 additions and 32 deletions

View File

@ -219,6 +219,8 @@ enum Command_ID{
cmdid_open_color_tweaker,
cmdid_cursor_mark_swap,
cmdid_open_menu,
cmdid_hide_scrollbar,
cmdid_show_scrollbar,
cmdid_set_settings,
cmdid_command_line,
//

View File

@ -404,15 +404,17 @@ default_keys(Bind_Helper *context){
bind(context, 'O', MDFR_CTRL, cmdid_reopen);
bind(context, 'q', MDFR_CTRL, query_replace);
bind(context, 'r', MDFR_CTRL, reverse_search);
bind(context, 's', MDFR_ALT, rewrite_as_single_caps);
bind(context, 's', MDFR_ALT, cmdid_show_scrollbar);
bind(context, 's', MDFR_CTRL, cmdid_save);
bind(context, 'u', MDFR_CTRL, cmdid_to_uppercase);
bind(context, 'v', MDFR_CTRL, cmdid_paste);
bind(context, 'V', MDFR_CTRL, cmdid_paste_next);
bind(context, 'w', MDFR_ALT, cmdid_hide_scrollbar);
bind(context, 'x', MDFR_CTRL, cmdid_cut);
bind(context, 'y', MDFR_CTRL, cmdid_redo);
bind(context, 'z', MDFR_CTRL, cmdid_undo);
bind(context, '1', MDFR_CTRL, cmdid_eol_dosify);
bind(context, '?', MDFR_CTRL, cmdid_toggle_show_whitespace);

31
4ed.cpp
View File

@ -1572,6 +1572,16 @@ COMMAND_DECL(user_callback){
if (binding.custom) binding.custom(&models->app_links);
}
COMMAND_DECL(hide_scrollbar){
USE_VIEW(view);
view->hide_scrollbar = 1;
}
COMMAND_DECL(show_scrollbar){
USE_VIEW(view);
view->hide_scrollbar = 0;
}
COMMAND_DECL(set_settings){
USE_MODELS(models);
@ -2737,6 +2747,8 @@ setup_command_table(){
SET(open_color_tweaker);
SET(cursor_mark_swap);
SET(open_menu);
SET(hide_scrollbar);
SET(show_scrollbar);
SET(set_settings);
SET(command_line);
@ -4030,7 +4042,7 @@ App_Step_Sig(app_step){
// The problem is that the exact region and scroll position is pretty important
// for some commands, so this is here to eliminate the one frame of lag.
// Going to leave this here for now because the order of events is going to
// change a lot soon anyway.
// change a lot soon anyway.// NOTE(allen):
for (dll_items(panel, used_panels)){
view = panel->view;
if (view->current_scroll){
@ -4559,16 +4571,17 @@ App_Step_Sig(app_step){
// NOTE(allen): send resize messages to panels that have changed size
{
Panel *panel, *used_panels;
Panel *panel = 0, *used_panels = 0;
used_panels = &models->layout.used_sentinel;
for (dll_items(panel, used_panels)){
i32_Rect prev = panel->prev_inner;
i32_Rect inner = panel->inner;
if (prev.x0 != inner.x0 || prev.y0 != inner.y0 ||
prev.x1 != inner.x1 || prev.y1 != inner.y1){
remeasure_file_view(system, panel->view, panel->inner);
View *view = panel->view;
i32_Rect prev = view->file_region_prev;
i32_Rect region = view->file_region;
if (!rect_equal(prev, region)){
remeasure_file_view(system, panel->view);
}
panel->prev_inner = inner;
view->file_region_prev = region;
}
}
@ -4604,7 +4617,7 @@ App_Step_Sig(app_step){
Panel *panel, *used_panels;
used_panels = &models->layout.used_sentinel;
for (dll_items(panel, used_panels)){
remeasure_file_view(system, panel->view, panel->inner);
remeasure_file_view(system, panel->view);
}
}

View File

@ -99,36 +99,39 @@ struct View{
View *next, *prev;
b32 in_use;
i32 id;
// TODO(allen): eliminate this models pointer: explicitly parameterize.
Models *models;
Panel *panel;
Command_Map *map;
Command_Map *map_for_file;
File_Viewing_Data file_data;
//GUI_Scroll_Vars file_scroll;
i32_Rect file_region_prev;
i32_Rect file_region;
i32_Rect scroll_region;
Recent_File_Data recent[16];
GUI_Scroll_Vars *current_scroll;
View_UI showing_ui;
GUI_Target gui_target;
void *gui_mem;
GUI_Scroll_Vars gui_scroll;
i32 list_i;
b32 hide_scrollbar;
// interactive stuff
Interactive_Interaction interaction;
Interactive_Action action;
char dest_[256];
String dest;
// theme stuff
View *hot_file_view;
u32 *palette;
@ -141,15 +144,15 @@ struct View{
i32 import_file_id;
i32 current_color_editing;
i32 color_cursor;
i32 font_advance;
i32 font_height;
View_Mode mode, next_mode;
View_Widget widget;
Query_Set query_set;
i32 scrub_max;
b32 reinit_scrolling;
};
@ -2735,7 +2738,7 @@ view_compute_max_target_y(View *view){
}
internal void
remeasure_file_view(System_Functions *system, View *view, i32_Rect rect){
remeasure_file_view(System_Functions *system, View *view){
if (file_is_ready(view->file_data.file)){
Relative_Scrolling relative = view_get_relative_scrolling(view);
view_measure_wraps(&view->models->mem.general, view);
@ -3396,7 +3399,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
f32 min_target_y = view->recent->scroll.min_y;
b32 show_scrollbar = 0;
b32 show_scrollbar = !view->hide_scrollbar;
view->current_scroll = 0;
@ -4062,10 +4065,11 @@ do_input_file_view(System_Functions *system, Exchange *exchange,
f32 new_min_y = -(f32)(gui_session_get_eclipsed_y(&gui_session) -
gui_session.rect.y0);
f32 new_max_y = view_compute_max_target_y(view);
view->file_region = view->scroll_region;
view->gui_target.scroll_updated.min_y = new_min_y;
view->gui_target.scroll_updated.max_y = new_max_y;
if (view->reinit_scrolling){
view_reinit_scrolling(view);
is_animating = 1;
@ -4075,7 +4079,7 @@ do_input_file_view(System_Functions *system, Exchange *exchange,
}
is_file_scroll = 1;
}break;
case guicom_color_button:
case guicom_font_button:
case guicom_button:
@ -4931,7 +4935,7 @@ do_render_file_view(System_Functions *system, Exchange *exchange,
}break;
case guicom_begin_scrollable_section:
clip_rect = gui_target->region_updated;
clip_rect.x1 = Min(gui_target->region_updated.x1, clip_rect.x1);
draw_push_clip(target, clip_rect);
break;

View File

@ -21,7 +21,6 @@ struct Panel_Divider{
struct Screen_Region{
i32_Rect full;
i32_Rect inner;
i32_Rect prev_inner;
i32 l_margin, r_margin;
i32 t_margin, b_margin;
};
@ -77,7 +76,6 @@ panel_init(Panel *panel){
panel->which_child = 0;
panel->screen_region.full = i32_rect_zero();
panel->screen_region.inner = i32_rect_zero();
panel->screen_region.prev_inner = i32_rect_zero();
panel->l_margin = 3;
panel->r_margin = 3;
panel->t_margin = 3;