Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-11-07 03:38:10 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-11-07 03:42:30 +0300
commitc19dafd2a62fe0bebe6f834017b108e77d133682 (patch)
tree812a90384c375ea82bdc34893bcdd3bd2f01154a /source/blender/editors
parent895295a9f0cb85c7c48c395621b9c9d7e5fc78a3 (diff)
Paint: paint.brush_select now supports gpencil
Replace grease pencil specific brush select operator.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c51
-rw-r--r--source/blender/editors/gpencil/gpencil_intern.h1
-rw-r--r--source/blender/editors/gpencil/gpencil_ops.c1
-rw-r--r--source/blender/editors/interface/interface_region_tooltip.c22
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c59
5 files changed, 17 insertions, 117 deletions
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 8c7068c0a7c..458e9d0eb41 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -1546,57 +1546,6 @@ void GPENCIL_OT_brush_presets_create(wmOperatorType *ot)
}
-/* ***************** Select Brush ************************ */
-
-static int gp_brush_select_exec(bContext *C, wmOperator *op)
-{
- ToolSettings *ts = CTX_data_tool_settings(C);
- Main *bmain = CTX_data_main(C);
-
- /* if there's no existing container */
- if (ts == NULL) {
- BKE_report(op->reports, RPT_ERROR, "Nowhere to go");
- return OPERATOR_CANCELLED;
- }
-
- const int index = RNA_int_get(op->ptr, "index");
-
- Paint *paint = &ts->gp_paint->paint;
- int i = 0;
- for (Brush *brush = bmain->brush.first; brush; brush = brush->id.next) {
- if (brush->ob_mode == OB_MODE_GPENCIL_PAINT) {
- if (i == index) {
- BKE_paint_brush_set(paint, brush);
-
- /* notifiers */
- WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
- return OPERATOR_FINISHED;
- }
- i++;
- }
- }
-
- return OPERATOR_CANCELLED;
-}
-
-void GPENCIL_OT_brush_select(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Select Brush";
- ot->idname = "GPENCIL_OT_brush_select";
- ot->description = "Select a Grease Pencil drawing brush";
-
- /* callbacks */
- ot->exec = gp_brush_select_exec;
- ot->poll = gp_active_brush_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Index of Drawing Brush", 0, INT_MAX);
-}
-
/* ***************** Select Sculpt Brush ************************ */
static int gp_sculpt_select_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index f7117189c32..bed4811d7bb 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -386,7 +386,6 @@ void GPENCIL_OT_stroke_separate(struct wmOperatorType *ot);
void GPENCIL_OT_stroke_split(struct wmOperatorType *ot);
void GPENCIL_OT_brush_presets_create(struct wmOperatorType *ot);
-void GPENCIL_OT_brush_select(struct wmOperatorType *ot);
void GPENCIL_OT_sculpt_select(struct wmOperatorType *ot);
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index d9a233b78d8..968233866f6 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -763,7 +763,6 @@ void ED_operatortypes_gpencil(void)
WM_operatortype_append(GPENCIL_OT_stroke_split);
WM_operatortype_append(GPENCIL_OT_brush_presets_create);
- WM_operatortype_append(GPENCIL_OT_brush_select);
WM_operatortype_append(GPENCIL_OT_sculpt_select);
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c
index 6d3ba95fda5..e8a73eaf56d 100644
--- a/source/blender/editors/interface/interface_region_tooltip.c
+++ b/source/blender/editors/interface/interface_region_tooltip.c
@@ -459,27 +459,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
if (shortcut == NULL) {
ePaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
- const char *tool_attr = NULL;
-
- switch (paint_mode) {
- case ePaintSculpt:
- tool_attr = "sculpt_tool";
- break;
- case ePaintVertex:
- tool_attr = "vertex_paint_tool";
- break;
- case ePaintWeight:
- tool_attr = "weight_paint_tool";
- break;
- case ePaintTexture2D:
- case ePaintTextureProjective:
- tool_attr = "texture_paint_tool";
- paint_mode = ePaintTextureProjective;
- break;
- default:
- break;
- }
-
+ const char *tool_attr = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
if (tool_attr != NULL) {
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
const int i = RNA_enum_from_name(items, tool_name);
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index be59d8e2c71..9bad1324aa6 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -466,18 +466,10 @@ static int brush_select_exec(bContext *C, wmOperator *op)
Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
- const char *op_prop_id = NULL;
-
- switch (paint_mode) {
- case ePaintSculpt: op_prop_id = "sculpt_tool"; break;
- case ePaintVertex: op_prop_id = "vertex_paint_tool"; break;
- case ePaintWeight: op_prop_id = "weight_paint_tool"; break;
- case ePaintTexture2D:
- case ePaintTextureProjective: op_prop_id = "texture_paint_tool"; break;
- default:
- /* invalid paint mode */
- BLI_assert(0);
- return OPERATOR_CANCELLED;
+ const char *op_prop_id = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
+
+ if (op_prop_id == NULL) {
+ return OPERATOR_CANCELLED;
}
const int tool = RNA_enum_get(op->ptr, op_prop_id);
@@ -490,12 +482,14 @@ static int brush_select_exec(bContext *C, wmOperator *op)
static void PAINT_OT_brush_select(wmOperatorType *ot)
{
+ /* Keep names matching 'rna_enum_object_mode_items' (besides active). */
static const EnumPropertyItem paint_mode_items[] = {
{ePaintInvalid, "ACTIVE", 0, "Current", "Set brush for active paint mode"},
{ePaintSculpt, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt", ""},
{ePaintVertex, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
{ePaintWeight, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
{ePaintTextureProjective, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
+ {ePaintGpencil, "GPENCIL_PAINT", ICON_GREASEPENCIL, "Grease Pencil Paint", ""},
{0, NULL, 0, NULL, NULL}
};
PropertyRNA *prop;
@@ -515,14 +509,13 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
/* All properties are hidden, so as not to show the redo panel. */
prop = RNA_def_enum(ot->srna, "paint_mode", paint_mode_items, ePaintInvalid, "Paint Mode", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
- prop = RNA_def_enum(ot->srna, "sculpt_tool", rna_enum_brush_sculpt_tool_items, 0, "Sculpt Tool", "");
- RNA_def_property_flag(prop, PROP_HIDDEN);
- prop = RNA_def_enum(ot->srna, "vertex_paint_tool", rna_enum_brush_vertex_tool_items, 0, "Vertex Paint Tool", "");
- RNA_def_property_flag(prop, PROP_HIDDEN);
- prop = RNA_def_enum(ot->srna, "weight_paint_tool", rna_enum_brush_weight_tool_items, 0, "Weight Paint Tool", "");
- RNA_def_property_flag(prop, PROP_HIDDEN);
- prop = RNA_def_enum(ot->srna, "texture_paint_tool", rna_enum_brush_image_tool_items, 0, "Texture Paint Tool", "");
- RNA_def_property_flag(prop, PROP_HIDDEN);
+
+ for (const EnumPropertyItem *item = paint_mode_items + 1; item->identifier; item++) {
+ const ePaintMode paint_mode = item->value;
+ const char *prop_id = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
+ prop = RNA_def_enum(ot->srna, prop_id, BKE_paint_get_tool_enum_from_paintmode(paint_mode), 0, prop_id, "");
+ RNA_def_property_flag(prop, PROP_HIDDEN);
+ }
prop = RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", "Toggle between two brushes rather than cycling");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
@@ -536,30 +529,10 @@ static wmKeyMapItem *keymap_brush_select(
int keymap_modifier)
{
wmKeyMapItem *kmi;
- kmi = WM_keymap_add_item(
- keymap, "PAINT_OT_brush_select",
- keymap_type, KM_PRESS, keymap_modifier, 0);
-
+ kmi = WM_keymap_add_item(keymap, "PAINT_OT_brush_select", keymap_type, KM_PRESS, keymap_modifier, 0);
RNA_enum_set(kmi->ptr, "paint_mode", paint_mode);
-
- switch (paint_mode) {
- case ePaintSculpt:
- RNA_enum_set(kmi->ptr, "sculpt_tool", tool);
- break;
- case ePaintVertex:
- RNA_enum_set(kmi->ptr, "vertex_paint_tool", tool);
- break;
- case ePaintWeight:
- RNA_enum_set(kmi->ptr, "weight_paint_tool", tool);
- break;
- case ePaintTexture2D:
- case ePaintTextureProjective:
- RNA_enum_set(kmi->ptr, "texture_paint_tool", tool);
- break;
- default:
- BLI_assert(0);
- }
-
+ const char *prop_id = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
+ RNA_enum_set(kmi->ptr, prop_id, tool);
return kmi;
}