def mouseDown(self, point): if self.isAtomic: return event = extractNSEvent(point) modifiers = getActiveEventTool().getModifiers() option = modifiers['optionDown'] command = modifiers['commandDown'] if not all([option, command]): if not event["shiftDown"]: self.currentGlyph.selectedElement = [] try: self.px, self.py = point['point'].x, point['point'].y except: return self.currentGlyph.pointIsInside((self.px, self.py), event["shiftDown"]) self.currentViewSliderList.deepComponentAxesList.set([]) self.currentViewSliderList.deepComponentName.set("") if self.currentGlyph.selectedElement: self.setListWithSelectedElement() if point[ 'clickCount'] == 2 and not self._currentSourceValidated( ): popover.EditPopoverAlignTool(self, point['point'], self.currentGlyph) else: self.currentGlyph.setTransformationCenterToSelectedElements( (point['point'].x, point['point'].y)) addObserver(self, 'mouseDragged', 'mouseDragged') if not self.isAtomic: self.glyphInspectorWindow.deepComponentListItem.setList() self.glyphInspectorWindow.transformationItem.setTransformationsField( )
def scrollWheel(self, info): # print(info) alt = extractNSEvent(info)['optionDown'] deltaY = info.deltaY() deltaX = info.deltaX() if alt: scale = self.scale scale += (deltaY / (abs(deltaY) + eps) * self.scrollWheel_ZoomSensibility) / self.scale if scale > 0: self.scale = scale else: if not self.verticalMode: self.scrollX = 0 scroll = self.scroll scroll -= (deltaY / (abs(deltaY) + eps) * 50) / self.scale if scroll < 0: scroll = 0 self.scroll = scroll else: self.scroll = 0 scrollX = self.scrollX scrollX += (deltaX / (abs(deltaX) + eps) * 50) / self.scale if scrollX < 0: scrollX = 0 self.scrollX = scrollX self.w.canvas.update()
def keyUp(self, info): self.glyph = self.ui.glyph modifiers = extractNSEvent(info['event']) command = modifiers["commandDown"] shift = modifiers["shiftDown"] char = info['event'].characters() if command and shift and char == "A": self.balance(self.glyph)
def keyDown(self, sender): self.glyph = CurrentGlyph() if self.glyph is None or not len(self.glyph): return command = extractNSEvent(sender['event'])["commandDown"] if sender['event'].characters() == "r": self.activDraw = 1 self.keydidUp = 0 if sender['event'].characters() == "r" and command: self.activDraw = 0 UpdateCurrentGlyphView()
def keyDown(self, event): event = extractNSEvent(event) if event["commandDown"] and event["shiftDown"] and event[ "keyDown"] == "r": currentTool = getActiveEventTool() if not currentTool.__class__ == SlightlyBetterTransformTool: # Switch to the tool setActiveEventTool("SlightlyBetterTransformTool") else: # The tool was already active, switch back to the Edit tool setActiveEventToolByIndex(0)
def scrollWheel(self, info): alt = extractNSEvent(info)['optionDown'] if not alt: return scale = self.scale delta = info.deltaY() sensibility = .009 scale += (delta / abs(delta) * sensibility) / self.scale minScale = .005 if scale > minScale: self.scale = scale self.update()
def mouseDragged(self, info): command = extractNSEvent(info)['commandDown'] deltaX = info.deltaX() / self.scale deltaY = info.deltaY() / self.scale if not command: self.translateX += deltaX self.translateY -= deltaY elif self.ui.reference_list_selection and self.name == "ReferenceViewer": currentSetting = self.ui.referenceViewerSettings[ self.ui.reference_list_selection[0]] currentSetting["x"] += deltaX currentSetting["y"] -= deltaY UpdateCurrentGlyphView() self.update()
def keyDown(self, info): if self.isAtomic: return event = extractNSEvent(info) try: character = info["event"].characters() except: return modifiers = [ event['shiftDown'] != 0, event['capLockDown'] != 0, event['optionDown'] != 0, event['controlDown'] != 0, event['commandDown'] != 0, ] arrowX = 0 arrowY = 0 if event['down']: arrowY = -1 elif event['up']: arrowY = 1 elif event['left']: arrowX = -1 elif event['right']: arrowX = 1 inputKey = [arrowX, arrowY] if self.isAtomic: return if modifiers[4] and character == 'z': self.doUndo() elif modifiers[4] and modifiers[0] and character == 'Z': self.doRedo() if character == ' ': self.currentGlyph.selectedSourceAxis = None if len(self.currentGlyph ) and self.currentGlyph.type != "deepComponent": SetCurrentLayerByName("foreground") self.updateDeepComponent() # self.currentViewSourceList.glyphVariationAxesList.setSelection([]) self.glyphInspectorWindow.sourcesItem.sourcesList.setSelection([]) self.glyphInspectorWindow.axesItem.axesList.setSelection([]) self.glyphView.setSelectedSource() self.disabledEditingUIIfValidated() if self._currentSourceValidated(): return self.currentGlyph.keyDown((modifiers, inputKey, character))
def keyDown(self, event): if self.isValid: ns_event = extractNSEvent(event) leftDown = ns_event['left'] rightDown = ns_event['right'] delta = self.increment if self.shiftDown: multiplier = self.glyphViewShiftIncrement if self.commandDown: multiplier = self.glyphViewCommandShiftIncrement delta *= multiplier if leftDown: self.moveMargin(-delta) if rightDown: self.moveMargin(delta)
def scrollWheel(self, info): alt = extractNSEvent(info)['optionDown'] delta = info.deltaY() sensibility = .002 if not alt: scroll = self.scroll scroll -= (delta / abs(delta) * 50) / self.scale if scroll < 0: scroll = 0 self.scroll = scroll else: scale = self.scale scale += (delta / abs(delta) * sensibility) / self.scale minScale = .005 if scale > minScale: self.scale = scale self.update()
def customShortcutCallback(self, info): event = extractNSEvent(info['event']) for toolName in self.hotkeys: hotkey = self.hotkeys[toolName] if len(hotkey.split(' ')) > 2: continue if len(hotkey.split(' ')) == 2: char, modifier = hotkey.split(' ') if event['keyDownWithoutModifiers'] == char and event[modifierDict[modifier]] != 0: setActiveEventTool(toolName) break else: char = hotkey.split(' ')[0] if event['keyDownWithoutModifiers'] == char: setActiveEventTool(toolName) break
def keyDown(self, info): char = info.characters() command = extractNSEvent(info)['commandDown'] if char == "i": self.inverse = abs(self.inverse - 1) self.w.canvas.update() if command and char == "+": self.scale += self.keyDown_ZoomSensibility elif command and char == "-": scale = self.scale scale -= self.keyDown_ZoomSensibility if scale > 0: self.scale = scale self.w.canvas.update()
def keyDown(self, event): modifiers = self.getModifiers() event = extractNSEvent(event) arrowDown = True in [ event["left"], event["right"], event["up"], event["down"] ] # If there's a selection: if self.selectionBounds: if event["keyDownWithoutModifiers"] == "\x1b": # Escape key -- deselect handles self.selectedHandle = None self.updateView() elif event["keyDownWithoutModifiers"] == "\t": # Tab key and option tab -- rotate the choice of selected handle if not self.selectedHandle: self.selectedHandle = "SW" elif modifiers["optionDown"]: self.selectedHandle = self.handleNeighbors[ self.selectedHandle][0] else: self.selectedHandle = self.handleNeighbors[ self.selectedHandle][1] self.updateView() elif arrowDown: # Arrow keys -- move the selection delta = (0, 0) value = 1 if modifiers["shiftDown"]: value *= 10 if modifiers["commandDown"]: value *= 10 if event["left"]: delta = (-value, 0) elif event["right"]: delta = (value, 0) elif event["up"]: delta = (0, -value) elif event["down"]: delta = (0, value) self.glyph.prepareUndo("Transform!") self.moveSelection(delta) self.glyph.performUndo()
def keyWasPressed(self, info): glyph = self.glyph if CurrentGlyph(): glyph = CurrentGlyph() self.glyph = glyph if glyph is not None: event = info["event"] characters = event.characters() shiftDown = extractNSEvent(info)['shiftDown'] if shiftDown and characters == pressed_key: if self.status == 0: addObserver(self, "viewDidChangeGlyph", "viewDidChangeGlyph") addObserver(self, "glyphChanged", "draw") addObserver(self, "drawText", "draw") self.updateGlyph() self.updateGlyphView() self.status = 1 self.updateGlyph() else: self.status = 0 removeObserver(self, "draw") self.updateGlyph() self.updateGlyphView() addObserver(self, "viewDidChangeGlyph", "viewDidChangeGlyph") addObserver(self, "glyphChanged", "draw")
def modifiersChanged(self, event): ns_event = extractNSEvent(event) self.shiftDown = ns_event['shiftDown'] self.commandDown = ns_event['commandDown']