fixed text image button + fixed internal font baker alignment
This commit is contained in:
parent
d050b444ef
commit
083152c6b9
|
@ -567,6 +567,7 @@ widget_panel(struct zr_context *panel, struct state *demo)
|
||||||
zr_label(panel, "text right", ZR_TEXT_RIGHT);
|
zr_label(panel, "text right", ZR_TEXT_RIGHT);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
/* Tooltip */
|
||||||
struct zr_rect bounds;
|
struct zr_rect bounds;
|
||||||
const struct zr_input *in = zr_input(panel);
|
const struct zr_input *in = zr_input(panel);
|
||||||
zr_layout_peek(&bounds, panel);
|
zr_layout_peek(&bounds, panel);
|
||||||
|
@ -614,10 +615,10 @@ widget_panel(struct zr_context *panel, struct state *demo)
|
||||||
zr_tiled_begin_local(&tiled, fmt, 250, 150);
|
zr_tiled_begin_local(&tiled, fmt, 250, 150);
|
||||||
if (!demo->scaleable) {
|
if (!demo->scaleable) {
|
||||||
zr_tiled_slot(&tiled, ZR_SLOT_LEFT, 100, ZR_SLOT_VERTICAL, 4);
|
zr_tiled_slot(&tiled, ZR_SLOT_LEFT, 100, ZR_SLOT_VERTICAL, 4);
|
||||||
zr_tiled_slot(&tiled, ZR_SLOT_RIGHT, 150, ZR_SLOT_VERTICAL, 4);
|
zr_tiled_slot(&tiled, ZR_SLOT_RIGHT, 150, ZR_SLOT_VERTICAL, 4);
|
||||||
} else {
|
} else {
|
||||||
zr_tiled_slot(&tiled, ZR_SLOT_LEFT, 0.50, ZR_SLOT_VERTICAL, 4);
|
zr_tiled_slot(&tiled, ZR_SLOT_LEFT, 0.50, ZR_SLOT_VERTICAL, 4);
|
||||||
zr_tiled_slot(&tiled, ZR_SLOT_RIGHT, 0.50, ZR_SLOT_VERTICAL, 4);
|
zr_tiled_slot(&tiled, ZR_SLOT_RIGHT, 0.50, ZR_SLOT_VERTICAL, 4);
|
||||||
}
|
}
|
||||||
zr_tiled_end(&tiled);
|
zr_tiled_end(&tiled);
|
||||||
|
|
||||||
|
@ -885,7 +886,7 @@ run_demo(struct demo_gui *gui)
|
||||||
/* popup panel */
|
/* popup panel */
|
||||||
if (state->popup)
|
if (state->popup)
|
||||||
{
|
{
|
||||||
zr_popup_begin(&layout, &tab, ZR_POPUP_STATIC, 0, zr_rect(20, 100, 220, 150), zr_vec2(0,0));
|
zr_popup_begin(&layout, &tab, ZR_POPUP_STATIC, 0, zr_rect(20, 100, 220, 180), zr_vec2(0,0));
|
||||||
{
|
{
|
||||||
if (zr_header(&tab, "Popup", ZR_CLOSEABLE, ZR_CLOSEABLE, ZR_HEADER_LEFT)) {
|
if (zr_header(&tab, "Popup", ZR_CLOSEABLE, ZR_CLOSEABLE, ZR_HEADER_LEFT)) {
|
||||||
zr_popup_close(&tab);
|
zr_popup_close(&tab);
|
||||||
|
|
48
zahnrad.c
48
zahnrad.c
|
@ -3062,7 +3062,7 @@ zr_font_bake(void *image_memory, zr_size width, zr_size height,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* second font pass: render glyphes */
|
/* second font pass: render glyphes */
|
||||||
baker = (struct zr_font_baker*)temp;
|
baker = (struct zr_font_baker*)ZR_ALIGN_PTR(temp, zr_baker_align);
|
||||||
zr_zero(image_memory, width * height);
|
zr_zero(image_memory, width * height);
|
||||||
baker->spc.pixels = (unsigned char*)image_memory;
|
baker->spc.pixels = (unsigned char*)image_memory;
|
||||||
baker->spc.height = (zr_int)height;
|
baker->spc.height = (zr_int)height;
|
||||||
|
@ -3926,9 +3926,9 @@ zr_widget_button_text_symbol(struct zr_command_buffer *out, struct zr_rect r,
|
||||||
|
|
||||||
zr_bool
|
zr_bool
|
||||||
zr_widget_button_text_image(struct zr_command_buffer *out, struct zr_rect r,
|
zr_widget_button_text_image(struct zr_command_buffer *out, struct zr_rect r,
|
||||||
struct zr_image img, const char* text, enum zr_text_align align,
|
struct zr_image img, const char* text, enum zr_button_behavior behavior,
|
||||||
enum zr_button_behavior behavior, const struct zr_button_text *button,
|
const struct zr_button_text *button, const struct zr_user_font *f,
|
||||||
const struct zr_user_font *f, const struct zr_input *i)
|
const struct zr_input *i)
|
||||||
{
|
{
|
||||||
zr_bool pressed;
|
zr_bool pressed;
|
||||||
struct zr_rect icon;
|
struct zr_rect icon;
|
||||||
|
@ -3940,7 +3940,7 @@ zr_widget_button_text_image(struct zr_command_buffer *out, struct zr_rect r,
|
||||||
pressed = zr_widget_button_text(out, r, text, behavior, button, i, f);
|
pressed = zr_widget_button_text(out, r, text, behavior, button, i, f);
|
||||||
icon.y = r.y + button->base.padding.y;
|
icon.y = r.y + button->base.padding.y;
|
||||||
icon.w = icon.h = r.h - 2 * button->base.padding.y;
|
icon.w = icon.h = r.h - 2 * button->base.padding.y;
|
||||||
if (align == ZR_TEXT_LEFT) {
|
if (button->alignment == ZR_TEXT_LEFT) {
|
||||||
icon.x = (r.x + r.w) - (2 * button->base.padding.x + icon.w);
|
icon.x = (r.x + r.w) - (2 * button->base.padding.x + icon.w);
|
||||||
icon.x = MAX(icon.x, 0);
|
icon.x = MAX(icon.x, 0);
|
||||||
} else icon.x = r.x + 2 * button->base.padding.x;
|
} else icon.x = r.x + 2 * button->base.padding.x;
|
||||||
|
@ -4730,7 +4730,7 @@ zr_widget_spinner(struct zr_command_buffer *out, struct zr_rect r,
|
||||||
/*
|
/*
|
||||||
* ==============================================================
|
* ==============================================================
|
||||||
*
|
*
|
||||||
* Config
|
* Style
|
||||||
*
|
*
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
|
@ -4948,7 +4948,7 @@ zr_tiled_begin_local(struct zr_tiled_layout *layout, enum zr_layout_format fmt,
|
||||||
|
|
||||||
void
|
void
|
||||||
zr_tiled_begin(struct zr_tiled_layout *layout, enum zr_layout_format fmt,
|
zr_tiled_begin(struct zr_tiled_layout *layout, enum zr_layout_format fmt,
|
||||||
struct zr_rect bounds, struct zr_vec2 spacing)
|
struct zr_rect bounds, struct zr_vec2 spacing, zr_float scaler_width)
|
||||||
{
|
{
|
||||||
ZR_ASSERT(layout);
|
ZR_ASSERT(layout);
|
||||||
if (!layout) return;
|
if (!layout) return;
|
||||||
|
@ -4956,6 +4956,21 @@ zr_tiled_begin(struct zr_tiled_layout *layout, enum zr_layout_format fmt,
|
||||||
layout->fmt = fmt;
|
layout->fmt = fmt;
|
||||||
layout->bounds = bounds;
|
layout->bounds = bounds;
|
||||||
layout->spacing = spacing;
|
layout->spacing = spacing;
|
||||||
|
layout->scaler_width = scaler_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
zr_tiled_begin_inside(struct zr_tiled_layout *parent, struct zr_tiled_layout *child,
|
||||||
|
enum zr_layout_format fmt, enum zr_tiled_layout_slot_index slot, zr_uint index)
|
||||||
|
{
|
||||||
|
struct zr_rect bounds;
|
||||||
|
ZR_ASSERT(parent);
|
||||||
|
ZR_ASSERT(child);
|
||||||
|
zr_tiled_bounds(&bounds, parent, slot, index);
|
||||||
|
child->fmt = fmt;
|
||||||
|
child->bounds = bounds;
|
||||||
|
child->spacing = parent->spacing;
|
||||||
|
child->scaler_width = parent->scaler_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -5024,19 +5039,6 @@ zr_tiled_bounds(struct zr_rect *bounds, const struct zr_tiled_layout *layout,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
zr_tiled_load(struct zr_tiled_layout *parent, struct zr_tiled_layout *child,
|
|
||||||
enum zr_layout_format fmt, enum zr_tiled_layout_slot_index slot, zr_uint index)
|
|
||||||
{
|
|
||||||
struct zr_rect bounds;
|
|
||||||
ZR_ASSERT(parent);
|
|
||||||
ZR_ASSERT(child);
|
|
||||||
zr_tiled_bounds(&bounds, parent, slot, index);
|
|
||||||
child->fmt = fmt;
|
|
||||||
child->bounds = bounds;
|
|
||||||
child->spacing = parent->spacing;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
zr_tiled_end(struct zr_tiled_layout *layout)
|
zr_tiled_end(struct zr_tiled_layout *layout)
|
||||||
{
|
{
|
||||||
|
@ -6851,10 +6853,11 @@ zr_button_text_image(struct zr_context *layout, struct zr_image img,
|
||||||
i = (state == ZR_WIDGET_ROM || layout->flags & ZR_WINDOW_ROM) ? 0 : layout->input;
|
i = (state == ZR_WIDGET_ROM || layout->flags & ZR_WINDOW_ROM) ? 0 : layout->input;
|
||||||
|
|
||||||
config = layout->style;
|
config = layout->style;
|
||||||
|
button.alignment = align;
|
||||||
button.normal = config->colors[ZR_COLOR_TEXT];
|
button.normal = config->colors[ZR_COLOR_TEXT];
|
||||||
button.hover = config->colors[ZR_COLOR_TEXT_HOVERING];
|
button.hover = config->colors[ZR_COLOR_TEXT_HOVERING];
|
||||||
button.active = config->colors[ZR_COLOR_TEXT_ACTIVE];
|
button.active = config->colors[ZR_COLOR_TEXT_ACTIVE];
|
||||||
return zr_widget_button_text_image(layout->buffer, bounds, img, text, align,
|
return zr_widget_button_text_image(layout->buffer, bounds, img, text,
|
||||||
behavior, &button, &config->font, i);
|
behavior, &button, &config->font, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8040,7 +8043,8 @@ zr_contextual_button_icon(struct zr_context *layout, struct zr_image img,
|
||||||
button.normal = config->colors[ZR_COLOR_TEXT];
|
button.normal = config->colors[ZR_COLOR_TEXT];
|
||||||
button.hover = config->colors[ZR_COLOR_TEXT_HOVERING];
|
button.hover = config->colors[ZR_COLOR_TEXT_HOVERING];
|
||||||
button.active = config->colors[ZR_COLOR_TEXT_ACTIVE];
|
button.active = config->colors[ZR_COLOR_TEXT_ACTIVE];
|
||||||
return zr_widget_button_text_image(layout->buffer, bounds, img, text, align,
|
button.alignment = align;
|
||||||
|
return zr_widget_button_text_image(layout->buffer, bounds, img, text,
|
||||||
behavior, &button, &config->font, i);
|
behavior, &button, &config->font, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
30
zahnrad.h
30
zahnrad.h
|
@ -2105,8 +2105,7 @@ zr_bool zr_widget_button_text_symbol(struct zr_command_buffer*, struct zr_rect,
|
||||||
- returns zr_true if the button was pressed zr_false otherwise
|
- returns zr_true if the button was pressed zr_false otherwise
|
||||||
*/
|
*/
|
||||||
zr_bool zr_widget_button_text_image(struct zr_command_buffer*, struct zr_rect,
|
zr_bool zr_widget_button_text_image(struct zr_command_buffer*, struct zr_rect,
|
||||||
struct zr_image, const char*, enum zr_text_align,
|
struct zr_image, const char*, enum zr_button_behavior,
|
||||||
enum zr_button_behavior,
|
|
||||||
const struct zr_button_text*,
|
const struct zr_button_text*,
|
||||||
const struct zr_user_font*, const struct zr_input*);
|
const struct zr_user_font*, const struct zr_input*);
|
||||||
/* this function executes a button widget with text and an icon
|
/* this function executes a button widget with text and an icon
|
||||||
|
@ -2589,6 +2588,8 @@ struct zr_tiled_slot {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct zr_tiled_layout {
|
struct zr_tiled_layout {
|
||||||
|
zr_float scaler_width;
|
||||||
|
/* widht of the scaling line between slots */
|
||||||
struct zr_tiled_slot slots[ZR_SLOT_MAX];
|
struct zr_tiled_slot slots[ZR_SLOT_MAX];
|
||||||
/* tiled layout slots */
|
/* tiled layout slots */
|
||||||
enum zr_layout_format fmt;
|
enum zr_layout_format fmt;
|
||||||
|
@ -2599,7 +2600,8 @@ struct zr_tiled_layout {
|
||||||
};
|
};
|
||||||
|
|
||||||
void zr_tiled_begin(struct zr_tiled_layout*, enum zr_layout_format,
|
void zr_tiled_begin(struct zr_tiled_layout*, enum zr_layout_format,
|
||||||
struct zr_rect bounds, struct zr_vec2 spacing);
|
struct zr_rect bounds, struct zr_vec2 spacing,
|
||||||
|
zr_float scaler_width);
|
||||||
/* this functions begins the definitions of a tiled layout
|
/* this functions begins the definitions of a tiled layout
|
||||||
Input:
|
Input:
|
||||||
- layout format with either dynamic ratio based or fixed pixel based slots
|
- layout format with either dynamic ratio based or fixed pixel based slots
|
||||||
|
@ -2616,6 +2618,17 @@ void zr_tiled_begin_local(struct zr_tiled_layout*, enum zr_layout_format,
|
||||||
- pixel width of the tiled layout space (IMPORTANT: not used for dynamic tiled layouts)
|
- pixel width of the tiled layout space (IMPORTANT: not used for dynamic tiled layouts)
|
||||||
- pixel height of the tiled layout space
|
- pixel height of the tiled layout space
|
||||||
*/
|
*/
|
||||||
|
void zr_tiled_begin_inside(struct zr_tiled_layout *parent, struct zr_tiled_layout *child,
|
||||||
|
enum zr_layout_format fmt, enum zr_tiled_layout_slot_index slot,
|
||||||
|
zr_uint index);
|
||||||
|
/* this functions load a tiled layout from another tiled layout slot
|
||||||
|
Input:
|
||||||
|
- slot filling format with either horizontal or vertical filling
|
||||||
|
- slot identifier
|
||||||
|
- index of the widget inside the slot
|
||||||
|
Output:
|
||||||
|
- loaded child tiled layout inside the parent tiled layout
|
||||||
|
*/
|
||||||
void zr_tiled_slot(struct zr_tiled_layout *layout,
|
void zr_tiled_slot(struct zr_tiled_layout *layout,
|
||||||
enum zr_tiled_layout_slot_index, zr_float ratio,
|
enum zr_tiled_layout_slot_index, zr_float ratio,
|
||||||
enum zr_tiled_slot_format, zr_uint widget_count);
|
enum zr_tiled_slot_format, zr_uint widget_count);
|
||||||
|
@ -2646,17 +2659,6 @@ void zr_tiled_bounds(struct zr_rect*, const struct zr_tiled_layout*,
|
||||||
Output:
|
Output:
|
||||||
- rectangle with position and size of the slot entry
|
- rectangle with position and size of the slot entry
|
||||||
*/
|
*/
|
||||||
void zr_tiled_load(struct zr_tiled_layout *parent, struct zr_tiled_layout *child,
|
|
||||||
enum zr_layout_format fmt, enum zr_tiled_layout_slot_index slot,
|
|
||||||
zr_uint index);
|
|
||||||
/* this functions load a tiled layout from another tiled layout slot
|
|
||||||
Input:
|
|
||||||
- slot filling format with either horizontal or vertical filling
|
|
||||||
- slot identifier
|
|
||||||
- index of the widget inside the slot
|
|
||||||
Output:
|
|
||||||
- loaded child tiled layout inside the parent tiled layout
|
|
||||||
*/
|
|
||||||
/*
|
/*
|
||||||
* ==============================================================
|
* ==============================================================
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue