Beispiel #1
0
 def on_drag_begin(self):
     Director.scene.state.selectOnUp = None
     self.dragging = True
     if is_ctrl_down():
         self.box.on_rotate_begin(self)
         self.dragfunc = self.box.on_rotate
     else:
         self.box.on_scale_begin(self)
         self.dragfunc = self.box.on_scale
Beispiel #2
0
 def test_cursor(self):
     if self.dragging:
         return
     if is_ctrl_down():
         #TODO: ctrl can't be tested when window doesn't have focus:(
         Mouse.cursor = Opioid2D.ResourceManager.get_image(
             get_image_path("rotate.png"), (0.28, 0.16))
     else:
         Mouse.cursor = Opioid2D.ResourceManager.get_image(
             get_image_path("scale.png"), (0, 0))
Beispiel #3
0
 def handle_mousebuttondown(self, event):
     if self.mouse_locked_by or self.busy:
         return
     shiftDown = is_shift_down()
     ctrlDown = is_ctrl_down()
     x, y = event.pos
     if shiftDown and ctrlDown:
         self.interface.add_object( position=(x,y))
     else:
         node = self.scene.mouse_manager.pick_selection(x,y,
                                         wx.GetApp().selectedObjectDict)
         if node is not None:
             self.selectOnUp = weakref.ref(node)
         else:
             wx.CallAfter(self.interface.set_selection,[])
Beispiel #4
0
 def handle_mousebuttondown(self, event):
     if self.mouse_locked_by or self.busy:
         return
     shiftDown = is_shift_down()
     ctrlDown = is_ctrl_down()
     x, y = event.pos
     if shiftDown and ctrlDown:
         self.interface.add_object(position=(x, y))
     else:
         node = self.scene.mouse_manager.pick_selection(
             x, y,
             wx.GetApp().selectedObjectDict)
         if node is not None:
             self.selectOnUp = weakref.ref(node)
         else:
             wx.CallAfter(self.interface.set_selection, [])
Beispiel #5
0
 def handle_keydown(self, ev):
     # nudge keys
     if self.busy:
         return
     nudge = 1
     shiftDown = is_shift_down()
     ctrlDown = is_ctrl_down()
     if shiftDown:
         nudge = nudge * 10
     if ctrlDown:
         nudge = nudge * 0.1
     if ev.key == Opioid2D.K_LEFT:
         self.interface.nudge((-nudge, 0))
     elif ev.key == Opioid2D.K_RIGHT:
         self.interface.nudge((nudge, 0))
     elif ev.key == Opioid2D.K_UP:
         self.interface.nudge((0, -nudge))
     elif ev.key == Opioid2D.K_DOWN:
         self.interface.nudge((0, nudge))
     elif ev.key == Opioid2D.K_DELETE:
         from pig.editor.util import undoable_delete_nodes
         deletelist = []
         for ref in wx.GetApp().selectedObjectDict.itervalues():
             if isinstance(ref(), Opioid2D.public.Node.Node):
                 deletelist.append(ref())
         undoable_delete_nodes(deletelist)
     elif ev.key == Opioid2D.K_s and ctrlDown:
         wx.CallAfter(save_scene)
     elif ev.key == Opioid2D.K_a and ctrlDown:
         wx.CallAfter(save_scene_as)
     elif ev.key == Opioid2D.K_q and ctrlDown:
         wx.CallAfter(self.interface.quit)
     elif ev.key == Opioid2D.K_w and ctrlDown:
         wx.CallAfter(wx.GetApp().raise_all_frames)
     elif ev.key == Opioid2D.K_c and ctrlDown:
         wx.CallAfter(self.interface.copy_selected)
     elif ev.key == Opioid2D.K_x and ctrlDown:
         wx.CallAfter(self.interface.cut_selected)
     elif ev.key == Opioid2D.K_v and ctrlDown:
         wx.CallAfter(self.interface.paste_clipboard)
     elif ev.key == Opioid2D.K_z and ctrlDown:
         if shiftDown:
             wx.GetApp().history.small_undo()
         else:
             wx.GetApp().history.undo()
     elif ev.key == Opioid2D.K_y and ctrlDown:
         if shiftDown:
             wx.GetApp().history.small_redo()
         else:
             wx.GetApp().history.redo()
     elif ev.key == Opioid2D.K_u and ctrlDown:
         try:
             app = wx.GetApp()
             selected = app.get_selection()
             if selected:
                 wx.CallAfter(
                     app.get_object_frame(
                         selected.popitem()[0]).pugWindow.view_source_code)
             else:
                 wx.CallAfter(
                     app.get_object_frame(Opioid2D.Director.scene).
                     pugWindow.view_source_code)
             wx.CallAfter(app.raise_all_frames)
         except:
             pass
     elif ev.key == Opioid2D.K_p and ctrlDown:
         try:
             app = wx.GetApp()
             selected = app.get_selection()
             if selected:
                 wx.CallAfter(
                     app.get_object_frame(
                         selected.popitem()[0]).pugWindow.open_shell)
             else:
                 wx.CallAfter(
                     app.get_object_frame(
                         Opioid2D.Director.scene).pugWindow.open_shell)
             wx.CallAfter(app.raise_all_frames)
         except:
             pass
