From 7d9ff90bec0435c8268af278e71fa6bff20153a7 Mon Sep 17 00:00:00 2001 From: zhyk Date: Thu, 7 May 2015 10:45:24 +0800 Subject: [PATCH] Add UIContext::DrawTextShadow for drawing text correctly under Qt --- ui/ui_context.cpp | 6 ++++++ ui/ui_context.h | 1 + 2 files changed, 7 insertions(+) diff --git a/ui/ui_context.cpp b/ui/ui_context.cpp index bc7d2d6faa..d67ed1e0c0 100644 --- a/ui/ui_context.cpp +++ b/ui/ui_context.cpp @@ -152,6 +152,12 @@ void UIContext::DrawText(const char *str, float x, float y, uint32_t color, int } } +void UIContext::DrawTextShadow(const char *str, float x, float y, uint32_t color, int align) { + uint32_t alpha = (color >> 1) & 0xFF000000; + DrawText(str, x + 2, y + 2, alpha, align); + DrawText(str, x, y, color, align); +} + void UIContext::DrawTextRect(const char *str, const Bounds &bounds, uint32_t color, int align) { if (!textDrawer_ || (align & FLAG_DYNAMIC_ASCII)) { float sizeFactor = (float)fontStyle_->sizePts / 24.0f; diff --git a/ui/ui_context.h b/ui/ui_context.h index d7960d34b4..628a96cba1 100644 --- a/ui/ui_context.h +++ b/ui/ui_context.h @@ -61,6 +61,7 @@ public: void MeasureTextCount(const UI::FontStyle &style, const char *str, int count, float *x, float *y, int align = 0) const; void MeasureText(const UI::FontStyle &style, const char *str, float *x, float *y, int align = 0) const; void DrawText(const char *str, float x, float y, uint32_t color, int align = 0); + void DrawTextShadow(const char *str, float x, float y, uint32_t color, int align = 0); void DrawTextRect(const char *str, const Bounds &bounds, uint32_t color, int align = 0); void FillRect(const UI::Drawable &drawable, const Bounds &bounds);