[ClutterText] Fix actors with a width but no wrapping and the wrap modes
authorNeil Roberts <neil@linux.intel.com>
Tue, 21 Apr 2009 13:15:19 +0000 (14:15 +0100)
committerNeil Roberts <neil@linux.intel.com>
Mon, 27 Apr 2009 16:43:48 +0000 (17:43 +0100)
Setting the wrap mode on the PangoLayout seems to have disappeared
during the text-actor-layout-height branch merge so this brings it
back. The test for this in test-text-cache no longer needs to be
disabled.

We also shouldn't set the width on the layout if there is no wrapping
or ellipsizing because otherwise it implicitly enables wrapping. This
only matters if the actor gets allocated smaller than its natural
size.

clutter/clutter-text.c
tests/conform/test-text-cache.c

index 9ece4b8..c575595 100644 (file)
@@ -284,6 +284,7 @@ clutter_text_create_layout_no_cache (ClutterText *text,
   pango_layout_set_alignment (layout, priv->alignment);
   pango_layout_set_single_paragraph_mode (layout, priv->single_line_mode);
   pango_layout_set_justify (layout, priv->justify);
+  pango_layout_set_wrap (layout, priv->wrap_mode);
 
   /* Cases, assuming ellipsize != NONE on actor:
    *
@@ -309,11 +310,14 @@ clutter_text_create_layout_no_cache (ClutterText *text,
         }
     }
 
-  /* we do not limit the layout width on editable, single-line
-   * text actors, since those can scroll the layout
+  /* We do not limit the layout width on editable, single-line text
+   * actors, since those can scroll the layout. For non-editable
+   * actors we only want to set the width if wrapping or ellipsizing
+   * is enabled.
    */
   if (allocation_width > 0 &&
-      !(priv->editable && priv->single_line_mode))
+      (priv->editable ? !priv->single_line_mode
+       : (priv->ellipsize != PANGO_ELLIPSIZE_NONE || priv->wrap)))
     {
       gint width;
 
index f7237b1..ac65052 100644 (file)
@@ -202,7 +202,6 @@ do_tests (CallbackData *data)
   pango_layout_set_wrap (data->test_layout, PANGO_WRAP_WORD);
   g_assert (check_result (data, "Enable line wrap", TRUE) == FALSE);
 
-#if 0
   /* TEST 11: change wrap mode
    * FIXME - broken
    */
@@ -210,7 +209,6 @@ do_tests (CallbackData *data)
                                    PANGO_WRAP_CHAR);
   pango_layout_set_wrap (data->test_layout, PANGO_WRAP_CHAR);
   g_assert (check_result (data, "Change wrap mode", TRUE) == FALSE);
-#endif
 
   /* TEST 12: enable justify */
   clutter_text_set_justify (CLUTTER_TEXT (data->label), TRUE);