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
153
154
156void dt_control_save_xmp(const int32_t imgid);
157void dt_control_save_xmps(const GList *imgids, const gboolean check_history);
159
166
172
178
183
188
193
194void dt_ctl_switch_mode_to(const char *mode);
196void dt_ctl_reload_view(const char *mode);
197
198struct dt_control_t;
199
201void dt_control_hinter_message(const struct dt_control_t *s, const char *message);
202
203#define DT_CTL_LOG_SIZE 10
204#define DT_CTL_LOG_MSG_SIZE 1000
205#define DT_CTL_LOG_TIMEOUT 8000
206#define DT_CTL_TOAST_SIZE 10
207#define DT_CTL_TOAST_MSG_SIZE 300
208#define DT_CTL_TOAST_TIMEOUT 5000
214typedef struct dt_control_t
215{
216 // gui related stuff
217 double tabborder;
218 int32_t width, height;
219 pthread_t gui_thread;
225
226 struct
227 {
229 gboolean lock;
233 gchar *shape_str;
236 gboolean hide;
238
239 // message log
244 dt_pthread_mutex_t log_mutex;
245
246 // toast log
251 dt_pthread_mutex_t toast_mutex;
252
253 // gui settings
254 dt_pthread_mutex_t global_mutex, image_mutex;
256
257 // job management
258 int32_t running;
260 dt_pthread_mutex_t queue_mutex, cond_mutex, run_mutex;
261 pthread_cond_t cond;
262 int32_t num_threads;
265
268
269 dt_pthread_mutex_t res_mutex;
273
274 struct
275 {
276 GList *list;
280 dt_pthread_mutex_t mutex;
281
282#ifdef _WIN32
283 ITaskbarList3 *taskbarlist;
284#endif
285
286 // these proxy functions should ONLY be used by control/process.c!
287 struct
288 {
289 dt_lib_module_t *module;
290 void *(*added)(dt_lib_module_t *self, gboolean has_progress_bar, const gchar *message);
293 dt_progress_t *progress);
296 const char *message);
298
300
301 /* proxy */
302 // TODO: this is unused now, but deleting it makes g_free(darktable.control)
303 // segfault on double free or corruption. Find out why.
304 struct
305 {
306
307 struct
308 {
309 dt_lib_module_t *module;
310 void (*set_message)(dt_lib_module_t *self, const gchar *message);
312
314
316
318
319// join all worker threads.
322
323// call this to quit dt
324void dt_control_quit();
325
328
329// thread-safe interface between core and gui.
330// is the locking really needed?
333
336
337#ifdef __cplusplus
338}
339#endif
340
341// clang-format off
342// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
343// vim: shiftwidth=2 expandtab tabstop=2 cindent
344// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
345// 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:673
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:635
void dt_control_init(dt_control_t *s)
Definition control.c:95
int32_t dt_control_get_mouse_over_id()
Definition control.c:939
void dt_control_draw_busy_msg(cairo_t *cr, int width, int height)
Definition control.c:521
void dt_control_mouse_is_dragging(gboolean state)
Definition control.c:423
void dt_control_button_pressed(double x, double y, double pressure, int which, int type, uint32_t state)
Definition control.c:722
void * dt_control_expose(void *voidptr)
Definition control.c:550
void dt_ctl_switch_mode_to_by_view(const dt_view_t *view)
Definition control.c:686
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:947
#define DT_CTL_TOAST_SIZE
Definition control.h:206
void dt_control_forbid_change_cursor()
Definition control.c:224
#define DT_CTL_TOAST_MSG_SIZE
Definition control.h:207
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:877
void dt_control_write_sidecar_files()
void dt_control_quit()
Definition control.c:443
void dt_control_mouse_leave()
Definition control.c:620
void dt_control_toast_busy_enter()
Definition control.c:848
void dt_control_shutdown(dt_control_t *s)
Definition control.c:456
void dt_control_log_busy_leave()
Definition control.c:856
void dt_control_mouse_is_painting(gboolean state)
Definition control.c:428
gboolean dt_control_configure(GtkWidget *da, GdkEventConfigure *event, gpointer user_data)
Definition control.c:506
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:484
void dt_control_button_released(double x, double y, int which, uint32_t state)
Definition control.c:640
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:433
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:630
#define DT_CTL_LOG_SIZE
Definition control.h:203
void void void void dt_control_log_busy_enter()
Definition control.c:840
void dt_control_log(const char *msg,...) __attribute__((format(printf
#define DT_CTL_LOG_MSG_SIZE
Definition control.h:204
void dt_control_delete_images()
void dt_ctl_reload_view(const char *mode)
Definition control.c:692
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:922
void dt_control_hinter_message(const struct dt_control_t *s, const char *message)
Definition control.c:934
int32_t dt_control_get_keyboard_over_id()
Definition control.c:965
void dt_control_toast_redraw()
request redraw of the toast widget. This redraws the message label.
Definition control.c:892
void dt_control_mouse_enter()
Definition control.c:625
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:887
void dt_control_navigation_redraw()
request redraw of the navigation widget. This redraws the wiget of the navigation module.
Definition control.c:882
void void void dt_toast_markup_log(const char *msg,...) __attribute__((format(printf
void dt_control_toast_busy_leave()
Definition control.c:864
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:872
void dt_control_set_keyboard_over_id(int32_t value)
Definition control.c:973
uint32_t view(const dt_view_t *self)
Definition darkroom.c:228
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:546
static const dt_aligned_pixel_simd_t value
Definition darktable.h:599
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:217
pthread_t * thread
Definition control.h:263
dt_pthread_mutex_t mutex
Definition control.h:280
dt_pthread_mutex_t run_mutex
Definition control.h:260
double last_expose_time
Definition control.h:255
int32_t height
Definition control.h:218
struct dt_control_t::@12 cursor
int32_t num_threads
Definition control.h:262
int32_t running
Definition control.h:258
int button_down_which
Definition control.h:220
dt_pthread_mutex_t image_mutex
Definition control.h:254
dt_lib_module_t *void(* set_message)(dt_lib_module_t *self, const gchar *message)
Definition control.h:310
dt_cursor_t shape
Definition control.h:231
void(* destroyed)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance)
Definition control.h:291
double button_y
Definition control.h:221
GList * queues[DT_JOB_QUEUE_MAX]
Definition control.h:266
int button_type
Definition control.h:220
struct dt_control_t::@13 progress_system
int toast_ack
Definition control.h:247
char toast_message[10][300]
Definition control.h:248
gboolean export_scheduled
Definition control.h:259
gchar * shape_str
Definition control.h:233
int history_start
Definition control.h:222
struct dt_control_t::@13::@15 proxy
gchar * current_shape_str
Definition control.h:234
GList * list
Definition control.h:276
void(* message_updated)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance, const char *message)
Definition control.h:295
int toast_busy
Definition control.h:250
pthread_t thread_res[DT_CTL_WORKER_RESERVED]
Definition control.h:272
dt_pthread_mutex_t log_mutex
Definition control.h:244
int32_t width
Definition control.h:218
void(* updated)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance, double value)
Definition control.h:294
pthread_cond_t cond
Definition control.h:261
guint log_message_timeout_id
Definition control.h:242
guint toast_message_timeout_id
Definition control.h:249
size_t list_length
Definition control.h:277
dt_pthread_mutex_t res_mutex
Definition control.h:269
double global_progress
Definition control.h:279
dt_cursor_t current_shape
Definition control.h:232
int toast_pos
Definition control.h:247
pthread_t kick_on_workers_thread
Definition control.h:263
int32_t mouse_over_id
Definition control.h:223
dt_pthread_mutex_t queue_mutex
Definition control.h:260
uint8_t new_res[DT_CTL_WORKER_RESERVED]
Definition control.h:271
dt_job_t * job_res[DT_CTL_WORKER_RESERVED]
Definition control.h:270
struct dt_control_t::@14::@16 hinter
dt_pthread_mutex_t toast_mutex
Definition control.h:251
int32_t keyboard_over_id
Definition control.h:224
char log_message[10][1000]
Definition control.h:241
double button_x
Definition control.h:221
dt_pthread_mutex_t cond_mutex
Definition control.h:260
dt_pthread_mutex_t global_mutex
Definition control.h:254
void(* cancellable)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance, dt_progress_t *progress)
Definition control.h:292
size_t queue_length[DT_JOB_QUEUE_MAX]
Definition control.h:267
gboolean hide
Definition control.h:236
gboolean lock
Definition control.h:229
dt_job_t ** job
Definition control.h:264
pthread_t gui_thread
Definition control.h:219
size_t n_progress_bar
Definition control.h:278
int button_down
Definition control.h:220