|
gpforge
An advanced bitmap font editor
|
The undo journal. More...
#include "font.h"Go to the source code of this file.
Enumerations | |
| enum | gpf_undo_what { GPF_UNDO_NONE , GPF_UNDO_GLYPH , GPF_UNDO_FAMILY } |
| Undo type. More... | |
Functions | |
| struct gpf_undo * | gpf_undo_new (void) |
| Creates a new undo. | |
| void | gpf_undo_free (struct gpf_undo *self) |
| Frees undo. | |
| void | gpf_undo_group_begin (struct gpf_undo *self) |
| Starts an undo group. | |
| void | gpf_undo_group_end (struct gpf_undo *self) |
| Ends an undo group. | |
| int | gpf_undo_begin (struct gpf_undo *self, struct gpf_font *font, enum gpf_variant_id id, uint32_t code) |
| Snapshots a glyph before it is changed. | |
| int | gpf_undo_retarget (struct gpf_undo *self, struct gpf_font *font, enum gpf_variant_id id, uint32_t code) |
| Finishes a snapshot and starts a snapshot for a different glyph. | |
| void | gpf_undo_commit (struct gpf_undo *self, struct gpf_font *font) |
| Finishes an undo on a glyph started by gpf_undo_begin(). | |
| int | gpf_undo_family (struct gpf_undo *self, struct gpf_font *font, const struct gpf_family_meta *meta, const struct gpf_author *authors) |
| Sets the font metadata and authors and saves the old ones into the undo journal. | |
| enum gpf_undo_what | gpf_undo (struct gpf_undo *self, struct gpf_font *font, enum gpf_variant_id *id, uint32_t *code) |
| Undoes the last entry, or group of entries. | |
| enum gpf_undo_what | gpf_redo (struct gpf_undo *self, struct gpf_font *font, enum gpf_variant_id *id, uint32_t *code) |
| Redoes the next entry, or group of entries. | |
| void | gpf_undo_saved (struct gpf_undo *self) |
| Marks the current state as the one written to the file. | |
| int | gpf_undo_is_saved (struct gpf_undo *self) |
| Returns if the font is in the state written to the file. | |
| int | gpf_undo_can_undo (struct gpf_undo *self) |
| Returns if undo is possible. | |
| int | gpf_undo_can_redo (struct gpf_undo *self) |
| Returns if redo is possible. | |
The undo journal.
One journal for the whole family, one entry per stroke, per command, per metric change, per overlay created or reverted. An entry is a before and an after snapshot of a single glyph entry in a single variant, either of which may be "the entry did not exist" — which is what creating an overlay and reverting one are.
The other kind of entry is a change to the family metadata, a before and an after snapshot of struct gpf_family_meta and of the font authors.
Definition in file undo.h.
| enum gpf_undo_what |
| enum gpf_undo_what gpf_redo | ( | struct gpf_undo * | self, |
| struct gpf_font * | font, | ||
| enum gpf_variant_id * | id, | ||
| uint32_t * | code ) |
Redoes the next entry, or group of entries.
| self | An undo journal. |
| font | A font to apply the redo on. |
| id | When glyph was redone this carries the glyph variant e.g. GPF_BOLD. |
| code | When glyph was redone this carries the glyph unicode codepoint. |
Definition at line 448 of file undo.c.
References GPF_UNDO_NONE.
| enum gpf_undo_what gpf_undo | ( | struct gpf_undo * | self, |
| struct gpf_font * | font, | ||
| enum gpf_variant_id * | id, | ||
| uint32_t * | code ) |
Undoes the last entry, or group of entries.
| self | An undo journal. |
| font | A font to apply the undo on. |
| id | When glyph was undone this carries the glyph variant e.g. GPF_BOLD. |
| code | When glyph was undone this carries the glyph unicode codepoint. |
Definition at line 421 of file undo.c.
References GPF_UNDO_NONE.
| int gpf_undo_begin | ( | struct gpf_undo * | self, |
| struct gpf_font * | font, | ||
| enum gpf_variant_id | id, | ||
| uint32_t | code ) |
Snapshots a glyph before it is changed.
Called before every glyph edit. A second call without a commit in between replaces the snapshot, so a stroke that starts over is not half recorded.
| self | An undo journal. |
| font | A font to snapshot the glyph from. |
| id | A glyph variant e.g. GPF_BOLD. |
| code | A unicode codepoint of the glyph to snapshot. |
Definition at line 154 of file undo.c.
References gpf_glyph::bits, and gpf_glyph::code.
| int gpf_undo_can_redo | ( | struct gpf_undo * | self | ) |
| int gpf_undo_can_undo | ( | struct gpf_undo * | self | ) |
| void gpf_undo_commit | ( | struct gpf_undo * | self, |
| struct gpf_font * | font ) |
Finishes an undo on a glyph started by gpf_undo_begin().
Records what the glyph became. An edit that changed nothing is dropped.
| self | An undo journal. |
| font | A font. |
Definition at line 220 of file undo.c.
References gpf_glyph::modified.
| int gpf_undo_family | ( | struct gpf_undo * | self, |
| struct gpf_font * | font, | ||
| const struct gpf_family_meta * | meta, | ||
| const struct gpf_author * | authors ) |
Sets the font metadata and authors and saves the old ones into the undo journal.
Sets the family metadata and the authors, as one journal entry.
The call is a no-op if both are the same as the font's.
| self | An undo journal. |
| font | A font family. |
| meta | New font family metadata. |
| authors | New gp_vec of authors, copied, may be NULL for none. |
Definition at line 282 of file undo.c.
References gpf_font::authors, and gpf_font::meta.
| void gpf_undo_free | ( | struct gpf_undo * | self | ) |
Frees undo.
| self | An undo journal to be freed. |
Definition at line 85 of file undo.c.
References gpf_glyph::bits.
| void gpf_undo_group_begin | ( | struct gpf_undo * | self | ) |
| void gpf_undo_group_end | ( | struct gpf_undo * | self | ) |
| int gpf_undo_is_saved | ( | struct gpf_undo * | self | ) |
Returns if the font is in the state written to the file.
That is the state at the last gpf_undo_saved(), or the one the journal was created with.
| self | An undo journal. |
| struct gpf_undo * gpf_undo_new | ( | void | ) |
| int gpf_undo_retarget | ( | struct gpf_undo * | self, |
| struct gpf_font * | font, | ||
| enum gpf_variant_id | id, | ||
| uint32_t | code ) |
Finishes a snapshot and starts a snapshot for a different glyph.
If the pending snapshot is already for this glyph and variant it's a no-op. Otherwise commits whatever was pending first with gpf_undo_commit(), then starts a new glyph snapshot with gpf_undo_begin().
| self | An undo journal. |
| font | A font to snapshot the glyph from. |
| id | A glyph variant e.g. GPF_BOLD. |
| code | A unicode codepoint of the glyph to snapshot. |
Definition at line 173 of file undo.c.
References gpf_glyph::code.