Пример #1
0
    def keyDown(self, info):
        """
            126
        123     124
            125
        """
        modifiers = getActiveEventTool().getModifiers()

        shift = modifiers['shiftDown']
        command = modifiers['commandDown']

        key = info['event'].keyCode()

        self.deepCompoWillDrag = True

        move = lambda x: int(str(x) + "".zfill(sum([shift, shift*command])))

        if key == 123:
            self.deepCompo_DeltaX = move(-1)

        elif key == 124:
            self.deepCompo_DeltaX = move(1)
        
        elif key == 125:
            self.deepCompo_DeltaY = move(-1)
            
        elif key == 126:
            self.deepCompo_DeltaY = move(1)
            
        self.dragDeepComponent()
Пример #2
0
    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(
            )
Пример #3
0
 def keyDown(self, sender):
     # self.getGlyph()
     if self.g is None: return
     if sender['event'].characters() == "r":
         self.activDraw = 1
         self.keydidUp = 0
     if sender['event'].characters() == "r" and getActiveEventTool(
     ).getModifiers()['commandDown']:
         self.activDraw = 0
     UpdateCurrentGlyphView()
Пример #4
0
 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)
Пример #5
0
    def mouseDragged(self, point, delta):
        modifiers = getActiveEventTool().getModifiers()
        option = modifiers['optionDown']
        command = modifiers['commandDown']
        shift = modifiers['shiftDown']

        def shiftLock(dx, dy, x, y):
            if abs(dx) > abs(dy):
                return x, 0
            return 0, y

        if command and option:
            return

        elif option:
            rotation = angle(self.px, self.py, *point)
            self.RCJKI.currentGlyph.setRotationAngleToSelectedElements(
                rotation, append=False)

        elif command:
            deltax = int(point.x - self.deltax)
            deltay = int(point.y - self.deltay)
            sensibility = 500
            deltax /= sensibility
            deltay /= sensibility
            if shift:
                deltax, deltay = shiftLock(delta.x, delta.y, deltax, deltay)
            self.RCJKI.currentGlyph.setScaleToSelectedElements(
                (round(deltax, 3), round(deltay, 3)))

        else:
            x = int(point.x - self.deltax)
            y = int(point.y - self.deltay)
            if shift:
                x, y = shiftLock(delta.x, delta.y, x, y)
            self.RCJKI.currentGlyph.setPositionToSelectedElements((x, y))

        self.deltax, self.deltay = point
        UpdateCurrentGlyphView()
Пример #6
0
 def isValid(self):
     return getActiveEventTool(
     ).__class__.__name__ in ACTIVE_TOOLS and self.glyph is not None
Пример #7
0
 def open(self):
     self.popover.open(
         parentView=getActiveEventTool().getNSView(), 
         relativeRect=self.relativeRect
         )
Пример #8
0
 def __init__(self, size, point):
     eventTool = getActiveEventTool()
     p,v = makeEmptyPopover(size, point, eventTool.getNSView())
     p.controller = self
     self._popover = p
     self._viewPos = v