Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wx Undo system #628

Open
wants to merge 151 commits into
base: wx
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
151 commits
Select commit Hold shift click to select a range
8854305
test first commit on fork
JeremieHornus Oct 3, 2018
cd69240
* in
YvesDup Oct 3, 2018
b7556cf
no
JeremieHornus Oct 3, 2018
07e637a
requirements.txt
YvesDup Oct 5, 2018
97c0676
calling right methods for changing segment type through interface
JeremieHornus Oct 8, 2018
022af1b
Initial files about logging messages
YvesDup Oct 15, 2018
f5a0923
initial files about undoredo
YvesDup Oct 15, 2018
5be06c1
Initial files
YvesDup Oct 15, 2018
63b7118
Revert "Initial files"
YvesDup Oct 15, 2018
0749363
Revert "Revert "Initial files""
YvesDup Oct 15, 2018
ae3a4ba
connected logging on menu application
YvesDup Oct 15, 2018
72d56b3
Update src/trufont/windows/loggingWindows.py
YvesDup Oct 16, 2018
708cab3
Auto create log folder
YvesDup Oct 16, 2018
b1a7468
minor updates
YvesDup Oct 16, 2018
6ec2c3f
minor updates
YvesDup Oct 16, 2018
2eacb7e
update with sys.argv
YvesDup Oct 16, 2018
ed3760c
minor updates
YvesDup Oct 16, 2018
047a539
Integration of undoredomgr
YvesDup Oct 16, 2018
7fa6dc6
logs folder to exclude
YvesDup Oct 16, 2018
53141ee
Correction at logger creation
YvesDup Oct 17, 2018
f7b8089
Add a new class derivated from Glyph
YvesDup Oct 23, 2018
ed3671d
Implementation of first undo/redo
YvesDup Oct 23, 2018
6284724
minor updates
YvesDup Oct 23, 2018
0ff90ed
New files
YvesDup Oct 23, 2018
8fead86
minor updates
YvesDup Oct 23, 2018
1c6bad1
add @deco4class.decorator_classfunc
YvesDup Oct 23, 2018
5f2827f
New files
YvesDup Oct 23, 2018
43bae72
integration of Action class
YvesDup Oct 24, 2018
29bee0a
Update test_file for wxWidget Files
YvesDup Oct 25, 2018
8466295
moving selection with arrow-keys is undo-redo-able
horasio Oct 28, 2018
f88383e
Change ctx construction
YvesDup Oct 29, 2018
7060f5c
Undo/Redo running for all functions of properties
YvesDup Oct 29, 2018
404f6ad
New file fro undo/redo
YvesDup Oct 29, 2018
6d340ee
Revert "New file fro undo/redo"
YvesDup Oct 29, 2018
2e286ac
Revert "Revert "New file fro undo/redo""
YvesDup Oct 29, 2018
76febb6
Shape figures are including in undo/redo process
YvesDup Oct 29, 2018
5c947a5
minor updates
YvesDup Nov 2, 2018
ebcb1ed
update canvasMove code to use begin/endUndoGroup from tfont
horasio Nov 2, 2018
fe19564
more undoable actions in baseTool
horasio Nov 4, 2018
41124d3
modify decorator functions
YvesDup Nov 6, 2018
63bc25c
add decorator to deleteUILayerSelection
YvesDup Nov 6, 2018
b7b2815
Add a decorator to function
YvesDup Nov 6, 2018
0125d80
Update src/trufont/objects/undoredomgr.py
YvesDup Nov 6, 2018
fdda130
code reviews
YvesDup Nov 6, 2018
fb2aeb8
Add undoredo decorator
YvesDup Nov 6, 2018
9a43b0f
code review
YvesDup Nov 6, 2018
7e5540c
Just add class decorator to explore class
YvesDup Nov 6, 2018
b1bc8f3
JUst add class decorator to explore
YvesDup Nov 6, 2018
85dc219
code review
YvesDup Nov 6, 2018
f824ef9
add decorator on deleteUILayer
YvesDup Nov 6, 2018
4789109
add traces
YvesDup Nov 7, 2018
63a2742
Update src/trufont/util/canvasMove.py
YvesDup Nov 7, 2018
d9c14bb
update too with updates from Samuel
YvesDup Nov 7, 2018
68dc05b
Integration of beginUndoGroup
YvesDup Nov 7, 2018
bd3c95a
minor updates
YvesDup Nov 8, 2018
812fe85
add layer_decorate_undoredo
YvesDup Nov 8, 2018
a927dc0
Updates layer_decorate_func
YvesDup Nov 8, 2018
390cd80
Update layer_decorate_undoredo
YvesDup Nov 8, 2018
7887b9c
Precisions on signature of decorated function
YvesDup Nov 8, 2018
8ead68a
change undo/redo decorator
YvesDup Nov 8, 2018
fae8b9a
minor updates
YvesDup Nov 8, 2018
67c28cc
Change UndoRedo decorator
YvesDup Nov 8, 2018
c3e6829
no undo/redo on mouse motion...
horasio Nov 11, 2018
6799bf3
Review and minor updates
YvesDup Nov 12, 2018
3f1ea1a
Add cut and paste operation to undoredomanager
YvesDup Nov 12, 2018
e1fad73
Review and add a getsize function
YvesDup Nov 12, 2018
22393ec
Add an origin param to deleteUILayerSelection
YvesDup Nov 12, 2018
1432ab7
Clean up ;-)
YvesDup Nov 13, 2018
615158e
add __slots__
YvesDup Nov 13, 2018
55d647a
Update src/trufont/tests/undoable_functions-tests.ods
YvesDup Nov 13, 2018
c657d26
Code rerview
YvesDup Nov 15, 2018
ad2b9c2
Word in prepareUndo
YvesDup Nov 15, 2018
cd11124
Code review
YvesDup Nov 15, 2018
515ba62
Precisions on operation
YvesDup Nov 15, 2018
d3dd8fa
Minor corrections
YvesDup Nov 15, 2018
5b038c7
Missing variable from selectionTools
YvesDup Nov 15, 2018
7ca7e52
add *args in Action __init__
YvesDup Nov 15, 2018
22eede0
Uncomment prepareUndo and performUndo
YvesDup Nov 15, 2018
376c732
modifiy finally clause
YvesDup Nov 15, 2018
7e124c8
minor corrections
YvesDup Nov 16, 2018
53d7dd6
Save datas from undoredomanager for each TruGlyph
YvesDup Nov 16, 2018
4148399
Minor updates
YvesDup Nov 16, 2018
3453fb2
Add directory and extension to ignore
YvesDup Nov 16, 2018
4d55c04
maj
YvesDup Nov 16, 2018
6af900a
fixed bug in layer_decorate_undoredo
horasio Nov 18, 2018
0528b85
Add fontname to a TruGlyph
YvesDup Nov 19, 2018
da4bbf1
Separate move selection from mouse and keyboard
YvesDup Nov 20, 2018
e9d2dec
Fanalize prepare and perform decorator
YvesDup Nov 20, 2018
ec062bc
add a _debug variable
YvesDup Nov 20, 2018
e1d4fca
add a self._path variable
YvesDup Nov 20, 2018
ade535b
Add undo/redo on pen draw point
YvesDup Nov 20, 2018
b71dfb5
add a OnMouseUpLeftUp
YvesDup Nov 20, 2018
64a22c3
Review on save of UndoRedoMgr
YvesDup Nov 22, 2018
fc1cbc7
Correction
YvesDup Nov 22, 2018
c098d78
Merge branch 'wx-bf' of https://github.com/BlackFoundry/trufont into …
YvesDup Nov 22, 2018
cff1d24
Maj
YvesDup Nov 22, 2018
f4a0009
end of undo/redo Integration
YvesDup Nov 22, 2018
79cedda
Add a test on Action
YvesDup Nov 22, 2018
3f3cd96
Minor corrections
YvesDup Nov 22, 2018
704f635
Validation of sav and load
YvesDup Nov 22, 2018
6d442f3
Minor updates
YvesDup Nov 22, 2018
bdae117
Init adds
YvesDup Nov 22, 2018
90bb07e
erase decorator to these 2 functions
YvesDup Nov 26, 2018
d874fe5
Create a method to add Points to Layer Selection
YvesDup Nov 26, 2018
ff67806
Refactoring undoredomgr
YvesDup Nov 27, 2018
db4b4e0
Ue of tryglyph_decorate_undo ...
YvesDup Nov 27, 2018
b5a9146
Refactoring with modifications from undoredomgr and truglyph changes
YvesDup Nov 27, 2018
cc117bc
Refactoring
YvesDup Nov 27, 2018
fd27460
Refactoring
YvesDup Nov 27, 2018
9858fc6
Include library click for command line argument
YvesDup Nov 28, 2018
01ff5b3
Install an disable/enable on undo/redo
YvesDup Nov 28, 2018
6659782
add library click
YvesDup Nov 28, 2018
18c82aa
Erase line 23
YvesDup Nov 28, 2018
d68530b
Missing default logger
YvesDup Nov 28, 2018
8bfb109
update tests on can_undo/can_redo
YvesDup Dec 2, 2018
a8a4fe7
add CM on undo and redo as undo_ctx, redo_ctx
YvesDup Dec 2, 2018
2765187
dd CM on undo and redo as undo_ctx, redo_ctx
YvesDup Dec 2, 2018
cb5bb85
installation disable_undoredo
YvesDup Dec 3, 2018
3418e10
Updates for test on decorator fcts
YvesDup Dec 3, 2018
546990c
Update tests
YvesDup Dec 3, 2018
585997b
Create tests for exception in decorators
YvesDup Dec 3, 2018
7ea6b43
fix the list of args to FontWindow
YvesDup Dec 3, 2018
15c88b6
Updates tests
YvesDup Dec 4, 2018
78d86fd
Fix on truglyph_decorator
YvesDup Dec 4, 2018
e0b6a2d
Set wx.GraphicsContext.Create(
YvesDup Dec 4, 2018
8898d6c
Fix error (Bad copy from clipboard)
YvesDup Dec 4, 2018
367a9c1
Cancel changing about GraphicsContext
YvesDup Dec 4, 2018
19158b4
Add logs and add a GraphicsContext in OnPaint
YvesDup Dec 4, 2018
0999ded
Add Logs
YvesDup Dec 4, 2018
1644300
Set OnSelectAll to UndoRedoMgr
YvesDup Dec 6, 2018
686ba33
Logs to trace bug on ColorButtonPaint
YvesDup Dec 10, 2018
0524ec5
Change classname of truGlyph to UndoRedoGlyph
YvesDup Dec 11, 2018
8b323ab
Erase selection after drawing
YvesDup Dec 14, 2018
c1c181b
Shrink size and move position to 1/3 right width
YvesDup Dec 14, 2018
c4320e0
Add logging msg
YvesDup Dec 14, 2018
b2d0cfd
change button color
YvesDup Dec 17, 2018
7a62b1d
Add logs
YvesDup Dec 17, 2018
4ddc626
Update colorButton.py
YvesDup Dec 17, 2018
7521fbe
create a default logger
YvesDup Dec 18, 2018
ce160aa
use of context managers (in URM) with undo and redo
YvesDup Dec 18, 2018
415b7aa
Add callback funciton on undo/redo errors
YvesDup Dec 18, 2018
33de9a1
Updates tests about URM
YvesDup Dec 18, 2018
3144953
Changes of name class
YvesDup Dec 20, 2018
2addaf6
Change filename of test files
YvesDup Dec 20, 2018
c78b067
Minor updates
YvesDup Dec 20, 2018
4aa78bb
Update penTool.py
YvesDup Dec 20, 2018
86f1a1e
comments and undoredo helper functions
horasio Jan 14, 2019
99e73ef
merged master into sam
horasio Jan 14, 2019
5e73f21
Merge remote-tracking branch 'origin/wx-bf' into yves-PaintDC
JeremieHornus Jan 23, 2019
d9347ae
open tfont files command
JeremieHornus Jan 23, 2019
2cdd57a
Fixed 2 bugs and added comments in selectiontool
horasio Mar 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changes of name class
UndoRedoMgr -> UndoManager
UndoRedoGlyph -> UndoableGlyph

So filenames are changed too
undoredomgr.py -> undoManager.py
undoredoglyph.py -> undoableGlyph.py
  • Loading branch information
YvesDup committed Dec 20, 2018
commit 31449536bd317676c635d75c342d58e4a0ff5fb8
60 changes: 30 additions & 30 deletions src/trufont/controls/propertiesView.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 14,10 @@
from wx import GetTranslation as tr

import logging
from trufont.objects.undoredoglyph import UndoRedoGlyph
from trufont.objects.undoableGlyph import UndoableGlyph
from typing import Any, Collection, Tuple, List, Dict, Callable

import trufont.objects.undoredomgr as undoredomgr
import trufont.objects.undoManager as undomanager
import trufont.util.func_copy as func_copy

from tfont.converters.tfontConverter import TFontConverter
Expand Down Expand Up @@ -49,13 49,13 @@
#-------------------------
# Used by undoredo decorator
#-------------------------
def align_expand_params(layer: Layer, glyph: UndoRedoGlyph, operation: str):
def align_expand_params(layer: Layer, glyph: UndoableGlyph, operation: str):
"""Used with align functions - Nothing to """
return layer

@undoredomgr.layer_decorate_undoredo(align_expand_params, operation="Align Horiz Left",
paths=True, guidelines=False, components=False, anchors=False)
def _alignHLeft(layer: Layer, tglyph: UndoRedoGlyph, operation: str):
@undomanager.layer_decorate_undo(align_expand_params, operation="Align Horiz Left",
paths=True, guidelines=False, components=False, anchors=False)
def _alignHLeft(layer: Layer, tglyph: UndoableGlyph, operation: str):
selectedPaths = []
xMin_all = None
for path in layer._paths:
Expand All @@ -74,9 74,9 @@ def _alignHLeft(layer: Layer, tglyph: UndoRedoGlyph, operation: str):
delta = xMin_all - xMin
path.transform(Transformation(xOffset=delta))

@undoredomgr.layer_decorate_undoredo(align_expand_params, operation="Align Horiz Center",
paths=True, guidelines=False, components=False, anchors=False)
def _alignHCenter(layer: Layer, tglyph: UndoRedoGlyph, operation: str):
@undomanager.layer_decorate_undo(align_expand_params, operation="Align Horiz Center",
paths=True, guidelines=False, components=False, anchors=False)
def _alignHCenter(layer: Layer, tglyph: UndoableGlyph, operation: str):
selectedPaths = []
xMin_all, xMax_all = None, None
for path in layer._paths:
Expand All @@ -100,9 100,9 @@ def _alignHCenter(layer: Layer, tglyph: UndoRedoGlyph, operation: str):
path.transform(Transformation(xOffset=delta))


@undoredomgr.layer_decorate_undoredo(align_expand_params, operation="Align Horiz Right",
paths=True, guidelines=False, components=False, anchors=False)
def _alignHRight(layer: Layer, tglyph: UndoRedoGlyph, operation: str):
@undomanager.layer_decorate_undo(align_expand_params, operation="Align Horiz Right",
paths=True, guidelines=False, components=False, anchors=False)
def _alignHRight(layer: Layer, tglyph: UndoableGlyph, operation: str):
selectedPaths = []
xMax_all = None
for path in layer._paths:
Expand All @@ -122,9 122,9 @@ def _alignHRight(layer: Layer, tglyph: UndoRedoGlyph, operation: str):
path.transform(Transformation(xOffset=delta))


@undoredomgr.layer_decorate_undoredo(align_expand_params, operation="Align Vert Top",
paths=True, guidelines=False, components=False, anchors=False)
def _alignVTop(layer: Layer, tglyph: UndoRedoGlyph, operation: str):
@undomanager.layer_decorate_undo(align_expand_params, operation="Align Vert Top",
paths=True, guidelines=False, components=False, anchors=False)
def _alignVTop(layer: Layer, tglyph: UndoableGlyph, operation: str):
selectedPaths = []
yMax_all = None
for path in layer._paths:
Expand All @@ -143,9 143,9 @@ def _alignVTop(layer: Layer, tglyph: UndoRedoGlyph, operation: str):
delta = yMax_all - yMax
path.transform(Transformation(yOffset=delta))

@undoredomgr.layer_decorate_undoredo(align_expand_params, operation="Align Vert Center",
paths=True, guidelines=False, components=False, anchors=False)
def _alignVCenter(layer: Layer, tglyph: UndoRedoGlyph, operation: str):
@undomanager.layer_decorate_undo(align_expand_params, operation="Align Vert Center",
paths=True, guidelines=False, components=False, anchors=False)
def _alignVCenter(layer: Layer, tglyph: UndoableGlyph, operation: str):
selectedPaths = []
yMin_all, yMax_all = None, None
for path in layer._paths:
Expand All @@ -169,9 169,9 @@ def _alignVCenter(layer: Layer, tglyph: UndoRedoGlyph, operation: str):
path.transform(Transformation(yOffset=delta))


@undoredomgr.layer_decorate_undoredo(align_expand_params, operation="Align Vert Bottom",
paths=True, guidelines=False, components=False, anchors=False)
def _alignVBottom(layer: Layer, tglyph: UndoRedoGlyph, operation: str):
@undomanager.layer_decorate_undo(align_expand_params, operation="Align Vert Bottom",
paths=True, guidelines=False, components=False, anchors=False)
def _alignVBottom(layer: Layer, tglyph: UndoableGlyph, operation: str):
selectedPaths = []
yMin_all = None
for path in layer._paths:
Expand Down Expand Up @@ -553,7 553,7 @@ def _DrawText_Spacing(ctx, text, x, y, sp=1.2):
#-------------------------
def header_expand_params(obj, *args, **kwargs):
""" use by decorator to get three params as
layer, undoredomgr and operation """
layer, undomanager and operation """
return obj.layer, obj._tooltips[obj._underMouseBtn]
#-------------------------

Expand Down Expand Up @@ -604,8 604,8 @@ def __init__(self, parent, font):
def layer(self):
return wx.GetTopLevelParent(self).activeLayer

@undoredomgr.layer_decorate_undoredo(header_expand_params,
paths=True, guidelines=False, components=False, anchors=False)
@undomanager.layer_decorate_undo(header_expand_params,
paths=True, guidelines=False, components=False, anchors=False)
def binaryPathOp(self, func):
layer = self.layer
paths = layer._paths
Expand All @@ -630,8 630,8 @@ def binaryPathOp(self, func):
paths.extend(open_)
trufont.TruFont.updateUI()

@undoredomgr.layer_decorate_undoredo(header_expand_params,
paths=True, guidelines=False, components=False, anchors=False)
@undomanager.layer_decorate_undo(header_expand_params,
paths=True, guidelines=False, components=False, anchors=False)
def removeOverlap(self):
layer = self.layer
paths = layer._paths
Expand All @@ -650,8 650,8 @@ def removeOverlap(self):
paths.extend(others)
trufont.TruFont.updateUI()

@undoredomgr.layer_decorate_undoredo(header_expand_params,
paths=True, guidelines=False, components=False, anchors=False)
@undomanager.layer_decorate_undo(header_expand_params,
paths=True, guidelines=False, components=False, anchors=False)
def transform(self, **kwargs):
layer = self.layer
transformation = Transformation(**kwargs)
Expand Down Expand Up @@ -1240,7 1240,7 @@ def OnPaint(self, event):
#-------------------------
def glyph_expand_params(obj, *args, **kwargs):
""" use by decorator to get three params as
layer, undoredomgr and operation """
layer, undomanager and operation """
return obj._layersView._activeLayer._parent

#-------------------------
Expand Down Expand Up @@ -1268,7 1268,7 @@ def OnActiveLayerChanged(self, event):
# wx methods
# ----------

@undoredomgr.glyph_decorate_undoredo(glyph_expand_params, operation="Add layer", layer=True)
@undomanager.undoableglyph_decorate_undo(glyph_expand_params, operation="Add layer", layer=True)
def DoCreateLayer(self):
# this logic should probably be in the model
view = self._layersView
Expand Down
7 changes: 4 additions & 3 deletions src/trufont/drawingTools/baseTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 3,7 @@
from trufont.util.drawing import CreatePath
from trufont.util.canvasDelete import deleteUILayerSelection
from trufont.util.canvasMove import moveFromKeysUILayerSelection
from trufont.objects.undoredomgr import Action
from trufont.objects.undoManager import Action
from tfont.objects import Point
import wx
from wx import GetTranslation as tr
Expand Down Expand Up @@ -110,12 110,13 @@ def prepareUndo(self, group_name: str="unknown"):
Also layer.endUndoGroup() will be called once, and only if prepareUndo()
was called."""
if not self.preparedUndo and self.layer:
self.layer.beginUndoGroup(group_name)
self.layer.beginUndo(group_name)
self.preparedUndo = True

def performUndo(self, operation:str, group_name: str="unknown"):
if self.preparedUndo and self.layer:
self.layer._parent.get_undoredo().append_action(Action(operation, *self.layer.endUndoGroup(group_name)))
action = Action(operation, *self.layer.endUndo(group_name))
self.layer._parent.get_undomanager().append_action(action)
self.preparedUndo = False

# we oughta eat the modifiers down/up events in baseTool to stop the
Expand Down
8 changes: 4 additions & 4 deletions src/trufont/drawingTools/knifeTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,7 @@
import wx
from wx import GetTranslation as tr

import trufont.objects.undoredomgr as undoredomgr
import trufont.objects.undoManager as undomanager

_path = CreatePath()
_path.MoveToPoint(1.0, 0.975)
Expand Down Expand Up @@ -77,9 77,9 @@ def OnMotion(self, event):
else:
super().OnMotion(event)

@undoredomgr.layer_decorate_undoredo((lambda *args, **kwargs: args[0].layer),
operation="Knife cut selection",
paths=True, guidelines=False, components=False, anchors=False)
@undomanager.layer_decorate_undo((lambda *args, **kwargs: args[0].layer),
operation="Knife cut selection",
paths=True, guidelines=False, components=False, anchors=False)
def OnMouseUpLeftUp(self, event):
""" make thios method to be sure that the super().OnMouseUp() call do not
bloc process of wx msgs """
Expand Down
Loading