new query bars up and running
This commit is contained in:
parent
022f7176bf
commit
2bbf370abb
|
@ -3539,6 +3539,17 @@ file_step(View *view, i32_Rect region, Input_Summary *user_input, b32 is_active)
|
|||
return(result);
|
||||
}
|
||||
|
||||
internal void
|
||||
view_do_queries(View *view, GUI_Target *target){
|
||||
Query_Slot *slot;
|
||||
Query_Bar *bar;
|
||||
|
||||
for (slot = view->query_set.used_slot; slot != 0; slot = slot->next){
|
||||
bar = slot->query_bar;
|
||||
gui_do_text_field(target, bar->prompt, bar->string);
|
||||
}
|
||||
}
|
||||
|
||||
internal i32
|
||||
step_file_view(View *view, b32 is_active){
|
||||
gui_begin_top_level(&view->gui_target);
|
||||
|
@ -3549,7 +3560,7 @@ step_file_view(View *view, b32 is_active){
|
|||
{
|
||||
gui_begin_serial_section(&view->gui_target);
|
||||
{
|
||||
// do widget
|
||||
view_do_queries(view, &view->gui_target);
|
||||
}
|
||||
gui_end_serial_section(&view->gui_target);
|
||||
|
||||
|
@ -3598,6 +3609,8 @@ do_input_file_view(System_Functions *system, Exchange *exchange,
|
|||
result = 1;
|
||||
}
|
||||
}break;
|
||||
|
||||
case guicom_text_field: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3876,6 +3889,27 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
|
|||
return(0);
|
||||
}
|
||||
|
||||
internal void
|
||||
do_render_text_field(Render_Target *target, View *view, i32_Rect rect, String p, String t){
|
||||
Models *models = view->models;
|
||||
Style *style = &models->style;
|
||||
|
||||
u32 back_color = style->main.margin_color;
|
||||
u32 text1_color = style->main.default_color;
|
||||
u32 text2_color = style->main.file_info_style.pop1_color;
|
||||
|
||||
i32 x = rect.x0;
|
||||
i32 y = rect.y0;
|
||||
|
||||
i16 font_id = models->global_font.font_id;
|
||||
|
||||
if (target){
|
||||
draw_rectangle(target, rect, back_color);
|
||||
x = draw_string(target, font_id, p, x, y + 1, text2_color);
|
||||
draw_string(target, font_id, t, x, y + 1, text1_color);
|
||||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
do_render_file_bar(Render_Target *target, View *view, Editing_File *file, i32_Rect rect){
|
||||
File_Bar bar;
|
||||
|
@ -3898,15 +3932,13 @@ do_render_file_bar(Render_Target *target, View *view, Editing_File *file, i32_Re
|
|||
bar.text_shift_x = 0;
|
||||
|
||||
draw_rectangle(target, bar.rect, back_color);
|
||||
if (file){
|
||||
intbar_draw_string(target, &bar, file->name.live_name, base_color);
|
||||
}
|
||||
else{
|
||||
if (!file){
|
||||
intbar_draw_string(target, &bar, make_lit_string("*NULL*"), base_color);
|
||||
}
|
||||
else{
|
||||
intbar_draw_string(target, &bar, file->name.live_name, base_color);
|
||||
intbar_draw_string(target, &bar, make_lit_string(" -"), base_color);
|
||||
|
||||
if (file){
|
||||
if (file->state.is_loading){
|
||||
intbar_draw_string(target, &bar, make_lit_string(" loading"), base_color);
|
||||
}
|
||||
|
@ -3987,6 +4019,14 @@ do_render_file_view(System_Functions *system, Exchange *exchange,
|
|||
}
|
||||
target->pop_clip(target);
|
||||
}break;
|
||||
|
||||
case guicom_text_field:
|
||||
{
|
||||
void *ptr = (h+1);
|
||||
String p = gui_read_string(&ptr);
|
||||
String t = gui_read_string(&ptr);
|
||||
do_render_text_field(target, view, gui_session.rect, p, t);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
73
4ed_gui.cpp
73
4ed_gui.cpp
|
@ -80,8 +80,6 @@ struct GUI_Header{
|
|||
i32 size;
|
||||
};
|
||||
|
||||
#define NextHeader(h) ((GUI_Header*)((char*)(h) + (h)->size))
|
||||
|
||||
enum GUI_Command_Type{
|
||||
guicom_null,
|
||||
guicom_begin_overlap,
|
||||
|
@ -90,32 +88,51 @@ enum GUI_Command_Type{
|
|||
guicom_end_serial,
|
||||
guicom_top_bar,
|
||||
guicom_file,
|
||||
guicom_text_field
|
||||
};
|
||||
|
||||
internal b32
|
||||
internal void*
|
||||
gui_push_command(GUI_Target *target, void *item, i32 size){
|
||||
b32 result = 0;
|
||||
void *dest = partition_allocate(&target->push, size);
|
||||
if (dest){
|
||||
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){
|
||||
b32 result;
|
||||
GUI_Header *result = 0;
|
||||
GUI_Header item;
|
||||
item.type = type;
|
||||
item.size = sizeof(item);
|
||||
result = gui_push_command(target, &item, item.size);
|
||||
result = (GUI_Header*)gui_push_command(target, &item, item.size);
|
||||
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
|
||||
gui_begin_top_level(GUI_Target *target){
|
||||
target->show_file = 0;
|
||||
target->push.pos = 0;
|
||||
}
|
||||
|
||||
internal void
|
||||
|
@ -154,6 +171,13 @@ gui_do_file(GUI_Target *target){
|
|||
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{
|
||||
b32 overlapped;
|
||||
|
@ -263,6 +287,16 @@ gui_interpret(GUI_Session *session, GUI_Header *h){
|
|||
end_v = rect.y1;
|
||||
end_section = section;
|
||||
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){
|
||||
|
@ -293,6 +327,27 @@ gui_interpret(GUI_Session *session, GUI_Header *h){
|
|||
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
|
||||
|
|
|
@ -342,8 +342,8 @@ get_ui_style_upper(Style *style){
|
|||
|
||||
inline void
|
||||
get_colors(UI_State *state, u32 *back, u32 *fore, Widget_ID wid, UI_Style style){
|
||||
bool32 hover = is_hover(state, wid);
|
||||
bool32 hot = is_hot(state, wid);
|
||||
b32 hover = is_hover(state, wid);
|
||||
b32 hot = is_hot(state, wid);
|
||||
i32 level = hot + hover;
|
||||
switch (level){
|
||||
case 2:
|
||||
|
@ -363,8 +363,8 @@ get_colors(UI_State *state, u32 *back, u32 *fore, Widget_ID wid, UI_Style style)
|
|||
|
||||
inline void
|
||||
get_pop_color(UI_State *state, u32 *pop, Widget_ID wid, UI_Style style){
|
||||
bool32 hover = is_hover(state, wid);
|
||||
bool32 hot = is_hot(state, wid);
|
||||
b32 hover = is_hover(state, wid);
|
||||
b32 hot = is_hot(state, wid);
|
||||
i32 level = hot + hover;
|
||||
switch (level){
|
||||
case 2:
|
||||
|
@ -381,8 +381,8 @@ get_pop_color(UI_State *state, u32 *pop, Widget_ID wid, UI_Style style){
|
|||
|
||||
internal UI_State
|
||||
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,
|
||||
b32 input_stage){
|
||||
Style *style, i16 font_id, Font_Set *font_set, Working_Set *working_set, b32 input_stage){
|
||||
|
||||
UI_State state = {};
|
||||
state.target = target;
|
||||
state.style = style;
|
||||
|
|
Loading…
Reference in New Issue