def __init__(self, dimensions, applicant_roster, font_family_id, after_approve=None): super(ApplicantList, self).__init__(dimensions) _, _, width, height = self.getPosSize() self.applicant_roster = applicant_roster self.family_id = font_family_id self.after_approve = after_approve self.border = DashedRectangle((0, 0, width, height)) self.enable_registry_button = CenteredButton(width, height, 190, 24, "Create Application Form", callback=self.enable) self.label = TextBox((0, 0, -0, 22), "Applicants", sizeStyle="small") self.list = List((0, 23, 0, -34), [], columnDescriptions=self.columns) self.approve_applicant_button = Button((0, -24, 90, 24), "Approve", callback=self.approve_applicant) self.open_registration_page_button = Button( (-150, -20, 150, 17), "Open Application Form", callback=self.open_registration_page, sizeStyle="small") self.enabled = self.applicant_roster is not None
def __init__(self): self.searchResults = [] self.selectedChars = "" self.w = FloatingWindow((300, 400), "Unicode Picker", minSize=(250, 300), autosaveName="UnicodePicker") y = 15 self.w.searchField = EditText((20, y, -20, 25), placeholder="Search Unicode name or value", callback=self.searchTextChanged_) y += 40 columnDescriptions = [ dict(title="char", width=40, cell=makeTextCell(align="center", font=AppKit.NSFont.systemFontOfSize_(14))), dict(title="unicode", width=60, cell=makeTextCell(align="right")), dict(title="name"), ] self.w.unicodeList = List((0, y, 0, -100), [], columnDescriptions=columnDescriptions, rowHeight=18, selectionCallback=self.listSelectionChanged_, doubleClickCallback=self.listDoubleClickCallback_) y = -95 self.w.unicodeText = TextBox((20, y, -10, 55), "") self.w.unicodeText._nsObject.cell().setFont_(AppKit.NSFont.systemFontOfSize_(36)) self.w.unicodeText._nsObject.cell().setLineBreakMode_(AppKit.NSLineBreakByTruncatingMiddle) y += 55 self.w.copyButton = Button((20, y, 120, 25), "Copy", callback=self.copy_) self.w.copyButton.enable(False) self.w.open() self.w._window.setWindowController_(self) self.w._window.setBecomesKeyOnlyIfNeeded_(False) self.w._window.makeKeyWindow()
def __init__(self): self.w = FloatingWindow((246, 300), "CodeColors") x = y = p = 10 self.w.colorThemesList = List((x, y, -p, -p), sorted(self.colorThemes.keys()), selectionCallback=self.selectionCallback, allowsMultipleSelection=False, allowsEmptySelection=False) self.w.open()
def __init__(self, posSize, callback): super(WordListController, self).__init__(posSize) x, y, self.ctrlWidth, self.ctrlHeight = posSize self.callback = callback # handling kerning words self.kerningWordsDB = loadKerningTexts(STANDARD_KERNING_TEXT_FOLDER) self.kerningTextBaseNames = self.kerningWordsDB.keys() self.activeKerningTextBaseName = self.kerningTextBaseNames[0] # this is the list used for data manipulation self.wordsWorkingList = self.kerningWordsDB[self.activeKerningTextBaseName] # this list instead is used for data visualization in the ctrl self._makeWordsDisplayList(self.activeKerningTextBaseName) self.activeWord = self.wordsWorkingList[0]['word'] self.wordFilter = '' jumping_Y = 0 self.kerningVocabularyPopUp = PopUpButton((0, jumping_Y, self.ctrlWidth*.6, vanillaControlsSize['PopUpButtonRegularHeight']), self.kerningTextBaseNames, callback=self.kerningVocabularyPopUpCallback) self.openTextsFolderButton = SquareButton((self.ctrlWidth*.62, jumping_Y, self.ctrlWidth*.38, vanillaControlsSize['PopUpButtonRegularHeight']+1), 'Load texts...', sizeStyle='small', callback=self.openTextsFolderButtonCallback) wordsColumnDescriptors = [ {'title': '#', 'width': 30, 'editable': False}, {'title': 'word', 'width': self.ctrlWidth-80, 'editable': False}, {'title': 'done?', 'width': 35, 'cell': CheckBoxListCell(), 'editable': False}] jumping_Y += self.openTextsFolderButton.getPosSize()[3] + MARGIN_VER self.wordsListCtrl = List((0, jumping_Y, self.ctrlWidth, 170), self.wordsDisplayList, enableDelete=False, allowsMultipleSelection=False, columnDescriptions=wordsColumnDescriptors, selectionCallback=self.wordsListCtrlSelectionCallback, doubleClickCallback=self.wordsListCtrlDoubleClickCallback) jumping_Y += self.wordsListCtrl.getPosSize()[3] + MARGIN_VER self.wordsFilterCtrl = EditText((-70, jumping_Y-1, 70, vanillaControlsSize['EditTextRegularHeight']), placeholder='filter...', callback=self.wordsFilterCtrlCallback) self.wordsDone = len([row['done?'] for row in self.wordsWorkingList if row['done?'] != 0]) self.infoCaption = TextBox((0, jumping_Y+2, self.ctrlWidth-self.wordsFilterCtrl.getPosSize()[2], vanillaControlsSize['TextBoxRegularHeight']), 'done: {:d}/{:d}'.format(self.wordsDone, len(self.wordsWorkingList))) jumping_Y += self.wordsFilterCtrl.getPosSize()[3] + MARGIN_VER self.loadStatus = SquareButton((0, jumping_Y, 90, vanillaControlsSize['ButtonRegularHeight']+2), 'Load status', callback=self.loadStatusCallback) self.saveButton = SquareButton((-90, jumping_Y, 90, vanillaControlsSize['ButtonRegularHeight']+2), 'Save status', callback=self.saveButtonCallback)
def __init__(self, posSize, sender=None, blenderMode=None, key=None, value=None, idx=0): super().__init__(posSize) self._setupView(self.nsViewClass, posSize) self.sender, self.key, self.value, self.idx = sender, key, value, idx if self.idx > 0: self.separator = HorizontalLine((0, 0, -0, 1)) self.help = HelpButton((0, 10, 21, 20), callback=self._helpCallback) try: docstring[self.key] except: self.help.enable(False) description = TextBox((60, 10, -0, 20), str(self.key)) if isinstance(value, dict): self.description = description # TODO: Recursive evaluation of nested dicts pass elif isinstance(self.value, str) or (isinstance(value, int) and not isinstance(value, bool)): self.description = description self.edit = EditText((10, 40, -0, 20), text=self.value, callback=self._dummyCallback) self.resize(self.getPosSize()[2], 80) elif isinstance(self.value, bool): self.check = CheckBox((60, 10, -0, 20), key, callback=self._dummyCallback, value=self.value) self.resize(self.getPosSize()[2], 40) elif isinstance(self.value, list): values = self.getValues(self.value) self.description = description self.list = List((10, 40, -0, 80), items=self.value, columnDescriptions=None, showColumnTitles=False, allowsEmptySelection=False, allowsMultipleSelection=False, autohidesScrollers=True, drawFocusRing=False) self.list._nsObject.setBorderType_(NSNoBorder) self.resize(self.getPosSize()[2], 120)
def selectDesignspaceCallback(self, sender): selection = sender.getSelection() designSpaces = self.designspaces.list.get() # delete current list posSize = self.sources.list.getPosSize() del self.sources.list # list of sources is empty if not selection or not len(designSpaces): items = [] self.sources.list = List(posSize, []) return # get sources from selected designspace designSpaceLabel = [D for i, D in enumerate(designSpaces) if i in selection][0] designSpacePath = self._designspaces[designSpaceLabel] designSpace = DesignSpaceDocument() designSpace.read(designSpacePath) # get column descriptions titles = ['name'] titles += [axis.name for axis in designSpace.axes] descriptions = [{"title": D} for D in titles] # make list items self._sources = {} items = [] for source in designSpace.sources: sourceName = os.path.splitext(os.path.split(source.path)[-1])[0] self._sources[sourceName] = source.path item = { 'name' : sourceName } for axis in designSpace.axes: item[axis.name] = source.location[axis.name] items.append(item) # create list UI with items self.sources.list = List( posSize, items, columnDescriptions=descriptions, allowsMultipleSelection=True, enableDelete=False)
def __init__(self): self.glyph = None # Typical RoboFont function self.updating = False pad = 10 leading = 32 y = pad w = 500 h = 500 c1 = 150 c2 = 200 bh = 24 # Button height leading = bh + pad / 2 self.w = Window((100, 100, w, h), 'Final tool window', minSize=(w, h)) self.w.fontList = List((pad, pad, c2, -w / 2), [], doubleClickCallback=self.openFontCallback, selectionCallback=self.update) y = pad self.w.fixTabWidths = Button((-c1 - pad, y, c1, bh), 'Fix tab widths', callback=self.fixTabWidthsCallback) self.w.fixTabWidths.enable(False) y += leading self.w.fixNegativeWidths = Button( (-c1 - pad, y, c1, bh), 'Fix negative widths', callback=self.fixNegativeWidthsCallback) self.w.fixNegativeWidths.enable(False) y += leading self.w.fixMissingComponentsWidths = Button( (-c1 - pad, y, c1, bh), 'Fix missing components', callback=self.fixMissingComponentCallback) self.w.fixMissingComponentsWidths.enable(False) self.w.selectFolder = Button((-c1 - pad, -pad - bh, c1, bh), 'Select fonts', callback=self.selectFontFolder) self.w.canvas = Canvas((pad, -w / 2 - pad, -pad, -w / 4), delegate=self) self.w.report = EditText((pad, -w / 4 + pad, -pad, -pad), readOnly=False) self.w.bind('close', self.windowCloseCallback) self.w.open() self.dirPath = self.selectFontFolder()
def initUI(self): self.prevSelection = [0] w, h = self.minSize self.w = HUDFloatingWindow((0, 0, w, h),self.windowTitle,minSize=self.minSize,autosaveName=key) self.w.getNSWindow().setHasShadow_(False) columnInfo = [ dict(title='icon', cell=ImageListCell(), width=self.rowHeight+self.rowHeight/8), dict(title='tool', cell=VerticallyCenteredTextFieldCell('mini'), editable=False), dict(title='active', cell=CheckBoxListCell(), editable=True, width=17), ] self.w.palette = Group((0,0,-0,-0)) self.w.palette.list = List((0,0,-0,-66),[], columnDescriptions=columnInfo, rowHeight=self.rowHeight, selectionCallback=self.selectionCallback,showColumnTitles=False, allowsEmptySelection=True, allowsMultipleSelection=False, drawHorizontalLines=True,drawFocusRing=True,editCallback=self.listChangedCallback)#,dragSettings=dict(type=toolOrderDragType, callback=self.dragCallback), selfDropSettings=dict(type=toolOrderDragType, operation=NSDragOperationMove, callback=self.dropListSelfCallback)) self.selectionCallback(self.w.palette.list) self.w.palette.openSettings = GradientButton((5,-66+5,-5,-5),imageNamed=NSImageNameActionTemplate,sizeStyle='mini',callback=self.openSettingsCallback) self.w.settings = Group((-self.settingsWidth,0,self.settingsWidth,-0)) columnInfo = [ dict(title='hotkey', editable=True), dict(title='modifier',cell=PopUpButtonListCell(self.modifiers), binding="selectedValue") ] self.w.settings.list = List((5,0,-0,-66),[], columnDescriptions=columnInfo, rowHeight=self.rowHeight, showColumnTitles=False, allowsEmptySelection=True, allowsMultipleSelection=False, drawVerticalLines=True, drawFocusRing=True,editCallback=self.hotkeyEditCallback) self.w.settings.hideToolbar = CheckBox((5,-66+5,-5,15),'hide toolbar',sizeStyle='mini', callback=self.hideToolbarCallback,value=self.hideToolbar) # self.w.settings.sortDefaulr = SquareButton((self.settingsWidth/2+2.5,-66+5,-5,15),'sort default bar',sizeStyle='mini',callback=self.sortDefaultToolsCallback) self.w.settings.showOnLaunchChB = CheckBox((5,-44+5,-5,15),'show on launch',sizeStyle='mini', callback=self.showOnLaunchCallback,value=self.showOnLaunch) self.w.settings.exportBtn = SquareButton((5,-22+2,self.settingsWidth/2-5-2.5,15),'export prefs',sizeStyle='mini',callback=self.exportImportCallback) self.w.settings.importBtn = SquareButton((self.settingsWidth/2+2.5,-22+2,-5,15),'import prefs',sizeStyle='mini',callback=self.exportImportCallback) self.w.settings.show(False) self.hideToolbarCallback(self.w.settings.hideToolbar) self._rebuildToolPalette() self.w.palette.list.setSelection(self.prevSelection) self.w.bind('close', self.windowClose) self.w.bind('resize', self.windowResize) self.windowResize(self.w) self.w.open()
def __init__(self): self.font_order = [] self.position = "left" L = 0 # left T = 0 # top W = 200 # width H = 300 # height p = 10 # padding buttonHeight = 20 title = "☎️ Hotline Glyph" self.w = Window((W, H), title, minSize=(W/3, H/3)) self.w.fileList = List( (L, T, -0, -(p * 3 + buttonHeight * 2)), self.font_order, columnDescriptions=[ {"title": "✓", "width":20}, {"title": "File name"}, ], # files showColumnTitles=False, allowsMultipleSelection=True, enableDelete=True, otherApplicationDropSettings = dict( type=NSFilenamesPboardType, operation=NSDragOperationCopy, callback=self.dropCallback), dragSettings=dict(type="RangeType", callback=self.font_list_drag_callback), selfDropSettings=dict(type="RangeType", operation=NSDragOperationMove, callback=self.font_list_drop_callback) ) self.w.editText = EditText((p, -(p * 2 + buttonHeight * 2), -p, buttonHeight)) self.w.draw = CheckBox((p, -(p + buttonHeight), -p, buttonHeight), 'show', value=True, callback=self.updateViewCallback) self.w.toLeftbutton = SquareButton((-p*6, -(p + buttonHeight), p*2, buttonHeight), "←", sizeStyle='small', callback=self.toLeft) self.w.toRightbutton = SquareButton((-p*3, -(p + buttonHeight), p*2, buttonHeight), "➝", sizeStyle='small', callback=self.toRight) addObserver(self, "drawPreviewRef", "drawBackground") addObserver(self, "drawRef", "drawPreview") self.setUpBaseWindowBehavior() # Needed for the windowCloseCallback self.w.open()
def __init__(self, font): self.font = font self.recipients = FontRecipients(self.font) if 'pm.ghostlines.ghostlines.registry_token' in self.font.lib: self.roster_token = self.font.lib[ 'pm.ghostlines.ghostlines.registry_token'] else: self.roster_token = None self.window.content = Group((15, 15, -15, -15)) self.window.content.font_name_label = TextBox((0, 0, -0, 22), "Font Name", sizeStyle="small") self.window.content.font_name = TextBox((0, 19, -0, 22), self.font.info.familyName) self.window.content.font_author_label = TextBox((0, 55, -0, 22), "Designer", sizeStyle="small") self.window.content.font_author = TextBox( (0, 74, -0, 22), self.font.info.openTypeNameDesigner) self.window.content.recipients_label = TextBox((0, 114, -15, 22), "Subscribers", sizeStyle="small") self.window.content.recipients = List((0, 135, -0, 190), self.recipients, drawFocusRing=False, allowsEmptySelection=True) self.window.content.recipients.setSelection([]) self.window.content.roster_label = TextBox((0, 350, -15, 22), "Application Page", sizeStyle="small") self.window.content.roster_status = TextBox((0, 370, -15, 22), self.roster_status) self.window.content.confirmation_button = Button((0, -24, 0, 24), "Complete Migration", callback=self.migrate) self.window.content.explainer = TextBox( (0, 405, -15, 66), "A new font entry will be created on Ghostlines with the details above. Any pending applicants will be retained if you have activated that feature.", sizeStyle="small") self.window.setDefaultButton(self.window.content.confirmation_button)
def __init__(self): self.filters = PenBallFiltersManager() self.filters.loadFiltersFromJSON('/'.join([LOCALPATH, JSONFILE])) self.glyphNames = [] self.observedGlyphs = [] self.cachedFont = RFont(showUI=False) self.currentFont = CurrentFont() filtersList = self.filters.keys() if len(filtersList) > 0: self.currentFilterName = filtersList[0] else: self.currentFilterName = None self.fill = True self.observers = [ ('fontChanged', 'fontBecameCurrent'), ('fontChanged', 'fontDidOpen'), ('fontChanged', 'fontDidClose'), ] self.w = Window((100, 100, 800, 500), 'PenBall Wizard v{0}'.format(__version__), minSize=(500, 400)) self.w.filtersPanel = Group((0, 0, 300, -0)) self.w.filtersPanel.filtersList = List((0, 0, -0, -40), filtersList, selectionCallback=self.filterSelectionChanged, doubleClickCallback=self.filterEdit, allowsMultipleSelection=False, allowsEmptySelection=False, rowHeight=22) self.w.filtersPanel.controls = Group((0, -40, -0, 0)) self.w.filtersPanel.addFilter = SquareButton((0, -40, 100, 40), 'Add filter', sizeStyle='small', callback=self.addFilter) self.w.filtersPanel.addFilterChain = SquareButton((100, -40, 100, 40), 'Add operations', sizeStyle='small', callback=self.addFilterChain) self.w.filtersPanel.removeFilter = SquareButton((-100, -40, 100, 40), 'Remove filter', sizeStyle='small', callback=self.removeFilter) self.w.textInput = EditText((300, 0, -90, 22), '', callback=self.stringInput) self.w.generate = SquareButton((-90, 0, 90, 22), 'Generate', callback=self.generateGlyphsToFont, sizeStyle='small') self.w.preview = MultiLineView((300, 22, -0, -0)) self.w.switchFillStroke = SquareButton((-75, -40, 60, 25), 'Stroke', callback=self.switchFillStroke, sizeStyle='small') displayStates = self.w.preview.getDisplayStates() for key in ['Show Metrics','Upside Down','Stroke','Beam','Inverse','Water Fall','Multi Line']: displayStates[key] = False for key in ['Fill','Single Line']: displayStates[key] = True self.w.preview.setDisplayStates(displayStates) for callback, event in self.observers: addObserver(self, callback, event) self.updateControls() self.w.bind('close', self.end) self.launchWindow() self.w.open()
def __init__(self, font): self._font = font if font.path: document = DoodleDocument.alloc().init() document.setFileURL_(NSURL.fileURLWithPath_(font.path)) dc = NSDocumentController.sharedDocumentController() dc.addDocument_(document) self._canUpdateChangeCount = True self.w = Window((250, 500), "SimpleFontWindow", minSize=(200, 300)) glyphs = sorted(font.keys()) self.w.glyphs = List((0, 0, -0, -0), glyphs, doubleClickCallback=self.openGlyph) toolbarItems = [ dict(itemIdentifier="spaceCenter", label="Space Center", imageNamed="toolbarSpaceCenterAlternate", callback=self.openSpaceCenter ), dict(itemIdentifier="fontInfo", label="Font Info", imageNamed="toolbarFontInfo", callback=self.openFontInfo ) ] self.w.addToolbar(toolbarIdentifier="SimpleToolbar", toolbarItems=toolbarItems) windowController = self.w.getNSWindowController() windowController.setShouldCloseDocument_(True) self._font.UIdocument().addWindowController_(windowController) self._font.addObserver(self, "fontChanged", "Font.Changed") self.setUpBaseWindowBehavior() self.w.open() self.openFirstGlyph()
def __init__(self): NSUserDefaults.standardUserDefaults().registerDefaults_({"ToucheWindowHeight":340}) self.windowHeight = NSUserDefaults.standardUserDefaults().integerForKey_("ToucheWindowHeight") self.minWindowHeight = 340 if self.windowHeight < self.minWindowHeight: self.windowHeight = self.minWindowHeight self.closedWindowHeight = 100 self.w = FloatingWindow((180, self.windowHeight), u'Touché!', minSize=(180,340), maxSize=(250,898)) self.w.bind("resize", self.windowResized) self.isResizing = False p = 10 w = 160 # options self.w.options = Group((0, 0, 180, 220)) buttons = { "checkSelBtn": {"text": "Check selected glyphs", "callback": self.checkSel, "y": p}, } for button, data in buttons.iteritems(): setattr(self.w.options, button, Button((p, data["y"], w - 22, 22), data["text"], callback=data["callback"], sizeStyle="small")) self.w.options.zeroCheck = CheckBox((p, 35, w, 20), "Ignore zero-width glyphs", value=True, sizeStyle="small") self.w.options.progress = ProgressSpinner((w - 8, 13, 16, 16), sizeStyle="small") # results self.w.results = Group((0, 220, 180, -0)) self.w.results.show(False) textBoxes = {"stats": -34, "result": -18} for box, y in textBoxes.iteritems(): setattr(self.w.results, box, TextBox((p, y, w, 14), "", sizeStyle="small")) # list and preview self.w.outputList = List((0,58,-0,-40), [{"left glyph": "", "right glyph": ""}], columnDescriptions=[{"title": "left glyph", "width": 90}, {"title": "right glyph"}], showColumnTitles=False, allowsMultipleSelection=False, enableDelete=False, selectionCallback=self.showPair) self.w.outputList._setColumnAutoresizing() self._resizeWindow(False) self.w.open()
def buildFilterGroupSheet(self, filterName='', makeNew=False): subfilters = self.filters[filterName].subfilters if filterName in self.filters else [] subfilterItems = [{'filterName': subfilterName, 'mode': subfilterMode if subfilterMode is not None else '', 'source': source if source is not None else ''} for subfilterName, subfilterMode, source in subfilters] self.filterSheet = Sheet((0, 0, 400, 350), self.w) self.filterSheet.new = makeNew self.filterSheet.index = self.filters[filterName].index if not makeNew else -1 applyTitle = 'Add Operation' if filterName == '' else 'Update Operation' self.filterSheet.apply = SquareButton((-145, -37, 130, 22), applyTitle, callback=self.processFilterGroup, sizeStyle='small') self.filterSheet.cancel = SquareButton((-210, -37, 60, 22), 'Cancel', callback=self.closeFilterSheet, sizeStyle='small') y = 20 self.filterSheet.nameTitle = TextBox((15, y, 100, 22), 'Filter Name') self.filterSheet.name = EditText((125, y, -15, 22), filterName) y += 22 columns = [ {'title': 'filterName', 'editable': True, 'width': 140}, {'title': 'mode', 'editable': True, 'width': 89}, {'title': 'source', 'editable': True, 'width': 100} ] buttonSize = 20 gutter = 7 y += 20 self.filterSheet.subfilters = List((15 + buttonSize + gutter, y, -15, -52), subfilterItems, columnDescriptions=columns, allowsMultipleSelection=False, allowsEmptySelection=False) self.filterSheet.addSubfilter = SquareButton((15, -52-(buttonSize*2)-gutter, buttonSize, buttonSize), '+', sizeStyle='small', callback=self.addSubfilter) self.filterSheet.removeSubfilter = SquareButton((15, -52-buttonSize, buttonSize, buttonSize), '-', sizeStyle='small', callback=self.removeSubfilter) if len(subfilters) == 0: self.filterSheet.removeSubfilter.enable(False) y += 75 self.filterSheet.moveSubfilterUp = SquareButton((15, y, buttonSize, buttonSize), u'⇡', sizeStyle='small', callback=self.moveSubfilterUp) self.filterSheet.moveSubfilterDown = SquareButton((15, y + buttonSize + gutter, buttonSize, buttonSize), u'⇣', sizeStyle='small', callback=self.moveSubfilterDown) if filterName == '': self.currentFilterName = ''
def __init__(self, dimensions, font, applicants, recipients, after_approve=None): super(ApplicantList, self).__init__(dimensions) _, _, width, height = self.getPosSize() self.recipients = recipients self.applicants = applicants self.font = font self.after_approve = after_approve self.border = DashedRectangle((0, 0, width, height)) self.activate_registry_button = CenteredButton( width, height, 190, 24, "Create Application Form", callback=self.activate) self.label = TextBox((0, 0, -0, 22), "Applicants") self.list = List((0, 23, 0, -34), applicants) self.approve_applicant_button = Button((0, -24, 90, 24), "Approve", callback=self.approve_applicant) self.open_registration_page_button = Button( (-150, -20, 150, 17), "Open Application Form", callback=self.open_registration_page, sizeStyle="small") self.activated = font.lib.has_key( 'pm.ghostlines.ghostlines.registry_token')
def __init__(self): super(CornersRounder, self).__init__() self._initLogger() self.rounderLogger.info('we are on air! start: __init__()') self._updateFontsAttributes() if self.allFonts != []: self.selectedFont = self.allFonts[0] self._initRoundingsData() if self.selectedFont is not None: self.layerNames = ['foreground'] + self.selectedFont.layerOrder self.sourceLayerName = self.layerNames[0] self.targetLayerName = self.layerNames[0] if PLUGIN_LIB_NAME in self.selectedFont.lib: self.roundingsData = pullRoundingsDataFromFont( self.selectedFont) self.w = Window((0, 0, PLUGIN_WIDTH, PLUGIN_HEIGHT), PLUGIN_TITLE) jumpingY = MARGIN_VER self.w.fontPopUp = PopUpButton( (MARGIN_HOR, jumpingY, NET_WIDTH, vanillaControlsSize['PopUpButtonRegularHeight']), [os.path.basename(item.path) for item in self.allFonts], callback=self.fontPopUpCallback) jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_VER self.w.sepLineOne = HorizontalLine( (MARGIN_HOR, jumpingY, NET_WIDTH, vanillaControlsSize['HorizontalLineThickness'])) jumpingY += MARGIN_VER for eachI in range(LABELS_AMOUNT): singleLabel = Label((MARGIN_HOR, jumpingY, NET_WIDTH, vanillaControlsSize['EditTextRegularHeight']), attachCallback=self.attachCallback, labelName='') setattr(self.w, 'label{:d}'.format(eachI), singleLabel) jumpingY += MARGIN_ROW + vanillaControlsSize[ 'EditTextRegularHeight'] self._fromRoundingsData2LabelCtrls() jumpingY += MARGIN_ROW self.w.sepLineTwo = HorizontalLine( (MARGIN_HOR, jumpingY, NET_WIDTH, vanillaControlsSize['HorizontalLineThickness'])) jumpingY += MARGIN_ROW * 2 # tables labelListWdt = 78 marginTable = 1 angleListWdt = (NET_WIDTH - labelListWdt - marginTable * 3) // 3 tableLineHeight = 16 tableHgt = LABELS_AMOUNT * tableLineHeight + 33 captionY = jumpingY captionOffset = 12 jumpingY += vanillaControlsSize['TextBoxSmallHeight'] + MARGIN_ROW labelColumnDesc = [{"title": "labelName", 'editable': True}] jumpingX = MARGIN_HOR self.w.labelNameList = List( (jumpingX, jumpingY, labelListWdt, tableHgt), [], columnDescriptions=labelColumnDesc, showColumnTitles=True, editCallback=self.labelNameListCallback, rowHeight=tableLineHeight, drawHorizontalLines=True, drawVerticalLines=True, autohidesScrollers=True, allowsMultipleSelection=False) anglesColumnDesc = [{ "title": "rad", 'editable': True }, { "title": "bcp", 'editable': True }] jumpingX += labelListWdt + marginTable self.w.fortyFiveCaption = TextBox( (jumpingX + captionOffset, captionY, angleListWdt, vanillaControlsSize['TextBoxSmallHeight']), u'45°', sizeStyle='small') self.w.fortyFiveList = List( (jumpingX, jumpingY, angleListWdt, tableHgt), [], columnDescriptions=anglesColumnDesc, showColumnTitles=True, rowHeight=tableLineHeight, editCallback=self.fortyFiveListCallback, drawHorizontalLines=True, drawVerticalLines=True, autohidesScrollers=True, allowsMultipleSelection=False) jumpingX += angleListWdt + marginTable self.w.ninetyCaption = TextBox( (jumpingX + captionOffset, captionY, angleListWdt, vanillaControlsSize['TextBoxSmallHeight']), u'90°', sizeStyle='small') self.w.ninetyList = List((jumpingX, jumpingY, angleListWdt, tableHgt), [], columnDescriptions=anglesColumnDesc, showColumnTitles=True, rowHeight=tableLineHeight, editCallback=self.ninetyListCallback, drawHorizontalLines=True, drawVerticalLines=True, autohidesScrollers=True, allowsMultipleSelection=False) jumpingX += angleListWdt + marginTable self.w.hundredThirtyFiveCaption = TextBox( (jumpingX + captionOffset, captionY, angleListWdt, vanillaControlsSize['TextBoxSmallHeight']), u'135°', sizeStyle='small') self.w.hundredThirtyFiveList = List( (jumpingX, jumpingY, angleListWdt, tableHgt), [], columnDescriptions=anglesColumnDesc, showColumnTitles=True, rowHeight=tableLineHeight, editCallback=self.hundredThirtyFiveListCallback, drawHorizontalLines=True, drawVerticalLines=True, autohidesScrollers=True, allowsMultipleSelection=False) self._fromRoundingsData2Lists() jumpingY += tableHgt + MARGIN_ROW * 2 rgtX = MARGIN_HOR + NET_WIDTH * .52 midWdt = NET_WIDTH * .48 self.w.pushButton = SquareButton( (MARGIN_HOR, jumpingY, midWdt, vanillaControlsSize['ButtonRegularHeight'] * 1.5), 'Push Data', callback=self.pushButtonCallback) self.w.clearLibButton = SquareButton( (rgtX, jumpingY, midWdt, vanillaControlsSize['ButtonRegularHeight'] * 1.5), 'Clear Lib', callback=self.clearLibButtonCallback) jumpingY += vanillaControlsSize[ 'ButtonRegularHeight'] * 1.5 + MARGIN_ROW * 2 self.w.sepLineThree = HorizontalLine( (MARGIN_HOR, jumpingY, NET_WIDTH, vanillaControlsSize['HorizontalLineThickness'])) jumpingY += MARGIN_ROW * 2 self.w.sourceLayerCaption = TextBox( (MARGIN_HOR, jumpingY, midWdt, vanillaControlsSize['TextBoxRegularHeight']), 'source layer') self.w.targetLayerCaption = TextBox( (rgtX, jumpingY, midWdt, vanillaControlsSize['TextBoxRegularHeight']), 'target layer') jumpingY += vanillaControlsSize['TextBoxRegularHeight'] + MARGIN_ROW self.w.sourceLayerPopUp = PopUpButton( (MARGIN_HOR, jumpingY, midWdt, vanillaControlsSize['PopUpButtonRegularHeight']), self.layerNames, callback=self.sourceLayerPopUpCallback) if self.layerNames and self.sourceLayerName: self.w.sourceLayerPopUp.set( self.layerNames.index(self.sourceLayerName)) self.w.targetLayerCombo = ComboBox( (rgtX, jumpingY, midWdt, vanillaControlsSize['PopUpButtonRegularHeight']), self.layerNames, callback=self.targetLayerComboCallback) if self.layerNames and self.targetLayerName: self.w.targetLayerCombo.set(self.targetLayerName) jumpingY += vanillaControlsSize[ 'PopUpButtonRegularHeight'] + MARGIN_ROW * 4 self.w.roundGlyphButton = SquareButton( (MARGIN_HOR, jumpingY, midWdt, vanillaControlsSize['ButtonRegularHeight'] * 1.5), u'Round Glyph (⌘+R)', callback=self.roundGlyphButtonCallback) self.w.roundGlyphButton.bind('r', ['command']) self.w.roundFontButton = SquareButton( (rgtX, jumpingY, midWdt, vanillaControlsSize['ButtonRegularHeight'] * 1.5), 'Round Font', callback=self.roundFontButtonCallback) jumpingY += vanillaControlsSize[ 'ButtonRegularHeight'] * 1.5 + MARGIN_VER * 2 self.w.resize(PLUGIN_WIDTH, jumpingY) self._checkPushButton() self._checkRoundButtons() self.setUpBaseWindowBehavior() addObserver(self, 'fontDidOpenCallback', 'fontDidOpen') addObserver(self, 'fontDidCloseCallback', 'fontDidClose') addObserver(self, '_keyDown', 'keyDown') self.w.open()
def __init__(self): # Preferences self._drawing = getExtensionDefault(self.DEFAULTKEY_DRAW, True) self._fill = getExtensionDefault(self.DEFAULTKEY_FILL, True) self._stroke = getExtensionDefault(self.DEFAULTKEY_STROKE, True) self._points = getExtensionDefault(self.DEFAULTKEY_POINTS, True) self._fillColor = getExtensionDefaultColor(self.DEFAULTKEY_FILLCOLOR, self.FALLBACK_FILLCOLOR) self._strokeColor = getExtensionDefaultColor(self.DEFAULTKEY_STROKECOLOR, self.FALLBACK_STROKECOLOR) self._pointsColor = getExtensionDefaultColor(self.DEFAULTKEY_POINTSCOLOR, self.FALLBACK_POINTSCOLOR) self._alignment = getExtensionDefault(self.DEFAULTKEY_ALIGNMENT, 0) self._kerning = getExtensionDefault(self.DEFAULTKEY_KERNING, 1) self._floating = getExtensionDefault(self.DEFAULTKEY_FLOATING, 1) # User preferences self._onCurvePointsSize = getDefault("glyphViewOncurvePointsSize") # typo, should be: OnCurve self._offCurvePointsSize = getDefault("glyphViewOffCurvePointsSize") self._strokeWidth = getDefault("glyphViewStrokeWidth") w, h = 400, 195 x = y = 10 self.initAllFonts() self.w = FloatingWindow((w, h), "Overlay UFOs") self.w.draw = CheckBox((x, y, 95, 18), "Draw", callback=self.drawCallback, value=self._drawing, sizeStyle="small") x += 60 self.w.fill = CheckBox((x, y, 95, 18), "Fill", callback=self.fillCallback, value=self._fill, sizeStyle="small") x += 40 self.w.fillColor = ColorWell((x, y, 45, 20), callback=self.fillColorCallback, color=self._fillColor) x += 60 self.w.stroke = CheckBox((x, y, 95, 18), "Stroke", callback=self.strokeCallback, value=self._stroke, sizeStyle="small") x += 60 self.w.strokeColor = ColorWell((x, y, 45, 20), callback=self.strokeColorCallback, color=self._strokeColor) x += 60 self.w.points = CheckBox((x, y, 95, 18), "Points", callback=self.pointsCallback, value=self._points, sizeStyle="small") x += 60 self.w.pointsColor = ColorWell((x, y, 45, 20), callback=self.pointsColorCallback, color=self._pointsColor) x, y = 10, 40 self.w.alignText = TextBox((x, y, 250, 15), "Alignment:", sizeStyle="small") y += 18 self.w.alignment = RadioGroup((x, y, 80, 55), ['Left', 'Center', 'Right'], isVertical=True, callback=self.alignmentCallback, sizeStyle="small") self.w.alignment.set(self._alignment) y += 62 self.w.kerning = CheckBox((x, y, 100, 10), "Show kerning", callback=self.kerningCallback, value=self._kerning, sizeStyle="mini") y += 18 self.w.floating = CheckBox((x, y, 100, 10), "Floating Window", callback=self.floatingCallback, value=self._floating, sizeStyle="mini") y += 25 self.w.resetDefaults = Button((x, y, 85, 14), "Reset settings", callback=self.resetSettingsCallback, sizeStyle="mini") x, y = 110, 40 self.w.fontList = List((x, y, 240, 55), self.getFontItems(), columnDescriptions=self.getListDescriptor(), showColumnTitles=False, selectionCallback=None, doubleClickCallback=self.fontListCallback, allowsMultipleSelection=True, allowsEmptySelection=True, drawVerticalLines=False, drawHorizontalLines=True, drawFocusRing=False, rowHeight=16 ) y += 55 self.w.hiddenFontList = List((x, y, 240, 55), self.getHiddenFontItems(), columnDescriptions=self.getListDescriptor(), showColumnTitles=False, selectionCallback=None, doubleClickCallback=self.hiddenFontListCallback, allowsMultipleSelection=True, allowsEmptySelection=True, drawVerticalLines=False, drawHorizontalLines=True, drawFocusRing=False, rowHeight=16 ) self._selectionChanging = False self.w.fontList.setSelection([]) # unselect y += 65 self.w.contextLeft = EditText((x, y, 90, 20), callback=self.contextCallback, continuous=True, placeholder="Left", sizeStyle="small") self.w.contextCurrent = EditText((x+95, y, 50, 20), callback=self.contextCallback, continuous=True, placeholder="?", sizeStyle="small") self.w.contextRight = EditText((x+150, y, 90, 20), callback=self.contextCallback, continuous=True, placeholder="Right", sizeStyle="small") x, y = 360, 100 self.w.addFonts = Button((x, y, 30, 20), "+", callback=self.addHiddenFontsCallback, sizeStyle="regular") y += 25 self.w.removeFonts = Button((x, y, 30, 20), unichr(8722), callback=self.removeHiddenFontsCallback, sizeStyle="regular") # Observers addObserver(self, "fontDidOpen", "fontDidOpen") addObserver(self, "fontWillClose", "fontWillClose") # fontDidClose? addObserver(self, "draw", "drawInactive") addObserver(self, "draw", "draw") # Prepare and open window self.setWindowLevel() self.setUpBaseWindowBehavior() self.w.open()
def __init__(self): self.locations = [ 'User Agents', 'Global Agents', 'Global Daemons', 'System Agents', 'System Daemons' ] self.listItems = [] self.selected = {} # Preferences self.homedir = os.path.expanduser('~') self.prefsFolder = self.homedir + "/Library/Preferences/" self.prefsFile = "de.nelsonfritsch.unicron.plist" if os.path.isfile(self.prefsFolder + self.prefsFile): self.prefs = self._loadPrefs(self) else: self.prefs = dict(showSystemWarning=True, windowStyle='System') self._savePrefs(self) # Preferences Window self.prefsWindow = Window((300, 105), 'Preferences') self.styles = ['System', 'Light', 'Dark'] self.prefsWindow.styleTxt = TextBox((10, 10, -10, 20), "Window Style:") self.prefsWindow.style = PopUpButton((30, 35, -10, 20), self.styles, callback=self.prefsSetStyle) self.prefsWindow.restore = Button((10, 75, -10, 20), 'Restore Warnings', callback=self.prefsRestoreWarnings) # Main Window minsize = 285 self.w = Window((minsize, 400), 'Unicron', closable=True, fullSizeContentView=True, titleVisible=False, minSize=(minsize, minsize), maxSize=(600, 1200), autosaveName="UnicronMainWindow") self.pathList = NSPopUpButton.alloc().initWithFrame_( ((0, 0), (160, 20))) self.pathList.addItemsWithTitles_(self.locations) refreshIcon = NSImage.alloc().initWithSize_((32, 32)) sourceImage = NSImage.imageNamed_(NSImageNameRefreshTemplate) w, h = sourceImage.size() if w > h: diffx = 0 diffy = w - h else: diffx = h - w diffy = 0 maxSize = max([w, h]) refreshIcon.lockFocus() sourceImage.drawInRect_fromRect_operation_fraction_( NSMakeRect(diffx, diffy + 4, 22, 22), NSMakeRect(0, 0, maxSize, maxSize), NSCompositeSourceOver, 1) refreshIcon.unlockFocus() refreshIcon.setTemplate_(True) toolbarItems = [ dict(itemIdentifier="Daemons", label="Daemons", toolTip="Daemon Group", view=self.pathList, callback=self.populateList), dict(itemIdentifier="image", label="Image", imageObject=refreshIcon, callback=self.populateList), ] self.w.addToolbar("Unicron Toolbar", toolbarItems=toolbarItems, displayMode="icon") self.w.blend = Group((0, 0, 0, 0), blendingMode='behindWindow') self.listColumnDescriptions = [{ 'title': '', 'key': 'image', 'width': 25, 'typingSensitive': True, 'allowsSorting': True, 'cell': ImageListCell() }, { 'title': 'Name', 'key': 'name', 'typingSensitive': True, 'allowsSorting': True, }] self.rowHeight = 20 self.w.list = List((0, 37, -0, 0), items=self.listItems, columnDescriptions=self.listColumnDescriptions, showColumnTitles=True, allowsEmptySelection=True, allowsMultipleSelection=False, autohidesScrollers=True, drawFocusRing=False, rowHeight=self.rowHeight, selectionCallback=self._selectionCallback, menuCallback=self._menuCallback) self.w.list._nsObject.setBorderType_(NSNoBorder) self.w.statusbar = Group((0, -26, 0, 0), blendingMode='behindWindow') self.w.statusbar.border = HorizontalLine((0, 0, 0, 1)) self.w.counter = TextBox((16, -20, -16, 15), '', alignment='center', sizeStyle='small') self.populateList(self) self.w.rowIndicator = Group((0, 0, 0, 10)) self.prefsSetStyle(self) self.w.open()
def __init__(self): self.font = CurrentFont() self.glyph = CurrentGlyph() self.upm = self.font.info.unitsPerEm self.rf3 = int(roboFontVersion.split(".")[0]) >= 3 if self.rf3: self.layer = CurrentLayer() # key: glyph name -- value: list containing assembled glyphs self.glyphPreviewCacheDict = {} # key: anchor name -- value: list of mark glyph names self.anchorsOnMarksDict = {} # key: anchor name -- value: list of base glyph names self.anchorsOnBasesDict = {} self.CXTanchorsOnBasesDict = {} # key: mark glyph name -- value: anchor name # NOTE: It's expected that each mark glyph only has one type of anchor self.marksDict = {} self.fillAnchorsAndMarksDicts() # list of glyph names that will be displayed in the UI list self.glyphNamesList = [] # list of glyph names selected in the UI list self.selectedGlyphNamesList = [] # list of the glyph objects that should be inserted # before and after the accented glyphs self.extraGlyphsList = [] self.Blue, self.Alpha = 1, 0.6 self.font.naked().addObserver(self, "fontWasModified", "Font.Changed") addObserver(self, "_fontWillClose", "fontWillClose") addObserver(self, "_currentFontChanged", "fontResignCurrent") addObserver(self, "_currentGlyphChanged", "currentGlyphChanged") addObserver(self, "_drawFill", "draw") addObserver(self, "_drawFill", "drawInactive") addObserver(self, "_previewFill", "drawPreview") # observer for the draw event addObserver(self, "_drawGlyphs", "draw") # draw the glyphs when the glyph window is not in focus addObserver(self, "_drawGlyphs", "drawInactive") addObserver(self, "_drawGlyphs", "drawPreview") integerNumFormatter = NSNumberFormatter.alloc().init() integerNumFormatter.setAllowsFloats_(False) integerNumFormatter.setGeneratesDecimalNumbers_(False) intPosMinZeroNumFormatter = NSNumberFormatter.alloc().init() intPosMinZeroNumFormatter.setAllowsFloats_(False) intPosMinZeroNumFormatter.setGeneratesDecimalNumbers_(False) intPosMinZeroNumFormatter.setMinimum_(NSNumber.numberWithInt_(0)) intPosMinOneNumFormatter = NSNumberFormatter.alloc().init() intPosMinOneNumFormatter.setAllowsFloats_(False) intPosMinOneNumFormatter.setGeneratesDecimalNumbers_(False) intPosMinOneNumFormatter.setMinimum_(NSNumber.numberWithInt_(1)) self.textSize = getExtensionDefault("%s.%s" % (extensionKey, "textSize")) if not self.textSize: self.textSize = 150 self.lineHeight = getExtensionDefault("%s.%s" % (extensionKey, "lineHeight")) if not self.lineHeight: self.lineHeight = 200 self.extraSidebearings = getExtensionDefault( "%s.%s" % (extensionKey, "extraSidebearings")) if not self.extraSidebearings: self.extraSidebearings = [0, 0] self.extraGlyphs = getExtensionDefault("%s.%s" % (extensionKey, "extraGlyphs")) if not self.extraGlyphs: self.extraGlyphs = '' posSize = getExtensionDefault("%s.%s" % (extensionKey, "posSize")) if not posSize: posSize = (100, 100, 1200, 400) self.calibrateMode = getExtensionDefault( "%s.%s" % (extensionKey, "calibrateMode")) if not self.calibrateMode: self.calibrateMode = False calibrateModeStrings = getExtensionDefault( "%s.%s" % (extensionKey, "calibrateModeStrings")) if not calibrateModeStrings: calibrateModeStrings = { 'group1.baseInput': 'dotlessi o s', 'group1.markInput': 'dieresis circumflex macron breve caron', 'group2.baseInput': 'I O S', 'group2.markInput': 'dieresis.cap circumflex.cap macron.cap ' 'breve.cap caron.cap', 'group3.baseInput': 'I.sc O.sc S.sc', 'group3.markInput': 'dieresis circumflex macron breve caron', 'group4.baseInput': '', 'group4.markInput': '', } # -- Window -- self.w = FloatingWindow(posSize, extensionName, minSize=(500, 400)) self.w.fontList = List((10, 10, 190, -41), self.glyphNamesList, selectionCallback=self.listSelectionCallback) if roboFontVersion < '1.7': # use the full width of the column self.w.fontList.getNSTableView().sizeToFit() self.w.fontList.show(not self.calibrateMode) self.w.lineView = MultiLineView((210, 10, -10, -41), pointSize=self.textSize, lineHeight=self.lineHeight, displayOptions={ "Beam": False, "displayMode": "Multi Line" }) self.w.lineView.setFont(self.font) # -- Calibration Mode -- baseLabel = "Bases" markLabel = "Marks" width, height = 190, 140 self.cm = Group((0, 0, 0, 0)) # --- self.cm.group1 = Group((5, height * 0, width, height - 10)) self.cm.group1.baseLabel = TextBox((0, 0, width, 20), baseLabel) self.cm.group1.baseInput = EditText( (0, 21, width, 22), calibrateModeStrings['group1.baseInput'], callback=self.updateCalibrateMode, continuous=False) self.cm.group1.markLabel = TextBox((0, 50, width, 20), markLabel) self.cm.group1.markInput = EditText( (0, 71, width, 44), calibrateModeStrings['group1.markInput'], callback=self.updateCalibrateMode, continuous=False) self.cm.group1.divider = HorizontalLine((0, -1, -0, 1)) # --- self.cm.group2 = Group((5, height * 1, width, height - 10)) self.cm.group2.baseLabel = TextBox((0, 0, width, 20), baseLabel) self.cm.group2.baseInput = EditText( (0, 21, width, 22), calibrateModeStrings['group2.baseInput'], callback=self.updateCalibrateMode, continuous=False) self.cm.group2.markLabel = TextBox((0, 50, width, 20), markLabel) self.cm.group2.markInput = EditText( (0, 71, width, 44), calibrateModeStrings['group2.markInput'], callback=self.updateCalibrateMode, continuous=False) self.cm.group2.divider = HorizontalLine((0, -1, -0, 1)) # --- self.cm.group3 = Group((5, height * 2, width, height - 10)) self.cm.group3.baseLabel = TextBox((0, 0, width, 20), baseLabel) self.cm.group3.baseInput = EditText( (0, 21, width, 22), calibrateModeStrings['group3.baseInput'], callback=self.updateCalibrateMode, continuous=False) self.cm.group3.markLabel = TextBox((0, 50, width, 20), markLabel) self.cm.group3.markInput = EditText( (0, 71, width, 44), calibrateModeStrings['group3.markInput'], callback=self.updateCalibrateMode, continuous=False) self.cm.group3.divider = HorizontalLine((0, -1, -0, 1)) # --- self.cm.group4 = Group((5, height * 3, width, height - 10)) self.cm.group4.baseLabel = TextBox((0, 0, width, 20), baseLabel) self.cm.group4.baseInput = EditText( (0, 21, width, 22), calibrateModeStrings['group4.baseInput'], callback=self.updateCalibrateMode, continuous=False) self.cm.group4.markLabel = TextBox((0, 50, width, 20), markLabel) self.cm.group4.markInput = EditText( (0, 71, width, 44), calibrateModeStrings['group4.markInput'], callback=self.updateCalibrateMode, continuous=False) # --- view = DefconAppKitTopAnchoredNSView.alloc().init() view.addSubview_(self.cm.getNSView()) view.setFrame_(((0, 0), (width + 10, height * 4 - 23))) self.cm.setPosSize((0, 0, width + 10, height * 4 - 22)) self.w.scrollView = ScrollView((5, 10, width + 10, -41), view, drawsBackground=False, hasHorizontalScroller=False) self.w.scrollView.getNSScrollView().setBorderType_(NSNoBorder) # NSScrollElasticityNone self.w.scrollView.getNSScrollView().setVerticalScrollElasticity_(1) self.w.scrollView.show(self.calibrateMode) # -- Footer -- self.w.footer = Group((10, -32, -10, -10)) self.w.footer.calibrateModeCheck = CheckBox( (0, 0, 200, -0), "Calibration Mode", callback=self.calibrateModeCallback, value=self.calibrateMode) self.w.footer.textSizeLabel = TextBox((200, 2, 100, -0), "Text Size") self.w.footer.textSize = EditText((260, 0, 35, -0), self.textSize, callback=self.textSizeCallback, continuous=False, formatter=intPosMinOneNumFormatter) self.w.footer.lineHeightLabel = TextBox((310, 2, 100, -0), "Line Height") self.w.footer.lineHeight = EditText((385, 0, 35, -0), self.lineHeight, callback=self.lineHeightCallback, continuous=False, formatter=integerNumFormatter) self.w.footer.extraSidebearingsLabel = TextBox((436, 2, 180, -0), "Extra Sidebearings") self.w.footer.extraSidebearingsChar = TextBox((592, 2, 20, -0), "&") self.w.footer.extraSidebearingLeft = EditText( (557, 0, 35, -0), self.extraSidebearings[0], callback=self.extraSidebearingsCallback, continuous=False, formatter=intPosMinZeroNumFormatter) self.w.footer.extraSidebearingRight = EditText( (604, 0, 35, -0), self.extraSidebearings[1], callback=self.extraSidebearingsCallback, continuous=False, formatter=intPosMinZeroNumFormatter) self.w.footer.extraGlyphsLabel = TextBox((655, 2, 180, -0), "Extra Glyphs") self.w.footer.extraGlyphs = EditText((739, 0, -0, -0), self.extraGlyphs, callback=self.extraGlyphsCallback, continuous=False) # trigger the initial state and contents of the window self.extraGlyphsCallback() # calls self.updateExtensionWindow() self.w.bind("close", self.windowClose) self.w.open() self.w.makeKey()
def __init__(self): self.w = Window((180, 340), u'Touché!', minSize=(180, 340), maxSize=(1000, 898)) p = 10 w = 160 # options self.w.options = Group((0, 0, 180, 220)) buttons = { "checkSelBtn": { "text": "Check selected glyphs\nfor touching pairs", "callback": self.checkSel, "y": p }, "checkAllBtn": { "text": "Check entire font\n(can take several minutes!)", "callback": self.checkAll, "y": 60 } } for button, data in buttons.items(): setattr( self.w.options, button, SquareButton((p, data["y"], w, 40), data["text"], callback=data["callback"], sizeStyle="small")) self.w.options.zeroCheck = CheckBox((p, 108, w, 20), "Ignore zero-width glyphs", value=True, sizeStyle="small") self.w.options.progress = ProgressSpinner((82, 174, 16, 16), sizeStyle="small") # results self.w.results = Group((0, 220, 180, -0)) self.w.results.show(False) textBoxes = {"stats": 24, "result": 42} for box, y in textBoxes.items(): setattr(self.w.results, box, TextBox((p, y, w, 14), "", sizeStyle="small")) moreButtons = { "spaceView": { "text": "View all in Space Center", "callback": self.showAllPairs, "y": 65 }, "exportTxt": { "text": "Export as MM pair list", "callback": self.exportPairList, "y": 90 } } for button, data in moreButtons.items(): setattr( self.w.results, button, SquareButton((p, data["y"], w, 20), data["text"], callback=data["callback"], sizeStyle="small")) # list and preview self.w.outputList = List((180, 0, 188, -0), [{ "left glyph": "", "right glyph": "" }], columnDescriptions=[{ "title": "left glyph" }, { "title": "right glyph" }], showColumnTitles=False, allowsMultipleSelection=False, enableDelete=False, selectionCallback=self.showPair) self.w.preview = MultiLineView((368, 0, -0, -0), pointSize=256) self.w.open()
def __init__(self): self.w = FloatingWindow( (self.width, self.height), title='tempEdit', minSize=(self.width*0.9, self.width*0.5)) self.designspaces = Group((0, 0, -0, -0)) x = y = p = self.padding self.designspaces.list = List( (x, y, -p, -p), [], allowsMultipleSelection=False, allowsEmptySelection=False, # editCallback=self.selectDesignspaceCallback, selectionCallback=self.selectDesignspaceCallback, enableDelete=True, otherApplicationDropSettings=dict( type=NSFilenamesPboardType, operation=NSDragOperationCopy, callback=self.dropCallback)) self.sources = Group((0, 0, -0, -0)) x = y = p = self.padding self.sources.list = List((x, y, -p, -p), []) self.glyphs = Group((0, 0, -0, -0)) x = y = p = self.padding textBoxHeight = -(self.lineHeight * 5) - (p * 3) self.glyphs.names = EditText( (x, y, -p, textBoxHeight), 'a b c A B C one two three') y = -(p + self.lineHeight) * 4 self.glyphs.importButton = Button( (x, y, -p, self.lineHeight), 'import glyphs', callback=self.importButtonCallback) y = -(p + self.lineHeight) * 3 self.glyphs.importMode = RadioGroup( (x, y, -p, self.lineHeight), ['fonts → fonts', 'fonts → glyphs', 'fonts → layers'], sizeStyle='small', isVertical=False) self.glyphs.importMode.set(2) y = -(p + self.lineHeight) * 2 self.glyphs.exportButton = Button( (x, y, -p, self.lineHeight), 'export selected glyphs', callback=self.exportButtonCallback) y = -(p + self.lineHeight) self.glyphs.progress = ProgressBar((x, y, -p, self.lineHeight)) descriptions = [ dict(label="designspaces", view=self.designspaces, size=self.lineHeight*5, minSize=self.lineHeight*3, collapsed=False, canResize=True), dict(label="sources", view=self.sources, size=self.lineHeight*8, minSize=self.lineHeight*6, collapsed=False, canResize=True), dict(label="glyphs", view=self.glyphs, size=self.lineHeight*10, minSize=self.lineHeight*8, collapsed=False, canResize=True), ] self.w.accordionView = AccordionView((0, 0, -0, -0), descriptions) self.w.getNSWindow().setTitlebarAppearsTransparent_(True) self.w.open()
def __init__(self, font): self.font = font self.recipients = FontRecipients(self.font) self.applicants = [] self.note_draft_storage = LibStorage(self.font.lib, "release_notes_draft") self.email_storage = LibStorage(self.font.lib, "designer_email_address") self.license_storage = LibStorage(self.font.lib, "license_filepath") self.window.banner_background = Background((0, -40, 0, 40), 1) self.window.upgrade_tip = TextBox( (15, -30, -15, 22), WhiteText( "Ghostlines is out of Beta. If you have an account, upgrade:")) self.window.upgrade_button = Button((-205, -31, 185, 22), "Migrate from Beta", callback=self.migrate, sizeStyle="small") self.window.background = Background((0, 0, -0, 235)) self.window.attribution = AttributionText((15, 15, -15, 22), font) self.window.send_button = CounterButton( (-215, 12, 200, 24), ("Send Release to All", "Send Release to {}"), callback=self.send) self.window.notes_field_label = TextBox((15, 52, -15, 22), WhiteText("Release Notes")) self.window.notes_field = NotesEditor( (15, 75, -15, 80), draft_storage=self.note_draft_storage) self.window.email_address_field_label = TextBox( (15, 170, 270, 22), WhiteText("Contact Email Included in Release")) self.window.email_address_field = EmailAddressField( (15, 193, 270, 22), storage=self.email_storage) self.window.license_field_label = TextBox((-285, 170, -15, 22), WhiteText("License")) self.window.license_field = FileUploadField( (-285, 193, -15, 22), storage=self.license_storage) self.window.recipients_label = TextBox((-285, 250, -15, 22), "Subscribers") self.window.recipients = List( (-285, 273, 270, -89), self.recipients, selectionCallback=self.update_send_button) self.window.recipients.setSelection([]) self.window.recipients_tip = TextBox((-200, -73, 185, 14), "cmd+click to select subset", alignment="right", sizeStyle="small") self.window.add_recipient_button = Button((-285, -79, 30, 24), "+", callback=self.add_recipient) self.window.remove_recipient_button = Button( (-246, -79, 30, 24), "-", callback=self.remove_recipient) self.window.applicants = ApplicantList( (15, 250, 270, 235), self.font, self.applicants, self.recipients, after_approve=self.add_approved_applicant) self.window.bind("became main", self.fetch_applicants) self.window.setDefaultButton(self.window.send_button)
def __init__(self, mainWindow, presetsList): self.presets = presetsList self.presetNames = [preset.name for preset in self.presets] self.selectedPreset = None self.selectedGroupIndex = None gutter = 10 left = 10 row = 10 colWidth = 275 listHeight = 115 col2Left = left + colWidth + gutter btnWidth = 85 btnHeight = 22 boxWidth = btnWidth * 2 + 15 windowWidth = col2Left + boxWidth + 10 self.w = Sheet((windowWidth, 550), mainWindow) self.w.presetsText = TextBox((left, row, colWidth, 20), "Presets:", sizeStyle="small") row += 17 self.w.presetsList = List((left, row, colWidth, listHeight), items=self.presetNames, allowsSorting=False, allowsMultipleSelection=False, allowsEmptySelection=False, selectionCallback=self.updatePresetInfo) self.w.presetCtrls = Box((col2Left, row, boxWidth, listHeight)) boxLeft = 0 boxRow = 0 self.w.presetCtrls.edit = TextBox((boxLeft, boxRow, btnWidth, 20), "Edit:", sizeStyle="small") boxRow += 15 self.w.presetCtrls.newBtn = Button((boxLeft, boxRow, btnWidth, btnHeight), "New", sizeStyle="small", callback=self.testerCB) boxRow += 22 self.w.presetCtrls.dupeBtn = Button((boxLeft, boxRow, btnWidth, btnHeight), "Duplicate", sizeStyle="small", callback=self.testerCB) boxRow += 22 self.w.presetCtrls.renameBtn = Button((boxLeft, boxRow, btnWidth, btnHeight), "Rename", sizeStyle="small", callback=self.testerCB) boxRow += 22 self.w.presetCtrls.delBtn = Button((boxLeft, boxRow, btnWidth, btnHeight), "Delete", sizeStyle="small", callback=self.testerCB) boxRow = 0 boxLeft += btnWidth + 7 self.w.presetCtrls.importText = TextBox((boxLeft, boxRow, btnWidth, 20), "Import:", sizeStyle="small") boxRow += 15 self.w.presetCtrls.importJSON = Button((boxLeft, boxRow, btnWidth, btnHeight), "JSON", sizeStyle="small", callback=self.testerCB) boxRow += 22 self.w.presetCtrls.importGroups = Button((boxLeft, boxRow, btnWidth, btnHeight), "Proof groups", sizeStyle="small", callback=self.testerCB) row += listHeight + 12 self.w.proofGroupsText = TextBox((left, row, colWidth, 20), "Proof groups:", sizeStyle="small") row += 17 listHeight = 150 self.w.proofGroupNames = List((left, row, colWidth, listHeight), items=[], allowsSorting=False, allowsMultipleSelection=False, selectionCallback=self.updateGroupContents) self.w.groupCtrls = Box((col2Left, row, boxWidth, listHeight)) boxLeft = 0 boxRow = 0 self.w.groupCtrls.newBtn = Button((boxLeft, boxRow, btnWidth, btnHeight), "New", sizeStyle="small", callback=self.testerCB) boxRow += 22 self.w.groupCtrls.dupeBtn = Button((boxLeft, boxRow, btnWidth, btnHeight), "Duplicate", sizeStyle="small", callback=self.testerCB) boxRow += 22 self.w.groupCtrls.rename = Button((boxLeft, boxRow, btnWidth, btnHeight), "Rename", sizeStyle="small", callback=self.testerCB) boxRow += 22 self.w.groupCtrls.delBtn = Button((boxLeft, boxRow, btnWidth, btnHeight), "Delete", sizeStyle="small", callback=self.testerCB) boxRow = 22 boxLeft += btnWidth + 7 + (btnWidth / 2 - 15) self.w.groupCtrls.upBtn = Button((boxLeft, boxRow, 30, btnHeight), "↑", sizeStyle="small", callback=self.testerCB) boxRow += 22 self.w.groupCtrls.dnBtn = Button((boxLeft, boxRow, 30, btnHeight), "↓", sizeStyle="small", callback=self.testerCB) row += listHeight + 12 self.w.groupContentsText = TextBox((left, row, colWidth, 20), "Group contents:", sizeStyle="small") row += 17 self.w.groupContents = TextEditor((left, row, -10, -36), text="", readOnly=True, callback=self.editGroupContents) self.w.groupContents.getNSTextView().setFont_(monoFont) # self.w.renameText = TextBox((left, row, colWidth, 20), # "Rename preset:", # sizeStyle="small") # self.w.renameEdit = EditText((left, row, colWidth, btnHeight)) row += 17 self.w.okButton = Button((windowWidth/2 - btnWidth/2, -31, btnWidth, btnHeight), "OK", callback=self.closeCB) self.w.setDefaultButton(self.w.okButton) self.updatePresetInfo()
def __init__(self): w = 300 # window width h = 700 # window height m = 8 # margin spacer s = 0.25 # scale to draw glyphs pb = 100 # padding bottom to space controls lsh = 150 # list height tbh = 24 # text box height cbh = 20 # checkbox height btw = 140 # button width bth = 24 # button height col_1_of_2 = w/2-m-m/2 col_2_of_2 = w/2+m/2 # GSFont obj self.font = Glyphs.font # current Font obj self.selectedMaster = Glyphs.font.selectedFontMaster # current Master obj self.KBtab = Glyphs.font.tabs[0] # current GSEditViewController obj tabs self.actvglyphleft = None self.actvglyphright = None self.SyncGlyphMetrics = True self.initComplete = False # Highly Used Letter in Draw F(x)s self.spaceLetter = self._getCurrentLayerForLetter(cGlyph=self.font.glyphs["space"]) # Vanilla Window Obj self.w = FloatingWindow( (50,100,w,h), "KernBot.io", autosaveName="com.joeygrable.kernbot.ui" ) # Vanilla Element Styles KgValueStyle = dict(alignment="center", sizeStyle="regular") KgLabelStyle = dict(alignment="center", sizeStyle="mini") KgBtnStyles = dict(sizeStyle="regular") # ------------------------------------------------------------------------------------------------- # create Left and Right list of Kerning Groups keys self.w.leftKernTxt = TextBox( (m, m, col_1_of_2, tbh), "Right KERN KEY" ) self.w.rightKernTxt = TextBox( (col_2_of_2, m, -m, tbh), "Left KERN KEY" ) self.w.leftKerns = List( (m, tbh+m, col_1_of_2, lsh), [], selectionCallback=self.updateKernGroupsList ) self.w.rightKerns = List( (col_2_of_2, tbh+m, -m, lsh), [], selectionCallback=self.updateKernGroupsList ) # (below KGroupsList) create Left and Right list of glyphs that share the selected Kerning Group Key self.w.leftGlyphsListTxt = TextBox( (m, tbh+lsh+m*2, col_1_of_2, tbh), "Left GLYPH" ) self.w.leftGlyphsListTxtSub = TextBox( (m, tbh*2+lsh+m*2, col_1_of_2, tbh), "w/ Right Kern Group", sizeStyle="mini" ) self.w.rightGlyphsListTxt = TextBox( (col_2_of_2, tbh+lsh+m*2, -m, tbh), "Right GLYPH" ) self.w.rightGlyphsListTxtSub = TextBox( (col_2_of_2, tbh*2+lsh+m*2, -m, tbh), "w/ Left Kern Group", sizeStyle="mini" ) self.w.leftGlyphsList = List( (m, tbh*3+lsh+m+m/2, col_1_of_2, lsh), [], selectionCallback=self.updateGlyphWithKernGroupList) self.w.rightGlyphsList = List( (col_2_of_2, tbh*3+lsh+m*1.5, -m, lsh), [], selectionCallback=self.updateGlyphWithKernGroupList ) # make kerning groups and cache them in the App --> list of kern groups self.kernGroups = makeKerningGroups( Glyphs.font.glyphs ) # make a cross reference for glyphName --> (kernGroupOnLeft, kernGroupOnRight) self.glyph2Group1, self.glyph2Group2 = glyphToKerningGroups( self.kernGroups ) # ------------------------------------------------------------------------------------------------- # populate List elements with initial font data self.leftKernKeysList = self._getCleanKernKeysAsList( self.glyph2Group1.keys() ) self.leftKernKeysList.sort(key=lambda x:(x.islower(), x)) self.rightKernKeysList = self._getCleanKernKeysAsList( self.glyph2Group2.keys() ) self.rightKernKeysList.sort(key=lambda x:(x.islower(), x)) # ------------------------------------------------------------------------------------------------- # display buttons for outputing kern/glyph strings to screen # divider line self.w.listsHorizontalDvd = HorizontalLine( (m, tbh*3+lsh*2+m*2.5, w-m-m, 1) ) # label text for this section of the app self.w.drawGlyphsActionsLabel = TextBox( (m, tbh*3+lsh*2+m*3.5, w-m-m, tbh), "Draw To Window Actions:" ) # show current letter pair self.w.showCurrentLetterPair = Button( (m, tbh*4+lsh*2+m*3.5, col_1_of_2, bth), "current letter pair", callback=self.drawCurrentLetterPair, **KgBtnStyles ) # label text for possible kern pairs list self.w.allPossibleLetterPairsLabel = TextBox( (m, tbh*5+lsh*2+m*4.25, col_1_of_2, tbh), "all possible letter pairs:", sizeStyle="mini" ) # show all letter pairs with kern pair self.w.showAllLetterPairsWithKerning = List( (m, tbh*5+lsh*2+m*6, col_1_of_2, lsh*0.76), [], selectionCallback=self.drawSelectedAllPossibleLetterPairsWithKerning) # show a randomly selected word from list self.w.showRandomSelectedWordBtn = Button( (col_2_of_2, tbh*4+lsh*2+m*3.5, -m, bth), "show random word", callback=self.drawRandomSelectedMatchingWord ) # label text for matching words list self.w.allMatchingWordsLabel = TextBox( (col_2_of_2, tbh*5+lsh*2+m*4.25, -m, tbh), "all words conaining pair:", sizeStyle="mini" ) # show list of all matching words self.w.showAllMatchingWords = List( (col_2_of_2, tbh*5+lsh*2+m*6, -m, lsh*0.76), [], selectionCallback=self.drawNewSelectedMatchingWord ) # divider line self.w.drawGlyphsActionsHorizontalDvd = HorizontalLine( (m, -pb-m, w-m-m, 1) ) # ------------------------------------------------------------------------------------------------- # display the current selected GLYPHS, their METRIC Keys/Values, and KERNING Pair/Value # show the current left glyph self.w.currentLeftGlyph = TextBox( (0, -pb, w/5, tbh), "H", **KgValueStyle ) self.w.currentLeftGlyphUC = TextBox( (0, -pb+tbh, w/5, tbh), "U+0048", **KgLabelStyle ) self.w.currentLeftGlyphUClabel = TextBox( (0, -pb+tbh*1.8, w/5, tbh), "LEFT GLYPH", **KgLabelStyle ) # divider line self.w.LeftGlyphDvdr = VerticalLine( (w/5, -pb, 1, tbh*2.5) ) # show the current left glyph right metric self.w.currentLeftGlyphRightMetricVal = TextBox( (w/5, -pb, w/5, tbh), "+0", **KgValueStyle ) self.w.currentLeftGlyphRightMetricKey = TextBox( (w/5, -pb+tbh, w/5, tbh), "=[value]", **KgLabelStyle ) self.w.currentLeftGlyphRightMetricLabel = TextBox( (w/5, -pb+tbh*3, w/5, tbh), "RGT MTRC", **KgLabelStyle ) # divider line-------- self.w.LeftGlyphRightMetricDvd = VerticalLine( (w/5+w/5, -pb, 1, tbh*2.5) ) # show the active kern pair self.w.currectKernPairVal = TextBox( (w/5+w/5, -pb, w/5, tbh), "-0", **KgValueStyle ) self.w.currectKernPairKey = TextBox( (w/5+w/5, -pb+tbh, w/5, tbh), "V|V", **KgLabelStyle ) self.w.currectKernPairLabel = TextBox( (w/5+w/5, -pb+tbh*3, w/5, tbh), "KERN PAIR", **KgLabelStyle ) # divider line self.w.RightGlyphLeftMetricDvdr = VerticalLine( (w/5+w/5+w/5, -pb, 1, tbh*2.5) ) # show the current right glyph left metric self.w.currentRightGlyphLeftMetricVal = TextBox( (-w/5-w/5, -pb, w/5, tbh), "+0", **KgValueStyle ) self.w.currentRightGlyphLeftMetricKey = TextBox( (-w/5-w/5, -pb+tbh, w/5, tbh), "=[value]", **KgLabelStyle ) self.w.currentRightGlyphLeftMetricLabel = TextBox( (-w/5-w/5, -pb+tbh*3, w/5, tbh), "LFT MTRC", **KgLabelStyle ) # divider line self.w.RightGlyphDvdr = VerticalLine( (-w/5, -pb, 1, tbh*2.5) ) # show the current right glyph self.w.currentRightGlyph = TextBox( (-w/5, -pb, -0, tbh), "I", **KgValueStyle ) self.w.currentRightGlyphUC = TextBox( (-w/5, -pb+tbh, -0, tbh), "U+0049", **KgLabelStyle ) self.w.currentRightGlyphUClabel = TextBox( (-w/5, -pb+tbh*1.8, -0, tbh), "RIGHT GLYPH", **KgLabelStyle ) # buttons for kerning in steps. Round if kerning is not a multiple of a step. # LEFT Glyph RIGHT Metric Value self.w.LgRmBtnPlus = Button( (w/5+((w/5)/2), -pb+tbh*1.75, (w/5)/2, bth), "+", callback=self.leftGlyphRightMetricPlus, **KgBtnStyles ) self.w.LgRmBtnMinus = Button( (w/5, -pb+tbh*1.75, (w/5)/2, bth), "-", callback=self.leftGlyphRightMetricMinus, **KgBtnStyles ) # LEFT+RIGHT Kerning Pair Value self.w.KernPairBtnPlus = Button( (w/5+w/5+((w/5)/2), -pb+tbh*1.75, (w/5)/2, bth), "+", callback=self.glyphsKerningPairPlus, **KgBtnStyles ) self.w.KernPairBtnMinus = Button( (w/5+w/5, -pb+tbh*1.75, (w/5)/2, bth), "-", callback=self.glyphsKerningPairMinus, **KgBtnStyles ) # RIGHT Glyph LEFT Metric Value self.w.RgLmBtnPlus = Button( (-w/5-w/5+((w/5)/2), -pb+tbh*1.75, (w/5)/2, bth), "+", callback=self.rightGlyphLeftMetricPlus, **KgBtnStyles ) self.w.RgLmBtnMinus = Button( (-w/5-w/5, -pb+tbh*1.75, (w/5)/2, bth), "-", callback=self.rightGlyphLeftMetricMinus, **KgBtnStyles ) # ------------------------------------------------------------------------------------------------- # addCallbacks and listen to CONSTANTS Glyphs.addCallback( self.documentWasSaved, DOCUMENTWASSAVED ) Glyphs.addCallback( self.drawBackground, DRAWBACKGROUND ) # load initial ALL_WORDS dataset self.allMatchingWords = [] self.allPossibleGlyphPairs = [] self.allPossibleLetterPairs = [] self.currentLetterPair = None # run initializing functions self.w.bind("close", self.closeCleanUp) # call if window closes self.updating = False # Flag to avoid recursive Updating # fill the controls with real values (ie. Lists) self.updateAppUI() self.initComplete = True self.w.open() # open window self.w.makeKey() # focus window
def __init__(self, font, document=None): self.font = font self.note_draft_storage = LibStorage(self.font.lib, "releaseNotesDraft") self.license_storage = LibStorage(self.font.lib, "licenseFilepath") self.family_id_storage = LibStorage(self.font.lib, "fontFamilyId") self.subscribers = self.font_family["subscribers"] if document is not None: self.window.assignToDocument(document) self.window.background = Background((301, -52, 299, 52), alpha=0.05) self.window.release_info = Group((315, 15, 270, -15)) self.window.release_info.font_name_label = TextBox((0, 0, -0, 22), "Font Name", sizeStyle="small") self.window.release_info.font_name = TextBox((0, 19, -0, 22), self.font_family["name"]) self.window.release_info.font_author_label = TextBox((0, 60, -0, 22), "Designer", sizeStyle="small") self.window.release_info.font_author = TextBox( (0, 79, -0, 22), self.font_family["designer_name"]) self.window.release_info.version_label = TextBox((0, 120, -0, 22), "Version Number", sizeStyle="small") self.window.release_info.version = TextBox((0, 139, -0, 22), self.font_version) self.window.release_info.notes_field_label = TextBox((0, 176, -0, 22), "Release Notes", sizeStyle="small") self.window.release_info.notes_field = NotesEditor( (0, 198, -0, 175), draft_storage=self.note_draft_storage) self.window.release_info.license_field_label = TextBox( (0, 393, -0, 22), "Attach License", sizeStyle="small") self.window.release_info.license_field = FileUploadField( (0, 410, -0, 22), storage=self.license_storage) self.window.release_info.send_button = CounterButton( (0, -24, -0, 24), ("Send Release to All", "Send Release to {}"), callback=self.send) self.window.release_subscriber_divider = VerticalLine((300, 0, 1, -0)) self.window.subscriber_info = Group((15, 15, 270, -15)) self.window.subscriber_info.subscribers_label = TextBox( (0, 0, -0, 22), "Subscribers", sizeStyle="small") self.window.subscriber_info.subscribers = List( (0, 22, -0, 205), self.subscribers, columnDescriptions=[{ "title": "Name", "key": "name", "editable": False }, { "title": "Email Address", "key": "email_address", "editable": False }], selectionCallback=self.update_send_button) self.window.subscriber_info.subscribers.setSelection([]) self.window.subscriber_info.subscribers_tip = TextBox( (0, 238, -0, 14), "cmd+click to select subset", alignment="right", sizeStyle="small") self.window.subscriber_info.show_subscriber_sheet_button = Button( (0, 233, 30, 24), "+", callback=self.show_subscriber_sheet) self.window.subscriber_info.remove_subscriber_button = Button( (40, 233, 30, 24), "-", callback=self.remove_subscriber) self.window.subscriber_info.applicants = \ ApplicantList((0, 280, 270, 210), self.font_family["applicant_roster"], self.family_id_storage.retrieve(), after_approve=self.refresh_subscribers) self.window.release_releases_divider = VerticalLine((600, 0, 1, -0)) self.window.releases_info = Group((615, 15, 270, -15)) self.window.releases_info.log_label = TextBox((0, 0, -0, 22), "Releases", sizeStyle="small") self.window.releases_info.log = \ ReleaseLog((0, 22, -0, -0), self.font_family["releases"][::-1], columnDescriptions=[ { "title": "Created", "key": "created_at", "editable": False }, { "title": "Version", "key": "version", "editable": False, "width": 50 }, { "title": "# subs.", "key": "subscriber_count", "editable": False, "width": 50 } ]) self.resize_window_for_releases() self.window.bind("became main", self.fetch_applicants)
def buildFilterSheet(self, filterName='', makeNew=False): sheetFields = { 'file': '', 'module': '', 'filterObjectName': '', 'limits': {}, 'arguments': {}, } if filterName != '': filterDict = self.filters[filterName].getFilterDict() for key in filterDict: if key == "arguments": entry = OrderedDict(filterDict[key]) else: entry = filterDict[key] sheetFields[key] = entry self.filterSheet = Sheet((0, 0, 400, 350), self.w) self.filterSheet.new = makeNew self.filterSheet.index = self.filters[filterName].index if not makeNew else -1 applyTitle = 'Add Filter' if filterName == '' else 'Update Filter' self.filterSheet.apply = SquareButton((-115, -37, 100, 22), applyTitle, callback=self.processFilter, sizeStyle='small') self.filterSheet.cancel = SquareButton((-205, -37, 80, 22), 'Cancel', callback=self.closeFilterSheet, sizeStyle='small') y = 20 self.filterSheet.nameTitle = TextBox((15, y, 100, 22), 'Filter Name') self.filterSheet.name = EditText((125, y, -15, 22), filterName) y += 22 tabs = ['module','file'] selectedTab = 0 if len(sheetFields['module']) >= len(sheetFields['file']) else 1 filterObjectName = sheetFields['filterObjectName'] y += 20 self.filterSheet.importPath = Tabs((15, y, -15, 75), tabs) self.filterSheet.importPath.set(selectedTab) modulePathTab = self.filterSheet.importPath[0] filePathTab = self.filterSheet.importPath[1] modulePathTab.pathInput = EditText((10, 10, -10, -10), sheetFields['module']) filePathTab.pathInput = EditText((10, 10, -110, -10), sheetFields['file']) filePathTab.fileInput = SquareButton((-100, 10, 90, -10), u'Add File…', sizeStyle='small', callback=self.getFile) y += 75 y += 10 self.filterSheet.filterObjectTitle = TextBox((15, y, 100, 22), 'Filter Object (pen, function)') self.filterSheet.filterObject = EditText((125, y, -15, 22), filterObjectName) y += 22 y += 20 columns = [ {'title': 'argument', 'width': 160, 'editable':True}, {'title': 'value', 'width': 71, 'editable':True}, {'title': 'min', 'width': 49, 'editable':True}, {'title': 'max', 'width': 49, 'editable':True} ] arguments = sheetFields['arguments'] limits = sheetFields['limits'] argumentItems = [] for key, value in arguments.items(): if isinstance(value, bool): value = str(value) elif isinstance(value, float): value = round(value, 2) argItem = { 'argument': key, 'value': value } if key in limits: minimum, maximum = sheetFields['limits'][key] argItem['min'] = minimum argItem['max'] = maximum argumentItems.append(argItem) buttonSize = 20 gutter = 7 self.filterSheet.arguments = List((15 + buttonSize + gutter, y, -15, -52), argumentItems, columnDescriptions=columns, allowsMultipleSelection=False, allowsEmptySelection=False) self.filterSheet.addArgument = SquareButton((15, -52-(buttonSize*2)-gutter, buttonSize, buttonSize), '+', sizeStyle='small', callback=self.addArgument) self.filterSheet.removeArgument = SquareButton((15, -52-buttonSize, buttonSize, buttonSize), '-', sizeStyle='small', callback=self.removeArgument) if len(argumentItems) == 0: self.filterSheet.removeArgument.enable(False) if filterName == '': self.currentFilterName = ''
def __init__(self, willOpen=True): super(SidebearingsLinker, self).__init__() # collecting fonts self.allFonts = AllFonts() if self.allFonts != []: self.selectedFont = self.allFonts[0] # interface self.w = FloatingWindow((PLUGIN_WIDTH, PLUGIN_HEIGHT), PLUGIN_TITLE) jumpingY = MARGIN_VER self.w.fontPopUp = PopUpButton( (MARGIN_HOR, jumpingY, NET_WIDTH, vanillaControlsSize['PopUpButtonRegularHeight']), getNamesFrom(self.allFonts), callback=self.fontPopUpCallback) jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_ROW self.w.canvas = CanvasGroup( (MARGIN_HOR, jumpingY, NET_WIDTH, CANVAS_HEIGHT), delegate=self) jumpingY += CANVAS_HEIGHT + MARGIN_ROW linksColumnDescriptions = [{ "title": "left", 'key': 'lft', 'width': LIST_WIDE_COL }, { "title": "active", "cell": CheckBoxListCell(), 'key': 'lftActive', 'width': LIST_NARROW_COL }, { "title": "glyph", 'key': 'servant', 'width': LIST_WIDE_COL, "editable": False }, { "title": "active", "cell": CheckBoxListCell(), 'key': 'rgtActive', 'width': LIST_NARROW_COL }, { "title": "right", 'key': 'rgt', 'width': LIST_WIDE_COL }] if self.selectedFont is not None: links = loadLinksFromFont(self.selectedFont) else: links = [] self.w.linksList = List( (MARGIN_HOR, jumpingY, NET_WIDTH, 200), links, showColumnTitles=False, allowsMultipleSelection=False, drawVerticalLines=True, columnDescriptions=linksColumnDescriptions, selectionCallback=self.selectionLinksListCallback, editCallback=self.editLinksListCallback) if self.selectedFont is not None: self.w.linksList.setSelection([0]) self.currentRow = self.w.linksList[0] self.matchDisplayedSubscriptions() jumpingY += self.w.linksList.getPosSize()[3] + MARGIN_ROW buttonWidth = (NET_WIDTH - MARGIN_HOR) / 2 self.w.linkAllButton = SquareButton( (MARGIN_HOR, jumpingY, buttonWidth, vanillaControlsSize['ButtonRegularHeight'] * 1.5), 'Link All', callback=self.linkAllButtonCallback) self.w.unlockAllButton = SquareButton( (MARGIN_HOR * 2 + buttonWidth, jumpingY, buttonWidth, vanillaControlsSize['ButtonRegularHeight'] * 1.5), 'Unlink All', callback=self.unlockAllButtonCallback) jumpingY += vanillaControlsSize[ 'ButtonRegularHeight'] * 1.5 + MARGIN_ROW self.w.separationLineOne = HorizontalLine( (MARGIN_HOR, jumpingY, NET_WIDTH, vanillaControlsSize['HorizontalLineThickness'])) jumpingY += MARGIN_ROW self.w.pushIntoFontButton = SquareButton( (MARGIN_HOR, jumpingY, buttonWidth, vanillaControlsSize['ButtonRegularHeight'] * 1.5), 'Push into font', callback=self.pushIntoFontButtonCallback) self.w.pushIntoFontButton.enable(False) self.w.clearLibsButton = SquareButton( (MARGIN_HOR * 2 + buttonWidth, jumpingY, buttonWidth, vanillaControlsSize['ButtonRegularHeight'] * 1.5), 'Clear Libs', callback=self.clearLibsButtonCallback) jumpingY += vanillaControlsSize[ 'ButtonRegularHeight'] * 1.5 + MARGIN_ROW self.w.loadFromTable = SquareButton( (MARGIN_HOR, jumpingY, buttonWidth, vanillaControlsSize['ButtonRegularHeight'] * 1.5), 'Load from table', callback=self.loadFromTableCallback) self.w.loadFromTable.enable(True) self.w.exportTable = SquareButton( (MARGIN_HOR * 2 + buttonWidth, jumpingY, buttonWidth, vanillaControlsSize['ButtonRegularHeight'] * 1.5), 'Export table', callback=self.exportTableCallback) self.w.exportTable.enable(True) jumpingY += vanillaControlsSize[ 'ButtonRegularHeight'] * 1.5 + MARGIN_VER * 2 self.w.resize(PLUGIN_WIDTH, jumpingY) self.setUpBaseWindowBehavior() if self.selectedFont is not None: self.matchSubscriptions() result = askYesNo('Warning', 'Do you want to align servants to masters?') if bool(result) is True: self._alignServantsToMasters() addObserver(self, "drawOnGlyphCanvas", "draw") addObserver(self, "drawOnGlyphCanvas", "drawInactive") addObserver(self, 'fontDidOpenCallback', 'fontDidOpen') addObserver(self, 'fontDidCloseCallback', 'fontDidClose') if willOpen is True: self.w.open()
def populateWindow(self): """ The UI """ self.fillColor = getExtensionDefault(DEFAULTKEY_FILLCOLOR, FALLBACK_FILLCOLOR) self.strokeColor = getExtensionDefault(DEFAULTKEY_STROKECOLOR, FALLBACK_STROKECOLOR) self.contextBefore = self.contextAfter = "" # Populating the view can only happen after the view is attached to the window, # or else the relative widths go wrong. self.w.add = Button((-40, 3, 30, 22), "+", callback=self.addCallback) self.w.reset = Button((-40, 30, 30, 22), chr(8634), callback=self.resetCallback) # Flag to see if the selection list click is in progress. We are resetting the selection # ourselves, using the list "buttons", but changing that selection will cause another # list update, that should be ignored. self._selectionChanging = False x = y = 4 self.w.fontList = List( (C2, y, 250, -65), self._getFontItems(), selectionCallback=self.fontListCallback, drawFocusRing=False, enableDelete=False, allowsMultipleSelection=False, allowsEmptySelection=True, drawHorizontalLines=True, showColumnTitles=False, columnDescriptions=self._getPathListDescriptor(), rowHeight=16, ) self.w.fill = CheckBox( (x, y, 60, 22), "Fill", sizeStyle=CONTROLS_SIZE_STYLE, value=True, callback=self.fillCallback, ) y += L - 3 self.w.stroke = CheckBox( (x, y, 60, 22), "Stroke", sizeStyle=CONTROLS_SIZE_STYLE, value=False, callback=self.strokeCallback, ) y += L defaultColor = getExtensionDefault(DEFAULTKEY_FILLCOLOR, FALLBACK_FILLCOLOR) self.w.color = ColorWell( (x, y, 60, 22), color=NSColor.colorWithCalibratedRed_green_blue_alpha_( *defaultColor), callback=self.colorCallback, ) y += LL + 5 self.w.alignText = TextBox((x, y, 90, 50), "Alignment", sizeStyle=CONTROLS_SIZE_STYLE) y += L self.w.align = RadioGroup( (x, y, 90, 50), ["Left", "Center", "Right"], isVertical=True, sizeStyle=CONTROLS_SIZE_STYLE, callback=self.alignCallback, ) self.w.align.set(0) self.w.viewCurrent = CheckBox( (C2, -60, 150, 22), "Always View Current", sizeStyle=CONTROLS_SIZE_STYLE, value=False, callback=self.viewCurrentCallback, ) self.w.contextBefore = GlyphNamesEditText( (C2, -30, 85, 20), callback=self.contextEditCallback, continuous=True, sizeStyle="small", placeholder="Left Context", ) self.w.contextBefore.title = "contextBefore" self.w.contextCurrent = GlyphNamesEditText( (C2 + 95, -30, 60, 20), callback=self.contextEditCallback, continuous=True, sizeStyle="small", ) self.w.contextCurrent.title = "contextCurrent" self.w.contextAfter = GlyphNamesEditText( (C2 + 165, -30, 85, 20), callback=self.contextEditCallback, continuous=True, sizeStyle="small", placeholder="Right Context", ) self.w.contextAfter.title = "contextAfter"
def _buildUI(self): editPresetsImgPath = os.path.join(currentFileDir,\ "..", "resources",\ "editPresetsIcon.pdf") listForList = [ { "title": "#", "key": "order", "width": 20, "editable": False }, { "title": "Group name", "key": "name", "width": 160, "editable": True }, { "title": "Type size", "key": "typeSize", "width": 70, "editable": True, }, { "title": "Leading", "key": "leading", "width": 65, "editable": True }, { "title": " 🖨", "key": "print", "cell": CheckBoxListCell() } ] width = 425 left = 10 row = 10 textWidth = 48 textHeight = 20 popUpLeft = left + textWidth + 5 presetsPopUpWidth = width - popUpLeft - 47 listWidth = textWidth + presetsPopUpWidth self.w = Window((width, 600), "Proof Drawer") self.w.fontText = TextBox((left, row, textWidth, textHeight), "Font:", alignment="right") self.w.fontsList = PopUpButton((popUpLeft, row, -10, textHeight), items=self.fonts, callback=self.fontButtonCB) row += 30 self.w.presetText = TextBox((left, row, textWidth, textHeight), "Preset:", alignment="right") self.w.presetsList = PopUpButton((popUpLeft, row, presetsPopUpWidth, textHeight), items=self.presetNamesList, callback=self.setCurrentPresetCB) self.w.editPresets = ImageButton((width - 38, row, 22, 22), imagePath=editPresetsImgPath, bordered=False, callback=self.openPresetsEditorCB) row += 35 self.w.line1 = HorizontalLine((left, row, -10, 1)) row += 15 self.w.proofGroups = List((left + 3, row, listWidth, 255), rowHeight=18, items=[], columnDescriptions=listForList, allowsSorting=False, allowsMultipleSelection=False, editCallback=self.editProofGroupCB) buttonGroup1Left = popUpLeft + presetsPopUpWidth + 3 buttonGroup1Top = row + 58 self.w.inspectGroup = Button((buttonGroup1Left, buttonGroup1Top, 30, 20), "\u24D8", callback=self.inspectGroupCB) buttonGroup1Top += 40 self.w.moveGroupUP = Button((buttonGroup1Left, buttonGroup1Top, 30, 20), "↑", callback=self.moveGroupCB) buttonGroup1Top += 25 self.w.moveGroupDN = Button((buttonGroup1Left, buttonGroup1Top, 30, 20), "↓", callback=self.moveGroupCB) buttonGroup1Top += 40 self.w.removeGroup = Button((buttonGroup1Left, buttonGroup1Top, 30, 20), "-", callback=self.removeGroupCB) row += 275 self.w.line2 = HorizontalLine((left, row, -10, 1)) row += 10 self.w.additionalGroupNamesText = TextBox((left, row, -10, 20), "Add more proof groups:") row += 25 self.w.additionalGroupNames = List((left + 3, row, listWidth, 150), rowHeight=17, items=self.currentPreset.uniqueGroupNames, allowsSorting=False, allowsMultipleSelection=True) self.w.addGroup = Button((buttonGroup1Left, row + 60, 30, 20), "+", callback=self.addProofGroupsCB) buttonWidth = 100 self.w.previewButton = Button((width/2 - buttonWidth - 10, -37, buttonWidth, 20), "Preview", callback=self.testerCB) self.w.printButton = Button((width/2 + 10, -37, buttonWidth, 20), "Print", callback=self.testerCB) self.w.setDefaultButton(self.w.printButton)