From 12ccaf883d4d8172df264307e02509f7201dca4a Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 24 Nov 2015 19:54:10 -0300 Subject: [PATCH] Add "px" suffix to New Sprite and Canvas Size fields (fix #875) --- data/widgets/canvas_size.xml | 14 +++++++------- data/widgets/new_sprite.xml | 4 ++-- src/app/ui/skin/skin_theme.cpp | 27 +++++++++++++++------------ 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/data/widgets/canvas_size.xml b/data/widgets/canvas_size.xml index 49bb59533..9d178387b 100644 --- a/data/widgets/canvas_size.xml +++ b/data/widgets/canvas_size.xml @@ -1,5 +1,5 @@ - + @@ -7,9 +7,9 @@ @@ -28,16 +28,16 @@ diff --git a/data/widgets/new_sprite.xml b/data/widgets/new_sprite.xml index 5d4e8dee0..9512ece6b 100644 --- a/data/widgets/new_sprite.xml +++ b/data/widgets/new_sprite.xml @@ -7,9 +7,9 @@ diff --git a/src/app/ui/skin/skin_theme.cpp b/src/app/ui/skin/skin_theme.cpp index a26f23a79..748171152 100644 --- a/src/app/ui/skin/skin_theme.cpp +++ b/src/app/ui/skin/skin_theme.cpp @@ -901,8 +901,7 @@ void SkinTheme::paintEntry(PaintEvent& ev) gfx::Rect bounds = widget->getClientBounds(); bool password = widget->isPassword(); int scroll, caret, state, selbeg, selend; - std::string textString = widget->getText() + widget->getSuffix(); - int suffixIndex = widget->getTextLength(); + const std::string& textString = widget->getText(); int c, ch, x, y, w; int caret_x; @@ -929,7 +928,6 @@ void SkinTheme::paintEntry(PaintEvent& ev) base::utf8_const_iterator utf8_it = base::utf8_const_iterator(textString.begin()); int textlen = base::utf8_length(textString); - if (scroll < textlen) utf8_it += scroll; @@ -955,15 +953,6 @@ void SkinTheme::paintEntry(PaintEvent& ev) fg = colors.disabled(); } - // Suffix - if (c >= suffixIndex) { - if (widget->hasFocus()) - break; - - bg = ColorNone; - fg = colors.entrySuffix(); - } - w = g->measureChar(ch).w; if (x+w > bounds.x2()-3) return; @@ -977,6 +966,20 @@ void SkinTheme::paintEntry(PaintEvent& ev) drawEntryCaret(g, widget, caret_x, y); } + // Draw suffix if there is enough space + if (!widget->getSuffix().empty()) { + Rect sufBounds(x, y, + bounds.x2()-3*guiscale()-x, + widget->getTextHeight()); + IntersectClip clip(g, sufBounds); + if (clip) { + drawTextString( + g, widget->getSuffix().c_str(), + colors.entrySuffix(), ColorNone, + widget, sufBounds, 0); + } + } + // Draw the caret if it is next of the last character if ((c == caret) && (state) && (widget->hasFocus()) &&