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) 2019-2021 darktable developers.
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*/
20#pragma once
21
22#include "common/darktable.h"
23#include "common/debug.h"
24
25#include <glib.h>
26#include <gtk/gtk.h>
27
28#define MAX_STARS 5
29
30struct dt_thumbtable_t;
31
40
48
49typedef struct
50{
51 int32_t imgid, rowid, groupid;
52 int width, height; // current thumb size (with the background and the border)
53 int x, y; // current position at screen
54 int img_width, img_height; // current image size (can be greater than the image box in case of zoom)
55
56 gboolean mouse_over;
57 gboolean selected;
58
59 int rating;
61 gchar *filename;
62 gboolean is_altered;
63 gboolean has_audio;
64 gboolean is_grouped;
65 gboolean is_bw;
66 gboolean is_bw_flow;
67 gboolean is_hdr;
68 gboolean has_localcopy;
69
70 // all widget components
71 GtkWidget *widget; // GtkEventbox -- parent of all others
72 GtkWidget *w_main; // GtkOverlay --
73 GtkWidget *w_background; // GtkBox, because a GtkOverlay can't get styling apparently
74 GtkWidget *w_ext; // GtkLabel -- thumbnail extension
75
76 GtkWidget *w_image; // GtkDrawingArea -- thumbnail image
77 cairo_surface_t *img_surf; // cached surface at exact dimensions to speed up redraw
78
79 GtkWidget *w_cursor; // GtkDrawingArea -- triangle to show current image(s) in filmstrip
80 GtkWidget *w_bottom_eb; // GtkEventBox -- background of the bottom infos area (contains w_bottom)
81 GtkWidget *w_reject; // GtkDarktableThumbnailBtn -- Reject icon
82 GtkWidget *w_stars[MAX_STARS]; // GtkDarktableThumbnailBtn -- Stars icons
83 GtkWidget *w_color; // GtkDarktableThumbnailBtn -- Colorlabels "flower" icon
84
85 GtkWidget *w_top_eb;
86 GtkWidget *w_local_copy; // GtkDarktableThumbnailBtn -- localcopy triangle
87 GtkWidget *w_altered; // GtkDarktableThumbnailBtn -- Altered icon
88 GtkWidget *w_group; // GtkDarktableThumbnailBtn -- Grouping icon
89 GtkWidget *w_audio; // GtkDarktableThumbnailBtn -- Audio sidecar icon
90
91 GtkWidget *w_alternative; // alternative overlay
92
93 dt_thumbnail_border_t group_borders; // which group borders should be drawn
94
95 gboolean disable_mouseover; // do we allow to change mouseoverid by mouse move
96 gboolean disable_actions; // do we allow to change rating/etc...
97
98 dt_thumbnail_overlay_t over; // type of overlays
99
100 // difference between the global zoom values and the value to apply to this specific thumbnail
101 double zoomx; // zoom panning of the image
102 double zoomy; //
105 gboolean dragging;
106
107 struct dt_thumbtable_t *table; // convenience reference to the parent
108
109 // Set FALSE when the thumbnail size changed, set TRUE when we have a Cairo image surface for that size
110 gboolean image_inited;
111
113 float iso;
114 float aperture;
115 float speed;
117 float focal;
119 char datetime[200];
120 char camera[128];
121 char lens[128];
122 char folder[PATH_MAX];
123
124 GtkWidget *w_exposure;
125 GtkWidget *w_exposure_bias;
126 GtkWidget *w_camera;
127 GtkWidget *w_filename;
128 GtkWidget *w_datetime;
129 GtkWidget *w_lens;
130 GtkWidget *w_focal;
131 GtkWidget *w_folder;
132
133 // TRUE when the mipmap cache is generating a new thumbnail for us,
134 // and there is nothing yet to paint in the surface.
135 // In that case, don't send more requests to the mipmap cache,
136 // listen and wait for the MIPMAP_UPDATED signal.
137
138 // Number of background jobs handling the backbuf Cairo surface.
139 // Those will fetch a mipmap thumbnail and possibly repaint focus regions on top.
140 // Because they all free/recreate the Cairo buffer internally, we need
141 // at most one job running at a time per thumbnail.
143
144 dt_pthread_mutex_t lock;
145
147
148dt_thumbnail_t *dt_thumbnail_new(int32_t imgid, int rowid, int32_t groupid, dt_thumbnail_overlay_t over, struct dt_thumbtable_t *table);
151void dt_thumbnail_resize(dt_thumbnail_t *thumb, int width, int height);
153void dt_thumbnail_set_mouseover(dt_thumbnail_t *thumb, gboolean over);
155
156// set if the thumbnail should react (mouse_over) to drag and drop
157// note that it's just cosmetic as dropping occurs in thumbtable in any case
158void dt_thumbnail_set_drop(dt_thumbnail_t *thumb, gboolean accept_drop);
159
160// Full update of the image information and update icons accordingly, using the image cache
162
163// Partial (quick) update of the image information from the thumbtable LUT, avoiding image cache lock
165
166// check if the image is selected and set its state and background
167void dt_thumbnail_update_selection(dt_thumbnail_t *thumb, gboolean selected);
168
169// force image recomputing
171#define dt_thumbnail_image_refresh(thumb) DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_LIGHTTABLE, dt_thumbnail_image_refresh_real, (thumb))
172
173void dt_thumbnail_alternative_mode(dt_thumbnail_t *thumb, gboolean enable);
174
175// If prefetching, Gtk won't redraw the invisible thumbnails so we need to manually call this ahead.
176// Return 1 on error.
178
179// Get the number of background jobs currently running.
180// Shouldn't be more than 1 if everything goes well
182{
184 const int value = thumb->background_jobs;
186 assert(value == 0 || value == 1);
187 return value;
188}
189
194
195// clang-format off
196// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
197// vim: shiftwidth=2 expandtab tabstop=2 cindent
198// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
199// clang-format on
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
#define PATH_MAX
Definition darktable.h:824
static int dt_pthread_mutex_unlock(dt_pthread_mutex_t *mutex) RELEASE(mutex) NO_THREAD_SAFETY_ANALYSIS
Definition dtpthread.h:321
static int dt_pthread_mutex_lock(dt_pthread_mutex_t *mutex) ACQUIRE(mutex) NO_THREAD_SAFETY_ANALYSIS
Definition dtpthread.h:311
Definition thumbnail.h:50
gboolean mouse_over
Definition thumbnail.h:56
int img_height
Definition thumbnail.h:54
GtkWidget * w_color
Definition thumbnail.h:83
dt_pthread_mutex_t lock
Definition thumbnail.h:144
gboolean is_bw
Definition thumbnail.h:65
float iso
Definition thumbnail.h:113
gboolean is_hdr
Definition thumbnail.h:67
GtkWidget * w_alternative
Definition thumbnail.h:91
GtkWidget * w_local_copy
Definition thumbnail.h:86
GtkWidget * w_folder
Definition thumbnail.h:131
gboolean is_altered
Definition thumbnail.h:62
gchar * filename
Definition thumbnail.h:61
float aperture
Definition thumbnail.h:114
gboolean dragging
Definition thumbnail.h:105
gboolean disable_actions
Definition thumbnail.h:96
GtkWidget * w_exposure_bias
Definition thumbnail.h:125
float focal
Definition thumbnail.h:117
GtkWidget * w_ext
Definition thumbnail.h:74
GtkWidget * w_datetime
Definition thumbnail.h:128
float focus_distance
Definition thumbnail.h:118
double zoomy
Definition thumbnail.h:102
GtkWidget * w_camera
Definition thumbnail.h:126
int32_t groupid
Definition thumbnail.h:51
GtkWidget * w_main
Definition thumbnail.h:72
gboolean selected
Definition thumbnail.h:57
dt_thumbnail_border_t group_borders
Definition thumbnail.h:93
GtkWidget * w_group
Definition thumbnail.h:88
int background_jobs
Definition thumbnail.h:142
int x
Definition thumbnail.h:53
gboolean image_inited
Definition thumbnail.h:110
float speed
Definition thumbnail.h:115
gboolean is_grouped
Definition thumbnail.h:64
gboolean has_localcopy
Definition thumbnail.h:68
GtkWidget * w_exposure
Definition thumbnail.h:124
int colorlabels
Definition thumbnail.h:60
gboolean has_audio
Definition thumbnail.h:63
gboolean alternative_mode
Definition thumbnail.h:112
GtkWidget * w_audio
Definition thumbnail.h:89
GtkWidget * w_focal
Definition thumbnail.h:130
GtkWidget * w_background
Definition thumbnail.h:73
GtkWidget * w_top_eb
Definition thumbnail.h:85
GtkWidget * w_reject
Definition thumbnail.h:81
GtkWidget * w_lens
Definition thumbnail.h:129
int height
Definition thumbnail.h:52
double drag_x_start
Definition thumbnail.h:103
gboolean is_bw_flow
Definition thumbnail.h:66
struct dt_thumbtable_t * table
Definition thumbnail.h:107
double drag_y_start
Definition thumbnail.h:104
GtkWidget * w_image
Definition thumbnail.h:76
dt_thumbnail_overlay_t over
Definition thumbnail.h:98
cairo_surface_t * img_surf
Definition thumbnail.h:77
GtkWidget * widget
Definition thumbnail.h:71
GtkWidget * w_altered
Definition thumbnail.h:87
float exposure_bias
Definition thumbnail.h:116
int rating
Definition thumbnail.h:59
GtkWidget * w_bottom_eb
Definition thumbnail.h:80
GtkWidget * w_cursor
Definition thumbnail.h:79
GtkWidget * w_filename
Definition thumbnail.h:127
gboolean disable_mouseover
Definition thumbnail.h:95
double zoomx
Definition thumbnail.h:101
Definition thumbtable.h:85
int rowid
Definition thumbtable.h:158
dt_thumbtable_mode_t mode
Definition thumbtable.h:86
dt_thumbnail_overlay_t overlays
Definition thumbtable.h:87
#define MIN(a, b)
Definition thinplate.c:23
void dt_thumbnail_set_drop(dt_thumbnail_t *thumb, gboolean accept_drop)
Definition thumbnail.c:1383
static dt_thumbnail_overlay_t sanitize_overlays(dt_thumbnail_overlay_t overlays)
Definition thumbnail.h:190
#define MAX_STARS
Definition thumbnail.h:28
void dt_thumbnail_update_infos(dt_thumbnail_t *thumb)
Definition thumbnail.c:1190
dt_thumbnail_border_t
Definition thumbnail.h:33
@ DT_THUMBNAIL_BORDER_BOTTOM
Definition thumbnail.h:38
@ DT_THUMBNAIL_BORDER_NONE
Definition thumbnail.h:34
@ DT_THUMBNAIL_BORDER_TOP
Definition thumbnail.h:36
@ DT_THUMBNAIL_BORDER_RIGHT
Definition thumbnail.h:37
@ DT_THUMBNAIL_BORDER_LEFT
Definition thumbnail.h:35
dt_thumbnail_t * dt_thumbnail_new(int32_t imgid, int rowid, int32_t groupid, dt_thumbnail_overlay_t over, struct dt_thumbtable_t *table)
Definition thumbnail.c:1127
void dt_thumbnail_set_mouseover(dt_thumbnail_t *thumb, gboolean over)
Definition thumbnail.c:1366
GtkWidget * dt_thumbnail_create_widget(dt_thumbnail_t *thumb)
Definition thumbnail.c:921
void dt_thumbnail_set_overlay(dt_thumbnail_t *thumb, dt_thumbnail_overlay_t mode)
Definition thumbnail.c:1212
void dt_thumbnail_set_group_border(dt_thumbnail_t *thumb, dt_thumbnail_border_t border)
Definition thumbnail.c:1341
void dt_thumbnail_update_partial_infos(dt_thumbnail_t *thumb)
Definition thumbnail.c:1198
int dt_thumbnail_destroy(dt_thumbnail_t *thumb)
Definition thumbnail.c:1155
static int dt_thumbnail_get_background_jobs(dt_thumbnail_t *thumb)
Definition thumbnail.h:181
int dt_thumbnail_image_refresh_real(dt_thumbnail_t *thumb)
Definition thumbnail.c:1394
void dt_thumbnail_update_selection(dt_thumbnail_t *thumb, gboolean selected)
Definition thumbnail.c:690
void dt_thumbnail_alternative_mode(dt_thumbnail_t *thumb, gboolean enable)
Definition thumbnail.c:720
dt_thumbnail_overlay_t
Definition thumbnail.h:42
@ DT_THUMBNAIL_OVERLAYS_HOVER_NORMAL
Definition thumbnail.h:44
@ DT_THUMBNAIL_OVERLAYS_ALWAYS_NORMAL
Definition thumbnail.h:45
@ DT_THUMBNAIL_OVERLAYS_NONE
Definition thumbnail.h:43
@ DT_THUMBNAIL_OVERLAYS_LAST
Definition thumbnail.h:46
void dt_thumbnail_resize(dt_thumbnail_t *thumb, int width, int height)
Definition thumbnail.c:1302
int dt_thumbnail_get_image_buffer(dt_thumbnail_t *thumb)
Definition thumbnail.c:437