-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappHandler.py
More file actions
59 lines (46 loc) · 2.48 KB
/
appHandler.py
File metadata and controls
59 lines (46 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import dearpygui.dearpygui as dpg
class InputHandler:
def __init__(self, appself):
self.app = appself
def on_mouse_click(self, sender, app_data):
self.app.wtimeline.handle_mouse_click(app_data)
self.app.MLED.on_mouse_click(sender, app_data)
def on_wheel_mouse(self, sender, app_data):
self.app.wtimeline.handle_mouse_wheel(app_data)
self.app.MLED.on_mouse_wheel(sender, app_data)
def on_mouse_release(self, sender, app_data):
self.app.wtimeline.handle_mouse_release(app_data)
self.app.MLED.on_mouse_release(sender, app_data)
def on_mouse_drag(self, sender, app_data):
self.app.wtimeline.handle_mouse_drag(app_data)
self.app.MLED.on_mouse_drag(sender, app_data)
def on_key_press(self, sender, key):
if key == 32:
if not self.app.is_play:
self.app.start_playback(None, None)
else:
self.app.stop_playback(None, None)
elif key == 0x25:
if self.app.is_play:
self.app.stop_playback(None, None)
self.app.wtimeline.current_frame -= 1
self.app.wtimeline.set_playhead_frame(self.app.wtimeline.current_frame)
self.app.timeline_object_callback(self.app.timeline.get_scene_state(self.app.wtimeline.current_frame))
self.app.gui.set_status(self.app.timeline.current_position, self.app.timeline.total_frames, self.app.timeline.frame_rate, 0, "SEEK", (-255, 0, 0, 255))
elif key == 0x27:
if self.app.is_play:
self.app.stop_playback(None, None)
self.app.wtimeline.current_frame += 1
self.app.wtimeline.set_playhead_frame(self.app.wtimeline.current_frame)
self.app.timeline_object_callback(self.app.timeline.get_scene_state(self.app.wtimeline.current_frame))
self.app.gui.set_status(self.app.timeline.current_position, self.app.timeline.total_frames, self.app.timeline.frame_rate, 0, "SEEK", (-255, 0, 0, 255))
elif key == 85: # U for update
self.app.update_mled_keyframe()
#print(key)
def register(self):
with dpg.handler_registry():
dpg.add_mouse_click_handler(callback=self.on_mouse_click)
dpg.add_mouse_wheel_handler(callback=self.on_wheel_mouse)
dpg.add_mouse_drag_handler(callback=self.on_mouse_drag)
dpg.add_mouse_release_handler(callback=self.on_mouse_release)
dpg.add_key_press_handler(callback=self.on_key_press)