[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Nodoka rounded corners for the gtk progress bar



I made a small patch to give the progress bar rounded corners.
Before: http://home.brej.org/test/1.png
After:  http://home.brej.org/test/2.png

diff --git a/trunk/gtk-nodoka-engine/src/GTKEngine/nodoka_draw.c b/trunk/gtk-nodoka-engine/src/GTKEngine/nodoka_draw.c
index e3647aa..6a2bb06 100644
--- a/trunk/gtk-nodoka-engine/src/GTKEngine/nodoka_draw.c
+++ b/trunk/gtk-nodoka-engine/src/GTKEngine/nodoka_draw.c
@@ -554,15 +554,29 @@ nodoka_draw_progressbar_trough (cairo_t * cr, const NodokaColors * colors,
 	NodokaRGB *border = (NodokaRGB *) & colors->shade[3];
 	NodokaRGB *fill = (NodokaRGB *) & colors->bg[widget->state_type];
 
+	cairo_rectangle (cr, -0.5, -0.5, width, height);
+	cairo_set_source_rgb (cr, widget->parentbg.r, widget->parentbg.g,
+						  widget->parentbg.b);
+	cairo_fill (cr);
+    
 	cairo_set_line_width (cr, 1.0);
 
 	/* Fill with bg color */
 	cairo_set_source_rgb (cr, fill->r, fill->g, fill->b);
-	cairo_rectangle (cr, x, y, width, height);
+    if (widget->corners == NDK_CORNER_NONE)
+		cairo_rectangle (cr, x, y, width, height);
+	else
+		nodoka_rounded_rectangle (cr, x, y, width, height,
+								  widget->roundness+1, widget->corners);
 	cairo_fill (cr);
 
 	/* Draw border */
-	cairo_rectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1);
+    if (widget->corners == NDK_CORNER_NONE)
+		cairo_rectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1);
+	else
+		nodoka_rounded_rectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1,
+								  widget->roundness+1, widget->corners);
+    
 	cairo_set_source_rgba (cr, border->r, border->g, border->b, 0.8);
 	cairo_stroke (cr);
 
@@ -589,7 +603,11 @@ nodoka_draw_progressbar_fill (cairo_t * cr, const NodokaColors * colors,
 	NodokaRGB *fill = (NodokaRGB *) & colors->spot[1];
 	NodokaRGB *border = (NodokaRGB *) & colors->spot[2];
 
-	cairo_rectangle (cr, x, y, width, height);
+    if (widget->corners == NDK_CORNER_NONE)
+		cairo_rectangle (cr, x, y, width, height);
+	else
+		nodoka_rounded_rectangle (cr, x, y, width, height,
+								  widget->roundness, widget->corners);
 
 	if (is_horizontal)
 	{
@@ -625,7 +643,12 @@ nodoka_draw_progressbar_fill (cairo_t * cr, const NodokaColors * colors,
 	cairo_save (cr);
 
 	/* Draw fill */
-	cairo_rectangle (cr, 2, 1, width - 4, height - 2);
+    if (widget->corners == NDK_CORNER_NONE)
+		cairo_rectangle (cr, 2, 1, width - 4, height - 2);
+	else
+		nodoka_rounded_rectangle (cr, 2, 1, width - 4, height - 2,
+								  widget->roundness, widget->corners);
+
 	nodoka_set_grad_full (cr, fill, DARK_TOP_HILIGHT, DARK_BOTTOM_HILIGHT,
 						  GRADIENT_CENTER, 0, height, widget->gradients, FALSE,
 						  1.0);
@@ -654,7 +677,11 @@ nodoka_draw_progressbar_fill (cairo_t * cr, const NodokaColors * colors,
 
 	//border
 	cairo_set_source_rgba (cr, border->r, border->g, border->b, 0.8);
-	cairo_rectangle (cr, 1.5, 0.5, width - 3, height - 1);
+    if (widget->corners == NDK_CORNER_NONE)
+		cairo_rectangle (cr, 1.5, 0.5, width - 3, height - 1);
+	else
+		nodoka_rounded_rectangle (cr, 1.5, 0.5, width - 3, height - 1,
+								  widget->roundness, widget->corners);
 	cairo_stroke (cr);
 }
 
diff --git a/trunk/gtk-nodoka-engine/src/GTKEngine/nodoka_style.c b/trunk/gtk-nodoka-engine/src/GTKEngine/nodoka_style.c
index 525359e..b9036ce 100644
--- a/trunk/gtk-nodoka-engine/src/GTKEngine/nodoka_style.c
+++ b/trunk/gtk-nodoka-engine/src/GTKEngine/nodoka_style.c
@@ -635,6 +635,11 @@ nodoka_style_draw_box (DRAW_ARGS)
 	else if (DETAIL ("trough") && widget && GTK_IS_PROGRESS_BAR (widget))
 	{
 		WidgetParameters params;
+		params.roundness = nodoka_style->roundness;
+		if (nodoka_style->roundness > 0)
+			params.corners = NDK_CORNER_ALL;
+		else
+			params.corners = NDK_CORNER_NONE;
 
 		nodoka_set_widget_parameters (widget, style, state_type, &params);
 
@@ -682,6 +687,12 @@ nodoka_style_draw_box (DRAW_ARGS)
 		WidgetParameters params;
 		ProgressBarParameters progressbar;
 		gdouble elapsed = 0.0;
+        
+		params.roundness = nodoka_style->roundness;
+		if (nodoka_style->roundness > 0)
+			params.corners = NDK_CORNER_ALL;
+		else
+			params.corners = NDK_CORNER_NONE;
 
 #ifdef HAVE_ANIMATION
 		if (nodoka_style->animation && NDK_IS_PROGRESS_BAR (widget))

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]