[the-board] [things] Implement proper size update on LabelThing



commit 106d824f3d609891a93ab3cd6452a70f17ec9a8d
Author: Lucas Rocha <lucasr gnome org>
Date:   Tue Dec 7 17:04:38 2010 +0000

    [things] Implement proper size update on LabelThing
    
    Take into account pading coming from style instead of hardcoding random
    values in the code.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=636623

 src/js/ui/things/text.js |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/src/js/ui/things/text.js b/src/js/ui/things/text.js
index baf0494..872558c 100644
--- a/src/js/ui/things/text.js
+++ b/src/js/ui/things/text.js
@@ -162,9 +162,12 @@ TextThing.prototype = {
 
         this._label.clutterText.lineWrap = !this._singleLine;
         this._label.clutterText.singleLineMode = this._singleLine;
-        //this._label.clutterText.lineWrapMode = Pango.WrapMode.WORD_CHAR;
         this._label.clutterText.ellipsize = Pango.EllipsizeMode.NONE;
 
+        this._label.clutterText.lineWrapMode = this._singleLine ?
+                                               Pango.WrapMode.WORD :
+                                               Pango.WrapMode.WORD_CHAR;
+
         let clickAction = new Clutter.ClickAction();
 
         clickAction.connect("clicked",
@@ -185,9 +188,23 @@ TextThing.prototype = {
     _maybeUpdateSizeFromText : function() {
         if (this._singleLine && !this._loadingState) {
             let [minWidth, naturalWidth] =
-                this._label.get_preferred_width(this._label.height);
+                this._label.get_preferred_width(-1);
+
+            let [minHeight, naturalHeight] =
+                this._label.get_preferred_height(naturalWidth);
+
+            let thingPadding = Tb.mx_stylable_get_padding(this.actor);
+            let textBoxPadding = Tb.mx_stylable_get_padding(this._textBox);
+
+            let newWidth = naturalWidth +
+                           thingPadding.left + textBoxPadding.left +
+                           thingPadding.right + textBoxPadding.right;
+
+            let newHeight = naturalHeight +
+                            thingPadding.top + textBoxPadding.top +
+                            thingPadding.bottom + textBoxPadding.bottom;
 
-            this.setSize(naturalWidth + 38, this._textBox.height + 20);
+            this.setSize(newWidth, newHeight);
         }
     },
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]