def __init__(self, parameter, posSize, title=None, callback=None): super(ParameterSliderTextInput, self).__init__(posSize) self.parameter = parameter self.callback = callback editTextPosSize = (-65, 0, 40, 22) if title is None: sliderPosSize = (5, 3, -80, 15) elif title is not None: title = title.capitalize() sliderPosSize = (70, 3, -80, 15) self.title = TextBox((0, 3, 65, 30), title, sizeStyle='small') if parameter.dissociable: editTextPosSize = (-65, 0, 40, 22) self.checkBox = CheckBox((-22, 5, 22, 25), u'∞', callback=self.setFree, value=True, sizeStyle='mini') self.slider = Slider(sliderPosSize, minValue=parameter.limits[0], maxValue=parameter.limits[1], value=parameter.value, callback=self.valueInput, sizeStyle='small') self.textInput = EditText(editTextPosSize, str(parameter.value), callback=self.valueInput, continuous=False, sizeStyle='small') self.parameter.bind(self)
def __init__(self, posSize, uppercaseAccents, callbackAttrs, callbackCheck, callbackBuild): super(BuildingCtrls, self).__init__(posSize) x, y, width, height = posSize self.uppercaseAccents = uppercaseAccents self.callbackAttrs = callbackAttrs self.callbackCheck = callbackCheck self.callbackBuild = callbackBuild jumpinY = 0 self.uppercaseCheck = CheckBox( (0, jumpinY, width, vanillaControlsSize['CheckBoxRegularHeight']), 'Use Uppercase accents', value=self.uppercaseAccents, callback=self.uppercaseCheckCallback) self.uppercaseCheck.enable(False) jumpinY += self.uppercaseCheck.getPosSize()[3] + MARGIN_ROW + 2 self.checkButton = Button((0, jumpinY, width * .45, vanillaControlsSize['ButtonRegularHeight']), 'Check', callback=self.checkButtonCallback) self.buildButton = Button((width * .55, jumpinY, width * .45, vanillaControlsSize['ButtonRegularHeight']), 'Build', callback=self.buildButtonCallback)
def __init__(self, posSize, callback): super(CheckBoxStar, self).__init__(posSize) ctrlWidth = posSize[2] ctrlHeight = posSize[3] self.lftCheck = CheckBox( (0, ctrlHeight / 2 - vanillaControlsSize['CheckBoxRegularHeight'] / 2, CHECK_BOX_WIDTH, vanillaControlsSize['CheckBoxRegularHeight']), '', callback=self.lftCheckCallback) # self.lftArrow = TextBox((0, ctrlHeight/2, ), # u'←') self.rgtCheck = CheckBox( (-CHECK_BOX_WIDTH, ctrlHeight / 2 - vanillaControlsSize['CheckBoxRegularHeight'] / 2, CHECK_BOX_WIDTH, vanillaControlsSize['CheckBoxRegularHeight']), '', callback=self.rgtCheckCallback) self.topCheck = CheckBox( (ctrlWidth / 2. - CHECK_BOX_WIDTH / 2., 0, CHECK_BOX_WIDTH, vanillaControlsSize['CheckBoxRegularHeight']), '', callback=self.topCheckCallback) self.btmCheck = CheckBox( (ctrlWidth / 2. - CHECK_BOX_WIDTH / 2., ctrlHeight - CHECK_BOX_WIDTH, CHECK_BOX_WIDTH, vanillaControlsSize['CheckBoxRegularHeight']), '', callback=self.btmCheckCallback)
def __init__(self, posSize, index, aFont, isTop, isBottom, directionCallback, displayedCallback): super(FontRow, self).__init__(posSize) self.directionCallback = directionCallback self.displayedCallback = displayedCallback self.index = index self.ctrlFont = aFont squareButtonSide = FONT_ROW_HEIGHT - 6 self.check = CheckBox( (0, 0, 16, vanillaControlsSize['CheckBoxRegularHeight']), '', value=self.isDisplayed, callback=self.checkCallback) self.caption = TextBox( (18, 2, 120, vanillaControlsSize['TextBoxRegularHeight']), '{}'.format(self.ctrlFont.info.styleName)) self.buttonUp = SquareButton((-(squareButtonSide * 2 + MARGIN_COL), 0, squareButtonSide, squareButtonSide), u'↑', callback=self.buttonUpCallback) if isTop is True: self.buttonUp.show(False) self.buttonDw = SquareButton( (-squareButtonSide, 0, squareButtonSide, squareButtonSide), u'↓', callback=self.buttonDwCallback) if isBottom is True: self.buttonDw.show(False)
def __init__(self): self.w = Window((550, 140), "Replace named Layer") self.w.editText = EditText((10, 15, -10, 22), placeholder="Layer Name", text='{170}') self.w.correct_path_direction = CheckBox((10, 50, -10, 18), "Correct Path Direction", value=True, sizeStyle='small') self.w.sync_metrics = CheckBox((210, 50, -10, 18), "Sync Metrics", value=True, sizeStyle='small') self.w.add_if_missing = CheckBox((10, 70, -10, 18), "Add layer if missing", value=True, sizeStyle='small') self.w.copybutton = Button((10, 100, -10, 17), "Replace layer", callback=self.buttonCallback) self.w.open()
def __init__(self): '''Initialize the dialog.''' x = y = padding = 10 buttonHeight = 20 windowWidth = 400 rows = 4.5 self.w = FloatingWindow( (windowWidth, buttonHeight * rows + padding * (rows)), "Glyph Fax Machine") self.fonts = {} # self.w.textBox = TextBox((x, y, -padding, buttonHeight), "Glyphs to Copy") # y += buttonHeight self.w.editText = EditText( (x, y, -padding, buttonHeight * 2 + padding), placeholder="Space-separated list of glyphs to copy") y += buttonHeight * 2 + padding * 2 # self.w.overwriteGlyphsCheckBox = CheckBox((x, y, -padding, buttonHeight), "Overwrite Glyphs", value=False, callback=self.overwriteGlyphsOptions) # y += buttonHeight + padding self.w.overwriteNormalWidthGlyphsCheckBox = CheckBox( (x, y, -padding, buttonHeight), "Overwrite 600w Glyphs", value=False, sizeStyle="small") # self.w.overwriteNormalWidthGlyphsCheckBox.show(False) self.w.overwriteAdjustedWidthGlyphsCheckBox = CheckBox( (windowWidth * 0.4, y, -padding, buttonHeight), "Overwrite non-600w Glyphs", value=False, sizeStyle="small") # self.w.overwriteAdjustedWidthGlyphsCheckBox.show(False) self.w.colorWell = ColorWell( (windowWidth * 0.85, y, -padding, buttonHeight), color=NSColor.orangeColor()) y += buttonHeight + padding self.w.sans2mono = Button( (x, y, windowWidth / 3 - padding / 2, buttonHeight), "Sans → Mono", callback=self.sans2monoCallback) self.w.mono2sans = Button( (windowWidth / 3 + padding, y, -padding, buttonHeight), "Mono → Sans", callback=self.mono2SansCallback) self.w.open()
def __init__(self): # Window 'self.w': w = 300 h = 300 windowWidthResize = 200 # user can resize width by this value windowHeightResize = 500 # user can resize height by this value self.w = vanilla.FloatingWindow( (w, h), # default window size "Dimensions", # window title minSize=(w, h - 100), # minimum size (for resizing) maxSize=(w + windowWidthResize, h + windowHeightResize), # maximum size (for resizing) autosaveName= "com.typetr.Dimensions.mainwindow" # stores last window position and size ) M = 10 y = 30 # UI elements we'll use later self.w.tabWidth = EditText((M, y, w / 4 - M - M, 20), "650", sizeStyle='small') self.w.tabWidthLabel = TextBox((w / 4, y + 4, w / 2, 20), "Tab width", sizeStyle='small') y += 30 # Checkbox to flag if any drawing should be done by this tools self.w.doDraw = CheckBox((M, y, -M, 24), "Draw dimensions", value=True, callback=self.update, sizeStyle='regular') y += 24 self.w.showReferenceLines = CheckBox((M, y, -M, 24), "Draw reference lines", callback=self.update, value=True, sizeStyle='regular') y += 24 self.w.showArrows = CheckBox((M, y, -M, 24), "Draw arrows", value=True, callback=self.update, sizeStyle='regular') # Open window and focus on it: self.w.bind( 'close', self.windowCloseCallback) # Make bind in case the window is closed self.w.open() self.w.makeKey() # Establish callbacks that we need for this tool Glyphs.addCallback(self.drawforeground, DRAWFOREGROUND) Glyphs.addCallback(self.drawbackground, DRAWBACKGROUND)
def __init__(self, posSize, gridActive, ctrlsAmount, activeCtrls, offgridActive, callback): Group.__init__(self, posSize) assert activeCtrls <= ctrlsAmount self.ctrlHeight = posSize[3] self.gridActive = gridActive self.ctrlsAmount = ctrlsAmount self.activeCtrls = activeCtrls self.offgridActive = offgridActive self.gridIndexes = [ '{:d}'.format(integer) for integer in range(1, ctrlsAmount + 1) ] self.callback = callback self.gridsDB = [{ 'horizontal': False, 'vertical': False, 'step': None, 'color': color } for color in GRID_COLOR_INIT] jumpin_Y = 4 self.gridActiveCheck = CheckBox( (0, jumpin_Y, NET_WIDTH * .6, vanillaControlsSize['CheckBoxRegularHeight']), "Show grids", value=self.gridActive, callback=self.gridActiveCheckCallback) for eachI in range(1, ctrlsAmount + 1): jumpin_Y += vanillaControlsSize[ 'EditTextRegularHeight'] + MARGIN_VER gridCtrl = SingleGridController( (0, jumpin_Y, NET_WIDTH, vanillaControlsSize['EditTextRegularHeight']), index=eachI, isVertical=False, isHorizontal=False, step=None, gridColor=GRID_COLOR_INIT[eachI - 1], callback=self.gridCtrlCallback) gridCtrl.enable(self.gridActive) setattr(self, 'grid{:0>2}'.format(eachI), gridCtrl) jumpin_Y += vanillaControlsSize['EditTextRegularHeight'] + MARGIN_VER self.showOffgridCheck = CheckBox( (0, jumpin_Y, NET_WIDTH, vanillaControlsSize['CheckBoxRegularHeight']), "Show offgrid points", value=self.offgridActive, callback=self.showOffgridCheckCallback)
def __init__(self): self.verboten = { 'right': ['napostrophe', 'Omegadasiavaria'], 'left': ['ldot', 'Ldot', 'ldot.sc', 'sigmafinal'], 'both': ['*.tf', '*.tosf', '.notdef', 'NULL', 'CR'] } self.category = None self.messages = [] self.interpolated_fonts = dict() self.use_real = True self.use_selection = False self.ignore_red = False self.current_glyph = None self.leftside_kerning_groups = None self.rightside_kerning_groups = None self.all_kern_categories = self.get_all_kern_categories() self.categories_leftside = self.get_categorised_glyphs('left') self.categories_rightside = self.get_categorised_glyphs('right') item_height = 24.0 w_width = 300.0 w_height = item_height * (7 + len(self.all_kern_categories)) margin = 10 next_y = margin col_1_width = w_width - (margin * 2) item_height = 24 radio_height = item_height * len(self.all_kern_categories) self.w = Window((w_width, w_height), "Make Kerning Strings") self.w.text_1 = TextBox((margin, next_y, w_width, item_height), "Kern with:", sizeStyle='regular') next_y += item_height self.w.radioCategories = RadioGroup((margin, next_y, col_1_width, radio_height), self.all_kern_categories, sizeStyle='regular') self.w.radioCategories.set(0) next_y += radio_height + margin self.w.use_real = CheckBox((margin, next_y, col_1_width, item_height), "Use real words", value=True, sizeStyle='regular') next_y += item_height self.w.use_selected = CheckBox((margin, next_y, col_1_width, item_height), "Use the selected glyphs verbatum", value=False, sizeStyle='regular') next_y += item_height self.w.ignore_red = CheckBox((margin, next_y, col_1_width, item_height), "Ignore red marked glyphs", value=False, sizeStyle='regular') next_y += item_height + margin self.w.gobutton = Button((margin + (col_1_width / 4), next_y, col_1_width / 2, item_height), 'Make Strings', callback=self.makeitso) self.w.setDefaultButton(self.w.gobutton) self.w.center() self.w.open()
def __init__(self, parameter, posSize, title=None, callback=None): super(ParameterSliderTextInput, self).__init__(posSize) self.parameter = parameter self.callback = callback editTextPosSize = (-65, 0, 40, 22) if title is None: sliderPosSize = (5, 3, -80, 15) elif title is not None: if "point" in title: title = title.lstrip("point") title = "p. " + title title = title.capitalize() sliderPosSize = (70, 3, -80, 15) self.title = TextBox((0, 3, 65, 30), title, sizeStyle="small") if parameter.dissociable: editTextPosSize = (-65, 0, 40, 22) self.checkBox = CheckBox((-22, 5, 22, 25), u"∞", callback=self.setFree, value=True, sizeStyle="mini") self.parameter.bind(self.checkBox) self.slider = Slider( sliderPosSize, minValue=parameter.limits[0], maxValue=parameter.limits[1], value=parameter.value, callback=self.valueInput, sizeStyle="small", ) self.textInput = EditText( editTextPosSize, str(parameter.value), callback=self.valueInput, continuous=False, sizeStyle="small" ) self.parameter.bind(self) self.parameter.bind(self.slider) self.parameter.bind(self.textInput)
def __init__(self): self.glyph = None # Typical RoboFont function self.updating = False pad = 10 leading = 32 y = pad w = 300 h = 400 buttonWidth = 100 buttonHeight = 48 self.w = FloatingWindow((100, 100, w, h), 'DemoWindowTool') self.w.doDraw = CheckBox((pad, y, 100, 24), 'Draw', callback=self.doDrawCallback) y += leading self.w.mySlider = Slider((pad, y, -pad, 24), minValue=0, maxValue=2000, value=0, tickMarkCount=10, callback=self.mySliderCallback) y = self.w.saveFont = Button((-buttonWidth - pad, -buttonHeight - pad, buttonWidth, buttonHeight), 'Save', callback=self.saveFontCallback) addObserver(self, "currentGlyphChanged", "currentGlyphChanged") # Subscribe to application event addObserver(self, 'draw', 'draw') addObserver(self, 'drawBackground', 'drawBackground') self.w.bind('close', self.windowCloseCallback) self.w.open()
def __init__(self, posSize, verticalMode, marginCallback, verticalCallback): super(SpacingJoystick, self).__init__(posSize) self.marginCallback = marginCallback self.verticalCallback = verticalCallback self.verticalMode = verticalMode xx, yy, width, height = posSize singleMarginCtrlHeight = SQUARE_SIDE * 2 + vanillaControlsSize[ 'TextBoxRegularHeight'] + MARGIN_ROW jumpingX = 0 jumpingY = 0 self.leftMarginCtrl = SingleMargin( (jumpingX, jumpingY, SQUARE_SIDE * 2, singleMarginCtrlHeight), whichMargin='LEFT', callback=self.leftMarginCtrlCallback) jumpingX += SQUARE_SIDE * 2 + MARGIN_COL * 2 self.rightMarginCtrl = SingleMargin( (jumpingX, jumpingY, SQUARE_SIDE * 2, singleMarginCtrlHeight), whichMargin='RIGHT', callback=self.rightMarginCtrlCallback) jumpingY += singleMarginCtrlHeight + 4 self.verticalModeCheck = CheckBox( (0, jumpingY, width, vanillaControlsSize['CheckBoxRegularHeight']), 'vertical mode', callback=self.verticalModeCheckCallback) jumpingY += vanillaControlsSize['CheckBoxRegularHeight'] self.resize(width, jumpingY)
def __init__(self): self.w = FloatingWindow( (120, 140), minSize=(100, 40), textured=True, ) self.w.ti_checkbox = CheckBox((10, 10, -10, 20), 'Test Install', value=True) self.w.otf_checkbox = CheckBox((10, 30, -10, 20), 'OTF Backup', value=True) self.w.button = SquareButton((10, 60, -10, -10), 'GO', callback=self.button_callback) self.w.open()
def __init__(self, posSize, fontOptions, whichFont, actions, whichAction, glyphLists, whichGlyphList, markColor, markEditedGlyphs, callback): super(SharedCtrls, self).__init__(posSize) x, y, width, height = posSize self.fontOptions = fontOptions self.fontOptionsRepr = ['All Fonts', 'Current Font'] + [ '{} {}'.format(ff.info.familyName, ff.info.styleName) for ff in self.fontOptions[2:] ] self.whichFont = whichFont self.actions = actions self.whichAction = whichAction self.glyphLists = glyphLists self.whichGlyphList = whichGlyphList self.markColor = markColor self.markEditedGlyphs = markEditedGlyphs self.callback = callback jumpinY = 0 self.popFonts = PopUpButton( (1, jumpinY, width - 1, vanillaControlsSize['PopUpButtonRegularHeight']), self.fontOptionsRepr, callback=self.popFontsCallback) jumpinY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_ROW self.popAction = PopUpButton( (1, jumpinY, width - 1, vanillaControlsSize['PopUpButtonRegularHeight']), self.actions, callback=self.popActionCallback) jumpinY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_ROW self.popGlyphList = PopUpButton( (1, jumpinY, width - 1, vanillaControlsSize['PopUpButtonRegularHeight']), self.glyphLists[self.whichAction].keys(), callback=self.popGlyphListCallback) jumpinY += vanillaControlsSize[ 'PopUpButtonRegularHeight'] + MARGIN_ROW + 2 self.checkMarkEditedColors = CheckBox( (0, jumpinY, width * .35, vanillaControlsSize['CheckBoxRegularHeight']), "Color", value=self.markEditedGlyphs, callback=self.checkMarkEditedColorsCallback) self.popColors = PopUpButton( (width * .4, jumpinY, width * .6, vanillaControlsSize['PopUpButtonRegularHeight']), glyphCollectionColors.keys(), callback=self.popColorsCallback) self.popColors.enable(self.markEditedGlyphs)
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 loadPlugin(self): self.menuName = "Italic Extremes" self.actionButtonLabel = 'Add Nodes' self.keyboardShortcut = None windowWidth = 300 windowHeight = 120 m, h, yPos = 10, 18, 10 self.w = FloatingWindow((windowWidth, windowHeight)) self.w.group = Group((0, 0, windowWidth, windowHeight)) self.w.group.angle = EditText((m, yPos, -50, h), "", placeholder='Angles', sizeStyle='small', callback=self.editAngles_callback, continuous=True) self.w.group.refresh = Button((-40, yPos, -m, h), u"↺", callback=self.revertAngles_callback) yPos += m + h self.w.group.tabs = Tabs((m, yPos, -m, -m), ["Add slanted nodes", "Add H/V extremes"], callback=self.tab_callback) self.tab1 = self.w.group.tabs[0] self.tab1.removeV = CheckBox((m, 0, -m, h), "Delete vertical extremes", sizeStyle='small', value=False, callback=self.removeV_callback) yPos = h self.tab1.removeH = CheckBox((m, yPos, -m, h), "Delete horizontal extremes", sizeStyle='small', value=False, callback=self.removeH_callback) self.tab2 = self.w.group.tabs[1] yPos = 0 self.tab2.removeI = CheckBox((m, yPos, -m, h), "Delete slanted nodes", sizeStyle='small', value=False, callback=self.removeI_callback) self.dialog = self.w.group.getNSView()
def __init__(self, posSize, index, isVertical, isHorizontal, step, gridColor, callback): Group.__init__(self, posSize) # from arguments to attributes self.ctrlX, self.ctrlY, self.ctrlWidth, self.ctrlHeight = posSize self.index = index self.isVertical = isVertical self.isHorizontal = isHorizontal self.step = step self.gridColor = gridColor self.callback = callback # ctrls jumpin_X = 12 self.indexText = TextBox( (jumpin_X, 0, 16, vanillaControlsSize['TextBoxRegularHeight']), '{:d})'.format(index)) jumpin_X += self.indexText.getPosSize()[2] self.stepCtrl = EditText( (jumpin_X, 0, 38, vanillaControlsSize['EditTextRegularHeight']), callback=self.stepCtrlCallback) jumpin_X += self.stepCtrl.getPosSize()[2] + 16 self.isHorizontalCheck = CheckBox( (jumpin_X, 0, 32, vanillaControlsSize['CheckBoxRegularHeight']), "H", value=self.isHorizontal, callback=self.isHorizontalCheckCallback) jumpin_X += self.isHorizontalCheck.getPosSize()[2] + 2 self.isVerticalCheck = CheckBox( (jumpin_X, 0, 32, vanillaControlsSize['CheckBoxRegularHeight']), "V", value=self.isVertical, callback=self.isVerticalCheckCallback) jumpin_X += self.isVerticalCheck.getPosSize()[2] + 10 self.whichColorWell = ColorWell( (jumpin_X, 0, 46, self.ctrlHeight), color=NSColor.colorWithCalibratedRed_green_blue_alpha_(*gridColor), callback=self.whichColorWellCallback)
def __init__(self): self.fontTarget = FONT_TARGET_OPTIONS[0] self.glyphTarget = GLYPH_TARGET_OPTIONS[0] self.gridSize = 4 self.w = FloatingWindow((0, 0, PLUGIN_WIDTH, 400), PLUGIN_TITLE) jumpingY = MARGIN_VER # font target self.w.fontTargetPopUp = PopUpButton( (MARGIN_HOR, jumpingY, NET_WIDTH, vanillaControlsSize['PopUpButtonRegularHeight']), FONT_TARGET_OPTIONS, callback=self.fontTargetPopUpCallback) jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_VER # glyph target self.w.glyphTargetPopUp = PopUpButton( (MARGIN_HOR, jumpingY, NET_WIDTH, vanillaControlsSize['PopUpButtonRegularHeight']), GLYPH_TARGET_OPTIONS, callback=self.glyphTargetPopUpCallback) jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_VER # grid size captions self.w.gridSizeCaption = TextBox( (MARGIN_HOR, jumpingY + 2, NET_WIDTH * .32, vanillaControlsSize['TextBoxRegularHeight']), 'Grid Size:') # grid size edit self.w.gridSizeEdit = EditText( (MARGIN_HOR + NET_WIDTH * .32, jumpingY, NET_WIDTH * .3, vanillaControlsSize['EditTextRegularHeight']), text='{:d}'.format(self.gridSize), callback=self.gridSizeEditCallback) jumpingY += vanillaControlsSize['EditTextRegularHeight'] + MARGIN_VER self.w.moveBcpHandlesCheck = CheckBox( (MARGIN_HOR, jumpingY, NET_WIDTH, vanillaControlsSize['CheckBoxRegularHeight']), 'move bcp handles', value=self.bcpHandlesFit, callback=self.moveBcpHandlesCheckCallback) jumpingY += vanillaControlsSize['CheckBoxRegularHeight'] + MARGIN_VER # fit button self.w.fitButton = Button((MARGIN_HOR, jumpingY, NET_WIDTH, vanillaControlsSize['ButtonRegularHeight']), 'Fit!', callback=self.fitButtonCallback) jumpingY += vanillaControlsSize['ButtonRegularHeight'] + MARGIN_VER self.w.setPosSize((0, 0, PLUGIN_WIDTH, jumpingY)) self.w.open()
def __init__(self): self.font = Glyphs.font # Returns the current that is open in GlyphsApp self.currentGlyphName = 'H' self.glyph = self.font[self.currentGlyphName].layers[0] lsb = int(round(self.glyph.LSB)) rsb = int(round(self.glyph.RSB)) pad = 10 leading = 32 y = pad w = 300 h = 400 buttonWidth = 100 buttonHeight = 48 self.w = Window((100, 100, w, h), 'DemoWindowTool') self.w.doDraw = CheckBox((pad, y, 100, 24), 'Draw', callback=self.doDrawCallback) y += leading self.w.leftMarginLabel = TextBox((pad, y, -pad, 24), 'Left margin') y += leading / 2 self.w.leftMarginSlider = Slider( (pad, y, -pad - 60, 24), minValue=MIN_LSB, maxValue=MAX_LSB, value=lsb, tickMarkCount=10, callback=self.leftMarginSliderCallback) self.w.leftMarginBox = EditText((-pad - 60 + pad, y, -pad, 24), callback=self.leftMarginBoxCallback) self.w.leftMarginBox.set(str(lsb)) y += leading self.w.rightMarginLabel = TextBox((pad, y, -pad, 24), 'Right margin') y += leading / 2 self.w.rightMarginSlider = Slider( (pad, y, -pad - 60, 24), minValue=MIN_RSB, maxValue=MAX_RSB, value=rsb, tickMarkCount=10, callback=self.rightMarginSliderCallback) self.w.rightMarginBox = EditText((-pad - 60 + pad, y, -pad, 24), callback=self.rightMarginBoxCallback) self.w.rightMarginBox.set(str(rsb)) y = self.w.saveFont = Button((-buttonWidth - pad, -buttonHeight - pad, buttonWidth, buttonHeight), 'Save', callback=self.saveFontCallback) self.w.open()
def __init__( self ): hori_margin = 10 verti_margin = hori_margin button_width = 30 glyphname_width = 180 line_height = 20 gap = 9 dialog_height = line_height + gap + line_height + gap + line_height dialog_width = button_width + gap + glyphname_width + gap + button_width self.w = Window( ( hori_margin + dialog_width + hori_margin, verti_margin + dialog_height + verti_margin ), "insert glyph" ) self.w.center() x = hori_margin y = verti_margin # glyph name self.w.glyphname = EditText( ( x, y, glyphname_width, line_height ), '') self.w.glyphname.getNSTextField().setToolTip_( u'Enter the name of the glyph to be inserted. It is sufficient to enter the beginning of the glyph name, e.g. “deg” for “degree”.' ) # buttons x += glyphname_width + gap self.w.alignleft = Button( ( x, y, button_width, line_height ), LEFT, callback = self.buttonCallback ) self.w.alignleft.getNSButton().setToolTip_( 'Insert the other glyph left-aligned, i.e. at its original same position. Keyboard shortcut: Enter' ) x += button_width + gap self.w.alignright = Button( ( x, y, button_width, line_height ), RIGHT, callback = self.buttonCallback ) self.w.alignright.getNSButton().setToolTip_( 'Insert the other glyph right-aligned with respect to the advance widths. Keyboard shortcut: Esc' ) self.w.setDefaultButton( self.w.alignleft ) self.w.alignright.bind( "\x1b", [] ) # insert as component as_component_is_checked = True if Glyphs.defaults["com.FMX.InsertGlyphToBackground.AsCompoment"] is not None: as_component_is_checked = Glyphs.defaults["com.FMX.InsertGlyphToBackground.AsCompoment"] y += line_height + gap x = hori_margin self.w.as_component = CheckBox( ( x, y, dialog_width, line_height ), 'Insert as component', callback=None, value=as_component_is_checked ) self.w.as_component.getNSButton().setToolTip_( 'If checked, the other glyph is inserted to the background as a component. Otherwise, it is inserted as paths (even if the other glyph is made of components).' ) # clear current contents y += line_height + gap clear_contents_is_checked = True if Glyphs.defaults["com.FMX.InsertGlyphToBackground.ClearContents"] is not None: clear_contents_is_checked = Glyphs.defaults["com.FMX.InsertGlyphToBackground.ClearContents"] self.w.clear_contents = CheckBox( ( x, y, dialog_width, line_height ), 'Clear current contents', callback=None, value=clear_contents_is_checked ) self.w.clear_contents.getNSButton().setToolTip_( 'Check this to clear the background before inserting the other glyph. Uncheck to keep the current contents of the background.' ) self.w.open()
def spaceCenterOpenCallback(self, notification): if (not self.popupOpen) and (len(self.metricsGroups) > 0): self.w = FloatingWindow((160, 36), 'Group Spacing') self.w.activateGroups = CheckBox( (9, -27, 151, 18), "Activate Group spacing", value=self.enableGroupSpacing, callback=self.enableGroupSpacingCallback, sizeStyle="small") self.w.bind('close', self.windowCloseCallback) self.w.open() self.popupOpen = True
def __init__(self): self.w = FloatingWindow((300, 40), "Coldtype Serializer", minSize=(123, 200)) self.w.globalToggle = CheckBox((10, 10, -10, 20), 'serialize?', value=True) self.output = Path("~/robofont-coldtype.json").expanduser().absolute() addObserver(self, "shouldDraw", "draw") self.setUpBaseWindowBehavior() self.w.open()
def __init__(self): self.doMarkGlyphs = 0 self.doOverwrite = 1 self.sourceFontList = AllFonts() self.destinationFontList = AllFonts() self.source_font = self.sourceFontList[0] self.destination_fonts = None self.glyphs = None self.mark = NSColor.redColor() sl = [] for f in self.sourceFontList: if f.info.familyName != None: fn = f.info.familyName else: fn = "None" if f.info.styleName != None: fs = f.info.styleName else: fs = "None" sl.append(fn+" "+fs) ## create a window self.w = Window((700, 500), "Copy Glyphs", minSize=(700, 500)) self.w.sourceTitle = TextBox((15, 20, 200, 20), "Source Font:") self.w.sourceFont = PopUpButton((15, 42, -410, 20), sl, callback=self.sourceCallback) self.w.glyphs = GlyphCollectionView((16, 70, -410, -65), initialMode="list", enableDelete=False, allowDrag=False, selectionCallback=self.glyphCallback) self._sortGlyphs(self.source_font) self.w.desTitle = TextBox((-400, 20, 200, 20), "Destination Fonts:") self.w.destinationFonts = FontList((-400, 42, -15, -115), self.destinationFontList, selectionCallback=self.desCallback) self.w.overwrite = CheckBox((-395, -105, 130, 22), "Overwrite glyphs", callback=self.overwriteCallback, value=self.doOverwrite) self.w.markGlyphs = CheckBox((-395, -84, 100, 22), "Mark Glyphs", callback=self.markCallback, value=self.doMarkGlyphs) self.w.copyButton = Button((-115, -40, 100, 20), 'Copy Glyphs', callback=self.copyCallback) self.w.line = HorizontalLine((10, -50, -10, 1)) self._checkSelection() self._updateDest() ## open the window self.w.open()
def __init__(self): self.w = FloatingWindow((135, 40), "", minSize=(123, 200)) # a checkbox to turn the tool on/off self.w.showPoints = CheckBox((10, 10, -10, 20), 'highlight points', value=True) # add an observer to the drawPreview event addObserver(self, "highlightPoints", "draw") # open window self.setUpBaseWindowBehavior() self.w.open()
def __init__(self, posSize, sqrActive, bcpLengthActive, callback): Group.__init__(self, posSize) self.ctrlHeight = posSize[3] self.sqrActive = sqrActive self.bcpLengthActive = bcpLengthActive self.callback = callback jumpin_Y = 2 self.sqrCheck = CheckBox( (0, jumpin_Y, NET_WIDTH, vanillaControlsSize['CheckBoxRegularHeight']), "Show squarings", value=self.sqrActive, callback=self.sqrCheckCallback) jumpin_Y += vanillaControlsSize['CheckBoxRegularHeight'] self.bcpLengthCheck = CheckBox( (0, jumpin_Y, NET_WIDTH, vanillaControlsSize['CheckBoxRegularHeight']), "Show bcp length", value=self.bcpLengthActive, callback=self.bcpLengthCheckCallback)
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, parameter, posSize, title=None, callback=None): super(ParameterSliderTextInput, self).__init__(posSize) self.parameter = parameter self.callback = callback editTextPosSize = (-45, 0, 45, 22) if title is None: sliderPosSize = (5, 3, -80, 15) elif title is not None: if len(title) > 15: title = '{0}.'.format(title[:16]) title = title.capitalize() sliderPosSize = (120, 3, -55, 15) self.title = TextBox((0, 3, 115, 30), title, sizeStyle='small') if parameter.dissociable: editTextPosSize = (-65, 0, 40, 22) self.checkBox = CheckBox((-22, 5, 22, 25), u'∞', callback=self.setFree, value=True, sizeStyle='mini') self.slider = Slider(sliderPosSize, minValue=parameter.limits[0], maxValue=parameter.limits[1], value=parameter.value, callback=self.valueInput, sizeStyle='small') self.textInput = EditText(editTextPosSize, str(parameter.value), callback=self.valueInput, continuous=False, sizeStyle='small') self.parameter.bind(self)
def __init__(self): self.file_name = 'CustomFilter Project Glyph Sets.plist' folder_path = os.path.dirname(Glyphs.font.filepath) self.file_path = os.path.join(folder_path, self.file_name) self.charsets = OrderedDict() self.parse_plist() self.basic_xml = """<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.08"> <array> {charsets} </array> </plist>""" item_height = 24.0 w_width = 350.0 w_height = item_height * 7 margin = 10 next_y = margin col_1_width = w_width - (margin * 2) item_height = 24 self.w = Window((w_width, w_height), "Insert a font as brace layers") next_y = margin self.w.charset_name_label = TextBox((margin, next_y + 2, col_1_width, item_height), "Character Set Name:", sizeStyle='regular') next_y += item_height self.w.charset_name = EditText((margin, next_y, col_1_width, item_height), callback=self.check_extant_charsets) next_y += item_height + 2 self.w.extant_warning = TextBox((margin, next_y + 2, col_1_width, item_height), "The Character Set already exists and will be overwritten!", sizeStyle='small') self.w.extant_warning.show(False) next_y += (item_height * 0.7) + margin self.w.reopen = CheckBox((margin, next_y, col_1_width, item_height), "Close and Reopen current file", value=True) next_y += item_height + margin self.w.gobutton = Button((margin + (col_1_width / 4), next_y, col_1_width / 2, item_height), 'Make Character Set', callback=self.makeitso) self.w.setDefaultButton(self.w.gobutton) self.w.open()
def createUI(self): x = 10; y = 10; w = 100; h = 30; space = 5; self.size = (200,450); pos = (1200,300); self.minSize = (50,400); self.w = HUDFloatingWindow((pos[0],pos[1],self.size[0],self.size[1]), "ToolsWindow", minSize=(self.minSize[0], self.minSize[1])) h = 30 self.w.innerFillButton = ImageButton((x,y,h,h), imagePath=extPath.ImagePath+extPath.attrImgList[0]+".png", callback=self.handleInnerFill) self.w.innerFillText = TextBox((x+40,y,w,h), "innerFill") y += h + space self.w.penPairButton = ImageButton((x,y,h,h), imagePath=extPath.ImagePath+extPath.attrImgList[1]+".png", callback=self.handlePenPair) self.w.PenPairText = TextBox((x+40,y,w,h), "penPair") y += h + space self.w.dependXButton = ImageButton((x,y,h,h), imagePath=extPath.ImagePath+extPath.attrImgList[2]+".png", callback=self.handleDependX) self.w.dependXText = TextBox((x+40,y,w,h), "dependX") y += h + space self.w.dependYButton = ImageButton((x,y,h,h), imagePath=extPath.ImagePath+extPath.attrImgList[3]+".png", callback=self.handleDependY) self.w.dependYText = TextBox((x+40,y,w,h), "dependY") y += h + space self.w.stokeButton = ImageButton((x,y,h,h), imagePath=extPath.ImagePath+extPath.attrImgList[4]+".png", callback=self.handleStroke) self.w.strokeText = TextBox((x+40,y,w,h), "stroke") y += h + space self.w.deleteButton = ImageButton((x,y,h,h), imagePath=extPath.ImagePath+extPath.attrImgList[5]+".png", callback=self.popDelete) self.w.deleteText = TextBox((x+40,y,w,h), "delete") y += h + space self.w.selectButton = ImageButton((x,y,h,h), imagePath=extPath.ImagePath+extPath.attrImgList[6]+".png", callback=self.handleSelect) self.w.selectText = TextBox((x+40,y,w,h), "select") y += h + space self.w.minimizeBox = CheckBox((x,y,80,20), "", callback=self.minimizeCallback, value=False) y += h +space mode = getExtensionDefault(DefaultKey+".mode") self.w.bind("close", self.close) self.w.open()
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 __init__(self): item_height = 24.0 margin = 10 w_width = 350.0 w_height = (item_height * 5) + margin next_y = margin col_1_width = w_width - (margin * 2) item_height = 24 self.get_prefs('SlantComponentPositions.pref') self.w = Window((w_width, w_height), "Slant Angle") self.w.slant_angle_text = TextBox( (margin, next_y + 2, col_1_width, item_height), "Slant Angle:", sizeStyle='regular') next_y += item_height self.w.slant_angle = EditText( (margin, next_y, col_1_width, item_height), self.prefs.get('slant_angle', '')) next_y += item_height + margin self.w.slant_all_layers = CheckBox( (margin, next_y, col_1_width, item_height), "Slant All Layers", value=int(self.prefs.get('slant_all_layers')), sizeStyle='regular') next_y += item_height + margin self.w.makeitso = Button( (w_width / 4.0, next_y, col_1_width / 2.0, item_height), 'Slant Components', callback=self.makeitso) self.w.setDefaultButton(self.w.makeitso) self.w.open() self.w.center()
class ParameterSliderTextInput(Group): ''' Custom Vanilla object consisting mainly of a Slider & and text input linked together (through a parameter object) ''' def __init__(self, parameter, posSize, title=None, callback=None): super(ParameterSliderTextInput, self).__init__(posSize) self.parameter = parameter self.callback = callback editTextPosSize = (-45, 0, 45, 22) if title is None: sliderPosSize = (5, 3, -80, 15) elif title is not None: if len(title) > 15: title = '{0}.'.format(title[:16]) title = title.capitalize() sliderPosSize = (120, 3, -55, 15) self.title = TextBox((0, 3, 115, 30), title, sizeStyle='small') if parameter.dissociable: editTextPosSize = (-65, 0, 40, 22) self.checkBox = CheckBox((-22, 5, 22, 25), u'∞', callback=self.setFree, value=True, sizeStyle='mini') self.slider = Slider(sliderPosSize, minValue=parameter.limits[0], maxValue=parameter.limits[1], value=parameter.value, callback=self.valueInput, sizeStyle='small') self.textInput = EditText(editTextPosSize, str(parameter.value), callback=self.valueInput, continuous=False, sizeStyle='small') self.parameter.bind(self) def get(self): return self.parameter.get() def enable(self, b): self.slider.enable(b) self.textInput.enable(b) if hasattr(self, checkBox): self.checkBox.enable(b) def valueInput(self, sender): value = sender.get() parameter = self.parameter if value == 'R': parameter.reset() parameter.update() if self.callback is not None: self.callback(self) return elif value != '*': parameter.setInput(value, sender=sender) parameter.update() if self.callback is not None: self.callback(self) def update(self, sender): value = self.parameter.get() self.textInput.set(str(value)) if (value != '*'): self.slider.set(value) if hasattr(self, 'checkBox'): free = self.parameter.hasMaster self.checkBox.set(free) def setFree(self, sender): value = not bool(sender.get()) self.parameter.setFree(value)
class ParameterSliderTextInput(Group): """ Custom Vanilla object consisting mainly of a Slider & and text input linked together (through a parameter object) """ def __init__(self, parameter, posSize, title=None, callback=None): super(ParameterSliderTextInput, self).__init__(posSize) self.parameter = parameter self.callback = callback editTextPosSize = (-65, 0, 40, 22) if title is None: sliderPosSize = (5, 3, -80, 15) elif title is not None: if "point" in title: title = title.lstrip("point") title = "p. " + title title = title.capitalize() sliderPosSize = (70, 3, -80, 15) self.title = TextBox((0, 3, 65, 30), title, sizeStyle="small") if parameter.dissociable: editTextPosSize = (-65, 0, 40, 22) self.checkBox = CheckBox((-22, 5, 22, 25), u"∞", callback=self.setFree, value=True, sizeStyle="mini") self.parameter.bind(self.checkBox) self.slider = Slider( sliderPosSize, minValue=parameter.limits[0], maxValue=parameter.limits[1], value=parameter.value, callback=self.valueInput, sizeStyle="small", ) self.textInput = EditText( editTextPosSize, str(parameter.value), callback=self.valueInput, continuous=False, sizeStyle="small" ) self.parameter.bind(self) self.parameter.bind(self.slider) self.parameter.bind(self.textInput) def enable(self, b): self.slider.enable(b) self.textInput.enable(b) if hasattr(self, checkBox): self.checkBox.enable(b) def valueInput(self, sender): value = sender.get() parameter = self.parameter if value == "R": parameter.reset() parameter.update() if self.callback is not None: self.callback(self) return elif value != "*": parameter.setInput(value, sender=sender) parameter.update() if self.callback is not None: self.callback(self) def setFree(self, sender): value = bool(sender.get()) self.parameter.setFree(value)