Author: rwhitcomb
Date: Fri Oct 28 18:19:25 2011
New Revision: 1190487
URL: http://svn.apache.org/viewvc?rev=1190487&view=rev
Log:
PIVOT-812 Add style to TabPane to specify the tab button corner radius.
The value for the corner radius of the tab pane buttons was fixed at
four pixels. It would be nice to be able to specify this value with
a style.
This change introduces the "buttonCornerRadius" style, defaulted to
a value of 4, but which can be set by user code to something different.
I anticipate adding a further style to allow setting the bottom corner
radii similar to the way it is done for Border.
Modified:
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java
Modified:
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java?rev=1190487&r1=1190486&r2=1190487&view=diff
==============================================================================
---
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java
(original)
+++
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java
Fri Oct 28 18:19:25 2011
@@ -245,16 +245,16 @@ public class TerraTabPaneSkin extends Co
case HORIZONTAL: {
graphics.setPaint(new GradientPaint(width / 2f, 0,
buttonBevelColor,
width / 2f, height / 2f, backgroundColor));
- graphics.fill(new RoundRectangle2D.Double(0.5, 0.5, width
- 1, height - 1 + CORNER_RADIUS,
- CORNER_RADIUS, CORNER_RADIUS));
+ graphics.fill(new RoundRectangle2D.Double(0.5, 0.5, width
- 1, height - 1 + buttonCornerRadius,
+ buttonCornerRadius, buttonCornerRadius));
break;
}
case VERTICAL: {
graphics.setPaint(new GradientPaint(0, height / 2f,
buttonBevelColor,
width / 2f, height / 2f, backgroundColor));
- graphics.fill(new RoundRectangle2D.Double(0.5, 0.5, width
- 1 + CORNER_RADIUS, height - 1,
- CORNER_RADIUS, CORNER_RADIUS));
+ graphics.fill(new RoundRectangle2D.Double(0.5, 0.5, width
- 1 + buttonCornerRadius, height - 1,
+ buttonCornerRadius, buttonCornerRadius));
break;
}
}
@@ -265,14 +265,14 @@ public class TerraTabPaneSkin extends Co
switch(tabOrientation) {
case HORIZONTAL: {
- graphics.draw(new RoundRectangle2D.Double(0.5, 0.5, width
- 1, height + CORNER_RADIUS - 1,
- CORNER_RADIUS, CORNER_RADIUS));
+ graphics.draw(new RoundRectangle2D.Double(0.5, 0.5, width
- 1, height + buttonCornerRadius - 1,
+ buttonCornerRadius, buttonCornerRadius));
break;
}
case VERTICAL: {
- graphics.draw(new RoundRectangle2D.Double(0.5, 0.5, width
+ CORNER_RADIUS - 1, height - 1,
- CORNER_RADIUS, CORNER_RADIUS));
+ graphics.draw(new RoundRectangle2D.Double(0.5, 0.5, width
+ buttonCornerRadius - 1, height - 1,
+ buttonCornerRadius, buttonCornerRadius));
break;
}
}
@@ -515,6 +515,7 @@ public class TerraTabPaneSkin extends Co
private Color disabledButtonColor;
private Insets buttonPadding;
private int buttonSpacing;
+ private int buttonCornerRadius;
private Color activeButtonBevelColor;
private Color inactiveButtonBevelColor;
@@ -537,7 +538,6 @@ public class TerraTabPaneSkin extends Co
};
- public static final int CORNER_RADIUS = 4;
public static final int GRADIENT_BEVEL_THICKNESS = 8;
private static final int CLOSE_TRIGGER_SIZE = 6;
private static final int DEFAULT_SELECTION_CHANGE_DURATION = 250;
@@ -555,6 +555,7 @@ public class TerraTabPaneSkin extends Co
disabledButtonColor = theme.getColor(7);
buttonPadding = new Insets(3, 4, 3, 4);
buttonSpacing = 6;
+ buttonCornerRadius = 4;
activeButtonBevelColor = TerraTheme.brighten(activeTabColor);
inactiveButtonBevelColor = TerraTheme.brighten(inactiveTabColor);
@@ -1328,6 +1329,26 @@ public class TerraTabPaneSkin extends Co
tabButtonBoxPane.getStyles().put("spacing", buttonSpacing);
}
+ public final void setButtonCornerRadius(int buttonCornerRadius) {
+ this.buttonCornerRadius = buttonCornerRadius;
+ }
+
+ public final void setButtonCornerRadius(Number radius) {
+ if (radius == null) {
+ throw new IllegalArgumentException("buttonCornerRadius is null.");
+ }
+
+ setButtonCornerRadius(radius.intValue());
+ }
+
+ public final void setButtonCornerRadius(String radius) {
+ if (radius == null) {
+ throw new IllegalArgumentException("buttonCornerRadius is null.");
+ }
+
+ setButtonCornerRadius(Integer.valueOf(radius));
+ }
+
public Orientation getTabOrientation() {
return tabOrientation;
}