def permListDoubleClick(self, sender): # Make a new sheet appear try: groupText1 = sender[sender.getSelection()[0]]["Left"] groupText2 = sender[sender.getSelection()[0]]["Right"] sWidth = 600 self.s = vanilla.Sheet((sWidth, 300), self.w) edWidth = int((sWidth - spX * 3) / 2) self.s.text1 = vanilla.TextBox((spX, 5, edWidth, txY), "Left", sizeStyle="small") self.s.text2 = vanilla.TextBox( (spX * 2 + edWidth, 5, edWidth, txY), "Right", sizeStyle="small") self.s.group1 = vanilla.TextEditor( (spX, 10 + txY, edWidth, -spY * 2 - btnY), groupText1) self.s.group1._textView.setFont_(Menlo12) self.s.group2 = vanilla.TextEditor( (spX * 2 + edWidth, 10 + txY, edWidth, -spY * 2 - btnY), groupText2) self.s.group2._textView.setFont_(Menlo12) self.s.cancel = vanilla.Button( (-spX * 2 - 200, -spY - btnY, 100, -spY), "Cancel", callback=self.cancelChange) self.s.ok = vanilla.Button((-spX - 100, -spY - btnY, -spX, -spY), "OK", callback=self.confirmChange) self.s.setDefaultButton(self.s.ok) self.s.open() except IndexError: pass except Exception, e: Glyphs.showMacroWindow() print "BubbleKern Error (permListDoubleClick): %s" % e
def __init__(self): # Window 'self.w': windowWidth = 320 windowHeight = 180 windowWidthResize = 300 # user can resize width by this value windowHeightResize = 400 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Find and Replace In Instance Parameters", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.mekkablue.FindAndReplaceInInstanceParameters.mainwindow" # stores last window position and size ) # UI elements: self.w.text_1 = vanilla.TextBox((15 - 1, 12 + 2, 130, 14), "Replace in parameters", sizeStyle='small') self.w.availableParameters = vanilla.PopUpButton( (145, 12, -15, 17), self.setAvailableParameters(None), callback=self.SavePreferences, sizeStyle='small') self.w.find = vanilla.TextEditor((15, 40, 100, -50), text="find", callback=self.SavePreferences, checksSpelling=False) self.w.replace = vanilla.TextEditor((110, 40, 100, -50), text="replace", callback=self.SavePreferences, checksSpelling=False) self.windowResize(None) # Run Button: self.w.rescanButton = vanilla.Button( (-200, -20 - 15, -110, -15), "Rescan", sizeStyle='regular', callback=self.setAvailableParameters) self.w.runButton = vanilla.Button( (-80 - 15, -20 - 15, -15, -15), "Replace", sizeStyle='regular', callback=self.FindAndReplaceInInstanceParametersMain) self.w.setDefaultButton(self.w.runButton) self.w.bind("resize", self.windowResize) # Load Settings: if not self.LoadPreferences(): print( "Note: 'Find and Replace In Instance Parameters' could not load preferences. Will resort to defaults" ) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): # Window 'self.w': edY = 200 txY = 14 spX = 10 spY = 5 btnX = 250 btnY = 20 windowWidth = 350 windowHeight = edY * 2 + spY * 6 + txY * 2 + btnY + 14 self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Analyse Manuscript", # window title autosaveName= "com.Tosche.AnalyseManuscript.mainwindow" # stores last window position and size ) # UI elements: self.w.text1 = vanilla.TextBox((spX, spY, -spX, txY), 'Paste your text below...', sizeStyle='small') self.w.dump = vanilla.TextEditor((spX, spY * 2 + txY, -spX, edY), "", callback=self.updateChar) self.w.text2 = vanilla.TextBox((spX, spY * 3 + txY + edY, -spX, txY), "0 Unicode characters", sizeStyle='small') self.w.chars = vanilla.TextEditor( (spX, spY * 4 + txY * 2 + edY, -spX, edY), "", readOnly=True) self.w.chars._textView.setFont_(NSFont.fontWithName_size_("Menlo", 12)) self.w.dump._textView.setAutomaticSpellingCorrectionEnabled_(False) self.w.dump._textView.setAutomaticTextReplacementEnabled_(False) self.w.dump._textView.setContinuousSpellCheckingEnabled_(False) self.w.dump._textView.setGrammarCheckingEnabled_(False) self.w.dump._textView.setAutomaticQuoteSubstitutionEnabled_(False) # Run Button: self.w.markPopup = vanilla.PopUpButton( (spX, -btnY - spY - 7, 70, -spY - 7), [ "Mark", "Red", "Orange", "Brown", "Yellow", "Light Green", "Dark Green", "Cyan", "Blue", "Purple", "Pink", "Light Grey", "Dark Grey" ], callback=self.markGlyphs) self.w.runButton = vanilla.Button( (-btnX - spX, -btnY - spY - 7, -spX, -spY - 7), "Add missing characters", sizeStyle='regular', callback=self.AnalyseManuscriptMain) self.w.setDefaultButton(self.w.runButton) # Open window and focus on it: self.w.open() menu = self.w.markPopup._nsObject.menu() menu.setAutoenablesItems_(False) menu.itemAtIndex_(0).setEnabled_(False) divider = NSMenuItem.separatorItem() menu.insertItem_atIndex_(divider, 1) self.w.makeKey()
def __init__(self): try: self.w = vanilla.FloatingWindow((windowWidth, windowHeight), "Cluster Kern Groups") instructions = "To prepare for kerning, we need to automatically set the kern groups. First we will group your glyphs by their left and right edges. Adjust the sliders to change the grouping tolerance. When the groups look reasonable, press 'Proceed'. Alternatively, you can load your existing kern groups." self.w.instr = vanilla.TextBox((10, 10, windowWidth - 10, 45), instructions, "left", sizeStyle='small') self.w.text_anchorL = vanilla.TextBox( (10, 50, windowWidth / 2 - 10, 15), "Left Tolerance", "center", sizeStyle='small') self.w.lSlider = vanilla.Slider( (10, 60, -(10 + windowWidth / 2), 15), 0.01, 500, callback=self.buttonPressed) self.w.text_anchorR = vanilla.TextBox( (windowWidth / 2, 50, windowWidth / 2 - 10, 15), "Right Tolerance", "center", sizeStyle='small') self.w.rSlider = vanilla.Slider( (10 + windowWidth / 2, 60, -10, 15), 0.01, 500, callback=self.buttonPressed) self.w.useMine = vanilla.Button( (windowWidth / 2 - 200, -50, 100, 20), "Just Use Mine", callback=self.useMine) self.w.calculate = vanilla.Button( (windowWidth / 2 - 50, -50, 100, 20), "Calculate", callback=self.buttonPressed) self.w.proceed = vanilla.Button((-120, -50, 100, 20), "Proceed", callback=self.checkModelAndApply) self.w.proceed.enable(False) self.w.progressBar = vanilla.ProgressBar( (10, windowHeight - 20, windowWidth - 20, 10)) self.w.progressBar.set(0) self.w.resultsL = vanilla.TextEditor( (10, 80, windowWidth / 2 - 10, -60)) self.w.resultsR = vanilla.TextEditor( (windowWidth / 2, 80, windowWidth / 2 - 10, -60)) self.w.open() self.lefts = [] self.rights = [] self.loadSidebearings() self.mineUsed = False except Exception, e: print(e)
def __init__( self ): # Window 'self.w': windowWidth = 400 windowHeight = 300 windowWidthResize = 1000 # user can resize width by this value windowHeightResize = 1000 # user can resize height by this value self.w = vanilla.FloatingWindow( ( windowWidth, windowHeight ), # default window size "Merge Suffixed Glyphs into Color Layers", # window title minSize = ( windowWidth, windowHeight ), # minimum size (for resizing) maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing) autosaveName = "com.mekkablue.MergeSuffixedGlyphsIntoColorLayers.mainwindow" # stores last window position and size ) # UI elements: linePos, inset, lineHeight = 12, 15, 22 self.w.descriptionText = vanilla.TextBox( (inset, linePos+2, -inset, 14), "Merge suffixed glyphs into the following color indexes:", sizeStyle='small', selectable=True ) linePos += lineHeight self.w.indexToSuffix = vanilla.TextEditor( (2, linePos, -2, -110), "# Syntax: CPAL index = glyph name suffix\n# list them in chronological order (bottom-up)\n# use hashtags for comments\n0=.shadow\n2=.body\n1=.front", callback=self.SavePreferences, checksSpelling=False ) #self.w.indexToSuffix.getNSTextEditor().setToolTip_("Syntax: colorindex=.suffix, use hashtags for comments. List them in chronological order (bottom-up). Example:\n0=.shadow\n2=.body\n1=.front") self.w.indexToSuffix.getNSScrollView().setHasVerticalScroller_(1) self.w.indexToSuffix.getNSScrollView().setHasHorizontalScroller_(1) self.w.indexToSuffix.getNSScrollView().setRulersVisible_(0) legibleFont = NSFont.legibileFontOfSize_(NSFont.systemFontSize()) textView = self.w.indexToSuffix.getNSTextView() textView.setFont_(legibleFont) textView.setHorizontallyResizable_(1) textView.setVerticallyResizable_(1) textView.setAutomaticDataDetectionEnabled_(1) textView.setAutomaticLinkDetectionEnabled_(1) textView.setDisplaysLinkToolTips_(1) textSize = textView.minSize() textSize.width = 1000 textView.setMinSize_(textSize) linePos = -105 self.w.disableSuffixedGlyphs = vanilla.CheckBox( (inset, linePos-1, -inset, 20), "Deactivate export for glyphs with listed suffixes", value=True, callback=self.SavePreferences, sizeStyle='small' ) linePos += lineHeight self.w.deletePreexistingColorLayers = vanilla.CheckBox( (inset, linePos-1, -inset, 20), "Delete preexisting Color layers in target glyphs", value=True, callback=self.SavePreferences, sizeStyle='small' ) linePos += lineHeight self.w.processCompleteFont = vanilla.CheckBox( (inset, linePos-1, -inset, 20), "Process complete font (otherwise only add into selected glyphs)", value=False, callback=self.SavePreferences, sizeStyle='small' ) linePos += lineHeight # Run Button: self.w.runButton = vanilla.Button( (-80-inset, -20-inset, -inset, -inset), "Merge", sizeStyle='regular', callback=self.MergeSuffixedGlyphsIntoColorLayersMain ) # self.w.setDefaultButton( self.w.runButton ) # Load Settings: if not self.LoadPreferences(): print("Note: 'Merge Suffixed Glyphs into Color Layers' could not load preferences. Will resort to defaults") # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__( self ): # Window 'self.w': windowWidth = 300 windowHeight = 160 windowWidthResize = 500 # user can resize width by this value windowHeightResize = 500 # user can resize height by this value self.w = vanilla.Window( ( windowWidth, windowHeight ), # default window size "Pangram Helper", # window title minSize = ( windowWidth, windowHeight ), # minimum size (for resizing) maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing) autosaveName = "com.mekkablue.PangramHelper.mainwindow" # stores last window position and size ) # UI elements: self.w.missingLetters = vanilla.TextBox( (15, 12+2, -15, 14), "Missing: %s" % fullAlphabet.upper(), sizeStyle='small' ) self.w.pangram = vanilla.TextEditor( (1, 40, -1, -45), "The quick brown fox jumps over the lazy dog.", checksSpelling=True, callback = self.updateMissingLetters) # Run Button: self.w.copyButton = vanilla.Button((-170, -20-15, -110, -15), "Copy", sizeStyle='regular', callback=self.PangramHelperMain ) self.w.tabButton = vanilla.Button((-100, -20-15, -15, -15), "Open Tab", sizeStyle='regular', callback=self.PangramHelperMain ) self.w.setDefaultButton( self.w.tabButton ) # Load Settings: if not self.LoadPreferences(): print "Note: 'Pangram Helper' could not load preferences. Will resort to defaults" # Open window and focus on it: self.updateMissingLetters() self.w.open() self.w.pangram.selectAll() self.w.makeKey()
def __init__( self ): # Window 'self.w': windowWidth = 550 windowHeight = 260 windowWidthResize = 1000 # user can resize width by this value windowHeightResize = 1000 # user can resize height by this value self.w = vanilla.FloatingWindow( ( windowWidth, windowHeight ), # default window size "Encoding Converter", # window title minSize = ( windowWidth, windowHeight ), # minimum size (for resizing) maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing) autosaveName = "com.mekkablue.EncodingConverter.mainwindow" # stores last window position and size ) # UI elements: linePos, inset, lineHeight = 8, 15, 22 self.w.descriptionText = vanilla.TextBox( (inset, linePos+2, -inset, 14), "Enter conversion text (see tooltips):", sizeStyle='small', selectable=True ) linePos += lineHeight self.w.recipe = vanilla.TextEditor( (1, linePos, -1, -inset*3), text="", callback=self.SavePreferences, checksSpelling=False ) self.w.recipe.getNSTextView().setToolTip_("- Freely write comments and empty lines\n- Rename: Lines containing a dash (-) followed by a greater sign (>) will trigger glyph renaming, with or without spaces between names\n- Recipe: Lines containing glyph recipes with plus (+) and equals (=) will be treated like in Glyph > Add Glyphs... as long as the do not contain any space\n- Recipes will overwrite existing glyphs. Renamings will create a number-suffixed glyph if a glyph with the same name already exists.") self.w.recipe.getNSScrollView().setHasVerticalScroller_(1) self.w.recipe.getNSScrollView().setHasHorizontalScroller_(1) self.w.recipe.getNSScrollView().setRulersVisible_(0) legibleFont = NSFont.legibileFontOfSize_(NSFont.systemFontSize()) textView = self.w.recipe.getNSTextView() textView.setFont_(legibleFont) textView.setHorizontallyResizable_(1) textView.setVerticallyResizable_(1) textView.setAutomaticDataDetectionEnabled_(1) textView.setAutomaticLinkDetectionEnabled_(1) textView.setDisplaysLinkToolTips_(1) textSize = textView.minSize() textSize.width = 1000 textView.setMinSize_(textSize) # textView.textContainer().setWidthTracksTextView_(0) # textView.textContainer().setContainerSize_(textSize) # Run Button: self.w.openButton = vanilla.Button( (inset, -20-inset, 110, -inset), "Open Text…", sizeStyle='regular', callback=self.importEncoding ) self.w.saveButton = vanilla.Button( (inset+120, -20-inset, 110, -inset), "Save Text…", sizeStyle='regular', callback=self.exportEncoding ) self.w.resetButton = vanilla.Button( (inset+260, -20-inset, 100, -inset), "Reset Text", sizeStyle='regular', callback=self.resetEncoding ) self.w.runButton = vanilla.Button( (-120-inset, -20-inset, -inset, -inset), "Convert Font", sizeStyle='regular', callback=self.EncodingConverterMain ) self.w.setDefaultButton( self.w.runButton ) # Load Settings: if not self.LoadPreferences(): print("Note: 'Encoding Converter' could not load preferences. Will resort to defaults") # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): # Window 'self.w': windowWidth = 200 windowHeight = 360 windowWidthResize = 1200 # user can resize width by this value windowHeightResize = 500 # user can resize height by this value self.w = vanilla.FloatingWindow( ( windowWidth, windowHeight ), # default window size "Demo Instances Generator", # window title minSize = ( windowWidth, windowHeight ), # minimum size (for resizing) maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing) autosaveName = "save.DemoInstancesGenerator.mainwindow" # stores last window position and size ) # UI elements: self.w.text_name = vanilla.TextBox( (m, m-3, windowWidth, tm), "Name (Suffix):", sizeStyle='small' ) self.w.text_glyphs = vanilla.TextBox( (m, tm*2+m-3, windowWidth, tm), "Limited Character Set:", sizeStyle='small' ) self.w.name = vanilla.TextEditor( (m, tm, windowWidth-m*2, tm), callback=self.SavePreferences, checksSpelling=False ) self.w.glyphs = vanilla.TextEditor( (m, tm*3, windowWidth-m*2, -bm), callback=self.SavePreferences, checksSpelling=False ) self.windowResize(None) # Run Button: self.w.runButton = vanilla.Button((-80-m, -20-m, -m, m), "Generate", sizeStyle='regular', callback=self.generateDemoInstances ) self.w.setDefaultButton( self.w.runButton ) # Reset Button: self.w.resetButton = vanilla.Button(((-80-m)*2, -20-m, (-80-m)-m, m), "Reset", sizeStyle='regular', callback=self.ResetParameters ) self.w.bind("resize",self.windowResize) # Load Settings: if not self.LoadPreferences(): print("Note: 'Demo Fonts Generator' could not load preferences. Will resort to defaults") # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): self.w = vanilla.FloatingWindow((330, 110), "Interpolate Master's Vert Metrics") self.w.textBox = vanilla.TextBox((10, 10, -10, 17), "Enter value between 1.0 > 0.0") self.w.interpolation_value = vanilla.TextEditor((10, 30, -10, 17)) self.w.ignore_win_metrics = vanilla.CheckBox((10, 50, 180, 20), 'Ignore Win Metrics', value=True) # Check button self.w.button = vanilla.Button((10, 80, -10, 17), "Interpolate", callback=self.buttonCallback) self.w.open()
def __init__(self): # Window 'self.w': windowWidth = 250 windowHeight = 200 windowWidthResize = 800 # user can resize width by this value windowHeightResize = 800 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Rename Glyphs", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.mekkablue.RenameGlyphs.mainwindow" # stores last window position and size ) # UI elements: self.w.text_1 = vanilla.TextBox((10, 12 + 2, -10, 14), "Add lines like oldname=newname:", sizeStyle='small') self.w.renameList = vanilla.TextEditor((1, 40, -1, -40), "oldname=newname", callback=self.SavePreferences) self.w.renameList.getNSTextView().setFont_( NSFont.userFixedPitchFontOfSize_(-1.0)) self.w.renameList.getNSTextView().turnOffLigatures_(1) self.w.renameList.getNSTextView().useStandardLigatures_(0) self.w.renameList.selectAll() # Run Button: self.w.runButton = vanilla.Button((-100, -35, -15, -15), "Rename", sizeStyle='regular', callback=self.RenameGlyphsMain) #self.w.setDefaultButton( self.w.runButton ) # Load Settings: if not self.LoadPreferences(): print( "Note: 'Rename Glyphs' could not load preferences. Will resort to defaults" ) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): # Window 'self.w': windowWidth = 250 windowHeight = 300 windowWidthResize = 500 # user can resize width by this value windowHeightResize = 300 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "SVN Update", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.mekkablue.SVNUpdate.mainwindow" # stores last window position and size ) # UI elements: self.w.descriptionText = vanilla.TextBox( (15 - 1, 12 + 2, -14, 14), "SVN Update these paths (1 path per line):", sizeStyle='small') self.w.svnPaths = vanilla.TextEditor( (15, 12 + 20, -15, -40), text="~/Library/Application Support/Glyphs/Scripts/", ) self.w.svnPaths.getNSTextView().setFont_( NSFont.fontWithName_size_("Menlo", 12.0)) # Run Button: self.w.runButton = vanilla.Button((-95, -20 - 15, -15, -15), "Update", sizeStyle='regular', callback=self.SVNUpdateMain) self.w.setDefaultButton(self.w.runButton) # Load Settings: if not self.LoadPreferences(): print "Note: 'SVN Update' could not load preferences. Will resort to defaults" # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): self.alphabetSet = alphabetSetLower # set up window self.w = vanilla.Window((420, 150), "Pangrammer Helper") # set up remaining letters display self.w.alphabet = vanilla.TextBox((15, 15, -15, 20), self.alphabetSet) # set up text field, inserting Space Center text if available if CurrentSpaceCenter() is None: pangram = "Type your pangram here" else: sp = CurrentSpaceCenter() pangram = sp.getRaw() self.w.pangramEditor = vanilla.TextEditor( (15, 40, -15, 70), pangram, callback=self.textEditorCallback) self.w.counter = vanilla.TextBox((-250, 112, -15, 20), "Pangram length: 0", alignment='right') self.w.checkBox = vanilla.CheckBox((15, 110, -15, 20), "", callback=self.checkBoxCallback, value=False) self.w.checkBoxLabel = vanilla.TextBox( # don’t know how to access the NSText of a Vanilla check box label (32, 112, -15, 20), "Mixed case") # set the editor font to be monospaced, and the rest to be system font monospace_font = NSFont.userFixedPitchFontOfSize_(12) system_font = NSFont.systemFontOfSize_(12) self.w.pangramEditor.getNSTextView().setFont_(monospace_font) self.w.alphabet.getNSTextField().setFont_(system_font) self.w.counter.getNSTextField().setFont_(system_font) self.w.checkBoxLabel.getNSTextField().setFont_(system_font) self.w.open() # set remaining letters and counter to reflect contents of text field self.textEditorCallback(self)
def __init__(self): # register prefs if run for the first time: if not Glyphs.defaults["com.mekkablue.Bumper.kernStrings"]: self.RegisterPreferences() # Window 'self.w': windowWidth = 500 windowHeight = 365 windowWidthResize = 500 # user can resize width by this value windowHeightResize = 500 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Auto Bumper", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.mekkablue.Bumper.mainwindow" # stores last window position and size ) # UI elements: inset, lineHeight, currentHeight = 14, 24, -10 currentHeight += lineHeight self.w.text_1 = vanilla.TextBox( (inset, currentHeight, -inset, 14), "Add supplementary kerning for specified glyphs in the current master:", sizeStyle='small') currentHeight += lineHeight self.w.swapButton = vanilla.SquareButton( (-inset - 20, currentHeight, -inset, 42), u"↰\n↲", sizeStyle='regular', callback=self.swap) self.w.text_left = vanilla.TextBox((inset, currentHeight + 3, 80, 14), "Left glyphs:", sizeStyle='small') self.w.leftGlyphs = vanilla.ComboBox( (inset + 80, currentHeight, -inset - 102, 18), self.kernStringList(self), callback=self.SavePreferences, sizeStyle='small') self.w.leftGlyphs.getNSComboBox().setToolTip_( u"Measures the specified glyphs from their right side to the following glyph. You can type the character ‘é’ or the slash-escaped glyph name ‘/eacute’. Or specify a category after an at sign ‘@Letter’, add a subcategory after a colon ‘@Letter:Lowercase’.\nAdd default strings in the text box at the bottom of the window. Expand the window at the bottom to access it." ) self.w.leftIsGroups = vanilla.CheckBox( (-inset - 94, currentHeight + 1, -inset - 22, 17), u"As groups", value=True, sizeStyle='small', callback=self.SavePreferences) self.w.leftIsGroups.getNSButton().setToolTip_( u"If on, will measure only the specified glyph, but set the calculated kerning for the whole right group of the glyph (i.e., add group kerning). If off, will set the kerning for the glyph only (i.e., add an exception)." ) currentHeight += lineHeight self.w.text_right = vanilla.TextBox((inset, currentHeight + 3, 80, 14), "Right glyphs:", sizeStyle='small') self.w.rightGlyphs = vanilla.ComboBox( (inset + 80, currentHeight, -inset - 102, 18), self.kernStringList(self), callback=self.SavePreferences, sizeStyle='small') self.w.rightGlyphs.getNSComboBox().setToolTip_( u"Measures from the previous glyphs to the specified glyphs to their left side. You can type the character ‘é’ or the slash-escaped glyph name ‘/eacute’. Or specify a category after an at sign ‘@Letter’, add a subcategory after a colon ‘@Letter:Lowercase’.\nAdd default strings in the text box at the bottom of the window. Expand the window at the bottom to access it." ) self.w.rightIsGroups = vanilla.CheckBox( (-inset - 94, currentHeight + 1, -inset - 22, 17), u"As groups", value=True, sizeStyle='small', callback=self.SavePreferences) self.w.rightIsGroups.getNSButton().setToolTip_( u"If on, will measure only the specified glyph, but set the calculated kerning for the whole left group of the glyph (i.e., add group kerning). If off, will set the kerning for the glyph only (i.e., add an exception)." ) currentHeight += lineHeight self.w.suffixText = vanilla.TextBox((inset, currentHeight + 3, 80, 14), u"Add suffix:", sizeStyle='small', selectable=True) self.w.suffix = vanilla.EditText((inset + 80, currentHeight, 150, 19), "", callback=self.SavePreferences, sizeStyle='small') self.w.suffix.getNSTextField().setToolTip_( "Looks for the suffixed version of the listed glyphs, with this suffix added to the name. Useful with .sc for smallcaps. Enter WITH the leading dot for dot suffixes. Can also be used with 'superior' for figures." ) currentHeight += lineHeight self.w.text_21 = vanilla.TextBox((inset, currentHeight + 3, 80, 14), "Min distance:", sizeStyle='small') self.w.minDistance = vanilla.EditText( (inset + 80, currentHeight, 60, 19), "50", sizeStyle='small', callback=self.SavePreferences) self.w.minDistance.getNSTextField().setPlaceholderString_("50") self.w.minDistance.getNSTextField().setToolTip_( u"Adds kerning if the shortest distance between two glyphs is shorter than specified value. Leave blank or set to zero to ignore." ) self.w.text_22 = vanilla.TextBox( (inset + 80 * 2, currentHeight + 3, 80, 14), "Max distance:", sizeStyle='small') self.w.maxDistance = vanilla.EditText( (inset + 80 * 3, currentHeight, 60, 19), "200", sizeStyle='small', callback=self.SavePreferences) self.w.maxDistance.getNSTextField().setPlaceholderString_("200") self.w.maxDistance.getNSTextField().setToolTip_( u"Adds kerning if the shortest distance between two glyphs is larger than specified value. Leave blank or set to zero to ignore." ) self.w.text_23 = vanilla.TextBox( (inset + 80 * 4, currentHeight + 3, 80, 14), "Round by:", sizeStyle='small') self.w.roundFactor = vanilla.EditText( (inset + 80 * 5, currentHeight, -inset, 19), "10", sizeStyle='small', callback=self.SavePreferences) self.w.roundFactor.getNSTextField().setPlaceholderString_("10") self.w.roundFactor.getNSTextField().setToolTip_( u"Rounds calculated kerning. Leave blank or set to zero to ignore." ) currentHeight += lineHeight self.w.text_speed = vanilla.TextBox((inset, currentHeight + 3, 42, 14), "Speed:", sizeStyle='small') self.w.speedPopup = vanilla.PopUpButton( (inset + 42, currentHeight + 1, 80, 17), ["very slow", "slow", "medium", "fast", "very fast"], callback=self.SavePreferences, sizeStyle='small') self.w.speedPopup.getNSPopUpButton().setToolTip_( u"Specifies the number of measurements. Measuring is processor-intensive and can take a while. Slow: many measurements, fast: few measurements." ) intervalIndex = Glyphs.defaults["com.mekkablue.Bumper.speedPopup"] if intervalIndex is None: intervalIndex = 0 self.w.text_speedExplanation = vanilla.TextBox( (inset + 42 + 90, currentHeight + 3, -15, 14), "Measuring every %i units." % intervalList[intervalIndex], sizeStyle='small') currentHeight += lineHeight self.w.text_6 = vanilla.TextBox((inset, currentHeight + 3, 130, 14), "Ignore height intervals:", sizeStyle='small') self.w.ignoreIntervals = vanilla.EditText( (inset + 130, currentHeight, -inset, 19), "", callback=self.SavePreferences, sizeStyle='small') self.w.ignoreIntervals.getNSTextField().setPlaceholderString_( "200:300, 400:370, -200:-150") self.w.ignoreIntervals.getNSTextField().setToolTip_( u"Does not measure on y coordinates in intervals specified as y1:y2. Separate multiple intervals with commas." ) currentHeight += lineHeight self.w.keepExistingKerning = vanilla.CheckBox( (inset + 5, currentHeight, -inset, 17), u"Keep (don’t overwrite) existing kerning", value=True, sizeStyle='small', callback=self.SavePreferences) self.w.keepExistingKerning.getNSButton().setToolTip_( u"If the kern pair already exists in the font, it will not be overwritten." ) currentHeight += lineHeight self.w.excludeNonExporting = vanilla.CheckBox( (inset + 5, currentHeight, 200, 17), u"Exclude non-exporting glyphs", value=True, sizeStyle='small', callback=self.SavePreferences) self.w.excludeNonExporting.getNSButton().setToolTip_( u"If one of the specified glyphs is not set to export, Auto Bumper will skip it." ) self.w.avoidZeroKerning = vanilla.CheckBox( (inset + 200, currentHeight, -inset, 17), u"Avoid zero kerns", value=True, sizeStyle='small', callback=self.SavePreferences) self.w.avoidZeroKerning.getNSButton().setToolTip_( u"If the calculated (and rounded) kerning value is 0, it will not be added to the font." ) currentHeight += lineHeight self.w.reportInMacroWindow = vanilla.CheckBox( (inset + 5, currentHeight, -inset, 17), u"Also report in Macro Window (a few seconds slower)", value=False, sizeStyle='small', callback=self.SavePreferences) self.w.reportInMacroWindow.getNSButton().setToolTip_( u"Outputs a detailed report in the Macro Window, and opens it.") currentHeight += lineHeight self.w.openNewTabWithKernPairs = vanilla.CheckBox( (inset + 5, currentHeight, -inset, 17), u"Open new Edit tab with new kern pairs", value=False, sizeStyle='small', callback=self.SavePreferences) self.w.openNewTabWithKernPairs.getNSButton().setToolTip_( u"If kern pairs were added, opens them in a new Edit tab, for inspection." ) currentHeight += lineHeight # Progress Bar: self.w.bar = vanilla.ProgressBar((inset, currentHeight, -inset, 16)) currentHeight += lineHeight # (Hidden) Preferences Kern Strings: self.w.kernStrings = vanilla.TextEditor((1, currentHeight, -1, -45), callback=self.SavePreferences) self.w.kernStrings.getNSTextView().setToolTip_( "Add your default kern strings here. They will show up in the left/right dropdowns at the top. Everything after a hashtag (#) is ignored. Use blank lines for structuring." ) self.w.text_kernStrings = vanilla.TextBox( (inset, -14 - inset, -100 - inset, -inset), "Expand window below to access default strings.", sizeStyle='small') self.w.text_kernStrings.getNSTextField().setTextColor_( NSColor.colorWithRed_green_blue_alpha_(0, 0, 0, 0.2)) # Run Button: self.w.runButton = vanilla.Button( (-100 - inset, -20 - inset, -inset, -inset), "Kern", sizeStyle='regular', callback=self.BumperMain) self.w.setDefaultButton(self.w.runButton) # Load Settings: if not self.LoadPreferences(): print( "Note: Auto Bumper could not load preferences. Will resort to defaults" ) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): # Window 'self.w': windowWidth = 350 windowHeight = 240 windowWidthResize = 1000 # user can resize width by this value windowHeightResize = 1000 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Metrics Key Manager", # window title minSize=(windowWidth, windowHeight - 100), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.mekkablue.MetricsKeyManager.mainwindow" # stores last window position and size ) # UI elements: linePos, inset, lineHeight, boxHeight = self.getMeasurements() self.w.LeftMetricsKeysText = vanilla.TextBox( (inset, linePos + 2, 70, 14), u"Left Keys:", sizeStyle='small', selectable=True) self.w.LeftMetricsKeys = vanilla.TextEditor( (inset + 70, linePos, -inset, boxHeight), "", callback=self.SavePreferences) #, sizeStyle='small' ) linePos += boxHeight + 10 self.w.RightMetricsKeysText = vanilla.TextBox( (inset, linePos + 2, 70, 14), u"Right Keys:", sizeStyle='small', selectable=True) self.w.RightMetricsKeys = vanilla.TextEditor( (inset + 70, linePos, -inset, boxHeight), "", callback=self.SavePreferences) #, sizeStyle='small' ) editFont = NSFont.legibileFontOfSize_(NSFont.smallSystemFontSize()) for editField in (self.w.LeftMetricsKeys, self.w.RightMetricsKeys): editField.getNSTextView().setToolTip_( u"Enter a metrics key like '=H', followed by a colon (:), followed by glyph names, spearated by space, comma, or any other separator that cannot be part of a glyph name. (Glyph names can contain A-Z, a-z, 0-9, period, underscore and hyphen.)\nExample: ‘=H: B D E F’." ) editField.getNSTextView().setFont_(editFont) editField.getNSScrollView().setHasVerticalScroller_(1) editField.getNSScrollView().setRulersVisible_(1) # Buttons: self.w.resetButton = vanilla.Button( (-280 - inset, -20 - inset, -inset - 190, -inset), u"⟲ Reset", sizeStyle='regular', callback=self.SetDefaults) self.w.resetButton.getNSButton().setToolTip_( u"Resets the contents of the L+R Keys to their (currently only Latin) defaults." ) self.w.scanButton = vanilla.Button( (-180 - inset, -20 - inset, -inset - 90, -inset), u"↑ Extract", sizeStyle='regular', callback=self.ScanFontForKeys) self.w.scanButton.getNSButton().setToolTip_( u"Scans the current font for all metrics keys and lists them here. Normalizes the preceding equals sign (=). No matter whether you typed them with or without an equals sign, they will show up here with one." ) self.w.runButton = vanilla.Button( (-80 - inset, -20 - inset, -inset, -inset), u"↓ Apply", sizeStyle='regular', callback=self.MetricsKeyManagerMain) self.w.runButton.getNSButton().setToolTip_( u"Parses the current content of the window and will attempt to set the metrics keys of the respective glyphs in the frontmost font." ) self.w.setDefaultButton(self.w.runButton) # Load Settings: if not self.LoadPreferences(): print( "Note: 'Metrics Key Manager' could not load preferences. Will resort to defaults" ) # Bind resizing method: self.w.bind("resize", self.windowResize) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__( self ): windowWidth = 600 windowHeight = 260 self.w = vanilla.FloatingWindow( ( windowWidth, windowHeight ), # default window size "BubbleKern", # window title minSize = ( windowWidth, windowHeight ), # minimum size (for resizing) autosaveName = "com.Tosche.BubbleKern.mainwindow" # stores last window position and size ) self.w.tabs = vanilla.Tabs((spX, spY, -spX, -spY*2-btnY), ["Pair List Builder", "Flat Text"]) tab0 = self.w.tabs[0] tab0.options = vanilla.PopUpButton((spX, 0, 200, btnY), tab0options, callback=self.optionTasks ) tab0.options._nsObject.menu().setAutoenablesItems_(False) emptyPermutation = [{" ":"", "Left":"", "Right":"", "Add Flipped":"", "Pair Count":"0" }] GroupColumnWidth = int((self.w.getPosSize()[2]-180-spX*5-prevX)/2+1) tab0.permList = vanilla.List((spX, spY+btnY, -prevX-spX*2, -spY*3), emptyPermutation, columnDescriptions=[ {"title":" ", "width":20}, {"title":"Left", "width":GroupColumnWidth}, {"title":"Right", "width":GroupColumnWidth}, {"title":"Add Flipped","cell":vanilla.CheckBoxListCell(), "width":70}, {"title":"Pair Count", "width":90} ], # dragSettings = dict( type=NSString, callback=self.dragCallback ), # WHY DOES THIS THING NOT WORK? selfDropSettings=dict(type=toolOrderDragType, operation=NSDragOperationMove, callback=self.dropListSelfCallback), allowsMultipleSelection = False, selectionCallback = self.permListSelected, doubleClickCallback= self.permListDoubleClick, ) tableView = tab0.permList._tableView tableView.setAllowsColumnReordering_(False) tableView.unbind_("sortDescriptors") # Disables sorting by clicking the title bar tableView.tableColumns()[0].setResizingMask_(0) tableView.tableColumns()[1].setResizingMask_(1) tableView.tableColumns()[2].setResizingMask_(1) tableView.tableColumns()[3].setResizingMask_(0) tableView.tableColumns()[4].setResizingMask_(0) tableView.setColumnAutoresizingStyle_(1) # setResizingMask_() 0=Fixed, 1=Auto-Resizable (Not user-resizable). There may be more options? # setColumnAutoresizingStyle accepts value from 0 to 5. # For detail,see: http://api.monobjc.net/html/T_Monobjc_AppKit_NSTableViewColumnAutoresizingStyle.htm tab0.sectionPreview = vanilla.TextBox((-prevX-spX, spY+btnY-2, -spX, txY), "Section Preview", sizeStyle = "small") tab0.preview = vanilla.TextEditor((-prevX-spX, spY+btnY+txY, -spX, -spY*3), "", readOnly=True) tab0.preview._textView.setFont_( Menlo12 ) tab0.total = vanilla.TextBox((-prevX-spX*2-75, -spY-txY, 100, txY), "", sizeStyle = "small") # Add & Delete Buttons: tab0.add = vanilla.SquareButton((spX, -spY*3-1, 30, 20), "+", sizeStyle = 'regular', callback=self.addButton) tab0.delete = vanilla.SquareButton((spX+29, -spY*3-1, 30, 20), u"–", sizeStyle = 'regular', callback=self.delButton) tab1 = self.w.tabs[1] tab1.loadButton = vanilla.Button((spX, 0, 160, btnY), "Load a Text File", callback=self.loadFile) tab1.flatPairs = vanilla.TextEditor((spX, spY+btnY, -spX, -spY*3), "", callback=self.refreshPairNum) tab1.flatPairs._textView.setFont_( Menlo12 ) tab1.pairNum = vanilla.TextBox((10, -spY-txY, -10, txY), "", sizeStyle = "small") self.w.allButton = vanilla.Button((-spX*2-btnX*2-60, -btnY-spY, btnX, btnY), "Kern All Pairs", sizeStyle='regular', callback=self.BubbleKernMain) self.w.selButton = vanilla.Button((-spX-btnX-60, -btnY-spY, btnX+60, btnY), "Kern Pairs with Selected Glyphs", sizeStyle='regular', callback=self.BubbleKernMain ) # Load Settings: if not self.LoadPreferences(): print "Note: 'BubbleKern' could not load preferences. Will resort to defaults" self.refreshTotal() self.refreshSectionPreview(0) self.refreshPairNum(self.w) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): # Window 'self.w': windowWidth = 350 windowHeight = 360 windowWidthResize = 1200 # user can resize width by this value windowHeightResize = 500 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Text Simplifier", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "save.TextFilter.mainwindow" # stores last window position and size ) # UI elements: self.w.text_inpt = vanilla.TextBox((m, m - 3, m, tm), "Input:", sizeStyle='small') self.w.text_outpt = vanilla.TextBox((m, m, m, tm), "Output:", sizeStyle='small') self.w.text_glyphs = vanilla.TextBox((m, m, m, tm), "Character set:", sizeStyle='small') self.w.inpt = vanilla.TextEditor((m, tm, m, tm), callback=self.SavePreferences, checksSpelling=False) self.w.outpt = vanilla.TextEditor((m, tm, m, tm), callback=self.SavePreferences, checksSpelling=False, readOnly='True') self.w.glyphs = vanilla.TextEditor((m, tm, m, tm), callback=self.SavePreferences, checksSpelling=False) self.windowResize(None) self.w.bind("resize", self.windowResize) # Run Button: self.w.runButton = vanilla.Button((-80 - m, -20 - m, -m, m), "Simplify", sizeStyle='regular', callback=self.TextFilter) self.w.setDefaultButton(self.w.runButton) # Reset Button: self.w.resetButton = vanilla.Button( ((-80 - m) * 2, -20 - m, (-80 - m) - m, m), "Reset", sizeStyle='regular', callback=self.ResetParameters) # Open in a new Tab checkbox self.w.newTab = vanilla.CheckBox((m, -20 - m, (-80 - m) - m, m), "Open in a New Tab", sizeStyle='regular', value=False) # Load Settings: if not self.LoadPreferences(): print( "Note: 'Text Simplifier' could not load preferences. Will resort to defaults" ) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): # Window 'self.w': windowWidth = 350 windowHeight = 260 windowWidthResize = 1000 # user can resize width by this value windowHeightResize = 1000 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Production Namer", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.mekkablue.ProductionNamer.mainwindow" # stores last window position and size ) # UI elements: linePos, inset, lineHeight = 12, 15, 22 self.w.descriptionText = vanilla.TextBox( (inset, linePos + 2, -inset, 14), "Will reset the production names of these glyphs:", sizeStyle='small', selectable=True) linePos += lineHeight self.w.recipe = vanilla.TextEditor((1, linePos, -1, -70), text=defaultString.strip(), callback=self.SavePreferences, checksSpelling=False) self.w.recipe.getNSTextView().setToolTip_( "- Syntax: glyphname -> productionname\n- Whitespace does not matter\n- Only lines containing a dash (-) followed by a greater sign (>) count\n- Freely write comments and empty lines\n- Anything after a hashtag (#) is ignored" ) self.w.recipe.getNSScrollView().setHasVerticalScroller_(1) self.w.recipe.getNSScrollView().setHasHorizontalScroller_(1) self.w.recipe.getNSScrollView().setRulersVisible_(0) legibleFont = NSFont.legibileFontOfSize_(NSFont.systemFontSize()) textView = self.w.recipe.getNSTextView() textView.setFont_(legibleFont) textView.setHorizontallyResizable_(1) textView.setVerticallyResizable_(1) textView.setAutomaticDataDetectionEnabled_(1) textView.setAutomaticLinkDetectionEnabled_(1) textView.setDisplaysLinkToolTips_(1) textSize = textView.minSize() textSize.width = 1000 textView.setMinSize_(textSize) # APPLY TO FONTS linePos = -inset - 50 self.w.finger = vanilla.TextBox((inset - 5, linePos, 22, 22), "👉 ", sizeStyle='regular', selectable=True) self.w.applyText = vanilla.TextBox((inset + 17, linePos + 2, 70, 14), "Apply to", sizeStyle='small', selectable=True) self.w.applyPopup = vanilla.PopUpButton( (inset + 70, linePos, 150, 17), ("ALL open fonts", "open fonts containing", "frontmost font only"), sizeStyle='small', callback=self.SavePreferences) self.w.applyContaining = vanilla.EditText( (inset + 70 + 150 + 10, linePos, -inset, 19), "", callback=self.SavePreferences, sizeStyle='small', placeholder="enter part of family name here") self.w.applyContaining.getNSTextField().setToolTip_( "Only applies the settings to fonts that contain this in Font Info > Font > Family Name." ) linePos += lineHeight self.w.resetButton = vanilla.Button((inset, -20 - inset, 80, -inset), "Reset", sizeStyle='regular', callback=self.updateUI) # Run Button: self.w.runButton = vanilla.Button( (-120 - inset, -20 - inset, -inset, -inset), "Set Names", sizeStyle='regular', callback=self.ProductionNamerMain) self.w.setDefaultButton(self.w.runButton) # Load Settings: if not self.LoadPreferences(): print( "Note: 'Production Namer' could not load preferences. Will resort to defaults" ) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): self.w = vanilla.Window((0, 0)) columnDescriptions = [ dict(columnPlacement="trailing"), dict(width=300, columnPlacement="fill") ] self.editText = vanilla.EditText("auto", "Type to test callback.", callback=self.editTextCallback) rows = [ (vanilla.TextBox("auto", "TextBox:"), vanilla.TextBox("auto", "Hello")), (vanilla.TextBox("auto", "EditText:"), self.editText), (vanilla.TextBox("auto", "Button:"), vanilla.Button("auto", "Button")), (vanilla.TextBox("auto", "PopUpButton:"), vanilla.PopUpButton("auto", ["PopUpButton"])), (vanilla.TextBox("auto", "ComboBox:"), vanilla.ComboBox("auto", ["ComboBox"])), (vanilla.TextBox("auto", "CheckBox:"), vanilla.CheckBox("auto", "CheckBox 1")), dict(rowPadding=(0, 0), cells=(None, vanilla.CheckBox("auto", "CheckBox 2"))), dict(rowPadding=(0, 0), cells=(None, vanilla.CheckBox("auto", "CheckBox 3"))), (vanilla.TextBox("auto", "SegmentedButton:"), vanilla.SegmentedButton( "auto", [dict(title="One"), dict(title="Two"), dict(title="Three")], sizeStyle="regular")), (vanilla.TextBox("auto", "Slider:"), vanilla.Slider("auto", minValue=0, maxValue=100, value=50)), dict(height=100, cells=(vanilla.TextBox("auto", "RadioGroup:"), dict(rowAlignment="none", view=vanilla.RadioGroup( "auto", ["One", "Two", "Three"])))), dict(height=100, cells=(vanilla.TextBox("auto", "ColorWell:"), dict(width=50, height=75, view=vanilla.ColorWell( "auto", color=AppKit.NSColor.redColor())))), dict(height=100, cells=(vanilla.TextBox("auto", "List:"), dict(columnPlacement="fill", rowPlacement="fill", view=vanilla.List("auto", ["One", "Two", "Three"])))), dict(height=100, cells=(vanilla.TextBox("auto", "TextEditor:"), vanilla.TextEditor("auto", "TextEditor"))), dict(height=100, cells=(vanilla.TextBox("auto", "Box:"), vanilla.Box("auto", fillColor=AppKit.NSColor.blueColor(), cornerRadius=20))), ] self.w.gridView = vanilla.GridView( "auto", rows, columnDescriptions=columnDescriptions, columnWidth=150, columnSpacing=10, rowHeight=25, rowPadding=(15, 0)) self.columnCount = len(columnDescriptions) self.rowCount = len(rows) # append, insert, etc. buttons self.appendColumnButton = vanilla.Button( "auto", "Append", callback=self.appendColumnButtonCallback) self.insertColumnButton = vanilla.Button( "auto", "Insert", callback=self.insertColumnButtonCallback) self.removeColumnButton = vanilla.Button( "auto", "Remove", callback=self.removeColumnButtonCallback) self.moveColumnButton = vanilla.Button( "auto", "Move", callback=self.moveColumnButtonCallback) self.showColumnButton = vanilla.Button( "auto", "Show/Hide", callback=self.showColumnButtonCallback) self.appendRowButton = vanilla.Button( "auto", "Append", callback=self.appendRowButtonCallback) self.insertRowButton = vanilla.Button( "auto", "Insert", callback=self.insertRowButtonCallback) self.removeRowButton = vanilla.Button( "auto", "Remove", callback=self.removeRowButtonCallback) self.moveRowButton = vanilla.Button( "auto", "Move", callback=self.moveRowButtonCallback) self.showRowButton = vanilla.Button( "auto", "Show/Hide", callback=self.showRowButtonCallback) rows = [[ vanilla.TextBox("auto", "Column:"), self.appendColumnButton, self.insertColumnButton, self.removeColumnButton, self.moveColumnButton, self.showColumnButton ], [ vanilla.TextBox("auto", "Row:"), self.appendRowButton, self.insertRowButton, self.removeRowButton, self.moveRowButton, self.showRowButton ]] columnDescriptions = [dict(width=60, columnPlacement="trailing")] for i in range(len(rows[0]) - 1): columnDescriptions.append({}) self.w.line = vanilla.HorizontalLine("auto") self.w.testButtonGrid = vanilla.GridView( "auto", rows, columnDescriptions=columnDescriptions, columnWidth=100, columnSpacing=5, columnPlacement="fill", rowHeight=25) rules = [ "H:|-margin-[gridView]-margin-|", "H:|[line]|", "H:|-margin-[testButtonGrid]-margin-|", "V:|" "-margin-" "[gridView]" "-margin-" "[line]" "-margin-" "[testButtonGrid]" "-margin-" "|" ] metrics = dict(margin=15) self.w.addAutoPosSizeRules(rules, metrics) self.w.open()
def __init__(self): # Window 'self.w': windowWidth = 380 windowHeight = 160 windowWidthResize = 500 # user can resize width by this value windowHeightResize = 600 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Axis Mapper", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.mekkablue.AxisMapper.mainwindow" # stores last window position and size ) # UI elements: linePos, inset, lineHeight = 4, 10, 22 self.w.descriptionText = vanilla.TextBox( (inset, linePos + 2, -inset, 14), "Axis Mapping from user-visible (not native) values:", sizeStyle='small', selectable=True) linePos += lineHeight self.w.axisPicker = vanilla.ComboBox((inset, linePos - 1, 60, 20), self.AxisListForFrontmostFont(), callback=self.SavePreferences, sizeStyle='small') self.w.axisPicker.getNSComboBox().setToolTip_( "Pick or type the 4-letter tag of the axis for which you want to edit the mapping." ) self.w.axisReset = vanilla.SquareButton((inset + 65, linePos, 20, 18), "↺", sizeStyle='small', callback=self.resetAxisList) self.w.axisReset.getNSButton().setToolTip_( "Will populate the axis picker with the tags for all axes in the frontmost font." ) self.w.minText = vanilla.TextBox((inset + 100, linePos + 2, 55, 14), "Axis Min:", sizeStyle='small', selectable=True) self.w.minValue = vanilla.EditText( (inset + 100 + 55, linePos - 1, 40, 19), self.MinimumForCurrentAxis(), callback=self.SavePreferences, sizeStyle='small') tooltipText = "User-visible slider minimum, typically set with an Axis Location parameter. Not (necessarily) the native master value." self.w.minText.getNSTextField().setToolTip_(tooltipText) self.w.minValue.getNSTextField().setToolTip_(tooltipText) self.w.minValueReset = vanilla.SquareButton( (inset + 100 + 60 + 40, linePos, 20, 18), "↺", sizeStyle='small', callback=self.resetMinimum) self.w.minValueReset.getNSButton().setToolTip_( "Will attempt to guess the user-visible slider minimum of the frontmost font." ) self.w.maxText = vanilla.TextBox((inset + 230, linePos + 2, 55, 14), "Axis Max:", sizeStyle='small', selectable=True) self.w.maxValue = vanilla.EditText( (inset + 230 + 55, linePos - 1, 40, 19), self.MaximumForCurrentAxis(), callback=self.SavePreferences, sizeStyle='small') tooltipText = "User-visible slider maximum, typically set with an Axis Location parameter. Not (necessarily) the native master value." self.w.maxText.getNSTextField().setToolTip_(tooltipText) self.w.maxValue.getNSTextField().setToolTip_(tooltipText) self.w.maxValueReset = vanilla.SquareButton( (inset + 230 + 60 + 40, linePos, 20, 18), "↺", sizeStyle='small', callback=self.resetMaximum) self.w.maxValueReset.getNSButton().setToolTip_( "Will attempt to guess the user-visible slider maximum of the frontmost font." ) linePos += lineHeight self.w.mappingRecipe = vanilla.TextEditor( (0, linePos, -0, -20 - inset * 2), text=fallbackText.strip(), callback=self.SavePreferences, checksSpelling=False) legibleFont = NSFont.legibileFontOfSize_(NSFont.systemFontSize()) textView = self.w.mappingRecipe.getNSTextView() textView.setFont_(legibleFont) # Buttons: self.w.recipeButton = vanilla.Button((inset, -20 - inset, 120, -inset), "Reset Recipe", sizeStyle='regular', callback=self.ResetRecipe) self.w.recipeButton.getNSButton().setToolTip_( "Construct a fallback axis mapping recipe for axis and the min/max values above, based on the existing active instances. Can be a good start for creating new mappings. Respects the weightClass settings for the 'wght' axis." ) self.w.extractButton = vanilla.Button( (inset + 130, -20 - inset, 120, -inset), "Extract Recipe", sizeStyle='regular', callback=self.ExtractAxisMapping) self.w.extractButton.getNSButton().setToolTip_( "Extract the axis mapping recipe for the chosen axis from an existing Axis Mappings parameter, and into the min/max values specified above. Will do nothing if it fails. Great for editing existing mappings." ) self.w.runButton = vanilla.Button( (-80 - inset, -20 - inset, -inset, -inset), "Map", sizeStyle='regular', callback=self.AxisMapperMain) self.w.runButton.getNSButton().setToolTip_( "Write the current mapping recipe into an Axis Mappings parameter for the frontmost font." ) self.w.setDefaultButton(self.w.runButton) # Load Settings: if not self.LoadPreferences(): print( "Note: 'Axis Mapper' could not load preferences. Will resort to defaults" ) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): if Font is None: Message("No font selected", "Select a font project!") return self.font = Font self.prefs = {} self.defaults = [ "n n", # LC "v n", "n o", "o n", "n a", "i n", "n u", "l n", "r n", "l H", # LC/UC "H o", "H n", "H s", "H x", "H H", "H O", "H T", "H V", "E H", "one zero", # numbers "one one", "one two", "one three", "one four", "one n", # numbers/LC/UC "one H", "d exclam", # LC/spaced-off "d colon", "one comma", "d period", "H ampersand", "n at", "d hyphen", "d endash", # dashes "d underscore", "endash endash", "d quoteright", # quotes "quoteright h", "d quoteleft", "quoteleft h", "guilsinglleft h", "d parenleft", # parens "pareneleft h", "bracketleft h", "h.sc h.sc", # SC "e.sc h.sc", "h.sc o.sc", "o.sc h.sc", "h.sc v.sc", "v.sc h.sc", "h.sc parenleft.sc", "parenleft.sc h.sc", "one.sc zero.sc", "one.sc one.sc", "one.sc two.sc", "one.sc three.sc", "one.sc four.sc", "one.sc comma" ] if Glyphs.defaults["com.eweracs.setKOmodels.prefs"]: for key in Glyphs.defaults["com.eweracs.setKOmodels.prefs"]: self.prefs[key] = Glyphs.defaults[ "com.eweracs.setKOmodels.prefs"][key] else: self.prefs = { "allMasters": 1, "capitalKerning": 1, "modelList": self.defaults } self.master_capital_kern_values = { master: 0 for master in self.font.masters } self.allMasters = self.prefs["allMasters"] self.capitalKerning = self.prefs["capitalKerning"] self.models = [] self.build_font_models() self.selected_master = self.font.masters[0] self.w = vanilla.FloatingWindow((0, 0), "Set base models") self.w.modelsTitle = vanilla.TextBox((10, 10, -10, 14), "Model list", sizeStyle="small") self.w.editModels = vanilla.TextEditor( (10, 32, 145, -40), text="\n".join(self.prefs["modelList"]), callback=self.edit_models) self.w.resetDefaults = vanilla.Button((10, -32, 145, 20), "Restore defaults", callback=self.restore_defaults) self.w.addCapitalSpacingCheckBox = vanilla.CheckBox( (165, 8, -10, 20), "Add capital kerning", sizeStyle="small", value=self.prefs["capitalKerning"], callback=self.toggle_capital_kerning) self.ypos = 34 for i, master in enumerate(self.font.masters): setattr( self.w, "master" + str(i), vanilla.TextBox((165, self.ypos, -60, 17), master.name, sizeStyle="regular")) setattr( self.w, "kern" + str(i), vanilla.EditText((-50, self.ypos - 1, -10, 22), text="0", callback=self.set_master_kern_value)) self.ypos += 28 self.w.kern0.selectAll() self.ypos += 70 if self.ypos <= 160: self.ypos = 160 self.w.allMasters = vanilla.CheckBox((165, -56, -10, 18), "Apply to all masters", sizeStyle="small", value=self.allMasters, callback=self.select_all_masters) self.w.setModelsButton = vanilla.Button((165, -32, -10, 20), "Set zero models", callback=self.set_models) self.toggle_master_input_fields() self.toggle_default_button() self.w.setDefaultButton(self.w.setModelsButton) self.w.resize(320, self.ypos) self.w.open() self.w.makeKey()