Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
control.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2009-2012, 2014-2015 johannes hanika.
4 Copyright (C) 2010-2011 Henrik Andersson.
5 Copyright (C) 2011 Robert Bieber.
6 Copyright (C) 2012 Richard Wonka.
7 Copyright (C) 2012-2017 Tobias Ellinghaus.
8 Copyright (C) 2013 Jochem Kossen.
9 Copyright (C) 2013, 2015 Jérémy Rosen.
10 Copyright (C) 2013 Simon Spannagel.
11 Copyright (C) 2014, 2019-2020 Aldric Renaudin.
12 Copyright (C) 2014, 2020-2021 Pascal Obry.
13 Copyright (C) 2014-2016 Roman Lebedev.
14 Copyright (C) 2015 Bruce Guenter.
15 Copyright (C) 2016-2017 Peter Budai.
16 Copyright (C) 2018 Andreas Schneider.
17 Copyright (C) 2018-2019 Edgardo Hoszowski.
18 Copyright (C) 2018 rawfiner.
19 Copyright (C) 2019, 2022-2023, 2025 Aurélien PIERRE.
20 Copyright (C) 2020 Chris Elston.
21 Copyright (C) 2020-2022 Diederik Ter Rahe.
22 Copyright (C) 2020 Hanno Schwalm.
23 Copyright (C) 2021 Ralf Brown.
24 Copyright (C) 2022 Martin Bařinka.
25 Copyright (C) 2024, 2026 Guillaume Stutin.
26 Copyright (C) 2025 Alynx Zhou.
27
28 darktable is free software: you can redistribute it and/or modify
29 it under the terms of the GNU General Public License as published by
30 the Free Software Foundation, either version 3 of the License, or
31 (at your option) any later version.
32
33 darktable is distributed in the hope that it will be useful,
34 but WITHOUT ANY WARRANTY; without even the implied warranty of
35 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 GNU General Public License for more details.
37
38 You should have received a copy of the GNU General Public License
39 along with darktable. If not, see <http://www.gnu.org/licenses/>.
40*/
41
42#ifndef DT_CONTROL_CONTROL_H
43#define DT_CONTROL_CONTROL_H
44
45
46
47#include <gtk/gtk.h>
48#include "system/dtpthread.h"
49#include <inttypes.h>
50#ifdef _OPENMP
51#include <omp.h>
52#endif
53
54#include "control/jobs.h"
55#include "control/user_message.h" // the message API moved out; still supplied here
56#include "control/redraw.h" // the redraw raisers moved out; still supplied here
57#include "control/progress.h"
58#include "libs/lib.h"
59#include <gtk/gtk.h>
60
61#ifdef _WIN32
62#include <shobjidl.h>
63#endif
64
65#ifdef __cplusplus
66extern "C" {
67#endif
68
70
71typedef GdkCursorType dt_cursor_t;
72
74{
75 /* Widget-space pointer position from the latest motion/button event. */
76 double x;
77 double y;
78 /* Normalized in [0, 1]. */
79 double pressure;
80 gboolean has_pressure;
81 /* Raw tablet tilt axes (typically in [-1, 1]). */
82 double tilt_x;
83 double tilt_y;
84 /* Magnitude of tilt vector, normalized in [0, 1]. */
85 double tilt;
86 gboolean has_tilt;
87 /* Normalized in [0, 1]. */
89 guint32 time_ms;
91
92// called from gui: paint the centre area into @p cr, which is GTK's own double buffer, clipped to
93// the region GTK asked for. Nothing is painted anywhere else and nothing is copied afterwards.
94void dt_control_expose(cairo_t *cr, int width, int height);
95void dt_control_button_pressed(double x, double y, double pressure, int which, int type, uint32_t state);
96
104char *dt_get_main_message_copy(void);
105void dt_set_main_message(char *message);
106void dt_control_button_released(double x, double y, int which, uint32_t state);
107void dt_control_mouse_moved(double x, double y, double pressure, int which);
110void dt_control_key_pressed(GdkEventKey *event);
113gboolean dt_control_configure(GtkWidget *da, GdkEventConfigure *event, gpointer user_data);
114void dt_control_draw_busy_msg(cairo_t *cr, int width, int height);
115// disable the possibility to change the cursor shape with dt_control_change_cursor
117// enable the possibility to change the cursor shape with dt_control_change_cursor
119
120void dt_control_change_cursor_EXT(dt_cursor_t cursor, const char *file, int line);
121#define dt_control_change_cursor(cursor) \
122 dt_control_change_cursor_EXT((cursor), __FILE__, __LINE__)
123
129void dt_control_change_cursor_by_name(const char *curs_str);
130
136void dt_control_change_cursor_by_name_and_flush(const char *curs_str);
137
138// set dt_control_get_global()->cursor.shape to the desired cursor shape
139void dt_control_queue_cursor_EXT(dt_cursor_t cursor, const char *file, int line);
140#define dt_control_queue_cursor(cursor) \
141 dt_control_queue_cursor_EXT((cursor), __FILE__, __LINE__)
142
143void dt_control_queue_cursor_by_name(const char *curs_str);
144
145// commit the currently set cursor shape from dt_control_get_global()->cursor.shape
152void dt_control_set_cursor_visible_EXT(gboolean visible, const char *file, int line);
153#define dt_control_set_cursor_visible(visible) \
154 dt_control_set_cursor_visible_EXT((visible), __FILE__, __LINE__)
155
158
159
161void dt_control_save_xmp(const int32_t imgid);
162void dt_control_save_xmps(const GList *imgids, const gboolean check_history);
163void dt_control_save_xmps_forced(const GList *imgids);
165
171
172void dt_ctl_switch_mode_to(const char *mode);
174
186void dt_ctl_open_image_in_darkroom(const int32_t imgid);
187
188struct dt_control_t;
189
191void dt_control_hinter_message(const struct dt_control_t *s, const char *message);
192
193#define DT_CTL_LOG_SIZE 10
194#define DT_CTL_LOG_MSG_SIZE 1000
195#define DT_CTL_LOG_TIMEOUT 8000
196#define DT_CTL_TOAST_SIZE 10
197#define DT_CTL_TOAST_MSG_SIZE 300
198#define DT_CTL_TOAST_TIMEOUT 5000
204typedef struct dt_control_t
205{
206 // gui related stuff
207 int32_t width, height;
208 pthread_t gui_thread;
213
214 struct
215 {
217 gboolean lock;
221 gchar *shape_str;
224 gboolean hide;
226
227 // message log
232 dt_pthread_mutex_t log_mutex;
233
234 // toast log
239 dt_pthread_mutex_t toast_mutex;
240
241 // gui settings
242 dt_pthread_mutex_t global_mutex, image_mutex;
244
245 // job management
246 int32_t running;
248 dt_pthread_mutex_t queue_mutex, cond_mutex, run_mutex;
249 pthread_cond_t cond;
250 int32_t num_threads;
253
256
257 dt_pthread_mutex_t res_mutex;
261
262 struct
263 {
264 GList *list;
268 dt_pthread_mutex_t mutex;
269
270#ifdef _WIN32
271 ITaskbarList3 *taskbarlist;
272#endif
273
274 // these proxy functions should ONLY be used by control/process.c!
275 struct
276 {
277 dt_lib_module_t *module;
278 void *(*added)(dt_lib_module_t *self, gboolean has_progress_bar, const gchar *message);
281 dt_progress_t *progress);
284 const char *message);
286
288
289 /* proxy */
290 // TODO: this is unused now, but deleting it makes g_free(dt_control_get_global())
291 // segfault on double free or corruption. Find out why.
292 struct
293 {
294
295 struct
296 {
297 dt_lib_module_t *module;
298 void (*set_message)(dt_lib_module_t *self, const gchar *message);
300
302
304
306
307/* The application-wide control singleton. Process-wide by nature (one job system, one
308 * log/toast queue, one pointer state) with no per-call context to ride on, so this
309 * accessor is the end state for the handle; finer encapsulation of its three
310 * sub-services (log/toast, progress, pointer state) is a separate concern.
311 * Implemented by the orchestrator (darktable.c). */
313
314// join all worker threads.
317
318// call this to quit dt
319void dt_control_quit();
320
323
324// thread-safe interface between core and gui.
325// is the locking really needed?
328
331
332#ifdef __cplusplus
333}
334#endif
335
336#endif // DT_CONTROL_CONTROL_H
337
338// clang-format off
339// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
340// vim: shiftwidth=2 expandtab tabstop=2 cindent
341// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
342// clang-format on
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
static const float x
struct _GtkWidget GtkWidget
GtkWidget, opaque, spelled exactly as GTK spells it.
Definition colorspaces.h:98
void dt_ctl_switch_mode_to(const char *mode)
Definition control.c:701
void dt_control_set_cursor_visible_EXT(gboolean visible, const char *file, int line)
Set whether the cursor should be visible or not.
Definition control.c:425
void dt_control_expose(cairo_t *cr, int width, int height)
Definition control.c:594
void dt_control_key_pressed(GdkEventKey *event)
Definition control.c:667
void dt_control_init(dt_control_t *s)
Definition control.c:89
int32_t dt_control_get_mouse_over_id()
Definition control.c:986
void dt_control_draw_busy_msg(cairo_t *cr, int width, int height)
Definition control.c:530
void dt_control_mouse_is_dragging(gboolean state)
Definition control.c:432
void dt_control_button_pressed(double x, double y, double pressure, int which, int type, uint32_t state)
Definition control.c:772
void dt_ctl_switch_mode_to_by_view(const dt_view_t *view)
Definition control.c:714
void dt_control_queue_cursor_EXT(dt_cursor_t cursor, const char *file, int line)
Definition control.c:385
void dt_control_get_pointer_input(dt_control_pointer_input_t *input)
Definition control.c:83
void dt_control_set_mouse_over_id(int32_t value)
Definition control.c:994
#define DT_CTL_TOAST_SIZE
Definition control.h:196
void dt_control_forbid_change_cursor()
Definition control.c:233
#define DT_CTL_TOAST_MSG_SIZE
Definition control.h:197
void dt_control_write_sidecar_files()
void dt_control_quit()
Definition control.c:452
void dt_control_mouse_leave()
Definition control.c:652
void dt_control_shutdown(dt_control_t *s)
Definition control.c:465
void dt_control_mouse_is_painting(gboolean state)
Definition control.c:437
gboolean dt_control_configure(GtkWidget *da, GdkEventConfigure *event, gpointer user_data)
Definition control.c:515
void dt_control_change_cursor_by_name_and_flush(const char *curs_str)
Apply a GTK named cursor immediately and flush display updates.
Definition control.c:335
void dt_control_cleanup(dt_control_t *s)
Definition control.c:493
void dt_control_button_released(double x, double y, int which, uint32_t state)
Definition control.c:672
void dt_control_commit_cursor()
Definition control.c:343
void dt_control_set_pointer_input(const dt_control_pointer_input_t *input)
Definition control.c:77
void dt_control_change_cursor_by_name(const char *curs_str)
Apply a GTK named cursor immediately without replacing the queued cursor state.
Definition control.c:283
void dt_control_allow_change_cursor()
Definition control.c:238
char * dt_get_main_message_copy(void)
Definition darktable.c:583
int dt_control_running()
Definition control.c:442
void dt_control_save_xmp(const int32_t imgid)
void dt_ctl_open_image_in_darkroom(const int32_t imgid)
open one specific image in the darkroom, from any view and any thread.
Definition control.c:745
void dt_control_mouse_moved(double x, double y, double pressure, int which)
Definition control.c:662
#define DT_CTL_LOG_SIZE
Definition control.h:193
#define DT_CTL_LOG_MSG_SIZE
Definition control.h:194
void dt_control_delete_images()
void dt_control_queue_redraw_widget(GtkWidget *widget)
threadsafe request of redraw of specific widget. Use this function if you need to redraw a specific w...
Definition control.c:969
void dt_control_hinter_message(const struct dt_control_t *s, const char *message)
Definition control.c:981
struct dt_control_t * dt_control_get_global(void)
Definition darktable.c:651
int32_t dt_control_get_keyboard_over_id()
Definition control.c:1012
void dt_control_mouse_enter()
Definition control.c:657
void dt_control_change_cursor_EXT(dt_cursor_t cursor, const char *file, int line)
Definition control.c:354
GdkCursorType dt_cursor_t
Definition control.h:71
void dt_control_queue_cursor_by_name(const char *curs_str)
Queue a GTK named cursor for the next cursor commit.
Definition control.c:407
void dt_set_main_message(char *message)
Definition darktable.c:591
void dt_control_save_xmps(const GList *imgids, const gboolean check_history)
void dt_control_save_xmps_forced(const GList *imgids)
void dt_control_set_keyboard_over_id(int32_t value)
Definition control.c:1020
GtkWidget * view
the tree view
@ DT_JOB_QUEUE_MAX
Definition jobs.h:59
#define DT_CTL_WORKER_RESERVED
Definition jobs.h:38
_lib_location_type_t type
Definition location.c:1
uint32_t width
Definition mipmap_cache.c:0
uint32_t height
Definition mipmap_cache.c:1
Asking the interface to repaint itself.
static const dt_aligned_pixel_simd_t value
Definition simd.h:144
const float uint32_t state[4]
pthread_t * thread
Definition control.h:251
dt_pthread_mutex_t mutex
Definition control.h:268
dt_pthread_mutex_t run_mutex
Definition control.h:248
double last_expose_time
Definition control.h:243
int32_t height
Definition control.h:207
int32_t num_threads
Definition control.h:250
int32_t running
Definition control.h:246
dt_pthread_mutex_t image_mutex
Definition control.h:242
dt_lib_module_t *void(* set_message)(dt_lib_module_t *self, const gchar *message)
Definition control.h:298
dt_cursor_t shape
Definition control.h:219
void(* destroyed)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance)
Definition control.h:279
double button_y
Definition control.h:209
GList * queues[DT_JOB_QUEUE_MAX]
Definition control.h:254
int toast_ack
Definition control.h:235
char toast_message[10][300]
Definition control.h:236
gboolean export_scheduled
Definition control.h:247
gchar * shape_str
Definition control.h:221
int history_start
Definition control.h:210
gchar * current_shape_str
Definition control.h:222
GList * list
Definition control.h:264
void(* message_updated)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance, const char *message)
Definition control.h:283
int toast_busy
Definition control.h:238
pthread_t thread_res[DT_CTL_WORKER_RESERVED]
Definition control.h:260
dt_pthread_mutex_t log_mutex
Definition control.h:232
int32_t width
Definition control.h:207
void(* updated)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance, double value)
Definition control.h:282
pthread_cond_t cond
Definition control.h:249
guint log_message_timeout_id
Definition control.h:230
guint toast_message_timeout_id
Definition control.h:237
size_t list_length
Definition control.h:265
dt_pthread_mutex_t res_mutex
Definition control.h:257
double global_progress
Definition control.h:267
dt_cursor_t current_shape
Definition control.h:220
int toast_pos
Definition control.h:235
pthread_t kick_on_workers_thread
Definition control.h:251
int32_t mouse_over_id
Definition control.h:211
dt_pthread_mutex_t queue_mutex
Definition control.h:248
uint8_t new_res[DT_CTL_WORKER_RESERVED]
Definition control.h:259
dt_job_t * job_res[DT_CTL_WORKER_RESERVED]
Definition control.h:258
struct dt_control_t::@7 cursor
dt_pthread_mutex_t toast_mutex
Definition control.h:239
int32_t keyboard_over_id
Definition control.h:212
char log_message[10][1000]
Definition control.h:229
struct dt_control_t::@9::@11 hinter
double button_x
Definition control.h:209
dt_pthread_mutex_t cond_mutex
Definition control.h:248
dt_pthread_mutex_t global_mutex
Definition control.h:242
ITaskbarList3 * taskbarlist
Definition control.h:271
void(* cancellable)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance, dt_progress_t *progress)
Definition control.h:280
size_t queue_length[DT_JOB_QUEUE_MAX]
Definition control.h:255
gboolean hide
Definition control.h:224
gboolean lock
Definition control.h:217
dt_job_t ** job
Definition control.h:252
pthread_t gui_thread
Definition control.h:208
struct dt_control_t::@8 progress_system
size_t n_progress_bar
Definition control.h:266
struct dt_control_t::@8::@10 proxy
Telling the user something happened.