Fields UI: Several attempts to follow UI guide and other things leaded to a really...
[blender.git] / release / ui / buttons_physics_field.py
1
2 import bpy
3
4 class PhysicButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "physics"
8
9         def poll(self, context):
10                 rd = context.scene.render_data
11                 return (context.object != None) and (not rd.use_game_engine)
12                 
13 class PHYSICS_PT_field(PhysicButtonsPanel):
14         __label__ = "Force Fields"
15         __default_closed__ = True
16
17         def draw(self, context):
18                 layout = self.layout
19                 
20                 ob = context.object
21                 field = ob.field
22
23                 #layout.active = field.enabled
24                 
25                 split = layout.split()
26                 
27                 col = split.column()
28                 col.itemR(field, "type", text="")
29                 
30                 col = split.column()
31                 split = layout.split(percentage=0.5)
32                 
33                 if field.type == 'NONE':
34                         col = split.column()
35                         
36                 elif field.type == 'GUIDE':
37                         col = split.column()
38                         col.itemR(field, "guide_path_add")
39                         
40                 elif field.type == 'WIND':
41                         col.itemR(field, "strength")
42                         
43                         col = split.column()
44                         col.itemR(field, "noise")
45                         col.itemR(field, "seed")
46
47                 elif field.type == 'VORTEX':
48                         col.itemR(field, "strength")
49                         
50                         col = split.column()
51
52                 elif field.type in ('SPHERICAL', 'CHARGE', 'LENNARDJ'):
53                         col = split.column()
54                         col.itemR(field, "strength")
55                         
56                         col = split.column()
57                         col.itemR(field, "planar")
58                         col = split.column()
59                         col.itemR(field, "surface")
60                         
61                 elif field.type == 'BOID':
62                         col.itemR(field, "strength")
63                         
64                         col = split.column()
65                         col.itemR(field, "surface")
66                         
67                 elif field.type == 'MAGNET':
68                         col.itemR(field, "strength")
69                         
70                         col = split.column()
71                         col.itemR(field, "planar")
72                         
73                 elif field.type == 'HARMONIC':
74                         col.itemR(field, "strength")
75                         col.itemR(field, "harmonic_damping", text="Damping")
76                         
77                         col = split.column()
78                         col.itemR(field, "surface")
79                         col.itemR(field, "planar")
80                         
81                 elif field.type == 'TEXTURE':
82                         col.itemR(field, "strength")
83                         col.itemR(field, "texture", text="")
84                         col.itemR(field, "force_2d")
85                         
86                         col = split.column()
87                         col.itemR(field, "texture_mode", text="")
88                         col.itemR(field, "texture_nabla")
89                         col.itemR(field, "use_coordinates")
90                         col.itemR(field, "root_coordinates")
91                         
92                 if field.type in ('HARMONIC', 'SPHERICAL', 'CHARGE', 'WIND', 'VORTEX', 'TEXTURE', 'MAGNET', 'BOID'):
93                         
94                         layout.itemL(text="Falloff:")
95                         layout.itemR(field, "falloff_type", expand=True)
96
97                         split = layout.split(percentage=0.35)
98                         
99                         col = split.column()
100                         col.itemR(field, "positive_z", text="Positive Z")
101                         col.itemR(field, "use_min_distance", text="Use Minimum")
102                         col.itemR(field, "use_max_distance", text="Use Maximum")
103
104                         col = split.column()
105                         col.itemR(field, "falloff_power", text="Power")
106                         
107                         sub = col.column()
108                         sub.active = field.use_min_distance
109                         sub.itemR(field, "minimum_distance", text="Distance")
110                         
111                         sub = col.column()
112                         sub.active = field.use_max_distance
113                         sub.itemR(field, "maximum_distance", text="Distance")
114                         
115                         if field.falloff_type == 'CONE':
116                                 
117                                 layout.itemS()
118                                 
119                                 split = layout.split(percentage=0.35)
120                                 
121                                 col = split.column()
122                                 col.itemL(text="Angular:")
123                                 col.itemR(field, "use_radial_min", text="Use Minimum")  
124                                 col.itemR(field, "use_radial_max", text="Use Maximum")
125                                 
126                                 col = split.column()
127                                 col.itemR(field, "radial_falloff", text="Power")
128                                 
129                                 sub = col.column()
130                                 sub.active = field.use_radial_min
131                                 sub.itemR(field, "radial_minimum", text="Angle")
132                                 
133                                 sub = col.column()
134                                 sub.active = field.use_radial_max
135                                 sub.itemR(field, "radial_maximum", text="Angle")
136                                 
137                         elif field.falloff_type == 'TUBE':
138                                 
139                                 layout.itemS()
140                                 
141                                 split = layout.split(percentage=0.35)
142                                         
143                                 col = split.column()
144                                 col.itemL(text="Radial:")       
145                                 col.itemR(field, "use_radial_min", text="Use Minimum")  
146                                 col.itemR(field, "use_radial_max", text="Use Maximum")
147                                 
148                                 col = split.column()
149                                 col.itemR(field, "radial_falloff", text="Power")
150                                 
151                                 sub = col.column()
152                                 sub.active = field.use_radial_min
153                                 sub.itemR(field, "radial_minimum", text="Distance")
154                                 
155                                 sub = col.column()
156                                 sub.active = field.use_radial_max
157                                 sub.itemR(field, "radial_maximum", text="Distance")
158                                 
159                 #if ob.type in "CURVE":
160                         #if field.type == "GUIDE":
161                                 #colsub = col.column(align=True)
162                         
163                 #if field.type != "NONE":
164                         #layout.itemR(field, "strength")
165
166                 #if field.type in ("HARMONIC", "SPHERICAL", "CHARGE", "LENNARDj"):
167                         #if ob.type in ("MESH", "SURFACE", "FONT", "CURVE"):
168                                 #layout.itemR(field, "surface")
169
170 class PHYSICS_PT_collision(PhysicButtonsPanel):
171         __label__ = "Collision"
172         __default_closed__ = True
173         
174         def poll(self, context):
175                 ob = context.object
176                 rd = context.scene.render_data
177                 return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
178
179         def draw_header(self, context):
180                 settings = context.object.collision
181                 self.layout.itemR(settings, "enabled", text="")
182
183         def draw(self, context):
184                 layout = self.layout
185                 
186                 md = context.collision
187                 settings = context.object.collision
188
189                 layout.active = settings.enabled
190                 
191                 split = layout.split()
192                 
193                 col = split.column()
194                 col.itemL(text="Particle:")
195                 col.itemR(settings, "permeability", slider=True)
196                 col.itemL(text="Particle Damping:")
197                 sub = col.column(align=True)
198                 sub.itemR(settings, "damping_factor", text="Factor", slider=True)
199                 sub.itemR(settings, "random_damping", text="Random", slider=True)
200                 
201                 col.itemL(text="Soft Body and Cloth:")
202                 sub = col.column(align=True)
203                 sub.itemR(settings, "outer_thickness", text="Outer", slider=True)
204                 sub.itemR(settings, "inner_thickness", text="Inner", slider=True)
205                 
206                 layout.itemL(text="Force Fields:")
207                 layout.itemR(md, "absorption", text="Absorption")
208                 
209                 col = split.column()
210                 col.itemL(text="")
211                 col.itemR(settings, "kill_particles")
212                 col.itemL(text="Particle Friction:")
213                 sub = col.column(align=True)
214                 sub.itemR(settings, "friction_factor", text="Factor", slider=True)
215                 sub.itemR(settings, "random_friction", text="Random", slider=True)
216                 col.itemL(text="Soft Body Damping:")
217                 col.itemR(settings, "damping", text="Factor", slider=True)
218                 
219 bpy.types.register(PHYSICS_PT_field)
220 bpy.types.register(PHYSICS_PT_collision)