GUI removed completely, new UI API implementation in place, old UI commands stripped and need to be replaced

master
Allen Webster 2018-07-13 18:13:05 -07:00
parent ad26a76060
commit af5d6c8360
17 changed files with 469 additions and 3045 deletions

View File

@ -685,8 +685,6 @@ STRUCT View_Summary{
GUI_Scroll_Vars scroll_vars;
};
GLOBAL_VAR View_Summary null_view_summary = {0};
/* DOC(Query_Bar is a struct used to store information in the user's control
that will be displayed as a drop down bar durring an interactive command.) */
STRUCT Query_Bar{
@ -703,6 +701,44 @@ STRUCT Event_Message{
int32_t type;
};
ENUM(int32_t, UI_Item_Type){
UIType_Option,
UIType_TextField,
};
ENUM(int32_t, UI_Activation_Level){
UIActivation_None,
UIActivation_Hover,
UIActivation_Active,
};
STRUCT UI_Item{
UI_Item_Type type;
String query;
String string;
String status;
void *user_data;
UI_Activation_Level activation_level;
i32_Rect rectangle;
};
STRUCT UI_Item_Node{
UI_Item_Node *next;
UI_Item_Node *prev;
UI_Item fixed;
};
STRUCT UI_List{
UI_Item_Node *first;
UI_Item_Node *last;
int32_t count;
};
STRUCT UI_Control{
UI_Item *items;
int32_t count;
};
/*
DOC(Theme_Color stores a style tag/color pair, for the purpose of setting and getting colors in the theme.)
DOC_SEE(Style_Tag)

View File

@ -1497,17 +1497,16 @@ CUSTOM_DOC("Opens the 4coder colors and fonts selector menu.")
////////////////////////////////
#if 0
CUSTOM_COMMAND_SIG(interactive_switch_buffer_DUMMY_API_EXPLORATION)
CUSTOM_DOC("Interactively switch to an open buffer.")
{
Partition *scratch = &global_part;
View_Summary view = get_active_view(app, AccessAll);
view_start_list_mode(app, &view);
view_start_ui_mode(app, &view);
int32_t x0 = 0;
int32_t x1 = view.view_region.x1 - view.view_region.x0;
int32_t line_height = view.line_height;
int32_t line_height = (int32_t)view.line_height;
int32_t block_height = line_height*2;
Temp_Memory temp = begin_temp_memory(scratch);
@ -1518,13 +1517,13 @@ CUSTOM_DOC("Interactively switch to an open buffer.")
int32_t y_pos = line_height;
List_Control list = {0};
List_Item *highlighted_item = 0;
UI_List list = {0};
UI_Item *highlighted_item = 0;
for (Buffer_Summary buffer = get_buffer_first(app, AccessAll);
buffer.exists;
get_buffer_next(app, &buffer, AccessAll)){
String buffer_name = make_string(buffer.buffer_name, buffer.buffer_name_len);
if (has_substr(buffer_name, text_field)){
if (text_field.size == 0 || has_substr(buffer_name, text_field)){
i32_Rect item_rect = {0};
item_rect.x0 = x0;
item_rect.y0 = y_pos;
@ -1532,23 +1531,25 @@ CUSTOM_DOC("Interactively switch to an open buffer.")
item_rect.y1 = y_pos + block_height;
y_pos = item_rect.y1;
List_Item *item = push_array(scratch, List_Item, 1);
memset(item, 0, sizeof(*item));
item->type = ListItemType_Option;
item->string = push_string_copy(scratch, buffer_name);
UI_Item item = {0};
item.type = UIType_Option;
item.string = push_string_copy(scratch, buffer_name);
char *status = "";
switch (buffer.dirty){
case DirtyState_UnsavedChanges: status = " *"; break;
case DirtyState_UnloadedChanges: status = " !"; break;
}
item->status = push_string_copy(scratch, status);
item->user_data = (void*)buffer.buffer_id;
item->highlighted = false;
item->rectangle = item_rect;
list_control_add_item(&list, item);
item.status = push_string_copy(scratch, status);
item.user_data = (void*)buffer.buffer_id;
item.activation_level = UIActivation_None;
item.rectangle = item_rect;
if (highlighted_item == 0){
highlighted_item = item;
item.activation_level = UIActivation_Hover;
UI_Item *item_ptr = ui_list_add_item(scratch, &list, item);
highlighted_item = item_ptr;
}
else{
ui_list_add_item(scratch, &list, item);
}
}
}
@ -1561,23 +1562,24 @@ CUSTOM_DOC("Interactively switch to an open buffer.")
item_rect.y1 = line_height;
y_pos = item_rect.y1;
List_Item *item = push_array(scratch, List_Item, 1);
memset(item, 0, sizeof(*item));
item->type = ListItemType_TextField;
item->query = push_string_copy(scratch, "Switch: ");
item->string = text_field;
item->user_data = 0;
item->rectangle = item_rect;
UI_Item item = {0};
item.type = UIType_TextField;
item.query = push_string_copy(scratch, "Switch: ");
item.string = text_field;
item.user_data = 0;
item.rectangle = item_rect;
ui_list_add_item(scratch, &list, item);
}
view_set_list(app, &view, &list);
UI_Control control = ui_list_to_ui_control(scratch, &list);
view_set_ui(app, &view, &control);
User_Input in = get_user_input(app, EventAll, EventOnEsc);
if (in.abort){
goto done;
}
List_Item *activated_item = 0;
UI_Item *activated_item = 0;
switch (in.type){
case UserInputKey:
{
@ -1601,7 +1603,7 @@ CUSTOM_DOC("Interactively switch to an open buffer.")
if (in.mouse.press_l){
int32_t mx = in.mouse.x - view.view_region.x0;
int32_t my = in.mouse.y - view.view_region.y0;
activated_item = list_control_get_mouse_hit(&list, mx, my);
activated_item = ui_control_get_mouse_hit(&control, mx, my);
}
}break;
}
@ -1614,10 +1616,9 @@ CUSTOM_DOC("Interactively switch to an open buffer.")
}
done:;
view_end_list_mode(app, &view);
view_end_ui_mode(app, &view);
end_temp_memory(temp);
}
#endif
////////////////////////////////

View File

@ -37,6 +37,7 @@
#include "4coder_default_framework_variables.cpp"
#include "4coder_buffer_seek_constructors.cpp"
#include "4coder_ui_helper.cpp"
#include "4coder_helper.cpp"
#include "4coder_font_helper.cpp"
#include "4coder_config.cpp"

View File

@ -52,6 +52,9 @@ struct Application_Links;
#define CREATE_VIEW_VARIABLE_SIG(n) int32_t n(Application_Links *app, char *null_terminated_name, uint64_t default_value)
#define VIEW_SET_VARIABLE_SIG(n) bool32 n(Application_Links *app, View_Summary *view, int32_t location, uint64_t value)
#define VIEW_GET_VARIABLE_SIG(n) bool32 n(Application_Links *app, View_Summary *view, int32_t location, uint64_t *value_out)
#define VIEW_START_UI_MODE_SIG(n) int32_t n(Application_Links *app, View_Summary *view)
#define VIEW_END_UI_MODE_SIG(n) int32_t n(Application_Links *app, View_Summary *view)
#define VIEW_SET_UI_SIG(n) bool32 n(Application_Links *app, View_Summary *view, UI_Control *control)
#define GET_USER_INPUT_SIG(n) User_Input n(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type)
#define GET_COMMAND_INPUT_SIG(n) User_Input n(Application_Links *app)
#define GET_MOUSE_STATE_SIG(n) Mouse_State n(Application_Links *app)
@ -141,6 +144,9 @@ typedef VIEW_POST_FADE_SIG(View_Post_Fade_Function);
typedef CREATE_VIEW_VARIABLE_SIG(Create_View_Variable_Function);
typedef VIEW_SET_VARIABLE_SIG(View_Set_Variable_Function);
typedef VIEW_GET_VARIABLE_SIG(View_Get_Variable_Function);
typedef VIEW_START_UI_MODE_SIG(View_Start_UI_Mode_Function);
typedef VIEW_END_UI_MODE_SIG(View_End_UI_Mode_Function);
typedef VIEW_SET_UI_SIG(View_Set_UI_Function);
typedef GET_USER_INPUT_SIG(Get_User_Input_Function);
typedef GET_COMMAND_INPUT_SIG(Get_Command_Input_Function);
typedef GET_MOUSE_STATE_SIG(Get_Mouse_State_Function);
@ -232,6 +238,9 @@ View_Post_Fade_Function *view_post_fade;
Create_View_Variable_Function *create_view_variable;
View_Set_Variable_Function *view_set_variable;
View_Get_Variable_Function *view_get_variable;
View_Start_UI_Mode_Function *view_start_ui_mode;
View_End_UI_Mode_Function *view_end_ui_mode;
View_Set_UI_Function *view_set_ui;
Get_User_Input_Function *get_user_input;
Get_Command_Input_Function *get_command_input;
Get_Mouse_State_Function *get_mouse_state;
@ -322,6 +331,9 @@ View_Post_Fade_Function *view_post_fade_;
Create_View_Variable_Function *create_view_variable_;
View_Set_Variable_Function *view_set_variable_;
View_Get_Variable_Function *view_get_variable_;
View_Start_UI_Mode_Function *view_start_ui_mode_;
View_End_UI_Mode_Function *view_end_ui_mode_;
View_Set_UI_Function *view_set_ui_;
Get_User_Input_Function *get_user_input_;
Get_Command_Input_Function *get_command_input_;
Get_Mouse_State_Function *get_mouse_state_;
@ -420,6 +432,9 @@ app_links->view_post_fade_ = View_Post_Fade;\
app_links->create_view_variable_ = Create_View_Variable;\
app_links->view_set_variable_ = View_Set_Variable;\
app_links->view_get_variable_ = View_Get_Variable;\
app_links->view_start_ui_mode_ = View_Start_UI_Mode;\
app_links->view_end_ui_mode_ = View_End_UI_Mode;\
app_links->view_set_ui_ = View_Set_UI;\
app_links->get_user_input_ = Get_User_Input;\
app_links->get_command_input_ = Get_Command_Input;\
app_links->get_mouse_state_ = Get_Mouse_State;\
@ -510,6 +525,9 @@ static inline bool32 view_post_fade(Application_Links *app, View_Summary *view,
static inline int32_t create_view_variable(Application_Links *app, char *null_terminated_name, uint64_t default_value){return(app->create_view_variable(app, null_terminated_name, default_value));}
static inline bool32 view_set_variable(Application_Links *app, View_Summary *view, int32_t location, uint64_t value){return(app->view_set_variable(app, view, location, value));}
static inline bool32 view_get_variable(Application_Links *app, View_Summary *view, int32_t location, uint64_t *value_out){return(app->view_get_variable(app, view, location, value_out));}
static inline int32_t view_start_ui_mode(Application_Links *app, View_Summary *view){return(app->view_start_ui_mode(app, view));}
static inline int32_t view_end_ui_mode(Application_Links *app, View_Summary *view){return(app->view_end_ui_mode(app, view));}
static inline bool32 view_set_ui(Application_Links *app, View_Summary *view, UI_Control *control){return(app->view_set_ui(app, view, control));}
static inline User_Input get_user_input(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type){return(app->get_user_input(app, get_type, abort_type));}
static inline User_Input get_command_input(Application_Links *app){return(app->get_command_input(app));}
static inline Mouse_State get_mouse_state(Application_Links *app){return(app->get_mouse_state(app));}
@ -600,6 +618,9 @@ static inline bool32 view_post_fade(Application_Links *app, View_Summary *view,
static inline int32_t create_view_variable(Application_Links *app, char *null_terminated_name, uint64_t default_value){return(app->create_view_variable_(app, null_terminated_name, default_value));}
static inline bool32 view_set_variable(Application_Links *app, View_Summary *view, int32_t location, uint64_t value){return(app->view_set_variable_(app, view, location, value));}
static inline bool32 view_get_variable(Application_Links *app, View_Summary *view, int32_t location, uint64_t *value_out){return(app->view_get_variable_(app, view, location, value_out));}
static inline int32_t view_start_ui_mode(Application_Links *app, View_Summary *view){return(app->view_start_ui_mode_(app, view));}
static inline int32_t view_end_ui_mode(Application_Links *app, View_Summary *view){return(app->view_end_ui_mode_(app, view));}
static inline bool32 view_set_ui(Application_Links *app, View_Summary *view, UI_Control *control){return(app->view_set_ui_(app, view, control));}
static inline User_Input get_user_input(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type){return(app->get_user_input_(app, get_type, abort_type));}
static inline User_Input get_command_input(Application_Links *app){return(app->get_command_input_(app));}
static inline Mouse_State get_mouse_state(Application_Links *app){return(app->get_mouse_state_(app));}

View File

@ -2,7 +2,7 @@
#define command_id(c) (fcoder_metacmd_ID_##c)
#define command_metadata(c) (&fcoder_metacmd_table[command_id(c)])
#define command_metadata_by_id(id) (&fcoder_metacmd_table[id])
#define command_one_past_last_id 184
#define command_one_past_last_id 185
#if defined(CUSTOM_COMMAND_SIG)
#define PROC_LINKS(x,y) x
#else
@ -77,6 +77,7 @@ CUSTOM_COMMAND_SIG(interactive_new);
CUSTOM_COMMAND_SIG(interactive_open);
CUSTOM_COMMAND_SIG(interactive_open_or_new);
CUSTOM_COMMAND_SIG(interactive_switch_buffer);
CUSTOM_COMMAND_SIG(interactive_switch_buffer_DUMMY_API_EXPLORATION);
CUSTOM_COMMAND_SIG(kill_buffer);
CUSTOM_COMMAND_SIG(left_adjust_view);
CUSTOM_COMMAND_SIG(list_all_functions_current_buffer);
@ -204,7 +205,7 @@ char *source_name;
int32_t source_name_len;
int32_t line_number;
};
static Command_Metadata fcoder_metacmd_table[184] = {
static Command_Metadata fcoder_metacmd_table[185] = {
{ PROC_LINKS(allow_mouse, 0), "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "w:\\4ed\\code\\4coder_default_framework.cpp", 43, 191 },
{ PROC_LINKS(auto_tab_line_at_cursor, 0), "auto_tab_line_at_cursor", 23, "Auto-indents the line on which the cursor sits.", 47, "w:\\4ed\\code\\4coder_auto_indent.cpp", 37, 722 },
{ PROC_LINKS(auto_tab_range, 0), "auto_tab_range", 14, "Auto-indents the range between the cursor and the mark.", 55, "w:\\4ed\\code\\4coder_auto_indent.cpp", 37, 733 },
@ -273,6 +274,7 @@ static Command_Metadata fcoder_metacmd_table[184] = {
{ PROC_LINKS(interactive_open, 0), "interactive_open", 16, "Interactively opens a file.", 27, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1450 },
{ PROC_LINKS(interactive_open_or_new, 0), "interactive_open_or_new", 23, "Interactively opens or creates a new file.", 42, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1456 },
{ PROC_LINKS(interactive_switch_buffer, 0), "interactive_switch_buffer", 25, "Interactively switch to an open buffer.", 39, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1462 },
{ PROC_LINKS(interactive_switch_buffer_DUMMY_API_EXPLORATION, 0), "interactive_switch_buffer_DUMMY_API_EXPLORATION", 47, "Interactively switch to an open buffer.", 39, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1500 },
{ PROC_LINKS(kill_buffer, 0), "kill_buffer", 11, "Kills the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1486 },
{ PROC_LINKS(left_adjust_view, 0), "left_adjust_view", 16, "Sets the left size of the view near the x position of the cursor.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 135 },
{ PROC_LINKS(list_all_functions_current_buffer, 0), "list_all_functions_current_buffer", 33, "Creates a jump list of lines of the current buffer that appear to define or declare functions.", 94, "w:\\4ed\\code\\4coder_function_list.cpp", 39, 318 },
@ -305,7 +307,7 @@ static Command_Metadata fcoder_metacmd_table[184] = {
{ PROC_LINKS(open_all_code_recursive, 0), "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "w:\\4ed\\code\\4coder_project_commands.cpp", 42, 1062 },
{ PROC_LINKS(open_color_tweaker, 0), "open_color_tweaker", 18, "Opens the 4coder colors and fonts selector menu.", 48, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1492 },
{ PROC_LINKS(open_file_in_quotes, 0), "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1339 },
{ PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1624 },
{ PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 39, 1625 },
{ PROC_LINKS(open_long_braces, 0), "open_long_braces", 16, "At the cursor, insert a '{' and '}' separated by a blank line.", 62, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 49, 58 },
{ PROC_LINKS(open_long_braces_break, 0), "open_long_braces_break", 22, "At the cursor, insert a '{' and '}break;' separated by a blank line.", 68, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 49, 74 },
{ PROC_LINKS(open_long_braces_semicolon, 0), "open_long_braces_semicolon", 26, "At the cursor, insert a '{' and '};' separated by a blank line.", 63, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 49, 66 },
@ -458,120 +460,121 @@ static int32_t fcoder_metacmd_ID_interactive_new = 64;
static int32_t fcoder_metacmd_ID_interactive_open = 65;
static int32_t fcoder_metacmd_ID_interactive_open_or_new = 66;
static int32_t fcoder_metacmd_ID_interactive_switch_buffer = 67;
static int32_t fcoder_metacmd_ID_kill_buffer = 68;
static int32_t fcoder_metacmd_ID_left_adjust_view = 69;
static int32_t fcoder_metacmd_ID_list_all_functions_current_buffer = 70;
static int32_t fcoder_metacmd_ID_list_all_locations = 71;
static int32_t fcoder_metacmd_ID_list_all_locations_case_insensitive = 72;
static int32_t fcoder_metacmd_ID_list_all_locations_of_identifier = 73;
static int32_t fcoder_metacmd_ID_list_all_locations_of_identifier_case_insensitive = 74;
static int32_t fcoder_metacmd_ID_list_all_locations_of_selection = 75;
static int32_t fcoder_metacmd_ID_list_all_locations_of_selection_case_insensitive = 76;
static int32_t fcoder_metacmd_ID_list_all_locations_of_type_definition = 77;
static int32_t fcoder_metacmd_ID_list_all_locations_of_type_definition_of_identifier = 78;
static int32_t fcoder_metacmd_ID_list_all_substring_locations = 79;
static int32_t fcoder_metacmd_ID_list_all_substring_locations_case_insensitive = 80;
static int32_t fcoder_metacmd_ID_load_project = 81;
static int32_t fcoder_metacmd_ID_make_directory_query = 82;
static int32_t fcoder_metacmd_ID_move_down = 83;
static int32_t fcoder_metacmd_ID_move_down_10 = 84;
static int32_t fcoder_metacmd_ID_move_down_textual = 85;
static int32_t fcoder_metacmd_ID_move_left = 86;
static int32_t fcoder_metacmd_ID_move_line_down = 87;
static int32_t fcoder_metacmd_ID_move_line_up = 88;
static int32_t fcoder_metacmd_ID_move_right = 89;
static int32_t fcoder_metacmd_ID_move_up = 90;
static int32_t fcoder_metacmd_ID_move_up_10 = 91;
static int32_t fcoder_metacmd_ID_newline_or_goto_position_direct = 92;
static int32_t fcoder_metacmd_ID_newline_or_goto_position_same_panel_direct = 93;
static int32_t fcoder_metacmd_ID_newline_or_goto_position_same_panel_sticky = 94;
static int32_t fcoder_metacmd_ID_newline_or_goto_position_sticky = 95;
static int32_t fcoder_metacmd_ID_open_all_code = 96;
static int32_t fcoder_metacmd_ID_open_all_code_recursive = 97;
static int32_t fcoder_metacmd_ID_open_color_tweaker = 98;
static int32_t fcoder_metacmd_ID_open_file_in_quotes = 99;
static int32_t fcoder_metacmd_ID_open_in_other = 100;
static int32_t fcoder_metacmd_ID_open_long_braces = 101;
static int32_t fcoder_metacmd_ID_open_long_braces_break = 102;
static int32_t fcoder_metacmd_ID_open_long_braces_semicolon = 103;
static int32_t fcoder_metacmd_ID_open_matching_file_cpp = 104;
static int32_t fcoder_metacmd_ID_open_panel_hsplit = 105;
static int32_t fcoder_metacmd_ID_open_panel_vsplit = 106;
static int32_t fcoder_metacmd_ID_page_down = 107;
static int32_t fcoder_metacmd_ID_page_up = 108;
static int32_t fcoder_metacmd_ID_paste = 109;
static int32_t fcoder_metacmd_ID_paste_and_indent = 110;
static int32_t fcoder_metacmd_ID_paste_next = 111;
static int32_t fcoder_metacmd_ID_paste_next_and_indent = 112;
static int32_t fcoder_metacmd_ID_place_in_scope = 113;
static int32_t fcoder_metacmd_ID_project_fkey_command = 114;
static int32_t fcoder_metacmd_ID_project_go_to_root_directory = 115;
static int32_t fcoder_metacmd_ID_query_replace = 116;
static int32_t fcoder_metacmd_ID_query_replace_identifier = 117;
static int32_t fcoder_metacmd_ID_query_replace_selection = 118;
static int32_t fcoder_metacmd_ID_redo = 119;
static int32_t fcoder_metacmd_ID_remap_interactive = 120;
static int32_t fcoder_metacmd_ID_rename_file_query = 121;
static int32_t fcoder_metacmd_ID_reopen = 122;
static int32_t fcoder_metacmd_ID_replace_in_range = 123;
static int32_t fcoder_metacmd_ID_reverse_search = 124;
static int32_t fcoder_metacmd_ID_reverse_search_identifier = 125;
static int32_t fcoder_metacmd_ID_save = 126;
static int32_t fcoder_metacmd_ID_save_all_dirty_buffers = 127;
static int32_t fcoder_metacmd_ID_save_to_query = 128;
static int32_t fcoder_metacmd_ID_scope_absorb_down = 129;
static int32_t fcoder_metacmd_ID_search = 130;
static int32_t fcoder_metacmd_ID_search_identifier = 131;
static int32_t fcoder_metacmd_ID_seek_alphanumeric_left = 132;
static int32_t fcoder_metacmd_ID_seek_alphanumeric_or_camel_left = 133;
static int32_t fcoder_metacmd_ID_seek_alphanumeric_or_camel_right = 134;
static int32_t fcoder_metacmd_ID_seek_alphanumeric_right = 135;
static int32_t fcoder_metacmd_ID_seek_beginning_of_line = 136;
static int32_t fcoder_metacmd_ID_seek_beginning_of_textual_line = 137;
static int32_t fcoder_metacmd_ID_seek_end_of_line = 138;
static int32_t fcoder_metacmd_ID_seek_end_of_textual_line = 139;
static int32_t fcoder_metacmd_ID_seek_token_left = 140;
static int32_t fcoder_metacmd_ID_seek_token_right = 141;
static int32_t fcoder_metacmd_ID_seek_white_or_token_left = 142;
static int32_t fcoder_metacmd_ID_seek_white_or_token_right = 143;
static int32_t fcoder_metacmd_ID_seek_whitespace_down = 144;
static int32_t fcoder_metacmd_ID_seek_whitespace_down_end_line = 145;
static int32_t fcoder_metacmd_ID_seek_whitespace_left = 146;
static int32_t fcoder_metacmd_ID_seek_whitespace_right = 147;
static int32_t fcoder_metacmd_ID_seek_whitespace_up = 148;
static int32_t fcoder_metacmd_ID_seek_whitespace_up_end_line = 149;
static int32_t fcoder_metacmd_ID_select_all = 150;
static int32_t fcoder_metacmd_ID_set_bindings_choose = 151;
static int32_t fcoder_metacmd_ID_set_bindings_default = 152;
static int32_t fcoder_metacmd_ID_set_bindings_mac_default = 153;
static int32_t fcoder_metacmd_ID_set_mark = 154;
static int32_t fcoder_metacmd_ID_setup_build_bat = 155;
static int32_t fcoder_metacmd_ID_setup_build_bat_and_sh = 156;
static int32_t fcoder_metacmd_ID_setup_build_sh = 157;
static int32_t fcoder_metacmd_ID_setup_new_project = 158;
static int32_t fcoder_metacmd_ID_show_filebar = 159;
static int32_t fcoder_metacmd_ID_show_scrollbar = 160;
static int32_t fcoder_metacmd_ID_snipe_token_or_word = 161;
static int32_t fcoder_metacmd_ID_snipe_token_or_word_right = 162;
static int32_t fcoder_metacmd_ID_suppress_mouse = 163;
static int32_t fcoder_metacmd_ID_swap_buffers_between_panels = 164;
static int32_t fcoder_metacmd_ID_to_lowercase = 165;
static int32_t fcoder_metacmd_ID_to_uppercase = 166;
static int32_t fcoder_metacmd_ID_toggle_filebar = 167;
static int32_t fcoder_metacmd_ID_toggle_fullscreen = 168;
static int32_t fcoder_metacmd_ID_toggle_line_wrap = 169;
static int32_t fcoder_metacmd_ID_toggle_mouse = 170;
static int32_t fcoder_metacmd_ID_toggle_show_whitespace = 171;
static int32_t fcoder_metacmd_ID_toggle_virtual_whitespace = 172;
static int32_t fcoder_metacmd_ID_undo = 173;
static int32_t fcoder_metacmd_ID_view_buffer_other_panel = 174;
static int32_t fcoder_metacmd_ID_word_complete = 175;
static int32_t fcoder_metacmd_ID_write_and_auto_tab = 176;
static int32_t fcoder_metacmd_ID_write_block = 177;
static int32_t fcoder_metacmd_ID_write_character = 178;
static int32_t fcoder_metacmd_ID_write_hack = 179;
static int32_t fcoder_metacmd_ID_write_note = 180;
static int32_t fcoder_metacmd_ID_write_todo = 181;
static int32_t fcoder_metacmd_ID_write_underscore = 182;
static int32_t fcoder_metacmd_ID_write_zero_struct = 183;
static int32_t fcoder_metacmd_ID_interactive_switch_buffer_DUMMY_API_EXPLORATION = 68;
static int32_t fcoder_metacmd_ID_kill_buffer = 69;
static int32_t fcoder_metacmd_ID_left_adjust_view = 70;
static int32_t fcoder_metacmd_ID_list_all_functions_current_buffer = 71;
static int32_t fcoder_metacmd_ID_list_all_locations = 72;
static int32_t fcoder_metacmd_ID_list_all_locations_case_insensitive = 73;
static int32_t fcoder_metacmd_ID_list_all_locations_of_identifier = 74;
static int32_t fcoder_metacmd_ID_list_all_locations_of_identifier_case_insensitive = 75;
static int32_t fcoder_metacmd_ID_list_all_locations_of_selection = 76;
static int32_t fcoder_metacmd_ID_list_all_locations_of_selection_case_insensitive = 77;
static int32_t fcoder_metacmd_ID_list_all_locations_of_type_definition = 78;
static int32_t fcoder_metacmd_ID_list_all_locations_of_type_definition_of_identifier = 79;
static int32_t fcoder_metacmd_ID_list_all_substring_locations = 80;
static int32_t fcoder_metacmd_ID_list_all_substring_locations_case_insensitive = 81;
static int32_t fcoder_metacmd_ID_load_project = 82;
static int32_t fcoder_metacmd_ID_make_directory_query = 83;
static int32_t fcoder_metacmd_ID_move_down = 84;
static int32_t fcoder_metacmd_ID_move_down_10 = 85;
static int32_t fcoder_metacmd_ID_move_down_textual = 86;
static int32_t fcoder_metacmd_ID_move_left = 87;
static int32_t fcoder_metacmd_ID_move_line_down = 88;
static int32_t fcoder_metacmd_ID_move_line_up = 89;
static int32_t fcoder_metacmd_ID_move_right = 90;
static int32_t fcoder_metacmd_ID_move_up = 91;
static int32_t fcoder_metacmd_ID_move_up_10 = 92;
static int32_t fcoder_metacmd_ID_newline_or_goto_position_direct = 93;
static int32_t fcoder_metacmd_ID_newline_or_goto_position_same_panel_direct = 94;
static int32_t fcoder_metacmd_ID_newline_or_goto_position_same_panel_sticky = 95;
static int32_t fcoder_metacmd_ID_newline_or_goto_position_sticky = 96;
static int32_t fcoder_metacmd_ID_open_all_code = 97;
static int32_t fcoder_metacmd_ID_open_all_code_recursive = 98;
static int32_t fcoder_metacmd_ID_open_color_tweaker = 99;
static int32_t fcoder_metacmd_ID_open_file_in_quotes = 100;
static int32_t fcoder_metacmd_ID_open_in_other = 101;
static int32_t fcoder_metacmd_ID_open_long_braces = 102;
static int32_t fcoder_metacmd_ID_open_long_braces_break = 103;
static int32_t fcoder_metacmd_ID_open_long_braces_semicolon = 104;
static int32_t fcoder_metacmd_ID_open_matching_file_cpp = 105;
static int32_t fcoder_metacmd_ID_open_panel_hsplit = 106;
static int32_t fcoder_metacmd_ID_open_panel_vsplit = 107;
static int32_t fcoder_metacmd_ID_page_down = 108;
static int32_t fcoder_metacmd_ID_page_up = 109;
static int32_t fcoder_metacmd_ID_paste = 110;
static int32_t fcoder_metacmd_ID_paste_and_indent = 111;
static int32_t fcoder_metacmd_ID_paste_next = 112;
static int32_t fcoder_metacmd_ID_paste_next_and_indent = 113;
static int32_t fcoder_metacmd_ID_place_in_scope = 114;
static int32_t fcoder_metacmd_ID_project_fkey_command = 115;
static int32_t fcoder_metacmd_ID_project_go_to_root_directory = 116;
static int32_t fcoder_metacmd_ID_query_replace = 117;
static int32_t fcoder_metacmd_ID_query_replace_identifier = 118;
static int32_t fcoder_metacmd_ID_query_replace_selection = 119;
static int32_t fcoder_metacmd_ID_redo = 120;
static int32_t fcoder_metacmd_ID_remap_interactive = 121;
static int32_t fcoder_metacmd_ID_rename_file_query = 122;
static int32_t fcoder_metacmd_ID_reopen = 123;
static int32_t fcoder_metacmd_ID_replace_in_range = 124;
static int32_t fcoder_metacmd_ID_reverse_search = 125;
static int32_t fcoder_metacmd_ID_reverse_search_identifier = 126;
static int32_t fcoder_metacmd_ID_save = 127;
static int32_t fcoder_metacmd_ID_save_all_dirty_buffers = 128;
static int32_t fcoder_metacmd_ID_save_to_query = 129;
static int32_t fcoder_metacmd_ID_scope_absorb_down = 130;
static int32_t fcoder_metacmd_ID_search = 131;
static int32_t fcoder_metacmd_ID_search_identifier = 132;
static int32_t fcoder_metacmd_ID_seek_alphanumeric_left = 133;
static int32_t fcoder_metacmd_ID_seek_alphanumeric_or_camel_left = 134;
static int32_t fcoder_metacmd_ID_seek_alphanumeric_or_camel_right = 135;
static int32_t fcoder_metacmd_ID_seek_alphanumeric_right = 136;
static int32_t fcoder_metacmd_ID_seek_beginning_of_line = 137;
static int32_t fcoder_metacmd_ID_seek_beginning_of_textual_line = 138;
static int32_t fcoder_metacmd_ID_seek_end_of_line = 139;
static int32_t fcoder_metacmd_ID_seek_end_of_textual_line = 140;
static int32_t fcoder_metacmd_ID_seek_token_left = 141;
static int32_t fcoder_metacmd_ID_seek_token_right = 142;
static int32_t fcoder_metacmd_ID_seek_white_or_token_left = 143;
static int32_t fcoder_metacmd_ID_seek_white_or_token_right = 144;
static int32_t fcoder_metacmd_ID_seek_whitespace_down = 145;
static int32_t fcoder_metacmd_ID_seek_whitespace_down_end_line = 146;
static int32_t fcoder_metacmd_ID_seek_whitespace_left = 147;
static int32_t fcoder_metacmd_ID_seek_whitespace_right = 148;
static int32_t fcoder_metacmd_ID_seek_whitespace_up = 149;
static int32_t fcoder_metacmd_ID_seek_whitespace_up_end_line = 150;
static int32_t fcoder_metacmd_ID_select_all = 151;
static int32_t fcoder_metacmd_ID_set_bindings_choose = 152;
static int32_t fcoder_metacmd_ID_set_bindings_default = 153;
static int32_t fcoder_metacmd_ID_set_bindings_mac_default = 154;
static int32_t fcoder_metacmd_ID_set_mark = 155;
static int32_t fcoder_metacmd_ID_setup_build_bat = 156;
static int32_t fcoder_metacmd_ID_setup_build_bat_and_sh = 157;
static int32_t fcoder_metacmd_ID_setup_build_sh = 158;
static int32_t fcoder_metacmd_ID_setup_new_project = 159;
static int32_t fcoder_metacmd_ID_show_filebar = 160;
static int32_t fcoder_metacmd_ID_show_scrollbar = 161;
static int32_t fcoder_metacmd_ID_snipe_token_or_word = 162;
static int32_t fcoder_metacmd_ID_snipe_token_or_word_right = 163;
static int32_t fcoder_metacmd_ID_suppress_mouse = 164;
static int32_t fcoder_metacmd_ID_swap_buffers_between_panels = 165;
static int32_t fcoder_metacmd_ID_to_lowercase = 166;
static int32_t fcoder_metacmd_ID_to_uppercase = 167;
static int32_t fcoder_metacmd_ID_toggle_filebar = 168;
static int32_t fcoder_metacmd_ID_toggle_fullscreen = 169;
static int32_t fcoder_metacmd_ID_toggle_line_wrap = 170;
static int32_t fcoder_metacmd_ID_toggle_mouse = 171;
static int32_t fcoder_metacmd_ID_toggle_show_whitespace = 172;
static int32_t fcoder_metacmd_ID_toggle_virtual_whitespace = 173;
static int32_t fcoder_metacmd_ID_undo = 174;
static int32_t fcoder_metacmd_ID_view_buffer_other_panel = 175;
static int32_t fcoder_metacmd_ID_word_complete = 176;
static int32_t fcoder_metacmd_ID_write_and_auto_tab = 177;
static int32_t fcoder_metacmd_ID_write_block = 178;
static int32_t fcoder_metacmd_ID_write_character = 179;
static int32_t fcoder_metacmd_ID_write_hack = 180;
static int32_t fcoder_metacmd_ID_write_note = 181;
static int32_t fcoder_metacmd_ID_write_todo = 182;
static int32_t fcoder_metacmd_ID_write_underscore = 183;
static int32_t fcoder_metacmd_ID_write_zero_struct = 184;
#endif

View File

@ -10,7 +10,7 @@ bind(context, 'n', MDFR_CTRL, interactive_new);
bind(context, 'o', MDFR_CTRL, interactive_open_or_new);
bind(context, 'o', MDFR_ALT, open_in_other);
bind(context, 'k', MDFR_CTRL, interactive_kill_buffer);
bind(context, 'i', MDFR_CTRL, interactive_switch_buffer);
bind(context, 'i', MDFR_CTRL, interactive_switch_buffer_DUMMY_API_EXPLORATION);
bind(context, 'h', MDFR_CTRL, project_go_to_root_directory);
bind(context, 'S', MDFR_CTRL, save_all_dirty_buffers);
bind(context, 'c', MDFR_ALT, open_color_tweaker);
@ -344,7 +344,7 @@ static Meta_Key_Bind fcoder_binds_for_default_mapid_global[45] = {
{0, 111, 1, "interactive_open_or_new", 23, LINK_PROCS(interactive_open_or_new)},
{0, 111, 2, "open_in_other", 13, LINK_PROCS(open_in_other)},
{0, 107, 1, "interactive_kill_buffer", 23, LINK_PROCS(interactive_kill_buffer)},
{0, 105, 1, "interactive_switch_buffer", 25, LINK_PROCS(interactive_switch_buffer)},
{0, 105, 1, "interactive_switch_buffer_DUMMY_API_EXPLORATION", 47, LINK_PROCS(interactive_switch_buffer_DUMMY_API_EXPLORATION)},
{0, 104, 1, "project_go_to_root_directory", 28, LINK_PROCS(project_go_to_root_directory)},
{0, 83, 1, "save_all_dirty_buffers", 22, LINK_PROCS(save_all_dirty_buffers)},
{0, 99, 2, "open_color_tweaker", 18, LINK_PROCS(open_color_tweaker)},

View File

@ -613,7 +613,7 @@ get_view_last(Application_Links *app, uint32_t access){
view.exists = true;
get_view_prev(app, &view, access);
if (view.view_id < 1 || view.view_id > 16){
view = null_view_summary;
memset(&view, 0, sizeof(view));
}
return(view);
}

42
4coder_ui_helper.cpp Normal file
View File

@ -0,0 +1,42 @@
/*
* Helpers for ui data structures.
*/
// TOP
static UI_Item*
ui_list_add_item(Partition *arena, UI_List *list, UI_Item item){
UI_Item_Node *node = push_array(arena, UI_Item_Node, 1);
zdll_push_back(list->first, list->last, node);
list->count += 1;
node->fixed = item;
return(&node->fixed);
}
static UI_Control
ui_list_to_ui_control(Partition *arena, UI_List *list){
UI_Control control = {0};
control.items = push_array(arena, UI_Item, list->count);
for (UI_Item_Node *node = list->first;
node != 0;
node = node->next){
control.items[control.count++] = node->fixed;
}
return(control);
}
static UI_Item*
ui_control_get_mouse_hit(UI_Control *control, int32_t mx, int32_t my){
int32_t count = control->count;
UI_Item *item = control->items + count - 1;
for (int32_t i = 0; i < count; ++i, item -= 1){
i32_Rect r = item->rectangle;
if (r.x0 <= mx && mx < r.x1 && r.y0 <= my && my < r.y1){
return(item);
}
}
return(0);
}
// BOTTOM

74
4ed.cpp
View File

@ -232,21 +232,15 @@ COMMAND_DECL(redo){
}
COMMAND_DECL(interactive_new){
USE_MODELS(models);
USE_VIEW(view);
view_show_interactive(system, view, models, IAct_New, IInt_Sys_File_List, make_lit_string("New: "));
}
COMMAND_DECL(interactive_open){
USE_MODELS(models);
USE_VIEW(view);
view_show_interactive(system, view, models, IAct_Open, IInt_Sys_File_List,make_lit_string("Open: "));
}
COMMAND_DECL(interactive_open_or_new){
USE_MODELS(models);
USE_VIEW(view);
view_show_interactive(system, view, models, IAct_OpenOrNew, IInt_Sys_File_List,make_lit_string("Open: "));
}
// TODO(allen): Improvements to reopen
@ -335,15 +329,11 @@ COMMAND_DECL(save){
}
COMMAND_DECL(interactive_switch_buffer){
USE_MODELS(models);
USE_VIEW(view);
view_show_interactive(system, view, models, IAct_Switch, IInt_Live_File_List, make_lit_string("Switch Buffer: "));
}
COMMAND_DECL(interactive_kill_buffer){
USE_MODELS(models);
USE_VIEW(view);
view_show_interactive(system, view, models, IAct_Kill, IInt_Live_File_List, make_lit_string("Kill Buffer: "));
}
COMMAND_DECL(kill_buffer){
@ -387,13 +377,7 @@ case_change_range(System_Functions *system, Models *models, View *view, Editing_
}
COMMAND_DECL(open_color_tweaker){
USE_VIEW(view);
view->transient.map = mapid_ui;
view->transient.showing_ui = VUI_Theme;
view->transient.color_mode = CV_Mode_Library;
view->transient.color = super_color_create(0xFF000000);
view->transient.current_color_editing = 0;
view->transient.changed_context_in_step = true;
}
COMMAND_DECL(user_callback){
@ -1683,7 +1667,9 @@ App_Step_Sig(app_step){
view = panel->view;
}
#if 0
view_show_interactive(system, view, models, IAct_Sure_To_Close, IInt_Sure_To_Close, make_lit_string("Are you sure?"));
#endif
models->command_coroutine = command_coroutine;
}
@ -1884,18 +1870,6 @@ App_Step_Sig(app_step){
view->transient.changed_context_in_step = 0;
View_Step_Result result = step_view(system, view, models, active_view, summary);
if (result.animating){
app_result.animating = 1;
}
if (result.consume_keys){
consume_input(&vars->available_input, Input_AnyKey, "file view step");
}
if (result.consume_keys || result.consume_esc){
consume_input(&vars->available_input, Input_Esc, "file view step");
}
if (view->transient.changed_context_in_step == 0){
active = (panel == active_panel);
summary = (active)?(active_input):(dead_input);
@ -1903,20 +1877,17 @@ App_Step_Sig(app_step){
summary.mouse = mouse_state;
}
b32 file_scroll = false;
GUI_Scroll_Vars *scroll_vars = &view->transient.gui_scroll;
if (view->transient.showing_ui == VUI_None){
Assert(view->transient.file_data.file != 0);
scroll_vars = &view->transient.edit_pos->scroll;
file_scroll = true;
}
b32 file_scroll = true;
GUI_Scroll_Vars *scroll_vars = &view->transient.edit_pos->scroll;
i32 max_y = 0;
if (view->transient.showing_ui == VUI_None){
if (view->transient.ui_mode_counter == 0){
max_y = view_compute_max_target_y(view);
}
else{
#if 0
max_y = view->transient.gui_max_y;
#endif
}
Input_Process_Result ip_result = do_step_file_view(system, view, models, panel->inner, active, &summary, *scroll_vars, view->transient.scroll_region, max_y);
@ -1931,11 +1902,7 @@ App_Step_Sig(app_step){
consume_input(&vars->available_input, Input_MouseRightButton, "file view step");
}
if (ip_result.has_max_y_suggestion){
view->transient.gui_max_y = ip_result.max_y;
}
if (!gui_scroll_eq(scroll_vars, &ip_result.vars)){
if (memcmp(scroll_vars, &ip_result.vars, sizeof(*scroll_vars)) != 0){
if (file_scroll){
view_set_scroll(system, view, ip_result.vars);
}
@ -2198,14 +2165,13 @@ App_Step_Sig(app_step){
panel != &models->layout.used_sentinel;
panel = panel->next){
View *view = panel->view;
GUI_Scroll_Vars *scroll_vars = &view->transient.gui_scroll;
if (view->transient.edit_pos != 0){
scroll_vars = &view->transient.edit_pos->scroll;
}
GUI_Scroll_Vars *scroll_vars = &view->transient.edit_pos->scroll;
scroll_vars->scroll_x = (f32)scroll_vars->target_x;
scroll_vars->scroll_y = (f32)scroll_vars->target_y;
}
}
}
// NOTE(allen): if this is the last frame, run the exit hook
if (!models->keep_playing && models->hooks[hook_exit] != 0){
@ -2236,13 +2202,7 @@ App_Step_Sig(app_step){
u32 back_color = style->main.back_color;
draw_rectangle(target, full, back_color);
b32 file_scroll = false;
GUI_Scroll_Vars *scroll_vars = &view->transient.gui_scroll;
if (view->transient.showing_ui == VUI_None){
Assert(view->transient.file_data.file != 0);
scroll_vars = &view->transient.edit_pos->scroll;
file_scroll = true;
}
GUI_Scroll_Vars *scroll_vars = &view->transient.edit_pos->scroll;
do_render_file_view(system, view, models, scroll_vars, active_view, panel->inner, active, target, &dead_input);

View File

@ -67,7 +67,7 @@ internal void
fill_view_summary(System_Functions *system, View_Summary *view, View *vptr, Live_Views *live_set, Working_Set *working_set){
File_Viewing_Data *data = &vptr->transient.file_data;
*view = null_view_summary;
memset(view, 0, sizeof(*view));
if (vptr->transient.in_use){
view->exists = true;
@ -1523,11 +1523,11 @@ internal_get_view_next(Command_Data *cmd, View_Summary *view){
fill_view_summary(system, view, panel->view, live_set, &cmd->models->working_set);
}
else{
*view = null_view_summary;
memset(view, 0, sizeof(*view));
}
}
else{
*view = null_view_summary;
memset(view, 0, sizeof(*view));
}
}
@ -1598,7 +1598,7 @@ DOC_SEE(Access_Flag)
View *vptr = live_set->views + view_id;
fill_view_summary(system, &view, vptr, live_set, &cmd->models->working_set);
if (!access_test(view.lock_flags, access)){
view = null_view_summary;
memset(&view, 0, sizeof(view));
}
}
@ -1623,7 +1623,7 @@ DOC_SEE(Access_Flag)
View_Summary view = {0};
fill_view_summary(system, &view, panel->view, &models->live_set, &models->working_set);
if (!access_test(view.lock_flags, access)){
view = null_view_summary;
memset(&view, 0, sizeof(view));
}
return(view);
}
@ -2185,6 +2185,69 @@ View_Get_Variable(Application_Links *app, View_Summary *view, int32_t location,
return(result);
}
API_EXPORT int32_t
View_Start_UI_Mode(Application_Links *app, View_Summary *view){
Command_Data *cmd = (Command_Data*)app->cmd_context;
View *vptr = imp_get_view(cmd, view);
if (vptr != 0){
vptr->transient.ui_mode_counter = clamp_bottom(0, vptr->transient.ui_mode_counter);
vptr->transient.ui_mode_counter += 1;
return(vptr->transient.ui_mode_counter);
}
else{
return(0);
}
}
API_EXPORT int32_t
View_End_UI_Mode(Application_Links *app, View_Summary *view){
Command_Data *cmd = (Command_Data*)app->cmd_context;
View *vptr = imp_get_view(cmd, view);
if (vptr != 0){
vptr->transient.ui_mode_counter = clamp_bottom(0, vptr->transient.ui_mode_counter);
if (vptr->transient.ui_mode_counter > 0){
vptr->transient.ui_mode_counter -= 1;
return(vptr->transient.ui_mode_counter + 1);
}
else{
return(0);
}
}
else{
return(0);
}
}
API_EXPORT bool32
View_Set_UI(Application_Links *app, View_Summary *view, UI_Control *control){
Command_Data *cmd = (Command_Data*)app->cmd_context;
View *vptr = imp_get_view(cmd, view);
Models *models = cmd->models;
General_Memory *general = &models->mem.general;
if (vptr != 0){
if (vptr->transient.ui_control.items != 0){
general_memory_free(general, vptr->transient.ui_control.items);
}
vptr->transient.ui_control.count = 0;
if (control->count > 0){
i32 memory_size = sizeof(UI_Item)*control->count;
vptr->transient.ui_control.items = (UI_Item*)general_memory_allocate(general, memory_size);
if (vptr->transient.ui_control.items != 0){
vptr->transient.ui_control.count = control->count;
memcpy(vptr->transient.ui_control.items, control->items, memory_size);
}
else{
return(false);
}
}
else{
vptr->transient.ui_control.items = 0;
}
return(true);
}
return(false);
}
API_EXPORT User_Input
Get_User_Input(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type)
/*

File diff suppressed because it is too large Load Diff

141
4ed_gui.h
View File

@ -12,10 +12,6 @@
#ifndef FRED_GUI_H
#define FRED_GUI_H
struct GUI_id{
u64 id[2];
};
struct Query_Slot{
Query_Slot *next;
Query_Bar *query_bar;
@ -27,143 +23,6 @@ struct Query_Set{
Query_Slot *used_slot;
};
struct Super_Color{
Vec4 hsla;
Vec4 rgba;
u32 *out;
};
struct GUI_Target{
Partition push;
GUI_id active;
GUI_id mouse_hot;
GUI_id auto_hot;
GUI_id hover;
// TODO(allen): Can we remove original yet?
GUI_Scroll_Vars scroll_original;
i32_Rect region_original;
//GUI_Scroll_Vars scroll_updated;
i32_Rect region_updated;
// TODO(allen): Would rather have a way of tracking this
// for more than one list. Perhaps just throw in a hash table?
// Or maybe this only needs to be tracked for the active list.
i32 list_max;
b32 has_list_index_position;
i32_Rect list_index_position;
i32 list_view_min;
i32 list_view_max;
GUI_id scroll_id;
// TODO(allen): is currently ignored in the wheel code, reevaluate?
i32 delta;
b32 has_keys;
b32 animating;
b32 did_file;
};
struct GUI_Item_Update{
i32 partition_point;
b32 has_adjustment;
i32 adjustment_value;
b32 has_index_position;
i32_Rect index_position;
};
struct GUI_Header{
i32 type;
i32 size;
};
struct GUI_Interactive{
GUI_Header h;
GUI_id id;
};
struct GUI_Edit{
GUI_Header h;
GUI_id id;
void *out;
};
enum GUI_Command_Type{
guicom_null,
guicom_begin_serial,
guicom_end_serial,
guicom_top_bar,
guicom_file,
guicom_text_field,
guicom_color_button,
guicom_text_with_cursor,
guicom_begin_list,
guicom_end_list,
guicom_file_option,
guicom_fixed_option,
guicom_button,
guicom_fixed_option_checkbox,
guicom_style_preview,
guicom_scrollable,
guicom_scrollable_bar,
guicom_scrollable_top,
guicom_scrollable_slider,
guicom_scrollable_bottom,
guicom_scrollable_invisible,
guicom_begin_scrollable_section,
guicom_end_scrollable_section,
};
struct GUI_Section{
i32 max_v, v, top_v;
};
struct GUI_List_Vars{
b32 in_list;
i32 index;
i32 auto_hot;
i32 auto_activate;
};
struct GUI_Session{
i32_Rect full_rect;
i32_Rect rect;
i32 suggested_max_y;
i32 clip_y;
i32 line_height;
b32 is_scrollable;
i32 scrollable_items_bottom;
i32_Rect scroll_region;
i32_Rect scroll_rect;
f32 scroll_top, scroll_bottom;
GUI_List_Vars list;
GUI_Section sections[64];
i32 t;
};
struct GUI_Interpret_Result{
b32 has_info;
b32 auto_hot;
b32 auto_activate;
i32 screen_orientation;
b32 has_region;
i32_Rect region;
};
struct GUI_View_Jump{
i32 view_min;
i32 view_max;
};
#endif
// BOTTOM

View File

@ -20,24 +20,21 @@ style_set_colors(Style *style, Theme *theme){
internal u32
style_get_margin_color(i32 active_level, Style *style){
u32 margin = 0xFFFFFFFF;
switch (active_level){
default:
case UIActivation_None:
{
margin = style->main.list_item_color;
}break;
case 1: case 2:
case UIActivation_Hover:
{
margin = style->main.list_item_hover_color;
}break;
case 3: case 4:
case UIActivation_Active:
{
margin = style->main.list_item_active_color;
}break;
}
return(margin);
}

View File

@ -30,12 +30,6 @@ live_set_alloc_view(General_Memory *general, Live_Views *live_set, Panel *panel)
init_query_set(&result.view->transient.query_set);
i32 gui_mem_size = KB(512);
void *gui_mem = general_memory_allocate(general, gui_mem_size + 8);
result.view->transient.gui_mem = gui_mem;
gui_mem = advance_to_alignment(gui_mem);
result.view->transient.gui_target.push = make_part(gui_mem, gui_mem_size);
dynamic_variables_block_init(general, &result.view->transient.dynamic_vars);
return(result);
@ -46,8 +40,10 @@ live_set_free_view(General_Memory *general, Live_Views *live_set, View *view){
Assert(live_set->count > 0);
--live_set->count;
general_memory_free(general, view->transient.gui_mem);
view->transient.gui_mem = 0;
if (view->transient.ui_control.items != 0){
general_memory_free(general, view->transient.ui_control.items);
}
//dll_insert(&live_set->free_sentinel, view);
view->transient.next = live_set->free_sentinel.transient.next;
view->transient.prev = &live_set->free_sentinel;
@ -98,7 +94,7 @@ view_get_cursor_xy(View *view){
internal f32
view_get_scroll_y(View *view){
f32 v = 0;
if (view->transient.showing_ui == VUI_None){
if (view->transient.ui_mode_counter == 0){
File_Edit_Positions *edit_pos = view->transient.edit_pos;
TentativeAssert(edit_pos != 0);
if (edit_pos != 0){
@ -106,7 +102,9 @@ view_get_scroll_y(View *view){
}
}
else{
#if 0
v = view->transient.gui_scroll.scroll_y;
#endif
}
return(v);
}
@ -158,11 +156,10 @@ inline u32
view_lock_flags(View *view){
u32 result = AccessOpen;
File_Viewing_Data *data = &view->transient.file_data;
if (view->transient.showing_ui != VUI_None){
if (view->transient.ui_mode_counter > 0){
result |= AccessHidden;
}
if (data->file_locked ||
(data->file && data->file->settings.read_only)){
if (data->file_locked || (data->file && data->file->settings.read_only)){
result |= AccessProtected;
}
return(result);
@ -348,25 +345,6 @@ view_show_file(View *view){
Editing_File *file = view->transient.file_data.file;
Assert(file != 0);
view->transient.map = file->settings.base_map_id;
if (view->transient.showing_ui != VUI_None){
view->transient.showing_ui = VUI_None;
view->transient.changed_context_in_step = 1;
}
}
inline void
view_show_interactive(System_Functions *system, View *view, Models *models, Interactive_Action action, Interactive_Interaction interaction, String query){
view->transient.showing_ui = VUI_Interactive;
view->transient.action = action;
view->transient.interaction = interaction;
view->transient.dest = make_fixed_width_string(view->transient.dest_);
view->transient.list_i = 0;
view->transient.map = mapid_ui;
hot_directory_clean_end(&models->hot_directory);
hot_directory_reload(system, &models->hot_directory);
view->transient.changed_context_in_step = true;
}
internal void
@ -397,7 +375,7 @@ view_set_file(System_Functions *system, Models *models, View *view, Editing_File
view_cursor_move(system, view, 0);
}
if (view->transient.showing_ui == VUI_None){
if (view->transient.ui_mode_counter == 0){
view_show_file(view);
}
}

View File

@ -30,55 +30,6 @@ struct File_Viewing_Data{
};
global File_Viewing_Data null_file_viewing_data = {0};
enum Interactive_Action{
IAct_Open,
IAct_New,
IAct_OpenOrNew,
IAct_Switch,
IAct_Kill,
IAct_Sure_To_Kill,
IAct_Sure_To_Close
};
typedef i32 Unsaved_Changes_User_Response;
enum{
UnsavedChangesUserResponse_Error = -1,
UnsavedChangesUserResponse_ContinueAnyway = 0,
UnsavedChangesUserResponse_Cancel = 1,
UnsavedChangesUserResponse_SaveAndContinue = 2,
};
typedef i32 Interactive_Interaction;
enum{
IInt_Sys_File_List = 0,
IInt_Live_File_List = 1,
IInt_Sure_To_Kill = 2,
IInt_Sure_To_Close = 3
};
typedef i32 View_UI;
enum{
VUI_None = 0,
VUI_Theme = 1,
VUI_Interactive = 2,
};
typedef i32 Color_View_Mode;
enum{
CV_Mode_Library = 0,
CV_Mode_Font = 1,
CV_Mode_Global_Font = 2,
CV_Mode_Font_Editing = 3,
CV_Mode_Global_Font_Editing = 4,
CV_Mode_Adjusting = 5,
};
struct Scroll_Context{
Editing_File *file;
GUI_id scroll;
View_UI mode;
};
struct View_Transient{
struct View *next;
struct View *prev;
@ -95,37 +46,14 @@ struct View_Transient{
i32_Rect scroll_region;
File_Edit_Positions *edit_pos;
View_UI showing_ui;
GUI_Target gui_target;
void *gui_mem;
GUI_Scroll_Vars gui_scroll;
i32 gui_max_y;
i32 list_i;
i32 ui_mode_counter;
UI_Control ui_control;
b32 hide_scrollbar;
b32 hide_file_bar;
// interactive stuff
Interactive_Interaction interaction;
Interactive_Action action;
char dest_[256];
String dest;
b32 changed_context_in_step;
// theme stuff
u32 *palette;
Color_View_Mode color_mode;
Face_ID font_edit_id;
Super_Color color;
b32 p4c_only;
Style_Library inspecting_styles;
b8 import_export_check[64];
i32 import_file_id;
i32 current_color_editing;
i32 color_cursor;
// misc
// TODO(allen): Can we burn line_height to the ground now?

File diff suppressed because it is too large Load Diff

View File

@ -682,7 +682,7 @@ generate_remapping_code_and_data(){
bind(mappings, 'o', MDFR_CTRL, interactive_open_or_new);
bind(mappings, 'o', MDFR_ALT, open_in_other);
bind(mappings, 'k', MDFR_CTRL, interactive_kill_buffer);
bind(mappings, 'i', MDFR_CTRL, interactive_switch_buffer);
bind(mappings, 'i', MDFR_CTRL, interactive_switch_buffer_DUMMY_API_EXPLORATION);
bind(mappings, 'h', MDFR_CTRL, project_go_to_root_directory);
bind(mappings, 'S', MDFR_CTRL, save_all_dirty_buffers);