Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
preset_repository.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2026 Aurélien PIERRE.
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
30#ifndef DT_DATABASE_PRESET_REPOSITORY_H
31#define DT_DATABASE_PRESET_REPOSITORY_H
32
33#include <glib.h>
34#include <stdint.h>
35
37
49typedef struct dt_preset_t
50{
51 gchar *name;
53 gchar *operation;
55
56 /* the conditions under which this preset auto-applies */
57 gchar *model;
58 gchar *maker;
59 gchar *lens;
64
65 /* the module parameters themselves, as raw blobs */
66 void *op_params;
72
75 gchar *multi_name;
76 int filter;
77 int def;
78 int format;
80
83
86
95
96/* ---------------------------------------------------------------------------------------
97 * Module presets
98 *
99 * The same table, seen the way a preset menu sees it: one module's presets, keyed by
100 * `(operation, op_version)`. A preset created this way is a name plus a parameter blob;
101 * every auto-apply condition is set to a wildcard, since a menu preset is applied by
102 * being picked, not by matching an image.
103 * ------------------------------------------------------------------------------------- */
104
106typedef struct dt_module_preset_t
107{
108 gchar *name;
109 gchar *description;
113 int rowid;
114 gboolean writeprotect;
115
116 /* IOP presets only -- a lib module has no blending. NULL / 0 otherwise. */
122
124void dt_module_preset_free(gpointer data);
125
137GList *dt_preset_repository_list_for_module(const char *operation, const int op_version,
138 const gboolean with_description,
139 const gboolean shipped_first);
140
147GList *dt_preset_repository_list_all_versions(const char *operation);
148
150GList *dt_preset_repository_list_for_version(const char *operation, const int op_version);
151
153gboolean dt_preset_repository_module_preset_exists(const char *operation, const int op_version,
154 const char *name);
155
157int dt_preset_repository_find_rowid(const char *operation, const int op_version, const char *name);
158
160dt_module_preset_t *dt_preset_repository_get_module_preset(const char *operation, const int op_version,
161 const char *name);
162
173void dt_preset_repository_add_module_preset(const char *name, const char *operation,
174 const int op_version, const void *params,
175 const int params_size);
176
184void dt_preset_repository_add_shipped_preset(const char *name, const char *operation,
185 const int op_version, const void *params,
186 const int params_size, const int writeprotect);
187
189void dt_preset_repository_update_module_params(const char *operation, const char *name,
190 const int op_version, const void *params,
191 const int params_size);
192
204void dt_preset_repository_set_module_version(const char *operation, const char *name,
205 const int op_version);
206
209void dt_preset_repository_set_blend_params(const char *operation, const char *name,
210 const int blendop_version, const void *blend_params,
211 const int blend_params_size);
212
223GList *dt_preset_repository_list_for_upgrade(const char *operation);
224
226void dt_preset_repository_rename_module_preset(const char *operation, const int op_version,
227 const char *old_name, const char *new_name,
228 const char *description, const void *params,
229 const int params_size);
230
232void dt_preset_repository_duplicate_module_preset(const char *operation, const int op_version,
233 const char *name, const char *new_name);
234
236void dt_preset_repository_delete_module_preset(const char *operation, const int op_version,
237 const char *name);
238
240void dt_preset_repository_delete_all_for_module(const char *operation);
241
243void dt_preset_repository_update_params_by_rowid(const int rowid, const int op_version,
244 const void *params, const int params_size);
245
247void dt_preset_repository_delete_by_rowid(const int rowid);
248
249/* ---------------------------------------------------------------------------------------
250 * Auto-apply conditions
251 *
252 * The preset edit dialog changes one condition at a time, so these are one statement per
253 * field rather than a whole-row write. Grouped into two families by shape: a numeric
254 * range, and a single integer. The enum picks the columns; nothing here builds SQL from a
255 * string, so every query in this file stays greppable.
256 * ------------------------------------------------------------------------------------- */
257
266
274
276void dt_preset_repository_update_range(const char *operation, const int op_version, const char *name,
277 const dt_preset_range_t range,
278 const double min, const double max);
279
281void dt_preset_repository_update_flag(const char *operation, const int op_version, const char *name,
282 const dt_preset_flag_t flag, const int value);
283
292void dt_preset_repository_update_camera(const char *operation, const int op_version, const char *name,
293 const char *maker, const char *model, const char *lens);
294
295/* ---------------------------------------------------------------------------------------
296 * IOP presets
297 *
298 * Same table again, seen by a pixel module's preset menu. Two things distinguish it from
299 * the lib half: the rows carry blend parameters, and the menu filters by whether a preset
300 * matches the image being edited -- so three queries share one predicate over the camera,
301 * the exposure triangle and the file format.
302 * ------------------------------------------------------------------------------------- */
303
311typedef struct dt_preset_match_t
312{
313 const char *exif_model;
314 const char *exif_maker;
315 const char *camera_alias;
316 const char *camera_maker;
317 const char *exif_lens;
318 double iso;
319 double exposure;
320 double aperture;
322 int format;
325
327void dt_preset_repository_add_iop_preset(const char *name, const char *operation, const int op_version,
328 const void *params, const int params_size,
329 const void *blend_params, const int blend_params_size,
330 const int blendop_version, const int enabled);
331
339GList *dt_preset_repository_list_for_iop(const char *operation, const int op_version);
340
348GList *dt_preset_repository_list_for_menu(const char *operation, const dt_preset_match_t *match,
349 const gboolean shipped_first);
350
352dt_module_preset_t *dt_preset_repository_get_iop_preset(const char *operation, const int op_version,
353 const char *name);
354
363GList *dt_preset_repository_find_autoapply(const char *operation, const int op_version,
364 const dt_preset_match_t *match, const char *always_name);
365
366/* ---------------------------------------------------------------------------------------
367 * The preset edit dialog
368 *
369 * It shows and writes the whole condition set at once, so these take it as one struct
370 * rather than sixteen parameters.
371 * ------------------------------------------------------------------------------------- */
372
376{
377 gchar *name;
379 gchar *model;
380 gchar *maker;
381 gchar *lens;
385 /* REAL columns, like the pairs above: read and bound as doubles so a fractional stored
386 * bound survives an open-and-save of the edit dialog. The dialog displays whole
387 * millimetres, but display rounding is the dialog's, not the store's. */
393
396
402gboolean dt_preset_repository_get_conditions(const char *operation, const int op_version,
403 const char *name, dt_preset_conditions_t *c, int *rowid);
404
407
410 const char *operation, const int op_version,
411 const void *params, const int params_size,
412 const int enabled,
413 const void *blend_params, const int blend_params_size,
414 const int blendop_version);
415
418gboolean dt_preset_repository_get_identity(const int rowid, gchar **operation, int *op_version);
419
421void dt_preset_repository_update_iop_params(const char *operation, const char *name,
422 const int op_version,
423 const void *params, const int params_size,
424 const int enabled,
425 const void *blend_params, const int blend_params_size,
426 const int blendop_version);
427
430
434
435/* ---------------------------------------------------------------------------------------
436 * Listing presets for the Preferences dialog
437 *
438 * The preferences tree shows every preset in the database, grouped by module, with the
439 * auto-apply conditions rendered as ranges. These two return whole rows rather than a
440 * cursor, because the caller builds GTK widgets from them and must not be stepping a
441 * statement while it does.
442 * ------------------------------------------------------------------------------------- */
443
460
462void dt_preset_row_free(gpointer data);
463
467
475
477void dt_preset_identity_free(gpointer data);
478
481
484
486
487#endif // DT_DATABASE_PRESET_REPOSITORY_H
488
489// clang-format off
490// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
491// vim: shiftwidth=2 expandtab tabstop=2 cindent
492// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
493// clang-format on
const char ** description(struct dt_iop_module_t *self)
Definition ashift.c:166
size_t params_size(dt_imageio_module_format_t *self)
Definition avif.c:571
static const float const float const float min
const float max
const char flag
Definition image.h:285
struct dt_iop_tonecurve_params_t preset
const char * maker
const char * model
const char * name
Definition pdf.h:90
gboolean dt_preset_repository_insert(const dt_preset_t *preset)
Insert preset, replacing any row that collides with it.
void dt_preset_repository_delete_module_preset(const char *operation, const int op_version, const char *name)
Delete (operation, op_version, name) unless it is write-protected.
void dt_preset_repository_add_iop_preset(const char *name, const char *operation, const int op_version, const void *params, const int params_size, const void *blend_params, const int blend_params_size, const int blendop_version, const int enabled)
Store an IOP preset, blend parameters included, replacing any of the same name.
void dt_module_preset_free(gpointer data)
Release one dt_module_preset_t. Suits g_list_free_full().
GList * dt_preset_repository_list_all(void)
Every preset, ordered by (operation, name) – the grouping the tree relies on to start a new module no...
GList * dt_preset_repository_list_all_versions(const char *operation)
Every preset of operation at ANY version, with rowid and op_version filled in, SHIPPED FIRST then by ...
void dt_preset_row_free(gpointer data)
Free one dt_preset_row_t. Suits g_list_free_full().
dt_preset_flag_t
@ DT_PRESET_FLAG_FORMAT
@ DT_PRESET_FLAG_FILTER
@ DT_PRESET_FLAG_LAST
@ DT_PRESET_FLAG_AUTOAPPLY
void dt_preset_repository_update_range(const char *operation, const int op_version, const char *name, const dt_preset_range_t range, const double min, const double max)
Set the <range>_min / <range>_max pair of (operation, op_version, name).
GList * dt_preset_repository_list_for_module(const char *operation, const int op_version, const gboolean with_description, const gboolean shipped_first)
Every preset of (operation, op_version).
void dt_preset_repository_delete_shipped(void)
Delete every write-protected preset – the auto-generated ones, dropped at startup so module code can ...
void dt_preset_repository_cleanup(void)
Finalise the cached statements. See dt_colorlabel_repository_cleanup().
void dt_preset_repository_update_iop_params(const char *operation, const char *name, const int op_version, const void *params, const int params_size, const int enabled, const void *blend_params, const int blend_params_size, const int blendop_version)
Replace the module payload of (operation, name), at any version.
dt_module_preset_t * dt_preset_repository_get_iop_preset(const char *operation, const int op_version, const char *name)
One IOP preset by name, blend parameters included, or NULL.
dt_preset_t * dt_preset_repository_get_by_rowid(const int rowid)
The preset at rowid, or NULL when there is none. Free with dt_preset_free().
dt_module_preset_t * dt_preset_repository_get_module_preset(const char *operation, const int op_version, const char *name)
One preset by name, or NULL. Free with dt_module_preset_free().
void dt_preset_repository_update_conditions(const int rowid, const dt_preset_conditions_t *c)
Overwrite the conditions of the row at rowid.
GList * dt_preset_repository_list_for_menu(const char *operation, const dt_preset_match_t *match, const gboolean shipped_first)
Presets of operation to offer in a menu, in display order.
GList * dt_preset_repository_list_editable(void)
Every preset the user may edit (writeprotect = 0), in row order.
void dt_preset_repository_update_params_by_rowid(const int rowid, const int op_version, const void *params, const int params_size)
Replace the parameters of one row, by rowid.
GList * dt_preset_repository_list_for_upgrade(const char *operation)
Every preset of operation at any version, with both parameter blobs.
int dt_preset_repository_find_rowid(const char *operation, const int op_version, const char *name)
rowid of (operation, op_version, name), or -1.
void dt_preset_repository_update_camera(const char *operation, const int op_version, const char *name, const char *maker, const char *model, const char *lens)
Set the camera match of (operation, op_version, name).
void dt_preset_repository_update_module_params(const char *operation, const char *name, const int op_version, const void *params, const int params_size)
Replace the parameters (and version) of (operation, name).
void dt_preset_identity_free(gpointer data)
Free one dt_preset_identity_t. Suits g_list_free_full().
void dt_preset_repository_add_module_preset(const char *name, const char *operation, const int op_version, const void *params, const int params_size)
Create an empty user preset holding params, as the "new preset" menu item does.
GList * dt_preset_repository_list_for_version(const char *operation, const int op_version)
As above, restricted to one op_version. Same columns, same order.
void dt_preset_repository_delete_by_rowid(const int rowid)
Delete one row by rowid.
gboolean dt_preset_repository_get_conditions(const char *operation, const int op_version, const char *name, dt_preset_conditions_t *c, int *rowid)
Read the conditions of (operation, op_version, name).
void dt_preset_repository_delete_all_for_module(const char *operation)
Delete every preset of operation, whatever its version or protection.
void dt_preset_free(dt_preset_t *preset)
Release a dt_preset_t and everything it owns. NULL-safe.
gboolean dt_preset_repository_module_preset_exists(const char *operation, const int op_version, const char *name)
TRUE when (operation, op_version, name) exists.
GList * dt_preset_repository_list_for_iop(const char *operation, const int op_version)
Every preset of (operation, op_version), with blend parameters.
void dt_preset_repository_rename_module_preset(const char *operation, const int op_version, const char *old_name, const char *new_name, const char *description, const void *params, const int params_size)
Replace name, description and parameters of (operation, op_version, old_name).
void dt_preset_repository_set_module_version(const char *operation, const char *name, const int op_version)
Set ONLY the version of (operation, name), leaving the parameters alone.
void dt_preset_repository_set_blend_params(const char *operation, const char *name, const int blendop_version, const void *blend_params, const int blend_params_size)
Replace the blend parameters (and blend version) of (operation, name), at any version....
void dt_preset_repository_delete_by_rowid_unprotected(const int rowid)
Delete the row at rowid unless it is write-protected.
void dt_preset_conditions_free(dt_preset_conditions_t *c)
Release the strings owned by c (not c itself).
gboolean dt_preset_repository_get_identity(const int rowid, gchar **operation, int *op_version)
The (operation, op_version) a rowid belongs to. Returns FALSE if there is none; *operation is newly a...
void dt_preset_repository_add_shipped_preset(const char *name, const char *operation, const int op_version, const void *params, const int params_size, const int writeprotect)
Create a preset from code rather than from the menu – the built-in presets a module registers at star...
void dt_preset_repository_update_flag(const char *operation, const int op_version, const char *name, const dt_preset_flag_t flag, const int value)
Set one integer condition of (operation, op_version, name).
void dt_preset_repository_insert_with_conditions(const dt_preset_conditions_t *c, const char *operation, const int op_version, const void *params, const int params_size, const int enabled, const void *blend_params, const int blend_params_size, const int blendop_version)
Create a preset from a full condition set plus its module payload.
void dt_preset_repository_duplicate_module_preset(const char *operation, const int op_version, const char *name, const char *new_name)
Copy (operation, op_version, name) to new_name, unprotected.
GList * dt_preset_repository_find_autoapply(const char *operation, const int op_version, const dt_preset_match_t *match, const char *always_name)
Names of the presets that should be applied to this image automatically.
dt_preset_range_t
@ DT_PRESET_RANGE_FOCAL_LENGTH
@ DT_PRESET_RANGE_ISO
@ DT_PRESET_RANGE_APERTURE
@ DT_PRESET_RANGE_LAST
@ DT_PRESET_RANGE_EXPOSURE
static const dt_aligned_pixel_simd_t value
Definition simd.h:144
Identity of one preset, for callers listing rather than loading.
The facts about one image that decide whether a preset matches it.
const char * camera_maker
const char * camera_alias
One row of the Preferences preset tree, with its auto-apply conditions.
One row of data.presets, owned by the caller.