added panel image widget
This commit is contained in:
parent
4694584a91
commit
9023390c68
38
gui.c
38
gui.c
|
@ -3143,6 +3143,26 @@ gui_panel_label(struct gui_panel_layout *layout, const char *text,
|
|||
gui_panel_text(layout, text, len, align);
|
||||
}
|
||||
|
||||
void
|
||||
gui_panel_image(struct gui_panel_layout *layout, struct gui_image img)
|
||||
{
|
||||
const struct gui_config *config;
|
||||
struct gui_vec2 item_padding;
|
||||
struct gui_rect bounds;
|
||||
GUI_ASSERT(layout);
|
||||
if (!gui_panel_widget(&bounds, layout))
|
||||
return;
|
||||
|
||||
config = layout->config;
|
||||
item_padding = gui_config_property(config, GUI_PROPERTY_ITEM_PADDING);
|
||||
bounds.x += item_padding.x;
|
||||
bounds.y += item_padding.y;
|
||||
bounds.w -= 2 * item_padding.x;
|
||||
bounds.h -= 2 * item_padding.y;
|
||||
gui_command_buffer_push_image(layout->buffer, bounds.x, bounds.y,
|
||||
bounds.w, bounds.h, &img);
|
||||
}
|
||||
|
||||
static gui_bool
|
||||
gui_panel_button(struct gui_button *button, struct gui_rect *bounds,
|
||||
struct gui_panel_layout *layout)
|
||||
|
@ -3813,8 +3833,15 @@ static void
|
|||
gui_panel_table_vline(struct gui_panel_layout *layout, gui_size cols)
|
||||
{
|
||||
gui_size i;
|
||||
struct gui_command_buffer *out = layout->buffer;
|
||||
const struct gui_config *config = layout->config;
|
||||
struct gui_command_buffer *out;
|
||||
const struct gui_config *config;
|
||||
|
||||
GUI_ASSERT(layout);
|
||||
GUI_ASSERT(cols);
|
||||
if (!layout || !cols) return;
|
||||
|
||||
out = layout->buffer;
|
||||
config = layout->config;
|
||||
for (i = 0; i < cols - 1; ++i) {
|
||||
gui_float y, h;
|
||||
struct gui_rect bounds;
|
||||
|
@ -4237,6 +4264,7 @@ gui_panel_tree_node(struct gui_tree *tree, enum gui_tree_node_symbol symbol,
|
|||
*state &= ~(gui_flags)GUI_NODE_ACTIVE;
|
||||
else *state |= GUI_NODE_ACTIVE;
|
||||
}
|
||||
|
||||
heading = (*state & GUI_NODE_ACTIVE) ? GUI_DOWN : GUI_RIGHT;
|
||||
gui_triangle_from_direction(points, sym.x, sym.y, sym.w, sym.h, 0, 0, heading);
|
||||
gui_command_buffer_push_triangle(layout->buffer, points[0].x, points[0].y,
|
||||
|
@ -4355,13 +4383,15 @@ gui_panel_end(struct gui_panel_layout *layout, struct gui_panel *panel)
|
|||
|
||||
config = layout->config;
|
||||
out = layout->buffer;
|
||||
if (!(panel->flags & GUI_PANEL_TAB))
|
||||
gui_command_buffer_push_scissor(out, layout->x,layout->y,layout->w+1,layout->h+1);
|
||||
|
||||
/* cache configuration data */
|
||||
item_padding = gui_config_property(config, GUI_PROPERTY_ITEM_PADDING);
|
||||
item_spacing = gui_config_property(config, GUI_PROPERTY_ITEM_SPACING);
|
||||
panel_padding = gui_config_property(config, GUI_PROPERTY_PADDING);
|
||||
scrollbar_width = gui_config_property(config, GUI_PROPERTY_SCROLLBAR_WIDTH).x;
|
||||
scaler_size = gui_config_property(config, GUI_PROPERTY_SCALER_SIZE);
|
||||
if (!(panel->flags & GUI_PANEL_TAB))
|
||||
gui_command_buffer_push_scissor(out, layout->x,layout->y,layout->w+1,layout->h+1);
|
||||
|
||||
if (panel->flags & GUI_PANEL_SCROLLBAR && layout->valid) {
|
||||
struct gui_scroll scroll;
|
||||
|
|
10
gui.h
10
gui.h
|
@ -1030,8 +1030,8 @@ struct gui_selector {
|
|||
};
|
||||
|
||||
void gui_text(struct gui_command_buffer*, gui_float, gui_float, gui_float, gui_float,
|
||||
const char *text, gui_size len, const struct gui_text*,
|
||||
enum gui_text_align, const struct gui_font*);
|
||||
const char *text, gui_size len, const struct gui_text*,
|
||||
enum gui_text_align, const struct gui_font*);
|
||||
/* this function executes a text widget with text alignment
|
||||
Input:
|
||||
- output command buffer for drawing
|
||||
|
@ -1964,6 +1964,11 @@ void gui_panel_label_colored(struct gui_panel_layout*, const char*,
|
|||
- text alignment with either left, centered or right alignment
|
||||
- color the label should be drawn
|
||||
*/
|
||||
void gui_panel_image(struct gui_panel_layout*, struct gui_image);
|
||||
/* this function creates an image widget
|
||||
Input:
|
||||
- string pointer to text that should be drawn
|
||||
*/
|
||||
gui_bool gui_panel_check(struct gui_panel_layout*, const char*, gui_bool active);
|
||||
/* this function creates a checkbox widget with either active or inactive state
|
||||
Input:
|
||||
|
@ -2272,7 +2277,6 @@ enum gui_tree_node_operation gui_panel_tree_begin_node_icon(struct gui_tree*,
|
|||
Output:
|
||||
- operation identifier what should be done with this node
|
||||
*/
|
||||
|
||||
void gui_panel_tree_end_node(struct gui_tree*);
|
||||
/* this function ends a parent node */
|
||||
enum gui_tree_node_operation gui_panel_tree_leaf(struct gui_tree*, const char*,
|
||||
|
|
Loading…
Reference in New Issue