[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22567] branches/blender2.5/blender: 2. 5 Paint:

Nicholas Bishop nicholasbishop at gmail.com
Mon Aug 17 17:05:19 CEST 2009


Revision: 22567
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22567
Author:   nicholasbishop
Date:     2009-08-17 17:05:18 +0200 (Mon, 17 Aug 2009)

Log Message:
-----------
2.5 Paint:

* Updated the brush selection UI to make the slots less apparent; adding and removing brushes now directly adds and removes slots.

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/space_view3d_toolbar.py
    branches/blender2.5/blender/source/blender/blenkernel/intern/paint.c
    branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_ops.c
    branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c

Modified: branches/blender2.5/blender/release/ui/space_view3d_toolbar.py
===================================================================
--- branches/blender2.5/blender/release/ui/space_view3d_toolbar.py	2009-08-17 14:29:29 UTC (rev 22566)
+++ branches/blender2.5/blender/release/ui/space_view3d_toolbar.py	2009-08-17 15:05:18 UTC (rev 22567)
@@ -296,14 +296,9 @@
 
 		if not context.particle_edit_object:
 			col = layout.split().column()
-			if paint:
-				row = col.row()
-				row.template_list(settings, "brushes", settings, "active_brush_index", rows=2)
+			row = col.row()
+			row.template_list(settings, "brushes", settings, "active_brush_index", rows=2)
 				
-				sub_col = row.column(align=True)
-				sub_col.itemO("paint.brush_slot_add", icon="ICON_ZOOMIN", text="")
-				sub_col.itemO("paint.brush_slot_remove", icon="ICON_ZOOMOUT", text="")
-
 			col.template_ID(settings, "brush", new="brush.add")
                 
 		# Particle Mode #

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/paint.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/paint.c	2009-08-17 14:29:29 UTC (rev 22566)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/paint.c	2009-08-17 15:05:18 UTC (rev 22567)
@@ -33,6 +33,7 @@
 
 #include "BKE_brush.h"
 #include "BKE_global.h"
+#include "BKE_library.h"
 #include "BKE_paint.h"
 
 #include <stdlib.h>
