1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 from timelinelib.wxgui.components.maincanvas.inputhandler import InputHandler
20 from timelinelib.general.methodcontainer import MethodContainer
21 from timelinelib.wxgui.keyboard import Keyboard
22
23
24 """
25 A NoOpInputHandler gets messages about the start of a user input, such as a
26 mouse move action, and delegates the workload to fulfill the user action, to
27 another event handler
28 """
29
30
46
47 toggle_balloon_stickyness()
48 event = event_at_cursor()
49 if event:
50 self._left_mouse_down_on_event(self._state, event, cursor, keyboard)
51 else:
52 self._left_mouse_down_on_timeline(self._state, cursor, keyboard)
53
58
59 def is_resize_command():
60 return hit_resize_handle() is not None
61
62 def hit_move_handle():
63 return self._canvas.hit_move_handle(cursor, keyboard)
64
65 def is_move_command():
66 if event.get_ends_today():
67 return False
68 else:
69 return hit_move_handle()
70
71 def start_event_action(action_method, action_arg):
72 if state.ok_to_edit():
73 try:
74 action_method(event, action_arg)
75 except:
76 state.edit_ends()
77 raise
78
79 def resize_event():
80 start_event_action(state.change_to_resize_by_drag, hit_resize_handle())
81
82 def move_event():
83 start_event_action(state.change_to_move_by_drag, self._canvas.GetTimeAt(cursor.x))
84
85 def toggle_event_selection():
86 self._canvas.toggle_event_selection(cursor, keyboard)
87
88 methods = MethodContainer(
89 [
90 (is_resize_command(), resize_event),
91 (is_move_command(), move_event)
92 ],
93 default_method=toggle_event_selection)
94 methods.select(True)()
95
100
101 def create_event():
102 self._canvas.ClearSelectedEvents()
103 state.change_to_create_period_event_by_drag(cursor)
104
105 def zoom():
106 self._canvas.ClearSelectedEvents()
107 state.change_to_zoom_by_drag(cursor)
108
109 def select():
110 state.change_to_select(cursor)
111
112 methods = MethodContainer(
113 [
114 (Keyboard.NONE, scroll),
115 (Keyboard.SHIFT, zoom),
116 (Keyboard.CTRL, create_event),
117 (Keyboard.SHIFT | Keyboard.CTRL, select),
118 ])
119 methods.select(keyboard.keys_combination)()
120