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