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"
26 #include "pan-view-filter.h"
29 void pan_timeline_compute(PanWindow *pw, FileData *dir_fd, gint *width, gint *height)
35 time_t group_start_date;
38 PanItem *pi_month = nullptr;
39 PanItem *pi_day = nullptr;
45 list = pan_list_tree(dir_fd, SORT_NONE, TRUE, TRUE, pw->ignore_symlinks);
46 pan_filter_fd_list(&list, pw->filter_ui->filter_elements, pw->filter_ui->filter_classes);
48 if (pw->cache_list && pw->exif_date_enable)
50 pw->cache_list = pan_cache_sort(pw->cache_list, SORT_NAME, TRUE, TRUE);
51 list = filelist_sort(list, SORT_NAME, TRUE, TRUE);
52 pan_cache_sync_date(pw, list);
55 pw->cache_list = pan_cache_sort(pw->cache_list, SORT_TIME, TRUE, TRUE);
56 list = filelist_sort(list, SORT_TIME, TRUE, TRUE);
58 *width = PAN_BOX_BORDER * 2;
59 *height = PAN_BOX_BORDER * 2;
64 day_start = month_start;
68 // total and count are used to enforce a stride of PAN_GROUP_MAX thumbs.
77 fd = static_cast<FileData *>(work->data);
80 if (!pan_date_compare(fd->date, group_start_date, PAN_DATE_LENGTH_DAY))
82 // FD starts a new day group.
86 if (!pan_date_compare(fd->date, group_start_date, PAN_DATE_LENGTH_MONTH))
88 // FD starts a new month group.
93 x = pi_month->x + pi_month->width + PAN_BOX_BORDER;
102 buf = pan_date_value_string(fd->date, PAN_DATE_LENGTH_MONTH);
103 pi = pan_item_text_new(pw, x, y, buf,
104 static_cast<PanTextAttrType>(PAN_TEXT_ATTR_BOLD | PAN_TEXT_ATTR_HEADING),
106 PAN_TEXT_COLOR, 255);
110 pi_month = pan_item_box_new(pw, file_data_ref(fd),
112 PAN_BOX_OUTLINE_THICKNESS,
113 PAN_BOX_COLOR, PAN_BOX_ALPHA,
114 PAN_BOX_OUTLINE_COLOR, PAN_BOX_OUTLINE_ALPHA);
121 if (pi_day) x = pi_day->x + pi_day->width + PAN_BOX_BORDER;
123 group_start_date = fd->date;
132 nfd = static_cast<FileData *>(needle->data);
133 if (pan_date_compare(nfd->date, group_start_date, PAN_DATE_LENGTH_DAY))
135 needle = needle->next;
144 buf = pan_date_value_string(fd->date, PAN_DATE_LENGTH_WEEK);
145 pi = pan_item_text_new(pw, x, y, buf, PAN_TEXT_ATTR_NONE,
147 PAN_TEXT_COLOR, 255);
152 pi_day = pan_item_box_new(pw, file_data_ref(fd), x, y, 0, 0,
153 PAN_BOX_OUTLINE_THICKNESS,
154 PAN_BOX_COLOR, PAN_BOX_ALPHA,
155 PAN_BOX_OUTLINE_COLOR, PAN_BOX_OUTLINE_ALPHA);
162 if (pw->size > PAN_IMAGE_SIZE_THUMB_LARGE)
164 pi = pan_item_image_new(pw, fd, x, y, 10, 10);
165 if (pi->width > x_width) x_width = pi->width;
166 y_height = pi->height;
170 pi = pan_item_thumb_new(pw, fd, x, y);
171 x_width = PAN_THUMB_SIZE;
172 y_height = PAN_THUMB_SIZE;
175 pan_item_size_by_item(pi_day, pi, PAN_BOX_BORDER);
176 pan_item_size_by_item(pi_month, pi_day, PAN_BOX_BORDER);
181 if (total > 0 && count < PAN_GROUP_MAX)
183 y += y_height + PAN_THUMB_GAP;
187 x += x_width + PAN_THUMB_GAP;
197 pan_item_size_coordinates(pi_month, PAN_BOX_BORDER, width, height);
202 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */