3360f4c47ad512c0aeb387f1e1dfa4dd1e0e4929
[blender.git] / release / ui / buttons_data_mesh.py
1
2 import bpy
3
4 class DataButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "data"
8         
9         def poll(self, context):
10                 return (context.mesh != None)
11
12 class DATA_PT_mesh(DataButtonsPanel):
13         __idname__ = "DATA_PT_mesh"
14         __label__ = "Mesh"
15         
16         def poll(self, context):
17                 return (context.object and context.object.type == 'MESH')
18
19         def draw(self, context):
20                 layout = self.layout
21                 
22                 ob = context.object
23                 mesh = context.mesh
24                 space = context.space_data
25
26                 split = layout.split(percentage=0.65)
27
28                 if ob:
29                         split.template_ID(ob, "data")
30                         split.itemS()
31                 elif mesh:
32                         split.template_ID(space, "pin_id")
33                         split.itemS()
34
35                 if mesh:
36                         layout.itemS()
37
38                         split = layout.split()
39                 
40                         col = split.column()
41                         col.itemR(mesh, "autosmooth")
42                         colsub = col.column()
43                         colsub.active = mesh.autosmooth
44                         colsub.itemR(mesh, "autosmooth_angle", text="Angle")
45                         sub = split.column()
46                         sub.itemR(mesh, "vertex_normal_flip")
47                         sub.itemR(mesh, "double_sided")
48                         
49                         layout.itemR(mesh, "texco_mesh")
50
51
52 class DATA_PT_materials(DataButtonsPanel):
53         __idname__ = "DATA_PT_materials"
54         __label__ = "Materials"
55         
56         def poll(self, context):
57                 return (context.object and context.object.type in ('MESH', 'CURVE', 'FONT', 'SURFACE'))
58
59         def draw(self, context):
60                 layout = self.layout
61                 ob = context.object
62
63                 row = layout.row()
64
65                 row.template_list(ob, "materials", "active_material_index")
66
67                 col = row.column(align=True)
68                 col.itemO("OBJECT_OT_material_slot_add", icon="ICON_ZOOMIN", text="")
69                 col.itemO("OBJECT_OT_material_slot_remove", icon="ICON_ZOOMOUT", text="")
70
71                 row = layout.row(align=True)
72
73                 row.itemO("OBJECT_OT_material_slot_assign", text="Assign");
74                 row.itemO("OBJECT_OT_material_slot_select", text="Select");
75                 row.itemO("OBJECT_OT_material_slot_deselect", text="Deselect");
76
77                 layout.itemS()
78
79                 box= layout.box()
80
81                 row = box.row()
82                 row.template_list(ob, "materials", "active_material_index", compact=True)
83
84                 subrow = row.row(align=True)
85                 subrow.itemO("OBJECT_OT_material_slot_add", icon="ICON_ZOOMIN", text="")
86                 subrow.itemO("OBJECT_OT_material_slot_remove", icon="ICON_ZOOMOUT", text="")
87
88
89 bpy.types.register(DATA_PT_mesh)
90 bpy.types.register(DATA_PT_materials)
91