| Age | Commit message (Collapse) | Author |
|
Via the debugger set up in ae1960f53dd02798bd00bed7fffe58a0db6bb52d and
some digging around I discovered the source of the problem that
prevented undo functionality from working in the `equalSideBearings_`
method.
This error came up:
AttributeError: "'list' object has no attribute 'resetSelectionPath'"
one line above the last line of `equalSideBearings_`, where a call is
made to `self._glyph.selection.resetSelectionPath()`. This exception
prevents further execution, notably short-circuiting before the glyph's
`performUndo()` method can be called in order for undo functionality to
work.
As the error indicates, `self._glyph.selection` (which is a property)
returns `[]` when what is expected is likely some kind of object.
That object, it turns out, is a `doodleSelection.Selection` object. The
reason why we don't have one is because `info['glyph']` is a
`RobofabWrapperGlyph` instead of a `DoodleGlyph`. And a
`RobofabWrapperGlyph` either doesn't have a `selection` or more likely
has a different sort of `selection` property.
In order to get a `DoodleGlyph`, we can call `naked()` on the
`RobofabWrapperGlyph`. By passing this object to
`CustomSpaceCenterMenuForGlyph` (and thereby `SpaceCenterMenuForGlyph`),
we can give the `equalSideBearings_` method something it actually
expects, and allow it to respond appropriately.
Now RoboFont's existing `equalSideBearings_` method is able to do the
right thing, namely equalise a glyph's sidebearings and allow that
action to be undone (and redone).
|
|
Temporarily add remote debugging facilities via Remote-PDB
(https://pypi.python.org/pypi/remote-pdb). This allows us to actually
debug our script to see what on earth is going on.
Injected Remote-PDB via another script that may become another RoboFont
extension at some point.
Once the package was injected, all I had to do was import `RemotePdb`
and set an address and port, and I could telnet into the pdb session to
try and figure out what's going on to make it so that undo functionality
doesn't work.
|
|
Comment out the copied RoboFont implementation and call the existing
implementation instead.
We do this by subclassing `SpaceCenterMenuForGlyph` and overriding the
`__init__` method. This allows us to bypass `SpaceCenterMenuForGlyph`'s
`__init__` method (notice that we call its super `__init__` but not its
`__init__`), allowing us to create an instance without needing to
specify the required `event`, `view`, and `callback` parameters that the
original class requires.
This also allows us to not include proprietary code in the project.
Undo functionality _still_ doesn't work. Can't figure out what the
problem is.
This change is really from shortly after the last commit, but I didn't
bother committing because I wanted to resolve the undo problems first.
Since it's been a while, deciding now to commit what's here and continue
working.
|
|
Copy `equalize_sidebearings` method and `getDefault` function from
RoboFont after uncompiling the `lib/UI/spaceCenter/*.pyc`,
`lib/doodleMenus.pyc`, and `lib/tools/defaults.pyc` files.
This gives us the exact same functionality that happens when choosing
"Equalize sidebearings" from the contextual menu in the Space Center.
Including the code directly instead of referencing it because the
`SpaceCenterMenuForGlyph` class opens a contextual menu on init, which
we really don't want, and the `equalizeSideBearings_` method that it
defined is an instance method, so I would need an instance of the class
but don't want to trigger the contextual menu. So I figured I'd just
copy the code directly to speed things up.
Unfortunately undo functionality doesn't work with the method I copied,
and I can't seem to figure out how to get it sorted out.
|
|
Allow centering to be undone.
|
|
From the inspection code that I removed in
76e0ea2b4dab01bef29e9a18589a32897b49de45.
|
|
|
|
|