From d2e70ce06fd54e0c884afe8d8b876ae28ce16df0 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Tue, 26 Nov 2013 13:56:56 +0100 Subject: [PATCH] Minor UI tweaks --- ui/ui_context.cpp | 4 ++++ ui/ui_screen.cpp | 4 ++++ ui/ui_screen.h | 2 +- ui/view.cpp | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ui/ui_context.cpp b/ui/ui_context.cpp index 5e6717fb4c..1731cd230b 100644 --- a/ui/ui_context.cpp +++ b/ui/ui_context.cpp @@ -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) { + // Only draw if alpha is non-zero. + if ((drawable.color & 0xFF000000) == 0) + return; + switch (drawable.type) { case UI::DRAW_SOLID_COLOR: uidrawbuffer_->DrawImageStretch(theme->whiteImage, bounds.x, bounds.y, bounds.x2(), bounds.y2(), drawable.color); diff --git a/ui/ui_screen.cpp b/ui/ui_screen.cpp index 0e60df7875..d4e7ac5c0c 100644 --- a/ui/ui_screen.cpp +++ b/ui/ui_screen.cpp @@ -10,6 +10,10 @@ UIScreen::UIScreen() : Screen(), root_(0), recreateViews_(true), hatDown_(0) { } +UIScreen::~UIScreen() { + delete root_; +} + void UIScreen::DoRecreateViews() { if (recreateViews_) { delete root_; diff --git a/ui/ui_screen.h b/ui/ui_screen.h index 56f63edbae..9f4dc828ec 100644 --- a/ui/ui_screen.h +++ b/ui/ui_screen.h @@ -8,7 +8,7 @@ class I18NCategory; class UIScreen : public Screen { public: UIScreen(); - ~UIScreen() { delete root_; } + ~UIScreen(); virtual void update(InputState &input); virtual void render(); diff --git a/ui/view.cpp b/ui/view.cpp index f6310d5d8e..f8bbc2b8b7 100644 --- a/ui/view.cpp +++ b/ui/view.cpp @@ -414,6 +414,9 @@ void CheckBox::Draw(UIContext &dc) { void Button::GetContentDimensions(const UIContext &dc, float &w, float &h) const { 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) {