svn merge -r39781:39792 https://svn.blender.org/svnroot/bf-blender/trunk/blender...
[blender-staging.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         split = layout.split()
70
71         row = split.row()
72
73         row.prop(speaker, "volume")
74         row.prop(speaker, "pitch")
75
76
77 class DATA_PT_distance(DataButtonsPanel, bpy.types.Panel):
78     bl_label = "Distance"
79     COMPAT_ENGINES = {'BLENDER_RENDER'}
80
81     def draw(self, context):
82         layout = self.layout
83
84         speaker = context.speaker
85
86         split = layout.split()
87         col = split.column()
88
89         col.label("Volume:")
90         col.prop(speaker, "volume_min", text="Minimum")
91         col.prop(speaker, "volume_max", text="Maximum")
92         col.prop(speaker, "attenuation")
93
94         col = split.column()
95
96         col.label("Distance:")
97         col.prop(speaker, "distance_max", text="Maximum")
98         col.prop(speaker, "distance_reference", text="Reference")
99
100
101 class DATA_PT_cone(DataButtonsPanel, bpy.types.Panel):
102     bl_label = "Cone"
103     COMPAT_ENGINES = {'BLENDER_RENDER'}
104
105     def draw(self, context):
106         layout = self.layout
107
108         speaker = context.speaker
109
110         split = layout.split()
111         col = split.column()
112
113         col.label("Angle:")
114         col.prop(speaker, "cone_angle_outer", text="Outer")
115         col.prop(speaker, "cone_angle_inner", text="Inner")
116
117         col = split.column()
118
119         col.label("Volume:")
120         col.prop(speaker, "cone_volume_outer", text="Outer")
121
122
123 class DATA_PT_custom_props_speaker(DataButtonsPanel, PropertyPanel, bpy.types.Panel):
124     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
125     _context_path = "object.data"
126     _property_type = bpy.types.Speaker
127
128 if __name__ == "__main__":  # only for live edit.
129     bpy.utils.register_module(__name__)