[Bf-blender-cvs] [0294327] master: Hide 3D Cursor in Paint Modes (with exceptions)

Julian Eisel noreply at git.blender.org
Tue Feb 17 03:26:34 CET 2015


Commit: 0294327615bb14655b03e0d9f0e0ce6e28ff2e7c
Author: Julian Eisel
Date:   Tue Feb 17 03:26:03 2015 +0100
Branches: master
https://developer.blender.org/rB0294327615bb14655b03e0d9f0e0ce6e28ff2e7c

Hide 3D Cursor in Paint Modes (with exceptions)

= Hide 3D Cursor in Paint Modes (with exceptions)

In paint modes, the 3D Cursor mostly is rather useless so it's more annoying than useful. This patch aims to hide the cursor in cases it's not used.

Included exceptions (cases where cursor is drawn in paint modes):
* Active object is in weight paint mode and a selected bone in pose mode can be found
* Clone brush (only if //Clone from paint slot// is disabled)

There might be more exceptions where the cursor should be shown in paint modes, but those are all I could find for now. Feel free to hint me for more.

Note: After D1110 was rejected, Campbell and me discussed this a bit more on IRC and agreed that this behaviour might be a good solution.

Reviewers: psy-fi, campbellbarton

Reviewed By: psy-fi, campbellbarton

Projects: #user_interface

Differential Revision: https://developer.blender.org/D1113

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

M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index ff212a1..a564de8 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -904,8 +904,15 @@ static void view3d_main_area_listener(bScreen *sc, ScrArea *sa, ARegion *ar, wmN
 			ED_region_tag_redraw(ar);
 			break;
 		case NC_BRUSH:
-			if (wmn->action == NA_EDITED)
-				ED_region_tag_redraw_overlay(ar);
+			switch (wmn->action) {
+				case NA_EDITED:
+					ED_region_tag_redraw_overlay(ar);
+				/* used on brush changes - needed because 3d cursor
+				 * has to be drawn if clone brush is selected */
+				case NA_SELECTED:
+					ED_region_tag_redraw(ar);
+				break;
+			}
 			break;
 		case NC_MATERIAL:
 			switch (wmn->data) {
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 0f57a83..ba031c8 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -42,6 +42,7 @@
 #include "DNA_lamp_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_world_types.h"
+#include "DNA_brush_types.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -3576,6 +3577,36 @@ static void view3d_main_area_draw_objects(const bContext *C, Scene *scene, View3
 
 }
 
+static bool is_cursor_visible(Scene *scene)
+{
+	Object *ob = OBACT;
+
+	/* don't draw cursor in paint modes, but with a few exceptions */
+	if (ob && ob->mode & OB_MODE_ALL_PAINT) {
+		/* exception: object is in weight paint and has deforming armature in pose mode */
+		if (ob->mode & OB_MODE_WEIGHT_PAINT) {
+			if (BKE_object_pose_armature_get(ob) != NULL) {
+				return true;
+			}
+		}
+		/* exception: object in texture paint mode, clone brush, use_clone_layer disabled */
+		else if (ob->mode & OB_MODE_TEXTURE_PAINT) {
+			const Paint *p = BKE_paint_get_active(scene);
+
+			if (p && p->brush->imagepaint_tool == PAINT_TOOL_CLONE) {
+				if ((scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE) == 0) {
+					return true;
+				}
+			}
+		}
+
+		/* no exception met? then don't draw cursor! */
+		return false;
+	}
+
+	return true;
+}
+
 static void view3d_main_area_draw_info(const bContext *C, Scene *scene,
                                        ARegion *ar, View3D *v3d,
                                        const char *grid_unit, bool render_border)
@@ -3609,7 +3640,10 @@ static void view3d_main_area_draw_info(const bContext *C, Scene *scene,
 	if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
 		Object *ob;
 
-		drawcursor(scene, ar, v3d);
+		/* 3d cursor */
+		if (is_cursor_visible(scene)) {
+			drawcursor(scene, ar, v3d);
+		}
 
 		if (U.uiflag & USER_SHOW_ROTVIEWICON)
 			draw_view_axis(rv3d, &rect);
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 0930767..e09e035 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -292,7 +292,7 @@ static void rna_Paint_brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po
 	Paint *paint = ptr->data;
 	Brush *br = paint->brush;
 	BKE_paint_invalidate_overlay_all();
-	WM_main_add_notifier(NC_BRUSH | NA_EDITED, br);
+	WM_main_add_notifier(NC_BRUSH | NA_SELECTED, br);
 }
 
 static void rna_ImaPaint_viewport_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
@@ -730,7 +730,7 @@ static void rna_def_image_paint(BlenderRNA *brna)
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_CLONE);
 	RNA_def_property_ui_text(prop, "Clone Map",
 	                         "Use another UV map as clone source, otherwise use the 3D cursor as the source");
-	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
+	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_viewport_update");
 	
 	/* integers */




More information about the Bf-blender-cvs mailing list