Added Title alignment flags to menu header fix #53

Previously all menu titles were centered in X- and Y-axis without any
way to control the alignment. Since it was requested I added an
alignment flag to `zr_menu_text_begin`. To achieve the same outcome
like before this commit the flag has to be `ZR_TEXT_DEFAULT_CENTER`.
This commit is contained in:
vurtun 2016-03-02 09:45:06 +01:00
parent 1125016d0a
commit 8159391640
3 changed files with 12 additions and 5 deletions

View File

@ -434,7 +434,7 @@ demo_window(struct zr_context *ctx)
zr_menubar_begin(ctx);
zr_layout_row_begin(ctx, ZR_STATIC, 25, 2);
zr_layout_row_push(ctx, 45);
if (zr_menu_text_begin(ctx, &menu, "MENU", 120))
if (zr_menu_text_begin(ctx, &menu, "MENU", ZR_TEXT_DEFAULT_LEFT, 120))
{
static size_t prog = 40;
static int slider = 10;

View File

@ -12123,7 +12123,7 @@ zr_menu_begin(struct zr_panel *layout, struct zr_context *ctx, struct zr_window
int
zr_menu_text_begin(struct zr_context *ctx, struct zr_panel *layout,
const char *title, float width)
const char *title, zr_flags align, float width)
{
struct zr_window *win;
const struct zr_input *in;
@ -12150,7 +12150,7 @@ zr_menu_text_begin(struct zr_context *ctx, struct zr_panel *layout,
button.base.border = ctx->style.colors[ZR_COLOR_WINDOW];
button.base.normal = ctx->style.colors[ZR_COLOR_WINDOW];
button.base.active = ctx->style.colors[ZR_COLOR_WINDOW];
button.alignment = ZR_TEXT_CENTERED|ZR_TEXT_MIDDLE;
button.alignment = align;
button.normal = ctx->style.colors[ZR_COLOR_TEXT];
button.active = ctx->style.colors[ZR_COLOR_TEXT];
button.hover = ctx->style.colors[ZR_COLOR_TEXT];

View File

@ -1377,8 +1377,14 @@ enum zr_text_align {
/* text is aligned to the top (Y-axis)*/
ZR_TEXT_MIDDLE = 0x10,
/* text is aligned to the middle (Y-axis) */
ZR_TEXT_BOTTOM = 0x20
ZR_TEXT_BOTTOM = 0x20,
/* text is aligned to the bottom (Y-axis)*/
ZR_TEXT_DEFAULT_CENTER = ZR_TEXT_CENTERED|ZR_TEXT_MIDDLE,
/* default center alignment with text centered both in X-and Y-axis */
ZR_TEXT_DEFAULT_LEFT = ZR_TEXT_LEFT|ZR_TEXT_MIDDLE,
/* default left alignment with text centered left in X-and and center Y-axis */
ZR_TEXT_DEFAULT_RIGHT = ZR_TEXT_RIGHT|ZR_TEXT_MIDDLE
/* default right alignment with text centered right in X-and and center Y-axis */
};
enum zr_button_behavior {
@ -1954,7 +1960,8 @@ void zr_tooltip_end(struct zr_context*);
void zr_menubar_begin(struct zr_context*);
void zr_menubar_end(struct zr_context*);
int zr_menu_text_begin(struct zr_context*, struct zr_panel*, const char*, float width);
int zr_menu_text_begin(struct zr_context*, struct zr_panel*, const char*,
zr_flags, float width);
int zr_menu_icon_begin(struct zr_context*, struct zr_panel*, const char*,
struct zr_image, float width);
int zr_menu_symbol_begin(struct zr_context*, struct zr_panel*, const char*,