comparison src/pan-timeline.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 71e1ebee420e
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
17 void pan_timeline_compute(PanWindow *pw, const gchar *path, gint *width, gint *height)
18 {
19 GList *list;
20 GList *work;
21 gint x, y;
22 time_t tc;
23 gint total;
24 gint count;
25 PanItem *pi_month = NULL;
26 PanItem *pi_day = NULL;
27 gint month_start;
28 gint day_start;
29 gint x_width;
30 gint y_height;
31
32 list = pan_list_tree(path, SORT_NONE, TRUE, pw->ignore_symlinks);
33
34 if (pw->cache_list && pw->exif_date_enable)
35 {
36 pw->cache_list = filelist_sort(pw->cache_list, SORT_NAME, TRUE);
37 list = filelist_sort(list, SORT_NAME, TRUE);
38 pan_cache_sync_date(pw, list);
39 }
40
41 pw->cache_list = filelist_sort(pw->cache_list, SORT_TIME, TRUE);
42 list = filelist_sort(list, SORT_TIME, TRUE);
43
44 *width = PAN_BOX_BORDER * 2;
45 *height = PAN_BOX_BORDER * 2;
46
47 x = 0;
48 y = 0;
49 month_start = y;
50 day_start = month_start;
51 x_width = 0;
52 y_height = 0;
53 tc = 0;
54 total = 0;
55 count = 0;
56 work = list;
57 while (work)
58 {
59 FileData *fd;
60 PanItem *pi;
61
62 fd = work->data;
63 work = work->next;
64
65 if (!pan_date_compare(fd->date, tc, PAN_DATE_LENGTH_DAY))
66 {
67 GList *needle;
68 gchar *buf;
69
70 if (!pan_date_compare(fd->date, tc, PAN_DATE_LENGTH_MONTH))
71 {
72 pi_day = NULL;
73
74 if (pi_month)
75 {
76 x = pi_month->x + pi_month->width + PAN_BOX_BORDER;
77 }
78 else
79 {
80 x = PAN_BOX_BORDER;
81 }
82
83 y = PAN_BOX_BORDER;
84
85 buf = pan_date_value_string(fd->date, PAN_DATE_LENGTH_MONTH);
86 pi = pan_item_text_new(pw, x, y, buf,
87 PAN_TEXT_ATTR_BOLD | PAN_TEXT_ATTR_HEADING,
88 PAN_TEXT_BORDER_SIZE,
89 PAN_TEXT_COLOR, 255);
90 g_free(buf);
91 y += pi->height;
92
93 pi_month = pan_item_box_new(pw, file_data_new_simple(fd->path),
94 x, y, 0, 0,
95 PAN_BOX_OUTLINE_THICKNESS,
96 PAN_BOX_COLOR, PAN_BOX_ALPHA,
97 PAN_BOX_OUTLINE_COLOR, PAN_BOX_OUTLINE_ALPHA);
98
99 x += PAN_BOX_BORDER;
100 y += PAN_BOX_BORDER;
101 month_start = y;
102 }
103
104 if (pi_day) x = pi_day->x + pi_day->width + PAN_BOX_BORDER;
105
106 tc = fd->date;
107 total = 1;
108 count = 0;
109
110 needle = work;
111 while (needle)
112 {
113 FileData *nfd;
114
115 nfd = needle->data;
116 if (pan_date_compare(nfd->date, tc, PAN_DATE_LENGTH_DAY))
117 {
118 needle = needle->next;
119 total++;
120 }
121 else
122 {
123 needle = NULL;
124 }
125 }
126
127 buf = pan_date_value_string(fd->date, PAN_DATE_LENGTH_WEEK);
128 pi = pan_item_text_new(pw, x, y, buf, PAN_TEXT_ATTR_NONE,
129 PAN_TEXT_BORDER_SIZE,
130 PAN_TEXT_COLOR, 255);
131 g_free(buf);
132
133 y += pi->height;
134
135 pi_day = pan_item_box_new(pw, file_data_new_simple(fd->path), x, y, 0, 0,
136 PAN_BOX_OUTLINE_THICKNESS,
137 PAN_BOX_COLOR, PAN_BOX_ALPHA,
138 PAN_BOX_OUTLINE_COLOR, PAN_BOX_OUTLINE_ALPHA);
139
140 x += PAN_BOX_BORDER;
141 y += PAN_BOX_BORDER;
142 day_start = y;
143 }
144
145 if (pw->size > PAN_IMAGE_SIZE_THUMB_LARGE)
146 {
147 pi = pan_item_image_new(pw, fd, x, y, 10, 10);
148 if (pi->width > x_width) x_width = pi->width;
149 y_height = pi->height;
150 }
151 else
152 {
153 pi = pan_item_thumb_new(pw, fd, x, y);
154 x_width = PAN_THUMB_SIZE;
155 y_height = PAN_THUMB_SIZE;
156 }
157
158 pan_item_size_by_item(pi_day, pi, PAN_BOX_BORDER);
159 pan_item_size_by_item(pi_month, pi_day, PAN_BOX_BORDER);
160
161 total--;
162 count++;
163
164 if (total > 0 && count < PAN_GROUP_MAX)
165 {
166 y += y_height + PAN_THUMB_GAP;
167 }
168 else
169 {
170 x += x_width + PAN_THUMB_GAP;
171 x_width = 0;
172 count = 0;
173
174 if (total > 0)
175 y = day_start;
176 else
177 y = month_start;
178 }
179
180 pan_item_size_coordinates(pi_month, PAN_BOX_BORDER, width, height);
181 }
182
183 g_list_free(list);
184 }
185