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#pragma once
32
33#include "common/dtpthread.h" // for dt_pthread_mutex_t
34#include <glib.h> // for gpointer, GList, gboolean
35#include <stdint.h> // for uint32_t
36
37// types that are known by the undo module
60
66
67typedef void *dt_undo_data_t;
68
69typedef struct dt_undo_t
70{
74 dt_pthread_mutex_t mutex;
75 gboolean locked;
76 gboolean disable_next;
78
80void dt_undo_cleanup(dt_undo_t *self);
81
82// create a group of item to be handled together, a group
85
86// record a change that will be insered into the undo list
87void dt_undo_record(dt_undo_t *self, gpointer user_data, dt_undo_type_t type, dt_undo_data_t data,
88 void (*undo)(gpointer user_data, dt_undo_type_t type, dt_undo_data_t item, dt_undo_action_t action, GList **imgs),
89 void (*free_data)(gpointer data));
90
91// undo an element which correspond to filter. filter here is expected to be
92// a set of dt_undo_type_t.
93void dt_undo_do_undo(dt_undo_t *self, uint32_t filter);
94
95// redo a previously undone action, does nothing if the redo list is empty
96void dt_undo_do_redo(dt_undo_t *self, uint32_t filter);
97
98// removes all items which correspond to filter in the undo/redo lists
99void dt_undo_clear(dt_undo_t *self, uint32_t filter);
100
101void dt_undo_iterate_internal(dt_undo_t *self, uint32_t filter, gpointer user_data,
102 void (*apply)(gpointer user_data, dt_undo_type_t type, dt_undo_data_t item));
103
104void dt_undo_iterate(dt_undo_t *self, uint32_t filter, gpointer user_data,
105 void (*apply)(gpointer user_data, dt_undo_type_t type, dt_undo_data_t item));
106
107// disable the next record, this is to avoid recording when reverting a value (in undo callbacks)
109
110// Check if the undo/redo stack has at least one available element for the corresponding filter.
111// Mostly meant to disable GUI undo/redo controls if they wouldn't have any effect.
112gboolean dt_is_undo_list_populated(dt_undo_t *self, uint32_t filter);
113gboolean dt_is_redo_list_populated(dt_undo_t *self, uint32_t filter);
114
115// clang-format off
116// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
117// vim: shiftwidth=2 expandtab tabstop=2 cindent
118// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
119// clang-format on
int type
Definition common/metadata.c:62
Definition undo.h:70
dt_pthread_mutex_t mutex
Definition undo.h:74
gboolean disable_next
Definition undo.h:76
gboolean locked
Definition undo.h:75
int group_indent
Definition undo.h:73
GList * undo_list
Definition undo.h:71
GList * redo_list
Definition undo.h:71
dt_undo_type_t group
Definition undo.h:72
void dt_undo_disable_next(dt_undo_t *self)
Definition undo.c:70
dt_undo_type_t
Definition undo.h:39
@ DT_UNDO_NONE
Definition undo.h:40
@ DT_UNDO_GEOTAG
Definition undo.h:41
@ DT_UNDO_METADATA
Definition undo.h:47
@ DT_UNDO_COLORLABELS
Definition undo.h:45
@ DT_UNDO_RATINGS
Definition undo.h:44
@ DT_UNDO_DATETIME
Definition undo.h:50
@ DT_UNDO_HISTORY
Definition undo.h:42
@ DT_UNDO_TAGS
Definition undo.h:46
@ DT_UNDO_LIGHTTABLE
Definition undo.h:54
@ DT_UNDO_ALL
Definition undo.h:58
@ DT_UNDO_LT_HISTORY
Definition undo.h:48
@ DT_UNDO_FLAGS
Definition undo.h:49
@ DT_UNDO_MAP
Definition undo.h:57
@ DT_UNDO_DEVELOP
Definition undo.h:52
@ DT_UNDO_MASK
Definition undo.h:43
@ DT_UNDO_DUPLICATE
Definition undo.h:51
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:311
void dt_undo_end_group(dt_undo_t *self)
Definition undo.c:149
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:337
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:364
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:374
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:67
gboolean dt_is_undo_list_populated(dt_undo_t *self, uint32_t filter)
Definition undo.c:306
dt_undo_action_t
Definition undo.h:62
@ DT_ACTION_REDO
Definition undo.h:64
@ DT_ACTION_UNDO
Definition undo.h:63