diff --git a/GlyphConstruction.roboFontExt/info.plist b/GlyphConstruction.roboFontExt/info.plist index 237eba8..c90c80e 100644 --- a/GlyphConstruction.roboFontExt/info.plist +++ b/GlyphConstruction.roboFontExt/info.plist @@ -30,7 +30,7 @@ requiresVersionMinor 5 timeStamp - 1679000061.4736819 + 1680895559.418968 version 0.13 diff --git a/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py b/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py index b6294f6..b0b1dad 100644 --- a/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py +++ b/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py @@ -383,7 +383,6 @@ def __init__(self, constructions, font, parentWindow, shouldOverWrite=None, shou self.constructions = constructions self.w = Sheet((300, 170), parentWindow=parentWindow) - getExtensionDefault, setExtensionDefault, getExtensionDefaultColor, setExtensionDefaultColor y = 15 if shouldOverWrite is None: shouldOverWrite = getExtensionDefault(self.overWriteKey, True) @@ -494,11 +493,15 @@ class GlyphBuilderController(BaseWindowController): fileNameKey = "%s.lastSavedFileName" % defaultKey glyphLibConstructionKey = "%s.construction" % defaultKey + isLiveUpdatingKey = "%s.liveUpdating" % defaultKey + def __init__(self, font): self.font = None self._glyphs = [] self._filePath = None + self.isLiveUpdating = getExtensionDefault(self.isLiveUpdatingKey, True) + statusBarHeight = 20 self.w = GlyphConstructionWindow((900, 700), "Glyph Builder", minSize=(400, 400)) @@ -586,18 +589,20 @@ def __init__(self, font): # self.w.split.showPane("analyser", True) self.w.statusBar = StatusBar((0, -statusBarHeight, -0, statusBarHeight)) - self.w.statusBar.hiddenReload = Button((0, 0, -0, -0), "Reload", self.reload) + self.w.statusBar.hiddenReload = Button((0, 0, 1, 1), "Reload", self.reload) button = self.w.statusBar.hiddenReload.getNSButton() button.setBezelStyle_(AppKit.NSRoundRectBezelStyle) button.setAlphaValue_(0) self.w.statusBar.hiddenReload.bind("\r", ["command"]) - self.w.statusBar.hiddenSave = Button((0, 0, -0, -0), "Reload", self.saveFile) + self.w.statusBar.hiddenSave = Button((0, 0, 1, 1), "Reload", self.saveFile) button = self.w.statusBar.hiddenSave.getNSButton() button.setBezelStyle_(AppKit.NSRoundRectBezelStyle) button.setAlphaValue_(0) self.w.statusBar.hiddenSave.bind("s", ["command"]) + self.w.statusBar.liveUpdating = CheckBox((10, 0, 100, 18), "Live Updates", value=self.isLiveUpdating, sizeStyle="mini", callback=self.liveUpdatingCallback) + self.subscribeFont(font) self.setUpBaseWindowBehavior() @@ -620,6 +625,9 @@ def unsubscribeFont(self): self.font.removeObserver(self, notification="Font.Changed") self.font = None + def liveUpdatingCallback(self, sender): + self.isLiveUpdating = sender.get() + def constructionsCallback(self, sender, update=True): if self.font is None: return @@ -860,7 +868,8 @@ def analyse(self, sender=None): # notifications def fontChanged(self, notification): - self.reload() + if self.isLiveUpdating: + self.reload() def fontBecameCurrent(self, notification): font = notification["font"] @@ -869,10 +878,14 @@ def fontBecameCurrent(self, notification): def fontResignCurrent(self, notification): self.unsubscribeFont() + def windowSelectCallback(self, sender): + self.reload() + def windowCloseCallback(self, sender): self.unsubscribeFont() removeObserver(self, "fontBecameCurrent") removeObserver(self, "fontResignCurrent") + setExtensionDefault(self.isLiveUpdatingKey, self.w.statusBar.liveUpdating.get()) super(GlyphBuilderController, self).windowCloseCallback(sender) diff --git a/LibExtension/glyphConstructionController.py b/LibExtension/glyphConstructionController.py index b6294f6..9bea3e7 100644 --- a/LibExtension/glyphConstructionController.py +++ b/LibExtension/glyphConstructionController.py @@ -383,7 +383,6 @@ def __init__(self, constructions, font, parentWindow, shouldOverWrite=None, shou self.constructions = constructions self.w = Sheet((300, 170), parentWindow=parentWindow) - getExtensionDefault, setExtensionDefault, getExtensionDefaultColor, setExtensionDefaultColor y = 15 if shouldOverWrite is None: shouldOverWrite = getExtensionDefault(self.overWriteKey, True) @@ -494,11 +493,15 @@ class GlyphBuilderController(BaseWindowController): fileNameKey = "%s.lastSavedFileName" % defaultKey glyphLibConstructionKey = "%s.construction" % defaultKey + isLiveUpdatingKey = "%s.liveUpdating" % defaultKey + def __init__(self, font): self.font = None self._glyphs = [] self._filePath = None + self.isLiveUpdating = getExtensionDefault(self.isLiveUpdatingKey, True) + statusBarHeight = 20 self.w = GlyphConstructionWindow((900, 700), "Glyph Builder", minSize=(400, 400)) @@ -586,18 +589,20 @@ def __init__(self, font): # self.w.split.showPane("analyser", True) self.w.statusBar = StatusBar((0, -statusBarHeight, -0, statusBarHeight)) - self.w.statusBar.hiddenReload = Button((0, 0, -0, -0), "Reload", self.reload) + self.w.statusBar.hiddenReload = Button((0, 0, 1, 1), "Reload", self.reload) button = self.w.statusBar.hiddenReload.getNSButton() button.setBezelStyle_(AppKit.NSRoundRectBezelStyle) button.setAlphaValue_(0) self.w.statusBar.hiddenReload.bind("\r", ["command"]) - self.w.statusBar.hiddenSave = Button((0, 0, -0, -0), "Reload", self.saveFile) + self.w.statusBar.hiddenSave = Button((0, 0, 1, 1), "Reload", self.saveFile) button = self.w.statusBar.hiddenSave.getNSButton() button.setBezelStyle_(AppKit.NSRoundRectBezelStyle) button.setAlphaValue_(0) self.w.statusBar.hiddenSave.bind("s", ["command"]) + self.w.statusBar.liveUpdating = CheckBox((10, 0, 100, 18), "Live Updates", value=self.isLiveUpdating, sizeStyle="mini", callback=self.liveUpdatingCallback) + self.subscribeFont(font) self.setUpBaseWindowBehavior() @@ -620,6 +625,9 @@ def unsubscribeFont(self): self.font.removeObserver(self, notification="Font.Changed") self.font = None + def liveUpdatingCallback(self, sender): + self.isLiveUpdating = sender.get() + def constructionsCallback(self, sender, update=True): if self.font is None: return @@ -860,7 +868,8 @@ def analyse(self, sender=None): # notifications def fontChanged(self, notification): - self.reload() + if self.isLiveUpdating: + self.reload() def fontBecameCurrent(self, notification): font = notification["font"] @@ -869,10 +878,15 @@ def fontBecameCurrent(self, notification): def fontResignCurrent(self, notification): self.unsubscribeFont() + def windowSelectCallback(self, sender): + if not self.isLiveUpdating: + self.reload() + def windowCloseCallback(self, sender): self.unsubscribeFont() removeObserver(self, "fontBecameCurrent") removeObserver(self, "fontResignCurrent") + setExtensionDefault(self.isLiveUpdatingKey, self.w.statusBar.liveUpdating.get()) super(GlyphBuilderController, self).windowCloseCallback(sender)