diff options
-rw-r--r-- | ChangeLog | 22 | ||||
-rw-r--r-- | docs/pango-sections.txt | 1 | ||||
-rw-r--r-- | docs/tmpl/layout.sgml | 9 | ||||
-rw-r--r-- | pango/ellipsize.c | 10 | ||||
-rw-r--r-- | pango/pango-layout-private.h | 3 | ||||
-rw-r--r-- | pango/pango-layout.c | 34 | ||||
-rw-r--r-- | pango/pango-layout.h | 1 | ||||
-rw-r--r-- | pango/pango.def | 1 |
8 files changed, 76 insertions, 5 deletions
@@ -1,5 +1,27 @@ 2007-01-16 Behdad Esfahbod <behdad@gnome.org> + Bug 363510 – Ability to query whether a PangoLayout is effectively + ellipsized (as opposed to the set_ellpisize()/get_ellipsize() methods + which only set a request, or return the set request respectively) + Patch from Milosz Derezynski + + * pango/pango-layout.h: + * pango/ellipsize.c (_pango_layout_line_ellipsize): + * pango/pango-layout-private.h: + * pango/pango-layout.c (pango_layout_init), (pango_layout_copy), + (pango_layout_is_ellipsized), (pango_layout_clear_lines), + (pango_layout_line_postprocess): + New public function: + + pango_layout_is_ellipsized() + + * pango/pango.def: + * docs/tmpl/layout.sgml: + * docs/pango-sections.txt: + Update. + +2007-01-16 Behdad Esfahbod <behdad@gnome.org> + * pango/pango-renderer.c (pango_renderer_draw_layout_line): Fix background rendering being off in presence of rise attributes. diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt index d9d68e9c..be100e0c 100644 --- a/docs/pango-sections.txt +++ b/docs/pango-sections.txt @@ -448,6 +448,7 @@ PangoWrapMode PANGO_TYPE_WRAP_MODE pango_layout_set_ellipsize pango_layout_get_ellipsize +pango_layout_is_ellipsized PangoEllipsizeMode PANGO_TYPE_ELLIPSIZE_MODE pango_layout_set_indent diff --git a/docs/tmpl/layout.sgml b/docs/tmpl/layout.sgml index 135a706a..6fb3fb80 100644 --- a/docs/tmpl/layout.sgml +++ b/docs/tmpl/layout.sgml @@ -245,6 +245,15 @@ The #GObject type for #PangoWrapMode. @Returns: +<!-- ##### FUNCTION pango_layout_is_ellipsized ##### --> +<para> + +</para> + +@layout: +@Returns: + + <!-- ##### ENUM PangoEllipsizeMode ##### --> <para> diff --git a/pango/ellipsize.c b/pango/ellipsize.c index b1523afe..e392d3c9 100644 --- a/pango/ellipsize.c +++ b/pango/ellipsize.c @@ -717,17 +717,20 @@ current_width (EllipsizeState *state) * * Given a #PangoLayoutLine with the runs still in logical order, ellipsize * it according the layout's policy to fit within the set width of the layout. + * + * Return value: whether the line had to be ellipsized **/ -void +gboolean _pango_layout_line_ellipsize (PangoLayoutLine *line, PangoAttrList *attrs) { EllipsizeState state; int goal_width; + gboolean is_ellipsized = FALSE; if (line->layout->ellipsize == PANGO_ELLIPSIZE_NONE || line->layout->width < 0) - return; + goto ret; init_state (&state, line, attrs); @@ -750,7 +753,10 @@ _pango_layout_line_ellipsize (PangoLayoutLine *line, g_slist_free (line->runs); line->runs = get_run_list (&state); + is_ellipsized = TRUE; out: free_state (&state); + ret: + return is_ellipsized; } diff --git a/pango/pango-layout-private.h b/pango/pango-layout-private.h index 75913940..56370c1a 100644 --- a/pango/pango-layout-private.h +++ b/pango/pango-layout-private.h @@ -52,6 +52,7 @@ struct _PangoLayout guint wrap : 2; /* PangoWrapMode */ guint ellipsize : 2; /* PangoEllipsizeMode */ + guint is_ellipsized : 1; /* Whether the layout has any ellipsized lines */ /* some caching */ guint logical_rect_cached : 1; @@ -72,7 +73,7 @@ struct _PangoLayout G_END_DECLS -void _pango_layout_line_ellipsize (PangoLayoutLine *line, +gboolean _pango_layout_line_ellipsize (PangoLayoutLine *line, PangoAttrList *attrs); PangoLayoutLine* _pango_layout_iter_get_line_readonly (PangoLayoutIter *iter); diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 52b9dccf..e708d555 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -200,6 +200,7 @@ pango_layout_init (PangoLayout *layout) layout->wrap = PANGO_WRAP_WORD; layout->ellipsize = PANGO_ELLIPSIZE_NONE; + layout->is_ellipsized = FALSE; } static void @@ -306,7 +307,7 @@ pango_layout_copy (PangoLayout *src) layout->wrap = src->wrap; layout->ellipsize = src->ellipsize; - /* log_attrs, lines fields are updated by check_lines */ + /* is_ellipsized, log_attrs, lines fields are updated by check_lines */ return layout; } @@ -845,6 +846,32 @@ pango_layout_get_ellipsize (PangoLayout *layout) } /** + * pango_layout_is_ellipsized: + * @layout: a #PangoLayout + * + * Queries whether the layout had to ellipsize any paragraphs. + * + * This can only return %TRUE if the ellipsization mode for @layout + * is not %PANGO_ELLIPSIZE_NONE, a positive width is set on @layout, + * and there were paragraphs exceeding that width that had to be + * ellipsized. + * + * Return value: %TRUE if any paragraphs had to be ellipsized, %FALSE + * otherwise. + * + * Since: 1.16 + */ +gboolean +pango_layout_is_ellipsized (PangoLayout *layout) +{ + g_return_if_fail (layout != NULL); + + pango_layout_check_lines (layout); + + return layout->is_ellipsized; +} + +/** * pango_layout_set_text: * @layout: a #PangoLayout * @text: a valid UTF-8 string @@ -2456,6 +2483,8 @@ pango_layout_get_pixel_size (PangoLayout *layout, static void pango_layout_clear_lines (PangoLayout *layout) { + layout->is_ellipsized = FALSE; + if (layout->lines) { GSList *tmp_list = layout->lines; @@ -4571,7 +4600,8 @@ pango_layout_line_postprocess (PangoLayoutLine *line, /* Ellipsize the line if necessary */ - _pango_layout_line_ellipsize (line, state->attrs); + if (_pango_layout_line_ellipsize (line, state->attrs)) + line->layout->is_ellipsized = TRUE; /* Now convert logical to visual order */ diff --git a/pango/pango-layout.h b/pango/pango-layout.h index 6e24a565..5a73c537 100644 --- a/pango/pango-layout.h +++ b/pango/pango-layout.h @@ -153,6 +153,7 @@ gboolean pango_layout_get_single_paragraph_mode (PangoLayout void pango_layout_set_ellipsize (PangoLayout *layout, PangoEllipsizeMode ellipsize); PangoEllipsizeMode pango_layout_get_ellipsize (PangoLayout *layout); +gboolean pango_layout_is_ellipsized (PangoLayout *layout); void pango_layout_context_changed (PangoLayout *layout); diff --git a/pango/pango.def b/pango/pango.def index 7b3aa3ec..3ea0951e 100644 --- a/pango/pango.def +++ b/pango/pango.def @@ -238,6 +238,7 @@ EXPORTS pango_layout_get_wrap pango_layout_index_to_line_x pango_layout_index_to_pos + pango_layout_is_ellipsized pango_layout_iter_at_last_line pango_layout_iter_free pango_layout_iter_get_baseline |