soc-2008-mxcurioni: merged changes to revision 23516
[blender.git] / release / scripts / ui / buttons_data_metaball.py
1 import bpy
2
3 class DataButtonsPanel(bpy.types.Panel):
4         __space_type__ = 'PROPERTIES'
5         __region_type__ = 'WINDOW'
6         __context__ = "data"
7         
8         def poll(self, context):
9                 return context.meta_ball
10
11 class DATA_PT_context_metaball(DataButtonsPanel):
12         __show_header__ = False
13         
14         def draw(self, context):
15                 layout = self.layout
16                 
17                 ob = context.object
18                 mball = context.meta_ball
19                 space = context.space_data
20
21                 split = layout.split(percentage=0.65)
22
23                 if ob:
24                         split.template_ID(ob, "data")
25                         split.itemS()
26                 elif mball:
27                         split.template_ID(space, "pin_id")
28                         split.itemS()
29
30 class DATA_PT_metaball(DataButtonsPanel):
31         __label__ = "Metaball"
32
33         def draw(self, context):
34                 layout = self.layout
35                 
36                 mball = context.meta_ball
37                 
38                 split = layout.split()
39                 
40                 col = split.column()
41                 col.itemL(text="Resolution:")
42                 sub = col.column(align=True)
43                 sub.itemR(mball, "wire_size", text="View")
44                 sub.itemR(mball, "render_size", text="Render")  
45                 
46                 col = split.column()
47                 col.itemL(text="Settings:")
48                 col.itemR(mball, "threshold", text="Threshold")
49
50                 layout.itemL(text="Update:")
51                 layout.itemR(mball, "flag", expand=True)
52
53 class DATA_PT_metaball_element(DataButtonsPanel):
54         __label__ = "Active Element"
55         
56         def poll(self, context):
57                 return (context.meta_ball and context.meta_ball.active_element)
58
59         def draw(self, context):
60                 layout = self.layout
61                 
62                 metaelem = context.meta_ball.active_element
63                 
64                 split = layout.split(percentage=0.3)
65                 split.itemL(text="Type:")       
66                 split.itemR(metaelem, "type", text="")
67                 
68                 split = layout.split()
69                         
70                 col = split.column()
71                 col.itemL(text="Settings:")
72                 col.itemR(metaelem, "stiffness", text="Stiffness")
73                 col.itemR(metaelem, "negative", text="Negative")
74                 col.itemR(metaelem, "hide", text="Hide")
75                 
76                 if metaelem.type == 'BALL':
77                         col = split.column(align=True)
78                         
79                 elif metaelem.type == 'CUBE':
80                         col = split.column(align=True)
81                         col.itemL(text="Size:") 
82                         col.itemR(metaelem, "size_x", text="X")
83                         col.itemR(metaelem, "size_y", text="Y")
84                         col.itemR(metaelem, "size_z", text="Z")
85                         
86                 elif metaelem.type == 'TUBE':
87                         col = split.column(align=True)
88                         col.itemL(text="Size:") 
89                         col.itemR(metaelem, "size_x", text="X")
90                         
91                 elif metaelem.type == 'PLANE':
92                         col = split.column(align=True)
93                         col.itemL(text="Size:") 
94                         col.itemR(metaelem, "size_x", text="X")
95                         col.itemR(metaelem, "size_y", text="Y")
96                         
97                 elif metaelem.type == 'ELLIPSOID':
98                         col = split.column(align=True)
99                         col.itemL(text="Size:") 
100                         col.itemR(metaelem, "size_x", text="X")
101                         col.itemR(metaelem, "size_y", text="Y")
102                         col.itemR(metaelem, "size_z", text="Z")
103
104 bpy.types.register(DATA_PT_context_metaball)
105 bpy.types.register(DATA_PT_metaball)
106 bpy.types.register(DATA_PT_metaball_element)