aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2015-12-25preferences.py: Remove commented importTeddy Wing
Not using `HotKeyItem` due to the length checking made in 1391f70d79144518dda9d0294a9e8a8fc79904ff.
2015-12-24Add LICENSE (MIT)Teddy Wing
2015-12-24preferences_window.py: Get rid of all the cruft from last commitTeddy Wing
Remove the commented `NSFormatter` subclasses, and debug statements from 1391f70d79144518dda9d0294a9e8a8fc79904ff, and also rename our single-letter variable.
2015-12-24preferences_window.py: Attempts to limit input character lengthTeddy Wing
Tried to create an `NSFormatter` subclass but kept getting this stupid error: TypeError: isPartialStringValid:newEditingString:errorDescription:: Need tuple of 3 arguments as result and: TypeError: isPartialStringValid:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:: Need tuple of 4 arguments as result which is freaking idiotic because if you look at the Cocoa documentation you can see that both those methods return fraking `BOOL`s. Also needed to keep renaming the subclass because every time I reinstalled the extension, PyObjC or RoboFont or whatever would yell: Traceback (most recent call last): File "preferences_window.py", line 10, in <module> error: Booya2HotKeyFormatter is overriding existing Objective-C class Anyway, ended up ditching the `NSFormatter` subclass because of that _stupid_ nonsensical error and am now just checking for string length in the input edit callback and forcing a max length there by resetting the value to ensure it doesn't go over 1 character.
2015-12-24Preferences: Always use NSUserDefaults to get & set keyTeddy Wing
This fixes the bug mentioned in 8778928a0989ea938fb06f0dd4c6639a6f9148ca, allowing us to change the preferred activation key and have it work immediately without first having to relaunch RoboFont.
2015-12-24Make hotkey preference workTeddy Wing
Separate preference handling into a new class and have the previous preferences class handle only the preferences window. We rename the old file to `preferences_window.py` and adjust the `info.plist` key for the menu item accordingly. Our new `Preference` class can now be imported from both `equalize_sidebearings.py` and `preferences_window.py` without causing confusion. I extracted it because asking for the `DEFAULT_ACTIVATION_KEY` from `preferences_window.py` from `equalize_sidebearings.py` would open the preferences window (bad). We now save the preferred key using RoboFont's extension preferences API. When the text input in the preferences window is modified, the new key preference gets saved. BUG: There's an issue with this implementation where the preferred key doesn't become active until the next launch of RoboFont because `EqualizeSidebearings` has its own instance of `Preferences` which has a stale `activation_key`.
2015-12-24preferences.py: PEP8 whitespaceTeddy Wing
2015-12-24equalize_sidebearings.py: Set default hotkey to 'e'Teddy Wing
Use a class variable to store the default. This will change in the very near future when we make this user editable.
2015-12-24equalize_sidebearings.py: Remove unused importTeddy Wing
This import is obsolete since 2180b298ff7fbee1df2d69c4552266c13d40c57c.
2015-12-24Remove build.pyTeddy Wing
Now that we're building with a shell script, this Python builder is no longer necessary. All the more so because it doesn't work in its current state.
2015-12-24build.sh: Update `timeStamp` on buildTeddy Wing
When building a new bundle, update the `timeStamp` key in `info.plist` to correspond to the current time. Was hoping to retain the decimal value in the timestamp, but for some reason only the integer part stays after it gets set. Oh well, I don't care enough to fiddle with that.
2015-12-24Makefile: Add `all` targetTeddy Wing
Cleans, builds anew, and installs.
2015-12-24Add build script to make extension bundleTeddy Wing
* Add `info.plist` (apparently it needs to be lowercase, weird, who knew?) that contains the necessary keys for the extension (as per http://robodocs.readthedocs.org/roboFontDocumentation/content/extensions/specification.html#specificationextensions) * Create a build script that copies the necessary files into the extension's bundle folder * Create a Makefile with some build and clean rules
2015-12-24Add build.pyTeddy Wing
Create a build script modeled after hTools2's (https://github.com/gferreira/hTools2_extension/blob/master/build-RF-extension.py) as referenced by the RoboFont docs. Unfortunately I can't get this to run because it obviously can't import `mojo`. The `mojo` package doesn't seem to exist anywhere, or I can't find it easily. Instead I'm going to write a shell script to build the extension as it seems like that will be easier.
2015-12-24preferences.py: Style window and controlsTeddy Wing
* Make the window a bit smaller because there's only one control * Add a text label to the editable input * Set a size for the editable input and move it into position to the right of the text label
2015-12-24Add preferences.pyTeddy Wing
Create a file for the extension's preferences window. This will be a window that opens when a menu item under the extension's menu is selected. The window will display an editable control to allow users to set a custom key to trigger sidebar equalisation.
2015-12-23equalize_sidebearings.py: Rename `center` method to `equalize`Teddy Wing
Because the term is not exactly appropriate in this context. Equalising and centering are really 2 different things and this method does the former.
2015-12-23equalize_sidebearings.py: Remove old debugging codeTeddy Wing
This code opened a GUI object browser for better inspection (still wasn't perfect, but it was decent enought for a start. Remote-Pdb really saved the day.). We no longer need this block now that we've figured out how to get it to work.
2015-12-23equalize_sidebearings.py: Remove old side bearing equalisation codeTeddy Wing
Remove old commented code that's irrelevant now that we're using this better method of equalising side bearings.
2015-12-23equalize_sidebearings.py: Get rid of proprietary codeTeddy Wing
Remove RoboFont's proprietary `getDefault` and `equalSideBearings_` code since the extension now works without them and we shouldn't be using this code in an extension that we plan to open source. Sorry for even including this in the repo! It did end up being useful for testing, just to see that it was possible.
2015-12-23equalize_sidebearings.py: Remove debugging statementsTeddy Wing
Figured out 36e8ed7f276923b4b3e4115a209ea79d961496a1.
2015-12-23equalize_sidebearings.py: Pass "naked" glyph to Space Center MenuTeddy Wing
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).
2015-12-23equalize_sidebearings.py: Add remote debugging with Remote-PDBTeddy Wing
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.
2015-12-06equalize_sidebearings.py: Call RoboFont implementation instead of copyTeddy Wing
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.
2015-11-20equalize_sidebearings.py: Copy RoboFont implementationTeddy Wing
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.
2015-11-19equalize_sidebearings.py: Add undo capabilityTeddy Wing
Allow centering to be undone.
2015-11-19equalize_sidebearings.py: Remove unused importTeddy Wing
From the inspection code that I removed in 76e0ea2b4dab01bef29e9a18589a32897b49de45.
2015-11-19equalize_sidebearings.py: Remove commented inspection codeTeddy Wing
2015-11-19Rename observer_test.py to equalize_sidebearings.pyTeddy Wing
2015-11-19observer_test.py: Remove test print statementTeddy Wing
2015-11-19observer_test.py: Center on 'a' key pressTeddy Wing
A lot of testing code from when I was trying to get this to work. Actually just trying to inspect the objects/event. Unfortunately, `print`ing and `pdb` don't seem to work. Fortunately managed to get enough information from the `ObjectBrowser` once I figured out that I could use that for inspecting. The `print 'test'` at the end was just for me to confirm that the script was running when I couldn't see any outward evidence of that fact. Finally figured out what was going on and now the script will center when you press 'a' in the Space Center. Future enhancements include: * Add undo support * Make sure `center()` does what we're looking for and actually equalises sidebearings * Add a setting that allows users of the plugin to customise the hotkey through a custom interface (and ideally through a text configuration file as well).
2015-11-19observer_test.py: Convert to new Python classTeddy Wing
Inherit from `object` instead of not inheriting from anything to get a new Python class. Actually, now that I'm writing this message, I'm wondering if this may not be necessary since Python 3 defaults to new Python objects regardless of how you write it. But then again this is RoboFont and I'm not sure which Python version it's built against (was thinking of TruFont for a moment since I'm currently trying to build it).
2015-11-19Initial commit. Placeholder RoboFont observer code.Teddy Wing
Start with RoboFont's sample code for creating an observer. The goal is to observe key presses in Space Center and equalise sidebearings when a special key is pressed so that this functionality can be triggered from the keyboard instead of needing to open the control-click contextual menu and selecting it from the menu options.