Mercurial > geeqie
comparison src/pan-grid.c @ 105:de64a683d5d0
Thu Nov 9 17:43:06 2006 John Ellis <johne@verizon.net>
* pan-view.c: Break this monstrosity of code into smaller files.
* pan-calendar.c, pan-folder.c, pan-grid.c, pan-timeline.c: Move the
layout types into their own files (for now flower is with folder tree).
* pan-item.c: PanItem creation, drawing, actions, and maintenance.
* pan-types.h: Defines, data types, function prototypes.
* pan-util.c: Various utilities.
* src/Makefile.am: Add new files above.
author | gqview |
---|---|
date | Thu, 09 Nov 2006 22:53:11 +0000 |
parents | |
children | f6e307c7bad6 |
comparison
equal
deleted
inserted
replaced
104:8d358a53146e | 105:de64a683d5d0 |
---|---|
1 /* | |
2 * GQview | |
3 * (C) 2006 John Ellis | |
4 * | |
5 * Author: John Ellis | |
6 * | |
7 * This software is released under the GNU General Public License (GNU GPL). | |
8 * Please read the included file COPYING for more information. | |
9 * This software comes with no warranty of any kind, use at your own risk! | |
10 */ | |
11 | |
12 | |
13 #include "gqview.h" | |
14 #include "pan-types.h" | |
15 | |
16 #include <math.h> | |
17 | |
18 | |
19 void pan_grid_compute(PanWindow *pw, const gchar *path, gint *width, gint *height) | |
20 { | |
21 GList *list; | |
22 GList *work; | |
23 gint x, y; | |
24 gint grid_size; | |
25 gint next_y; | |
26 | |
27 list = pan_list_tree(path, SORT_NAME, TRUE, pw->ignore_symlinks); | |
28 | |
29 grid_size = (gint)sqrt((double)g_list_length(list)); | |
30 if (pw->size > PAN_IMAGE_SIZE_THUMB_LARGE) | |
31 { | |
32 grid_size = grid_size * (512 + PAN_THUMB_GAP) * pw->image_size / 100; | |
33 } | |
34 else | |
35 { | |
36 grid_size = grid_size * (PAN_THUMB_SIZE + PAN_THUMB_GAP); | |
37 } | |
38 | |
39 next_y = 0; | |
40 | |
41 *width = PAN_BOX_BORDER * 2; | |
42 *height = PAN_BOX_BORDER * 2; | |
43 | |
44 x = PAN_THUMB_GAP; | |
45 y = PAN_THUMB_GAP; | |
46 work = list; | |
47 while (work) | |
48 { | |
49 FileData *fd; | |
50 PanItem *pi; | |
51 | |
52 fd = work->data; | |
53 work = work->next; | |
54 | |
55 if (pw->size > PAN_IMAGE_SIZE_THUMB_LARGE) | |
56 { | |
57 pi = pan_item_image_new(pw, fd, x, y, 10, 10); | |
58 | |
59 x += pi->width + PAN_THUMB_GAP; | |
60 if (y + pi->height + PAN_THUMB_GAP > next_y) next_y = y + pi->height + PAN_THUMB_GAP; | |
61 if (x > grid_size) | |
62 { | |
63 x = PAN_THUMB_GAP; | |
64 y = next_y; | |
65 } | |
66 } | |
67 else | |
68 { | |
69 pi = pan_item_thumb_new(pw, fd, x, y); | |
70 | |
71 x += PAN_THUMB_SIZE + PAN_THUMB_GAP; | |
72 if (x > grid_size) | |
73 { | |
74 x = PAN_THUMB_GAP; | |
75 y += PAN_THUMB_SIZE + PAN_THUMB_GAP; | |
76 } | |
77 } | |
78 pan_item_size_coordinates(pi, PAN_THUMB_GAP, width, height); | |
79 } | |
80 | |
81 g_list_free(list); | |
82 } | |
83 |