Author: rwhitcomb Date: Fri Sep 28 15:33:18 2012 New Revision: 1391504 URL: http://svn.apache.org/viewvc?rev=1391504&view=rev Log: Pivot-721: setFillIcon on ButtonDataRenderer has no effect.
Changed previous fix to put the set of "fill:true" only in the "setFillIcon" method (because setting it always messed up the default behavior in a lot of cases). And, completely fixed the issue by setting the image preferred size to the button size in the "fillIcon" case, which allows the image to completely fill the button. Also, fixed a copy/paste bug in the Pivot721.java test case. Modified: pivot/trunk/ (props changed) pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot721.java pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java Propchange: pivot/trunk/ ------------------------------------------------------------------------------ Merged /pivot/branches/2.0.x:r1391496 Modified: pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot721.java URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot721.java?rev=1391504&r1=1391503&r2=1391504&view=diff ============================================================================== --- pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot721.java (original) +++ pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot721.java Fri Sep 28 15:33:18 2012 @@ -32,7 +32,7 @@ public class Pivot721 extends Applicatio @Override public void startup(Display display, Map<String, String> properties) throws Exception { BXMLSerializer bxmlSerializer = new BXMLSerializer(); - window = (Window) bxmlSerializer.readObject(Pivot734.class, "pivot_721.bxml"); + window = (Window) bxmlSerializer.readObject(Pivot721.class, "pivot_721.bxml"); // force fill into button renderer, but only in some buttons ... ButtonDataRenderer filledButtonDataRenderer = new ButtonDataRenderer(); Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java?rev=1391504&r1=1391503&r2=1391504&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java Fri Sep 28 15:33:18 2012 @@ -38,7 +38,6 @@ public class ButtonDataRenderer extends public ButtonDataRenderer() { getStyles().put("horizontalAlignment", HorizontalAlignment.CENTER); getStyles().put("verticalAlignment", VerticalAlignment.CENTER); - getStyles().put("fill", true); add(imageView); add(label); @@ -81,6 +80,11 @@ public class ButtonDataRenderer extends imageView.setImage(icon); imageView.getStyles().put("opacity", button.isEnabled() ? 1.0f : 0.5f); + + if (getFillIcon()) { + imageView.setPreferredWidth(button.getWidth()); + imageView.setPreferredHeight(button.getHeight()); + } } // Update the label @@ -135,6 +139,7 @@ public class ButtonDataRenderer extends public void setFillIcon(boolean fillIcon) { imageView.getStyles().put("fill", fillIcon); + getStyles().put("fill", fillIcon); } @Override