def showWindow_(self, sender): if Glyphs.font is None: self.helperWindow(self.warningNoFontOpen) elif len(Glyphs.font.masters) < 2: self.helperWindow(self.warningOnlyOneMaster) else: mastersList = [] for m in Glyphs.font.masters: mastersList.append(m.name) currentMasterIndex = Glyphs.font.masterIndex self.windowWidth = 250 self.windowHeight = 25 * len(mastersList) + 23 + 30 self.w = FloatingWindow((self.windowWidth, self.windowHeight), self.name) self.w.radiomasters = RadioGroup( (10, 10, -10, 25 * len(mastersList)), mastersList, callback=self.changeMaster) self.w.slider = Slider((10, -35, -10, 23), tickMarkCount=len(mastersList), stopOnTickMarks=True, value=currentMasterIndex, minValue=0, maxValue=len(mastersList) - 1, sizeStyle="small", continuous=False, callback=self.changeMasterSlider) self.w.open()
def __init__(self, options, callback): super(ChooseExceptionWindow, self).__init__() self.options = options self.callback = callback self.whichException = options[0] self.w = FloatingWindow((300, 120), 'Choose exception') self.w.optionsRadio = RadioGroup( (MARGIN, MARGIN, -MARGIN, len(options) * 20), options, callback=self.optionsCallback) self.w.optionsRadio.set(0) self.w.cancel = Button( (-(90 * 2 + MARGIN * 2), -(vanillaControlsSize['ButtonRegularHeight'] + MARGIN), 90, vanillaControlsSize['ButtonRegularHeight']), 'Cancel', callback=self.cancelCallback) self.w.submit = Button( (-(90 + MARGIN), -(vanillaControlsSize['ButtonRegularHeight'] + MARGIN), 90, vanillaControlsSize['ButtonRegularHeight']), 'Submit', callback=self.submitCallback) self.setUpBaseWindowBehavior()
def __init__(self, glyph, callback, x, y): self.glyph = glyph self.callback = callback # create the modal dialog (from dialogKit) self.w = ModalDialog((200, 150), "Shapes Tool", okCallback=self.okCallback, cancelCallback=self.cancelCallback) # add some text boxes self.w.xText = TextBox((10, 43, 100, 22), "x") self.w.wText = TextBox((10, 13, 100, 22), "w") self.w.yText = TextBox((100, 43, 100, 22), "y") self.w.hText = TextBox((100, 13, 100, 22), "h") # adding input boxes self.w.xInput = EditText((30, 40, 50, 22), "%i" % x) self.w.wInput = EditText((30, 10, 50, 22)) self.w.yInput = EditText((120, 40, 50, 22), "%i" % y) self.w.hInput = EditText((120, 10, 50, 22)) # a radio shape choice group # (the RadioGroup isn't standaard in dialogKit, this is a vanilla object) self.shapes = ["oval", "rect"] self.w.shape = RadioGroup((10, 70, -10, 22), self.shapes, isVertical=False) self.w.shape.set(0) self.w.open()
def createUI(self): x=10;y=10;w=80;h=30;space=5;self.size=(150,300);pos=(1200,300); self.w = HUDFloatingWindow((pos[0],pos[1], self.size[0],self.size[1]), "DeleteWindow") self.w.deleteRadio = RadioGroup((x, y, w, 190),["penPair", "stroke", "innerFill", "dependX", "dependY"],callback=self.radioGroupCallback) y += space + h + 190 self.w.applyButton = Button((x,y,w,35), "Apply", callback=self.buttonCallback) self.deleteOption = None self.w.open()
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): item_height = 24.0 w_width = 500.0 w_height = item_height * 12 margin = 10 next_y = margin col_1_width = w_width - (margin * 2) item_height = 24 self.get_prefs('copyMetricsFromFont.pref') self.available_layers = dict( ('{} - {}'.format(os.path.basename(font.filepath), master), master) for font in Glyphs.fonts for master in font.masters) self.w = Window((w_width, w_height), "Copy Metrics") self.w.hText_2 = TextBox((margin, next_y, col_1_width, item_height), "Copy metrics from this font/layer:", sizeStyle='regular') next_y += item_height self.w.available_layers = PopUpButton( (margin, next_y, col_1_width, item_height), sorted(self.available_layers.keys() )) # , callback=self.update_brace_value) next_y += item_height + margin metrics_options = [ 'Left sidebearing Only', 'Right sidebearing Only', 'Width Only (keep LSB)', 'Width Only (assign proportionally)', "Left sidebearing and Width", "Left sidebearing and Right sidebearing", 'Width and Right sidebearing', ] self.w.metrics_to_copy = RadioGroup( (margin, next_y, col_1_width, item_height * len(metrics_options)), metrics_options) self.w.metrics_to_copy.set(int(self.prefs.get('metrics_to_copy', 0))) next_y += item_height * len(metrics_options) + margin self.w.gobutton = Button( (margin + (col_1_width / 4), next_y, col_1_width / 2, item_height), 'Copy Metrics', callback=self.makeitso) next_y += item_height self.w.setDefaultButton(self.w.gobutton) self.w.open()
def __init__(self): item_height = 24.0 margin = 10 next_y = margin w_width = 400.0 w_height = item_height * 7 + margin col_1_width = w_width - (margin * 2) self.this_font = Glyphs.font try: self.other_font = [f for f in Glyphs.fonts if f != self.this_font][0] except IndexError: Glyphs.showNotification('Copy kerning for Class from Other Font:', 'There is only 1 file open!') raise self.other_fonts_classes = self.get_other_fonts_classes() self.w = Window((w_width, w_height), "Copy kerning for Class from Other Font") self.w.text_1 = TextBox( (margin, next_y, w_width, item_height), "Copy the kerning for this class to this font:", sizeStyle='small') next_y += item_height self.w.class_to_copy = PopUpButton( (margin, next_y, w_width - (margin * 2), item_height), self.other_fonts_classes, sizeStyle='regular') next_y += item_height + item_height self.w.copy_for_all = RadioGroup( (margin, next_y, w_width, item_height * 2), [ ' Copy only for the current Master', ' Copy for All masters', ]) self.w.copy_for_all.set(0) next_y += (item_height * 2) + margin self.w.gobutton = Button( (margin + (col_1_width / 4), next_y, col_1_width / 2, item_height), 'Copy', callback=self.makeitso) self.w.setDefaultButton(self.w.gobutton) self.w.center() self.w.open()
def __init__(self): self.f = CurrentFont() self.u = getKerningPairsFromUFO.UFOkernReader(self.f) self.absKerning = int(self.u.absoluteKerning) self.amountOfPairs = len(self.u.allKerningPairs) self.textString = ('The font has %s flat kerning pairs.\n' 'Set at %s points, the absolute amount\n' 'of kerning would cover the distance of\n%s.') wWidth = 300 wHeight = 250 if self.amountOfPairs: message = u'CONGRATULATIONS! \U0001F600' else: message = u'Bummer. \U0001F622' self.w = Window((wWidth, wHeight), message) self.w.measurementSystem = RadioGroup((20, 15, -10, 20), ["Metric", "Imperial"], callback=self.parametersChanged, isVertical=False) self.w._pointSize = TextBox((20, 145, -30, 17), 'Point size:') self.w.pointSize = Slider((100, 145, -30, 17), minValue=0, maxValue=1000, callback=self.parametersChanged, value=12) pointSize = int(self.w.pointSize.get()) absKerning = int(self.absKerning * (pointSize / self.f.info.unitsPerEm)) self.w.text = TextBox( (20, 45, -20, 85), self.textString % (self.amountOfPairs, int( self.w.pointSize.get()), self.convertToMetric(absKerning))) self.w.button = Button((20, -40, -30, 20), "Copy kerning pairs to clipboard", callback=self.button) self.w.open()
def __init__(self): self.modifiedGlyph = None self.w = FloatingWindow((400, 170), 'Corner Tool') self.w.getNSWindow().setBackgroundColor_(NSColor.whiteColor()) self.modes = ['Break', 'Build','Pit'] self.objectTypes = {'Build':'Segment', 'Break':'Corner point', 'Pit':'Corner point'} self.parameters = { 'radius': VanillaSingleValueParameter('radius', 20, (-200, 200), numType='int'), 'roundness': VanillaSingleValueParameter('roundness', 1.25, (0, 4), numType='float'), 'depth': VanillaSingleValueParameter('depth', 30, (-100, 100), numType='int'), 'breadth': VanillaSingleValueParameter('breadth', 30, (0, 150), numType='int'), 'bottom': VanillaSingleValueParameter('bottom', 5, (0, 40), numType='int') } self.currentMode = 'Break' self.previewGlyph = None self.w.modes = RadioGroup((15, 15, 70, -15), self.modes, callback=self.changeMode) for i, mode in enumerate(self.modes): setattr(self.w, mode, Group((120, 15, -15, -15))) modeGroup = getattr(self.w, mode) modeGroup.apply = GradientButton((-35, 0, -0, -0), title=u'>', callback=self.apply) modeGroup.infoBox = Box((0, 0, -50, 35)) modeGroup.info = TextBox((10, 8, -50, 20), 'No selection') if i > 0: modeGroup.show(False) self.w.Break.radius = ParameterSliderTextInput(self.parameters['radius'], (0, 60, -25, 25), title='Radius', callback=self.makePreviewGlyph) self.w.Break.roundness = ParameterSliderTextInput(self.parameters['roundness'], (0, 95, -25, 25), title='Roundness', callback=self.makePreviewGlyph) self.w.Pit.depth = ParameterSliderTextInput(self.parameters['depth'], (0, 50, -25, 25), title='Depth', callback=self.makePreviewGlyph) self.w.Pit.breadth = ParameterSliderTextInput(self.parameters['breadth'], (0, 80, -25, 25), title='Breadth', callback=self.makePreviewGlyph) self.w.Pit.bottom = ParameterSliderTextInput(self.parameters['bottom'], (0, 110, -25, 25), title='bottom', callback=self.makePreviewGlyph) addObserver(self, 'preview', 'draw') addObserver(self, 'preview', 'drawInactive') addObserver(self, 'previewSolid', 'drawPreview') addObserver(self, 'makePreviewGlyph', 'mouseDown') addObserver(self, 'makePreviewGlyph', 'mouseDragged') addObserver(self, 'makePreviewGlyph', 'keyDown') addObserver(self, 'makePreviewGlyph', 'keyUp') addObserver(self, 'setControls', 'mouseUp') addObserver(self, 'setControls', 'selectAll') addObserver(self, 'setControls', 'deselectAll') addObserver(self, 'setControls', 'currentGlyphChanged') self.w.bind('close', self.windowClose) self.setControls() self.w.open()
def setOptions(self, options): self.options = options optionsRepresentation = [] for lft, rgt in self.options: row = [] for eachSide in [lft, rgt]: if eachSide.startswith('@') is True: groupRepr = encloseClassTitleInBrackets(eachSide) row.append(groupRepr) else: row.append(eachSide) optionsRepresentation.append(', '.join(row)) if hasattr(self.w, 'optionsRadio') is True: delattr(self.w, 'optionsRadio') self.w.optionsRadio = RadioGroup( (MARGIN, MARGIN, -MARGIN, len(options) * 20), optionsRepresentation, callback=self.optionsCallback)
def __init__(self, parent): self.parent = parent self.w = FloatingWindow((150, 130), "Speed Punk %s" % VERSION, closable = False, autosaveName = 'de_yanone_speedPunk_%s.prefWindow' % (environment), ) self.w.illustrationPositionRadioGroup = RadioGroup((10, 10, -10, 40), ["Outside of glyph", "Outer side of curve"], callback=self.radioGroupCallback, sizeStyle = "small") self.w.curveGainTextBox = TextBox((10, 60, -10, 17), "Gain", sizeStyle = "mini") self.w.curveGainSlider = Slider((10, 70, -10, 25), tickMarkCount=5, callback=self.curveGainSliderCallback, sizeStyle = "small", minValue = curveGain[0], maxValue = curveGain[1], value = self.parent.getPreference('curveGain')) self.w.illustrationPositionRadioGroup.set(self.parent.getPreference('illustrationPositionIndex')) self.w.faderCheckBox = CheckBox((10, 100, -10, 17), "Fader", sizeStyle = "small", callback = self.faderCheckBoxCallback) self.w.faderSlider = Slider((10, 125, -10, 25), sizeStyle = "small", minValue = 0, maxValue = 1.0, value = 1.0, callback = self.faderSliderCallback) self.w.gradientImage = ImageView((10, 150, -10, 15)) self.w.histogramImage = ImageView((10, 150, -10, 15))
def __init__(self): super(VFB2UFO, self).__init__() self.w = FloatingWindow((PLUGIN_WIDTH, 2), PLUGIN_TITLE) self.jumpingY = MARGIN_VER # options button self.w.optionsPopUp = PopUpButton( (MARGIN_HOR, self.jumpingY, NET_WIDTH, vanillaControlsSize['PopUpButtonRegularHeight']), self.inputOptions, callback=self.optionsPopUpCallback) self.jumpingY += vanillaControlsSize[ 'PopUpButtonRegularHeight'] + MARGIN_HOR # suffix option self.w.suffixRadio = RadioGroup( (MARGIN_HOR, self.jumpingY, NET_WIDTH, vanillaControlsSize['ButtonRegularHeight'] * 2), ["From VFB to UFO", "From UFO to VFB"], callback=self.suffixRadioCallback) self.w.suffixRadio.set(0) self.w.suffixRadio.enable(False) self.jumpingY += vanillaControlsSize[ 'ButtonRegularHeight'] * 2 + MARGIN_HOR # convert button self.w.convertButton = Button( (MARGIN_HOR, self.jumpingY, NET_WIDTH, vanillaControlsSize['ButtonRegularHeight']), 'Choose file and convert', callback=self.convertButtonCallback) self.jumpingY += vanillaControlsSize['ButtonRegularHeight'] + MARGIN_HOR self.w.resize(PLUGIN_WIDTH, self.jumpingY) self.setUpBaseWindowBehavior() self.w.open()
def __init__(self): # init window self.win = FloatingWindow((self.pluginWidth, self.pluginHeight), "Broad Nib") # checkBox preview jumpingY = self.marginTop self.win.preview = CheckBox( (self.marginLft, jumpingY, self.netWidth, CheckBoxHeight), "Preview", value=self.preview, sizeStyle='small', callback=self.previewCallback) jumpingY += CheckBoxHeight self.win.shapeRadio = RadioGroup( (self.marginLft + 10, jumpingY, self.netWidth, 32), SHAPE_OPTIONS, sizeStyle='small', callback=self.shapeRadioCallback) self.win.shapeRadio.enable(False) self.win.shapeRadio.set(0) # checkBox draw values jumpingY += self.marginRow + self.win.shapeRadio.getPosSize()[3] - 3 self.win.drawValues = CheckBox( (self.marginLft, jumpingY, self.netWidth, CheckBoxHeight), "Draw Values", value=self.drawValues, sizeStyle='small', callback=self.drawValuesCallback) # oval width jumpingY += self.marginRow + CheckBoxHeight self.win.widthCaption = TextBox( (self.marginLft, jumpingY + 3, self.netWidth * .5, TextBoxHeight), "Width:", sizeStyle='small') self.win.widthEdit = EditText( (self.marginLft + self.netWidth * .5, jumpingY, self.netWidth * .4, EditTextHeight), sizeStyle='small', callback=self.widthEditCallback) # oval height jumpingY += self.marginRow + EditTextHeight self.win.heightCaption = TextBox( (self.marginLft, jumpingY + 3, self.netWidth * .5, TextBoxHeight), "Height:", sizeStyle='small') self.win.heightEdit = EditText( (self.marginLft + self.netWidth * .5, jumpingY, self.netWidth * .4, EditTextHeight), sizeStyle='small', callback=self.heightEditCallback) # oval angle jumpingY += self.marginRow + EditTextHeight self.win.angleCaption = TextBox( (self.marginLft, jumpingY + 3, self.netWidth * .5, TextBoxHeight), "Angle:", sizeStyle='small') self.win.angleEdit = EditText( (self.marginLft + self.netWidth * .5, jumpingY, self.netWidth * .4, EditTextHeight), sizeStyle='small', callback=self.angleEditCallback) # add jumpingY += self.marginRow + EditTextHeight self.win.addToLib = SquareButton( (self.marginLft, jumpingY, self.netWidth, SquareButtonHeight), "Add to lib", sizeStyle='small', callback=self.addToLibCallback) # clear jumpingY += self.marginRow + EditTextHeight self.win.clearLib = SquareButton( (self.marginLft, jumpingY, self.netWidth, SquareButtonHeight), "Clear lib", sizeStyle='small', callback=self.clearLibCallback) jumpingY += self.marginRow + EditTextHeight self.win.expandToForeground = SquareButton( (self.marginLft, jumpingY, self.netWidth, SquareButtonHeight), "Expand", sizeStyle='small', callback=self.expandToForegroundCallback) # managing observers addObserver(self, "_drawBackground", "drawBackground") addObserver(self, "_drawBackground", "drawInactive") addObserver(self, "_drawBlack", "drawPreview") self.win.bind("close", self.closing) # adjust window jumpingY += self.marginRow + EditTextHeight self.win.setPosSize((200, 200, self.pluginWidth, jumpingY)) # opening window self.win.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 __init__(self): self.all_layer_combos = self.get_all_layer_combos() self.instance_values = self.get_instance_values() item_height = 24.0 w_width = 300.0 w_height = item_height * 10 margin = 10 next_y = margin col_1_width = w_width - (margin * 2) col_2_width = (w_width / 2) - (margin * 1.5) item_height = 24 radio_height = 20 * 2 self.get_prefs('addBraceLayers.pref') self.w = Window((w_width, w_height), "Add Layers") self.w.text_1 = TextBox((margin, next_y, col_1_width, item_height), "Layer Combinations:", sizeStyle='regular') next_y += item_height self.w.parent_layers = PopUpButton( (margin, next_y, col_1_width, item_height), self.all_layer_combos, sizeStyle='regular') self.set_all_layer_combos() next_y += item_height + margin self.w.brace_or_bracket = RadioGroup( (margin, next_y, col_1_width, radio_height), ['Bracket Layer [X]', 'Brace Layer {X}'], sizeStyle='regular') self.w.brace_or_bracket.set(int(self.prefs.get('brace_or_bracket', 0))) next_y += radio_height + margin self.w.text_2 = TextBox((margin, next_y, col_1_width, item_height), "Layer Value:", sizeStyle='regular') next_y += item_height self.w.layer_value = EditText( (margin, next_y, col_2_width, item_height), '', sizeStyle='small', placeholder='e.g. 700') self.w.instance_value_popup = PopUpButton( (margin + margin + col_2_width, next_y, col_2_width, item_height), self.instance_values, sizeStyle='regular', callback=self.changeinstance_value) next_y += item_height + margin if self.prefs.get('layer_value') is not None: self.w.layer_value.set(self.prefs.get('layer_value')) self.w.gobutton = Button( (margin + (col_1_width / 4), next_y, col_1_width / 2, item_height), 'Add Layers', callback=self.makeitso) self.w.setDefaultButton(self.w.gobutton) self.w.center() 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.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 build_ui(self, useFloatingWindow=True): self.methods = { 0: "balance", 1: "free", 2: "hobby", } self.methodNames = [ "Balance", "Adjust:", "Hobby:", ] height = 108 width = 200 sliderX = 76 if useFloatingWindow: self.paletteView = FloatingWindow( posSize=(width, height), title="Curve EQ", minSize=(width, height + 16), maxSize=(1000, height + 16), ) else: self.paletteView = Window((width, height)) self.paletteView.group = Group((0, 0, width, height)) y = 8 self.paletteView.group.eqMethodSelector = RadioGroup( (8, y, -8, -36), titles=self.methodNames, callback=self._changeMethod, sizeStyle="small", ) y += 22 self.paletteView.group.eqCurvatureSlider = Slider( (sliderX, y, -8, 17), callback=self._changeCurvatureFree, minValue=0.5, maxValue=1.0, value=0.75, # Will be replaced by saved value sizeStyle="small", ) y += 25 self.paletteView.group.eqHobbyTensionSlider = Slider( (sliderX, y, -8, 17), tickMarkCount=5, callback=self._changeTension, minValue=0.5, maxValue=1.0, sizeStyle="small", ) if useFloatingWindow: y = height - 32 self.paletteView.group.eqSelectedButton = Button( (8, y, -8, 25), "Equalize Selected", callback=self._eqSelected, sizeStyle="small", )
def __init__(self, parent): self.parent = parent self.w = FloatingWindow((150, 130), "Speed Punk %s" % VERSION, closable = False, autosaveName = 'de_yanone_speedPunk_%s.prefWindow' % (environment), ) self.w.illustrationPositionRadioGroup = RadioGroup((10, 10, -10, 40), ( Glyphs.localize({ 'en': 'Outside of glyph', 'de': 'Außen an Form', 'fr': 'Éxterieur de la forme', 'es': 'Exterior del glifo', 'pt': 'Fora do glifo', }), Glyphs.localize({ 'en': 'Outer side of curve', 'de': 'Außen am Pfad', 'fr': 'Éxterieur de la courbe', 'es': 'Exterior del trazo', 'pt': 'Fora da curva', }), ), callback=self.radioGroupCallback, sizeStyle = "small") self.w.curveGainTextBox = TextBox((10, 60, -10, 17), Glyphs.localize({ 'en': 'Gain', 'de': 'Stärke', 'fr': 'Volume', 'es': 'Volumen', 'pt': 'Volume', }), sizeStyle = "mini") self.w.curveGainSlider = Slider((10, 70, -10, 25), tickMarkCount=5, callback=self.curveGainSliderCallback, sizeStyle = "small", minValue = curveGain[0], maxValue = curveGain[1], value = self.parent.getPreference('curveGain')) self.w.illustrationPositionRadioGroup.set(self.parent.getPreference('illustrationPositionIndex')) self.w.faderCheckBox = CheckBox((10, 100, -10, 17), Glyphs.localize({ 'en': 'Fade', 'de': 'Ausblenden', 'fr': 'Opacité', 'es': 'Opacidad', 'pt': 'Opacidade', }), sizeStyle = "small", callback = self.faderCheckBoxCallback) self.w.faderSlider = Slider((10, 125, -10, 25), sizeStyle = "small", minValue = 0, maxValue = 1.0, value = 1.0, callback = self.faderSliderCallback) self.w.gradientImage = ImageView((10, 150, -10, 15)) self.w.histogramImage = ImageView((10, 150, -10, 15))
def __init__(self): padding = 10 lineHeight = 20 buttonHeight = 20 width = 123 height = lineHeight * 6 + buttonHeight * 4 + padding * 9 self.w = FloatingWindow((width, height), title='spacing') x = y = padding self.w.makeGroupButton = Button((x, y, -padding, buttonHeight), 'make group', callback=self.makeGroupCallback, sizeStyle='small') y += buttonHeight + padding self.w.side = RadioGroup((x, y, -padding, lineHeight), ['left', 'right'], isVertical=False, callback=self.updateViewsCallback, sizeStyle='small') self.w.side.set(0) y += lineHeight + padding self.w.copySpacingButton = Button((x, y, -padding, buttonHeight), 'copy margin', callback=self.copySpacingCallback, sizeStyle='small') y += buttonHeight + padding self.w.useBeam = CheckBox((x, y, -padding, lineHeight), 'use beam', callback=self.useBeamCallback, sizeStyle='small') y += lineHeight self.w.allLayers = CheckBox((x, y, -padding, lineHeight), 'all layers', callback=self.updateViewsCallback, sizeStyle='small') y += lineHeight + padding self.w.opacityLabel = TextBox((x, y, -padding, lineHeight), 'opacity:', sizeStyle='small') y += lineHeight self.w.opacity = Slider((x, y, -padding, lineHeight), value=0.4, minValue=0.0, maxValue=0.9, callback=self.updateViewsCallback, sizeStyle='small') y += lineHeight + padding self.w.exportButton = Button((x, y, -padding, buttonHeight), 'export…', callback=self.exportCallback, sizeStyle='small') y += buttonHeight + padding self.w.importButton = Button((x, y, -padding, buttonHeight), 'import…', callback=self.importCallback, sizeStyle='small') y += buttonHeight + padding self.w.verbose = CheckBox((x, y, -padding, lineHeight), 'verbose', value=True, sizeStyle='small') self.setUpBaseWindowBehavior() addObserver(self, "drawGlyphsInGroup", "spaceCenterDraw") self.w.getNSWindow().setTitlebarAppearsTransparent_(True) self.w.open()
def populateWindow(self): y = 10 x = 10 self.w.italicAngleLabel = TextBox((x, y + 4, 100, 22), 'Italic Angle', sizeStyle="small") x += 100 self.w.italicAngle = EditText((x, y, 40, 22), '', sizeStyle="small", callback=self.calcItalicCallback) y += 30 x = 10 self.w.crossHeightLabel = TextBox((x, y + 4, 95, 22), 'Cross Height', sizeStyle="small") x += 100 self.w.crossHeight = EditText((x, y, 40, 22), '', sizeStyle="small", callback=self.calcItalicCallback) x += 50 self.w.crossHeightSetUC = Button((x, y, 65, 22), 'Mid UC', sizeStyle="small", callback=self.calcItalicCallback) x += 75 self.w.crossHeightSetLC = Button((x, y, 65, 22), 'Mid LC', sizeStyle="small", callback=self.calcItalicCallback) y += 30 x = 10 self.w.italicSlantOffsetLabel = TextBox((x, y + 4, 100, 22), 'Italic Slant Offset', sizeStyle="small") x += 100 self.w.italicSlantOffset = EditText((x, y, 40, 22), '', sizeStyle="small", callback=self.calcItalicCallback) x += 60 y += 30 x = 10 self.w.refresh = Button((x, y, 140, 22), u'Values from Current', callback=self.refresh, sizeStyle="small") y += 30 self.w.fontSelection = RadioGroup((x, y, 120, 35), ['Current Font', 'All Fonts'], sizeStyle="small") self.w.fontSelection.set(0) x += 160 self.w.glyphSelection = RadioGroup( (x, y, 120, 55), ['Current Glyph', 'Selected Glyphs', 'All Glyphs'], sizeStyle="small") self.w.glyphSelection.set(0) y += 60 x = 10 self.w.setInFont = Button((x, y, 140, 22), 'Set Font Italic Values', sizeStyle="small", callback=self.setInFontCallback) x += 160 self.w.italicize = Button((x, y, 140, 22), 'Italicize Glyphs', sizeStyle="small", callback=self.italicizeCallback) y += 25 self.w.makeReferenceLayer = CheckBox( (x, y, 145, 22), 'Make Reference Layer', value=getExtensionDefault(self.DEFAULTKEY_REFERENCE, False), sizeStyle="small", callback=self.makeReferenceLayerCallback) x = 10 self.refresh() if self.getItalicAngle() == 0 and CurrentFont() is not None: self.setCrossHeight((CurrentFont().info.capHeight or 0) / 2)