fixed menubar + made panel without header possible

This commit is contained in:
vurtun 2015-05-18 16:14:28 +02:00
parent 0e571b6799
commit bef36dad16
2 changed files with 20 additions and 15 deletions

View File

@ -353,7 +353,6 @@ color_tab(struct gui_panel_layout *panel, struct control_window *control, struct
} else {
gui_panel_row(panel, 30, 2);
for (i = 0; i < GUI_COLOR_COUNT; ++i) {
struct gui_panel_layout layout;
gui_panel_label(panel, labels[i], GUI_TEXT_LEFT);
if (gui_panel_button_color(panel, config->colors[i], GUI_BUTTON_DEFAULT)) {
if (!control->picker_active) {
@ -524,7 +523,7 @@ texture_tab(struct gui_panel_layout *panel, struct settings_window *win)
gui_panel_seperator(panel, 2);
win->update_on_stroke = gui_panel_check(panel, "Update on stroke", win->update_on_stroke);
gui_panel_seperator(panel, 2);
win->save_on_stroke = gui_panel_check(panel, "Save texture on stroke", win->save_on_stroke);
win->save_on_stroke = gui_panel_check(panel, "Save on stroke", win->save_on_stroke);
gui_panel_seperator(panel, 2);
win->extend_seam_color = gui_panel_check(panel, "Extend seam color", win->extend_seam_color);
}
@ -577,7 +576,7 @@ update_menu(struct menubar_window *win, struct gui_layout *layout,
const struct level *iter = levels[win->current];
struct gui_panel_layout panel;
gui_panel_hook_begin_tiled(&panel, &win->hook, layout, GUI_SLOT_TOP, 0, NULL, canvas, in);
gui_panel_row(&panel, 25, 10);
gui_panel_row(&panel, 25, 16);
while (iter->name) {
if (gui_panel_button_text(&panel, iter->name, GUI_BUTTON_DEFAULT)) {
fprintf(stdout, "button: %s pressed!\n", iter->name);
@ -592,7 +591,6 @@ update_menu(struct menubar_window *win, struct gui_layout *layout,
static void
init_demo(struct demo_gui *gui, struct gui_font *font)
{
struct gui_layout_config ratio;
struct gui_command_buffer *buffer = &gui->buffer;
struct gui_memory *memory = &gui->memory;
struct gui_config *config = &gui->config;
@ -603,14 +601,6 @@ init_demo(struct demo_gui *gui, struct gui_font *font)
gui_buffer_init_fixed(buffer, memory, GUI_BUFFER_CLIPPING);
gui_default_config(config);
ratio.left = 0.05f;
ratio.right = 0.35f;
ratio.centerv = 0.9f;
ratio.centerh = 0.6f;
ratio.bottom = 0.05f;
ratio.top = 0.05f;
gui_layout_init(&gui->layout, &ratio);
gui_panel_hook_init(&gui->settings.hook, 0, 0, 0, 0, GUI_PANEL_BORDER, config, font);
gui_panel_hook_init(&gui->menu.hook, 0, 0, 0, 0, GUI_PANEL_BORDER|GUI_PANEL_NO_HEADER,
config, font);
@ -624,11 +614,20 @@ static void
background_demo(struct demo_gui *gui, struct gui_input *input, struct gui_command_buffer *buffer,
gui_bool active)
{
struct gui_layout_config ratio;
struct gui_command_buffer sub;
struct gui_canvas canvas;
struct menubar_window *menu = &gui->menu;
struct settings_window *settings = &gui->settings;
ratio.right = 450.0f / gui->width;
ratio.top = 52.0f / gui->height;
ratio.left = 0.0f;
ratio.bottom = 0;
ratio.centerv = 1.0f - ratio.top;
ratio.centerh = 1.0f - ratio.right;
gui_layout_init(&gui->layout, &ratio);
gui_layout_begin(&gui->layout, gui->width, gui->height, active);
gui_layout_slot(&gui->layout, GUI_SLOT_RIGHT, GUI_LAYOUT_VERTICAL, 1);
gui_layout_slot(&gui->layout, GUI_SLOT_TOP, GUI_LAYOUT_VERTICAL, 1);

12
gui.c
View File

@ -1445,7 +1445,9 @@ gui_panel_begin(struct gui_panel_layout *layout, struct gui_panel *panel,
/* add footer at the end of the panel */
footer_h = config->scaler_size.y + config->item_padding.y;
if ((panel->flags & GUI_PANEL_SCROLLBAR) && !panel->minimized) {
if ((panel->flags & GUI_PANEL_SCALEABLE) &&
(panel->flags & GUI_PANEL_SCROLLBAR) &&
!panel->minimized) {
gui_float footer_x, footer_y, footer_w;
footer_x = panel->x;
footer_w = panel->w;
@ -1469,7 +1471,9 @@ gui_panel_begin(struct gui_panel_layout *layout, struct gui_panel *panel,
layout->clip.w = panel->w;
layout->clip.y = panel->y + layout->header_height - 1;
if (panel->flags & GUI_PANEL_SCROLLBAR) {
layout->clip.h = panel->h - (footer_h + layout->header_height);
if (panel->flags & GUI_PANEL_SCALEABLE)
layout->clip.h = panel->h - (footer_h + layout->header_height);
else layout->clip.h = panel->h - layout->header_height;
layout->clip.h -= (config->panel_padding.y + config->item_padding.y);
}
else layout->clip.h = null_rect.h;
@ -1540,7 +1544,7 @@ gui_panel_begin(struct gui_panel_layout *layout, struct gui_panel *panel,
const struct gui_color *color = &config->colors[GUI_COLOR_PANEL];
layout->width = panel->w - config->scrollbar_width;
layout->height = panel->h - (layout->header_height + 2 * config->item_spacing.y);
layout->height -= footer_h;
if (panel->flags & GUI_PANEL_SCALEABLE) layout->height -= footer_h;
if (layout->valid)
canvas->draw_rect(canvas->userdata, panel->x, panel->y + layout->header_height,
panel->w, panel->h - layout->header_height, *color);
@ -2021,6 +2025,7 @@ gui_panel_edit_base(struct gui_rect *bounds, struct gui_edit *field,
field->show_cursor = gui_true;
field->background = config->colors[GUI_COLOR_INPUT];
field->foreground = config->colors[GUI_COLOR_INPUT_BORDER];
field->cursor = config->colors[GUI_COLOR_INPUT_CURSOR];
return gui_true;
}
@ -2088,6 +2093,7 @@ gui_panel_shell(struct gui_panel_layout *layout, gui_char *buffer, gui_size *len
field.padding.x = config->item_padding.x;
field.padding.y = config->item_padding.y;
field.show_cursor = gui_true;
field.cursor = config->colors[GUI_COLOR_INPUT_CURSOR];
field.background = config->colors[GUI_COLOR_INPUT];
field.foreground = config->colors[GUI_COLOR_INPUT_BORDER];
*len = gui_edit(layout->canvas, field_x, field_y, field_w, field_h, buffer,