nice visual effect (patch)
- From: "Daniel Godas Lopez" <siro eurielec etsit upm es>
- To: nautilus-list gnome org
- Subject: nice visual effect (patch)
- Date: Wed, 25 Aug 2004 14:46:49 +0200
i made a little "bouncing-icons" effect like the one they have in kde,
its not perfect at the moment but id like to know what you think about
it
i made the patch today against the head of the cvs
? jumping_icons.patch
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.634
diff -p -u -r1.634 fm-directory-view.c
--- src/file-manager/fm-directory-view.c 18 Aug 2004 23:23:53 -0000 1.634
+++ src/file-manager/fm-directory-view.c 25 Aug 2004 12:43:28 -0000
@@ -6583,6 +6583,93 @@ cancel_activate_callback (gpointer callb
}
}
+typedef struct {
+ GdkWindow *anim_window;
+ GdkPixbuf *anim_base_pixbuf;
+ GdkBitmap *anim_window_mask;
+
+ GdkWindowAttr *anim_window_attr;
+ GdkColormap *anim_window_colormap;
+ GdkVisual *anim_window_visual;
+
+ gint x0, y0;
+ gint w0, h0, last_w, last_h;
+ gint counter;
+ guint frame;
+} anim_param;
+
+static gboolean
+handle_anim (gpointer p_)
+{
+ #define MAX_ANIM_TIME 200
+ #define N_OF_FRAMES 42
+ #define MAX_OFFSET 30
+
+ static guint offsets[N_OF_FRAMES] = {0, 1, 1, 2, 3, 4, 6, 9, 12, 15, 19, 23, 27,
+ 28, 28, 28, 29, 29, 29, 29, 30, 30, 29, 29,
+ 29, 29, 29, 29, 28, 28, 28, 27, 27, 26, 23,
+ 19, 16, 12, 9, 7, 4, 2};
+ gint x, y, w, h, floor;
+ GdkPixbuf *anim_pixbuf;
+ anim_param *p = (anim_param*) p_;
+
+ p->frame = ( (p->frame)+1 == N_OF_FRAMES ? 0 : (p->frame)+1 );
+ gdk_display_get_pointer (gdk_display_get_default () ,NULL, &x, &y, NULL);
+ x += p->x0;
+ y += p->y0;
+ w = p->w0;
+ h = p->h0;
+ floor = y + MAX_OFFSET + ((3*h)/4);
+ y += offsets[p->frame];
+
+ if (floor-y < h) {
+ h = floor-y;
+ anim_pixbuf = gdk_pixbuf_scale_simple (p->anim_base_pixbuf,
+ w, h, GDK_INTERP_BILINEAR);
+ } else {
+ anim_pixbuf = p->anim_base_pixbuf;
+ }
+
+ if (p->counter == 0) {
+ gdk_window_show (p->anim_window);
+ }
+
+ gdk_window_move_resize (p->anim_window, x, y, w, h);
+ if (w != p->last_w || h != p->last_h) {
+ gdk_pixbuf_render_threshold_alpha (anim_pixbuf, p->anim_window_mask,
+ 0, 0, 0, 0, w, h, 120);
+ gdk_window_shape_combine_mask (p->anim_window, p->anim_window_mask, 0, 0);
+ }
+ gdk_draw_pixbuf (GDK_DRAWABLE (p->anim_window), NULL, anim_pixbuf, 0, 0, 0,
+ 0, w, h, GDK_RGB_DITHER_NORMAL, 0, 0);
+
+ p->last_w = w;
+ p->last_h = h;
+ if (anim_pixbuf != p->anim_base_pixbuf) {
+ gdk_pixbuf_unref (anim_pixbuf);
+ }
+
+ /*
+ * TODO: check if the thingie has been launched, in that case we should end
+ * the animation before MAX_ANIM_TIME
+ */
+ if (++(p->counter) == MAX_ANIM_TIME) {
+ gdk_window_destroy (p->anim_window);
+ gdk_pixbuf_unref (p->anim_base_pixbuf);
+ gdk_bitmap_unref (p->anim_window_mask);
+ gdk_colormap_unref (p->anim_window_colormap);
+ g_free (p->anim_window_attr);
+ g_free (p);
+ return FALSE;
+ }
+ return TRUE;
+
+ #undef MAX_ANIM_TIME
+ #undef N_OF_FRAMES
+ #undef MAX_OFFSET
+}
+
+
/**
* fm_directory_view_activate_file:
*
@@ -6603,9 +6690,56 @@ fm_directory_view_activate_file (FMDirec
NautilusFileAttributes attributes;
char *file_name;
char *timed_wait_prompt;
+ GdkWindowAttr *anim_window_attr;
+ GdkColormap *anim_window_colormap;
+ GdkVisual *anim_window_visual;
+ GdkWindow *anim_window;
+ GdkPixbuf *anim_base_pixbuf;
+ anim_param *p;
g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
g_return_if_fail (NAUTILUS_IS_FILE (file));
+
+ /* prepare cool visual effect :) */
+ anim_base_pixbuf = nautilus_icon_factory_get_pixbuf_for_file (file, NULL,
+ NAUTILUS_ICON_SIZE_SMALLER);
+ if (anim_base_pixbuf != NULL) {
+ anim_window_visual = gdk_visual_get_best ();
+ anim_window_colormap = gdk_colormap_new (anim_window_visual, TRUE);
+ anim_window_attr = g_new0 (GdkWindowAttr, 1);
+ anim_window_attr->event_mask = !GDK_ALL_EVENTS_MASK;
+ anim_window_attr->x = gdk_screen_get_width (gdk_screen_get_default ());
+ anim_window_attr->y = gdk_screen_get_height (gdk_screen_get_default ());
+ anim_window_attr->width = gdk_pixbuf_get_width (anim_base_pixbuf);
+ anim_window_attr->height = gdk_pixbuf_get_height (anim_base_pixbuf);
+ anim_window_attr->wclass = GDK_INPUT_OUTPUT;
+ anim_window_attr->visual = anim_window_visual;
+ anim_window_attr->colormap = anim_window_colormap;
+ anim_window_attr->window_type = GDK_WINDOW_CHILD;
+ anim_window_attr->override_redirect = TRUE;
+ anim_window = gdk_window_new (NULL, anim_window_attr, 0x1FF1);
+ gdk_window_set_keep_above (anim_window, TRUE);
+ gdk_window_stick (anim_window);
+
+ p = g_new0 (anim_param, 1);
+ p->anim_window = anim_window;
+ p->anim_base_pixbuf = anim_base_pixbuf;
+ p->anim_window_mask = gdk_pixmap_new (NULL, anim_window_attr->width,
+ anim_window_attr->height, 1);
+ p->anim_window_colormap = anim_window_colormap;
+ p->anim_window_visual = anim_window_visual;
+ p->anim_window_attr = anim_window_attr;
+ p->x0 = gdk_display_get_default_cursor_size (gdk_display_get_default ());
+ p->y0 = gdk_display_get_default_cursor_size (gdk_display_get_default ());
+ p->w0 = gdk_pixbuf_get_width (anim_base_pixbuf);
+ p->h0 = gdk_pixbuf_get_height (anim_base_pixbuf);
+ p->last_w = -1;
+ p->last_h = -1;
+ p->counter = -1;
+ p->frame = 0;
+
+ g_timeout_add (40, handle_anim, p);
+ }
/* link target info might be stale, re-read it */
if (nautilus_file_is_symbolic_link (file)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]