2018-08-04 02:41:38 +00:00
|
|
|
/*
|
|
|
|
* Helpers for ui data structures.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TOP
|
|
|
|
|
|
|
|
#if !defined(FCODER_UI_HELPER_H)
|
|
|
|
#define FCODER_UI_HELPER_H
|
|
|
|
|
2019-02-26 19:59:57 +00:00
|
|
|
typedef i8 UI_Item_Type;
|
|
|
|
enum UI_Activation_Level{
|
|
|
|
UIActivation_None = 0,
|
|
|
|
UIActivation_Hover = 1,
|
|
|
|
UIActivation_Active = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef u8 UI_Coordinate_System;
|
|
|
|
enum{
|
|
|
|
UICoordinates_ViewSpace = 0,
|
|
|
|
UICoordinates_PanelSpace = 1,
|
|
|
|
UICoordinates_COUNT = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UI_Item{
|
|
|
|
UI_Item *next;
|
|
|
|
UI_Item *prev;
|
|
|
|
UI_Activation_Level activation_level;
|
|
|
|
UI_Coordinate_System coordinates;
|
|
|
|
Rect_i32 rect_outer;
|
|
|
|
i32 inner_margin;
|
|
|
|
Fancy_String_List lines[4];
|
|
|
|
i32 line_count;
|
|
|
|
void *user_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UI_List{
|
|
|
|
UI_Item *first;
|
|
|
|
UI_Item *last;
|
|
|
|
int32_t count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UI_Data{
|
|
|
|
UI_List list;
|
|
|
|
Rect_i32 bounding_box[UICoordinates_COUNT];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UI_Storage{
|
|
|
|
UI_Data *data;
|
|
|
|
Arena *arena;
|
|
|
|
Managed_Object arena_object;
|
|
|
|
Temp_Memory_Arena temp;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
2018-08-04 02:41:38 +00:00
|
|
|
typedef int32_t Lister_Activation_Code;
|
|
|
|
enum{
|
|
|
|
ListerActivation_Finished = 0,
|
|
|
|
ListerActivation_Continue = 1,
|
|
|
|
ListerActivation_ContinueAndRefresh = 2,
|
|
|
|
};
|
|
|
|
|
2018-09-17 18:47:06 +00:00
|
|
|
typedef void Lister_Activation_Function_Type(Application_Links *app, Partition *scratch, Heap *heap,
|
|
|
|
View_Summary *view, struct Lister_State *state,
|
2019-02-26 23:08:42 +00:00
|
|
|
String text_field, void *user_data, b32 activated_by_mouse);
|
2018-08-04 02:41:38 +00:00
|
|
|
|
2018-12-17 02:07:49 +00:00
|
|
|
typedef void Lister_Regenerate_List_Function_Type(Application_Links *app, struct Lister *lister);
|
2018-08-04 02:41:38 +00:00
|
|
|
|
2018-09-15 23:48:02 +00:00
|
|
|
struct Lister_Node{
|
|
|
|
Lister_Node *next;
|
|
|
|
Lister_Node *prev;
|
2018-08-04 02:41:38 +00:00
|
|
|
String string;
|
2018-08-10 21:52:57 +00:00
|
|
|
union{
|
|
|
|
String status;
|
|
|
|
int32_t index;
|
|
|
|
};
|
2018-08-04 02:41:38 +00:00
|
|
|
void *user_data;
|
2018-09-15 23:48:02 +00:00
|
|
|
int32_t raw_index;
|
2018-08-04 02:41:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Lister_Option_List{
|
2018-09-15 23:48:02 +00:00
|
|
|
Lister_Node *first;
|
|
|
|
Lister_Node *last;
|
2018-08-04 02:41:38 +00:00
|
|
|
int32_t count;
|
|
|
|
};
|
|
|
|
|
2018-09-15 23:48:02 +00:00
|
|
|
struct Lister_Node_Ptr_Array{
|
|
|
|
Lister_Node **node_ptrs;
|
2018-09-14 19:02:02 +00:00
|
|
|
int32_t count;
|
|
|
|
};
|
|
|
|
|
2018-08-05 07:09:18 +00:00
|
|
|
struct Lister_Handlers{
|
2018-08-04 02:41:38 +00:00
|
|
|
Lister_Activation_Function_Type *activate;
|
|
|
|
Lister_Regenerate_List_Function_Type *refresh;
|
|
|
|
Custom_Command_Function *write_character;
|
|
|
|
Custom_Command_Function *backspace;
|
|
|
|
Custom_Command_Function *navigate_up;
|
|
|
|
Custom_Command_Function *navigate_down;
|
2018-08-05 07:09:18 +00:00
|
|
|
};
|
|
|
|
|
2018-12-17 02:07:49 +00:00
|
|
|
struct Lister_Data{
|
2018-08-05 07:09:18 +00:00
|
|
|
// Event Handlers
|
|
|
|
Lister_Handlers handlers;
|
2018-08-04 02:41:38 +00:00
|
|
|
|
|
|
|
// List Data
|
2018-08-05 07:09:18 +00:00
|
|
|
void *user_data;
|
2018-12-17 02:07:49 +00:00
|
|
|
int32_t user_data_size;
|
2018-08-04 02:41:38 +00:00
|
|
|
char query_space[256];
|
|
|
|
String query;
|
|
|
|
char text_field_space[256];
|
|
|
|
String text_field;
|
|
|
|
char key_string_space[256];
|
|
|
|
String key_string;
|
|
|
|
Lister_Option_List options;
|
2019-02-26 23:08:42 +00:00
|
|
|
b32 theme_list;
|
2018-08-04 02:41:38 +00:00
|
|
|
};
|
|
|
|
|
2018-12-17 02:07:49 +00:00
|
|
|
struct Lister{
|
2019-02-05 00:10:38 +00:00
|
|
|
Arena arena;
|
2018-12-17 02:07:49 +00:00
|
|
|
Lister_Data data;
|
2018-08-04 02:41:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Lister_State{
|
2019-02-26 23:08:42 +00:00
|
|
|
b32 initialized;
|
2018-12-17 02:07:49 +00:00
|
|
|
Lister lister;
|
|
|
|
|
|
|
|
// Action defered to next UI update
|
2019-02-26 23:08:42 +00:00
|
|
|
b32 set_view_vertical_focus_to_item;
|
2018-12-17 02:07:49 +00:00
|
|
|
|
|
|
|
// State set directly by input handlers
|
2018-08-04 02:41:38 +00:00
|
|
|
void *hot_user_data;
|
|
|
|
int32_t item_index;
|
2018-12-17 02:07:49 +00:00
|
|
|
|
|
|
|
// State of UI computed during UI update
|
2018-08-04 02:41:38 +00:00
|
|
|
int32_t raw_item_index;
|
2018-12-17 02:07:49 +00:00
|
|
|
int32_t item_count_after_filter;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Lister_Prealloced_String{
|
|
|
|
String string;
|
2018-08-04 02:41:38 +00:00
|
|
|
};
|
|
|
|
|
2018-08-05 07:09:18 +00:00
|
|
|
////////////////////////////////
|
|
|
|
|
2018-09-15 23:48:02 +00:00
|
|
|
struct Lister_Option{
|
2018-12-10 01:31:30 +00:00
|
|
|
String string;
|
|
|
|
String status;
|
2018-09-15 23:48:02 +00:00
|
|
|
void *user_data;
|
|
|
|
};
|
|
|
|
|
2018-08-05 07:09:18 +00:00
|
|
|
struct Lister_Fixed_Option{
|
|
|
|
char *string;
|
|
|
|
char *status;
|
|
|
|
char *shortcut_chars;
|
|
|
|
void *user_data;
|
|
|
|
};
|
|
|
|
|
2018-08-10 21:52:57 +00:00
|
|
|
struct Lister_UI_Option{
|
|
|
|
char *string;
|
|
|
|
int32_t index;
|
|
|
|
void *user_data;
|
|
|
|
};
|
|
|
|
|
2018-08-04 02:41:38 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// BOTTOM
|
|
|
|
|