From 8d036a21d7dca6691c0846df2162f50015407ed0 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Sun, 31 Mar 2013 16:17:18 +0000 Subject: Changes to Stencil control: * Add a poll function that only activates the operator when a stencil brush is active * Change shortcuts to RMouse - translate, Shift - RMouse Scale, Ctrl - RMouse, rotate. MUCH faster and simpler workflow. * Change shortcut of colour sampling to S. Sampling is important but not as important as warranting the Right Mouse button. * Add a notifier so that toolbar gets updated texture rotation when rotating the stencil Also, * Slight rearrangement of options so that jittering is more accessible (easily more often used than smooth stroke) --- source/blender/editors/sculpt_paint/paint_ops.c | 31 ++++++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'source/blender/editors/sculpt_paint/paint_ops.c') diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index a63d147e459..cd9523f8ff6 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -542,14 +542,18 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve } } break; - case LEFTMOUSE: - if (event->val == KM_PRESS) { + /* XXX hardcoded! */ + case RIGHTMOUSE: + if (event->val == KM_RELEASE) { MEM_freeN(op->customdata); + WM_event_add_notifier(C, NC_WINDOW, NULL); return OPERATOR_FINISHED; } - case RIGHTMOUSE: + case ESCKEY: if (event->val == KM_PRESS) { - return stencil_control_cancel(C, op); + stencil_control_cancel(C, op); + WM_event_add_notifier(C, NC_WINDOW, NULL); + return OPERATOR_CANCELLED; } default: break; @@ -560,6 +564,14 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve return OPERATOR_RUNNING_MODAL; } +static int stencil_control_poll(bContext *C) +{ + Paint *paint = paint_get_active_from_context(C); + Brush *br = paint->brush; + + return br->mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL; +} + static void BRUSH_OT_stencil_control(wmOperatorType *ot) { static EnumPropertyItem stencil_control_items[] = { @@ -577,6 +589,7 @@ static void BRUSH_OT_stencil_control(wmOperatorType *ot) ot->invoke = stencil_control_invoke; ot->modal = stencil_control_modal; ot->cancel = stencil_control_cancel; + ot->poll = stencil_control_poll; /* flags */ ot->flag = 0; @@ -588,11 +601,11 @@ static void ed_keymap_stencil(wmKeyMap *keymap) { wmKeyMapItem *kmi; - kmi = WM_keymap_add_item(keymap, "BRUSH_OT_stencil_control", QKEY, KM_PRESS, 0, 0); + kmi = WM_keymap_add_item(keymap, "BRUSH_OT_stencil_control", RIGHTMOUSE, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "mode", STENCIL_TRANSLATE); - kmi = WM_keymap_add_item(keymap, "BRUSH_OT_stencil_control", QKEY, KM_PRESS, KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "BRUSH_OT_stencil_control", RIGHTMOUSE, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "mode", STENCIL_SCALE); - kmi = WM_keymap_add_item(keymap, "BRUSH_OT_stencil_control", QKEY, KM_PRESS, KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "BRUSH_OT_stencil_control", RIGHTMOUSE, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "mode", STENCIL_ROTATE); } @@ -852,7 +865,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap->poll = vertex_paint_mode_poll; WM_keymap_verify_item(keymap, "PAINT_OT_vertex_paint", LEFTMOUSE, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "PAINT_OT_sample_color", SKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PAINT_OT_vertex_color_set", KKEY, KM_PRESS, KM_SHIFT, 0); @@ -932,7 +945,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_image_paint", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", BRUSH_STROKE_NORMAL); RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_image_paint", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "mode", BRUSH_STROKE_INVERT); WM_keymap_add_item(keymap, "PAINT_OT_grab_clone", RIGHTMOUSE, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "PAINT_OT_sample_color", SKEY, KM_PRESS, 0, 0); ed_keymap_paint_brush_switch(keymap, "image_paint"); ed_keymap_paint_brush_size(keymap, "tool_settings.image_paint.brush.size"); -- cgit v1.2.3