def __init__(self): col = getDefaultColor("glyphViewSelectionColor") self.glyphViewSelectionColor = (col.redComponent(), col.greenComponent(), col.blueComponent(), col.alphaComponent()) self.rightMarginIsSelected = False self.leftMarginIsSelected = False self.glyph = None self.font = None self.mousePoint = None self.mouseDelta = None self.deltaX = 0 self.threshold = 5 self.increment = 1 self.glyphViewShiftIncrement = getDefault("glyphViewShiftIncrement") self.glyphViewCommandShiftIncrement = getDefault( "glyphViewCommandShiftIncrement") self.shiftDown = False self.commandDown = False addObserver(self, 'mouseDragged', 'mouseDragged') addObserver(self, 'mouseUp', 'mouseUp') addObserver(self, 'mouseDown', 'mouseDown') addObserver(self, 'keyDown', 'keyDown') addObserver(self, 'modifiersChanged', 'modifiersChanged') addObserver(self, 'draw', 'draw') addObserver(self, 'viewDidChangeGlyph', 'viewDidChangeGlyph')
def getColorTheme(): try: tokens = dict(getDefault("PyDETokenColors")) except: tokens = {} print('no custom colors defined.\n') background = getDefaultColor("PyDEbackgroundColor") highlight = getDefaultColor("PyDEHightLightColor") return { 'background': background, 'highlight': highlight, 'tokens': tokens, }
def __init__(self, menuTitle, menuItems, width=50): col = getDefaultColor("spaceCenterBeamStrokeColor") self.sel_color = (col.redComponent(), col.greenComponent(), col.blueComponent(), col.alphaComponent()) self.title = menuTitle self.items = menuItems self.width = width addObserver(self, "glyphWindowDidOpenObserver", "glyphWindowDidOpen")
def draw(self, scale): if self.isDragging() and self.pStart and self.pEnd: r = self.getMarqueRect() if r: color = getDefaultColor('glyphViewSelectionMarqueColor') color.set() path = NSBezierPath.bezierPathWithRect_(r) path.fill() return self.drawSelection(scale)
def getFlattenedAlpha(self, color): # flatten transparency of eye, using background color preference r, g, b, a = color r2, g2, b2, a2 = NSColorToRgba( getDefaultColor("glyphViewBackgroundColor")) r3 = r2 + (r - r2) * a g3 = g2 + (g - g2) * a b3 = b2 + (b - b2) * a return (r3, g3, b3, 1)
def __init__(self): self.col_font_dim = self.getFlattenedAlpha( NSColorToRgba(getDefaultColor("glyphViewMetricsColor"))) self.col_glob_guides = self.getFlattenedAlpha( NSColorToRgba(getDefaultColor("glyphViewGlobalGuidesColor"))) self.col_loc_guides = self.getFlattenedAlpha( NSColorToRgba(getDefaultColor("glyphViewLocalGuidesColor"))) r, g, b, a = NSColorToRgba(getDefaultColor("glyphViewBluesColor")) self.col_blues = (r, g, b, 1) r, g, b, a = NSColorToRgba( getDefaultColor("glyphViewFamilyBluesColor")) self.col_fBlues = (r, g, b, 1) self.scale = 0 self.radius = 0 addObserver(self, "drawBackground", "drawBackground") addObserver(self, "drawBackground", "drawBackgroundInactive")
def becomeActive(self): self.glyph = None self.cachedGlyph = None # A copy of the glyph to use as a reference, to avoid accumulating rounding errors self.selectionBounds = None # The selection rect that the user is modifying self.cachedSelectionBounds = None # The selection rect from the original cached set of points self.selectionHandles = None # The handle locaitons on the selectionBounds self.selectedHandle = None # Currently selected handle, for nudging and things # Current state of the transformation self.currentOffset = (0, 0) self.currentScale = (1, 1) self.handleNeighbors = { "N": ("NW", "NE"), # Previous and next cardinal directions "NE": ("N", "E"), "E": ("NE", "SE"), "SE": ("E", "S"), "S": ("SE", "SW"), "SW": ("S", "W"), "W": ("SW", "NW"), "NW": ("W", "N") } self.selectionColor = self.NSColorToRGBA( getDefaultColor("glyphViewSelectionColor")) addObserver(self, "glyphChanged", "viewDidChangeGlyph") addObserver(self, "glyphDidUndo", "didUndo") # To help with the Undo self.needsUndo = False # Go ahead and collect the glyph info self.glyphChanged(None)
def __init__(self): ## add observer when the glyph view draws the content addObserver(self, "myDraw", "drawBackground") ## get the stroke color from the defaults self.strokeColor = getDefaultColor("glyphViewStrokeColor")
def drawPreviewNeighBors(self, info): fillColor = getDefaultColor("glyphViewFillColor") fillColor.set() self._drawNeightborsGlyphs(info["glyph"], stroke=False)
def __init__(self): self.fontAnchors = FontAnchors(CurrentFont()) self.showPreview = getExtensionDefault( "%s.%s" % (extensionID, "preview"), True) nscolor = getDefaultColor("glyphViewPreviewFillColor") self.preview_color = (nscolor.redComponent(), nscolor.greenComponent(), nscolor.blueComponent(), nscolor.alphaComponent()) columnDescriptions = [ { "title": "Show", "cell": vanilla.CheckBoxListCell(), "width": 35 }, { "title": "Name", "typingSensitive": True, "editable": False }, ] self.w = vanilla.FloatingWindow((170, 490), "Anchor Overlay", closable=False) y = 10 self.w.showAnchors_label = vanilla.TextBox((10, y, -10, 20), "Show anchors:", sizeStyle="small") y += 25 self.w.showAnchors = vanilla.List( (10, y, -10, 150), self.fontAnchors.getAnchorNames(), columnDescriptions=columnDescriptions, drawFocusRing=True, editCallback=self.updateAnchorVisibility, doubleClickCallback=self.selectGlyphsWithAnchorName, selectionCallback=self.updateAnchoredGlyphsList, ) y += 160 self.w.markAnchors_label = vanilla.TextBox((10, y, 150, 20), "Show mark glyphs:", sizeStyle="small") y += 25 self.w.markAnchors = vanilla.List( (10, y, 150, 180), [], #self.fontAnchors.anchorGlyphs.keys(), columnDescriptions=columnDescriptions, editCallback=self.updateMarkVisibility, doubleClickCallback=self.gotoGlyph, allowsMultipleSelection=False, allowsEmptySelection=False, ) y += 188 #self.w.drawPreview = vanilla.CheckBox((10, y, -10, -10), "Show in preview mode", # callback=self.setShowPreview, # value=self.showPreview, # sizeStyle="small" #) #self.w.displayAnchors = vanilla.CheckBox((10, y+25, -10, -10), "Show anchors", # callback=self.setShowAnchors, # value=getGlyphViewDisplaySettings()["Anchors"], # sizeStyle="small" #) y += 2 self.w.alignAnchors_label = vanilla.TextBox((10, y, -10, -10), "Align selected anchors:", sizeStyle="small") y += 21 self.w.centerXButton = vanilla.Button( (10, y, 72, 25), "Points X", callback=self.centerAnchorX, sizeStyle="small", ) self.w.centerYButton = vanilla.Button( (88, y, 72, 25), "Points Y", callback=self.centerAnchorY, sizeStyle="small", ) y += 26 self.w.baselineButton = vanilla.Button( (10, y, 46, 25), "base", callback=self.moveAnchorBaseline, sizeStyle="small", ) self.w.xheightButton = vanilla.Button( (62, y, 46, 25), "x", callback=self.moveAnchorXheight, sizeStyle="small", ) self.w.capheightButton = vanilla.Button( (114, y, 46, 25), "cap", callback=self.moveAnchorCapheight, sizeStyle="small", ) self.setUpBaseWindowBehavior() self.addObservers() self.w.showAnchors.setSelection([]) self.w.open()