Merging r48971 through r48980 from trunk into soc-2011-tomato
[blender.git] / source / blender / editors / interface / interface_templates.c
index 4702253140a60b7da0754f1ab3614fde1a886eee..a87fc76d9d8e57733ef11a4873bfb6d5c53f2165 100644 (file)
@@ -2768,3 +2768,66 @@ void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr)
        }
 }
 
+/********************************* Color management *************************************/
+
+void uiTemplateColorspaceSettings(uiLayout *layout, PointerRNA *ptr, const char *propname)
+{
+       PropertyRNA *prop;
+       PointerRNA colorspace_settings_ptr;
+
+       prop = RNA_struct_find_property(ptr, propname);
+
+       if (!prop) {
+               printf("%s: property not found: %s.%s\n",
+                      __func__, RNA_struct_identifier(ptr->type), propname);
+               return;
+       }
+
+       colorspace_settings_ptr = RNA_property_pointer_get(ptr, prop);
+
+       uiItemL(layout, "Color Space:", ICON_NONE);
+       uiItemR(layout, &colorspace_settings_ptr, "name", 0, "", ICON_NONE);
+}
+
+void uiTemplateColormanagedViewSettings(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, int show_global_settings)
+{
+       PropertyRNA *prop;
+       PointerRNA view_transform_ptr;
+       uiLayout *col;
+       ColorManagedViewSettings *view_settings;
+
+       prop = RNA_struct_find_property(ptr, propname);
+
+       if (!prop) {
+               printf("%s: property not found: %s.%s\n",
+                      __func__, RNA_struct_identifier(ptr->type), propname);
+               return;
+       }
+
+       view_transform_ptr = RNA_property_pointer_get(ptr, prop);
+       view_settings = view_transform_ptr.data;
+
+       col = uiLayoutColumn(layout, FALSE);
+
+       if (show_global_settings) {
+               wmWindow *win = CTX_wm_window(C);
+               bScreen *screen = CTX_wm_screen(C);
+
+               uiItemR(col, &view_transform_ptr, "use_global_settings", 0, NULL, ICON_NONE);
+
+               if (view_settings->flag & COLORMANAGE_VIEW_USE_GLOBAL) {
+                       PointerRNA window_ptr;
+
+                       RNA_pointer_create(&screen->id, &RNA_Window, win, &window_ptr);
+
+                       prop = RNA_struct_find_property(&window_ptr, "view_settings");
+                       view_transform_ptr = RNA_property_pointer_get(&window_ptr, prop);
+               }
+       }
+
+       uiItemR(col, &view_transform_ptr, "view_transform", 0, "View", ICON_NONE);
+
+       col = uiLayoutColumn(layout, FALSE);
+       uiItemR(col, &view_transform_ptr, "exposure", 0, NULL, ICON_NONE);
+       uiItemR(col, &view_transform_ptr, "gamma", 0, NULL, ICON_NONE);
+}