[Splashy-devel] Patch: Border operations.

Pat Suwalski pats at xandros.com
Fri Feb 24 21:55:34 UTC 2006


Hello,

The attached patch does the following:
* Allows for specifying the colour of the progress border
* Draws border 1 pixel outside of progress bar
    (does not get overdrawn by progress bar)
* Fixes spelling of "rectangle" :)

The new way of specifying a border is:
<border>
   <red></red>
   <green></green>
   <blue></blue>
   <alpha></alpha>
</border>

If they are not specified correctly, no border is drawn. This makes 
sense, IMO.

Other things on my patch wishlist:
* Ability to specify pixel-precise progressbar placement
   (if <sourcewidth> given, use <x>/<sourcewidth>*<screenwidth>
   instead of <x>/100*<screenwidth>).
* Invividual line printing (already done, very basically)

We just made a nice in-house theme using this patch, and it looks great!

--Pat
-------------- next part --------------
--- ./video.c	2005-12-29 03:51:11.000000000 -0500
+++ ./video.c	2006-02-24 16:27:29.000000000 -0500
@@ -144,12 +148,8 @@
 video_draw_progressbar (splashy_video_t * video, DFBRectangle * progressbar)
 {
         gint screen_width, screen_height;
-        guint retangle_red, retangle_green, retangle_blue, retangle_alpha;
+        guint rectangle_red, rectangle_green, rectangle_blue, rectangle_alpha;
         
-        const gchar * draw_progress = xml_parser_get_text ("/splashy/progressbar/border");
-        gboolean draw_progress_border = ( draw_progress && g_ascii_strncasecmp(draw_progress,"yes",3) == 0 ) ? TRUE : FALSE;
-
-        DEBUG_PRINT("Printing progress border: %s",draw_progress_border);
         video->surface->GetSize (video->surface, &screen_width, &screen_height);
 
         progressbar->x = screen_width *
@@ -168,43 +168,69 @@
                 return 1;
         }
 
-        if ( draw_progress_border == TRUE )
-        {
-                DEBUG_PRINT ("draw x = %d", progressbar->x);
-                DEBUG_PRINT ("draw y = %d", progressbar->y);
-                DEBUG_PRINT ("draw w = %d", progressbar->w);
-                DEBUG_PRINT ("draw h = %d", progressbar->h);
+        /* Check progress bar border colours. Assume we want a border if they
+         * are all properly specified. */
+        rectangle_red = xml_parser_get_int ("/splashy/progressbar/border/red", 10);
+        rectangle_green = xml_parser_get_int ("/splashy/progressbar/border/green", 10);
+        rectangle_blue = xml_parser_get_int ("/splashy/progressbar/border/blue", 10);
+        rectangle_alpha = xml_parser_get_int ("/splashy/progressbar/border/alpha", 10);
+
+        if (!(rectangle_red > 255 || rectangle_green > 255 ||
+                rectangle_blue > 255 || rectangle_alpha > 255)) 
+        {
+                DEBUG_PRINT ("border draw: x = %d", progressbar->x);
+                DEBUG_PRINT ("border draw: y = %d", progressbar->y);
+                DEBUG_PRINT ("border draw: w = %d", progressbar->w);
+                DEBUG_PRINT ("border draw: h = %d", progressbar->h);
+                DEBUG_PRINT ("border color: red = %d", rectangle_red);
+                DEBUG_PRINT ("border color: green = %d", rectangle_green);
+                DEBUG_PRINT ("border color: blue = %d", rectangle_blue);
+                DEBUG_PRINT ("border color: alpha = %d", rectangle_alpha);
+        
+                video->surface->SetColor (video->surface,
+                                rectangle_red, rectangle_green,
+                                rectangle_blue, rectangle_alpha);
 
+                /* Draw border so that it is one pixel around the bar */
                 video->surface->DrawRectangle (video->surface,
-                                progressbar->x,
-                                progressbar->y,
-                                progressbar->w, progressbar->h);
+                                progressbar->x-1, progressbar->y-1,
+                                progressbar->w+2, progressbar->h+2);
         }
-        retangle_red = xml_parser_get_int ("/splashy/progressbar/red", 10);
-        retangle_green =
+        else if (rectangle_red < 0 || rectangle_green < 0 ||
+                rectangle_blue < 0 || rectangle_alpha < 0)
+        {
+                g_print ("ERROR: Progress bar border colour not properly specified.");
+        }
+        else
+        {
+                DEBUG_PRINT ("No progress bar border specified.%s", "");
+        }
+
+        rectangle_red = xml_parser_get_int ("/splashy/progressbar/red", 10);
+        rectangle_green =
                 xml_parser_get_int ("/splashy/progressbar/green", 10);
-        retangle_blue = xml_parser_get_int ("/splashy/progressbar/blue", 10);
-        retangle_alpha =
+        rectangle_blue = xml_parser_get_int ("/splashy/progressbar/blue", 10);
+        rectangle_alpha =
                 xml_parser_get_int ("/splashy/progressbar/alpha", 10);
 
         /*
          * set the filling color of the progressbar to be used by video_update_progress()
          */
-        if (retangle_red > 255 ||
-                        retangle_green > 255 ||
-                        retangle_blue > 255 || retangle_alpha > 255)
+        if (rectangle_red > 255 ||
+                        rectangle_green > 255 ||
+                        rectangle_blue > 255 || rectangle_alpha > 255)
         {
                 g_print ("ERROR: red, green, blue or alpha tags in the configuration file contain wrong values");
                 return 3;
         }
-        DEBUG_PRINT ("draw red   = %d", retangle_red);
-        DEBUG_PRINT ("draw green = %d", retangle_green);
-        DEBUG_PRINT ("draw blue  = %d", retangle_blue);
-        DEBUG_PRINT ("draw alpha = %d", retangle_alpha);
+        DEBUG_PRINT ("draw red   = %d", rectangle_red);
+        DEBUG_PRINT ("draw green = %d", rectangle_green);
+        DEBUG_PRINT ("draw blue  = %d", rectangle_blue);
+        DEBUG_PRINT ("draw alpha = %d", rectangle_alpha);
         video->surface->SetColor (video->surface,
-                        retangle_red,
-                        retangle_green,
-                        retangle_blue, retangle_alpha);
+                        rectangle_red,
+                        rectangle_green,
+                        rectangle_blue, rectangle_alpha);
         return 0;
 }
 


More information about the Splashy-devel mailing list