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#pragma once
43
44#include "common/darktable.h"
45#include "common/dtpthread.h"
46
47#include "control/settings.h"
48
49#include <gtk/gtk.h>
50#include <inttypes.h>
51#ifdef _OPENMP
52#include <omp.h>
53#endif
54
55#include "control/jobs.h"
56#include "control/progress.h"
57#include "libs/lib.h"
58#include <gtk/gtk.h>
59
60#ifdef _WIN32
61#include <shobjidl.h>
62#endif
63
64#ifdef __cplusplus
65extern "C" {
66#endif
67
69
70typedef GdkCursorType dt_cursor_t;
71
73{
74 /* Widget-space pointer position from the latest motion/button event. */
75 double x;
76 double y;
77 /* Normalized in [0, 1]. */
78 double pressure;
79 gboolean has_pressure;
80 /* Raw tablet tilt axes (typically in [-1, 1]). */
81 double tilt_x;
82 double tilt_y;
83 /* Magnitude of tilt vector, normalized in [0, 1]. */
84 double tilt;
85 gboolean has_tilt;
86 /* Normalized in [0, 1]. */
88 guint32 time_ms;
90
91// called from gui
92void *dt_control_expose(void *voidptr);
93void dt_control_button_pressed(double x, double y, double pressure, int which, int type, uint32_t state);
94void dt_control_button_released(double x, double y, int which, uint32_t state);
95void dt_control_mouse_moved(double x, double y, double pressure, int which);
98void dt_control_key_pressed(GdkEventKey *event);
101gboolean dt_control_configure(GtkWidget *da, GdkEventConfigure *event, gpointer user_data);
102void dt_control_log(const char *msg, ...) __attribute__((format(printf, 1, 2)));
103void dt_toast_log(const char *msg, ...) __attribute__((format(printf, 1, 2)));
104void dt_toast_markup_log(const char *msg, ...) __attribute__((format(printf, 1, 2)));
109void dt_control_draw_busy_msg(cairo_t *cr, int width, int height);
110// disable the possibility to change the cursor shape with dt_control_change_cursor
112// enable the possibility to change the cursor shape with dt_control_change_cursor
114
115void dt_control_change_cursor_EXT(dt_cursor_t cursor, const char *file, int line);
116#define dt_control_change_cursor(cursor) \
117 dt_control_change_cursor_EXT((cursor), __FILE__, __LINE__)
118
124void dt_control_change_cursor_by_name(const char *curs_str);
125
131void dt_control_change_cursor_by_name_and_flush(const char *curs_str);
132
133// set darktable.control->cursor.shape to the desired cursor shape
134void dt_control_queue_cursor_EXT(dt_cursor_t cursor, const char *file, int line);
135#define dt_control_queue_cursor(cursor) \
136 dt_control_queue_cursor_EXT((cursor), __FILE__, __LINE__)
137
138void dt_control_queue_cursor_by_name(const char *curs_str);
139
140// commit the currently set cursor shape from darktable.control->cursor.shape
147void dt_control_set_cursor_visible_EXT(gboolean visible, const char *file, int line);
148#define dt_control_set_cursor_visible(visible) \
149 dt_control_set_cursor_visible_EXT((visible), __FILE__, __LINE__)
150
152void dt_control_save_xmp(const int32_t imgid);
153void dt_control_save_xmps(const GList *imgids, const gboolean check_history);
155
162
168
174
179
184
189
190void dt_ctl_switch_mode_to(const char *mode);
192void dt_ctl_reload_view(const char *mode);
193
194struct dt_control_t;
195
197void dt_control_hinter_message(const struct dt_control_t *s, const char *message);
198
199#define DT_CTL_LOG_SIZE 10
200#define DT_CTL_LOG_MSG_SIZE 1000
201#define DT_CTL_LOG_TIMEOUT 8000
202#define DT_CTL_TOAST_SIZE 10
203#define DT_CTL_TOAST_MSG_SIZE 300
204#define DT_CTL_TOAST_TIMEOUT 5000
210typedef struct dt_control_t
211{
212 // gui related stuff
213 double tabborder;
214 int32_t width, height;
215 pthread_t gui_thread;
221
222 struct
223 {
225 gboolean lock;
229 gchar *shape_str;
232 gboolean hide;
234
235 // message log
240 dt_pthread_mutex_t log_mutex;
241
242 // toast log
247 dt_pthread_mutex_t toast_mutex;
248
249 // gui settings
250 dt_pthread_mutex_t global_mutex, image_mutex;
252
253 // job management
254 int32_t running;
256 dt_pthread_mutex_t queue_mutex, cond_mutex, run_mutex;
257 pthread_cond_t cond;
258 int32_t num_threads;
261
264
265 dt_pthread_mutex_t res_mutex;
269
270 struct
271 {
272 GList *list;
276 dt_pthread_mutex_t mutex;
277
278#ifdef _WIN32
279 ITaskbarList3 *taskbarlist;
280#endif
281
282 // these proxy functions should ONLY be used by control/process.c!
283 struct
284 {
285 dt_lib_module_t *module;
286 void *(*added)(dt_lib_module_t *self, gboolean has_progress_bar, const gchar *message);
289 dt_progress_t *progress);
292 const char *message);
294
296
297 /* proxy */
298 // TODO: this is unused now, but deleting it makes g_free(darktable.control)
299 // segfault on double free or corruption. Find out why.
300 struct
301 {
302
303 struct
304 {
305 dt_lib_module_t *module;
306 void (*set_message)(dt_lib_module_t *self, const gchar *message);
308
310
312
314
315// join all worker threads.
318
319// call this to quit dt
320void dt_control_quit();
321
324
325// thread-safe interface between core and gui.
326// is the locking really needed?
329
332
333#ifdef __cplusplus
334}
335#endif
336
337// clang-format off
338// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
339// vim: shiftwidth=2 expandtab tabstop=2 cindent
340// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
341// clang-format on
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
int type
void dt_ctl_switch_mode_to(const char *mode)
Definition control.c:657
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:416
void dt_control_key_pressed(GdkEventKey *event)
Definition control.c:619
void dt_control_init(dt_control_t *s)
Definition control.c:95
int32_t dt_control_get_mouse_over_id()
Definition control.c:923
void dt_control_draw_busy_msg(cairo_t *cr, int width, int height)
Definition control.c:505
void dt_control_button_pressed(double x, double y, double pressure, int which, int type, uint32_t state)
Definition control.c:706
void * dt_control_expose(void *voidptr)
Definition control.c:534
void dt_ctl_switch_mode_to_by_view(const dt_view_t *view)
Definition control.c:670
void dt_control_queue_cursor_EXT(dt_cursor_t cursor, const char *file, int line)
Definition control.c:376
void dt_control_get_pointer_input(dt_control_pointer_input_t *input)
Definition control.c:89
void dt_control_set_mouse_over_id(int32_t value)
Definition control.c:931
#define DT_CTL_TOAST_SIZE
Definition control.h:202
void dt_control_forbid_change_cursor()
Definition control.c:224
#define DT_CTL_TOAST_MSG_SIZE
Definition control.h:203
void dt_control_queue_redraw_center()
request redraw of center window. This redraws the center view within a gdk critical section to preven...
Definition control.c:861
void dt_control_write_sidecar_files()
void dt_control_quit()
Definition control.c:433
void dt_control_mouse_leave()
Definition control.c:604
void dt_control_toast_busy_enter()
Definition control.c:832
void dt_control_shutdown(dt_control_t *s)
Definition control.c:446
void dt_control_log_busy_leave()
Definition control.c:840
gboolean dt_control_configure(GtkWidget *da, GdkEventConfigure *event, gpointer user_data)
Definition control.c:490
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:326
void void dt_toast_log(const char *msg,...) __attribute__((format(printf
void dt_control_cleanup(dt_control_t *s)
Definition control.c:468
void dt_control_button_released(double x, double y, int which, uint32_t state)
Definition control.c:624
void dt_control_commit_cursor()
Definition control.c:334
void dt_control_set_pointer_input(const dt_control_pointer_input_t *input)
Definition control.c:83
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:274
void dt_control_allow_change_cursor()
Definition control.c:229
int dt_control_running()
Definition control.c:423
void dt_control_save_xmp(const int32_t imgid)
void dt_control_mouse_moved(double x, double y, double pressure, int which)
Definition control.c:614
#define DT_CTL_LOG_SIZE
Definition control.h:199
void void void void dt_control_log_busy_enter()
Definition control.c:824
void dt_control_log(const char *msg,...) __attribute__((format(printf
#define DT_CTL_LOG_MSG_SIZE
Definition control.h:200
void dt_control_delete_images()
void dt_ctl_reload_view(const char *mode)
Definition control.c:676
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:906
void dt_control_hinter_message(const struct dt_control_t *s, const char *message)
Definition control.c:918
int32_t dt_control_get_keyboard_over_id()
Definition control.c:949
void dt_control_toast_redraw()
request redraw of the toast widget. This redraws the message label.
Definition control.c:876
void dt_control_mouse_enter()
Definition control.c:609
void dt_control_change_cursor_EXT(dt_cursor_t cursor, const char *file, int line)
Definition control.c:345
void dt_control_log_redraw()
request redraw of the log widget. This redraws the message label.
Definition control.c:871
void dt_control_navigation_redraw()
request redraw of the navigation widget. This redraws the wiget of the navigation module.
Definition control.c:866
void void void dt_toast_markup_log(const char *msg,...) __attribute__((format(printf
void dt_control_toast_busy_leave()
Definition control.c:848
GdkCursorType dt_cursor_t
Definition control.h:70
void dt_control_queue_cursor_by_name(const char *curs_str)
Queue a GTK named cursor for the next cursor commit.
Definition control.c:398
void dt_control_save_xmps(const GList *imgids, const gboolean check_history)
void dt_control_queue_redraw()
request redraw of the workspace. This redraws the whole workspace within a gdk critical section to pr...
Definition control.c:856
void dt_control_set_keyboard_over_id(int32_t value)
Definition control.c:957
uint32_t view(const dt_view_t *self)
Definition darkroom.c:227
float dt_aligned_pixel_simd_t __attribute__((vector_size(16), aligned(16)))
Enable aggressive floating-point arithmetic optimizations, in denormals handling. Set through user pr...
Definition darktable.h:524
static const dt_aligned_pixel_simd_t value
Definition darktable.h:577
static const float x
@ DT_JOB_QUEUE_MAX
Definition jobs.h:58
#define DT_CTL_WORKER_RESERVED
Definition jobs.h:37
struct _GtkWidget GtkWidget
Definition splash.h:29
const float uint32_t state[4]
double tabborder
Definition control.h:213
pthread_t * thread
Definition control.h:259
dt_pthread_mutex_t mutex
Definition control.h:276
dt_pthread_mutex_t run_mutex
Definition control.h:256
double last_expose_time
Definition control.h:251
int32_t height
Definition control.h:214
struct dt_control_t::@12 cursor
int32_t num_threads
Definition control.h:258
int32_t running
Definition control.h:254
int button_down_which
Definition control.h:216
dt_pthread_mutex_t image_mutex
Definition control.h:250
dt_lib_module_t *void(* set_message)(dt_lib_module_t *self, const gchar *message)
Definition control.h:306
dt_cursor_t shape
Definition control.h:227
void(* destroyed)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance)
Definition control.h:287
double button_y
Definition control.h:217
GList * queues[DT_JOB_QUEUE_MAX]
Definition control.h:262
int button_type
Definition control.h:216
struct dt_control_t::@13 progress_system
int toast_ack
Definition control.h:243
char toast_message[10][300]
Definition control.h:244
gboolean export_scheduled
Definition control.h:255
gchar * shape_str
Definition control.h:229
int history_start
Definition control.h:218
struct dt_control_t::@13::@15 proxy
gchar * current_shape_str
Definition control.h:230
GList * list
Definition control.h:272
void(* message_updated)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance, const char *message)
Definition control.h:291
int toast_busy
Definition control.h:246
pthread_t thread_res[DT_CTL_WORKER_RESERVED]
Definition control.h:268
dt_pthread_mutex_t log_mutex
Definition control.h:240
int32_t width
Definition control.h:214
void(* updated)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance, double value)
Definition control.h:290
pthread_cond_t cond
Definition control.h:257
guint log_message_timeout_id
Definition control.h:238
guint toast_message_timeout_id
Definition control.h:245
size_t list_length
Definition control.h:273
dt_pthread_mutex_t res_mutex
Definition control.h:265
double global_progress
Definition control.h:275
dt_cursor_t current_shape
Definition control.h:228
int toast_pos
Definition control.h:243
pthread_t kick_on_workers_thread
Definition control.h:259
int32_t mouse_over_id
Definition control.h:219
dt_pthread_mutex_t queue_mutex
Definition control.h:256
uint8_t new_res[DT_CTL_WORKER_RESERVED]
Definition control.h:267
dt_job_t * job_res[DT_CTL_WORKER_RESERVED]
Definition control.h:266
struct dt_control_t::@14::@16 hinter
dt_pthread_mutex_t toast_mutex
Definition control.h:247
int32_t keyboard_over_id
Definition control.h:220
char log_message[10][1000]
Definition control.h:237
double button_x
Definition control.h:217
dt_pthread_mutex_t cond_mutex
Definition control.h:256
dt_pthread_mutex_t global_mutex
Definition control.h:250
void(* cancellable)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance, dt_progress_t *progress)
Definition control.h:288
size_t queue_length[DT_JOB_QUEUE_MAX]
Definition control.h:263
gboolean hide
Definition control.h:232
gboolean lock
Definition control.h:225
dt_job_t ** job
Definition control.h:260
pthread_t gui_thread
Definition control.h:215
size_t n_progress_bar
Definition control.h:274
int button_down
Definition control.h:216