2.5 Paint:
authorNicholas Bishop <nicholasbishop@gmail.com>
Mon, 17 Aug 2009 15:05:18 +0000 (15:05 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Mon, 17 Aug 2009 15:05:18 +0000 (15:05 +0000)
* Updated the brush selection UI to make the slots less apparent; adding and removing brushes now directly adds and removes slots.

release/ui/space_view3d_toolbar.py
source/blender/blenkernel/intern/paint.c
source/blender/editors/sculpt_paint/paint_ops.c
source/blender/editors/sculpt_paint/sculpt.c

index c4ee89bd1e9284f9758e2c6d57757054071c5942..c8dedd7431c602b82e23f6d4e20c38bb1cf1f30f 100644 (file)
@@ -296,14 +296,9 @@ class VIEW3D_PT_tools_brush(PaintPanel):
 
                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 #
index 5ae8411835609a0d7e8bdde12d0c75b534cb897c..79d1df3d67f3200779c5c088cf2be3a3a78e8aa6 100644 (file)
@@ -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 @@ Brush *paint_brush(Paint *p)
 
 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 @@ static void paint_brush_slots_alloc(Paint *p, const int count)
 
 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;
                
index 5d6589b7d8cef415f38d5fd17154cd4d45f96742..63a6591d0576b96b934b8a0e55c965446d37fff9 100644 (file)
 /* 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 @@ static EnumPropertyItem brush_type_items[] = {
        {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 @@ static int paint_poll(bContext *C)
        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);
index 59a716090651f4815c7c370bbbfa27546ae61413..20b13087348daaf0c9bb0e057c8932bacd414cec 100644 (file)
@@ -1702,7 +1702,7 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op)
                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));
        }