added text box
This commit is contained in:
parent
6f78f0bcff
commit
b4555c26dc
14
gui.c
14
gui.c
|
@ -2237,9 +2237,9 @@ gui_panel_list(struct gui_panel *panel, gui_bool *selection,
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
gui_int
|
void
|
||||||
gui_panel_text_box(struct gui_panel *panel, char *content, gui_size *len,
|
gui_panel_text_box(struct gui_panel *panel, const gui_char *content, gui_size *len,
|
||||||
gui_float *offset, gui_int active)
|
gui_float *offset)
|
||||||
{
|
{
|
||||||
gui_size i;
|
gui_size i;
|
||||||
struct gui_panel box;
|
struct gui_panel box;
|
||||||
|
@ -2247,8 +2247,8 @@ gui_panel_text_box(struct gui_panel *panel, char *content, gui_size *len,
|
||||||
struct gui_text text;
|
struct gui_text text;
|
||||||
struct gui_rect bounds;
|
struct gui_rect bounds;
|
||||||
const struct gui_config *temp;
|
const struct gui_config *temp;
|
||||||
if (!panel || !content || !len || !offset) return 0;
|
if (!panel || !content || !len || !offset) return;
|
||||||
if (panel->minimized) return 0;
|
if (panel->minimized) return;
|
||||||
|
|
||||||
temp = panel->config;
|
temp = panel->config;
|
||||||
memcopy(&config, panel->config, sizeof(struct gui_config));
|
memcopy(&config, panel->config, sizeof(struct gui_config));
|
||||||
|
@ -2267,7 +2267,7 @@ gui_panel_text_box(struct gui_panel *panel, char *content, gui_size *len,
|
||||||
text.h = bounds.h;
|
text.h = bounds.h;
|
||||||
text.pad_x = box.config->item_padding.x;
|
text.pad_x = box.config->item_padding.x;
|
||||||
text.pad_y = box.config->item_padding.y;
|
text.pad_y = box.config->item_padding.y;
|
||||||
text.text = content;
|
text.text = (const char*)content;
|
||||||
text.length = *len;
|
text.length = *len;
|
||||||
text.font = temp->colors[GUI_COLOR_TEXT];
|
text.font = temp->colors[GUI_COLOR_TEXT];
|
||||||
text.background = temp->colors[GUI_COLOR_PANEL];
|
text.background = temp->colors[GUI_COLOR_PANEL];
|
||||||
|
@ -2276,7 +2276,7 @@ gui_panel_text_box(struct gui_panel *panel, char *content, gui_size *len,
|
||||||
gui_panel_frame_end(&box);
|
gui_panel_frame_end(&box);
|
||||||
panel->config = temp;
|
panel->config = temp;
|
||||||
*offset = box.offset;
|
*offset = box.offset;
|
||||||
return active;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
6
gui.h
6
gui.h
|
@ -434,8 +434,8 @@ gui_int gui_panel_plot(struct gui_panel *panel, const gui_float *values,
|
||||||
gui_size value_count);
|
gui_size value_count);
|
||||||
gui_int gui_panel_histo(struct gui_panel *panel, const gui_float *values,
|
gui_int gui_panel_histo(struct gui_panel *panel, const gui_float *values,
|
||||||
gui_size value_count);
|
gui_size value_count);
|
||||||
gui_int gui_panel_text_box(struct gui_panel *panel, char *text, gui_size *len,
|
void gui_panel_text_box(struct gui_panel *panel, const gui_char *text, gui_size *len,
|
||||||
gui_float *offset, gui_int active);
|
gui_float *offset);
|
||||||
gui_float gui_panel_list(struct gui_panel *panel, gui_bool *selected, const char *items[],
|
gui_float gui_panel_list(struct gui_panel *panel, gui_bool *selected, const char *items[],
|
||||||
gui_size item_count, gui_float offset, gui_float item_height);
|
gui_size item_count, gui_float offset, gui_float item_height);
|
||||||
void gui_panel_frame_begin(struct gui_panel *panel, struct gui_panel *tab, const char *title);
|
void gui_panel_frame_begin(struct gui_panel *panel, struct gui_panel *tab, const char *title);
|
||||||
|
@ -443,6 +443,4 @@ void gui_panel_frame_end(struct gui_panel *tab);
|
||||||
void gui_panel_hook(struct gui_panel *panel, struct gui_panel *tab);
|
void gui_panel_hook(struct gui_panel *panel, struct gui_panel *tab);
|
||||||
gui_uint gui_panel_end(struct gui_panel *panel);
|
gui_uint gui_panel_end(struct gui_panel *panel);
|
||||||
|
|
||||||
/* Window */
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
5
opengl.c
5
opengl.c
|
@ -68,8 +68,12 @@ struct GUI {
|
||||||
/* State */
|
/* State */
|
||||||
gui_char input_text[INPUT_MAX];
|
gui_char input_text[INPUT_MAX];
|
||||||
gui_char cmd_input[INPUT_MAX];
|
gui_char cmd_input[INPUT_MAX];
|
||||||
|
gui_char box_input[INPUT_MAX];
|
||||||
gui_size input_len;
|
gui_size input_len;
|
||||||
gui_size cmd_len;
|
gui_size cmd_len;
|
||||||
|
gui_size box_len;
|
||||||
|
gui_float box_off;
|
||||||
|
gui_bool box_act;
|
||||||
gui_bool typing;
|
gui_bool typing;
|
||||||
gui_float slider;
|
gui_float slider;
|
||||||
gui_size prog;
|
gui_size prog;
|
||||||
|
@ -550,6 +554,7 @@ main(int argc, char *argv[])
|
||||||
gui.seloff = gui_panel_list(&gui.panel, gui.selection, sel, LEN(sel), gui.seloff, 30);
|
gui.seloff = gui_panel_list(&gui.panel, gui.selection, sel, LEN(sel), gui.seloff, 30);
|
||||||
gui_panel_histo(&gui.panel, values, LEN(values));
|
gui_panel_histo(&gui.panel, values, LEN(values));
|
||||||
gui_panel_plot(&gui.panel, values, LEN(values));
|
gui_panel_plot(&gui.panel, values, LEN(values));
|
||||||
|
gui_panel_text_box(&gui.panel, gui.box_input, &gui.box_len, &gui.box_off);
|
||||||
gui_panel_end(&gui.panel);
|
gui_panel_end(&gui.panel);
|
||||||
gui_end(&gui.out, &gui.draw_list, &gui.status);
|
gui_end(&gui.out, &gui.draw_list, &gui.status);
|
||||||
/* ---------------------------------------------------------*/
|
/* ---------------------------------------------------------*/
|
||||||
|
|
Loading…
Reference in New Issue