-
-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathBaseOperator.py
More file actions
100 lines (79 loc) · 3 KB
/
BaseOperator.py
File metadata and controls
100 lines (79 loc) · 3 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
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
import bpy
from bpy.props import *
from .common import *
class FileSelectOptions():
# File browser filter
filter_folder : BoolProperty(default=True, options={'HIDDEN', 'SKIP_SAVE'})
filter_image : BoolProperty(default=True, options={'HIDDEN', 'SKIP_SAVE'})
display_type : EnumProperty(
items = (
('FILE_DEFAULTDISPLAY', 'Default', ''),
('FILE_SHORTDISLPAY', 'Short List', ''),
('FILE_LONGDISPLAY', 'Long List', ''),
('FILE_IMGDISPLAY', 'Thumbnails', '')
),
default = 'FILE_IMGDISPLAY',
options = {'HIDDEN', 'SKIP_SAVE'}
)
class BlendMethodOptions():
blend_method : EnumProperty(
name = 'Blend Method',
description = 'Blend method for transparent material',
items = (
('CLIP', 'Alpha Clip', ''),
('HASHED', 'Alpha Hashed', ''),
('BLEND', 'Alpha Blend', '')
),
default = 'HASHED'
)
shadow_method : EnumProperty(
name = 'Shadow Method',
description = 'Shadow method for transparent material',
items = (
('CLIP', 'Alpha Clip', ''),
('HASHED', 'Alpha Hashed', ''),
),
default = 'HASHED'
)
surface_render_method : EnumProperty(
name = 'Surface Render Method',
description = 'Surface render method for transparent material',
items = (
('DITHERED', 'Dithered', ''),
('BLENDED', 'Blended', ''),
),
default = 'DITHERED'
)
class OpenImage(FileSelectOptions):
# File related
files : CollectionProperty(type=bpy.types.OperatorFileListElement, options={'HIDDEN', 'SKIP_SAVE'})
directory : StringProperty(maxlen=1024, subtype='FILE_PATH', options={'HIDDEN', 'SKIP_SAVE'})
relative : BoolProperty(name="Relative Path", default=True, description="Apply relative paths")
def running_fileselect_modal(self, context, event):
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
def check(self, context):
return True
def generate_paths(self):
return (fn.name for fn in self.files), self.directory
def get_loaded_images(self):
import_list, directory = self.generate_paths()
loaded_images = tuple(load_image(path, directory) for path in import_list)
return loaded_images
def channel_items_base(self, context):
from . import lib
items = []
node = get_active_ypaint_node()
if node:
yp = node.node_tree.yp
for i, ch in enumerate(yp.channels):
# Add two spaces to prevent text from being translated
text_ch_name = ch.name + ' '
icon_name = lib.channel_custom_icon_dict[ch.type]
items.append((str(i), text_ch_name, '', lib.get_icon(icon_name), i))
return items
def channel_items(self, context):
from . import lib
items = channel_items_base(self, context)
items.append(('-1', 'All Channels', '', lib.get_icon('channels'), len(items)))
return items