Skip to content

Commit c052109

Browse files
committed
Panelレイアウトの整理
1 parent 71103a5 commit c052109

File tree

3 files changed

+102
-126
lines changed

3 files changed

+102
-126
lines changed

mmd_tools/panels/prop_object.py

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,10 @@ class _PanelBase(object):
1010
bl_region_type = 'WINDOW'
1111
bl_context = 'object'
1212

13-
class MMDModelObjectDisplayPanel(_PanelBase, Panel):
14-
bl_idname = 'OBJECT_PT_mmd_tools_root_object_display'
15-
bl_label = 'MMD Display'
1613

17-
def draw(self, context):
18-
layout = self.layout
19-
obj = context.active_object
20-
21-
root = mmd_model.Model.findRoot(obj)
22-
23-
row = layout.row(align=True)
24-
c = row.column(align=True)
25-
c.prop(root.mmd_root, 'show_meshes', text='Mesh')
26-
c.prop(root.mmd_root, 'show_armature', text='Armature')
27-
c.prop(root.mmd_root, 'show_rigid_bodies', text='Rigidbody')
28-
c.prop(root.mmd_root, 'show_joints', text='Joint')
29-
c = row.column(align=True)
30-
c.prop(root.mmd_root, 'show_temporary_objects', text='Temporary Object')
31-
c.prop(root.mmd_root, 'show_names_of_rigid_bodies', text='Rigidbody Name')
32-
c.prop(root.mmd_root, 'show_names_of_joints', text='Joint Name')
14+
class MMDModelObjectPanel(_PanelBase, Panel):
15+
bl_idname = 'OBJECT_PT_mmd_tools_root_object'
16+
bl_label = 'MMD Model Information'
3317

3418
@classmethod
3519
def poll(cls, context):
@@ -43,13 +27,21 @@ def poll(cls, context):
4327

4428
return True
4529

30+
def draw(self, context):
31+
layout = self.layout
32+
obj = context.active_object
33+
34+
root = mmd_model.Model.findRoot(obj)
35+
36+
c = layout.column()
37+
c.prop(root.mmd_root, 'name')
38+
c.prop(root.mmd_root, 'name_e')
39+
c.prop(root.mmd_root, 'scale')
40+
4641

4742
class MMDRigidPanel(_PanelBase, Panel):
4843
bl_idname = 'RIGID_PT_mmd_tools_bone'
49-
bl_label = 'MMD Rigid Tool'
50-
bl_space_type = 'PROPERTIES'
51-
bl_region_type = 'WINDOW'
52-
bl_context = 'object'
44+
bl_label = 'MMD Rigidbody'
5345

5446
@classmethod
5547
def poll(cls, context):

mmd_tools/panels/tool.py

Lines changed: 46 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,49 @@ class _PanelBase(object):
1212
bl_category = 'mmd_tools'
1313

1414

