From fe79bf14991ae3490d50954f8eececc95f8bd7be Mon Sep 17 00:00:00 2001 From: CJ Dunn Date: Thu, 6 Apr 2023 13:23:31 -0400 Subject: [PATCH 1/8] add toggle to pause updates in the background --- .../lib/glyphConstructionController.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py b/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py index 901c83e..11964ff 100644 --- a/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py +++ b/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py @@ -592,6 +592,15 @@ def __init__(self, font): button.setAlphaValue_(0) self.w.statusBar.hiddenReload.bind("\r", ["command"]) + ## pause updates toggle + leftMargin = 5 + yPos = -20 + checkBoxSize = 18 + self.w.pauseOnOff = CheckBox((leftMargin, yPos, checkBoxSize, checkBoxSize), "", sizeStyle="small", callback=self.pause) + self.w.pauseLabel = TextBox((checkBoxSize+5, yPos+2, -leftMargin, checkBoxSize), "Pause Updates", sizeStyle="small") + + + self.w.statusBar.hiddenSave = Button((0, 0, -0, -0), "Reload", self.saveFile) button = self.w.statusBar.hiddenSave.getNSButton() button.setBezelStyle_(AppKit.NSRoundRectBezelStyle) @@ -620,6 +629,32 @@ def unsubscribeFont(self): self.font.removeObserver(self, notification="Font.Changed") self.font = None + + def pause(self, sender): + self.pauseState = self.w.pauseOnOff.get() + + if self.pauseState == True: + + ## first I tried self.unsubscribeFont(), but then self.font = None and had trouble setting self.font after this. + ## I tried ʻʻʻself.font = CurrentFont()ʻʻʻ but didnʻt work + self.font.removeObserver(self, notification="Font.Changed") + ## save the self.font until unpaused. + self.pausedFont = self.font + + #print("paused", self.pauseState) + + if self.pauseState == False: + try: + font = self.pausedFont + self.subscribeFont(font) + #print("unpaused", self.pauseState) + except: + #print("font = None") + pass + + + + def constructionsCallback(self, sender, update=True): if self.font is None: return From aced075ecaa77d5d571c4e47952d5b2119c1355b Mon Sep 17 00:00:00 2001 From: CJ Dunn Date: Thu, 6 Apr 2023 14:39:49 -0400 Subject: [PATCH 2/8] rename to "Pause Observer", so as not to confuse with updates to versions of this RF Extension --- .../lib/glyphConstructionController.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py b/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py index 11964ff..5216307 100644 --- a/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py +++ b/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py @@ -597,7 +597,7 @@ def __init__(self, font): yPos = -20 checkBoxSize = 18 self.w.pauseOnOff = CheckBox((leftMargin, yPos, checkBoxSize, checkBoxSize), "", sizeStyle="small", callback=self.pause) - self.w.pauseLabel = TextBox((checkBoxSize+5, yPos+2, -leftMargin, checkBoxSize), "Pause Updates", sizeStyle="small") + self.w.pauseLabel = TextBox((checkBoxSize+5, yPos+2, -leftMargin, checkBoxSize), "Pause Observer", sizeStyle="small") From ee8ef9a39e2f36a8290bae15d51d06ab5f869e46 Mon Sep 17 00:00:00 2001 From: CJ Dunn Date: Thu, 6 Apr 2023 14:43:07 -0400 Subject: [PATCH 3/8] =?UTF-8?q?fix=20unpaused=20behavior=20so=20window=20d?= =?UTF-8?q?oesn=CA=BBt=20scroll=20back=20up=20to=20top?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/glyphConstructionController.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py b/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py index 5216307..e48f5d5 100644 --- a/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py +++ b/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py @@ -646,7 +646,13 @@ def pause(self, sender): if self.pauseState == False: try: font = self.pausedFont - self.subscribeFont(font) + + if font is not None: + ## donʻt set font again, this scrolls up to top of window which is annoying + #self.preview.setFont(font) + self.font.naked().addObserver(self, "fontChanged", "Font.Changed") + + #self.subscribeFont(font) #print("unpaused", self.pauseState) except: #print("font = None") From 82f3014e5c58f88d4090b94445c2b1f0279a2901 Mon Sep 17 00:00:00 2001 From: Frederik Berlaen Date: Thu, 6 Apr 2023 21:55:46 +0200 Subject: [PATCH 4/8] some fixes - use the checkbox label itself - set a live updating flag and use it to reload on a font changes - save it in the defaults --- .../lib/glyphConstructionController.py | 61 +++++-------------- 1 file changed, 16 insertions(+), 45 deletions(-) diff --git a/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py b/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py index e48f5d5..b9da1e3 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) @@ -493,12 +492,17 @@ 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,26 +590,19 @@ 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"]) - - ## pause updates toggle - leftMargin = 5 - yPos = -20 - checkBoxSize = 18 - self.w.pauseOnOff = CheckBox((leftMargin, yPos, checkBoxSize, checkBoxSize), "", sizeStyle="small", callback=self.pause) - self.w.pauseLabel = TextBox((checkBoxSize+5, yPos+2, -leftMargin, checkBoxSize), "Pause Observer", sizeStyle="small") - - - - 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() @@ -630,36 +627,8 @@ def unsubscribeFont(self): self.font = None - def pause(self, sender): - self.pauseState = self.w.pauseOnOff.get() - - if self.pauseState == True: - - ## first I tried self.unsubscribeFont(), but then self.font = None and had trouble setting self.font after this. - ## I tried ʻʻʻself.font = CurrentFont()ʻʻʻ but didnʻt work - self.font.removeObserver(self, notification="Font.Changed") - ## save the self.font until unpaused. - self.pausedFont = self.font - - #print("paused", self.pauseState) - - if self.pauseState == False: - try: - font = self.pausedFont - - if font is not None: - ## donʻt set font again, this scrolls up to top of window which is annoying - #self.preview.setFont(font) - self.font.naked().addObserver(self, "fontChanged", "Font.Changed") - - #self.subscribeFont(font) - #print("unpaused", self.pauseState) - except: - #print("font = None") - pass - - - + def liveUpdatingCallback(self, sender): + self.isLiveUpdating = sender.get() def constructionsCallback(self, sender, update=True): if self.font is None: @@ -901,7 +870,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"] @@ -914,6 +884,7 @@ 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) From 69c6660e3e9eac720787230534d29b8c4f6dbdc3 Mon Sep 17 00:00:00 2001 From: Frederik Berlaen Date: Thu, 6 Apr 2023 22:01:40 +0200 Subject: [PATCH 5/8] add the new controller in the libExtension --- LibExtension/glyphConstructionController.py | 24 +++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/LibExtension/glyphConstructionController.py b/LibExtension/glyphConstructionController.py index 901c83e..b9da1e3 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) @@ -493,12 +492,17 @@ 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,17 +590,19 @@ 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 +626,10 @@ 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 +870,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"] @@ -873,6 +884,7 @@ 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) From 9ad74e28d18d083fe4babbb939d77524d48a950f Mon Sep 17 00:00:00 2001 From: Frederik Berlaen Date: Thu, 6 Apr 2023 22:01:52 +0200 Subject: [PATCH 6/8] touch the version --- build-extension.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-extension.py b/build-extension.py index f13a672..4b3f703 100644 --- a/build-extension.py +++ b/build-extension.py @@ -27,7 +27,7 @@ B.name = "Glyph Construction" B.developer = 'Frederk Berlaen' B.developerURL = 'http://typemytype.com/' -B.version = '0.12' +B.version = '0.13' B.launchAtStartUp = True B.mainScript = 'glyphConstructionUIStartUp.py' B.html = True From e1469daba05edbac1043ce64afced479707e0cbb Mon Sep 17 00:00:00 2001 From: Frederik Berlaen Date: Thu, 6 Apr 2023 22:02:02 +0200 Subject: [PATCH 7/8] build new extension --- GlyphConstruction.roboFontExt/info.plist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GlyphConstruction.roboFontExt/info.plist b/GlyphConstruction.roboFontExt/info.plist index 08a3118..8a6d58b 100644 --- a/GlyphConstruction.roboFontExt/info.plist +++ b/GlyphConstruction.roboFontExt/info.plist @@ -30,8 +30,8 @@ requiresVersionMinor 5 timeStamp - 1669815851.0749199 + 1680811269.7662001 version - 0.12 + 0.13 From 867c980502d45826a325cc47fec6fd5e499c01e1 Mon Sep 17 00:00:00 2001 From: Frederik Berlaen Date: Fri, 7 Apr 2023 21:26:56 +0200 Subject: [PATCH 8/8] reload when the window is selected and liveUpdate is False --- GlyphConstruction.roboFontExt/info.plist | 2 +- .../lib/glyphConstructionController.py | 15 ++++++++------- LibExtension/glyphConstructionController.py | 16 +++++++++------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/GlyphConstruction.roboFontExt/info.plist b/GlyphConstruction.roboFontExt/info.plist index 8a6d58b..c90c80e 100644 --- a/GlyphConstruction.roboFontExt/info.plist +++ b/GlyphConstruction.roboFontExt/info.plist @@ -30,7 +30,7 @@ requiresVersionMinor 5 timeStamp - 1680811269.7662001 + 1680895559.418968 version 0.13 diff --git a/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py b/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py index b9da1e3..2a51fd2 100644 --- a/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py +++ b/GlyphConstruction.roboFontExt/lib/glyphConstructionController.py @@ -492,17 +492,16 @@ class GlyphBuilderController(BaseWindowController): fileNameKey = "%s.lastSavedFileName" % defaultKey glyphLibConstructionKey = "%s.construction" % defaultKey - - isLiveUpdatingKey = "%s.liveUpdating" % 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)) @@ -595,13 +594,13 @@ def __init__(self, font): button.setBezelStyle_(AppKit.NSRoundRectBezelStyle) button.setAlphaValue_(0) self.w.statusBar.hiddenReload.bind("\r", ["command"]) - + 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) @@ -626,7 +625,6 @@ def unsubscribeFont(self): self.font.removeObserver(self, notification="Font.Changed") self.font = None - def liveUpdatingCallback(self, sender): self.isLiveUpdating = sender.get() @@ -880,6 +878,9 @@ 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") diff --git a/LibExtension/glyphConstructionController.py b/LibExtension/glyphConstructionController.py index b9da1e3..1b55eda 100644 --- a/LibExtension/glyphConstructionController.py +++ b/LibExtension/glyphConstructionController.py @@ -492,17 +492,16 @@ class GlyphBuilderController(BaseWindowController): fileNameKey = "%s.lastSavedFileName" % defaultKey glyphLibConstructionKey = "%s.construction" % defaultKey - - isLiveUpdatingKey = "%s.liveUpdating" % 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)) @@ -595,13 +594,13 @@ def __init__(self, font): button.setBezelStyle_(AppKit.NSRoundRectBezelStyle) button.setAlphaValue_(0) self.w.statusBar.hiddenReload.bind("\r", ["command"]) - + 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) @@ -626,7 +625,6 @@ def unsubscribeFont(self): self.font.removeObserver(self, notification="Font.Changed") self.font = None - def liveUpdatingCallback(self, sender): self.isLiveUpdating = sender.get() @@ -880,6 +878,10 @@ 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")