Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
undo.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2010-2011 Henrik Andersson.
4 Copyright (C) 2010 johannes hanika.
5 Copyright (C) 2010 Pascal de Bruijn.
6 Copyright (C) 2012 Richard Wonka.
7 Copyright (C) 2013, 2016-2017, 2019-2021 Pascal Obry.
8 Copyright (C) 2014, 2016 Tobias Ellinghaus.
9 Copyright (C) 2016-2017 Roman Lebedev.
10 Copyright (C) 2019 Heiko Bauke.
11 Copyright (C) 2019-2021 Philippe Weyland.
12 Copyright (C) 2020 Aldric Renaudin.
13 Copyright (C) 2022 Martin Bařinka.
14 Copyright (C) 2023 Aurélien PIERRE.
15 Copyright (C) 2023 Luca Zulberti.
16
17 darktable is free software: you can redistribute it and/or modify
18 it under the terms of the GNU General Public License as published by
19 the Free Software Foundation, either version 3 of the License, or
20 (at your option) any later version.
21
22 darktable is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 GNU General Public License for more details.
26
27 You should have received a copy of the GNU General Public License
28 along with darktable. If not, see <http://www.gnu.org/licenses/>.
29*/
30
31#ifndef DT_COMMON_UNDO_H
32#define DT_COMMON_UNDO_H
33
34#include "system/dtpthread.h" // for dt_pthread_mutex_t
35#include <glib.h> // for gpointer, GList, gboolean
36#include <stdint.h> // for uint32_t
37
38// types that are known by the undo module
63
69
70typedef void *dt_undo_data_t;
71
72typedef struct dt_undo_t
73{
77 dt_pthread_mutex_t mutex;
78 gboolean locked;
79 gboolean disable_next;
81
83void dt_undo_cleanup(dt_undo_t *self);
84
85// Interim accessor (Strategy B, doc/globals-migration.md): implemented by the orchestrator; long-term the handle should be carried on the job/view context (Strategy C).
87
88// create a group of item to be handled together, a group
91
92// record a change that will be insered into the undo list
93void dt_undo_record(dt_undo_t *self, gpointer user_data, dt_undo_type_t type, dt_undo_data_t data,
94 void (*undo)(gpointer user_data, dt_undo_type_t type, dt_undo_data_t item, dt_undo_action_t action, GList **imgs),
95 void (*free_data)(gpointer data));
96
97// undo an element which correspond to filter. filter here is expected to be
98// a set of dt_undo_type_t.
99void dt_undo_do_undo(dt_undo_t *self, uint32_t filter);
100
101// redo a previously undone action, does nothing if the redo list is empty
102void dt_undo_do_redo(dt_undo_t *self, uint32_t filter);
103
104// removes all items which correspond to filter in the undo/redo lists
105void dt_undo_clear(dt_undo_t *self, uint32_t filter);
106
107void dt_undo_iterate_internal(dt_undo_t *self, uint32_t filter, gpointer user_data,
108 void (*apply)(gpointer user_data, dt_undo_type_t type, dt_undo_data_t item));
109
110void dt_undo_iterate(dt_undo_t *self, uint32_t filter, gpointer user_data,
111 void (*apply)(gpointer user_data, dt_undo_type_t type, dt_undo_data_t item));
112
113// disable the next record, this is to avoid recording when reverting a value (in undo callbacks)
115
116// Check if the undo/redo stack has at least one available element for the corresponding filter.
117// Mostly meant to disable GUI undo/redo controls if they wouldn't have any effect.
118gboolean dt_is_undo_list_populated(dt_undo_t *self, uint32_t filter);
119gboolean dt_is_redo_list_populated(dt_undo_t *self, uint32_t filter);
120
125int dt_undo_list_length(dt_undo_t *self, uint32_t filter);
126int dt_redo_list_length(dt_undo_t *self, uint32_t filter);
127
128#endif // DT_COMMON_UNDO_H
129
130// clang-format off
131// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
132// vim: shiftwidth=2 expandtab tabstop=2 cindent
133// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
134// clang-format on
_lib_location_type_t type
Definition location.c:1
dt_pthread_mutex_t mutex
Definition undo.h:77
gboolean disable_next
Definition undo.h:79
gboolean locked
Definition undo.h:78
int group_indent
Definition undo.h:76
GList * undo_list
Definition undo.h:74
GList * redo_list
Definition undo.h:74
dt_undo_type_t group
Definition undo.h:75
void dt_undo_disable_next(dt_undo_t *self)
Definition undo.c:70
dt_undo_type_t
Definition undo.h:40
@ DT_UNDO_REMOVE
Definition undo.h:53
@ DT_UNDO_NONE
Definition undo.h:41
@ DT_UNDO_GEOTAG
Definition undo.h:42
@ DT_UNDO_METADATA
Definition undo.h:48
@ DT_UNDO_COLORLABELS
Definition undo.h:46
@ DT_UNDO_RATINGS
Definition undo.h:45
@ DT_UNDO_DATETIME
Definition undo.h:51
@ DT_UNDO_HISTORY
Definition undo.h:43
@ DT_UNDO_TAGS
Definition undo.h:47
@ DT_UNDO_LIGHTTABLE
Definition undo.h:56
@ DT_UNDO_ALL
Definition undo.h:61
@ DT_UNDO_LT_HISTORY
Definition undo.h:49
@ DT_UNDO_FLAGS
Definition undo.h:50
@ DT_UNDO_MAP
Definition undo.h:60
@ DT_UNDO_DEVELOP
Definition undo.h:54
@ DT_UNDO_MASK
Definition undo.h:44
@ DT_UNDO_DUPLICATE
Definition undo.h:52
int dt_redo_list_length(dt_undo_t *self, uint32_t filter)
Definition undo.c:341
dt_undo_t * dt_undo_get_global(void)
Definition darktable.c:611
void dt_undo_do_redo(dt_undo_t *self, uint32_t filter)
Definition undo.c:272
gboolean dt_is_redo_list_populated(dt_undo_t *self, uint32_t filter)
Definition undo.c:331
void dt_undo_end_group(dt_undo_t *self)
Definition undo.c:149
int dt_undo_list_length(dt_undo_t *self, uint32_t filter)
How many records match filter, so a caller can tell a one-record undo from a batch of a thousand....
Definition undo.c:336
void dt_undo_cleanup(dt_undo_t *self)
Definition undo.c:76
void dt_undo_clear(dt_undo_t *self, uint32_t filter)
Definition undo.c:367
void dt_undo_iterate_internal(dt_undo_t *self, uint32_t filter, gpointer user_data, void(*apply)(gpointer user_data, dt_undo_type_t type, dt_undo_data_t item))
Definition undo.c:394
void dt_undo_iterate(dt_undo_t *self, uint32_t filter, gpointer user_data, void(*apply)(gpointer user_data, dt_undo_type_t type, dt_undo_data_t item))
Definition undo.c:404
void dt_undo_start_group(dt_undo_t *self, dt_undo_type_t type)
Definition undo.c:134
void dt_undo_do_undo(dt_undo_t *self, uint32_t filter)
Definition undo.c:277
dt_undo_t * dt_undo_init(void)
Definition undo.c:50
void dt_undo_record(dt_undo_t *self, gpointer user_data, dt_undo_type_t type, dt_undo_data_t data, void(*undo)(gpointer user_data, dt_undo_type_t type, dt_undo_data_t item, dt_undo_action_t action, GList **imgs), void(*free_data)(gpointer data))
Definition undo.c:163
void * dt_undo_data_t
Definition undo.h:70
gboolean dt_is_undo_list_populated(dt_undo_t *self, uint32_t filter)
Definition undo.c:326
dt_undo_action_t
Definition undo.h:65
@ DT_ACTION_REDO
Definition undo.h:67
@ DT_ACTION_UNDO
Definition undo.h:66