Permalink
Browse files

UI: Make button padding configurable.

Useful for buttons on the MainScreen which look out of place with the
default padding.
  • Loading branch information...
unknownbrackets committed Jun 2, 2018
1 parent e4aef72 commit 40c7f5ddfd79723b9acd6755750e99319f015e05
Showing with 8 additions and 2 deletions.
  1. +2 −2 ext/native/ui/view.cpp
  2. +6 −0 ext/native/ui/view.h
@@ -733,8 +733,8 @@ void Button::GetContentDimensions(const UIContext &dc, float &w, float &h) const
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_.c_str(), &w, &h);
}
// Add some internal padding to not look totally ugly
w += 16;
h += 8;
w += paddingW_;
h += paddingH_;
}
void Button::Draw(UIContext &dc) {
@@ -508,11 +508,17 @@ class Button : public Clickable {
void Draw(UIContext &dc) override;
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
const std::string &GetText() const { return text_; }
void SetPadding(int w, int h) {
paddingW_ = w;
paddingH_ = h;
}
private:
Style style_;
std::string text_;
ImageID imageID_;
int paddingW_ = 16;
int paddingH_ = 8;
};
class Slider : public Clickable {

0 comments on commit 40c7f5d

Please sign in to comment.