1 /*
2     This file is part of darktable,
3     copyright (c) 2020 Aldric Renaudin.
4 
5     darktable is free software: you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation, either version 3 of the License, or
8     (at your option) any later version.
9 
10     darktable is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14 
15     You should have received a copy of the GNU General Public License
16     along with darktable.  If not, see <http://www.gnu.org/licenses/>.
17 */
18 /** a class to manage a collection of zoomable thumbnails for culling or full preview.  */
19 #include "dtgtk/thumbnail.h"
20 #include <gtk/gtk.h>
21 
22 typedef enum dt_culling_mode_t
23 {
24   DT_CULLING_MODE_CULLING = 0, // classic culling mode
25   DT_CULLING_MODE_PREVIEW      // full preview mode
26 } dt_culling_mode_t;
27 
28 typedef enum dt_culling_move_t
29 {
30   DT_CULLING_MOVE_NONE,
31   DT_CULLING_MOVE_LEFT,
32   DT_CULLING_MOVE_UP,
33   DT_CULLING_MOVE_RIGHT,
34   DT_CULLING_MOVE_DOWN,
35   DT_CULLING_MOVE_PAGEUP,
36   DT_CULLING_MOVE_PAGEDOWN,
37   DT_CULLING_MOVE_START,
38   DT_CULLING_MOVE_END
39 } dt_culling_move_t;
40 
41 typedef struct dt_culling_t
42 {
43   dt_culling_mode_t mode;
44 
45   GtkWidget *widget; // GtkLayout -- main widget
46 
47   // list of thumbnails loaded inside main widget (dt_thumbnail_t)
48   GList *list;
49 
50   // rowid of the main shown image inside 'memory.collected_images'
51   int offset;
52   int offset_imgid;
53 
54   int thumbs_count;            // last nb of thumb to display
55   int view_width, view_height; // last main widget size
56   GdkRectangle thumbs_area;    // coordinate of all the currently loaded thumbs area
57 
58   gboolean navigate_inside_selection; // do we navigate inside selection or inside full collection
59   gboolean selection_sync;            // should the selection follow current culling images
60 
61   gboolean select_desactivate;
62 
63   // the global zoom level of all images in the culling view.
64   // scales images from 0 "image to fit" to 1 "100% zoom".
65   float zoom_ratio;
66 
67   gboolean panning;      // are we moving zoomed images ?
68   double pan_x;          // last position during panning
69   double pan_y;          //
70   gboolean mouse_inside; // is the mouse inside culling center view ?
71 
72   gboolean focus; // do we show focus rectangles on images ?
73 
74   dt_thumbnail_overlay_t overlays; // overlays type
75   int overlays_block_timeout;      // overlay block visibility duration
76   gboolean show_tooltips;          // are tooltips visible ?
77 } dt_culling_t;
78 
79 dt_culling_t *dt_culling_new(dt_culling_mode_t mode);
80 // reload all thumbs from scratch.
81 void dt_culling_full_redraw(dt_culling_t *table, gboolean force);
82 // initialise culling offset/naviagtion mode, etc before entering.
83 // if offset is > 0 it'll be used as offset, otherwise offset will be determined by other means
84 void dt_culling_init(dt_culling_t *table, int offset);
85 // move by key actions.
86 // this key accels are not managed here but inside view
87 gboolean dt_culling_key_move(dt_culling_t *table, dt_culling_move_t move);
88 
89 // change the offset imgid. This will recompute everything even if offset doesn't change
90 // because this may means that other images have changed
91 void dt_culling_change_offset_image(dt_culling_t *table, int offset);
92 
93 void dt_culling_zoom_max(dt_culling_t *table);
94 void dt_culling_zoom_fit(dt_culling_t *table);
95 
96 // set the overlays type
97 void dt_culling_set_overlays_mode(dt_culling_t *table, dt_thumbnail_overlay_t over);
98 
99 // update active images list
100 void dt_culling_update_active_images_list(dt_culling_t *table);
101 // modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh
102 // vim: shiftwidth=2 expandtab tabstop=2 cindent
103 // kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
104