forked from JacquesLucke/animation_nodes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.py
87 lines (67 loc) · 2.02 KB
/
events.py
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import bpy
from . import tree_info
from . import file_tests
from . import event_handler
from . utils.handlers import eventHandler
class EventState:
def __init__(self):
self.reset()
self.isRendering = False
def reset(self):
self.treeChanged = False
self.fileChanged = False
self.sceneChanged = False
self.frameChanged = False
self.addonChanged = False
self.propertyChanged = False
def getActives(self):
events = set()
if self.treeChanged: events.add("Tree")
if self.fileChanged: events.add("File")
if self.addonChanged: events.add("Addon")
if self.sceneChanged: events.add("Scene")
if self.frameChanged: events.add("Frame")
if self.propertyChanged: events.add("Property")
return events
event = EventState()
@eventHandler("SCENE_UPDATE_POST")
def sceneUpdated(scene):
event.sceneChanged = True
evaluateRaisedEvents()
@eventHandler("RENDER_PRE")
def renderFramePre():
event.frameChanged = True
evaluateRaisedEvents()
def evaluateRaisedEvents():
event_handler.update(event.getActives())
event.reset()
@eventHandler("FRAME_CHANGE_POST")
def frameChanged(scene):
event.frameChanged = True
def propertyChanged(self = None, context = None):
event.propertyChanged = True
@eventHandler("FILE_LOAD_POST")
def fileLoaded():
file_tests.checkCurrentFile()
event.fileChanged = True
treeChanged()
@eventHandler("ADDON_LOAD_POST")
def addonChanged():
event.addonChanged = True
treeChanged()
def executionCodeChanged(self = None, context = None):
treeChanged()
def networkChanged(self = None, context = None):
treeChanged()
def treeChanged(self = None, context = None):
event.treeChanged = True
tree_info.treeChanged()
@eventHandler("RENDER_INIT")
def renderInitialized():
event.isRendering = True
@eventHandler("RENDER_CANCEL")
@eventHandler("RENDER_COMPLETE")
def renderEnd():
event.isRendering = False
def isRendering():
return event.isRendering