]> git.sesse.net Git - mlt/commitdiff
Add support for HTML style color parameter to producer_pango.
authorBrian Matherly <pez4brian@yahoo.com>
Mon, 26 Sep 2011 03:40:51 +0000 (22:40 -0500)
committerBrian Matherly <pez4brian@yahoo.com>
Mon, 26 Sep 2011 03:40:51 +0000 (22:40 -0500)
producer_color and producer_pango now work exactly the same
WRT color parameters.

src/modules/gtk2/filter_dynamictext.yml
src/modules/gtk2/producer_pango.c
src/modules/gtk2/producer_pango.yml

index 9356f60ce79d1db88298c814fe59ef22df869614..658f13946c379ee35acc15d05f30c775fc041588 100644 (file)
@@ -57,7 +57,10 @@ parameters:
   - identifier: fgcolour
     title: Foreground color
     type: string
-    description: an RGBA colour specification of the text (i.e. 0xrrggbbaa)
+    description: >
+      A color value is a hexadecimal representation of RGB plus alpha channel 
+      as 0xrrggbbaa. Colors can also be the words: white, black, red, green,
+      or blue. You can also use a HTML-style color values #rrggbb or #aarrggbb.
     default: 0x000000ff
     readonly: no
     mutable: yes
@@ -65,7 +68,10 @@ parameters:
   - identifier: bgcolour
     title: Background color
     type: string
-    description: an RGBA colour of the background rectangle (i.e. 0xrrggbbaa)
+    description: >
+      A color value is a hexadecimal representation of RGB plus alpha channel 
+      as 0xrrggbbaa. Colors can also be the words: white, black, red, green,
+      or blue. You can also use a HTML-style color values #rrggbb or #aarrggbb.
     default: 0x00000020
     readonly: no
     mutable: yes
index 0988715dcd539f24cac8d410fc607fb003d01725..e1bff5d43bba5a0f79942689c98eb0994752b772 100644 (file)
@@ -241,20 +241,11 @@ static void set_string( char **string, const char *value, const char *fallback )
        }
 }
 
-rgba_color parse_color( char *color )
+rgba_color parse_color( char *color, unsigned int color_int )
 {
        rgba_color result = { 0xff, 0xff, 0xff, 0xff };
 
-       if ( !strncmp( color, "0x", 2 ) )
-       {
-               unsigned int temp = 0;
-               sscanf( color + 2, "%x", &temp );
-               result.r = ( temp >> 24 ) & 0xff;
-               result.g = ( temp >> 16 ) & 0xff;
-               result.b = ( temp >> 8 ) & 0xff;
-               result.a = ( temp ) & 0xff;
-       }
-       else if ( !strcmp( color, "red" ) )
+       if ( !strcmp( color, "red" ) )
        {
                result.r = 0xff;
                result.g = 0x00;
@@ -272,14 +263,12 @@ rgba_color parse_color( char *color )
                result.g = 0x00;
                result.b = 0xff;
        }
-       else
+       else if ( strcmp( color, "white" ) )
        {
-               unsigned int temp = 0;
-               sscanf( color, "%d", &temp );
-               result.r = ( temp >> 24 ) & 0xff;
-               result.g = ( temp >> 16 ) & 0xff;
-               result.b = ( temp >> 8 ) & 0xff;
-               result.a = ( temp ) & 0xff;
+               result.r = ( color_int >> 24 ) & 0xff;
+               result.g = ( color_int >> 16 ) & 0xff;
+               result.b = ( color_int >> 8 ) & 0xff;
+               result.a = ( color_int ) & 0xff;
        }
 
        return result;
@@ -383,8 +372,8 @@ static void refresh_image( mlt_frame frame, int width, int height )
 
        if ( pixbuf == NULL && property_changed )
        {
-               rgba_color fgcolor = parse_color( this->fgcolor );
-               rgba_color bgcolor = parse_color( this->bgcolor );
+               rgba_color fgcolor = parse_color( this->fgcolor, mlt_properties_get_int( producer_props, "fgcolour" ) );
+               rgba_color bgcolor = parse_color( this->bgcolor, mlt_properties_get_int( producer_props, "bgcolour" ) );
 
                if ( this->pixbuf )
                        g_object_unref( this->pixbuf );
index b63982d93916929b006644a2dfcea3fd2bafae38..889120cdabfaf71d26deac7aabe2286e57c0c853 100644 (file)
@@ -53,7 +53,10 @@ parameters:
   - identifier: fgcolour
     title: Foreground color
     type: string
-    description: an RGBA colour specification of the text (i.e. 0xrrggbbaa)
+    description: >
+      A color value is a hexadecimal representation of RGB plus alpha channel 
+      as 0xrrggbbaa. Colors can also be the words: white, black, red, green,
+      or blue. You can also use a HTML-style color values #rrggbb or #aarrggbb.
     readonly: no
     mutable: yes
     widget: color
@@ -61,7 +64,10 @@ parameters:
   - identifier: bgcolour
     title: Background color
     type: string
-    description: an RGBA colour of the background rectangle (i.e. 0xrrggbbaa)
+    description: >
+      A color value is a hexadecimal representation of RGB plus alpha channel 
+      as 0xrrggbbaa. Colors can also be the words: white, black, red, green,
+      or blue. You can also use a HTML-style color values #rrggbb or #aarrggbb.
     readonly: no
     mutable: yes
     widget: color