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:
authorNicholas Bishop <nicholasbishop@gmail.com>2011-05-12 05:57:47 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2011-05-12 05:57:47 +0400
commit910220be47729d6effffb7aa33bfe05d4caa5d3d (patch)
treeecc0d3c6c5073aee112ed5946ec7882ee4bfe236 /source/blender/editors/physics
parent040f65f6c29a8d5b624d4dd5b3083d8519d4a8c1 (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/physics')
-rw-r--r--source/blender/editors/physics/particle_edit.c74
-rw-r--r--source/blender/editors/physics/physics_intern.h1
-rw-r--r--source/blender/editors/physics/physics_ops.c12
3 files changed, 9 insertions, 78 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);