view is now tied to list index position
parent
39fd699274
commit
6b6cb0b3ab
|
@ -23,6 +23,10 @@ CUSTOM_COMMAND_SIG(write_allen_note){
|
|||
write_string(app, make_lit_string("// NOTE(allen): "));
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(write_zero_struct){
|
||||
write_string(app, make_lit_string(" = {0};"));
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(write_h){
|
||||
write_string(app, make_lit_string("<h1></h1>"));
|
||||
}
|
||||
|
@ -184,7 +188,6 @@ CUSTOM_COMMAND_SIG(improve_theme){
|
|||
{Stag_Margin_Active, 0xDD0088},
|
||||
{Stag_Cursor, 0xFF0000},
|
||||
};
|
||||
|
||||
int count = ArrayCount(colors);
|
||||
|
||||
app->set_theme_colors(app, colors, count);
|
||||
|
@ -198,7 +201,6 @@ CUSTOM_COMMAND_SIG(ruin_theme){
|
|||
{Stag_Margin_Active, 0x323232},
|
||||
{Stag_Cursor, 0x00EE00},
|
||||
};
|
||||
|
||||
int count = ArrayCount(colors);
|
||||
|
||||
app->set_theme_colors(app, colors, count);
|
||||
|
@ -351,6 +353,7 @@ default_keys(Bind_Helper *context, Extension_Bindings *extension = 0){
|
|||
bind(context, '9', MDFR_CTRL, paren_wrap);
|
||||
bind(context, 'i', MDFR_ALT, if0_off);
|
||||
bind(context, '1', MDFR_ALT, open_file_in_quotes);
|
||||
bind(context, '0', MDFR_CTRL, write_zero_struct);
|
||||
|
||||
end_map(context);
|
||||
|
||||
|
@ -429,7 +432,8 @@ default_keys(Bind_Helper *context, Extension_Bindings *extension = 0){
|
|||
|
||||
#ifndef NO_BINDING
|
||||
|
||||
int get_bindings(void *data, int size){
|
||||
extern "C" int
|
||||
get_bindings(void *data, int size){
|
||||
Bind_Helper context_ = begin_bind_helper(data, size);
|
||||
Bind_Helper *context = &context_;
|
||||
|
||||
|
|
|
@ -3678,7 +3678,8 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
|||
|
||||
for (i = 0; i < keys.count; ++i){
|
||||
key = get_single_key(&keys, i);
|
||||
step = app_single_file_input_step(system, &models->working_set, key, &hdir->string, hdir, 1, 1, 0);
|
||||
step = app_single_file_input_step(system, &models->working_set, key,
|
||||
&hdir->string, hdir, 1, 1, 0);
|
||||
if (step.made_a_change){
|
||||
view->list_i = 0;
|
||||
}
|
||||
|
@ -3692,7 +3693,8 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
|||
|
||||
view->current_scroll = &view->gui_scroll;
|
||||
gui_get_scroll_vars(target, view->showing_ui, &view->gui_scroll);
|
||||
gui_begin_scrollable(target, view->showing_ui, view->gui_scroll, 9.f * view->font_height);
|
||||
gui_begin_scrollable(target, view->showing_ui,
|
||||
view->gui_scroll, 9.f * view->font_height);
|
||||
|
||||
id.id[0] = (u64)(hdir) + 1;
|
||||
|
||||
|
@ -3704,11 +3706,16 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
|||
}
|
||||
|
||||
if (update.has_index_position){
|
||||
// TODO(allen): update scrolling here.
|
||||
// TODO(allen): THOUGHT:
|
||||
// Could we better abstract this idea of having something that
|
||||
// wants to stay in view so that users don't have to manage this
|
||||
// nasty view back and forth directly if they don't want?
|
||||
|
||||
GUI_View_Jump jump =
|
||||
gui_compute_view_jump(view->gui_scroll, update.index_position);
|
||||
jump.view_min += 60.f;
|
||||
jump.view_max -= 60.f;
|
||||
gui_do_jump(target, jump);
|
||||
}
|
||||
|
||||
b32 indirectly_activate = 0;
|
||||
|
|
41
4ed_gui.cpp
41
4ed_gui.cpp
|
@ -494,7 +494,7 @@ gui_begin_list(GUI_Target *target, GUI_id id, i32 list_i, b32 activate_item, GUI
|
|||
gui_push_item(target, h, &list_i, sizeof(list_i));
|
||||
gui_push_item(target, h, &activate_item, sizeof(activate_item));
|
||||
|
||||
result = target->has_keys;
|
||||
result = target->has_keys || target->has_list_index_position;
|
||||
if (gui_id_eq(id, target->active)){
|
||||
active = 1;
|
||||
result = 1;
|
||||
|
@ -667,6 +667,12 @@ gui_get_scroll_vars(GUI_Target *target, u32 scroll_id, GUI_Scroll_Vars *vars_out
|
|||
return(result);
|
||||
}
|
||||
|
||||
internal GUI_Scroll_Vars
|
||||
gui_get_scroll_vars(GUI_Target *target){
|
||||
GUI_Scroll_Vars vars = target->scroll_updated;
|
||||
return(vars);
|
||||
}
|
||||
|
||||
internal void
|
||||
gui_post_scroll_vars(GUI_Target *target, GUI_Scroll_Vars *vars_in){
|
||||
if (!gui_scroll_eq(vars_in, &target->scroll_updated)){
|
||||
|
@ -1051,8 +1057,10 @@ gui_interpret(GUI_Target *target, GUI_Session *session, GUI_Header *h){
|
|||
if (session->list.in_list){
|
||||
if (session->list.auto_hot == session->list.index){
|
||||
result.auto_hot = 1;
|
||||
target->has_list_index_position = 1;
|
||||
target->list_index_position = rect;
|
||||
if (!rect_equal(target->list_index_position, rect)){
|
||||
target->has_list_index_position = 1;
|
||||
target->list_index_position = rect;
|
||||
}
|
||||
}
|
||||
if (session->list.auto_activate == session->list.index){
|
||||
result.auto_activate = 1;
|
||||
|
@ -1210,5 +1218,32 @@ gui_standard_list(GUI_Target *target, GUI_id id,
|
|||
gui_begin_list(target, id, *list_i, indirectly_activate, 0);
|
||||
}
|
||||
|
||||
struct GUI_View_Jump{
|
||||
f32 view_min;
|
||||
f32 view_max;
|
||||
};
|
||||
|
||||
internal GUI_View_Jump
|
||||
gui_compute_view_jump(GUI_Scroll_Vars scroll, i32_Rect position){
|
||||
GUI_View_Jump jump = {0};
|
||||
i32 region_h = scroll.region.y1 - scroll.region.y0;
|
||||
jump.view_min = (f32)position.y1 - region_h - scroll.region.y0;
|
||||
jump.view_max = (f32)position.y0 - scroll.region.y0;
|
||||
return(jump);
|
||||
}
|
||||
|
||||
internal void
|
||||
gui_do_jump(GUI_Target *target, GUI_View_Jump jump){
|
||||
GUI_Scroll_Vars vars = gui_get_scroll_vars(target);
|
||||
if (vars.target_y < jump.view_min){
|
||||
vars.target_y = jump.view_min;
|
||||
gui_post_scroll_vars(target, &vars);
|
||||
}
|
||||
else if (vars.target_y > jump.view_max){
|
||||
vars.target_y = jump.view_max;
|
||||
gui_post_scroll_vars(target, &vars);
|
||||
}
|
||||
}
|
||||
|
||||
// BOTTOM
|
||||
|
||||
|
|
2123
4ed_gui_old.cpp
2123
4ed_gui_old.cpp
File diff suppressed because it is too large
Load Diff
|
@ -172,6 +172,15 @@ f32XYWH(f32 x, f32 y, f32 w, f32 h){
|
|||
return rect;
|
||||
}
|
||||
|
||||
inline b32
|
||||
rect_equal(i32_Rect r1, i32_Rect r2){
|
||||
b32 result = (r1.x0 == r2.x0 &&
|
||||
r1.y0 == r2.y0 &&
|
||||
r1.x1 == r2.x1 &&
|
||||
r1.y1 == r2.y1);
|
||||
return(result);
|
||||
}
|
||||
|
||||
inline b32
|
||||
hit_check(i32 x, i32 y, i32 x0, i32 y0, i32 x1, i32 y1){
|
||||
return (x >= x0 && x < x1 && y >= y0 && y < y1);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Distribution Date: 16.5.2016 (dd.mm.yyyy)
|
||||
Distribution Date: 18.5.2016 (dd.mm.yyyy)
|
||||
|
||||
Thank you for contributing to the 4coder project!
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Distribution Date: 16.5.2016 (dd.mm.yyyy)
|
||||
Distribution Date: 18.5.2016 (dd.mm.yyyy)
|
||||
|
||||
Thank you for contributing to the 4coder project!
|
||||
|
||||
|
|
Loading…
Reference in New Issue