def on_mouse(self, event): '''EVT_MOUSE_EVENTS handler.''' # todo: maybe right click should give context menu with 'Sensitivity...' # todo: make check: if left up and has capture, release capture self.Refresh() (w, h) = self.GetClientSize() (x, y) = event.GetPositionTuple() if event.LeftDown(): self.being_dragged = True self.snap_map = SnapMap( snap_point_ratios=self._get_snap_points_as_ratios(), base_drag_radius=self.base_drag_radius, snap_point_drag_well=self.snap_point_drag_well, initial_y=y, initial_ratio=self.current_ratio ) self.SetCursor(cursor_collection.get_closed_grab()) # SetCursor must be before CaptureMouse because of wxPython/GTK # weirdness self.CaptureMouse() return if event.LeftIsDown() and self.HasCapture(): ratio = self.snap_map.y_to_ratio(y) value = self._ratio_to_value(ratio) self.value_setter(value) if event.LeftUp(): # todo: make sure that when leaving # entire app, things don't get f****d if self.HasCapture(): self.ReleaseMouse() # SetCursor must be after ReleaseMouse because of wxPython/GTK # weirdness self.SetCursor(cursor_collection.get_open_grab()) self.being_dragged = False self.snap_map = None return
def on_mouse(self, event): '''EVT_MOUSE_EVENTS handler.''' # todo: maybe right click should give context menu with # 'Sensitivity...' # todo: make check: if left up and has capture, release capture self.Refresh() (w, h) = self.GetClientSize() (x, y) = event.GetPositionTuple() if event.LeftDown(): self.being_dragged = True self.snap_map = SnapMap( snap_point_ratios=self._get_snap_points_as_ratios(), base_drag_radius=self.base_drag_radius, snap_point_drag_well=self.snap_point_drag_well, initial_y=y, initial_ratio=self.current_ratio) self.SetCursor(cursor_collection.get_closed_grab()) # SetCursor must be before CaptureMouse because of wxPython/GTK # weirdness self.CaptureMouse() return if event.LeftIsDown() and self.HasCapture(): ratio = self.snap_map.y_to_ratio(y) value = self._ratio_to_value(ratio) self.value_setter(value) if event.LeftUp(): # todo: make sure that when leaving # entire app, things don't get f****d if self.HasCapture(): self.ReleaseMouse() # SetCursor must be after ReleaseMouse because of wxPython/GTK # weirdness self.SetCursor(cursor_collection.get_open_grab()) self.being_dragged = False self.snap_map = None return
def on_mouse_event(self, e): '''EVT_MOUSE_EVENTS handler.''' # todo: possibly do momentum, like in old shockwave carouselle. # todo: right click should give context menu with 'Sensitivity...' and # 'Disable' # todo: make check: if left up and has capture, release capture self.Refresh() (w, h) = self.GetClientSize() (x, y) = e.GetPositionTuple() (rx, ry) = (x/w, y/h) if e.LeftDown(): self.angle_while_dragging = self.grabbed_angle = self._expanded_pos_to_angle(rx) self.d_angle_while_dragging = 0 self.desired_clock_while_dragging = self.grabbed_pseudoclock = \ self.gui_project.pseudoclock self.was_playing_before_drag = self.gui_project.is_playing self.gui_project.stop_playing() self.being_dragged = True self.SetCursor(cursor_collection.get_closed_grab()) # SetCursor must be before CaptureMouse because of wxPython/GTK # weirdness self.CaptureMouse() return if e.LeftIsDown(): if not self.HasCapture(): return self.angle_while_dragging = self._expanded_pos_to_angle(rx) self.d_angle_while_dragging = (self.angle_while_dragging - self.grabbed_angle) desired_pseudoclock = self.grabbed_pseudoclock + \ (self.d_angle_while_dragging / self.clock_factor) self.gui_project.set_pseudoclock(desired_pseudoclock) if self.gui_project.pseudoclock != desired_pseudoclock: # Means we got an edge node edge_clock = self.gui_project.active_node.state.clock direction = cmp(self.gui_project.pseudoclock, desired_pseudoclock) # direction that we bring back the cursor to if it goes too far d_clock = (edge_clock - self.grabbed_pseudoclock) d_angle = d_clock * self.clock_factor edge_angle = self.grabbed_angle + d_angle edge_rx = self._expanded_angle_to_pos(edge_angle) edge_x = edge_rx * w is_going_over = \ (edge_x - x > 0) if direction == 1 else (edge_x - x < 0) if is_going_over: self.WarpPointer(edge_x, y) if e.LeftUp(): #or e.Leaving(): # todo: make sure that when leaving entire app, things don't get # f****d if self.HasCapture(): self.ReleaseMouse() # SetCursor must be after ReleaseMouse because of wxPython/GTK # weirdness self.SetCursor(cursor_collection.get_open_grab()) self.being_dragged = False self.grabbed_angle = None self.grabbed_pseudoclock = None self.angle_while_dragging = None self.d_angle_while_dragging = None self.desired_clock_while_dragging = None if self.was_playing_before_drag: self.gui_project.start_playing() self.gui_project.round_pseudoclock_to_active_node() self.was_playing_before_drag = None
def on_mouse_event(self, e): '''EVT_MOUSE_EVENTS handler.''' # todo: possibly do momentum, like in old shockwave carouselle. # todo: right click should give context menu with 'Sensitivity...' and # 'Disable' # todo: make check: if left up and has capture, release capture # If the gui project has no active path, we can't navigate on it at # all: if self.gui_project.path is None: return self.Refresh() (w, h) = self.GetClientSize() (x, y) = e.GetPositionTuple() (rx, ry) = (x/w, y/h) if e.LeftDown(): self.angle_while_dragging = self.grabbed_angle = \ self._expanded_pos_to_angle(rx) self.d_angle_while_dragging = 0 self.desired_clock_while_dragging = self.grabbed_pseudoclock = \ self.gui_project.pseudoclock self.was_playing_before_drag = self.gui_project.is_playing self.gui_project.stop_playing() self.being_dragged = True self.SetCursor(cursor_collection.get_closed_grab()) # SetCursor must be before CaptureMouse because of wxPython/GTK # weirdness self.CaptureMouse() return if e.LeftIsDown(): if not self.HasCapture(): return self.angle_while_dragging = self._expanded_pos_to_angle(rx) self.d_angle_while_dragging = \ (self.angle_while_dragging - self.grabbed_angle) desired_pseudoclock = self.grabbed_pseudoclock + \ (self.d_angle_while_dragging / self.clock_factor) self.gui_project.set_pseudoclock(desired_pseudoclock) if self.gui_project.pseudoclock != desired_pseudoclock: # Means we got an edge node edge_clock = self.gui_project.active_node.state.clock direction = cmp(self.gui_project.pseudoclock, desired_pseudoclock) # direction that we bring back the cursor to if it goes too far d_clock = (edge_clock - self.grabbed_pseudoclock) d_angle = d_clock * self.clock_factor edge_angle = self.grabbed_angle + d_angle edge_rx = self._expanded_angle_to_pos(edge_angle) edge_x = edge_rx * w is_going_over = \ (edge_x - x > 0) if direction == 1 else (edge_x - x < 0) if is_going_over: self.WarpPointer(edge_x, y) if e.LeftUp(): #or e.Leaving(): # todo: make sure that when leaving entire app, things don't get # f****d if self.HasCapture(): self.ReleaseMouse() # SetCursor must be after ReleaseMouse because of wxPython/GTK # weirdness self.SetCursor(cursor_collection.get_open_grab()) self.being_dragged = False self.grabbed_angle = None self.grabbed_pseudoclock = None self.angle_while_dragging = None self.d_angle_while_dragging = None self.desired_clock_while_dragging = None if self.was_playing_before_drag: self.gui_project.start_playing() self.gui_project.round_pseudoclock_to_active_node() self.was_playing_before_drag = None