15+
class MMDToolsObjectPanel(_PanelBase, Panel):
16+
bl_idname = 'OBJECT_PT_mmd_tools_object'
17+
bl_label = 'Operator'
18+
bl_context = ''
19+
20+
def draw(self, context):
21+
active_obj = context.active_object
22+
23+
layout = self.layout
24+
25+
col = layout.column(align=True)
26+
col.label('Edit:')
27+
row = col.row(align=True)
28+
row.operator(operators.model.CreateMMDModelRoot.bl_idname, text='Create Model')
29+
row.operator(operators.fileio.ImportPmx.bl_idname, text='Import Model')
30+
if active_obj is not None and active_obj.type == 'MESH':
31+
col = layout.column(align=True)
32+
col.operator('mmd_tools.separate_by_materials', text='Separate By Materials')
33+
34+
if active_obj is None:
35+
return
36+
37+
root = mmd_model.Model.findRoot(active_obj)
38+
if root is None:
39+
return
40+
41+
col = self.layout.column(align=True)
42+
col.label('Rigidbody:')
43+
row = col.row(align=True)
44+
row.operator('mmd_tools.build_rig')
45+
row.operator('mmd_tools.clean_rig')
46+
if not root.mmd_root.is_built:
47+
col.label(text='Press the "Build" button before playing the physical animation.', icon='ERROR')
48+
49+
col.label('Bone Constraints:')
50+
col.operator('mmd_tools.apply_additioinal_transform')
51+
52+
col = self.layout.column(align=True)
53+
col.label('Import/Export:')
54+
col.operator(operators.fileio.ImportVmdToMMDModel.bl_idname, text='Import Motion')
55+
col.operator(operators.fileio.ExportPmx.bl_idname, text='Export Model')
56+
57+
1558
class MMD_ROOT_UL_display_item_frames(UIList):
1659
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
1760
mmd_root = data
@@ -43,9 +86,11 @@ def draw_item(self, context, layout, data, item, icon, active_data, active_propn
4386
layout.alignment = 'CENTER'
4487
layout.label(text="", icon_value=icon)
4588

89+
4690
class MMDDisplayItemsPanel(_PanelBase, Panel):
4791
bl_idname = 'OBJECT_PT_mmd_tools_display_items'
48-
bl_label = 'MMD Display Items'
92+
bl_label = 'Display Items'
93+
bl_options = {'DEFAULT_CLOSED'}
4994

5095
def draw(self, context):
5196
active_obj = context.active_object
@@ -113,100 +158,3 @@ def draw(self, context):
113158
row = col.row(align=True)
114159
row.label(i.name+':')
115160
row.prop(i.data.shape_keys.key_blocks[item.name], 'value')
116-
117-
118-
class MMDRootView3DPanel(_PanelBase, Panel):
119-
bl_idname = 'OBJECT_PT_mmd_tools_root'
120-
bl_label = 'MMD Model Tools'
121-
bl_context = ''
122-
123-
def draw(self, context):
124-
layout = self.layout
125-
obj = context.active_object
126-
127-
if obj is None:
128-
c = layout.column()
129-
c.label('No object is selected.')
130-
return
131-
132-
root = mmd_model.Model.findRoot(obj)
133-
if root is None:
134-
c = layout.column()
135-
c.label('Create MMD Model')
136-
return
137-
138-
col = self.layout.column(align=True)
139-
140-
if not root.mmd_root.is_built:
141-
col.label(text='Press the "Build" button before playing the physical animation.', icon='ERROR')
142-
row = col.row(align=True)
143-
row.operator('mmd_tools.build_rig')
144-
row.operator('mmd_tools.clean_rig')
145-
col.operator('mmd_tools.apply_additioinal_transform')
146-
147-
col = self.layout.column(align=True)
148-
col.operator(operators.fileio.ImportVmdToMMDModel.bl_idname, text='Import Motion')
149-
col.operator(operators.fileio.ExportPmx.bl_idname, text='Export Model')
150-
151-
152-
class MMDModelObjectPanel(_PanelBase, Panel):
153-
bl_idname = 'OBJECT_PT_mmd_tools_root_object'
154-
bl_label = 'MMD Model Information'
155-
bl_space_type = 'PROPERTIES'
156-
bl_region_type = 'WINDOW'
157-
bl_context = 'object'
158-
159-
@classmethod
160-
def poll(cls, context):
161-
obj = context.active_object
162-
if obj is None:
163-
return False
164-
165-
root = mmd_model.Model.findRoot(obj)
166-
if root is None:
167-
return False
168-
169-
return True
170-
171-
def draw(self, context):
172-
layout = self.layout
173-
obj = context.active_object
174-
175-
root = mmd_model.Model.findRoot(obj)
176-
177-
c = layout.column()
178-
c.prop(root.mmd_root, 'name')
179-
c.prop(root.mmd_root, 'name_e')
180-
c.prop(root.mmd_root, 'scale')
181-
182-
class MMDToolsObjectPanel(_PanelBase, Panel):
183-
bl_idname = 'OBJECT_PT_mmd_tools_object'
184-
bl_label = 'Object'
185-
bl_context = ''
186-
187-
def draw(self, context):
188-
active_obj = context.active_object
189-
190-
layout = self.layout
191-
192-
col = layout.column()
193-
col.label('Model:')
194-
c = col.column(align=True)
195-
c.operator(operators.model.CreateMMDModelRoot.bl_idname, text='Create')
196-
c.operator(operators.fileio.ImportPmx.bl_idname, text='Import')
197-
198-
col.label('Motion(vmd):')
199-
c = col.column()
200-
c.operator('mmd_tools.import_vmd', text='Import')
201-
202-
203-
if active_obj is not None and active_obj.type == 'MESH':
204-
col = layout.column(align=True)
205-
col.label('Mesh:')
206-
c = col.column()
207-
c.operator('mmd_tools.separate_by_materials', text='Separate by materials')
208-
209-
col = layout.column(align=True)
210-
col.label('Scene:')
211-
c = col.column(align=True)
212-
c.operator('mmd_tools.set_frame_range', text='Set frame range')

mmd_tools/panels/view_prop.py

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,54 @@
22

33
from bpy.types import Panel
44

5-
class MMDViewPanel(Panel):
6-
bl_idname = 'OBJECT_PT_mmd_tools_view'
7-
bl_label = 'MMD Shading'
5+
import mmd_tools.core.model as mmd_model
6+
7+
class _PanelBase(object):
88
bl_space_type = 'VIEW_3D'
99
bl_region_type = 'UI'
10-
bl_context = ''
10+
11+
class MMDModelObjectDisplayPanel(_PanelBase, Panel):
12+
bl_idname = 'OBJECT_PT_mmd_tools_root_object_display'
13+
bl_label = 'MMD Display'
14+
15+
@classmethod
16+
def poll(cls, context):
17+
obj = context.active_object
18+
if obj is None:
19+
return False
20+
21+
root = mmd_model.Model.findRoot(obj)
22+
if root is None:
23+
return False
24+
25+
return True
26+
27+
def draw(self, context):
28+
layout = self.layout
29+
obj = context.active_object
30+
31+
root = mmd_model.Model.findRoot(obj)
32+
33+
row = layout.row(align=True)
34+
c = row.column(align=True)
35+
c.prop(root.mmd_root, 'show_meshes', text='Mesh')
36+
c.prop(root.mmd_root, 'show_armature', text='Armature')
37+
c.prop(root.mmd_root, 'show_rigid_bodies', text='Rigidbody')
38+
c.prop(root.mmd_root, 'show_joints', text='Joint')
39+
c = row.column(align=True)
40+
c.prop(root.mmd_root, 'show_temporary_objects', text='Temporary Object')
41+
c.prop(root.mmd_root, 'show_names_of_rigid_bodies', text='Rigidbody Name')
42+
c.prop(root.mmd_root, 'show_names_of_joints', text='Joint Name')
43+
44+
45+
class MMDViewPanel(_PanelBase, Panel):
46+
bl_idname = 'OBJECT_PT_mmd_tools_view'
47+
bl_label = 'MMD Shading'
1148

1249
def draw(self, context):
1350
layout = self.layout
1451

1552
col = layout.column()
16-
col.label('View:')
1753
c = col.column(align=True)
1854
r = c.row(align=True)
1955
r.operator('mmd_tools.set_glsl_shading', text='GLSL')

0 commit comments

Comments
 (0)