Moved mesh display options to the 3D view n-key area, next to other display options.
[blender.git] / release / ui / buttons_data_mesh.py
1
2 import bpy
3
4 class DataButtonsPanel(bpy.types.Panel):
5         __space_type__ = 'PROPERTIES'
6         __region_type__ = 'WINDOW'
7         __context__ = "data"
8         
9         def poll(self, context):
10                 return (context.mesh != None)
11
12 class DATA_PT_context_mesh(DataButtonsPanel):
13         __show_header__ = False
14         
15         def draw(self, context):
16                 layout = self.layout
17                 
18                 ob = context.object
19                 mesh = context.mesh
20                 space = context.space_data
21
22                 split = layout.split(percentage=0.65)
23
24                 if ob:
25                         split.template_ID(ob, "data")
26                         split.itemS()
27                 elif mesh:
28                         split.template_ID(space, "pin_id")
29                         split.itemS()
30
31 class DATA_PT_normals(DataButtonsPanel):
32         __label__ = "Normals"
33
34         def draw(self, context):
35                 layout = self.layout
36                 
37                 mesh = context.mesh
38                 
39                 split = layout.split()
40                 
41                 col = split.column()
42                 col.itemR(mesh, "autosmooth")
43                 sub = col.column()
44                 sub.active = mesh.autosmooth
45                 sub.itemR(mesh, "autosmooth_angle", text="Angle")
46                 
47                 col = split.column()
48                 col.itemR(mesh, "vertex_normal_flip")
49                 col.itemR(mesh, "double_sided")
50
51 class DATA_PT_vertex_groups(DataButtonsPanel):
52         __label__ = "Vertex Groups"
53         
54         def poll(self, context):
55                 return (context.object and context.object.type in ('MESH', 'LATTICE'))
56
57         def draw(self, context):
58                 layout = self.layout
59                 
60                 ob = context.object
61
62                 row = layout.row()
63                 row.template_list(ob, "vertex_groups", ob, "active_vertex_group_index")
64
65                 col = row.column(align=True)
66                 col.itemO("object.vertex_group_add", icon='ICON_ZOOMIN', text="")
67                 col.itemO("object.vertex_group_remove", icon='ICON_ZOOMOUT', text="")
68
69                 col.itemO("object.vertex_group_copy", icon='ICON_BLANK1', text="")
70                 if ob.data.users > 1:
71                         col.itemO("object.vertex_group_copy_to_linked", icon='ICON_BLANK1', text="")
72
73                 group = ob.active_vertex_group
74                 if group:
75                         row = layout.row()
76                         row.itemR(group, "name")
77
78                 if ob.mode == 'EDIT':
79                         row = layout.row()
80                         
81                         sub = row.row(align=True)
82                         sub.itemO("object.vertex_group_assign", text="Assign")
83                         sub.itemO("object.vertex_group_remove_from", text="Remove")
84                         
85                         sub = row.row(align=True)
86                         sub.itemO("object.vertex_group_select", text="Select")
87                         sub.itemO("object.vertex_group_deselect", text="Deselect")
88
89                         layout.itemR(context.tool_settings, "vertex_group_weight", text="Weight")
90
91 class DATA_PT_shape_keys(DataButtonsPanel):
92         __label__ = "Shape Keys"
93         
94         def poll(self, context):
95                 return (context.object and context.object.type in ('MESH', 'LATTICE'))
96
97         def draw(self, context):
98                 layout = self.layout
99                 
100                 ob = context.object
101                 key = ob.data.shape_keys
102                 kb = ob.active_shape_key
103
104                 row = layout.row()
105                 row.template_list(key, "keys", ob, "active_shape_key_index")
106
107                 col = row.column()
108
109                 subcol = col.column(align=True)
110                 subcol.itemO("object.shape_key_add", icon='ICON_ZOOMIN', text="")
111                 subcol.itemO("object.shape_key_remove", icon='ICON_ZOOMOUT', text="")
112
113                 if kb:
114                         col.itemS()
115
116                         subcol = col.column(align=True)
117                         subcol.itemR(ob, "shape_key_lock", icon='ICON_UNPINNED', text="")
118                         subcol.itemR(kb, "mute", icon='ICON_MUTE_IPO_ON', text="")
119
120                         if key.relative:
121                                 row = layout.row()
122                                 row.itemR(key, "relative")
123                                 row.itemL()
124
125                                 row = layout.row()
126                                 row.itemR(kb, "name")
127
128                                 if ob.active_shape_key_index != 0:
129                                         
130                                         row = layout.row()
131                                         row.enabled = ob.shape_key_lock == False
132                                         row.itemR(kb, "value", slider=True)
133                                         
134                                         split = layout.split()
135                                         sub = split.column(align=True)
136                                         sub.enabled = ob.shape_key_lock == False
137                                         sub.itemL(text="Range:")
138                                         sub.itemR(kb, "slider_min", text="Min")
139                                         sub.itemR(kb, "slider_max", text="Max")
140                                         
141                                         sub = split.column()
142                                         sub.itemL(text="Blend:")
143                                         sub.item_pointerR(kb, "vertex_group", ob, "vertex_groups", text="")
144                                         sub.item_pointerR(kb, "relative_key", key, "keys", text="")
145                                         
146                         else:
147                                 row = layout.row()
148                                 row.itemR(key, "relative")
149                                 row.itemR(key, "slurph")
150
151                                 layout.itemR(kb, "name")
152
153                 if ob.mode == 'EDIT':
154                         layout.enabled = False
155
156 class DATA_PT_uv_texture(DataButtonsPanel):
157         __label__ = "UV Texture"
158         
159         def draw(self, context):
160                 layout = self.layout
161                 
162                 me = context.mesh
163
164                 row = layout.row()
165                 col = row.column()
166                 
167                 col.template_list(me, "uv_textures", me, "active_uv_texture_index", rows=2)
168
169                 col = row.column(align=True)
170                 col.itemO("mesh.uv_texture_add", icon='ICON_ZOOMIN', text="")
171                 col.itemO("mesh.uv_texture_remove", icon='ICON_ZOOMOUT', text="")
172
173                 lay = me.active_uv_texture
174                 if lay:
175                         layout.itemR(lay, "name")
176
177 class DATA_PT_vertex_colors(DataButtonsPanel):
178         __label__ = "Vertex Colors"
179         
180         def draw(self, context):
181                 layout = self.layout
182                 
183                 me = context.mesh
184
185                 row = layout.row()
186                 col = row.column()
187
188                 col.template_list(me, "vertex_colors", me, "active_vertex_color_index", rows=2)
189
190                 col = row.column(align=True)
191                 col.itemO("mesh.vertex_color_add", icon='ICON_ZOOMIN', text="")
192                 col.itemO("mesh.vertex_color_remove", icon='ICON_ZOOMOUT', text="")
193
194                 lay = me.active_vertex_color
195                 if lay:
196                         layout.itemR(lay, "name")
197
198 bpy.types.register(DATA_PT_context_mesh)
199 bpy.types.register(DATA_PT_normals)
200 bpy.types.register(DATA_PT_vertex_groups)
201 bpy.types.register(DATA_PT_shape_keys)
202 bpy.types.register(DATA_PT_uv_texture)
203 bpy.types.register(DATA_PT_vertex_colors)