[aseprite] 19/308: Add "px" suffix to New Sprite and Canvas Size fields (fix #875)

Tobias Hansen thansen at moszumanska.debian.org
Tue Mar 8 02:44:47 UTC 2016


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit 12ccaf883d4d8172df264307e02509f7201dca4a
Author: David Capello <davidcapello at gmail.com>
Date:   Tue Nov 24 19:54:10 2015 -0300

    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 49bb595..9d17838 100644
--- a/data/widgets/canvas_size.xml
+++ b/data/widgets/canvas_size.xml
@@ -1,5 +1,5 @@
 <!-- ASEPRITE -->
-<!-- Copyright (C) 2001-2014 by David Capello -->
+<!-- Copyright (C) 2001-2015 by David Capello -->
 <gui>
  <window text="Canvas Size" id="canvas_size">
   <vbox>
@@ -7,9 +7,9 @@
     <hbox>
       <grid columns="2">
         <label text="Width:" />
-        <entry text="0" id="width" maxsize="32" maxwidth="64" magnet="true" />
+        <entry text="0" id="width" maxsize="32" maxwidth="64" suffix="px" magnet="true" />
         <label text="Height:" />
-        <entry text="0" id="height" maxsize="32" maxwidth="64" />
+        <entry text="0" id="height" maxsize="32" maxwidth="64" suffix="px" />
         <hbox filler="true" cell_hspan="2" />
       </grid>
       <buttonset columns="3" id="dir">
@@ -28,16 +28,16 @@
     <separator text="Borders:" left="true" horizontal="true" />
     <grid columns="4">
       <label text="Left:" />
-      <entry text="0" id="left" maxsize="32" maxwidth="64" tooltip="Columns to be added/removed in the left side.
Use a negative number to remove columns." />
+      <entry text="0" id="left" maxsize="32" maxwidth="64" suffix="px" tooltip="Columns to be added/removed in the left side.
Use a negative number to remove columns." />
 
       <label text="Top:" />
-      <entry text="0" id="top" maxsize="32" maxwidth="64" tooltip="Rows to be added/removed in the top side.
Use a negative number to remove rows." />
+      <entry text="0" id="top" maxsize="32" maxwidth="64" suffix="px" tooltip="Rows to be added/removed in the top side.
Use a negative number to remove rows." />
 
       <label text="Right:" />
-      <entry text="0" id="right" maxsize="32" maxwidth="64" tooltip="Columns to be added/removed in the right side.
Use a negative number to remove columns." />
+      <entry text="0" id="right" maxsize="32" maxwidth="64" suffix="px" tooltip="Columns to be added/removed in the right side.
Use a negative number to remove columns." />
 
       <label text="Bottom:" />
-      <entry text="0" id="bottom" maxsize="32" maxwidth="64" tooltip="Rows to be added/removed in the bottom side.
Use a negative number to remove rows." />
+      <entry text="0" id="bottom" maxsize="32" maxwidth="64" suffix="px" tooltip="Rows to be added/removed in the bottom side.
Use a negative number to remove rows." />
     </grid>
 
     <separator horizontal="true" />
diff --git a/data/widgets/new_sprite.xml b/data/widgets/new_sprite.xml
index 5d4e8de..9512ece 100644
--- a/data/widgets/new_sprite.xml
+++ b/data/widgets/new_sprite.xml
@@ -7,9 +7,9 @@
       <separator text="Size:" left="true" horizontal="true" />
       <grid columns="2">
         <label text="Width:" />
-        <entry id="width" maxsize="8" magnet="true" cell_align="horizontal" tooltip="Width of the new sprite
(in pixels)" />
+        <entry id="width" maxsize="8" magnet="true" cell_align="horizontal" suffix="px" />
         <label text="Height:" />
-        <entry id="height" maxsize="8" cell_align="horizontal" tooltip="Height of the new sprite
(in pixels)" />
+        <entry id="height" maxsize="8" cell_align="horizontal" suffix="px" />
       </grid>
 
       <separator text="Color Mode:" left="true" horizontal="true" />
diff --git a/src/app/ui/skin/skin_theme.cpp b/src/app/ui/skin/skin_theme.cpp
index a26f23a..7481711 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()) &&

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list