2.5 UI Files:
[blender.git] / release / scripts / startup / bl_ui / properties_data_speaker.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from rna_prop_ui import PropertyPanel
22
23
24 class DataButtonsPanel():
25     bl_space_type = 'PROPERTIES'
26     bl_region_type = 'WINDOW'
27     bl_context = "data"
28
29     @classmethod
30     def poll(cls, context):
31         engine = context.scene.render.engine
32         return context.speaker and (engine in cls.COMPAT_ENGINES)
33
34
35 class DATA_PT_context_speaker(DataButtonsPanel, bpy.types.Panel):
36     bl_label = ""
37     bl_options = {'HIDE_HEADER'}
38     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
39
40     def draw(self, context):
41         layout = self.layout
42
43         ob = context.object
44         speaker = context.speaker
45         space = context.space_data
46
47         split = layout.split(percentage=0.65)
48
49         if ob:
50             split.template_ID(ob, "data")
51         elif speaker:
52             split.template_ID(space, "pin_id")
53
54
55 class DATA_PT_speaker(DataButtonsPanel, bpy.types.Panel):
56     bl_label = "Sound"
57     COMPAT_ENGINES = {'BLENDER_RENDER'}
58
59     def draw(self, context):
60         layout = self.layout
61
62         speaker = context.speaker
63
64         split = layout.split(percentage=0.75)
65
66         split.template_ID(speaker, "sound", open="sound.open_mono")
67         split.prop(speaker, "muted")
68
69         row = layout.row()
70         row.prop(speaker, "volume")
71         row.prop(speaker, "pitch")
72
73
74 class DATA_PT_distance(DataButtonsPanel, bpy.types.Panel):
75     bl_label = "Distance"
76     COMPAT_ENGINES = {'BLENDER_RENDER'}
77
78     def draw(self, context):
79         layout = self.layout
80
81         speaker = context.speaker
82
83         split = layout.split()
84         
85         col = split.column()
86         col.label("Volume:")
87         col.prop(speaker, "volume_min", text="Minimum")
88         col.prop(speaker, "volume_max", text="Maximum")
89         col.prop(speaker, "attenuation")
90
91         col = split.column()
92         col.label("Distance:")
93         col.prop(speaker, "distance_max", text="Maximum")
94         col.prop(speaker, "distance_reference", text="Reference")
95
96
97 class DATA_PT_cone(DataButtonsPanel, bpy.types.Panel):
98     bl_label = "Cone"
99     COMPAT_ENGINES = {'BLENDER_RENDER'}
100
101     def draw(self, context):
102         layout = self.layout
103
104         speaker = context.speaker
105
106         split = layout.split()
107         col = split.column()
108
109         col.label("Angle:")
110         col.prop(speaker, "cone_angle_outer", text="Outer")
111         col.prop(speaker, "cone_angle_inner", text="Inner")
112
113         col = split.column()
114
115         col.label("Volume:")
116         col.prop(speaker, "cone_volume_outer", text="Outer")
117
118
119 class DATA_PT_custom_props_speaker(DataButtonsPanel, PropertyPanel, bpy.types.Panel):
120     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
121     _context_path = "object.data"
122     _property_type = bpy.types.Speaker
123
124 if __name__ == "__main__":  # only for live edit.
125     bpy.utils.register_module(__name__)