fixed tiled wigdet layout width calculation

This commit is contained in:
vurtun 2015-09-09 23:12:03 +02:00
parent 33637284d8
commit 821aeaebaf
2 changed files with 24 additions and 26 deletions

19
gui.c
View File

@ -5386,7 +5386,7 @@ gui_layout_row_tiled_begin(struct gui_context *layout,
space.h = layout->row.height;
/* setup clipping rect for the free space to prevent overdraw */
gui_unify(&clip, &layout->clip, space.x, space.y, space.x + space.w, space.y + space.h);
gui_unify(&clip, &layout->clip, space.x,space.y,space.x+space.w,space.y+space.h);
gui_command_buffer_push_scissor(layout->buffer, clip);
layout->row.clip = layout->clip;
layout->clip = clip;
@ -5406,8 +5406,10 @@ gui_layout_row_tiled_push(struct gui_context *layout,
struct gui_rect slot_bounds;
const struct gui_tiled_slot *s;
struct gui_vec2 spacing;
struct gui_vec2 padding;
const struct gui_style *config;
struct gui_tiled_layout *tiled;
gui_float temp;
GUI_ASSERT(layout);
GUI_ASSERT(layout->style);
@ -5423,12 +5425,16 @@ gui_layout_row_tiled_push(struct gui_context *layout,
s = &tiled->slots[slot];
GUI_ASSERT(index < s->capacity);
if (tiled->fmt == GUI_DYNAMIC)
tiled->width = layout->width;
gui_tiled_slot_bounds(&slot_bounds, tiled, slot);
config = layout->style;
spacing = config->properties[GUI_PROPERTY_ITEM_SPACING];
padding = config->properties[GUI_PROPERTY_PADDING];
temp = tiled->width;
if (tiled->fmt == GUI_DYNAMIC)
tiled->width = layout->width - (2 * padding.x);
gui_tiled_slot_bounds(&slot_bounds, tiled, slot);
tiled->width = temp;
if (s->format == GUI_SLOT_HORIZONTAL) {
slot_bounds.h -= (2 * spacing.y);
slot_bounds.w -= (gui_float)s->capacity * spacing.x;
@ -5440,7 +5446,8 @@ gui_layout_row_tiled_push(struct gui_context *layout,
} else {
layout->row.item.x = slot_bounds.x + spacing.x;
layout->row.item.w = slot_bounds.w - (2 * spacing.x);
layout->row.item.h = (slot_bounds.h - (gui_float)s->capacity * spacing.y)/(gui_float)s->capacity;
layout->row.item.h = (slot_bounds.h - (gui_float)s->capacity * spacing.y);
layout->row.item.h /= (gui_float)s->capacity;
layout->row.item.y = slot_bounds.y + (gui_float)index * layout->row.item.h;
layout->row.item.y += ((gui_float)index * spacing.y);
}

31
gui.h
View File

@ -2483,8 +2483,7 @@ gui_bool gui_window_has_flag(struct gui_window*, gui_flags);
/* this function checks if a window has given flag(s) */
gui_bool gui_window_is_minimized(struct gui_window*);
/* this function checks if the window is minimized */
/*
* --------------------------------------------------------------
/* --------------------------------------------------------------
* Context
* --------------------------------------------------------------
CONTEXT
@ -2643,8 +2642,7 @@ const struct gui_input *gui_input(struct gui_context*);
/* this functions returns the currently used input */
struct gui_command_queue *gui_queue(struct gui_context*);
/* this functions returns the currently used queue */
/*
* --------------------------------------------------------------
/* --------------------------------------------------------------
* HEADER
* --------------------------------------------------------------
HEADER
@ -2760,8 +2758,7 @@ void gui_menubar_begin(struct gui_context*);
void gui_menubar_end(struct gui_context*);
/* this function ends the window menubar build up process */
/*
* --------------------------------------------------------------
/* --------------------------------------------------------------
* Layout
* --------------------------------------------------------------
LAYOUT
@ -2937,8 +2934,7 @@ gui_bool gui_layout_push(struct gui_context*, enum gui_layout_node_type,
*/
void gui_layout_pop(struct gui_context*);
/* this functions ends the previously added node */
/*
* --------------------------------------------------------------
/* --------------------------------------------------------------
* WIDGETS
* --------------------------------------------------------------
WIDGET
@ -3213,8 +3209,7 @@ gui_int gui_spinner(struct gui_context*, gui_int min, gui_int value,
- the from user input updated spinner value
- current state of the editbox with active(gui_true) or inactive(gui_false)
*/
/*
* -------------------------------------------------------------
/* --------------------------------------------------------------
* Group
* --------------------------------------------------------------
*
@ -3252,8 +3247,7 @@ struct gui_vec2 gui_group_end(struct gui_context*, struct gui_context*);
Output:
- The from user input updated group scrollbar pixel offset
*/
/*
* -------------------------------------------------------------
/* --------------------------------------------------------------
* SHELF
* --------------------------------------------------------------
SHELF
@ -3290,8 +3284,7 @@ struct gui_vec2 gui_shelf_end(struct gui_context*, struct gui_context*);
Output:
- The from user input updated shelf scrollbar pixel offset
*/
/*
* -------------------------------------------------------------
/* --------------------------------------------------------------
* POPUP
* --------------------------------------------------------------
POPUP
@ -3368,8 +3361,7 @@ gui_state gui_popup_nonblock_close(struct gui_context *popup);
*/
void gui_popup_nonblock_end(struct gui_context *parent, struct gui_context *popup);
/* this functions closes a previously opened context menu */
/*
* -------------------------------------------------------------
/* --------------------------------------------------------------
* GRAPH
* --------------------------------------------------------------
GRAPH
@ -3457,8 +3449,7 @@ gui_int gui_graph_callback(struct gui_context*, enum gui_graph_type,
- callback to access the values inside your datastrucutre
- userdata to pull the graph values from
*/
/*
* --------------------------------------------------------------
/* --------------------------------------------------------------
* COMBO BOX
* --------------------------------------------------------------
COMBO BOX
@ -3510,8 +3501,7 @@ void gui_combo_close(struct gui_context *combo);
/* this function closes a opened combobox */
void gui_combo_end(struct gui_context *parent, struct gui_context *combo);
/* this function ends the combobox build up process */
/*
* --------------------------------------------------------------
/*----------------------------------------------------------------
* MENU
* --------------------------------------------------------------
MENU
@ -3553,6 +3543,7 @@ void gui_menu_begin(struct gui_context *parent,
- title of the menu to
- the current state of the menu with either gui_true (open) or gui_false else
*/
void gui_menu_close(struct gui_context *menu);
/* this function closes a opened menu */
struct gui_vec2 gui_menu_end(struct gui_context *parent,