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-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*/
18
19#pragma once
20
21#include "common/darktable.h"
22#include "common/dtpthread.h"
23
24#include "control/settings.h"
25
26#include <gtk/gtk.h>
27#include <inttypes.h>
28#ifdef _OPENMP
29#include <omp.h>
30#endif
31
32#include "control/jobs.h"
33#include "control/progress.h"
34#include "libs/lib.h"
35#include <gtk/gtk.h>
36
37#ifdef _WIN32
38#include <shobjidl.h>
39#endif
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
46
47typedef GdkCursorType dt_cursor_t;
48
49// called from gui
50void *dt_control_expose(void *voidptr);
51void dt_control_button_pressed(double x, double y, double pressure, int which, int type, uint32_t state);
52void dt_control_button_released(double x, double y, int which, uint32_t state);
53void dt_control_mouse_moved(double x, double y, double pressure, int which);
54void dt_control_key_pressed(GdkEventKey *event);
57gboolean dt_control_configure(GtkWidget *da, GdkEventConfigure *event, gpointer user_data);
58void dt_control_log(const char *msg, ...) __attribute__((format(printf, 1, 2)));
59void dt_toast_log(const char *msg, ...) __attribute__((format(printf, 1, 2)));
60void dt_toast_markup_log(const char *msg, ...) __attribute__((format(printf, 1, 2)));
65void dt_control_draw_busy_msg(cairo_t *cr, int width, int height);
66// disable the possibility to change the cursor shape with dt_control_change_cursor
68// enable the possibility to change the cursor shape with dt_control_change_cursor
73
80
86
92
97
102
107
108void dt_ctl_switch_mode_to(const char *mode);
110void dt_ctl_reload_view(const char *mode);
111
112struct dt_control_t;
113
115void dt_control_hinter_message(const struct dt_control_t *s, const char *message);
116
117#define DT_CTL_LOG_SIZE 10
118#define DT_CTL_LOG_MSG_SIZE 1000
119#define DT_CTL_LOG_TIMEOUT 8000
120#define DT_CTL_TOAST_SIZE 10
121#define DT_CTL_TOAST_MSG_SIZE 300
122#define DT_CTL_TOAST_TIMEOUT 5000
128typedef struct dt_control_t
129{
130 // gui related stuff
131 double tabborder;
132 int32_t width, height;
133 pthread_t gui_thread;
140
141 // TODO: move these to some darkroom struct
142 // synchronized navigation
146
147 // message log
152 dt_pthread_mutex_t log_mutex;
153
154 // toast log
159 dt_pthread_mutex_t toast_mutex;
160
161 // gui settings
162 dt_pthread_mutex_t global_mutex, image_mutex;
164
165 // job management
166 int32_t running;
168 dt_pthread_mutex_t queue_mutex, cond_mutex, run_mutex;
169 pthread_cond_t cond;
170 int32_t num_threads;
173
176
177 dt_pthread_mutex_t res_mutex;
181
182 struct
183 {
184 GList *list;
188 dt_pthread_mutex_t mutex;
189
190#ifdef _WIN32
191 ITaskbarList3 *taskbarlist;
192#endif
193
194 // these proxy functions should ONLY be used by control/process.c!
195 struct
196 {
197 dt_lib_module_t *module;
198 void *(*added)(dt_lib_module_t *self, gboolean has_progress_bar, const gchar *message);
201 dt_progress_t *progress);
202 void (*updated)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance, double value);
204 const char *message);
206
208
209 /* proxy */
210 // TODO: this is unused now, but deleting it makes free(darktable.control)
211 // segfault on double free or corruption. Find out why.
212 struct
213 {
214
215 struct
216 {
217 dt_lib_module_t *module;
218 void (*set_message)(dt_lib_module_t *self, const gchar *message);
220
222
224
226
227// join all worker threads.
230
231// call this to quit dt
232void dt_control_quit();
233
236
237// thread-safe interface between core and gui.
238// is the locking really needed?
240void dt_control_set_mouse_over_id(int32_t value);
241
243void dt_control_set_keyboard_over_id(int32_t value);
244
246void dt_control_set_dev_zoom_x(float value);
247
249void dt_control_set_dev_zoom_y(float value);
250
252void dt_control_set_dev_zoom_scale(float value);
253
255void dt_control_set_dev_closeup(int value);
256
259
260#ifdef __cplusplus
261}
262#endif
263
264// clang-format off
265// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
266// vim: shiftwidth=2 expandtab tabstop=2 cindent
267// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
268// 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:42
void dt_ctl_switch_mode_to(const char *mode)
Definition control.c:320
void dt_control_set_dev_zoom_scale(float value)
Definition control.c:639
float dt_control_get_dev_zoom_scale()
Definition control.c:632
void dt_control_key_pressed(GdkEventKey *event)
Definition control.c:282
void dt_control_init(dt_control_t *s)
Definition control.c:46
float dt_control_get_dev_zoom_x()
Definition control.c:604
void dt_control_set_dev_closeup(int value)
Definition control.c:653
int32_t dt_control_get_mouse_over_id()
Definition control.c:563
void dt_control_draw_busy_msg(cairo_t *cr, int width, int height)
Definition control.c:185
void dt_control_button_pressed(double x, double y, double pressure, int which, int type, uint32_t state)
Definition control.c:369
void * dt_control_expose(void *voidptr)
Definition control.c:214
void dt_ctl_switch_mode_to_by_view(const dt_view_t *view)
Definition control.c:333
void dt_control_set_mouse_over_id(int32_t value)
Definition control.c:571
#define DT_CTL_TOAST_SIZE
Definition control.h:120
void dt_control_forbid_change_cursor()
Definition control.c:84
#define DT_CTL_TOAST_MSG_SIZE
Definition control.h:121
void dt_control_change_cursor(dt_cursor_t cursor)
Definition control.c:94
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:524
void dt_control_write_sidecar_files()
Definition control_jobs.c:260
void dt_control_quit()
Definition control.c:115
void dt_control_mouse_leave()
Definition control.c:267
void dt_control_toast_busy_enter()
Definition control.c:495
void dt_control_shutdown(dt_control_t *s)
Definition control.c:128
void dt_control_log_busy_leave()
Definition control.c:503
gboolean dt_control_configure(GtkWidget *da, GdkEventConfigure *event, gpointer user_data)
Definition control.c:170
int dt_control_get_dev_closeup()
Definition control.c:646
void void dt_toast_log(const char *msg,...) __attribute__((format(printf
void dt_control_cleanup(dt_control_t *s)
Definition control.c:150
dt_dev_zoom_t dt_control_get_dev_zoom()
Definition control.c:660
void dt_control_button_released(double x, double y, int which, uint32_t state)
Definition control.c:287
void dt_control_allow_change_cursor()
Definition control.c:89
float dt_control_get_dev_zoom_y()
Definition control.c:618
int dt_control_running()
Definition control.c:105
void dt_control_set_dev_zoom_x(float value)
Definition control.c:611
void dt_control_mouse_moved(double x, double y, double pressure, int which)
Definition control.c:277
#define DT_CTL_LOG_SIZE
Definition control.h:117
void void void void dt_control_log_busy_enter()
Definition control.c:487
void dt_control_set_dev_zoom(dt_dev_zoom_t value)
Definition control.c:667
void dt_control_log(const char *msg,...) __attribute__((format(printf
#define DT_CTL_LOG_MSG_SIZE
Definition control.h:118
void dt_control_delete_images()
Definition control_jobs.c:1588
void dt_ctl_reload_view(const char *mode)
Definition control.c:339
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:550
void dt_control_hinter_message(const struct dt_control_t *s, const char *message)
Definition control.c:558
int32_t dt_control_get_keyboard_over_id()
Definition control.c:589
void dt_control_toast_redraw()
request redraw of the toast widget. This redraws the message label.
Definition control.c:539
void dt_control_mouse_enter()
Definition control.c:272
void dt_control_log_redraw()
request redraw of the log widget. This redraws the message label.
Definition control.c:534
void dt_control_navigation_redraw()
request redraw of the navigation widget. This redraws the wiget of the navigation module.
Definition control.c:529
void void void dt_toast_markup_log(const char *msg,...) __attribute__((format(printf
void dt_control_toast_busy_leave()
Definition control.c:511
GdkCursorType dt_cursor_t
Definition control.h:47
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:519
void dt_control_set_dev_zoom_y(float value)
Definition control.c:625
void dt_control_set_keyboard_over_id(int32_t value)
Definition control.c:597
uint32_t view(const dt_view_t *self)
Definition darkroom.c:114
@ DT_JOB_QUEUE_MAX
Definition jobs.h:49
#define DT_CTL_WORKER_RESERVED
Definition jobs.h:27
dt_dev_zoom_t
Definition settings.h:28
Definition jobs.c:46
Definition progress.c:42
Definition control.h:129
double tabborder
Definition control.h:131
gboolean lock_cursor_shape
Definition control.h:139
pthread_t * thread
Definition control.h:171
dt_pthread_mutex_t mutex
Definition control.h:188
dt_pthread_mutex_t run_mutex
Definition control.h:168
double last_expose_time
Definition control.h:163
int32_t height
Definition control.h:132
int32_t num_threads
Definition control.h:170
int32_t running
Definition control.h:166
int log_ack
Definition control.h:148
struct dt_control_t::@12::@14 proxy
int button_down_which
Definition control.h:134
dt_pthread_mutex_t image_mutex
Definition control.h:162
dt_lib_module_t *void(* set_message)(dt_lib_module_t *self, const gchar *message)
Definition control.h:218
void(* destroyed)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance)
Definition control.h:199
double button_y
Definition control.h:135
GList * queues[DT_JOB_QUEUE_MAX]
Definition control.h:174
struct dt_control_t::@13::@15 hinter
int button_type
Definition control.h:134
int toast_ack
Definition control.h:155
char toast_message[10][300]
Definition control.h:156
gboolean export_scheduled
Definition control.h:167
int history_start
Definition control.h:136
int dev_closeup
Definition control.h:145
float dev_zoom_x
Definition control.h:143
int log_pos
Definition control.h:148
GList * list
Definition control.h:184
void(* message_updated)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance, const char *message)
Definition control.h:203
int toast_busy
Definition control.h:158
pthread_t thread_res[DT_CTL_WORKER_RESERVED]
Definition control.h:180
dt_pthread_mutex_t log_mutex
Definition control.h:152
int32_t width
Definition control.h:132
void(* updated)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance, double value)
Definition control.h:202
pthread_cond_t cond
Definition control.h:169
guint log_message_timeout_id
Definition control.h:150
guint toast_message_timeout_id
Definition control.h:157
size_t list_length
Definition control.h:185
dt_pthread_mutex_t res_mutex
Definition control.h:177
float dev_zoom_scale
Definition control.h:143
double global_progress
Definition control.h:187
int toast_pos
Definition control.h:155
pthread_t kick_on_workers_thread
Definition control.h:171
int32_t mouse_over_id
Definition control.h:137
dt_pthread_mutex_t queue_mutex
Definition control.h:168
uint8_t new_res[DT_CTL_WORKER_RESERVED]
Definition control.h:179
dt_job_t * job_res[DT_CTL_WORKER_RESERVED]
Definition control.h:178
dt_pthread_mutex_t toast_mutex
Definition control.h:159
struct dt_control_t::@12 progress_system
int log_busy
Definition control.h:151
int32_t keyboard_over_id
Definition control.h:138
char log_message[10][1000]
Definition control.h:149
double button_x
Definition control.h:135
dt_pthread_mutex_t cond_mutex
Definition control.h:168
dt_pthread_mutex_t global_mutex
Definition control.h:162
void(* cancellable)(dt_lib_module_t *self, struct dt_lib_backgroundjob_element_t *instance, dt_progress_t *progress)
Definition control.h:200
size_t queue_length[DT_JOB_QUEUE_MAX]
Definition control.h:175
dt_dev_zoom_t dev_zoom
Definition control.h:144
float dev_zoom_y
Definition control.h:143
dt_job_t ** job
Definition control.h:172
pthread_t gui_thread
Definition control.h:133
size_t n_progress_bar
Definition control.h:186
int button_down
Definition control.h:134
Definition backgroundjobs.c:35
GtkWidget * widget
Definition backgroundjobs.c:36
Definition libs/lib.h:75
Definition views/view.h:95
static float __attribute__((__unused__))
Definition thinplate.c:39