-
Notifications
You must be signed in to change notification settings - Fork 0
/
panel.py
130 lines (100 loc) · 4.31 KB
/
panel.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
125
126
127
128
129
130
import bpy
from bpy.types import Panel
from bpy.types import Operator
from bpy.props import *
class NPRPanel(Panel):
bl_idname = "OBJECT_PT_TexturePaintAdd"
bl_category = "TexturePaintAdd"
bl_label = "Add Alpha paint Image Texture"
bl_space_type = 'NODE_EDITOR'
bl_region_type = "UI"
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
img_512 = 512
img_1k = 1024
img_2k = 2048
img_4k = 4096
# Alpha image
# manual sizes
row = layout.row()
split = row.split(factor=1, align=True)
col = split.column()
col.label(text="Resolution")
split = row.split(factor=1, align=True)
col = split.column()
col.prop(context.scene, "set_res_width_alpha", text="Width")
split = row.split(factor=1, align=True)
col = split.column()
col.prop(context.scene, "set_res_height_alpha", text="Height")
split = row.split(factor=1, align=True)
col = split.column()
col.prop(context.scene, "set_alpha_color", text='')
# add size click buttons
row = layout.row()
props = row.operator('shading.set_res_img', text="Image Size 512")
props.cpropimage = 'alpha'
props.imageres = img_512
props = row.operator('shading.set_res_img', text="Image Size 1K")
props.cpropimage = 'alpha'
props.imageres = img_1k
props = row.operator('shading.set_res_img', text="Image Size 2K")
props.cpropimage = 'alpha'
props.imageres = img_2k
props = row.operator('shading.set_res_img', text="Image Size 4K")
props.cpropimage = 'alpha'
props.imageres = img_4k
layout.separator()
# Add img
row = layout.row()
row.operator('shading.add_img', text="Add Image", icon='ADD')
class NPRPanel2(Panel):
bl_idname = "object_PT_TexturePaintAdd2"
bl_category = "TexturePaintAdd"
bl_label = "Add NPR Image Textures"
bl_space_type = 'NODE_EDITOR'
bl_region_type = "UI"
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
img_sizes = [512, 1024, 2048, 4096]
img_sizes_name = ["512", "1K", "2K", "4K"]
def draw_texture_row(label, color_prop, name_prop, width_prop, height_prop, cpropimage):
# Texture
row = layout.row()
split = row.split(factor=1, align=True)
col = split.column()
col.label(text=label)
split = row.split(align=True)
col = split.column()
col.prop(context.scene, color_prop, text="")
split = row.split(factor=1, align=True)
col = split.column()
col.prop(context.scene, name_prop, text="Name")
# Texture manual sizes
row = layout.row()
split = row.split(factor=1, align=True)
col = split.column()
col.label(text="Resolution")
split = row.split(factor=1, align=True)
col = split.column()
col.prop(context.scene, width_prop, text="Width")
split = row.split(factor=1, align=True)
col = split.column()
col.prop(context.scene, height_prop, text="Height")
row = layout.row()
for size, size_name in zip(img_sizes, img_sizes_name):
props = row.operator('shading.set_res_img', text=f"Image Size {size_name}")
props.cpropimage = cpropimage
props.imageres = size
layout.separator()
draw_texture_row("Prefix Texture", "set_prefix_color", "set_prefix_name", "set_res_width_prefix", "set_res_height_prefix", 'prefix')
draw_texture_row("Texture 1", "set_tex1_color", "set_tex1_name", "set_res_width_tex1", "set_res_height_tex1", 'tex1')
draw_texture_row("Texture 2", "set_tex2_color", "set_tex2_name", "set_res_width_tex2", "set_res_height_tex2", 'tex2')
draw_texture_row("Texture 3", "set_tex3_color", "set_tex3_name", "set_res_width_tex3", "set_res_height_tex3", 'tex3')
# Add images
layout.separator()
row = layout.row()
row.operator('shading.add_img_npr', text="Add Images", icon='ADD')