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 selectionCallback(self, sender): items = sender.get() if len(sender.getSelection()) > 0: item = items[sender.getSelection()[0]] if item['active'] != 1: sender.setSelection(self.prevSelection) else: toolName = item['tool'] if not self.isDropping: setActiveEventTool(toolName) self.prevSelection = sender.getSelection()
def additionContectualMenuItems(self): # Up to RF 1.6 selectText = 'Turn On Non-Selected' if self.settings[ 'selectOnly'] else 'Turn Off Non-Selected' smoothText = 'Turn Off Smooths' if self.settings[ 'smoothsToo'] else 'Turn On Smooths' simpliText = 'Turn Off Simplified Mode' if self.settings[ 'simplified'] else 'Turn On Simplified Mode' setActiveEventTool( 'ScalingEditTool' ) # needs a reset if using trackpad for some reason. This bug is in the default Edit Tool also... return [('Angle Keeping Override (cmd-key)', [(selectText, self.menuCallSelected), (smoothText, self.menuCallSmooths)]), (simpliText, self.menuCallSimplified)]
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 additionContectualMenuItems(self): selectText = 'Turn On Non-Selected' if self.settings['selectOnly'] else 'Turn Off Non-Selected' smoothText = 'Turn Off Smooths' if self.settings['smoothsToo'] else 'Turn On Smooths' simpliText = 'Turn Off Simplified Mode' if self.settings['simplified'] else 'Turn On Simplified Mode' setActiveEventTool('ScalingEditTool') # needs a reset if using trackpad for some reason. This bug is in the default Edit Tool also... return [('Angle Keeping Override (cmd-key)', [(selectText, self.menuCallSelected), (smoothText, self.menuCallSmooths)]), (simpliText, self.menuCallSimplified)]
return if not self.kernel: self.getKernel() level = 0 self._insides = {} self._hits = {} self._misses = {} nsPathObject = self.getGlyph().getRepresentation("defconAppKit.NSBezierPath") for pos, val in self.kernel.items(): thisPos = samplePoint[0]+pos[0]*self.prefs['chunkSize'], samplePoint[1]+pos[1]*self.prefs['chunkSize'] a = math.atan2(pos[0], pos[1]) if thisPos not in self._insides: self._insides[thisPos] = nsPathObject.containsPoint_(thisPos) if not self._insides[thisPos]: level += self.kernel.get(pos) self._hits[thisPos] = self.kernel.get(pos) else: self._misses[thisPos] = self.kernel.get(pos) self.pts.append((samplePoint, level, self.prefs['toolDiameter'])) self.samples[(samplePoint, self.prefs['toolDiameter'])] = dict(level=level) self.dupes.add((self.prefs['toolDiameter'], samplePoint)) return level def getToolbarTip(self): return 'LightMeter' p = LightMeterTool() installTool(p) setActiveEventTool('LightMeterTool')