finish undo/redo rework
* "Undo(Redo) last brushstroke" -> "Undo(Redo)". * Sync `_updateActionSensitivity` menu method with the new undo/redo behavior. * Smooth button action is no longer destructive. * Clean undone smooth transformations when doing a new smooth transformation.
This commit is contained in:
parent
236e4db236
commit
28def0059d
|
|
@ -413,6 +413,9 @@ const _DrawingElement = new Lang.Class({
|
|||
this.transformations.push({ type: Transformations.SMOOTH, undoable: true,
|
||||
undo: () => this.points = oldPoints,
|
||||
redo: () => this.points = newPoints });
|
||||
|
||||
if (this._undoneTransformations)
|
||||
this._undoneTransformations = this._undoneTransformations.filter(transformation => transformation.type != Transformations.SMOOTH);
|
||||
},
|
||||
|
||||
addPoint: function() {
|
||||
|
|
@ -636,6 +639,10 @@ const _DrawingElement = new Lang.Class({
|
|||
delete this._undoneTransformations;
|
||||
},
|
||||
|
||||
get canUndo() {
|
||||
return this._undoneTransformations && this._undoneTransformations.length ? true : false;
|
||||
},
|
||||
|
||||
// The figure rotation center before transformations (original).
|
||||
// this.textWidth is computed during Cairo building.
|
||||
_getOriginalCenter: function() {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: Draw On Your Screen\n"
|
||||
"Report-Msgid-Bugs-To: https://framagit.org/abakkk/DrawOnYourScreen/issues\n"
|
||||
"POT-Creation-Date: 2020-09-19 15:32+0200\n"
|
||||
"POT-Creation-Date: 2020-10-04 22:45+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -265,12 +265,6 @@ msgctxt "drawing-tool"
|
|||
msgid "Mirror"
|
||||
msgstr ""
|
||||
|
||||
msgid "Undo"
|
||||
msgstr ""
|
||||
|
||||
msgid "Redo"
|
||||
msgstr ""
|
||||
|
||||
msgid "Erase"
|
||||
msgstr ""
|
||||
|
||||
|
|
@ -586,7 +580,7 @@ msgstr ""
|
|||
msgid "Add images from the clipboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Redo last brushstroke"
|
||||
msgid "Redo"
|
||||
msgstr ""
|
||||
|
||||
msgid "Save drawing"
|
||||
|
|
@ -710,5 +704,5 @@ msgstr ""
|
|||
msgid "Square drawing area"
|
||||
msgstr ""
|
||||
|
||||
msgid "Undo last brushstroke"
|
||||
msgid "Undo"
|
||||
msgstr ""
|
||||
|
|
|
|||
7
menu.js
7
menu.js
|
|
@ -230,12 +230,11 @@ var DrawingMenu = new Lang.Class({
|
|||
this.menu.removeAll();
|
||||
|
||||
let groupItem = new PopupMenu.PopupBaseMenuItem({ reactive: false, can_focus: false, style_class: 'draw-on-your-screen-menu-group-item' });
|
||||
this.undoButton = new ActionButton(_("Undo"), 'edit-undo-symbolic', this.area.undo.bind(this.area), this._updateActionSensitivity.bind(this));
|
||||
this.redoButton = new ActionButton(_("Redo"), 'edit-redo-symbolic', this.area.redo.bind(this.area), this._updateActionSensitivity.bind(this));
|
||||
this.undoButton = new ActionButton(getSummary('undo'), 'edit-undo-symbolic', this.area.undo.bind(this.area), this._updateActionSensitivity.bind(this));
|
||||
this.redoButton = new ActionButton(getSummary('redo'), 'edit-redo-symbolic', this.area.redo.bind(this.area), this._updateActionSensitivity.bind(this));
|
||||
this.eraseButton = new ActionButton(_("Erase"), 'edit-clear-all-symbolic', this.area.deleteLastElement.bind(this.area), this._updateActionSensitivity.bind(this));
|
||||
this.smoothButton = new ActionButton(_("Smooth"), Files.Icons.SMOOTH, this.area.smoothLastElement.bind(this.area), this._updateActionSensitivity.bind(this));
|
||||
this.eraseButton.child.add_style_class_name('draw-on-your-screen-menu-destructive-button');
|
||||
this.smoothButton.child.add_style_class_name('draw-on-your-screen-menu-destructive-button');
|
||||
getActor(groupItem).add_child(this.undoButton);
|
||||
getActor(groupItem).add_child(this.redoButton);
|
||||
getActor(groupItem).add_child(this.eraseButton);
|
||||
|
|
@ -309,7 +308,7 @@ var DrawingMenu = new Lang.Class({
|
|||
|
||||
_updateActionSensitivity: function() {
|
||||
this.undoButton.child.reactive = this.area.elements.length > 0;
|
||||
this.redoButton.child.reactive = this.area.undoneElements.length > 0;
|
||||
this.redoButton.child.reactive = this.area.undoneElements.length > 0 || (this.area.elements.length && this.area.elements[this.area.elements.length - 1].canUndo);
|
||||
this.eraseButton.child.reactive = this.area.elements.length > 0;
|
||||
this.smoothButton.child.reactive = this.area.elements.length > 0 && this.area.elements[this.area.elements.length - 1].shape == this.drawingTools.NONE;
|
||||
this.saveButton.child.reactive = this.area.elements.length > 0;
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@
|
|||
</key>
|
||||
<key type="as" name="redo">
|
||||
<default>["<Primary><Shift>z"]</default>
|
||||
<summary>Redo last brushstroke</summary>
|
||||
<summary>Redo</summary>
|
||||
</key>
|
||||
<key type="as" name="save-as-json">
|
||||
<default>["<Primary>s"]</default>
|
||||
|
|
@ -340,7 +340,7 @@
|
|||
</key>
|
||||
<key type="as" name="undo">
|
||||
<default>["<Primary>z"]</default>
|
||||
<summary>Undo last brushstroke</summary>
|
||||
<summary>Undo</summary>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
||||
|
|
|
|||
Loading…
Reference in New Issue