forked from bartvdbraak/blender
2.5 Paint:
* Updated the brush selection UI to make the slots less apparent; adding and removing brushes now directly adds and removes slots.
This commit is contained in:
parent
9f973bca78
commit
b0fe88117b
@ -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 #
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 @@ 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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user