svn merge ^/trunk/blender -r49890:49917
[blender.git] / source / blender / editors / interface / interface_templates.c
index 0c69a1888d08a5afe60815faa11e7caf8ce5eca8..450c4c8920e7b14f2284943fa539007d09ce4bf6 100644 (file)
@@ -1743,6 +1743,13 @@ static void curvemap_buttons_redraw(bContext *C, void *UNUSED(arg1), void *UNUSE
        ED_region_tag_redraw(CTX_wm_region(C));
 }
 
+static void curvemap_buttons_update(bContext *UNUSED(C), void *UNUSED(arg1), void *cumap_v)
+{
+       CurveMapping *cumap = cumap_v;
+
+       curvemapping_changed(cumap, TRUE);
+}
+
 static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v)
 {
        CurveMapping *cumap = cumap_v;
@@ -1765,12 +1772,14 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v)
 static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labeltype, int levels, int brush, RNAUpdateCb *cb)
 {
        CurveMapping *cumap = ptr->data;
+       CurveMap *cm = &cumap->cm[cumap->cur];
+       CurveMapPoint *cmp = NULL;
        uiLayout *row, *sub, *split;
        uiBlock *block;
        uiBut *bt;
        float dx = UI_UNIT_X;
        int icon, size;
-       int bg = -1;
+       int bg = -1, i;
 
        block = uiLayoutGetBlock(layout);
 
@@ -1875,6 +1884,21 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe
        row = uiLayoutRow(layout, FALSE);
        uiDefBut(block, BUT_CURVE, 0, "", 0, 0, size, MIN2(size, 200), cumap, 0.0f, 1.0f, bg, 0, "");
 
+       /* sliders for selected point */
+       for (i = 0; i < cm->totpoint; i++) {
+               if (cm->curve[i].flag & CUMA_SELECT) {
+                       cmp = &cm->curve[i];
+                       break;
+               }
+       }
+
+       if (cmp) {
+               uiLayoutColumn(layout, TRUE);
+               uiBlockSetNFunc(block, curvemap_buttons_update, NULL, cumap);
+               uiDefButF(block, NUM, 0, "X", 0, 2 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y, &cmp->x, 0.0f, 1.0f, 1, 5, "");
+               uiDefButF(block, NUM, 0, "Y", 0, 1 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y, &cmp->y, 0.0f, 1.0f, 1, 5, "");
+       }
+
        /* black/white levels */
        if (levels) {
                split = uiLayoutSplit(layout, 0.0f, FALSE);
@@ -2769,3 +2793,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);
+}