Add height parameter to UIButton

This commit is contained in:
Henrik Rydgård
2013-04-13 15:05:57 +02:00
parent 5626d01e14
commit 8f8f65c45d
2 changed files with 8 additions and 4 deletions
+7 -3
View File
@@ -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;
+1 -1
View File
@@ -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.