Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
history_merge.h
Go to the documentation of this file.
1/*
2 This file is part of Ansel,
3 Copyright (C) 2026 Aurélien PIERRE.
4
5 Ansel 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 Ansel 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 Ansel. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef DT_DEVELOP_HISTORY_MERGE_H
20#define DT_DEVELOP_HISTORY_MERGE_H
21
22#include <glib.h>
23#include <inttypes.h>
24
25#ifdef __cplusplus
26extern "C"
27{
28#endif
29
30 struct dt_develop_t;
31 struct dt_iop_module_t;
32
34 {
35 DT_HISTORY_MERGE_PREPEND = 0, // source applied early in destination history (destination wins conflicts)
36 DT_HISTORY_MERGE_APPEND = 1, // source applied after destination (source wins conflicts)
37 DT_HISTORY_MERGE_REPLACE = 2 // entirely replace history and modules order
39
41 {
42 DT_HM_BATCH_UNDECIDED = 0, // show the report dialog for each image
43 DT_HM_BATCH_ACCEPT, // silently keep the merge result
44 DT_HM_BATCH_REVERT, // silently revert the merge
46
47 typedef struct dt_hm_batch_state_t
48 {
50 // Resolved destination module order (list of owned "op|multi_name" strings) captured from the first
51 // accepted image of a batch. When non-NULL, later images replay this order instead of re-solving it,
52 // so a single high-level decision (and any manual reorder done in the report) applies to the whole batch.
53 GList *order_ids;
55
60
79 int dt_history_merge(struct dt_develop_t *dev_dest, struct dt_develop_t *dev_src, const int32_t dest_imgid,
80 const GList *mod_list, const gboolean merge_iop_order,
81 const dt_history_merge_strategy_t strategy, const gboolean force_new_modules,
82 const char *source_label, dt_hm_batch_state_t *batch);
83
84#ifdef __cplusplus
85}
86#endif
87
88
89/* Node identity helpers, defined in history_merge.c. They were declared in
90 * gui/develop/history_merge_gui.h, which had the backend including a GUI header to see
91 * its own functions; the GUI half needs them too, and gets them from here. */
92char *_hm_make_node_id(const char *op, const char *multi_name);
93void _hm_id_to_op_name(const char *id, char *op, char *name);
94int _hm_build_last_history_by_id(const struct dt_develop_t *dev, GHashTable **out_map);
95
96
98{
99 // Keep the destination adjacency constraints when breaking incompatible 2-cycles.
101 // Keep the source/pasted adjacency constraints when breaking incompatible 2-cycles.
104
105/* The four moments a merge needs a user for.
106 *
107 * Merging runs deep in the backend but hits situations only a person can settle. Those
108 * dialogs used to be called from here directly, which is why a layer-1 file included a gui/
109 * header. They are handlers now, registered by gui/develop/history_merge_gui.c, and each has
110 * a defined answer for when nobody registered one -- a headless merge must still finish, or
111 * refuse, on its own.
112 */
113
117typedef dt_hm_constraint_choice_t (*dt_hm_constraints_choice_handler_t)(GHashTable *id_ht, const char *faulty_id,
118 const char *src_prev, const char *src_next,
119 const char *dst_prev, const char *dst_next);
120
124typedef gboolean (*dt_hm_missing_raster_handler_t)(const GList *mod_list);
125
127typedef void (*dt_hm_toposort_cycle_handler_t)(GList *cycle_nodes, GHashTable *id_ht);
128
131typedef gboolean (*dt_hm_merge_report_handler_t)(struct dt_develop_t *dev_dest, struct dt_develop_t *dev_src,
132 const gboolean merge_iop_order, const gboolean used_source_order,
133 const dt_history_merge_strategy_t strategy,
134 GHashTable *src_last_by_id, GHashTable *dst_last_before_by_id,
135 const GHashTable *orig_ids, const GHashTable *mod_list_ids,
136 const char *source_label, dt_hm_batch_state_t *batch);
137
142
143#endif // DT_DEVELOP_HISTORY_MERGE_H
144
145// clang-format off
146// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
147// vim: shiftwidth=2 expandtab tabstop=2 cindent
148// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
149// clang-format on
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
void dt_hm_set_merge_report_handler(dt_hm_merge_report_handler_t handler)
dt_hm_constraint_choice_t(* dt_hm_constraints_choice_handler_t)(GHashTable *id_ht, const char *faulty_id, const char *src_prev, const char *src_next, const char *dst_prev, const char *dst_next)
void dt_hm_set_constraints_choice_handler(dt_hm_constraints_choice_handler_t handler)
void _hm_id_to_op_name(const char *id, char *op, char *name)
char * _hm_make_node_id(const char *op, const char *multi_name)
void(* dt_hm_toposort_cycle_handler_t)(GList *cycle_nodes, GHashTable *id_ht)
int dt_history_merge(struct dt_develop_t *dev_dest, struct dt_develop_t *dev_src, const int32_t dest_imgid, const GList *mod_list, const gboolean merge_iop_order, const dt_history_merge_strategy_t strategy, const gboolean force_new_modules, const char *source_label, dt_hm_batch_state_t *batch)
Merge a list of modules into a destination image, solving pipeline topologies for proper insertion of...
dt_hm_constraint_choice_t
@ DT_HM_CONSTRAINTS_PREFER_DEST
@ DT_HM_CONSTRAINTS_PREFER_SRC
dt_hm_batch_decision_t
@ DT_HM_BATCH_UNDECIDED
@ DT_HM_BATCH_ACCEPT
@ DT_HM_BATCH_REVERT
int _hm_build_last_history_by_id(const struct dt_develop_t *dev, GHashTable **out_map)
gboolean(* dt_hm_merge_report_handler_t)(struct dt_develop_t *dev_dest, struct dt_develop_t *dev_src, const gboolean merge_iop_order, const gboolean used_source_order, const dt_history_merge_strategy_t strategy, GHashTable *src_last_by_id, GHashTable *dst_last_before_by_id, const GHashTable *orig_ids, const GHashTable *mod_list_ids, const char *source_label, dt_hm_batch_state_t *batch)
void dt_hm_batch_state_cleanup(dt_hm_batch_state_t *batch)
Release resources held by a batch state (the cached order). Safe to call on a zeroed state.
void dt_hm_set_missing_raster_handler(dt_hm_missing_raster_handler_t handler)
void dt_hm_set_toposort_cycle_handler(dt_hm_toposort_cycle_handler_t handler)
dt_history_merge_strategy_t
@ DT_HISTORY_MERGE_REPLACE
@ DT_HISTORY_MERGE_PREPEND
@ DT_HISTORY_MERGE_APPEND
gboolean(* dt_hm_missing_raster_handler_t)(const GList *mod_list)
const char * name
Definition pdf.h:90
dt_hm_batch_decision_t decision