|
from mojo.subscriber import * |
|
from vanilla import * |
|
from mojo.UI import CurrentGlyphWindow, SetCurrentGlyphByName |
|
|
|
class crumbponents(Subscriber): |
|
|
|
def started(self): |
|
self._path = [] # keep the path as a list and join on set |
|
self.glyph = None # Current Glyph to keep track of |
|
self.editor = CurrentGlyphWindow() |
|
|
|
def _getPath(self): |
|
return "/".join(self._path) |
|
|
|
def _setPath(self,value): |
|
self._path = value |
|
|
|
path = property(_getPath, _setPath) |
|
|
|
def _getCrumb(self): |
|
if hasattr(self, "sb"): |
|
return self.sb.crumbs.get() |
|
|
|
def _setCrumb(self,value): |
|
if hasattr(self, "sb"): |
|
self.sb.crumbs.set(value) |
|
|
|
crumb = property(_getCrumb, _setCrumb) |
|
|
|
def glyphEditorWillOpen(self, info): |
|
if CurrentGlyph() is not None: |
|
self.editor = info["glyphEditor"] |
|
self.path = [CurrentGlyph().name] |
|
self.sb = self.editor.getGlyphStatusBar() |
|
if hasattr(self.sb, 'crumbs'): |
|
del self.sb.crumbs |
|
|
|
self.sb.crumbs = PathControl( |
|
(90, -0, -0, -0), |
|
url = self.path, |
|
callback = self.crumbleback, |
|
sizeStyle = 'small' |
|
) |
|
|
|
def roboFontDidSwitchCurrentGlyph(self, info): |
|
tempGlyph = info["glyph"] |
|
if tempGlyph is not None: |
|
if tempGlyph.name not in self._path: |
|
if self.glyph is not None: |
|
if tempGlyph.name in [c.baseGlyph for c in self.glyph.components]: |
|
## print("appending") |
|
self._path.append(tempGlyph.name) |
|
else: |
|
## print(self.glyph.name) |
|
## print("temp not in self.glyph replacing") |
|
self.path = [tempGlyph.name] |
|
else: |
|
## print("no self.glyph replacing") |
|
self.path = [tempGlyph.name] |
|
#self.path = ["fivesixths",CurrentGlyph().name] |
|
self.crumb = self.path |
|
self.glyph = tempGlyph |
|
|
|
def crumbleback(self, sender): |
|
selected = sender.getSelected().split("/")[-1] |
|
self.editor.setGlyphByName(selected) |
|
self.glyph = self.editor.getGlyph().font[selected] |
|
|
|
|
|
registerRoboFontSubscriber(crumbponents) |