Commit: 91d72d7865808b649be4fa367d02d63619d90fd2
Author: Nathan Vollmer
Date:   Sat Sep 3 12:21:06 2016 -0600
Branches: soc-2016-pbvh-painting
https://developer.blender.org/rB91d72d7865808b649be4fa367d02d63619d90fd2

Got foreground-background colors working with vertex paint.

===================================================================

M       release/scripts/startup/bl_ui/space_view3d_toolbar.py
M       source/blender/editors/sculpt_paint/paint_image.c
M       source/blender/editors/sculpt_paint/paint_ops.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py 
b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 5c394b0..ee9b7e5 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1130,7 +1130,11 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
             self.prop_unified_color_picker(col, context, brush, "color", 
value_slider=True)
             if settings.palette:
                 col.template_palette(settings, "palette", color=True)
-            self.prop_unified_color(col, context, brush, "color", text="")
+            row = col.row(align=True)
+            self.prop_unified_color(row, context, brush, "color", text="")
+            self.prop_unified_color(row, context, brush, "secondary_color", 
text="")
+            row.separator()
+            row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', 
text="")
 
             col.separator()
             row = col.row(align=True)
diff --git a/source/blender/editors/sculpt_paint/paint_image.c 
b/source/blender/editors/sculpt_paint/paint_image.c
index bf344e1..7a6702f 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -1448,7 +1448,18 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot)
 static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op))
 {
        UnifiedPaintSettings *ups = 
&CTX_data_tool_settings(C)->unified_paint_settings;
-       Brush *br = image_paint_brush(C);
+
+       Brush *br;
+       Object *ob = CTX_data_active_object(C);
+       if (!(ob && (ob->mode & OB_MODE_VERTEX_PAINT))) {
+               br = image_paint_brush(C);
+       }
+       else {
+               ToolSettings *ts = CTX_data_tool_settings(C);
+               VPaint *vp = ts->vpaint;
+               br = BKE_paint_brush(&vp->paint);
+       }
+
        if (ups->flag & UNIFIED_PAINT_COLOR) {
                swap_v3_v3(ups->rgb, ups->secondary_rgb);
        }
@@ -1467,7 +1478,11 @@ static int brush_colors_flip_poll(bContext *C)
                if (br->imagepaint_tool == PAINT_TOOL_DRAW)
                        return 1;
        }
-
+       else {
+               Object *ob = CTX_data_active_object(C);
+               if (ob && (ob->mode & OB_MODE_VERTEX_PAINT))
+                       return 1;
+       }
        return 0;
 }
 
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c 
b/source/blender/editors/sculpt_paint/paint_ops.c
index f88b641..ace1804 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -1615,6 +1615,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
        keymap->poll = vertex_paint_mode_poll;
 
        WM_keymap_verify_item(keymap, "PAINT_OT_vertex_paint", LEFTMOUSE, 
KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "PAINT_OT_brush_colors_flip", XKEY, 
KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "PAINT_OT_sample_color", SKEY, KM_PRESS, 0, 
0);
 
        WM_keymap_add_item(keymap,

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to