Merging r49953 through r50015 into from trunk into soc-2011-tomato
[blender.git] / source / blender / editors / space_image / image_buttons.c
index b8ca0deb7704b2b877e988b2fc555e2a48d4027c..d858e05132d52ef1b09101c72d6a19d8efabe55b 100644 (file)
@@ -611,6 +611,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
        uiLayout *row, *split, *col;
        uiBlock *block;
        char str[128];
+
        void *lock;
 
        if (!ptr->data)
@@ -726,8 +727,11 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
                                        uiItemL(layout, str, ICON_NONE);
                                }
                        }
-                       
+
                        if (ima->source != IMA_SRC_GENERATED) {
+                               col = uiLayoutColumn(layout, FALSE);
+                               uiTemplateColorspaceSettings(col, &imaptr, "colorspace_settings");
+
                                if (compact == 0) { /* background image view doesnt need these */
                                        uiItemS(layout);
 
@@ -796,11 +800,14 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr)
 {
        ImageFormatData *imf = imfptr->data;
        ID *id = imfptr->id.data;
+       PointerRNA display_settings_ptr;
+       PropertyRNA *prop;
        const int depth_ok = BKE_imtype_valid_depths(imf->imtype);
        /* some settings depend on this being a scene thats rendered */
        const short is_render_out = (id && GS(id->name) == ID_SCE);
 
        uiLayout *col, *row, *split, *sub;
+       int show_preview = FALSE;
 
        col = uiLayoutColumn(layout, FALSE);
 
@@ -841,6 +848,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr)
        }
 
        if (is_render_out && (imf->imtype == R_IMF_IMTYPE_OPENEXR)) {
+               show_preview = TRUE;
                uiItemR(row, imfptr, "use_preview", 0, NULL, ICON_NONE);
        }
 
@@ -862,6 +870,21 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr)
                uiItemR(col, imfptr, "cineon_gamma", 0, NULL, ICON_NONE);
 #endif
        }
+
+       /* color management */
+       if (!BKE_imtype_supports_float(imf->imtype) ||
+           (show_preview && imf->flag & R_IMF_FLAG_PREVIEW_JPG))
+       {
+               prop = RNA_struct_find_property(imfptr, "display_settings");
+               display_settings_ptr = RNA_property_pointer_get(imfptr, prop);
+
+               col = uiLayoutColumn(layout, FALSE);
+               uiItemL(col, IFACE_("Color Management"), ICON_NONE);
+
+               uiItemR(col, &display_settings_ptr, "display_device", 0, NULL, ICON_NONE);
+
+               uiTemplateColormanagedViewSettings(col, NULL, imfptr, "view_settings", FALSE);
+       }
 }
 
 void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser *iuser)