Beispiel #6
0
 def handle_keydown(self, ev):
     # nudge keys
     if self.busy:
         return
     nudge = 1
     shiftDown = is_shift_down()
     ctrlDown = is_ctrl_down()
     if shiftDown:
         nudge = nudge * 10
     if ctrlDown:
         nudge = nudge * 0.1            
     if ev.key == Opioid2D.K_LEFT:
         self.interface.nudge((-nudge, 0))
     elif ev.key == Opioid2D.K_RIGHT:
         self.interface.nudge((nudge, 0))
     elif ev.key == Opioid2D.K_UP:
         self.interface.nudge((0, -nudge))
     elif ev.key == Opioid2D.K_DOWN:
         self.interface.nudge((0, nudge))
     elif ev.key == Opioid2D.K_DELETE:
         from pig.editor.util import undoable_delete_nodes
         deletelist = []
         for ref in wx.GetApp().selectedObjectDict.itervalues():
             if isinstance(ref(), Opioid2D.public.Node.Node):
                 deletelist.append(ref())
         undoable_delete_nodes(deletelist)
     elif ev.key == Opioid2D.K_s and ctrlDown:
         wx.CallAfter(save_scene)
     elif ev.key == Opioid2D.K_a and ctrlDown:
         wx.CallAfter(save_scene_as)
     elif ev.key == Opioid2D.K_q and ctrlDown:
         wx.CallAfter(self.interface.quit)
     elif ev.key == Opioid2D.K_w and ctrlDown:
         wx.CallAfter(wx.GetApp().raise_all_frames)
     elif ev.key == Opioid2D.K_c and ctrlDown:
         wx.CallAfter(self.interface.copy_selected)
     elif ev.key == Opioid2D.K_x and ctrlDown:
         wx.CallAfter(self.interface.cut_selected)
     elif ev.key == Opioid2D.K_v and ctrlDown:
         wx.CallAfter(self.interface.paste_clipboard)
     elif ev.key == Opioid2D.K_z and ctrlDown:
         if shiftDown:
            wx.GetApp().history.small_undo()
         else:
            wx.GetApp().history.undo()
     elif ev.key == Opioid2D.K_y and ctrlDown:
         if shiftDown:
            wx.GetApp().history.small_redo()
         else:
            wx.GetApp().history.redo()
     elif ev.key == Opioid2D.K_u and ctrlDown:
         try:
             app = wx.GetApp()
             selected = app.get_selection()
             if selected:                    
                 wx.CallAfter(app.get_object_frame(
                     selected.popitem()[0]).pugWindow.view_source_code)
             else:
                 wx.CallAfter(app.get_object_frame(
                     Opioid2D.Director.scene).pugWindow.view_source_code)
             wx.CallAfter(app.raise_all_frames)
         except:
             pass
     elif ev.key == Opioid2D.K_p and ctrlDown:
         try:
             app = wx.GetApp()
             selected = app.get_selection()
             if selected:                    
                 wx.CallAfter(app.get_object_frame(
                     selected.popitem()[0]).pugWindow.open_shell)
             else:
                 wx.CallAfter(app.get_object_frame(
                     Opioid2D.Director.scene).pugWindow.open_shell)
             wx.CallAfter(app.raise_all_frames)
         except:
             pass