Update copyright in all files
[geeqie.git] / src / pan-types.h
1 /*
2  * Copyright (C) 2006 John Ellis
3  * Copyright (C) 2008 - 2016 The Geeqie Team
4  *
5  * Author: John Ellis
6  *
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.
11  *
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.
16  *
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.
20  */
21
22 #ifndef PAN_TYPES_H
23 #define PAN_TYPES_H
24
25 #include "cache.h"
26 #include "cache-loader.h"
27 #include "filedata.h"
28 #include "image.h"
29 #include "image-load.h"
30 #include "pixbuf_util.h"
31 #include "pixbuf-renderer.h"
32 #include "ui_misc.h"
33
34
35 /* thumbnail sizes and spacing */
36
37 #define PAN_THUMB_SIZE_DOTS 4
38 #define PAN_THUMB_SIZE_NONE 24
39 #define PAN_THUMB_SIZE_SMALL 64
40 #define PAN_THUMB_SIZE_NORMAL 128
41 #define PAN_THUMB_SIZE_LARGE 256
42 #define PAN_THUMB_SIZE pw->thumb_size
43
44 #define PAN_THUMB_GAP_DOTS 2
45 #define PAN_THUMB_GAP_SMALL 14
46 #define PAN_THUMB_GAP_NORMAL 30
47 #define PAN_THUMB_GAP_LARGE 40
48 #define PAN_THUMB_GAP_HUGE 50
49 #define PAN_THUMB_GAP pw->thumb_gap
50
51 /* basic sizes, colors, spacings */
52
53 #define PAN_SHADOW_OFFSET 6
54 #define PAN_SHADOW_FADE 5
55 #define PAN_SHADOW_COLOR 0, 0, 0
56 #define PAN_SHADOW_ALPHA 64
57
58 #define PAN_OUTLINE_THICKNESS 1
59 #define PAN_OUTLINE_COLOR_1 255, 255, 255
60 #define PAN_OUTLINE_COLOR_2 64, 64, 64
61 #define PAN_OUTLINE_ALPHA 180
62
63 #define PAN_BACKGROUND_COLOR 150, 150, 150
64
65 #define PAN_GRID_SIZE 60
66 #define PAN_GRID_COLOR 0, 0, 0
67 #define PAN_GRID_ALPHA 20
68
69 #define PAN_BOX_COLOR 255, 255, 255
70 #define PAN_BOX_ALPHA 100
71 #define PAN_BOX_BORDER 20
72
73 #define PAN_BOX_OUTLINE_THICKNESS 4
74 #define PAN_BOX_OUTLINE_COLOR 0, 0, 0
75 #define PAN_BOX_OUTLINE_ALPHA 128
76
77 #define PAN_TEXT_BORDER_SIZE 4
78 #define PAN_TEXT_COLOR 0, 0, 0
79
80 /* popup info box */
81
82 #define PAN_POPUP_COLOR 255, 255, 225
83 #define PAN_POPUP_ALPHA 255
84 #define PAN_POPUP_BORDER 1
85 #define PAN_POPUP_BORDER_COLOR 0, 0, 0
86 #define PAN_POPUP_TEXT_COLOR 0, 0, 0
87
88
89 #define PAN_GROUP_MAX 16
90
91
92
93 typedef enum {
94         PAN_LAYOUT_TIMELINE = 0,
95         PAN_LAYOUT_CALENDAR,
96         PAN_LAYOUT_FOLDERS_LINEAR,
97         PAN_LAYOUT_FOLDERS_FLOWER,
98         PAN_LAYOUT_GRID,
99         PAN_LAYOUT_COUNT
100 } PanLayoutType;
101
102 typedef enum {
103         PAN_IMAGE_SIZE_THUMB_DOTS = 0,
104         PAN_IMAGE_SIZE_THUMB_NONE,
105         PAN_IMAGE_SIZE_THUMB_SMALL,
106         PAN_IMAGE_SIZE_THUMB_NORMAL,
107         PAN_IMAGE_SIZE_THUMB_LARGE,
108         PAN_IMAGE_SIZE_10,
109         PAN_IMAGE_SIZE_25,
110         PAN_IMAGE_SIZE_33,
111         PAN_IMAGE_SIZE_50,
112         PAN_IMAGE_SIZE_100,
113         PAN_IMAGE_SIZE_COUNT
114 } PanImageSize;
115
116 typedef enum {
117         PAN_ITEM_NONE,
118         PAN_ITEM_THUMB,
119         PAN_ITEM_BOX,
120         PAN_ITEM_TRIANGLE,
121         PAN_ITEM_TEXT,
122         PAN_ITEM_IMAGE
123 } PanItemType;
124
125 typedef enum {
126         PAN_TEXT_ATTR_NONE = 0,
127         PAN_TEXT_ATTR_BOLD = 1 << 0,
128         PAN_TEXT_ATTR_HEADING = 1 << 1,
129         PAN_TEXT_ATTR_MARKUP = 1 << 2
130 } PanTextAttrType;
131
132 typedef enum {
133         PAN_BORDER_NONE = 0,
134         PAN_BORDER_1 = 1 << 0,
135         PAN_BORDER_2 = 1 << 1,
136         PAN_BORDER_3 = 1 << 2,
137         PAN_BORDER_4 = 1 << 3
138 } PanBorderType;
139
140 #define PAN_BORDER_TOP          PAN_BORDER_1
141 #define PAN_BORDER_RIGHT                PAN_BORDER_2
142 #define PAN_BORDER_BOTTOM       PAN_BORDER_3
143 #define PAN_BORDER_LEFT         PAN_BORDER_4
144
145
146 typedef struct _PanItem PanItem;
147 struct _PanItem {
148         PanItemType type;
149         gint x;
150         gint y;
151         gint width;
152         gint height;
153         gchar *key;
154
155         FileData *fd;
156
157         GdkPixbuf *pixbuf;
158         gint refcount;
159
160         gchar *text;
161         PanTextAttrType text_attr;
162
163         guint8 color_r;
164         guint8 color_g;
165         guint8 color_b;
166         guint8 color_a;
167
168         guint8 color2_r;
169         guint8 color2_g;
170         guint8 color2_b;
171         guint8 color2_a;
172         gint border;
173
174         gpointer data;
175
176         gboolean queued;
177 };
178
179 typedef struct _PanWindow PanWindow;
180 struct _PanWindow
181 {
182         GtkWidget *window;
183         ImageWindow *imd;
184         ImageWindow *imd_normal;
185         FullScreenData *fs;
186
187         GtkWidget *path_entry;
188
189         GtkWidget *label_message;
190         GtkWidget *label_zoom;
191
192         GtkWidget *search_box;
193         GtkWidget *search_entry;
194         GtkWidget *search_label;
195         GtkWidget *search_button;
196         GtkWidget *search_button_arrow;
197
198         GtkWidget *date_button;
199
200         GtkWidget *scrollbar_h;
201         GtkWidget *scrollbar_v;
202
203         FileData *dir_fd;
204         PanLayoutType layout;
205         PanImageSize size;
206         gint thumb_size;
207         gint thumb_gap;
208         gint image_size;
209         gboolean exif_date_enable;
210
211         gint info_image_size;
212         gboolean info_includes_exif;
213
214         gboolean ignore_symlinks;
215
216         GList *list;
217         GList *list_static;
218         GList *list_grid;
219
220         GList *cache_list;
221         GList *cache_todo;
222         gint cache_count;
223         gint cache_total;
224         gint cache_tick;
225         CacheLoader *cache_cl;
226
227         ImageLoader *il;
228         ThumbLoader *tl;
229         PanItem *queue_pi;
230         GList *queue;
231
232         PanItem *click_pi;
233         PanItem *search_pi;
234
235         gint idle_id;
236 };
237
238 typedef struct _PanGrid PanGrid;
239 struct _PanGrid {
240         gint x;
241         gint y;
242         gint w;
243         gint h;
244         GList *list;
245 };
246
247 typedef struct _PanCacheData PanCacheData;
248 struct _PanCacheData {
249         FileData *fd;
250         CacheData *cd;
251 };
252
253
254 /* pan-view.c */
255
256 GList *pan_layout_intersect(PanWindow *pw, gint x, gint y, gint width, gint height);
257 void pan_layout_resize(PanWindow *pw);
258
259 void pan_cache_sync_date(PanWindow *pw, GList *list);
260
261 GList *pan_cache_sort(GList *list, SortType method, gboolean ascend);
262 /* pan-item.c */
263
264 void pan_item_free(PanItem *pi);
265
266 void pan_item_set_key(PanItem *pi, const gchar *key);
267 void pan_item_added(PanWindow *pw, PanItem *pi);
268 void pan_item_remove(PanWindow *pw, PanItem *pi);
269
270 void pan_item_size_by_item(PanItem *pi, PanItem *child, gint border);
271 void pan_item_size_coordinates(PanItem *pi, gint border, gint *w, gint *h);
272
273
274 PanItem *pan_item_find_by_key(PanWindow *pw, PanItemType type, const gchar *key);
275 GList *pan_item_find_by_path(PanWindow *pw, PanItemType type, const gchar *path,
276                              gboolean ignore_case, gboolean partial);
277 GList *pan_item_find_by_fd(PanWindow *pw, PanItemType type, FileData *fd,
278                              gboolean ignore_case, gboolean partial);
279 PanItem *pan_item_find_by_coord(PanWindow *pw, PanItemType type,
280                                 gint x, gint y, const gchar *key);
281
282
283 PanItem *pan_item_box_new(PanWindow *pw, FileData *fd, gint x, gint y, gint width, gint height,
284                           gint border_size,
285                           guint8 base_r, guint8 base_g, guint8 base_b, guint8 base_a,
286                           guint8 bord_r, guint8 bord_g, guint8 bord_b, guint8 bord_a);
287 void pan_item_box_shadow(PanItem *pi, gint offset, gint fade);
288 gint pan_item_box_draw(PanWindow *pw, PanItem *pi, GdkPixbuf *pixbuf, PixbufRenderer *pr,
289                        gint x, gint y, gint width, gint height);
290
291 PanItem *pan_item_tri_new(PanWindow *pw, FileData *fd, gint x, gint y, gint width, gint height,
292                           gint x1, gint y1, gint x2, gint y2, gint x3, gint y3,
293                           guint8 r, guint8 g, guint8 b, guint8 a);
294 void pan_item_tri_border(PanItem *pi, gint borders,
295                          guint8 r, guint8 g, guint8 b, guint8 a);
296 gint pan_item_tri_draw(PanWindow *pw, PanItem *pi, GdkPixbuf *pixbuf, PixbufRenderer *pr,
297                        gint x, gint y, gint width, gint height);
298
299 PanItem *pan_item_text_new(PanWindow *pw, gint x, gint y, const gchar *text,
300                            PanTextAttrType attr, PanBorderType border,
301                            guint8 r, guint8 g, guint8 b, guint8 a);
302 gint pan_item_text_draw(PanWindow *pw, PanItem *pi, GdkPixbuf *pixbuf, PixbufRenderer *pr,
303                         gint x, gint y, gint width, gint height);
304
305 PanItem *pan_item_thumb_new(PanWindow *pw, FileData *fd, gint x, gint y);
306 gint pan_item_thumb_draw(PanWindow *pw, PanItem *pi, GdkPixbuf *pixbuf, PixbufRenderer *pr,
307                          gint x, gint y, gint width, gint height);
308
309 PanItem *pan_item_image_new(PanWindow *pw, FileData *fd, gint x, gint y, gint w, gint h);
310 gint pan_item_image_draw(PanWindow *pw, PanItem *pi, GdkPixbuf *pixbuf, PixbufRenderer *pr,
311                          gint x, gint y, gint width, gint height);
312
313
314 typedef struct _PanTextAlignment PanTextAlignment;
315 struct _PanTextAlignment {
316         PanWindow *pw;
317
318         GList *column1;
319         GList *column2;
320
321         gint x;
322         gint y;
323         gchar *key;
324 };
325
326 PanTextAlignment *pan_text_alignment_new(PanWindow *pw, gint x, gint y, const gchar *key);
327 void pan_text_alignment_free(PanTextAlignment *ta);
328
329 PanItem *pan_text_alignment_add(PanTextAlignment *ta, const gchar *label, const gchar *text);
330 void pan_text_alignment_calc(PanTextAlignment *ta, PanItem *box);
331
332
333 /* utils in pan-util.c */
334
335 typedef enum {
336         PAN_DATE_LENGTH_EXACT,
337         PAN_DATE_LENGTH_HOUR,
338         PAN_DATE_LENGTH_DAY,
339         PAN_DATE_LENGTH_WEEK,
340         PAN_DATE_LENGTH_MONTH,
341         PAN_DATE_LENGTH_YEAR
342 } PanDateLengthType;
343
344 gboolean pan_date_compare(time_t a, time_t b, PanDateLengthType length);
345 gint pan_date_value(time_t d, PanDateLengthType length);
346 gchar *pan_date_value_string(time_t d,  PanDateLengthType length);
347 time_t pan_date_to_time(gint year, gint month, gint day);
348
349 gboolean pan_is_link_loop(const gchar *s);
350 gboolean pan_is_ignored(const gchar *s, gboolean ignore_symlinks);
351 GList *pan_list_tree(FileData *dir_fd, SortType sort, gboolean ascend,
352                      gboolean ignore_symlinks);
353
354
355 /* the different view types */
356
357 void pan_calendar_update(PanWindow *pw, PanItem *pi_day);
358 void pan_calendar_compute(PanWindow *pw, FileData *dir_fd, gint *width, gint *height);
359 void pan_flower_compute(PanWindow *pw, FileData *dir_fd,
360                         gint *width, gint *height,
361                         gint *scroll_x, gint *scroll_y);
362 void pan_folder_tree_compute(PanWindow *pw, FileData *dir_fd, gint *width, gint *height);
363 void pan_grid_compute(PanWindow *pw, FileData *dir_fd, gint *width, gint *height);
364 void pan_timeline_compute(PanWindow *pw, FileData *dir_fd, gint *width, gint *height);
365
366
367 #endif
368 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */