56 lines
2.4 KiB
C
56 lines
2.4 KiB
C
/* Historial unificado (deshacer/rehacer) de un documento.
|
|
* - Edición de píxeles, fotogramas, capas y propiedades usan el mismo historial.
|
|
* - Operaciones agrupadas: begin_group ... end_group = UNA entrada.
|
|
* - Límites adaptativos: memoria, nº de operaciones y almacenamiento temporal.
|
|
* Al superarlos, las operaciones más antiguas de píxeles se pasan a disco
|
|
* (si hay carpeta temporal y espacio) o, si no, se descartan (la más
|
|
* antigua primero). Nunca se descarta lo ya aplicado al documento. */
|
|
#ifndef TAHGIBU_HISTORY_H
|
|
#define TAHGIBU_HISTORY_H
|
|
|
|
#include "tahgibu/document.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
tgb_status tgb_history_undo(tgb_document *doc); /* TGB_ERR_NOTHING si no hay nada */
|
|
tgb_status tgb_history_redo(tgb_document *doc);
|
|
bool tgb_history_can_undo(const tgb_document *doc);
|
|
bool tgb_history_can_redo(const tgb_document *doc);
|
|
const char *tgb_history_undo_label(const tgb_document *doc); /* NULL si no hay */
|
|
const char *tgb_history_redo_label(const tgb_document *doc);
|
|
|
|
/* Grupos anidables (hasta 8 niveles). Mientras hay un grupo abierto no se
|
|
* puede deshacer/rehacer. abort_group deshace lo hecho dentro del grupo y
|
|
* lo descarta (lo usan las extensiones al fallar). */
|
|
tgb_status tgb_history_begin_group(tgb_document *doc, const char *label);
|
|
tgb_status tgb_history_end_group(tgb_document *doc);
|
|
tgb_status tgb_history_abort_group(tgb_document *doc);
|
|
|
|
typedef struct tgb_history_limits {
|
|
size_t max_memory_bytes; /* memoria para datos del historial */
|
|
uint32_t max_operations; /* nº máximo de operaciones deshacibles */
|
|
size_t max_temp_bytes; /* disco temporal permitido (0 = no usar disco) */
|
|
char temp_dir[512]; /* carpeta temporal ("" = no usar disco) */
|
|
} tgb_history_limits;
|
|
|
|
tgb_status tgb_history_set_limits(tgb_document *doc, const tgb_history_limits *limits);
|
|
void tgb_history_get_limits(const tgb_document *doc, tgb_history_limits *out);
|
|
/* Recalcula los límites según la RAM libre, el tamaño del documento y el
|
|
* espacio en disco. Llámalo de vez en cuando (p. ej. cada minuto). */
|
|
tgb_status tgb_history_adapt(tgb_document *doc);
|
|
|
|
typedef struct tgb_history_stats {
|
|
size_t undo_count, redo_count;
|
|
size_t memory_bytes, temp_bytes;
|
|
uint64_t dropped_ops, spilled_ops;
|
|
} tgb_history_stats;
|
|
void tgb_history_get_stats(const tgb_document *doc, tgb_history_stats *out);
|
|
void tgb_history_clear(tgb_document *doc);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|