3f30e214f24f417107d04fe3b4ea64f2ad42d62f
[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 bpy.types import Panel
22 from rna_prop_ui import PropertyPanel
23
24
25 class DataButtonsPanel:
26     bl_space_type = 'PROPERTIES'
27     bl_region_type = 'WINDOW'
28     bl_context = "data"
29
30     @classmethod
31     def poll(cls, context):
32         engine = context.scene.render.engine
33         return context.speaker and (engine in cls.COMPAT_ENGINES)
34
35
36 class DATA_PT_context_speaker(DataButtonsPanel, Panel):
37     bl_label = ""
38     bl_options = {'HIDE_HEADER'}
39     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
40
41     def draw(self, context):
42         layout = self.layout
43
44         ob = context.object
45         speaker = context.speaker
46         space = context.space_data
47
48         split = layout.split(percentage=0.65)
49
50         if ob:
51             split.template_ID(ob, "data")
52         elif speaker:
53             split.template_ID(space, "pin_id")
54
55
56 class DATA_PT_speaker(DataButtonsPanel, Panel):
57     bl_label = "Sound"
58     COMPAT_ENGINES = {'BLENDER_RENDER'}
59
60     def draw(self, context):
61         layout = self.layout
62
63         speaker = context.speaker
64
65         split = layout.split(percentage=0.75)
66
67         split.template_ID(speaker, "sound", open="sound.open_mono")
68         split.prop(speaker, "muted")
69
70         row = layout.row()
71         row.prop(speaker, "volume")
72         row.prop(speaker, "pitch")
73
74
75 class DATA_PT_distance(DataButtonsPanel, Panel):
76     bl_label = "Distance"
77     COMPAT_ENGINES = {'BLENDER_RENDER'}
78
79     def draw(self, context):
80         layout = self.layout
81
82         speaker = context.speaker
83
84         split = layout.split()
85
86         col = split.column()
87         col.label("Volume:")
88         col.prop(speaker, "volume_min", text="Minimum")
89         col.prop(speaker, "volume_max", text="Maximum")
90         col.prop(speaker, "attenuation")
91
92         col = split.column()
93         col.label("Distance:")
94         col.prop(speaker, "distance_max", text="Maximum")
95         col.prop(speaker, "distance_reference", text="Reference")
96
97
98 class DATA_PT_cone(DataButtonsPanel, Panel):
99     bl_label = "Cone"
100     COMPAT_ENGINES = {'BLENDER_RENDER'}
101
102     def draw(self, context):
103         layout = self.layout
104
105         speaker = context.speaker
106
107         split = layout.split()
108
109         col = split.column()
110         col.label("Angle:")
111         col.prop(speaker, "cone_angle_outer", text="Outer")
112         col.prop(speaker, "cone_angle_inner", text="Inner")
113
114         col = split.column()
115         col.label("Volume:")
116         col.prop(speaker, "cone_volume_outer", text="Outer")
117
118
119 class DATA_PT_custom_props_speaker(DataButtonsPanel, PropertyPanel, Panel):
120     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
121     _context_path = "object.data"
122     _property_type = bpy.types.Speaker
123
124
125 classes = (
126     DATA_PT_cone,
127     DATA_PT_context_speaker,
128     DATA_PT_custom_props_speaker,
129     DATA_PT_distance,
130     DATA_PT_speaker,
131 )
132
133 if __name__ == "__main__":  # only for live edit.
134     from bpy.utils import register_class
135     for cls in classes:
136         register_class(cls)