Hi,

attached patch implement wrapping feature setup for Pango producer

--
Maksym Veremeyenko

From 338eb0889125e39a8cd26c8c5077e14e9df8e60f Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko <ve...@m1.tv>
Date: Sat, 20 Feb 2016 19:43:03 +0200
Subject: [PATCH] Wrapping customizing implemented.

---
 src/modules/gtk2/producer_pango.c   |   24 ++++++++++++++++++++----
 src/modules/gtk2/producer_pango.yml |   25 +++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/src/modules/gtk2/producer_pango.c 
b/src/modules/gtk2/producer_pango.c
index d0972b8..77de18f 100644
--- a/src/modules/gtk2/producer_pango.c
+++ b/src/modules/gtk2/producer_pango.c
@@ -84,6 +84,8 @@ struct producer_pango_s
        int   width_crop;
        int   width_fit;
        double aspect_ratio;
+       int   wrap_width;
+       int   wrap_type;
 };
 
 static void clean_cached( producer_pango self )
@@ -104,7 +106,7 @@ static void pango_draw_background( GdkPixbuf *pixbuf, 
rgba_color bg );
 static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, 
const char *font,
                rgba_color fg, rgba_color bg, rgba_color ol, int pad, int 
align, char* family,
                int style, int weight, int size, int outline, int rotate, int 
width_crop, int width_fit,
-               double aspect_ratio );
+               double aspect_ratio, int wrap_width, int wrap_type );
 static void fill_pixbuf( GdkPixbuf* pixbuf, FT_Bitmap* bitmap, int w, int h, 
int pad, int align, rgba_color fg, rgba_color bg );
 static void fill_pixbuf_with_outline( GdkPixbuf* pixbuf, FT_Bitmap* bitmap, 
int w, int h, int pad, int align, rgba_color fg, rgba_color bg, rgba_color ol, 
int outline );
 
@@ -406,6 +408,8 @@ static void refresh_image( mlt_frame frame, int width, int 
height )
        int width_crop = mlt_properties_get_int( producer_props, "width_crop" );
        int width_fit = mlt_properties_get_int( producer_props, "width_fit" );
        double aspect_ratio = mlt_properties_get_double( properties, 
"aspect_ratio" );
+       int wrap_width = mlt_properties_get_int( producer_props, "wrap_width" );
+       int wrap_type = mlt_properties_get_int( producer_props, "wrap_type" );
        int property_changed = 0;
 
        if ( pixbuf == NULL )
@@ -459,6 +463,8 @@ static void refresh_image( mlt_frame frame, int width, int 
height )
                this->width_crop = width_crop;
                this->width_fit = width_fit;
                this->aspect_ratio = aspect_ratio;
+               this->wrap_width = wrap_width;
+               this->wrap_type = wrap_type;
        }
 
        if ( pixbuf == NULL && property_changed )
@@ -490,7 +496,7 @@ static void refresh_image( mlt_frame frame, int width, int 
height )
                // Render the title
                pixbuf = pango_get_pixbuf( markup, text, font, fgcolor, 
bgcolor, olcolor, pad, align, family,
                        style, weight, size, outline, rotate, width_crop, 
width_fit,
-                       aspect_ratio );
+                       aspect_ratio, wrap_width, wrap_type );
 
                if ( pixbuf != NULL )
                {
@@ -759,7 +765,10 @@ static void pango_draw_background( GdkPixbuf *pixbuf, 
rgba_color bg )
        }
 }
 
-static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, 
const char *font, rgba_color fg, rgba_color bg, rgba_color ol, int pad, int 
align, char* family, int style, int weight, int size, int outline, int rotate, 
int width_crop, int width_fit, double aspect_ratio )
+static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, 
const char *font,
+               rgba_color fg, rgba_color bg, rgba_color ol, int pad, int 
align, char* family,
+               int style, int weight, int size, int outline, int rotate, int 
width_crop, int width_fit,
+               double aspect_ratio, int wrap_width, int wrap_type )
 {
        PangoContext *context = pango_ft2_font_map_create_context( fontmap );
        PangoLayout *layout = pango_layout_new( context );
@@ -784,7 +793,14 @@ static GdkPixbuf *pango_get_pixbuf( const char *markup, 
const char *text, const
 
        pango_font_description_set_weight( desc, ( PangoWeight ) weight  );
 
-       pango_layout_set_width( layout, -1 ); // set wrapping constraints
+       // set wrapping constraints
+       if ( wrap_width <= 0 )
+               pango_layout_set_width( layout, -1 );
+       else
+       {
+               pango_layout_set_width( layout,  PANGO_SCALE * wrap_width );
+               pango_layout_set_wrap( layout,  ( PangoWrapMode ) wrap_type );
+       }
        pango_layout_set_font_description( layout, desc );
        pango_layout_set_alignment( layout, ( PangoAlignment ) align  );
        if ( markup != NULL && strcmp( markup, "" ) != 0 )
diff --git a/src/modules/gtk2/producer_pango.yml 
b/src/modules/gtk2/producer_pango.yml
index d6e1ab9..c5955e8 100644
--- a/src/modules/gtk2/producer_pango.yml
+++ b/src/modules/gtk2/producer_pango.yml
@@ -253,3 +253,28 @@ parameters:
     readonly: no
     mutable: yes
     widget: spinner
+
+  - identifier: wrap_width
+    title: Sets the width to wrap to
+    type: integer
+    description: >
+      Sets the width to which the lines of the PangoLayout should wrap.
+    default: 0
+    readonly: no
+    mutable: yes
+    widget: spinner
+
+  - identifier: wrap_type
+    title: Sets the wrap mode
+    type: integer
+    description: >
+      Sets the wrap mode; the wrap mode only has effect if a 'wrap_width' is 
set.
+      Possible values:
+          0 - wrap lines at word boundaries
+          1 - wrap lines at character boundaries
+          2 - wrap lines at word boundaries, but fall back to character
+              boundaries if there is not enough space for a full word
+    default: 0
+    readonly: no
+    mutable: yes
+    widget: spinner
-- 
1.7.1

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to