=== modified file 'data/awn.schema-ini.in' --- data/awn.schema-ini.in 2008-07-07 20:22:50 +0000 +++ data/awn.schema-ini.in 2008-07-28 16:23:56 +0000 @@ -110,6 +110,14 @@ type = int default = 10 description = The number of pixels between the bottom of the icons and the bottom of the dock. +[bar/reflection_offset] +type = int +default = 0 +description = The number of pixels the reflections are moved up. +[bar/bar_depth_scale] +type = int +default = 1 +description = Scale-factor for the bar-depth in 3d-look. [bar/bar_pos] type = float default = 0.5 @@ -176,6 +184,10 @@ type = bool default = TRUE description = Enable dept on 3d type effects. +[app/show_shadows] +type = bool +default = False +description = Shows shadows for the icons. [title/text_color] type = string default = FFFFFFFF === modified file 'libawn/awn-effects.c' (properties changed: -x to +x) --- libawn/awn-effects.c 2008-07-04 03:47:24 +0000 +++ libawn/awn-effects.c 2008-07-28 16:04:29 +0000 @@ -700,6 +700,266 @@ } } +void +darken_surface(cairo_surface_t *src) +{ + int width, height, row_stride; + guchar *pixsrc, *target_pixels; + cairo_surface_t *temp_srfc; + cairo_t *temp_ctx; + + temp_srfc = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, + cairo_xlib_surface_get_width(src), + cairo_xlib_surface_get_height(src) + ); + temp_ctx = cairo_create(temp_srfc); + cairo_set_operator(temp_ctx,CAIRO_OPERATOR_SOURCE); + cairo_set_source_surface(temp_ctx, src, 0, 0); + cairo_paint(temp_ctx); + + width = cairo_image_surface_get_width(temp_srfc); + height = cairo_image_surface_get_height(temp_srfc); + row_stride = cairo_image_surface_get_stride(temp_srfc); + target_pixels = cairo_image_surface_get_data(temp_srfc); + + // darken + int i, j; + for (i = 0; i < height; i++) { + pixsrc = target_pixels + i * row_stride; + for (j = 0; j < width; j++) { + *pixsrc = 0; + pixsrc++; + *pixsrc = 0; + pixsrc++; + *pixsrc = 0; + pixsrc++; + // alpha + pixsrc++; + } + } + + // -- + + cairo_destroy(temp_ctx); + + temp_ctx = cairo_create(src); + cairo_set_operator(temp_ctx,CAIRO_OPERATOR_SOURCE); + g_assert( cairo_get_operator(temp_ctx) == CAIRO_OPERATOR_SOURCE); + cairo_set_source_surface(temp_ctx, temp_srfc, 0, 0); + cairo_paint(temp_ctx); + cairo_surface_destroy(temp_srfc); + cairo_destroy(temp_ctx); +} +/* +void +blur_surface(cairo_surface_t *src, const int radius) +{ + guchar * pixdest, * target_pixels_dest, * target_pixels, * pixsrc; + cairo_surface_t * temp_srfc, * temp_srfc_dest; + cairo_t * temp_ctx, * temp_ctx_dest; + + g_return_if_fail(src); + int width = cairo_xlib_surface_get_width(src); + int height = cairo_xlib_surface_get_height(src); + + // the original stuff + temp_srfc = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); + temp_ctx = cairo_create(temp_srfc); + cairo_set_operator(temp_ctx,CAIRO_OPERATOR_SOURCE); + cairo_set_source_surface(temp_ctx, src, 0, 0); + cairo_paint(temp_ctx); + + // the stuff we draw to + temp_srfc_dest = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); + temp_ctx_dest = cairo_create(temp_srfc_dest); + //--- + + int row_stride = cairo_image_surface_get_stride(temp_srfc); + target_pixels = cairo_image_surface_get_data(temp_srfc); + target_pixels_dest = cairo_image_surface_get_data(temp_srfc_dest); + + // -- blur --- + int total_r, total_g, total_b, total_a; + int x, y, kx, ky; + + for (y = 0; y < height; ++y) + { + for (x = 0; x < width; ++x) + { + total_r = total_g = total_b = total_a = 0; + + for (ky = -radius; ky <= radius; ++ky) { + if ((y+ky)>0 && (y+ky)0 && (x+kx) 0) { + pixsrc -= 3; + total_r += *pixsrc; pixsrc++; + total_g += *pixsrc; pixsrc++; + total_b += *pixsrc; pixsrc++; + total_a += *pixsrc; + } + } + } + } + } + + total_r /= pow((radius<<1)|1,2); + total_g /= pow((radius<<1)|1,2); + total_b /= pow((radius<<1)|1,2); + total_a /= pow((radius<<1)|1,2); + + pixdest = (target_pixels_dest + y * row_stride); + pixdest += x*4; + + *pixdest = (guchar) total_r; pixdest++; + *pixdest = (guchar) total_g; pixdest++; + *pixdest = (guchar) total_b; pixdest++; + *pixdest = (guchar) total_a; + } + } + //---------- + + cairo_set_operator(temp_ctx, CAIRO_OPERATOR_CLEAR); + cairo_paint(temp_ctx); + cairo_destroy(temp_ctx); + + temp_ctx = cairo_create(src); + cairo_set_operator(temp_ctx,CAIRO_OPERATOR_SOURCE); + g_assert( cairo_get_operator(temp_ctx) == CAIRO_OPERATOR_SOURCE); + cairo_set_source_surface(temp_ctx, temp_srfc_dest, 0, 0); + cairo_paint(temp_ctx); + cairo_surface_destroy(temp_srfc); + cairo_surface_destroy(temp_srfc_dest); + cairo_destroy(temp_ctx); + cairo_destroy(temp_ctx_dest); +} +*/ +void +blur_surface_shadow(cairo_surface_t *src, const int radius) +{ + guchar * pixdest, * target_pixels_dest, * target_pixels, * pixsrc; + cairo_surface_t * temp_srfc, * temp_srfc_dest; + cairo_t * temp_ctx, * temp_ctx_dest; + + g_return_if_fail(src); + int width = cairo_xlib_surface_get_width(src); + int height = cairo_xlib_surface_get_height(src); + + // the original stuff + temp_srfc = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); + temp_ctx = cairo_create(temp_srfc); + cairo_set_operator(temp_ctx,CAIRO_OPERATOR_SOURCE); + cairo_set_source_surface(temp_ctx, src, 0, 0); + cairo_paint(temp_ctx); + + // the stuff we draw to + temp_srfc_dest = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); + temp_ctx_dest = cairo_create(temp_srfc_dest); + //--- + + int row_stride = cairo_image_surface_get_stride(temp_srfc); + target_pixels = cairo_image_surface_get_data(temp_srfc); + target_pixels_dest = cairo_image_surface_get_data(temp_srfc_dest); + + // -- blur --- + int total_a; + int x, y, kx, ky; + + for (y = 0; y < height; ++y) + { + for (x = 0; x < width; ++x) + { + total_a = 0; + + for (ky = -radius; ky <= radius; ++ky) { + if ((y+ky)>0 && (y+ky)0 && (x+kx)icon_width+10, fx->icon_height+10); + blur_c = cairo_create(blur_s); + + cairo_set_operator(blur_c,CAIRO_OPERATOR_SOURCE); + cairo_set_source_surface(blur_c, cairo_get_target(fx->icon_ctx), 5, 5); + cairo_paint(blur_c); + + darken_surface(blur_s); + blur_surface_shadow(blur_s, 4); + + cairo_set_source_surface(cr, blur_s, x1-5, y1-7); + cairo_paint_with_alpha(cr, 0.5); + + cairo_surface_destroy(blur_s); + cairo_destroy(blur_c); + + + // scaled shadow + cairo_rectangle(cr, 0, fx->window_height - fx->settings->bar_height + (fx->settings->bar_height / ( 2 * fx->settings->bar_depth_scale)) - 4, fx->window_width, fx->settings->bar_height); + cairo_clip(cr); + x1 = (fx->window_width - width) / 2; + y1 = fx->window_height - height - fx->settings->icon_offset; + + blur_s = cairo_surface_create_similar(cairo_get_target(cr),CAIRO_CONTENT_COLOR_ALPHA, fx->icon_width+10, fx->icon_height+10); + blur_c = cairo_create(blur_s); + + cairo_set_operator(blur_c,CAIRO_OPERATOR_SOURCE); + cairo_scale(blur_c, 1, 0.5); + cairo_set_source_surface(blur_c, cairo_get_target(fx->icon_ctx), 5, 5); + cairo_paint(blur_c); + + darken_surface(blur_s); + blur_surface_shadow(blur_s, 1); + + cairo_set_source_surface(cr, blur_s, x1-5, y1-5+(fx->icon_height/2)); + cairo_paint_with_alpha(cr, 0.2); + + cairo_reset_clip(cr); + cairo_surface_destroy(blur_s); + cairo_destroy(blur_c); +} /* The icon surface must be an xlib surface. expose() in awn-applet-simple @@ -781,6 +1041,12 @@ || icon_changed; } + // shadows + if (fx->settings && fx->settings->bar_angle > 0 && fx->settings->show_shadows) + { + make_shadows(fx, cr, ds.x1, ds.y1, ds.current_width, ds.current_height); + } + //Update our displayed Icon. cairo_set_source_surface(cr, cairo_get_target(fx->icon_ctx), ds.x1, ds.y1); @@ -790,7 +1056,7 @@ /* reflection */ if (fx->y_offset >= 0) { - ds.y1 += ds.current_height + fx->y_offset * 2; + ds.y1 += ds.current_height + fx->y_offset * 2 - ((fx->settings->reflection_offset > 30)? 30 : fx->settings->reflection_offset); if (icon_changed || !reflect) { @@ -809,9 +1075,11 @@ 0, 0); cairo_paint(fx->reflect_ctx); + cairo_set_operator(cr,CAIRO_OPERATOR_DEST_OVER); cairo_set_source_surface(cr, cairo_get_target(fx->reflect_ctx), ds.x1, ds.y1); - cairo_paint_with_alpha(cr, fx->alpha / 3); + cairo_paint_with_alpha(cr, fx->alpha / 4); + cairo_set_operator(cr,CAIRO_OPERATOR_SOURCE); cairo_restore(fx->reflect_ctx); } else === modified file 'libawn/awn-settings.c' --- libawn/awn-settings.c 2008-06-28 00:36:52 +0000 +++ libawn/awn-settings.c 2008-07-28 16:22:02 +0000 @@ -54,6 +54,9 @@ #define ICON_OFFSET "icon_offset" /*float*/ #define BAR_POS "bar_pos" /*float, between 0 and 1 */ #define NO_BAR_RESIZE_ANI "no_bar_resize_animation" /*bool*/ +#define SHOW_SHADOWS "show_shadows" /*bool*/ +#define REFLECTION_OFFSET "reflection_offset" /*int*/ +#define BAR_DEPTH_SCALE "bar_depth_scale" /*int*/ #define CURVES_SYMMETRY "curves_symmetry" /*float, between 0 and 1*/ #define CURVINESS "curviness" /*float, between 0 and 1*/ @@ -157,6 +160,8 @@ awn_load_int(client, BAR, BAR_ANGLE, &s->bar_angle,0); awn_load_bool(client, BAR, NO_BAR_RESIZE_ANI,&s->no_bar_resize_ani,FALSE); + awn_load_int(client, BAR, REFLECTION_OFFSET, &s->reflection_offset, 0); + awn_load_int(client, BAR, BAR_DEPTH_SCALE, &s->bar_depth_scale, 1); awn_load_int(client, BAR, ICON_OFFSET, &s->icon_offset,10); awn_load_bool(client, BAR, ROUNDED_CORNERS, &s->rounded_corners, TRUE); awn_load_float(client, BAR, CORNER_RADIUS, &s->corner_radius, 10.0); @@ -197,7 +202,8 @@ awn_load_float(client, APP, ICON_ALPHA, &s->icon_alpha,1.0); awn_load_int(client, APP, FRAME_RATE, &s->frame_rate,25); awn_load_bool(client, APP, ICON_DEPTH_ON, &s->icon_depth_on,TRUE); - awn_load_float(client, APP, REFLECT_ALPHA_MULT, &s->reflection_alpha_mult,0.33); + awn_load_float(client, APP, REFLECT_ALPHA_MULT, &s->reflection_alpha_mult,0.33); + awn_load_bool(client, APP, SHOW_SHADOWS, &s->show_shadows, FALSE); /* Title settings */ awn_config_client_ensure_group (client, TITLE); === modified file 'libawn/awn-settings.h' --- libawn/awn-settings.h 2008-06-27 20:12:56 +0000 +++ libawn/awn-settings.h 2008-07-28 16:22:55 +0000 @@ -98,6 +98,9 @@ gboolean icon_depth_on; int icon_offset; + int reflection_offset; + int bar_depth_scale; + gboolean show_shadows; /* Title settings */ AwnColor text_color; === modified file 'src/awn-bar.c' --- src/awn-bar.c 2008-06-18 13:24:26 +0000 +++ src/awn-bar.c 2008-07-28 16:01:51 +0000 @@ -279,7 +279,7 @@ if (settings->bar_angle == 0) return 0; else - return height / 2; + return height / (2 * settings->bar_depth_scale); } static void