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
115// set darktable.control->cursor to the desired cursor shape
117// commit the currently set cursor shape from darktable.control->cursor
120void dt_control_save_xmp(const int32_t imgid);
121void dt_control_save_xmps(const GList *imgids, const gboolean check_history);
123
130
136
142
147
152
157
158void dt_ctl_switch_mode_to(const char *mode);
160void dt_ctl_reload_view(const char *mode);
161
162struct dt_control_t;
163
165void dt_control_hinter_message(const struct dt_control_t *s, const char *message);
166
167#define DT_CTL_LOG_SIZE 10
168#define DT_CTL_LOG_MSG_SIZE 1000
169#define DT_CTL_LOG_TIMEOUT 8000
170#define DT_CTL_TOAST_SIZE 10
171#define DT_CTL_TOAST_MSG_SIZE 300
172#define DT_CTL_TOAST_TIMEOUT 5000
178typedef struct dt_control_t
179{
180 // gui related stuff
181 double tabborder;
182 int32_t width, height;
183 pthread_t gui_thread;
190 dt_cursor_t cursor; // cursor to draw at the end of mouse_moved
191
192 // message log
197 dt_pthread_mutex_t log_mutex;
198
199 // toast log
204 dt_pthread_mutex_t toast_mutex;
205
206 // gui settings
207 dt_pthread_mutex_t global_mutex, image_mutex;
209
210 // job management
211 int32_t running;
213 dt_pthread_mutex_t queue_mutex, cond_mutex, run_mutex;
214 pthread_cond_t cond;
215 int32_t num_threads;
218
221
222 dt_pthread_mutex_t res_mutex;
226
227 struct
228 {
229 GList *list;
233 dt_pthread_mutex_t mutex;
234
235#ifdef _WIN32
236 ITaskbarList3 *taskbarlist;
237#endif
238
239 // these proxy functions should ONLY be used by control/process.c!
240 struct
241 {
242 dt_lib_module_t *module;
243 void *(*added)(dt_lib_module_t *self, gboolean has_progress_bar, const gchar *message);
246 dt_progress_t *progress);
249 const char *message);
251
253
254 /* proxy */
255 // TODO: this is unused now, but deleting it makes g_free(darktable.control)
256 // segfault on double free or corruption. Find out why.
257 struct
258 {
259
260 struct
261 {
262 dt_lib_module_t *module;
263 void (*set_message)(dt_lib_module_t *self, const gchar *message);
265
267
269
271
272// join all worker threads.
275
276// call this to quit dt
277void dt_control_quit();
278
281
282// thread-safe interface between core and gui.
283// is the locking really needed?
286
289
290#ifdef __cplusplus
291}
292#endif
293
294// clang-format off
295// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
296// vim: shiftwidth=2 expandtab tabstop=2 cindent
297// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
298// 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
Definition common/metadata.c:62
void dt_ctl_switch_mode_to(const char *mode)
Definition control.c:426
void dt_control_key_pressed(GdkEventKey *event)
Definition control.c:388
void dt_control_init(dt_control_t *s)
Definition control.c:95
int32_t dt_control_get_mouse_over_id()
Definition control.c:669
void dt_control_draw_busy_msg(cairo_t *cr, int width, int height)
Definition control.c:274
void dt_control_button_pressed(double x, double y, double pressure, int which, int type, uint32_t state)
Definition control.c:475
void * dt_control_expose(void *voidptr)
Definition control.c:303
void dt_ctl_switch_mode_to_by_view(const dt_view_t *view)
Definition control.c:439
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:677
#define DT_CTL_TOAST_SIZE
Definition control.h:170
void dt_control_forbid_change_cursor()
Definition control.c:129
#define DT_CTL_TOAST_MSG_SIZE
Definition control.h:171
void dt_control_change_cursor(dt_cursor_t cursor)
Definition control.c:163
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:630
void dt_control_write_sidecar_files()
Definition control_jobs.c:310
void dt_control_quit()
Definition control.c:204
void dt_control_mouse_leave()
Definition control.c:373
void dt_control_toast_busy_enter()
Definition control.c:601
void dt_control_shutdown(dt_control_t *s)
Definition control.c:217
void dt_control_log_busy_leave()
Definition control.c:609
gboolean dt_control_configure(GtkWidget *da, GdkEventConfigure *event, gpointer user_data)
Definition control.c:259
void void dt_toast_log(const char *msg,...) __attribute__((format(printf
void dt_control_cleanup(dt_control_t *s)
Definition control.c:239
void dt_control_button_released(double x, double y, int which, uint32_t state)
Definition control.c:393
void dt_control_commit_cursor()
Definition control.c:188
void dt_control_set_pointer_input(const dt_control_pointer_input_t *input)
Definition control.c:83
void dt_control_allow_change_cursor()
Definition control.c:134
int dt_control_running()
Definition control.c:194
void dt_control_save_xmp(const int32_t imgid)
Definition control_jobs.c:1547
void dt_control_mouse_moved(double x, double y, double pressure, int which)
Definition control.c:383
#define DT_CTL_LOG_SIZE
Definition control.h:167
void void void void dt_control_log_busy_enter()
Definition control.c:593
void dt_control_log(const char *msg,...) __attribute__((format(printf
#define DT_CTL_LOG_MSG_SIZE
Definition control.h:168
void dt_control_delete_images()
Definition control_jobs.c:1657
void dt_ctl_reload_view(const char *mode)
Definition control.c:445
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:656
void dt_control_hinter_message(const struct dt_control_t *s, const char *message)
Definition control.c:664
int32_t dt_control_get_keyboard_over_id()
Definition control.c:695
void dt_control_toast_redraw()
request redraw of the toast widget. This redraws the message label.
Definition control.c:645
void dt_control_mouse_enter()
Definition control.c:378
void dt_control_log_redraw()
request redraw of the log widget. This redraws the message label.
Definition control.c:640
void dt_control_navigation_redraw()
request redraw of the navigation widget. This redraws the wiget of the navigation module.
Definition control.c:635
void void void dt_toast_markup_log(const char *msg,...) __attribute__((format(printf
void dt_control_toast_busy_leave()
Definition control.c:617
GdkCursorType dt_cursor_t
Definition control.h:70
void dt_control_set_cursor(dt_cursor_t cursor)
Definition control.c:183
void dt_control_save_xmps(const GList *imgids, const gboolean check_history)
Definition control_jobs.c:1555
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:625
void dt_control_set_keyboard_over_id(int32_t value)
Definition control.c:703
uint32_t view(const dt_view_t *self)
Definition darkroom.c:194
float dt_aligned_pixel_simd_t __attribute__((vector_size(16), aligned(16)))
Multi-tap smudge source sample with directional jitter.
Definition darktable.h:448
static const dt_aligned_pixel_simd_t value
Definition darktable.h:501
static const float x
Definition iop_profile.h:239
@ DT_JOB_QUEUE_MAX
Definition jobs.h:58
#define DT_CTL_WORKER_RESERVED
Definition jobs.h:37
struct _GtkWidget GtkWidget
Definition splash.h:29
Definition jobs.c:51
Definition progress.c:50
Definition control.h:73
double y
Definition control.h:76
gboolean has_tilt
Definition control.h:85
gboolean has_pressure
Definition control.h:79
double tilt_x
Definition control.h:81
double acceleration
Definition control.h:87
double tilt_y
Definition control.h:82
guint32 time_ms
Definition control.h:88
double x
Definition control.h:75
double tilt
Definition control.h:84
double pressure
Definition control.h:78
Definition control.h:179
double tabborder
Definition control.h:181
gboolean lock_cursor_shape
Definition control.h:189
pthread_t * thread
Definition control.h:216
dt_pthread_mutex_t mutex
Definition control.h:233
dt_pthread_mutex_t run_mutex
Definition control.h:213
double last_expose_time
Definition control.h:208
int32_t height
Definition control.h:182
int32_t num_threads
Definition control.h:215
int32_t running
Definition control.h:211
int log_ack
Definition control.h:193
struct dt_control_t::@12::@14 proxy
int button_down_which
Definition control.h:184
dt_pthread_mutex_t image_mutex
Definition control.h:207
dt_lib_module_t *void(* set_message)(dt_lib_module_t *self, const gchar *message)
Definition control.h:263
void(* destroyed)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance)
Definition control.h:244
double button_y
Definition control.h:185
GList * queues[DT_JOB_QUEUE_MAX]
Definition control.h:219
struct dt_control_t::@13::@15 hinter
int button_type
Definition control.h:184
int toast_ack
Definition control.h:200
char toast_message[10][300]
Definition control.h:201
gboolean export_scheduled
Definition control.h:212
int history_start
Definition control.h:186
int log_pos
Definition control.h:193
GList * list
Definition control.h:229
void(* message_updated)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance, const char *message)
Definition control.h:248
int toast_busy
Definition control.h:203
pthread_t thread_res[DT_CTL_WORKER_RESERVED]
Definition control.h:225
dt_pthread_mutex_t log_mutex
Definition control.h:197
int32_t width
Definition control.h:182
void(* updated)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance, double value)
Definition control.h:247
pthread_cond_t cond
Definition control.h:214
guint log_message_timeout_id
Definition control.h:195
guint toast_message_timeout_id
Definition control.h:202
size_t list_length
Definition control.h:230
dt_pthread_mutex_t res_mutex
Definition control.h:222
dt_cursor_t cursor
Definition control.h:190
double global_progress
Definition control.h:232
int toast_pos
Definition control.h:200
pthread_t kick_on_workers_thread
Definition control.h:216
int32_t mouse_over_id
Definition control.h:187
dt_pthread_mutex_t queue_mutex
Definition control.h:213
uint8_t new_res[DT_CTL_WORKER_RESERVED]
Definition control.h:224
dt_job_t * job_res[DT_CTL_WORKER_RESERVED]
Definition control.h:223
dt_pthread_mutex_t toast_mutex
Definition control.h:204
struct dt_control_t::@12 progress_system
int log_busy
Definition control.h:196
int32_t keyboard_over_id
Definition control.h:188
char log_message[10][1000]
Definition control.h:194
double button_x
Definition control.h:185
dt_pthread_mutex_t cond_mutex
Definition control.h:213
dt_pthread_mutex_t global_mutex
Definition control.h:207
void(* cancellable)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance, dt_progress_t *progress)
Definition control.h:245
size_t queue_length[DT_JOB_QUEUE_MAX]
Definition control.h:220
dt_job_t ** job
Definition control.h:217
pthread_t gui_thread
Definition control.h:183
size_t n_progress_bar
Definition control.h:231
int button_down
Definition control.h:184
Definition backgroundjobs.c:51
Definition libs/lib.h:78
Definition views/view.h:123