OSDN Git Service

Setting to turn off label ellipse.
authorNathanSweet <nathan.sweet@gmail.com>
Fri, 13 Sep 2013 18:54:23 +0000 (20:54 +0200)
committerNathanSweet <nathan.sweet@gmail.com>
Fri, 13 Sep 2013 18:54:23 +0000 (20:54 +0200)
f201abec80d03dcc7417522763b5dcb0ecada272

gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Label.java

index 631d873..42adab3 100644 (file)
@@ -46,6 +46,7 @@ public class Label extends Widget {
        private float lastPrefHeight;\r
        private boolean sizeInvalid = true;\r
        private float fontScaleX = 1, fontScaleY = 1;\r
+       private boolean ellipse = true;\r
 \r
        public Label (CharSequence text, Skin skin) {\r
                this(text, skin.get(LabelStyle.class));\r
@@ -151,7 +152,7 @@ public class Label extends Widget {
 \r
                float width = getWidth(), height = getHeight();\r
                StringBuilder text;\r
-               if (width < bounds.width) {\r
+               if (ellipse && width < bounds.width) {\r
                        float ellipseWidth = font.getBounds("...").width;\r
                        text = tempText != null ? tempText : (tempText = new StringBuilder());\r
                        text.setLength(0);\r
@@ -289,6 +290,11 @@ public class Label extends Widget {
                invalidateHierarchy();\r
        }\r
 \r
+       /** When true the text will be truncated with an ellipse if it does not fit within the width of the label. Default is true. */\r
+       public void setEllipse (boolean ellipse) {\r
+               this.ellipse = ellipse;\r
+       }\r
+\r
        /** The style for a label, see {@link Label}.\r
         * @author Nathan Sweet */\r
        static public class LabelStyle {\r