-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path__init__.py
124 lines (100 loc) · 4.55 KB
/
__init__.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
"""
Copyright (C) 2024 Spencer Magnusson
semagnum@gmail.com
Created by Spencer Magnusson
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
if "bpy" in locals():
import importlib
import os
import types
# double-check this add-on is imported, so it can be referenced and reloaded
import shot_matcher
def reload_package(package):
assert (hasattr(package, '__package__'))
fn = package.__file__
fn_dir = os.path.dirname(fn) + os.sep
module_visit = {fn}
del fn
def reload_recursive_ex(module):
module_iter = (
module_child
for module_child in vars(module).values()
if isinstance(module_child, types.ModuleType)
)
for module_child in module_iter:
fn_child = getattr(module_child, '__file__', None)
if (fn_child is not None) and fn_child.startswith(fn_dir) and fn_child not in module_visit:
module_visit.add(fn_child)
reload_recursive_ex(module_child)
importlib.reload(module)
print('Reloaded', module.__name__)
return reload_recursive_ex(package)
reload_package(shot_matcher)
import bpy
from . import operators, panels
from .handlers import set_bg_name, set_fg_name, get_bg_name, get_fg_name, bg_update, fg_update
from .handlers import save_pre_layer_settings, load_post_purge_settings
from .layers import LayerSettings, LayerDict
bl_info = {
"name": 'Shot Matcher',
"author": 'Spencer Magnusson',
"version": (3, 5, 4),
"blender": (4, 0, 0),
"description": 'Analyzes colors of an image or movie clip and applies it to the compositing tree.',
"location": 'Image Editor > UI > Shot Matcher, Movie Clip Editor > Tools > Shot Matcher, Compositor > UI > Shot Matcher',
"support": 'COMMUNITY',
"category": 'Compositing',
'doc_url': 'https://semagnum.github.io/shot-matcher/',
'tracker_url': 'https://github.com/semagnum/shot-matcher/issues',
}
MODEL_CLASSES = (LayerSettings, LayerDict)
def register():
for cls in MODEL_CLASSES:
bpy.utils.register_class(cls)
scene = bpy.types.Scene
scene.sm_settings_movieclips = bpy.props.CollectionProperty(type=LayerDict)
scene.sm_settings_images = bpy.props.CollectionProperty(type=LayerDict)
scene.sm_fg_type = bpy.props.EnumProperty(
name='Layer Type',
description='Select which file type the foreground layer is',
items=[('video', 'Video', '', 'FILE_MOVIE', 1),
('image', 'Image', '', 'FILE_IMAGE', 2),
],
update=fg_update
)
scene.sm_bg_type = bpy.props.EnumProperty(
name='Layer Type',
description='Select which file type the background layer is',
items=[('video', 'Video', '', 'FILE_MOVIE', 1),
('image', 'Image', '', 'FILE_IMAGE', 2),
],
update=bg_update
)
scene.sm_background = bpy.props.PointerProperty(type=LayerSettings)
scene.sm_foreground = bpy.props.PointerProperty(type=LayerSettings)
scene.sm_bg_name = bpy.props.StringProperty(default='', get=get_bg_name, set=set_bg_name)
scene.sm_fg_name = bpy.props.StringProperty(default='', get=get_fg_name, set=set_fg_name)
bpy.app.handlers.save_pre.append(save_pre_layer_settings)
bpy.app.handlers.load_post.append(load_post_purge_settings)
operators.register()
panels.register()
def unregister():
panels.unregister()
operators.unregister()
scene = bpy.types.Scene
bpy.app.handlers.save_pre.remove(save_pre_layer_settings)
bpy.app.handlers.load_post.remove(load_post_purge_settings)
del scene.sm_settings_movieclips, scene.sm_settings_images, scene.sm_bg_type, scene.sm_fg_type
del scene.sm_background, scene.sm_foreground
for cls in MODEL_CLASSES:
bpy.utils.unregister_class(cls)