]> source.dussan.org Git - vaadin-framework.git/commitdiff
Avoid some rounding errors related to caption centering (#8313)
authorLeif Åstrand <leif@vaadin.com>
Thu, 22 Mar 2012 12:58:51 +0000 (14:58 +0200)
committerLeif Åstrand <leif@vaadin.com>
Thu, 22 Mar 2012 13:04:38 +0000 (15:04 +0200)
src/com/vaadin/terminal/gwt/client/ui/layout/VLayoutSlot.java

index 4494ef95d0a9805150e947021ee0149fc4394768..10a3b5c6789b6e55c4801f4a39b3c8a99056184e 100644 (file)
@@ -108,13 +108,14 @@ public abstract class VLayoutSlot {
             if (alignment.isHorizontalCenter()) {
                 currentLocation += (allocatedSpace - usedWidth) / 2d;
                 if (captionAboveCompnent) {
-                    captionStyle.setLeft((usedWidth - captionWidth) / 2,
-                            Unit.PX);
+                    captionStyle.setLeft(
+                            Math.round(usedWidth - captionWidth) / 2, Unit.PX);
                 }
             } else {
                 currentLocation += (allocatedSpace - usedWidth);
                 if (captionAboveCompnent) {
-                    captionStyle.setLeft(usedWidth - captionWidth, Unit.PX);
+                    captionStyle.setLeft(Math.round(usedWidth - captionWidth),
+                            Unit.PX);
                 }
             }
         } else {
@@ -123,7 +124,7 @@ public abstract class VLayoutSlot {
             }
         }
 
-        style.setLeft(currentLocation, Unit.PX);
+        style.setLeft(Math.round(currentLocation), Unit.PX);
     }
 
     private double parsePercent(String size) {