new query bars up and running
parent
022f7176bf
commit
2bbf370abb
8812
4ed_file_view.cpp
8812
4ed_file_view.cpp
File diff suppressed because it is too large
Load Diff
73
4ed_gui.cpp
73
4ed_gui.cpp
|
@ -80,8 +80,6 @@ struct GUI_Header{
|
||||||
i32 size;
|
i32 size;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NextHeader(h) ((GUI_Header*)((char*)(h) + (h)->size))
|
|
||||||
|
|
||||||
enum GUI_Command_Type{
|
enum GUI_Command_Type{
|
||||||
guicom_null,
|
guicom_null,
|
||||||
guicom_begin_overlap,
|
guicom_begin_overlap,
|
||||||
|
@ -90,32 +88,51 @@ enum GUI_Command_Type{
|
||||||
guicom_end_serial,
|
guicom_end_serial,
|
||||||
guicom_top_bar,
|
guicom_top_bar,
|
||||||
guicom_file,
|
guicom_file,
|
||||||
|
guicom_text_field
|
||||||
};
|
};
|
||||||
|
|
||||||
internal b32
|
internal void*
|
||||||
gui_push_command(GUI_Target *target, void *item, i32 size){
|
gui_push_command(GUI_Target *target, void *item, i32 size){
|
||||||
b32 result = 0;
|
|
||||||
void *dest = partition_allocate(&target->push, size);
|
void *dest = partition_allocate(&target->push, size);
|
||||||
if (dest){
|
if (dest){
|
||||||
memcpy(dest, item, size);
|
memcpy(dest, item, size);
|
||||||
result = 1;
|
|
||||||
}
|
}
|
||||||
return(result);
|
return(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal b32
|
internal void*
|
||||||
|
gui_align(GUI_Target *target){
|
||||||
|
void *ptr;
|
||||||
|
partition_align(&target->push, 8);
|
||||||
|
ptr = partition_current(&target->push);
|
||||||
|
return(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal GUI_Header*
|
||||||
gui_push_simple_command(GUI_Target *target, i32 type){
|
gui_push_simple_command(GUI_Target *target, i32 type){
|
||||||
b32 result;
|
GUI_Header *result = 0;
|
||||||
GUI_Header item;
|
GUI_Header item;
|
||||||
item.type = type;
|
item.type = type;
|
||||||
item.size = sizeof(item);
|
item.size = sizeof(item);
|
||||||
result = gui_push_command(target, &item, item.size);
|
result = (GUI_Header*)gui_push_command(target, &item, item.size);
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
gui_push_string(GUI_Target *target, GUI_Header *h, String s){
|
||||||
|
u8 *start, *end;
|
||||||
|
i32 size;
|
||||||
|
start = (u8*)gui_push_command(target, &s.size, sizeof(s.size));
|
||||||
|
gui_push_command(target, s.str, s.size);
|
||||||
|
end = (u8*)gui_align(target);
|
||||||
|
size = (i32)(end - start);
|
||||||
|
h->size += size;
|
||||||
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
gui_begin_top_level(GUI_Target *target){
|
gui_begin_top_level(GUI_Target *target){
|
||||||
target->show_file = 0;
|
target->show_file = 0;
|
||||||
|
target->push.pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
|
@ -154,6 +171,13 @@ gui_do_file(GUI_Target *target){
|
||||||
target->show_file = 1;
|
target->show_file = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
gui_do_text_field(GUI_Target *target, String p, String t){
|
||||||
|
GUI_Header *h = gui_push_simple_command(target, guicom_text_field);
|
||||||
|
gui_push_string(target, h, p);
|
||||||
|
gui_push_string(target, h, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct GUI_Section{
|
struct GUI_Section{
|
||||||
b32 overlapped;
|
b32 overlapped;
|
||||||
|
@ -263,6 +287,16 @@ gui_interpret(GUI_Session *session, GUI_Header *h){
|
||||||
end_v = rect.y1;
|
end_v = rect.y1;
|
||||||
end_section = section;
|
end_section = section;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case guicom_text_field:
|
||||||
|
give_to_user = 1;
|
||||||
|
rect.y0 = y;
|
||||||
|
rect.y1 = rect.y0 + session->line_height + 2;
|
||||||
|
rect.x0 = session->full_rect.x0;
|
||||||
|
rect.x1 = session->full_rect.x1;
|
||||||
|
end_v = rect.y1;
|
||||||
|
end_section = section;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (give_to_user){
|
if (give_to_user){
|
||||||
|
@ -293,6 +327,27 @@ gui_interpret(GUI_Session *session, GUI_Header *h){
|
||||||
return(give_to_user);
|
return(give_to_user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define NextHeader(h) ((GUI_Header*)((char*)(h) + (h)->size))
|
||||||
|
|
||||||
|
internal String
|
||||||
|
gui_read_string(void **ptr){
|
||||||
|
String result;
|
||||||
|
char *start, *end;
|
||||||
|
i32 size;
|
||||||
|
|
||||||
|
start = (char*)*ptr;
|
||||||
|
result.size = *(i32*)*ptr;
|
||||||
|
*ptr = ((i32*)*ptr) + 1;
|
||||||
|
result.str = (char*)*ptr;
|
||||||
|
end = result.str + result.size;
|
||||||
|
|
||||||
|
size = (i32)(end - start);
|
||||||
|
size = (size + 7) & (~7);
|
||||||
|
|
||||||
|
*ptr = ((char*)start) + size;
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
|
@ -342,8 +342,8 @@ get_ui_style_upper(Style *style){
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
get_colors(UI_State *state, u32 *back, u32 *fore, Widget_ID wid, UI_Style style){
|
get_colors(UI_State *state, u32 *back, u32 *fore, Widget_ID wid, UI_Style style){
|
||||||
bool32 hover = is_hover(state, wid);
|
b32 hover = is_hover(state, wid);
|
||||||
bool32 hot = is_hot(state, wid);
|
b32 hot = is_hot(state, wid);
|
||||||
i32 level = hot + hover;
|
i32 level = hot + hover;
|
||||||
switch (level){
|
switch (level){
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -363,8 +363,8 @@ get_colors(UI_State *state, u32 *back, u32 *fore, Widget_ID wid, UI_Style style)
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
get_pop_color(UI_State *state, u32 *pop, Widget_ID wid, UI_Style style){
|
get_pop_color(UI_State *state, u32 *pop, Widget_ID wid, UI_Style style){
|
||||||
bool32 hover = is_hover(state, wid);
|
b32 hover = is_hover(state, wid);
|
||||||
bool32 hot = is_hot(state, wid);
|
b32 hot = is_hot(state, wid);
|
||||||
i32 level = hot + hover;
|
i32 level = hot + hover;
|
||||||
switch (level){
|
switch (level){
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -381,8 +381,8 @@ get_pop_color(UI_State *state, u32 *pop, Widget_ID wid, UI_Style style){
|
||||||
|
|
||||||
internal UI_State
|
internal UI_State
|
||||||
ui_state_init(UI_State *state_in, Render_Target *target, Input_Summary *user_input,
|
ui_state_init(UI_State *state_in, Render_Target *target, Input_Summary *user_input,
|
||||||
Style *style, i16 font_id, Font_Set *font_set, Working_Set *working_set,
|
Style *style, i16 font_id, Font_Set *font_set, Working_Set *working_set, b32 input_stage){
|
||||||
b32 input_stage){
|
|
||||||
UI_State state = {};
|
UI_State state = {};
|
||||||
state.target = target;
|
state.target = target;
|
||||||
state.style = style;
|
state.style = style;
|
||||||
|
|
Loading…
Reference in New Issue