Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
thumbnail.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2010-2011 Henrik Andersson.
4 Copyright (C) 2010, 2012 johannes hanika.
5 Copyright (C) 2012 Richard Wonka.
6 Copyright (C) 2013, 2021 Pascal Obry.
7 Copyright (C) 2014, 2016, 2020 Tobias Ellinghaus.
8 Copyright (C) 2018 Rick Yorgason.
9 Copyright (C) 2019 Philippe Weyland.
10 Copyright (C) 2020-2021 Aldric Renaudin.
11 Copyright (C) 2020 Hanno Schwalm.
12 Copyright (C) 2020 Tianhao Chai.
13 Copyright (C) 2021 Fabio Heer.
14 Copyright (C) 2021 luzpaz.
15 Copyright (C) 2022-2023, 2025-2026 Aurélien PIERRE.
16 Copyright (C) 2022 Martin Bařinka.
17 Copyright (C) 2022 Nicolas Auffray.
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*/
34#pragma once
35
36#include "common/atomic.h"
37#include "common/darktable.h"
38#include "common/debug.h"
40
41#include <glib.h>
42#include <gtk/gtk.h>
43
44#define MAX_STARS 5
45
46struct dt_thumbtable_t;
47
56
64
65
66typedef struct
67{
68 int32_t rowid;
69 int width, height; // current thumb size (with the background and the border)
70 int x, y; // current position at screen
71 int img_width, img_height; // current image size (can be greater than the image box in case of zoom)
72
73 gboolean mouse_over;
74 gboolean selected;
75
77
78 // all widget components
79 GtkWidget *widget; // GtkEventbox -- parent of all others
80 GtkWidget *w_main; // GtkOverlay --
81 GtkWidget *w_background; // GtkBox, because a GtkOverlay can't get styling apparently
82 GtkWidget *w_ext; // GtkLabel -- thumbnail extension
83
84 GtkWidget *w_image; // GtkDrawingArea -- thumbnail image
85 cairo_surface_t *img_surf; // cached surface at exact dimensions to speed up redraw
86
87 GtkWidget *w_cursor; // GtkDrawingArea -- triangle to show current image(s) in filmstrip
88 GtkWidget *w_bottom_eb; // GtkEventBox -- background of the bottom infos area (contains w_bottom)
89 GtkWidget *w_reject; // GtkDarktableThumbnailBtn -- Reject icon
90 GtkWidget *w_stars[MAX_STARS]; // GtkDarktableThumbnailBtn -- Stars icons
91 GtkWidget *w_color; // GtkDarktableThumbnailBtn -- Colorlabels "flower" icon
92
94 GtkWidget *w_local_copy; // GtkDarktableThumbnailBtn -- localcopy triangle
95 GtkWidget *w_altered; // GtkDarktableThumbnailBtn -- Altered icon
96 GtkWidget *w_group; // GtkDarktableThumbnailBtn -- Grouping icon
97 GtkWidget *w_audio; // GtkDarktableThumbnailBtn -- Audio sidecar icon
98
99 GtkWidget *w_alternative; // alternative overlay
100
101 dt_thumbnail_border_t group_borders; // which group borders should be drawn
102
103 gboolean disable_mouseover; // do we allow to change mouseoverid by mouse move
104 gboolean disable_actions; // do we allow to change rating/etc...
105
106 dt_thumbnail_overlay_t over; // type of overlays
107
108 // difference between the global zoom values and the value to apply to this specific thumbnail
109 double zoomx; // zoom panning of the image
110 double zoomy; //
113 gboolean dragging;
114
115 struct dt_thumbtable_t *table; // convenience reference to the parent
116
117 // Set FALSE when the thumbnail size changed, set TRUE when we have a Cairo image surface for that size
118 gboolean image_inited;
119
129
130 dt_pthread_mutex_t lock;
131 struct _dt_job_t *job;
133
134 // Thumbnail actual image sizes (bounding box of GUI widget)
135 int img_w;
136 int img_h;
137
139
141 dt_image_t *info);
144void dt_thumbnail_resize(dt_thumbnail_t *thumb, int width, int height);
146void dt_thumbnail_set_mouseover(dt_thumbnail_t *thumb, gboolean over);
148
149// set if the thumbnail should react (mouse_over) to drag and drop
150// note that it's just cosmetic as dropping occurs in thumbtable in any case
151void dt_thumbnail_set_drop(dt_thumbnail_t *thumb, gboolean accept_drop);
152
153// Resync cached image info for this thumbnail with any arbitrary new info
154void dt_thumbnail_resync_info(dt_thumbnail_t *thumb, const dt_image_t *const info);
155
156// Full update of the image information and update icons accordingly, using the image cache
158
159// check if the image is selected and set its state and background
160void dt_thumbnail_update_selection(dt_thumbnail_t *thumb, gboolean selected);
161
162// force image recomputing
164#define dt_thumbnail_image_refresh(thumb) DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_LIGHTTABLE, dt_thumbnail_image_refresh_real, (thumb))
165
167
168// If prefetching, Gtk won't redraw the invisible thumbnails so we need to manually call this ahead.
169// Return 1 on error.
171
176
177// clang-format off
178// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
179// vim: shiftwidth=2 expandtab tabstop=2 cindent
180// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
181// clang-format on
atomic_int dt_atomic_int
Definition atomic.h:63
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
static gboolean enable(dt_image_t *image)
Definition highlights.c:2785
struct _GtkWidget GtkWidget
Definition splash.h:29
Definition jobs.c:51
Definition common/image.h:247
Definition thumbnail.h:67
int img_h
Definition thumbnail.h:136
gboolean mouse_over
Definition thumbnail.h:73
int img_height
Definition thumbnail.h:71
int img_w
Definition thumbnail.h:135
GtkWidget * w_color
Definition thumbnail.h:91
dt_pthread_mutex_t lock
Definition thumbnail.h:130
GtkWidget * w_alternative
Definition thumbnail.h:99
GtkWidget * w_local_copy
Definition thumbnail.h:94
GtkWidget * w_folder
Definition thumbnail.h:128
gboolean dragging
Definition thumbnail.h:113
gboolean disable_actions
Definition thumbnail.h:104
GtkWidget * w_exposure_bias
Definition thumbnail.h:122
dt_image_t info
Definition thumbnail.h:76
GtkWidget * w_ext
Definition thumbnail.h:82
GtkWidget * w_datetime
Definition thumbnail.h:125
dt_atomic_int destroying
Definition thumbnail.h:132
double zoomy
Definition thumbnail.h:110
GtkWidget * w_camera
Definition thumbnail.h:123
GtkWidget * w_main
Definition thumbnail.h:80
gboolean selected
Definition thumbnail.h:74
dt_thumbnail_border_t group_borders
Definition thumbnail.h:101
struct _dt_job_t * job
Definition thumbnail.h:131
int32_t rowid
Definition thumbnail.h:68
GtkWidget * w_group
Definition thumbnail.h:96
int x
Definition thumbnail.h:70
gboolean image_inited
Definition thumbnail.h:118
GtkWidget * w_exposure
Definition thumbnail.h:121
gboolean alternative_mode
Definition thumbnail.h:120
GtkWidget * w_audio
Definition thumbnail.h:97
GtkWidget * w_focal
Definition thumbnail.h:127
GtkWidget * w_background
Definition thumbnail.h:81
GtkWidget * w_top_eb
Definition thumbnail.h:93
GtkWidget * w_reject
Definition thumbnail.h:89
GtkWidget * w_lens
Definition thumbnail.h:126
int height
Definition thumbnail.h:69
double drag_x_start
Definition thumbnail.h:111
struct dt_thumbtable_t * table
Definition thumbnail.h:115
double drag_y_start
Definition thumbnail.h:112
GtkWidget * w_image
Definition thumbnail.h:84
dt_thumbnail_overlay_t over
Definition thumbnail.h:106
cairo_surface_t * img_surf
Definition thumbnail.h:85
GtkWidget * widget
Definition thumbnail.h:79
GtkWidget * w_altered
Definition thumbnail.h:95
GtkWidget * w_bottom_eb
Definition thumbnail.h:88
GtkWidget * w_cursor
Definition thumbnail.h:87
GtkWidget * w_filename
Definition thumbnail.h:124
gboolean disable_mouseover
Definition thumbnail.h:103
double zoomx
Definition thumbnail.h:109
Definition thumbtable.h:96
#define MIN(a, b)
Definition thinplate.c:32
void dt_thumbnail_set_drop(dt_thumbnail_t *thumb, gboolean accept_drop)
Definition thumbnail.c:1557
static dt_thumbnail_overlay_t sanitize_overlays(dt_thumbnail_overlay_t overlays)
Definition thumbnail.h:172
#define MAX_STARS
Definition thumbnail.h:44
dt_thumbnail_border_t
Definition thumbnail.h:49
@ DT_THUMBNAIL_BORDER_BOTTOM
Definition thumbnail.h:54
@ DT_THUMBNAIL_BORDER_NONE
Definition thumbnail.h:50
@ DT_THUMBNAIL_BORDER_TOP
Definition thumbnail.h:52
@ DT_THUMBNAIL_BORDER_RIGHT
Definition thumbnail.h:53
@ DT_THUMBNAIL_BORDER_LEFT
Definition thumbnail.h:51
dt_thumbnail_t * dt_thumbnail_new(int rowid, dt_thumbnail_overlay_t over, struct dt_thumbtable_t *table, dt_image_t *info)
Definition thumbnail.c:1314
void dt_thumbnail_set_mouseover(dt_thumbnail_t *thumb, gboolean over)
Definition thumbnail.c:1540
GtkWidget * dt_thumbnail_create_widget(dt_thumbnail_t *thumb)
Definition thumbnail.c:1088
void dt_thumbnail_resync_info(dt_thumbnail_t *thumb, const dt_image_t *const info)
Definition thumbnail.c:1294
void dt_thumbnail_set_overlay(dt_thumbnail_t *thumb, dt_thumbnail_overlay_t mode)
Definition thumbnail.c:1386
void dt_thumbnail_set_group_border(dt_thumbnail_t *thumb, dt_thumbnail_border_t border)
Definition thumbnail.c:1515
int dt_thumbnail_destroy(dt_thumbnail_t *thumb)
Definition thumbnail.c:1341
int dt_thumbnail_image_refresh_real(dt_thumbnail_t *thumb)
Definition thumbnail.c:1568
void dt_thumbnail_update_gui(dt_thumbnail_t *thumb)
Definition thumbnail.c:1375
void dt_thumbnail_update_selection(dt_thumbnail_t *thumb, gboolean selected)
Definition thumbnail.c:853
void dt_thumbnail_alternative_mode(dt_thumbnail_t *thumb, gboolean enable)
Definition thumbnail.c:887
dt_thumbnail_overlay_t
Definition thumbnail.h:58
@ DT_THUMBNAIL_OVERLAYS_HOVER_NORMAL
Definition thumbnail.h:60
@ DT_THUMBNAIL_OVERLAYS_ALWAYS_NORMAL
Definition thumbnail.h:61
@ DT_THUMBNAIL_OVERLAYS_NONE
Definition thumbnail.h:59
@ DT_THUMBNAIL_OVERLAYS_LAST
Definition thumbnail.h:62
void dt_thumbnail_resize(dt_thumbnail_t *thumb, int width, int height)
Definition thumbnail.c:1476
int dt_thumbnail_get_image_buffer(dt_thumbnail_t *thumb)
Definition thumbnail.c:554