Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
thumbtable.h
Go to the documentation of this file.
1
14/*
15 This file is part of darktable,
16 Copyright (C) 2019-2021 darktable developers.
17 Copyright (C) 2022-2025 Aurélien PIERRE.
18
19 darktable is free software: you can redistribute it and/or modify
20 it under the terms of the GNU General Public License as published by
21 the Free Software Foundation, either version 3 of the License, or
22 (at your option) any later version.
23
24 darktable is distributed in the hope that it will be useful,
25 but WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 GNU General Public License for more details.
28
29 You should have received a copy of the GNU General Public License
30 along with darktable. If not, see <http://www.gnu.org/licenses/>.
31*/
32
33#include "dtgtk/thumbnail.h"
34#include "common/dtpthread.h"
35#include "common/darktable.h"
36#include "common/debug.h"
37
38#include <gtk/gtk.h>
39#include <gdk/gdk.h>
40
41#pragma once
42
43
54
55
56
68
69
82
83
84typedef struct dt_thumbtable_t
85{
88
89 GtkWidget *grid; // GtkGrid
90
91 // Store the current number of columns in grid
93
94 // list of thumbnails loaded inside main widget (dt_thumbnail_t)
95 // for filmstrip and filemanager, this is all the images drawn at screen (even partially)
96 // for zoommable, this is all the images in the row drawn at screen. We don't load laterals images on fly.
97 GList *list;
98
99 int thumbs_per_row; // number of image in a row (1 for filmstrip ; MAX_ZOOM for zoomable)
100 int thumb_width; // demanded thumb size (real size can differ of 1 due to rounding)
102 int view_width, view_height; // last main widget size
103
104 gboolean dragging;
105 int last_x, last_y; // last position of cursor during move
106 int drag_dx, drag_dy; // distance of move of the current dragging session
107 dt_thumbnail_t *drag_thumb; // thumb currently dragged (under the mouse)
108
109 // when performing a drag, we store the list of items to drag here
110 // as this can change during the drag and drop (esp. because of the image_over_id)
111 GList *drag_list;
112
113 // nb of thumbnails loaded
114 uint32_t thumb_nb;
115
116 // Set to TRUE once the current collection has been loaded into thumbnails,
117 // reset to FALSE on collection changed events.
118 // When TRUE, we bypass (re)-init of the thumbnails.
121 gboolean configured;
122
123 // Checksum of the collection query for caching
126
129
130 // Our LUT of collection, mapping rowid (index) to imgid (content)
132
133 GtkWidget *scroll_window;
134
135 // References to the scrollbar adjustments belonging to the parent widget
136 GtkAdjustment *v_scrollbar;
137 GtkAdjustment *h_scrollbar;
140
141 // Overlay in which we insert the grid, in central view and filmstrip
142 GtkWidget *parent_overlay;
143
144 // Since GUI and background signals can init/delete/populate/iterate over the same stuff,
145 // ensure iterations don't happen on stuff being deleted at the same time.
146 // Protect only the loops of dynamic size
147 dt_pthread_mutex_t lock;
148
149 // signal that the current collection needs to be entirely flushed unconditionnaly
151
152 // show extended overlays while holding alt key
154
155 // The rowid (aka index in thumbnail sequence) of the last active thumbnail
156 // used as a fallback for missing imgid to sync scrolling when an image is evicted
157 // from current collection
158 int rowid;
159
160 // Set to TRUE to only display the group leader image
162
163 // Thumbnails inner zoom level
165
166 // Show focus regions on thumbnails
169
171
173
174
190
205void dt_thumbtable_event_dnd_received(GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection_data, guint target_type, guint time, gpointer user_data);
206
216
217// set zoom level
220
221// offset all the zoomed thumbnails by the same amount
222void dt_thumbtable_offset_zoom(dt_thumbtable_t *table, const double delta_x, const double delta_y);
223
224void dt_thumbtable_set_focus_regions(dt_thumbtable_t *table, gboolean enable);
226
227void dt_thumbtable_set_focus_peaking(dt_thumbtable_t *table, gboolean enable);
229
230void dt_thumbtable_set_draw_group_borders(dt_thumbtable_t *table, gboolean enable);
232
233// signal that the current collection needs to be flushed entirely before being reloaded
235
236gboolean dt_thumbtable_key_released_grid(GtkWidget *self, GdkEventKey *event, gpointer user_data);
237gboolean dt_thumbtable_key_pressed_grid(GtkWidget *self, GdkEventKey *event, gpointer user_data);
238
239// call this when the history of an image is changed and mipmap cache needs updating.
240// reinit = TRUE will force-flush the existing thumbnail. imgid = -1 applies on all thumbnails in thumbtable.
241void dt_thumbtable_refresh_thumbnail_real(dt_thumbtable_t *table, int32_t imgid, gboolean reinit);
242#define dt_thumbtable_refresh_thumbnail(table, imgid, reinit) DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_LIGHTTABLE, dt_thumbtable_refresh_thumbnail_real, (table), (imgid), (reinit))
243
251
260void dt_thumbtable_select_range(dt_thumbtable_t *table, const int rowid);
261
269
279void dt_thumbtable_dispatch_over(dt_thumbtable_t *table, GdkEventType type, int32_t imgid);
280
287int dt_thumbtable_scroll_to_imgid(dt_thumbtable_t *table, int32_t imgid);
288
295
305
313
314// Scroll to the first-selected image, or default to keyboard "over" then mouse "over", then last active image,
315// in this order.
317
323{
324 gtk_widget_queue_draw(table->grid);
325}
326
327#define dt_thumbtable_redraw(table) DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_LIGHTTABLE, dt_thumbtable_redraw_real, (table))
328
335static inline void dt_thumbtable_show(dt_thumbtable_t *table)
336{
337 gtk_widget_show(table->parent_overlay);
338 gtk_widget_show(table->scroll_window);
339 gtk_widget_show(table->grid);
340
341 // Thumbtable is prevented to configure and update, for
342 // as long as it's hidden. We need to force the update now.
344}
345
350static inline void dt_thumbtable_hide(dt_thumbtable_t *table)
351{
352 gtk_widget_hide(table->parent_overlay);
353 gtk_widget_hide(table->scroll_window);
354 gtk_widget_hide(table->grid);
355}
356
357// clang-format off
358// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
359// vim: shiftwidth=2 expandtab tabstop=2 cindent
360// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
361// clang-format on
int type
Definition common/metadata.c:42
unsigned __int64 uint64_t
Definition strptime.c:71
Definition thumbnail.h:50
Cache entry for a single thumbnail.
Definition thumbtable.h:75
int32_t imgid
Definition thumbtable.h:76
uint32_t history_items
Definition thumbtable.h:80
int32_t groupid
Definition thumbtable.h:77
uint32_t group_members
Definition thumbtable.h:79
dt_thumbnail_t * thumb
Definition thumbtable.h:78
Definition thumbtable.h:85
int last_x
Definition thumbtable.h:105
gboolean focus_peaking
Definition thumbtable.h:168
gboolean collapse_groups
Definition thumbtable.h:161
GtkWidget * grid
Definition thumbtable.h:89
gboolean alternate_mode
Definition thumbtable.h:153
int drag_dy
Definition thumbtable.h:106
int drag_dx
Definition thumbtable.h:106
int min_row_id
Definition thumbtable.h:127
int rowid
Definition thumbtable.h:158
int last_y
Definition thumbtable.h:105
gboolean collection_inited
Definition thumbtable.h:119
int view_height
Definition thumbtable.h:102
dt_thumbtable_mode_t mode
Definition thumbtable.h:86
dt_pthread_mutex_t lock
Definition thumbtable.h:147
gboolean dragging
Definition thumbtable.h:104
GtkAdjustment * v_scrollbar
Definition thumbtable.h:136
GList * list
Definition thumbtable.h:97
dt_thumbtable_zoom_t zoom
Definition thumbtable.h:164
gboolean focus_regions
Definition thumbtable.h:167
GList * drag_list
Definition thumbtable.h:111
int collection_count
Definition thumbtable.h:125
int thumb_width
Definition thumbtable.h:100
double y_position
Definition thumbtable.h:139
gboolean configured
Definition thumbtable.h:121
GtkWidget * scroll_window
Definition thumbtable.h:133
int view_width
Definition thumbtable.h:102
dt_thumbtable_cache_t * lut
Definition thumbtable.h:131
dt_thumbnail_t * drag_thumb
Definition thumbtable.h:107
int max_row_id
Definition thumbtable.h:128
gboolean thumbs_inited
Definition thumbtable.h:120
GtkAdjustment * h_scrollbar
Definition thumbtable.h:137
uint32_t thumb_nb
Definition thumbtable.h:114
double x_position
Definition thumbtable.h:138
int thumbs_per_row
Definition thumbtable.h:99
int grid_cols
Definition thumbtable.h:92
int thumb_height
Definition thumbtable.h:101
dt_thumbnail_overlay_t overlays
Definition thumbtable.h:87
gboolean reset_collection
Definition thumbtable.h:150
GtkWidget * parent_overlay
Definition thumbtable.h:142
uint64_t collection_hash
Definition thumbtable.h:124
gboolean draw_group_borders
Definition thumbtable.h:170
dt_thumbnail_overlay_t
Definition thumbnail.h:42
void dt_thumbtable_set_zoom(dt_thumbtable_t *table, dt_thumbtable_zoom_t level)
Definition thumbtable.c:807
int dt_thumbtable_scroll_to_selection(dt_thumbtable_t *table)
Scroll to show selected content.
Definition thumbtable.c:301
int dt_thumbtable_scroll_to_imgid(dt_thumbtable_t *table, int32_t imgid)
Scroll the view to show a specific image.
Definition thumbtable.c:270
gboolean dt_thumbtable_get_focus_peaking(dt_thumbtable_t *table)
Definition thumbtable.c:851
void dt_thumbtable_update(dt_thumbtable_t *table)
Definition thumbtable.c:734
void dt_thumbtable_offset_zoom(dt_thumbtable_t *table, const double delta_x, const double delta_y)
Definition thumbtable.c:820
void dt_thumbtable_set_active_rowid(dt_thumbtable_t *table)
Update internal active row tracking.
Definition thumbtable.c:229
dt_thumbtable_mode_t
Display modes for the thumbnail table.
Definition thumbtable.h:49
@ DT_THUMBTABLE_MODE_NONE
Definition thumbtable.h:50
@ DT_THUMBTABLE_MODE_FILMSTRIP
Definition thumbtable.h:52
@ DT_THUMBTABLE_MODE_FILEMANAGER
Definition thumbtable.h:51
void dt_thumbtable_configure(dt_thumbtable_t *table)
Definition thumbtable.c:446
void dt_thumbtable_cleanup(dt_thumbtable_t *table)
Definition thumbtable.c:1823
static void dt_thumbtable_redraw_real(dt_thumbtable_t *table)
Definition thumbtable.h:322
gboolean dt_thumbtable_get_focus_regions(dt_thumbtable_t *table)
Definition thumbtable.c:840
void dt_thumbtable_set_focus_peaking(dt_thumbtable_t *table, gboolean enable)
Definition thumbtable.c:845
void dt_thumbtable_event_dnd_received(GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection_data, guint target_type, guint time, gpointer user_data)
Handle drag-and-drop data received.
Definition thumbtable.c:1325
void dt_thumbtable_invert_selection(dt_thumbtable_t *table)
Invert the current selection.
Definition thumbtable.c:1956
dt_thumbtable_zoom_t
Zoom levels for thumbnail display.
Definition thumbtable.h:62
@ DT_THUMBTABLE_ZOOM_TWICE
Definition thumbtable.h:66
@ DT_THUMBTABLE_ZOOM_FULL
Definition thumbtable.h:65
@ DT_THUMBTABLE_ZOOM_HALF
Definition thumbtable.h:64
@ DT_THUMBTABLE_ZOOM_FIT
Definition thumbtable.h:63
static void dt_thumbtable_show(dt_thumbtable_t *table)
Show the thumbnail table widget.
Definition thumbtable.h:335
void dt_thumbtable_set_focus_regions(dt_thumbtable_t *table, gboolean enable)
Definition thumbtable.c:834
int dt_thumbtable_scroll_to_active_rowid(dt_thumbtable_t *table)
Scroll to show the active row.
Definition thumbtable.c:291
gboolean dt_thumbtable_get_draw_group_borders(dt_thumbtable_t *table)
Definition thumbtable.c:864
void dt_thumbtable_dispatch_over(dt_thumbtable_t *table, GdkEventType type, int32_t imgid)
Update the mouse-over image ID with conflict resolution.
Definition thumbtable.c:1972
gboolean dt_thumbtable_key_pressed_grid(GtkWidget *self, GdkEventKey *event, gpointer user_data)
Definition thumbtable.c:1457
void dt_thumbtable_set_overlays_mode(dt_thumbtable_t *table, dt_thumbnail_overlay_t over)
Set the overlay display mode for thumbnails.
Definition thumbtable.c:1142
void dt_thumbtable_refresh_thumbnail_real(dt_thumbtable_t *table, int32_t imgid, gboolean reinit)
Definition thumbtable.c:872
void dt_thumbtable_select_all(dt_thumbtable_t *table)
Select all images in the current grid.
Definition thumbtable.c:1865
void dt_thumbtable_reset_collection(dt_thumbtable_t *table)
Definition thumbtable.c:1636
gboolean dt_thumbtable_key_released_grid(GtkWidget *self, GdkEventKey *event, gpointer user_data)
Definition thumbtable.c:1601
dt_thumbtable_zoom_t dt_thumbtable_get_zoom(dt_thumbtable_t *table)
Definition thumbtable.c:815
void dt_thumbtable_set_parent(dt_thumbtable_t *table, dt_thumbtable_mode_t mode)
Definition thumbtable.c:1845
dt_thumbtable_t * dt_thumbtable_new(dt_thumbtable_mode_t mode)
Create a new thumbnail table widget.
Definition thumbtable.c:1649
void dt_thumbtable_set_draw_group_borders(dt_thumbtable_t *table, gboolean enable)
Definition thumbtable.c:856
void dt_thumbtable_select_range(dt_thumbtable_t *table, const int rowid)
Select a range of images in the collection.
Definition thumbtable.c:1888
static void dt_thumbtable_hide(dt_thumbtable_t *table)
Hide the thumbnail table widget.
Definition thumbtable.h:350
#define dt_thumbtable_redraw(table)
Definition thumbtable.h:327
void dt_thumbtable_update_parent(dt_thumbtable_t *table)
Definition thumbtable.c:1840