diff -ur clearlooks.orig/src/clearlooks_draw.c clearlooks/src/clearlooks_draw.c --- clearlooks.orig/src/clearlooks_draw.c 2005-10-30 16:35:01.000000000 +0100 +++ clearlooks/src/clearlooks_draw.c 2005-11-02 14:09:44.000000000 +0100 @@ -333,7 +333,7 @@ 1.0, params->corners); cairo_set_source_rgba (cr, colors->spot[1].r, colors->spot[1].g, colors->spot[1].b, 0.7 ); cairo_stroke (cr); -*/ + /* cairo_move_to (cr, 2.5, 2); cairo_line_to (cr, width-3.5, 2); @@ -475,6 +475,32 @@ cairo_stroke (cr); } +#ifdef HAVE_ANIMATION +static void +clearlooks_scale_draw_gradient_alpha (cairo_t *cr, + const CairoColor *c1, + const CairoColor *c2, + const CairoColor *c3, + int x, int y, int width, int height, + boolean horizontal, + const double alpha) +{ + cairo_pattern_t *pattern; + + pattern = cairo_pattern_create_linear (0, 0, horizontal ? 0 : width, horizontal ? height : 0); + cairo_pattern_add_color_stop_rgba (pattern, 0.0, c1->r, c1->g, c1->b,alpha); + cairo_pattern_add_color_stop_rgba (pattern, 1.0, c2->r, c2->g, c2->b,alpha); + + cairo_rectangle (cr, x+0.5, y+0.5, width-1, height-1); + cairo_set_source (cr, pattern); + cairo_fill (cr); + + cairo_rectangle (cr, x, y, width, height); + cairo_set_source_rgb (cr, c3->r, c3->g, c3->b); + cairo_stroke (cr); +} +#endif + #define TROUGH_SIZE 6 void clearlooks_draw_scale_trough (cairo_t *cr, @@ -486,6 +512,9 @@ int fill_x, fill_y, fill_width, fill_height; /* Fill x,y,w,h */ int trough_width, trough_height; double translate_x, translate_y; +#ifdef HAVE_ANIMATION + double tran; +#endif int fill_size = slider->fill_size; if (slider->horizontal) @@ -523,21 +552,35 @@ cairo_set_line_width (cr, 1.0); cairo_translate (cr, translate_x, translate_y); - clearlooks_draw_inset (cr, trough_width+2, trough_height+2, 0, 0); cairo_translate (cr, 1, 1); - clearlooks_scale_draw_gradient (cr, &colors->shade[3], /* top */ - &colors->shade[2], /* bottom */ - &colors->shade[6], /* border */ + + clearlooks_scale_draw_gradient (cr, &colors->shade[3], + &colors->shade[2], + &colors->shade[6], 0, 0, trough_width, trough_height, slider->horizontal); - - clearlooks_scale_draw_gradient (cr, &colors->spot[1], /* top */ - &colors->spot[0], /* bottom */ - &colors->spot[2], /* border */ +#ifdef HAVE_ANIMATION + //calculate transparency + if (slider->horizontal) + tran = (float)fill_width/width; + else + tran = (float)fill_height/height; + if (tran<0.2) + tran = 0.2; + clearlooks_scale_draw_gradient_alpha (cr, &colors->spot[1], + &colors->spot[0], + &colors->spot[2], + fill_x, fill_y, fill_width, fill_height, + slider->horizontal,tran); +#else + clearlooks_scale_draw_gradient (cr, &colors->spot[1], + &colors->spot[0], + &colors->spot[2], fill_x, fill_y, fill_width, fill_height, slider->horizontal); +#endif } void @@ -680,11 +723,12 @@ const ClearlooksColors *colors, const WidgetParameters *params, const ProgressBarParameters *progressbar, - int x, int y, int width, int height) + int x, int y, int width, int height, gint offset) { boolean is_horizontal = progressbar->orientation < 2; double tile_pos = 0; double stroke_width; + int x_step; cairo_pattern_t *pattern; CairoColor shade1; @@ -712,7 +756,8 @@ } stroke_width = height*2; - + x_step = (((float)stroke_width/10)*offset); + cairo_set_line_width (cr, 1.0); cairo_save (cr); @@ -735,13 +780,13 @@ cairo_fill (cr); /* Draw strokes */ - while (tile_pos <= width) + while (tile_pos <= width+x_step) { - cairo_move_to (cr, stroke_width/2, 0); - cairo_line_to (cr, stroke_width, 0); - cairo_line_to (cr, stroke_width/2, height); - cairo_line_to (cr, 0, height); - + cairo_move_to (cr, stroke_width/2-x_step, 0); + cairo_line_to (cr, stroke_width-x_step, 0); + cairo_line_to (cr, stroke_width/2-x_step, height); + cairo_line_to (cr, -x_step, height); + cairo_translate (cr, stroke_width, 0); tile_pos += stroke_width; } @@ -765,7 +810,7 @@ cairo_set_source (cr, pattern); cairo_rectangle (cr, 0, 0, 3, height); cairo_fill (cr); - cairo_pattern_destroy (pattern); + cairo_pattern_destroy (pattern); /* End of bar line */ cairo_move_to (cr, -0.5, 0); diff -ur clearlooks.orig/src/clearlooks_draw.h clearlooks/src/clearlooks_draw.h --- clearlooks.orig/src/clearlooks_draw.h 2005-09-12 19:31:09.000000000 +0200 +++ clearlooks/src/clearlooks_draw.h 2005-11-01 21:25:26.000000000 +0100 @@ -29,7 +29,7 @@ const ClearlooksColors *colors, const WidgetParameters *widget, const ProgressBarParameters *progressbar, - int x, int y, int width, int height); + int x, int y, int width, int height, gint offset); void clearlooks_draw_slider_button (cairo_t *cr, const ClearlooksColors *colors, diff -ur clearlooks.orig/src/clearlooks_style.c clearlooks/src/clearlooks_style.c --- clearlooks.orig/src/clearlooks_style.c 2005-10-30 16:35:01.000000000 +0100 +++ clearlooks/src/clearlooks_style.c 2005-11-02 19:20:33.000000000 +0100 @@ -32,6 +32,13 @@ gint width, \ gint height +static GList *progressbars = NULL; +static GList *checks = NULL; +static gint8 pboffset = 10; +static gint8 checks_trans = 2; +static int timer_id = 0; +static int checks_timer_id = 0; + static GtkStyleClass *parent_class; static cairo_t * @@ -50,6 +57,124 @@ return cr; } +#ifdef HAVE_ANIMATION +static void cl_progressbar_remove (gpointer data) +{ + if (g_list_find (progressbars, data) == NULL) + return; + + progressbars = g_list_remove (progressbars, data); + g_object_unref (data); + + if (g_list_first(progressbars) == NULL) { + g_source_remove(timer_id); + timer_id = 0; + } +} + +static void update_progressbar (gpointer data, gpointer user_data) +{ + gfloat fraction; + + if (data == NULL) + return; + + fraction = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (data)); + + /* update only if not filled */ + if (fraction < 1.0) + gtk_widget_queue_resize ((GtkWidget*)data); + + if (fraction >= 1.0 || GTK_PROGRESS (data)->activity_mode) + cl_progressbar_remove (data); +} + +static gboolean timer_func (gpointer data) +{ + g_list_foreach (progressbars, update_progressbar, NULL); + if (--pboffset < 0) pboffset = 9; + return (g_list_first(progressbars) != NULL); +} + +static gboolean cl_progressbar_known(gconstpointer data) +{ + return (g_list_find (progressbars, data) != NULL); +} + +static void cl_progressbar_add (gpointer data) +{ + if (!GTK_IS_PROGRESS_BAR (data)) + return; + + progressbars = g_list_append (progressbars, data); + + g_object_ref (data); + g_signal_connect ((GObject*)data, "unrealize", G_CALLBACK (cl_progressbar_remove), data); + + if (timer_id == 0) + timer_id = g_timeout_add (100, timer_func, NULL); +} + +static void cl_checks_remove (gpointer data) +{ + if (g_list_find (checks, data) == NULL) + return; + + checks = g_list_remove (checks, data); + g_object_unref (data); + if (g_list_first(checks) == NULL) { + g_source_remove(checks_timer_id); + checks_timer_id = 0; + } +} + +static void cl_update_checks (gpointer data, gpointer user_data) +{ + if (data == NULL) + return; + if (checks_trans > 10) + cl_checks_remove(data); + + gtk_widget_queue_resize ((GtkWidget*)data); +} + +static gboolean cl_checks_known(gconstpointer data) +{ + return (g_list_find (checks, data) != NULL); +} + +static gboolean cl_checks_timer_func (gpointer data) +{ + g_list_foreach (checks, cl_update_checks, NULL); + + if (++checks_trans > 11) + checks_trans = 2; + return (g_list_first(checks) != NULL); +} + +static void cl_checks_add (gpointer data) +{ + if (!GTK_IS_CHECK_BUTTON (data)) + return; + + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data))) + checks_trans = 2; + else + return; + + if(!cl_checks_known(data)) + checks = g_list_append (checks, data); + else + return; + + g_object_ref (data); + g_signal_connect ((GObject*)data, "unrealize", G_CALLBACK (cl_checks_remove), data); + if (checks_timer_id == 0) + checks_timer_id = g_timeout_add (100, cl_checks_timer_func, NULL); +} + +#endif + static void clearlooks_set_widget_parameters (const GtkWidget *widget, const GtkStyle *style, @@ -573,6 +698,14 @@ WidgetParameters params; ProgressBarParameters progressbar; + gboolean activity_mode = GTK_PROGRESS (widget)->activity_mode; +#ifdef HAVE_ANIMATION + if (!activity_mode && gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (widget)) != 1.0 && + !cl_progressbar_known((gconstpointer)widget)) + { + cl_progressbar_add ((gpointer)widget); + } +#endif clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); if (widget && GTK_IS_PROGRESS_BAR (widget)) @@ -583,7 +716,7 @@ cairo_reset_clip (cr); clearlooks_draw_progressbar_fill (cr, colors, ¶ms, &progressbar, - x, y, width, height); + x, y, width, height, pboffset); } else if (DETAIL ("hscale") || DETAIL ("vscale")) @@ -792,10 +925,18 @@ ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); CairoColor *border; CairoColor *dot; +#ifdef HAVE_ANIMATION + double trans; +#endif cairo_t *cr = clearlooks_begin_paint (window, area); cairo_pattern_t *pt; +#ifdef HAVE_ANIMATION + if (!cl_checks_known((gconstpointer)widget)) + g_signal_connect ((GObject*)widget, "toggled", G_CALLBACK (cl_checks_add), widget); +#endif + if (state_type == GTK_STATE_INSENSITIVE) { border = &clearlooks_style->colors.shade[2]; @@ -842,7 +983,15 @@ cairo_curve_to (cr, 0.5 + (width*0.4), (height*0.7), 0.5 + (width*0.5), (height*0.4), 0.5 + (width*0.70), (height*0.25)); +#ifdef HAVE_ANIMATION + if ((checks_trans > 9)||(!cl_checks_known((gconstpointer)widget))) + trans = 1; + else + trans = (float)checks_trans/10; + cairo_set_source_rgba (cr, dot->r, dot->g, dot->b, trans); +#else cairo_set_source_rgb (cr, dot->r, dot->g, dot->b); +#endif cairo_stroke (cr); }