You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2013/03/07 12:07:41 UTC

svn commit: r1453774 - /pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java

Author: smartini
Date: Thu Mar  7 11:07:41 2013
New Revision: 1453774

URL: http://svn.apache.org/r1453774
Log:
PIVOT-898 , use even paddings when calculating the area available to the image for the fillIcon style (like in the skin, when drawing the button)

Modified:
    pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java

Modified: pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java?rev=1453774&r1=1453773&r2=1453774&view=diff
==============================================================================
--- pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java (original)
+++ pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java Thu Mar  7 11:07:41 2013
@@ -23,6 +23,7 @@ import org.apache.pivot.wtk.BoxPane;
 import org.apache.pivot.wtk.Button;
 import org.apache.pivot.wtk.HorizontalAlignment;
 import org.apache.pivot.wtk.ImageView;
+import org.apache.pivot.wtk.Insets;
 import org.apache.pivot.wtk.Label;
 import org.apache.pivot.wtk.VerticalAlignment;
 import org.apache.pivot.wtk.media.Image;
@@ -82,15 +83,22 @@ public class ButtonDataRenderer extends 
             imageView.getStyles().put("opacity", button.isEnabled() ? 1.0f : 0.5f);
 
             if (getFillIcon()) {
-                imageView.setPreferredWidth(button.getWidth());
-                imageView.setPreferredHeight(button.getHeight());
+                int buttonWidth = button.getWidth();
+                int buttonHeight = button.getHeight();
+                Insets padding = (Insets) button.getStyles().get("padding");
+                if (buttonWidth > 0) {
+                    imageView.setPreferredWidth(Math.max(buttonWidth - (padding.left + padding.right + 2), 0));
+                }
+                if (buttonHeight > 0) {
+                    imageView.setPreferredWidth(Math.max(buttonHeight - (padding.top + padding.bottom + 2), 0));
+                }
             }
         }
 
         // Update the label
         label.setText(text != null ? text : "");
 
-        if (text == null) {
+        if (text == null || text.length() == 0) {
             label.setVisible(false);
         } else {
             label.setVisible(true);