Minor UI tweaks

This commit is contained in:
Henrik Rydgard 2013-11-26 13:56:56 +01:00
parent d6fa5b8399
commit d2e70ce06f
4 changed files with 12 additions and 1 deletions

View File

@ -175,6 +175,10 @@ void UIContext::DrawTextRect(const char *str, const Bounds &bounds, uint32_t col
} }
void UIContext::FillRect(const UI::Drawable &drawable, const Bounds &bounds) { void UIContext::FillRect(const UI::Drawable &drawable, const Bounds &bounds) {
// Only draw if alpha is non-zero.
if ((drawable.color & 0xFF000000) == 0)
return;
switch (drawable.type) { switch (drawable.type) {
case UI::DRAW_SOLID_COLOR: case UI::DRAW_SOLID_COLOR:
uidrawbuffer_->DrawImageStretch(theme->whiteImage, bounds.x, bounds.y, bounds.x2(), bounds.y2(), drawable.color); uidrawbuffer_->DrawImageStretch(theme->whiteImage, bounds.x, bounds.y, bounds.x2(), bounds.y2(), drawable.color);

View File

@ -10,6 +10,10 @@ UIScreen::UIScreen()
: Screen(), root_(0), recreateViews_(true), hatDown_(0) { : Screen(), root_(0), recreateViews_(true), hatDown_(0) {
} }
UIScreen::~UIScreen() {
delete root_;
}
void UIScreen::DoRecreateViews() { void UIScreen::DoRecreateViews() {
if (recreateViews_) { if (recreateViews_) {
delete root_; delete root_;

View File

@ -8,7 +8,7 @@ class I18NCategory;
class UIScreen : public Screen { class UIScreen : public Screen {
public: public:
UIScreen(); UIScreen();
~UIScreen() { delete root_; } ~UIScreen();
virtual void update(InputState &input); virtual void update(InputState &input);
virtual void render(); virtual void render();

View File

@ -414,6 +414,9 @@ void CheckBox::Draw(UIContext &dc) {
void Button::GetContentDimensions(const UIContext &dc, float &w, float &h) const { void Button::GetContentDimensions(const UIContext &dc, float &w, float &h) const {
dc.MeasureText(dc.theme->uiFont, text_.c_str(), &w, &h); dc.MeasureText(dc.theme->uiFont, text_.c_str(), &w, &h);
// Add some internal padding to not look totally ugly
w += 16;
h += 8;
} }
void Button::Draw(UIContext &dc) { void Button::Draw(UIContext &dc) {