Amaranth Addon
[blender-addons-contrib.git] / amaranth / misc / color_management.py
1 #  This program is free software; you can redistribute it and/or
2 #  modify it under the terms of the GNU General Public License
3 #  as published by the Free Software Foundation; either version 2
4 #  of the License, or (at your option) any later version.
5 #
6 #  This program is distributed in the hope that it will be useful,
7 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
8 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9 #  GNU General Public License for more details.
10 #
11 #  You should have received a copy of the GNU General Public License
12 #  along with this program; if not, write to the Free Software Foundation,
13 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 """
15 Color Management Presets
16
17 Save your Color Management options as presets, for easy re-use.
18
19 It will pretty much every option in the Color Management panel, such as
20 the look, color settings, and so on. Except the curve points (have to
21 figure out how to do that nicely), good news is that in Blender 2.69+ you
22 can now copy/paste curves.
23 """
24
25 import bpy
26 from bl_operators.presets import AddPresetBase
27
28
29 class AMTH_SCENE_MT_color_management_presets(bpy.types.Menu):
30
31     """List of Color Management presets"""
32     bl_label = "Color Management Presets"
33     preset_subdir = "color"
34     preset_operator = "script.execute_preset"
35     draw = bpy.types.Menu.draw_preset
36
37
38 class AMTH_AddPresetColorManagement(AddPresetBase, bpy.types.Operator):
39
40     """Add or remove a Color Management preset"""
41     bl_idname = "scene.color_management_preset_add"
42     bl_label = "Add Color Management Preset"
43     preset_menu = "AMTH_SCENE_MT_color_management_presets"
44
45     preset_defines = [
46         "scene = bpy.context.scene",
47     ]
48
49     preset_values = [
50         "scene.view_settings.view_transform",
51         "scene.display_settings.display_device",
52         "scene.view_settings.exposure",
53         "scene.view_settings.gamma",
54         "scene.view_settings.look",
55         "scene.view_settings.use_curve_mapping",
56         "scene.sequencer_colorspace_settings.name",
57     ]
58
59     preset_subdir = "color"
60
61
62 def ui_color_management_presets(self, context):
63
64     layout = self.layout
65
66     row = layout.row(align=True)
67     row.menu("AMTH_SCENE_MT_color_management_presets",
68              text=bpy.types.AMTH_SCENE_MT_color_management_presets.bl_label)
69     row.operator("scene.color_management_preset_add", text="", icon="ZOOMIN")
70     row.operator("scene.color_management_preset_add",
71                  text="", icon="ZOOMOUT").remove_active = True
72     layout.separator()
73
74
75 def register():
76     bpy.utils.register_class(AMTH_AddPresetColorManagement)
77     bpy.utils.register_class(AMTH_SCENE_MT_color_management_presets)
78     bpy.types.SCENE_PT_color_management.prepend(ui_color_management_presets)
79
80
81 def unregister():
82     bpy.utils.unregister_class(AMTH_AddPresetColorManagement)
83     bpy.utils.unregister_class(AMTH_SCENE_MT_color_management_presets)
84     bpy.types.SCENE_PT_color_management.remove(ui_color_management_presets)