diff --git a/ui/ui.cpp b/ui/ui.cpp index 04b32fff83..f894eb97e1 100644 --- a/ui/ui.cpp +++ b/ui/ui.cpp @@ -129,8 +129,9 @@ void UIText(int font, const LayoutManager &layout, const char *text, uint32_t co ui_draw2d.SetFontScale(1.0f, 1.0f); } -int UIButton(int id, const LayoutManager &layout, float w, const char *text, int button_align) { - float h = themeAtlas->images[theme.buttonImage].h; +int UIButton(int id, const LayoutManager &layout, float w, float h, const char *text, int button_align) { + if (h == 0.0f) + h = themeAtlas->images[theme.buttonImage].h; float x, y; layout.GetPos(&w, &h, &x, &y); @@ -174,7 +175,10 @@ int UIButton(int id, const LayoutManager &layout, float w, const char *text, int // Render button - ui_draw2d.DrawImage2GridH((txOffset && theme.buttonSelected) ? theme.buttonSelected : theme.buttonImage, x, y, x + w); + if (h == themeAtlas->images[theme.buttonImage].h) + ui_draw2d.DrawImage2GridH((txOffset && theme.buttonSelected) ? theme.buttonSelected : theme.buttonImage, x, y, x + w); + else + ui_draw2d.DrawImage4Grid((txOffset && theme.buttonSelected) ? theme.buttonSelected : theme.buttonImage, x, y, x + w, y + h); ui_draw2d.DrawTextShadow(theme.uiFont, text, x + w/2, y + h/2 + txOffset, 0xFFFFFFFF, ALIGN_HCENTER | ALIGN_VCENTER); uistate.lastwidget = id; diff --git a/ui/ui.h b/ui/ui.h index be67e693fc..237d57fed3 100644 --- a/ui/ui.h +++ b/ui/ui.h @@ -242,7 +242,7 @@ void UIUpdateMouse(int i, float x, float y, bool down); void UIReset(); // Returns 1 if clicked -int UIButton(int id, const LayoutManager &layout, float w, const char *text, int button_align); +int UIButton(int id, const LayoutManager &layout, float w, float h, const char *text, int button_align); int UIImageButton(int id, const LayoutManager &layout, float w, int image_id, int button_align); // uses current UI atlas for fetching images. int UITextureButton(UIContext *ctx, int id, const LayoutManager &layout, float w, float h, Texture *texture, int button_align); // uses current UI atlas for fetching images.