2 * Copyright (C) 2006 John Ellis
3 * Copyright (C) 2008 - 2016 The Geeqie Team
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "pan-timeline.h"
28 #include "pan-types.h"
30 #include "pan-view-filter.h"
34 void pan_timeline_compute(PanWindow *pw, FileData *dir_fd, gint *width, gint *height)
40 time_t group_start_date;
43 PanItem *pi_month = nullptr;
44 PanItem *pi_day = nullptr;
50 list = pan_list_tree(dir_fd, SORT_NONE, TRUE, TRUE, pw->ignore_symlinks);
51 pan_filter_fd_list(&list, pw->filter_ui->filter_elements, pw->filter_ui->filter_classes);
53 if (pw->cache_list && pw->exif_date_enable)
55 pw->cache_list = pan_cache_sort(pw->cache_list, SORT_NAME, TRUE, TRUE);
56 list = filelist_sort(list, SORT_NAME, TRUE, TRUE);
57 pan_cache_sync_date(pw, list);
60 pw->cache_list = pan_cache_sort(pw->cache_list, SORT_TIME, TRUE, TRUE);
61 list = filelist_sort(list, SORT_TIME, TRUE, TRUE);
63 *width = PAN_BOX_BORDER * 2;
64 *height = PAN_BOX_BORDER * 2;
69 day_start = month_start;
73 // total and count are used to enforce a stride of PAN_GROUP_MAX thumbs.
82 fd = static_cast<FileData *>(work->data);
85 if (!pan_date_compare(fd->date, group_start_date, PAN_DATE_LENGTH_DAY))
87 // FD starts a new day group.
91 if (!pan_date_compare(fd->date, group_start_date, PAN_DATE_LENGTH_MONTH))
93 // FD starts a new month group.
98 x = pi_month->x + pi_month->width + PAN_BOX_BORDER;
107 buf = pan_date_value_string(fd->date, PAN_DATE_LENGTH_MONTH);
108 pi = pan_item_text_new(pw, x, y, buf,
109 static_cast<PanTextAttrType>(PAN_TEXT_ATTR_BOLD | PAN_TEXT_ATTR_HEADING),
111 PAN_TEXT_COLOR, 255);
115 pi_month = pan_item_box_new(pw, file_data_ref(fd),
117 PAN_BOX_OUTLINE_THICKNESS,
118 PAN_BOX_COLOR, PAN_BOX_ALPHA,
119 PAN_BOX_OUTLINE_COLOR, PAN_BOX_OUTLINE_ALPHA);
126 if (pi_day) x = pi_day->x + pi_day->width + PAN_BOX_BORDER;
128 group_start_date = fd->date;
137 nfd = static_cast<FileData *>(needle->data);
138 if (pan_date_compare(nfd->date, group_start_date, PAN_DATE_LENGTH_DAY))
140 needle = needle->next;
149 buf = pan_date_value_string(fd->date, PAN_DATE_LENGTH_WEEK);
150 pi = pan_item_text_new(pw, x, y, buf, PAN_TEXT_ATTR_NONE,
152 PAN_TEXT_COLOR, 255);
157 pi_day = pan_item_box_new(pw, file_data_ref(fd), x, y, 0, 0,
158 PAN_BOX_OUTLINE_THICKNESS,
159 PAN_BOX_COLOR, PAN_BOX_ALPHA,
160 PAN_BOX_OUTLINE_COLOR, PAN_BOX_OUTLINE_ALPHA);
167 if (pw->size > PAN_IMAGE_SIZE_THUMB_LARGE)
169 pi = pan_item_image_new(pw, fd, x, y, 10, 10);
170 if (pi->width > x_width) x_width = pi->width;
171 y_height = pi->height;
175 pi = pan_item_thumb_new(pw, fd, x, y);
176 x_width = PAN_THUMB_SIZE;
177 y_height = PAN_THUMB_SIZE;
180 pan_item_size_by_item(pi_day, pi, PAN_BOX_BORDER);
181 pan_item_size_by_item(pi_month, pi_day, PAN_BOX_BORDER);
186 if (total > 0 && count < PAN_GROUP_MAX)
188 y += y_height + PAN_THUMB_GAP;
192 x += x_width + PAN_THUMB_GAP;
202 pan_item_size_coordinates(pi_month, PAN_BOX_BORDER, width, height);
207 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */