📄 pan-view.c
字号:
case LAYOUT_SIZE_THUMB_LARGE: pw->thumb_size = PAN_THUMB_SIZE_LARGE; pw->thumb_gap = PAN_THUMB_GAP_LARGE; break; case LAYOUT_SIZE_10: pw->image_size = 10; pw->thumb_gap = PAN_THUMB_GAP_NORMAL; break; case LAYOUT_SIZE_25: pw->image_size = 25; pw->thumb_gap = PAN_THUMB_GAP_NORMAL; break; case LAYOUT_SIZE_33: pw->image_size = 33; pw->thumb_gap = PAN_THUMB_GAP_LARGE; break; case LAYOUT_SIZE_50: pw->image_size = 50; pw->thumb_gap = PAN_THUMB_GAP_HUGE; break; case LAYOUT_SIZE_100: pw->image_size = 100; pw->thumb_gap = PAN_THUMB_GAP_HUGE; break; } *width = 0; *height = 0; *scroll_x = 0; *scroll_y = 0; switch (pw->layout) { case LAYOUT_GRID: default: pan_window_layout_compute_grid(pw, path, width, height); break; case LAYOUT_FOLDERS_LINEAR: pan_window_layout_compute_folders_linear(pw, path, width, height); break; case LAYOUT_FOLDERS_FLOWER: pan_window_layout_compute_folders_flower(pw, path, width, height, scroll_x, scroll_y); break; case LAYOUT_CALENDAR: pan_window_layout_compute_calendar(pw, path, width, height); break; case LAYOUT_TIMELINE: pan_window_layout_compute_timeline(pw, path, width, height); break; } pan_cache_free(pw); printf("computed %d objects\n", g_list_length(pw->list));}static GList *pan_layout_intersect_l(GList *list, GList *item_list, gint x, gint y, gint width, gint height){ GList *work; work = item_list; while (work) { PanItem *pi; gint rx, ry, rw, rh; pi = work->data; work = work->next; if (util_clip_region(x, y, width, height, pi->x, pi->y, pi->width, pi->height, &rx, &ry, &rw, &rh)) { list = g_list_prepend(list, pi); } } return list;}static GList *pan_layout_intersect(PanWindow *pw, gint x, gint y, gint width, gint height){ GList *list = NULL; GList *grid; PanGrid *pg = NULL; grid = pw->list_grid; while (grid && !pg) { pg = grid->data; grid = grid->next; if (x < pg->x || x + width > pg->x + pg->w || y < pg->y || y + height > pg->y + pg->h) { pg = NULL; } } list = pan_layout_intersect_l(list, pw->list, x, y, width, height); if (pg) { list = pan_layout_intersect_l(list, pg->list, x, y, width, height); } else { list = pan_layout_intersect_l(list, pw->list_static, x, y, width, height); } return list;}/* *----------------------------------------------------------------------------- * tile generation *----------------------------------------------------------------------------- */static gint pan_layout_queue_step(PanWindow *pw);static void pan_layout_queue_thumb_done_cb(ThumbLoader *tl, gpointer data){ PanWindow *pw = data; if (pw->queue_pi) { PanItem *pi; gint rc; pi = pw->queue_pi; pw->queue_pi = NULL; pi->queued = FALSE; if (pi->pixbuf) g_object_unref(pi->pixbuf); pi->pixbuf = thumb_loader_get_pixbuf(tl, TRUE); rc = pi->refcount; image_area_changed(pw->imd, pi->x, pi->y, pi->width, pi->height); pi->refcount = rc; } thumb_loader_free(pw->tl); pw->tl = NULL; while (pan_layout_queue_step(pw));}static void pan_layout_queue_image_done_cb(ImageLoader *il, gpointer data){ PanWindow *pw = data; if (pw->queue_pi) { PanItem *pi; gint rc; pi = pw->queue_pi; pw->queue_pi = NULL; pi->queued = FALSE; if (pi->pixbuf) g_object_unref(pi->pixbuf); pi->pixbuf = image_loader_get_pixbuf(pw->il); if (pi->pixbuf) g_object_ref(pi->pixbuf); if (pi->pixbuf && pw->size != LAYOUT_SIZE_100 && (gdk_pixbuf_get_width(pi->pixbuf) > pi->width || gdk_pixbuf_get_height(pi->pixbuf) > pi->height)) { GdkPixbuf *tmp; tmp = pi->pixbuf; pi->pixbuf = gdk_pixbuf_scale_simple(tmp, pi->width, pi->height, (GdkInterpType)zoom_quality); g_object_unref(tmp); } rc = pi->refcount; image_area_changed(pw->imd, pi->x, pi->y, pi->width, pi->height); pi->refcount = rc; } image_loader_free(pw->il); pw->il = NULL; while (pan_layout_queue_step(pw));}#if 0static void pan_layout_queue_image_area_cb(ImageLoader *il, guint x, guint y, guint width, guint height, gpointer data){ PanWindow *pw = data; if (pw->queue_pi) { PanItem *pi; gint rc; pi = pw->queue_pi; if (!pi->pixbuf) { pi->pixbuf = image_loader_get_pixbuf(pw->il); if (pi->pixbuf) g_object_ref(pi->pixbuf); } rc = pi->refcount; image_area_changed(pw->imd, pi->x + x, pi->y + y, width, height); pi->refcount = rc; }}#endifstatic gint pan_layout_queue_step(PanWindow *pw){ PanItem *pi; if (!pw->queue) return FALSE; pi = pw->queue->data; pw->queue = g_list_remove(pw->queue, pi); pw->queue_pi = pi; if (!pw->queue_pi->fd) { pw->queue_pi->queued = FALSE; pw->queue_pi = NULL; return TRUE; } image_loader_free(pw->il); pw->il = NULL; thumb_loader_free(pw->tl); pw->tl = NULL; if (pi->type == ITEM_IMAGE) { pw->il = image_loader_new(pi->fd->path); if (pw->size != LAYOUT_SIZE_100) { image_loader_set_requested_size(pw->il, pi->width, pi->height); }#if 0 image_loader_set_area_ready_func(pw->il, pan_layout_queue_image_area_cb, pw);#endif image_loader_set_error_func(pw->il, pan_layout_queue_image_done_cb, pw); if (image_loader_start(pw->il, pan_layout_queue_image_done_cb, pw)) return FALSE; image_loader_free(pw->il); pw->il = NULL; } else if (pi->type == ITEM_THUMB) { pw->tl = thumb_loader_new(PAN_THUMB_SIZE, PAN_THUMB_SIZE); if (!pw->tl->standard_loader) { /* The classic loader will recreate a thumbnail any time we * request a different size than what exists. This view will * almost never use the user configured sizes so disable cache. */ thumb_loader_set_cache(pw->tl, FALSE, FALSE, FALSE); } thumb_loader_set_callbacks(pw->tl, pan_layout_queue_thumb_done_cb, pan_layout_queue_thumb_done_cb, NULL, pw); if (thumb_loader_start(pw->tl, pi->fd->path)) return FALSE; thumb_loader_free(pw->tl); pw->tl = NULL; } pw->queue_pi->queued = FALSE; pw->queue_pi = NULL; return TRUE;}static void pan_layout_queue(PanWindow *pw, PanItem *pi){ if (!pi || pi->queued || pi->pixbuf) return; if (pw->size <= LAYOUT_SIZE_THUMB_NONE) return; pi->queued = TRUE; pw->queue = g_list_prepend(pw->queue, pi); if (!pw->tl && !pw->il) while(pan_layout_queue_step(pw));}static gint pan_window_request_tile_cb(PixbufRenderer *pr, gint x, gint y, gint width, gint height, GdkPixbuf *pixbuf, gpointer data){ PanWindow *pw = data; GList *list; GList *work; gint i; pixbuf_set_rect_fill(pixbuf, 0, 0, width, height, PAN_BACKGROUND_COLOR, 255); for (i = (x / PAN_GRID_SIZE) * PAN_GRID_SIZE; i < x + width; i += PAN_GRID_SIZE) { gint rx, ry, rw, rh; if (util_clip_region(x, y, width, height, i, y, 1, height, &rx, &ry, &rw, &rh)) { pixbuf_draw_rect_fill(pixbuf, rx - x, ry - y, rw, rh, PAN_GRID_COLOR, PAN_GRID_ALPHA); } } for (i = (y / PAN_GRID_SIZE) * PAN_GRID_SIZE; i < y + height; i += PAN_GRID_SIZE) { gint rx, ry, rw, rh; if (util_clip_region(x, y, width, height, x, i, width, 1, &rx, &ry, &rw, &rh)) { pixbuf_draw_rect_fill(pixbuf, rx - x, ry - y, rw, rh, PAN_GRID_COLOR, PAN_GRID_ALPHA); } } list = pan_layout_intersect(pw, x, y, width, height); work = list; while (work) { PanItem *pi; gint tx, ty, tw, th; gint rx, ry, rw, rh; pi = work->data; work = work->next; pi->refcount++; if (pi->type == ITEM_THUMB && pi->pixbuf) { tw = gdk_pixbuf_get_width(pi->pixbuf); th = gdk_pixbuf_get_height(pi->pixbuf); tx = pi->x + (pi->width - tw) / 2; ty = pi->y + (pi->height - th) / 2; if (gdk_pixbuf_get_has_alpha(pi->pixbuf)) { if (util_clip_region(x, y, width, height, tx + PAN_SHADOW_OFFSET, ty + PAN_SHADOW_OFFSET, tw, th, &rx, &ry, &rw, &rh)) { pixbuf_draw_shadow(pixbuf, rx - x, ry - y, rw, rh, tx + PAN_SHADOW_OFFSET - x, ty + PAN_SHADOW_OFFSET - y, tw, th, PAN_SHADOW_FADE, PAN_SHADOW_COLOR, PAN_SHADOW_ALPHA); } } else { if (util_clip_region(x, y, width, height, tx + tw, ty + PAN_SHADOW_OFFSET, PAN_SHADOW_OFFSET, th - PAN_SHADOW_OFFSET, &rx, &ry, &rw, &rh)) { pixbuf_draw_shadow(pixbuf, rx - x, ry - y, rw, rh, tx + PAN_SHADOW_OFFSET - x, ty + PAN_SHADOW_OFFSET - y, tw, th, PAN_SHADOW_FADE, PAN_SHADOW_COLOR, PAN_SHADOW_ALPHA); } if (util_clip_region(x, y, width, height, tx + PAN_SHADOW_OFFSET, ty + th, tw, PAN_SHADOW_OFFSET, &rx, &ry, &rw, &rh)) { pixbuf_draw_shadow(pixbuf, rx - x, ry - y, rw, rh, tx + PAN_SHADOW_OFFSET - x, ty + PAN_SHADOW_OFFSET - y, tw, th, PAN_SHADOW_FADE, PAN_SHADOW_COLOR, PAN_SHADOW_ALPHA); } } if (util_clip_region(x, y, width, height, tx, ty, tw, th, &rx, &ry, &rw, &rh)) { gdk_pixbuf_composite(pi->pixbuf, pixbuf, rx - x, ry - y, rw, rh, (double) tx - x, (double) ty - y, 1.0, 1.0, GDK_INTERP_NEAREST, 255); } if (util_clip_region(x, y, width, height, tx, ty, tw, PAN_OUTLINE_THICKNESS, &rx, &ry, &rw, &rh)) { pixbuf_draw_rect_fill(pixbuf, rx - x, ry - y, rw, rh, PAN_OUTLINE_COLOR_1, PAN_OUTLINE_ALPHA); } if (util_clip_region(x, y, width, height, tx, ty, PAN_OUTLINE_THICKNESS, th, &rx, &ry, &rw, &rh)) { pixbuf_draw_rect_fill(pixbuf, rx - x, ry - y, rw, rh, PAN_OUTLINE_COLOR_1, PAN_OUTLINE_ALPHA); } if (util_clip_region(x, y, width, height, tx + tw - PAN_OUTLINE_THICKNESS, ty + PAN_OUTLINE_THICKNESS, PAN_OUTLINE_THICKNESS, th - PAN_OUTLINE_THICKNESS, &rx, &ry, &rw, &rh)) { pixbuf_draw_rect_fill(pixbuf, rx - x, ry - y, rw, rh, PAN_OUTLINE_COLOR_2, PAN_OUTLINE_ALPHA); } if (util_clip_region(x, y, width, height, tx + PAN_OUTLINE_THICKNESS, ty + th - PAN_OUTLINE_THICKNESS, tw - PAN_OUTLINE_THICKNESS * 2, PAN_OUTLINE_THICKNESS, &rx, &ry, &rw, &rh)) { pixbuf_draw_rect_fill(pixbuf, rx - x, ry - y, rw, rh, PAN_OUTLINE_COLOR_2, PAN_OUTLINE_ALPHA); } } else if (pi->type == ITEM_THUMB) { tw = pi->width - PAN_SHADOW_OFFSET * 2; th = pi->height - PAN_SHADOW_OFFSET * 2; tx = pi->x + PAN_SHADOW_OFFSET; ty = pi->y + PAN_SHADOW_OFFSET; if (util_clip_region(x, y, width, height, tx, ty, tw, th, &rx, &ry, &rw, &rh)) { gint d; d = (pw->size <= LAYOUT_SIZE_THUMB_NONE) ? 2 : 8; pixbuf_draw_rect_fill(pixbuf, rx - x, ry - y, rw, rh, PAN_SHADOW_COLOR, PAN_SHADOW_ALPHA / d); } pan_layout_queue(pw, pi); } else if (pi->type == ITEM_IMAGE) { if (util_clip_region(x, y, width, height, pi->x, pi->y, pi->width, pi->height, &rx, &ry, &rw, &rh)) { if (pi->pixbuf) { gdk_pixbuf_composite(pi->pixbuf, pixbuf, rx - x, ry - y, rw, rh, (double) pi->x - x, (double) pi->y - y, 1.0, 1.0, GDK_INTERP_NEAREST, 255); } else { pixbuf_draw_rect_fill(pixbuf, rx - x, ry - y, rw, rh, PAN_SHADOW_COLOR, PAN_SHADOW_ALPHA / 2); pan_layout_queue(pw, pi); } } } else if (pi->type == ITEM_BOX) { gint bw, bh; gint *shadow; bw = pi->width; bh = pi->height; shadow = pi->data; if (shadow) { bw -= shadow[0]; bh -= shadow[0]; if (pi->color_a > 254) { pixbuf_draw_shadow(pixbuf, pi->x - x + bw, pi->y - y + shadow[0], shadow[0], bh - shadow[0], pi->x - x + shadow[0], pi->y - y + shadow[0], bw, bh, shadow[1], PAN_SHADOW_COLOR, PAN_SHADOW_ALPHA); pixbuf_draw_shadow(pixbuf, pi->x - x + shadow[0], pi->y - y + bh, bw, shadow[0], pi->x - x + shadow[0], pi->y - y + shadow[0], bw, bh, shadow[1], PAN_SHADOW_COLOR, PAN_SHADOW_ALPHA); } else { gint a; a = pi->color_a * PAN_SHADOW_ALPHA >> 8; pixbuf_draw_shadow(pixbuf, pi->x - x + shadow[0], pi->y - y + shadow[0], bw, bh, pi->x - x + shadow[0], pi->y - y + shadow[0], bw, bh, shadow[1], PAN_SHADOW_COLOR, a); } } if (util_clip_region(x, y, width, height, pi->x, pi->y, bw, bh, &rx, &ry, &rw, &rh)) { pixbuf_draw_rect_fill(pixbuf, rx - x, ry - y, rw, rh, pi->color_r, pi->color_g, pi->color_b, pi->color_a); } if (util_clip_region(x, y, width, height, pi->x, pi->y, bw, pi->border, &rx, &ry, &rw, &rh)) { pixbuf_draw_rect_fill(pixbuf, rx - x, ry - y, rw, rh, pi->color2_r, pi->color2_g, pi->color2_b, pi->color2_a); } if (util_clip_region(x, y, width, height, pi->x, pi->y + pi->border, pi->border, bh - pi->border * 2, &rx, &ry, &rw, &rh)) { pixbuf_draw_rect_fill(pixbuf, rx - x, ry - y, rw, rh, pi->color2_r, pi->color2_g, pi->color2_b, pi->color2_a); } if (util_clip_region(x, y, width, height, pi->x + bw - pi->border, pi->y + pi->border, pi->border, bh - pi->border * 2, &rx, &ry, &rw, &rh)) { pixbuf_draw_rect_fill(pixbuf, rx - x, ry - y, rw, rh, pi->color2_r, pi->color2_g, pi->color2_b, pi->color2_a); } if (util_clip_region(x, y, width, height, pi->x, pi->y + bh - pi->border, bw, pi->border, &rx, &ry, &rw, &rh)) { pixbuf_draw_rect_fill(pixbuf, rx - x, ry - y, rw, rh, pi->color2_r, pi->color2_g, pi->color2_b, pi->color2_a); } } else if (pi->type == ITEM_TRIANGLE) { if (util_clip_region(x, y, width, height, pi->x, pi->y, pi->width, pi->height, &rx, &ry, &rw, &rh) && pi->data) { gint *coord = pi->data; pixbuf_draw_triangle(pixbuf, rx - x, ry - y, rw, rh, coord[0] - x, coord[1] - y, coord[2] - x, coord[3] - y, coord[4] - x, coord[5] - y, pi->color_r, pi->color_g, pi->color_b, pi->color_a); if (pi->border & BORDER_1) { pixbuf_draw_line(pixbuf, rx - x, ry - y, rw, rh, coord[0] - x, coord[1] - y, coord[2] - x, coord[3] - y, pi->color2_r, pi->color2_g, pi->color2_b, pi->color2_a); } if (pi->border & BORDER_2) { pixbuf_draw_line(pixbuf, rx - x, ry - y, rw, rh, coord[2] - x, coord[3] - y, coord[4] - x, coord[5] - y, pi->color2_r, pi->color2_g, pi->color2_b, pi->color2_a);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -