changeset 5734:9500977f0627

RT-34298: RTL orientation: MenuButton RTL text exceeds the bound if preferred width is small. Reviewed-by: felipe
author leifs
date Mon, 18 Nov 2013 11:24:01 -0800
parents ac4d9e43d517
children 323f71bef4ae
files modules/controls/src/main/java/com/sun/javafx/scene/control/skin/LabeledSkinBase.java modules/controls/src/main/java/com/sun/javafx/scene/control/skin/Utils.java
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/LabeledSkinBase.java	Mon Nov 18 11:21:45 2013 -0800
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/LabeledSkinBase.java	Mon Nov 18 11:24:01 2013 -0800
@@ -29,6 +29,7 @@
 import javafx.beans.InvalidationListener;
 import javafx.beans.Observable;
 import javafx.geometry.HPos;
+import javafx.geometry.NodeOrientation;
 import javafx.geometry.Orientation;
 import javafx.geometry.Pos;
 import javafx.geometry.VPos;
@@ -1149,7 +1150,11 @@
                 textClip = new Rectangle();
             }
 
-            textClip.setX(text.getLayoutBounds().getMinX());
+            if (labeled.getEffectiveNodeOrientation() == NodeOrientation.LEFT_TO_RIGHT) {
+                textClip.setX(text.getLayoutBounds().getMinX());
+            } else {
+                textClip.setX(text.getLayoutBounds().getMaxX() - wrapWidth);
+            }
             textClip.setY(text.getLayoutBounds().getMinY());
             textClip.setWidth(wrapWidth);
             textClip.setHeight(wrapHeight);
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/Utils.java	Mon Nov 18 11:21:45 2013 -0800
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/Utils.java	Mon Nov 18 11:24:01 2013 -0800
@@ -30,6 +30,7 @@
 
 package com.sun.javafx.scene.control.skin;
 
+import java.text.Bidi;
 import java.text.BreakIterator;
 
 import static javafx.scene.control.OverrunStyle.*;
@@ -210,7 +211,7 @@
                 // RT-23458: Use a faster algorithm for the most common case
                 // where truncation happens at the end, i.e. for ELLIPSIS and
                 // CLIP, but not for other cases such as WORD_ELLIPSIS, etc.
-                if (style == ELLIPSIS) {
+                if (style == ELLIPSIS && !new Bidi(text, Bidi.DIRECTION_LEFT_TO_RIGHT).isMixed()) {
                     int hit = computeTruncationIndex(font, text, width - ellipsisWidth);
                     if (hit < 0 || hit >= text.length()) {
                         return text;