diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2011-05-12 05:57:47 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2011-05-12 05:57:47 +0400 |
commit | 910220be47729d6effffb7aa33bfe05d4caa5d3d (patch) | |
tree | ecc0d3c6c5073aee112ed5946ec7882ee4bfe236 /source/blender/editors | |
parent | 040f65f6c29a8d5b624d4dd5b3083d8519d4a8c1 (diff) |
== Radial control ==
Patch to make the radial control more generic with RNA. Patch was
reviewed here: http://codereview.appspot.com/4280080/
Prior to this update, the radial control code in trunk had generic
parts of the radial control implemented as an incomplete operator
within WM. Then each different user of the radial control had to
implement a separate operator to actually pass in specific brush data
-- e.g. sculpt's brush size, vpaint's brush size, etc.
This patch removes all the extra operators and makes the WM operator
do everything. It now takes several RNA path strings as its properties
-- the only required property is data_path, which specifies the data
to be modified by the radial control. The other paths affect display
in various ways, e.g. rotation, color, etc.
In addition to decreasing some duplicate paint brush code, these
updates make it pretty easy to enable radial control for other
purposes (and it can be set up entirely though python or keymaps, no
extra C code needed.)
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 74 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_ops.c | 12 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 89 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_intern.h | 4 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 79 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 104 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 60 |
8 files changed, 69 insertions, 354 deletions
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 1c9f9e60e14..733919ff166 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -2521,80 +2521,6 @@ static void toggle_particle_cursor(bContext *C, int enable) pset->paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), PE_poll_view3d, brush_drawcursor, NULL); } -/********************* radial control operator *********************/ - -static int brush_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - ParticleEditSettings *pset= PE_settings(CTX_data_scene(C)); - ParticleBrushData *brush; - int mode = RNA_enum_get(op->ptr, "mode"); - float original_value=1.0f; - - if(pset->brushtype < 0) - return OPERATOR_CANCELLED; - - brush= &pset->brush[pset->brushtype]; - - toggle_particle_cursor(C, 0); - - if(mode == WM_RADIALCONTROL_SIZE) - original_value = brush->size; - else if(mode == WM_RADIALCONTROL_STRENGTH) - original_value = brush->strength; - - RNA_float_set(op->ptr, "initial_value", original_value); - - return WM_radial_control_invoke(C, op, event); -} - -static int brush_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - int ret = WM_radial_control_modal(C, op, event); - - if(ret != OPERATOR_RUNNING_MODAL) - toggle_particle_cursor(C, 1); - - return ret; -} - -static int brush_radial_control_exec(bContext *C, wmOperator *op) -{ - ParticleEditSettings *pset= PE_settings(CTX_data_scene(C)); - ParticleBrushData *brush; - int mode = RNA_enum_get(op->ptr, "mode"); - float new_value = RNA_float_get(op->ptr, "new_value"); - - if(pset->brushtype < 0) - return OPERATOR_CANCELLED; - - brush= &pset->brush[pset->brushtype]; - - if(mode == WM_RADIALCONTROL_SIZE) - brush->size= new_value; - else if(mode == WM_RADIALCONTROL_STRENGTH) - brush->strength= new_value; - - WM_event_add_notifier(C, NC_WINDOW, NULL); - - return OPERATOR_FINISHED; -} - -void PARTICLE_OT_brush_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Brush Radial Control"; - ot->idname= "PARTICLE_OT_brush_radial_control"; - - ot->invoke= brush_radial_control_invoke; - ot->modal= brush_radial_control_modal; - ot->exec= brush_radial_control_exec; - ot->poll= PE_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - /*************************** delete operator **************************/ enum { DEL_PARTICLE, DEL_KEY }; diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h index d447da3f8c4..71f1128baf0 100644 --- a/source/blender/editors/physics/physics_intern.h +++ b/source/blender/editors/physics/physics_intern.h @@ -60,7 +60,6 @@ void PARTICLE_OT_delete(struct wmOperatorType *ot); void PARTICLE_OT_mirror(struct wmOperatorType *ot); void PARTICLE_OT_brush_edit(struct wmOperatorType *ot); -void PARTICLE_OT_brush_radial_control(struct wmOperatorType *ot); void PARTICLE_OT_particle_edit_toggle(struct wmOperatorType *ot); void PARTICLE_OT_edited_clear(struct wmOperatorType *ot); diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index 02b2fad7a00..aafa5a185ed 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -66,7 +66,6 @@ static void operatortypes_particle(void) WM_operatortype_append(PARTICLE_OT_mirror); WM_operatortype_append(PARTICLE_OT_brush_edit); - WM_operatortype_append(PARTICLE_OT_brush_radial_control); WM_operatortype_append(PARTICLE_OT_particle_edit_toggle); WM_operatortype_append(PARTICLE_OT_edited_clear); @@ -91,6 +90,7 @@ static void operatortypes_particle(void) static void keymap_particle(wmKeyConfig *keyconf) { + wmKeyMapItem *kmi; wmKeyMap *keymap; keymap= WM_keymap_find(keyconf, "Particle", 0, 0); @@ -112,8 +112,14 @@ static void keymap_particle(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(WM_keymap_add_item(keymap, "PARTICLE_OT_brush_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "PARTICLE_OT_brush_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); + + /* size radial control */ + kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.particle_edit.brush.size"); + + /* size radial control */ + kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.particle_edit.brush.strength"); WM_keymap_add_menu(keymap, "VIEW3D_MT_particle_specials", WKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index cb807117198..66a0044d55e 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -5068,56 +5068,6 @@ void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings) } } -/* ************ image paint radial control *************/ -static int paint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - float zoom; - ToolSettings *ts = CTX_data_scene(C)->toolsettings; - get_imapaint_zoom(C, &zoom, &zoom); - toggle_paint_cursor(C, 0); - brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), zoom); - return WM_radial_control_invoke(C, op, event); -} - -static int paint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - int ret = WM_radial_control_modal(C, op, event); - if(ret != OPERATOR_RUNNING_MODAL) - toggle_paint_cursor(C, 1); - return ret; -} - -static int paint_radial_control_exec(bContext *C, wmOperator *op) -{ - Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint); - float zoom; - int ret; - char str[64]; - get_imapaint_zoom(C, &zoom, &zoom); - ret = brush_radial_control_exec(op, brush, 1.0f / zoom); - WM_radial_control_string(op, str, sizeof(str)); - - WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush); - - return ret; -} - -void PAINT_OT_image_paint_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Image Paint Radial Control"; - ot->idname= "PAINT_OT_image_paint_radial_control"; - - ot->invoke= paint_radial_control_invoke; - ot->modal= paint_radial_control_modal; - ot->exec= paint_radial_control_exec; - ot->poll= image_paint_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - /************************ grab clone operator ************************/ typedef struct GrabClone { @@ -5445,28 +5395,6 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -/************* texture paint radial control *************/ - -static int texture_paint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - ToolSettings *ts = CTX_data_scene(C)->toolsettings; - toggle_paint_cursor(C, !ts->imapaint.paintcursor); - brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), 1); - return WM_radial_control_invoke(C, op, event); -} - -static int texture_paint_radial_control_exec(bContext *C, wmOperator *op) -{ - Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint); - int ret = brush_radial_control_exec(op, brush, 1); - char str[64]; - WM_radial_control_string(op, str, sizeof(str)); - - WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush); - - return ret; -} - static int texture_paint_poll(bContext *C) { if(texture_paint_toggle_poll(C)) @@ -5481,23 +5409,6 @@ int image_texture_paint_poll(bContext *C) return (texture_paint_poll(C) || image_paint_poll(C)); } -void PAINT_OT_texture_paint_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Texture Paint Radial Control"; - ot->idname= "PAINT_OT_texture_paint_radial_control"; - - ot->invoke= texture_paint_radial_control_invoke; - ot->modal= paint_radial_control_modal; - ot->exec= texture_paint_radial_control_exec; - ot->poll= texture_paint_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - - int facemask_paint_poll(bContext *C) { return paint_facesel_test(CTX_data_active_object(C)); diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 48fca04ac87..ba7235a3161 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -81,12 +81,10 @@ void vpaint_fill(struct Object *ob, unsigned int paintcol); void wpaint_fill(struct VPaint *wp, struct Object *ob, float paintweight); void PAINT_OT_weight_paint_toggle(struct wmOperatorType *ot); -void PAINT_OT_weight_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_weight_paint(struct wmOperatorType *ot); void PAINT_OT_weight_set(struct wmOperatorType *ot); void PAINT_OT_weight_from_bones(struct wmOperatorType *ot); -void PAINT_OT_vertex_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_vertex_paint_toggle(struct wmOperatorType *ot); void PAINT_OT_vertex_paint(struct wmOperatorType *ot); @@ -96,12 +94,10 @@ unsigned int vpaint_get_current_col(struct VPaint *vp); int image_texture_paint_poll(struct bContext *C); void PAINT_OT_image_paint(struct wmOperatorType *ot); -void PAINT_OT_image_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_grab_clone(struct wmOperatorType *ot); void PAINT_OT_sample_color(struct wmOperatorType *ot); void PAINT_OT_clone_cursor_set(struct wmOperatorType *ot); void PAINT_OT_texture_paint_toggle(struct wmOperatorType *ot); -void PAINT_OT_texture_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_project_image(struct wmOperatorType *ot); void PAINT_OT_image_from_view(struct wmOperatorType *ot); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 9a1de939067..e4a21b1f1a7 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -23,7 +23,10 @@ * \ingroup edsculpt */ +#include "MEM_guardedalloc.h" +#include <stdlib.h> +#include "BLI_string.h" #include "BLI_utildefines.h" #include "DNA_object_types.h" @@ -355,9 +358,7 @@ void ED_operatortypes_paint(void) /* image */ WM_operatortype_append(PAINT_OT_texture_paint_toggle); - WM_operatortype_append(PAINT_OT_texture_paint_radial_control); WM_operatortype_append(PAINT_OT_image_paint); - WM_operatortype_append(PAINT_OT_image_paint_radial_control); WM_operatortype_append(PAINT_OT_sample_color); WM_operatortype_append(PAINT_OT_grab_clone); WM_operatortype_append(PAINT_OT_clone_cursor_set); @@ -366,13 +367,11 @@ void ED_operatortypes_paint(void) /* weight */ WM_operatortype_append(PAINT_OT_weight_paint_toggle); - WM_operatortype_append(PAINT_OT_weight_paint_radial_control); WM_operatortype_append(PAINT_OT_weight_paint); WM_operatortype_append(PAINT_OT_weight_set); WM_operatortype_append(PAINT_OT_weight_from_bones); /* vertex */ - WM_operatortype_append(PAINT_OT_vertex_paint_radial_control); WM_operatortype_append(PAINT_OT_vertex_paint_toggle); WM_operatortype_append(PAINT_OT_vertex_paint); WM_operatortype_append(PAINT_OT_vertex_color_set); @@ -464,6 +463,59 @@ static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *UNUSED(path RNA_float_set(kmi->ptr, "scalar", 10.0/9.0); // 1.1111.... } +typedef enum { + RC_COLOR = 1, + RC_ROTATION = 2, + RC_ZOOM = 4, +} RCFlags; + +static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path, + const char *output_name, const char *input_name) +{ + char *path; + + path = BLI_sprintfN("%s.%s", brush_path, input_name); + RNA_string_set(ptr, output_name, path); + MEM_freeN(path); +} + +static void set_brush_rc_props(PointerRNA *ptr, const char *paint, + const char *prop, RCFlags flags) +{ + char *brush_path; + + brush_path = BLI_sprintfN("tool_settings.%s.brush", paint); + + set_brush_rc_path(ptr, brush_path, "data_path", prop); + set_brush_rc_path(ptr, brush_path, "color_path", "cursor_color_add"); + set_brush_rc_path(ptr, brush_path, "rotation_path", "texture_slot.angle"); + RNA_string_set(ptr, "image_id", brush_path); + + if(flags & RC_COLOR) + set_brush_rc_path(ptr, brush_path, "fill_color_path", "color"); + if(flags & RC_ZOOM) + RNA_string_set(ptr, "zoom_path", "space_data.zoom"); + + MEM_freeN(brush_path); +} + +static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *paint, + RCFlags flags) +{ + wmKeyMapItem *kmi; + + kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0); + set_brush_rc_props(kmi->ptr, paint, "size", flags); + + kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0); + set_brush_rc_props(kmi->ptr, paint, "strength", flags); + + if(flags & RC_ROTATION) { + kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0); + set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", flags); + } +} + void ED_keymap_paint(wmKeyConfig *keyconf) { wmKeyMap *keymap; @@ -474,10 +526,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap= WM_keymap_find(keyconf, "Sculpt", 0, 0); keymap->poll= sculpt_poll; - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", WM_RADIALCONTROL_ANGLE); - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", BRUSH_STROKE_NORMAL); RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "mode", BRUSH_STROKE_INVERT); RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", BRUSH_STROKE_SMOOTH); @@ -496,6 +544,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "sculpt"); ed_keymap_paint_brush_size(keymap, "tool_settings.sculpt.brush.size"); + ed_keymap_paint_brush_radial_control(keymap, "sculpt", RC_ROTATION); RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", DKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_DRAW); RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", SKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_SMOOTH); @@ -521,8 +570,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap= WM_keymap_find(keyconf, "Vertex Paint", 0, 0); keymap->poll= vertex_paint_mode_poll; - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); 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); @@ -531,6 +578,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "vertex_paint"); ed_keymap_paint_brush_size(keymap, "tool_settings.vertex_paint.brush.size"); + ed_keymap_paint_brush_radial_control(keymap, "vertex_paint", RC_COLOR); kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ RNA_string_set(kmi->ptr, "data_path", "vertex_paint_object.data.use_paint_mask"); @@ -539,9 +587,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap= WM_keymap_find(keyconf, "Weight Paint", 0, 0); keymap->poll= weight_paint_mode_poll; - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); - WM_keymap_verify_item(keymap, "PAINT_OT_weight_paint", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, @@ -549,6 +594,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "weight_paint"); ed_keymap_paint_brush_size(keymap, "tool_settings.weight_paint.brush.size"); + ed_keymap_paint_brush_radial_control(keymap, "weight_paint", 0); kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ RNA_string_set(kmi->ptr, "data_path", "weight_paint_object.data.use_paint_mask"); @@ -559,12 +605,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap= WM_keymap_find(keyconf, "Image Paint", 0, 0); keymap->poll= image_texture_paint_poll; - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_image_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_image_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); - - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_texture_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_texture_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); - WM_keymap_add_item(keymap, "PAINT_OT_image_paint", LEFTMOUSE, KM_PRESS, 0, 0); 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); @@ -572,6 +612,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "image_paint"); ed_keymap_paint_brush_size(keymap, "tool_settings.image_paint.brush.size"); + ed_keymap_paint_brush_radial_control(keymap, "image_paint", RC_COLOR|RC_ZOOM); kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ RNA_string_set(kmi->ptr, "data_path", "image_paint_object.data.use_paint_mask"); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 19c726616da..90cfdda78a8 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1147,110 +1147,6 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot) } -/* ************ paint radial controls *************/ - -static int vpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - Paint *p = paint_get_active(CTX_data_scene(C)); - Brush *brush = paint_brush(p); - float col[4]; - - WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor); - p->paint_cursor = NULL; - brush_radial_control_invoke(op, brush, 1); - - copy_v3_v3(col, brush->add_col); - col[3]= 0.5f; - RNA_float_set_array(op->ptr, "color", col); - - return WM_radial_control_invoke(C, op, event); -} - -static int vpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - int ret = WM_radial_control_modal(C, op, event); - if(ret != OPERATOR_RUNNING_MODAL) - paint_cursor_start(C, vertex_paint_poll); - return ret; -} - -static int vpaint_radial_control_exec(bContext *C, wmOperator *op) -{ - Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->vpaint->paint); - int ret = brush_radial_control_exec(op, brush, 1); - - WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush); - - return ret; -} - -static int wpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - Paint *p = paint_get_active(CTX_data_scene(C)); - Brush *brush = paint_brush(p); - float col[4]; - - WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor); - p->paint_cursor = NULL; - brush_radial_control_invoke(op, brush, 1); - - copy_v3_v3(col, brush->add_col); - col[3]= 0.5f; - RNA_float_set_array(op->ptr, "color", col); - - return WM_radial_control_invoke(C, op, event); -} - -static int wpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - int ret = WM_radial_control_modal(C, op, event); - if(ret != OPERATOR_RUNNING_MODAL) - paint_cursor_start(C, weight_paint_poll); - return ret; -} - -static int wpaint_radial_control_exec(bContext *C, wmOperator *op) -{ - Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->wpaint->paint); - int ret = brush_radial_control_exec(op, brush, 1); - - WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush); - - return ret; -} - -void PAINT_OT_weight_paint_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Weight Paint Radial Control"; - ot->idname= "PAINT_OT_weight_paint_radial_control"; - - ot->invoke= wpaint_radial_control_invoke; - ot->modal= wpaint_radial_control_modal; - ot->exec= wpaint_radial_control_exec; - ot->poll= weight_paint_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - -void PAINT_OT_vertex_paint_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Vertex Paint Radial Control"; - ot->idname= "PAINT_OT_vertex_paint_radial_control"; - - ot->invoke= vpaint_radial_control_invoke; - ot->modal= vpaint_radial_control_modal; - ot->exec= vpaint_radial_control_exec; - ot->poll= vertex_paint_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - /* ************ weight paint operator ********** */ struct WPaintData { diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 7156b49c026..00607d66049 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2816,65 +2816,6 @@ static const char *sculpt_tool_name(Sculpt *sd) } } -/**** Radial control ****/ -static int sculpt_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - Paint *p = paint_get_active(CTX_data_scene(C)); - Brush *brush = paint_brush(p); - float col[4], tex_col[4]; - - WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor); - p->paint_cursor = NULL; - brush_radial_control_invoke(op, brush, 1); - - if((brush->flag & BRUSH_DIR_IN) && ELEM4(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_PINCH)) - copy_v3_v3(col, brush->sub_col); - else - copy_v3_v3(col, brush->add_col); - col[3]= 0.5f; - - copy_v3_v3(tex_col, U.sculpt_paint_overlay_col); - tex_col[3]= (brush->texture_overlay_alpha / 100.0f); - - RNA_float_set_array(op->ptr, "color", col); - RNA_float_set_array(op->ptr, "texture_color", tex_col); - - return WM_radial_control_invoke(C, op, event); -} - -static int sculpt_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - int ret = WM_radial_control_modal(C, op, event); - if(ret != OPERATOR_RUNNING_MODAL) - paint_cursor_start(C, sculpt_poll); - return ret; -} - -static int sculpt_radial_control_exec(bContext *C, wmOperator *op) -{ - Brush *brush = paint_brush(&CTX_data_tool_settings(C)->sculpt->paint); - int ret = brush_radial_control_exec(op, brush, 1); - - WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush); - - return ret; -} - -static void SCULPT_OT_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Sculpt Radial Control"; - ot->idname= "SCULPT_OT_radial_control"; - - ot->invoke= sculpt_radial_control_invoke; - ot->modal= sculpt_radial_control_modal; - ot->exec= sculpt_radial_control_exec; - ot->poll= sculpt_poll; - - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - /**** Operator for applying a stroke (various attributes including mouse path) using the current brush. ****/ @@ -3758,7 +3699,6 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) void ED_operatortypes_sculpt(void) { - WM_operatortype_append(SCULPT_OT_radial_control); WM_operatortype_append(SCULPT_OT_brush_stroke); WM_operatortype_append(SCULPT_OT_sculptmode_toggle); WM_operatortype_append(SCULPT_OT_set_persistent_base); |