changeset 2153:f9854bbcd1cb

Fixed RT-27545: Slider Track start and end are not snapped to pixel positions
author "Jasper Potts"
date Sun, 06 Jan 2013 13:26:23 -0800
parents 907061acb223
children fb5f92a6d1f6
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/SliderSkin.java
diffstat 1 files changed, 16 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/SliderSkin.java	Sun Jan 06 13:25:55 2013 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/SliderSkin.java	Sun Jan 06 13:26:23 2013 -0800
@@ -240,8 +240,8 @@
             final double w, final double h) {
          // calculate the available space
         // resize thumb to preferred size
-        thumbWidth = thumb.prefWidth(-1);
-        thumbHeight = thumb.prefHeight(-1);
+        thumbWidth = snapSize(thumb.prefWidth(-1));
+        thumbHeight = snapSize(thumb.prefHeight(-1));
         thumb.resize(thumbWidth, thumbHeight);
         // we are assuming the is common radius's for all corners on the track
         double trackRadius = track.getBackground() == null ? 0 : track.getBackground().getFills().size() > 0 ?
@@ -249,18 +249,21 @@
 
         if (getSkinnable().getOrientation() == Orientation.HORIZONTAL) {
             double tickLineHeight =  (showTickMarks) ? tickLine.prefHeight(-1) : 0;
-            double trackHeight = track.prefHeight(-1);
+            double trackHeight = snapSize(track.prefHeight(-1));
             double trackAreaHeight = Math.max(trackHeight,thumbHeight);
             double totalHeightNeeded = trackAreaHeight  + ((showTickMarks) ? trackToTickGap+tickLineHeight : 0);
             double startY = y + ((h - totalHeightNeeded)/2); // center slider in available height vertically
-            trackLength = w - thumbWidth;
-            trackStart = x + (thumbWidth/2);
+            trackLength = snapSize(w - thumbWidth);
+            trackStart = snapPosition(x + (thumbWidth/2));
             double trackTop = (int)(startY + ((trackAreaHeight-trackHeight)/2));
             thumbTop = (int)(startY + ((trackAreaHeight-thumbHeight)/2));
 
             positionThumb();
             // layout track
-            track.resizeRelocate(trackStart - trackRadius, trackTop , trackLength + trackRadius + trackRadius, trackHeight);
+            track.resizeRelocate((int)(trackStart - trackRadius),
+                                 trackTop ,
+                                 (int)(trackLength + trackRadius + trackRadius),
+                                 trackHeight);
             // layout tick line
             if (showTickMarks) {
                 tickLine.setLayoutX(trackStart);
@@ -276,18 +279,21 @@
             }
         } else {
             double tickLineWidth = (showTickMarks) ? tickLine.prefWidth(-1) : 0;
-            double trackWidth = track.prefWidth(-1);
+            double trackWidth = snapSize(track.prefWidth(-1));
             double trackAreaWidth = Math.max(trackWidth,thumbWidth);
             double totalWidthNeeded = trackAreaWidth  + ((showTickMarks) ? trackToTickGap+tickLineWidth : 0) ;
             double startX = x + ((w - totalWidthNeeded)/2); // center slider in available width horizontally
-            trackLength = h - thumbHeight;
-            trackStart = y + (thumbHeight/2);
+            trackLength = snapSize(h - thumbHeight);
+            trackStart = snapPosition(y + (thumbHeight/2));
             double trackLeft = (int)(startX + ((trackAreaWidth-trackWidth)/2));
             thumbLeft = (int)(startX + ((trackAreaWidth-thumbWidth)/2));
 
             positionThumb();
             // layout track
-            track.resizeRelocate(trackLeft, trackStart - trackRadius, trackWidth, trackLength + trackRadius + trackRadius);
+            track.resizeRelocate(trackLeft,
+                                 (int)(trackStart - trackRadius),
+                                 trackWidth,
+                                 (int)(trackLength + trackRadius + trackRadius));
             // layout tick line
             if (showTickMarks) {
                 tickLine.setLayoutX(trackLeft+trackWidth+trackToTickGap);