@@ -66,23 +67,33 @@
 
 void paint_brush_set(Paint *p, Brush *br)
 {
-	if(p && p->brushes) {
-		int i;
-
-		/* See if there's already a slot with the brush */
-		for(i = 0; i < p->brush_count; ++i) {
-			if(p->brushes[i] == br) {
-				p->active_brush_index = i;
-				break;
+	if(!br) {
+		/* Setting to NULL removes the current slot */
+		paint_brush_slot_remove(p);
+	}
+	else {
+		int found = 0;
+	
+		if(p && p->brushes) {
+			int i;
+			
+			/* See if there's already a slot with the brush */
+			for(i = 0; i < p->brush_count; ++i) {
+				if(p->brushes[i] == br) {
+					p->active_brush_index = i;
+					found = 1;
+					break;
+				}
 			}
+			
 		}
 		
+		if(!found)
+			paint_brush_slot_add(p);
+		
+		/* Make sure the current slot is the new brush */
+		p->brushes[p->active_brush_index] = br;
 	}
-	else
-		paint_brush_slot_add(p);
-
-	/* Make sure the current slot is the new brush */
-	p->brushes[p->active_brush_index] = br;
 }
 
 static void paint_brush_slots_alloc(Paint *p, const int count)
@@ -96,22 +107,24 @@
 
 void paint_brush_slot_add(Paint *p)
 {
-	Brush **orig = p->brushes;
-	int orig_count = p->brushes ? p->brush_count : 0;
+	if(p) {
+		Brush **orig = p->brushes;
+		int orig_count = p->brushes ? p->brush_count : 0;
 
-	/* Increase size of brush slot array */
-	paint_brush_slots_alloc(p, orig_count + 1);
-	if(orig) {
-		memcpy(p->brushes, orig, sizeof(Brush*) * orig_count);
-		MEM_freeN(orig);
+		/* Increase size of brush slot array */
+		paint_brush_slots_alloc(p, orig_count + 1);
+		if(orig) {
+			memcpy(p->brushes, orig, sizeof(Brush*) * orig_count);
+			MEM_freeN(orig);
+		}
+
+		p->active_brush_index = orig_count;
 	}
-
-	p->active_brush_index = orig_count;
 }
 
 void paint_brush_slot_remove(Paint *p)
 {
-	if(p->brushes) {
+	if(p && p->brushes) {
 		Brush **orig = p->brushes;
 		int src, dst;
 		

Modified: branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_ops.c	2009-08-17 14:29:29 UTC (rev 22566)
+++ branches/blender2.5/blender/source/blender/editors/sculpt_paint/paint_ops.c	2009-08-17 15:05:18 UTC (rev 22567)
@@ -44,22 +44,13 @@
 /* Brush operators */
 static int brush_add_exec(bContext *C, wmOperator *op)
 {
-	int type = RNA_enum_get(op->ptr, "type");
-	int sculpt_tool = SCULPT_TOOL_DRAW;
-	const char *name = "Brush";
+	/*int type = RNA_enum_get(op->ptr, "type");*/
 	Brush *br = NULL;
 
-	if(type == OB_MODE_SCULPT) {
-		sculpt_tool = RNA_enum_get(op->ptr, "sculpt_tool");
-		RNA_enum_name(brush_sculpt_tool_items, sculpt_tool, &name);
-	}
+	br = add_brush("Brush");
 
-	br = add_brush(name);
-
-	if(br) {
-		br->sculpt_tool = sculpt_tool;
+	if(br)
 		paint_brush_set(paint_get_active(CTX_data_scene(C)), br);
-	}
 	
 	return OPERATOR_FINISHED;
 }
@@ -71,23 +62,6 @@
 	{OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
 	{0, NULL, 0, NULL, NULL}};
 
-void SCULPT_OT_brush_add(wmOperatorType *ot)
-{
-	/* identifiers */
-	ot->name= "Add Brush";
-	ot->idname= "SCULPT_OT_brush_add";
-	
-	/* api callbacks */
-	ot->exec= brush_add_exec;
-	
-	/* flags */
-	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
-	RNA_def_enum(ot->srna, "sculpt_tool", brush_sculpt_tool_items, SCULPT_TOOL_DRAW, "Sculpt Tool", "");
-
-	RNA_def_enum(ot->srna, "type", brush_type_items, OB_MODE_SCULPT, "Type", "Which paint mode to create the brush for.");
-}
-
 void BRUSH_OT_add(wmOperatorType *ot)
 {
 	/* identifiers */
@@ -109,67 +83,14 @@
 	return !!paint_get_active(CTX_data_scene(C));
 }
 
-static int brush_slot_add_exec(bContext *C, wmOperator *op)
-{
-	Paint *p = paint_get_active(CTX_data_scene(C));
-
-	paint_brush_slot_add(p);
-
-	return OPERATOR_FINISHED;
-}
-
-void PAINT_OT_brush_slot_add(wmOperatorType *ot)
-{
-	/* identifiers */
-	ot->name= "Add Brush Slot";
-	ot->idname= "PAINT_OT_brush_slot_add";
-       
-	/* api callbacks */
-	ot->poll= paint_poll;
-	ot->exec= brush_slot_add_exec;
-
-	/* flags */
-	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-}
-
-static int brush_slot_remove_exec(bContext *C, wmOperator *op)
-{
-	Paint *p = paint_get_active(CTX_data_scene(C));
-
-	paint_brush_slot_remove(p);
-
-	return OPERATOR_FINISHED;
-}
-
-void PAINT_OT_brush_slot_remove(wmOperatorType *ot)
-{
-	/* identifiers */
-	ot->name= "Remove Brush Slot";
-	ot->idname= "PAINT_OT_brush_slot_remove";
-       
-	/* api callbacks */
-	ot->poll= paint_poll;
-	ot->exec= brush_slot_remove_exec;
-
-	/* flags */
-	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-}
-
 /**************************** registration **********************************/
 
 void ED_operatortypes_paint(void)
 {
-	/* paint */
-	WM_operatortype_append(PAINT_OT_brush_slot_add);
-	WM_operatortype_append(PAINT_OT_brush_slot_remove);
-
 	/* brush */
 	WM_operatortype_append(BRUSH_OT_add);
 	WM_operatortype_append(BRUSH_OT_curve_preset);
 
-	/* sculpt */
-	WM_operatortype_append(SCULPT_OT_brush_add);
-
 	/* image */
 	WM_operatortype_append(PAINT_OT_texture_paint_toggle);
 	WM_operatortype_append(PAINT_OT_texture_paint_radial_control);

Modified: branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c	2009-08-17 14:29:29 UTC (rev 22566)
+++ branches/blender2.5/blender/source/blender/editors/sculpt_paint/sculpt.c	2009-08-17 15:05:18 UTC (rev 22567)
@@ -1702,7 +1702,7 @@
 		if(!ts->sculpt->cursor)
 			toggle_paint_cursor(C);
 
-		paint_init(&ts->sculpt->paint, "Draw");
+		paint_init(&ts->sculpt->paint, "Brush");
 
 		WM_event_add_notifier(C, NC_SCENE|ND_MODE, CTX_data_scene(C));
 	}





More information about the Bf-blender-cvs mailing list