diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-17 19:04:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-17 19:04:17 +0300 |
commit | 966b01665b80fb7dc1c3b0b2ff067dba1df4d088 (patch) | |
tree | f69b4b583a4251e128672f0bc1189b4271668a29 /source/blender | |
parent | fd64e0d6626e9e9c28d49b648e49cb66f6234ed0 (diff) |
use number keys to set the current brush in paint modes
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 44 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ops.c | 122 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sculpt_paint.c | 2 |
3 files changed, 107 insertions, 61 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index d8f13f679a5..256d114fbdc 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -140,6 +140,42 @@ void ED_operatortypes_paint(void) WM_operatortype_append(PAINT_OT_face_deselect_all); } +static void ed_keymap_paint_brush_switch(wmKeyMap *keymap, const char *path) +{ + wmKeyMapItem *kmi; + + kmi= WM_keymap_add_item(keymap, "WM_OT_context_set_int", ONEKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "path", path); + RNA_int_set(kmi->ptr, "value", 0); + kmi= WM_keymap_add_item(keymap, "WM_OT_context_set_int", TWOKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "path", path); + RNA_int_set(kmi->ptr, "value", 1); + kmi= WM_keymap_add_item(keymap, "WM_OT_context_set_int", THREEKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "path", path); + RNA_int_set(kmi->ptr, "value", 2); + kmi= WM_keymap_add_item(keymap, "WM_OT_context_set_int", FOURKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "path", path); + RNA_int_set(kmi->ptr, "value", 3); + kmi= WM_keymap_add_item(keymap, "WM_OT_context_set_int", FIVEKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "path", path); + RNA_int_set(kmi->ptr, "value", 4); + kmi= WM_keymap_add_item(keymap, "WM_OT_context_set_int", SIXKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "path", path); + RNA_int_set(kmi->ptr, "value", 5); + kmi= WM_keymap_add_item(keymap, "WM_OT_context_set_int", SEVENKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "path", path); + RNA_int_set(kmi->ptr, "value", 6); + kmi= WM_keymap_add_item(keymap, "WM_OT_context_set_int", EIGHTKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "path", path); + RNA_int_set(kmi->ptr, "value", 7); + kmi= WM_keymap_add_item(keymap, "WM_OT_context_set_int", NINEKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "path", path); + RNA_int_set(kmi->ptr, "value", 8); + kmi= WM_keymap_add_item(keymap, "WM_OT_context_set_int", ZEROKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "path", path); + RNA_int_set(kmi->ptr, "value", 10); +} + void ED_keymap_paint(wmKeyConfig *keyconf) { wmKeyMap *keymap; @@ -155,6 +191,8 @@ void ED_keymap_paint(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); + ed_keymap_paint_brush_switch(keymap, "tool_settings.sculpt.active_brush_index"); + /* Vertex Paint mode */ keymap= WM_keymap_find(keyconf, "Vertex Paint", 0, 0); keymap->poll= vertex_paint_poll; @@ -167,6 +205,8 @@ void ED_keymap_paint(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "PAINT_OT_vertex_color_set",KKEY, KM_PRESS, KM_SHIFT, 0); + ed_keymap_paint_brush_switch(keymap, "tool_settings.vertex_paint.active_brush_index"); + /* Weight Paint mode */ keymap= WM_keymap_find(keyconf, "Weight Paint", 0, 0); keymap->poll= weight_paint_poll; @@ -179,6 +219,8 @@ void ED_keymap_paint(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "PAINT_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0); + ed_keymap_paint_brush_switch(keymap, "tool_settings.weight_paint.active_brush_index"); + /* Image/Texture Paint mode */ keymap= WM_keymap_find(keyconf, "Image Paint", 0, 0); keymap->poll= image_texture_paint_poll; @@ -190,6 +232,8 @@ void ED_keymap_paint(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PAINT_OT_clone_cursor_set", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); + ed_keymap_paint_brush_switch(keymap, "tool_settings.image_paint.active_brush_index"); + /* face-mask mode */ keymap= WM_keymap_find(keyconf, "Face Mask", 0, 0); keymap->poll= facemask_paint_poll; diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 19128337cb1..b02003721f7 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -105,7 +105,7 @@ void view3d_operatortypes(void) void view3d_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap; - wmKeyMapItem *km; + wmKeyMapItem *kmi; keymap= WM_keymap_find(keyconf, "View3D Generic", SPACE_VIEW3D, 0); @@ -160,24 +160,24 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD8, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANUP); /* active aligned, replaces '*' key in 2.4x */ - km= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(km->ptr, "type", RV3D_VIEW_FRONT); - RNA_boolean_set(km->ptr, "align_active", TRUE); - km= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(km->ptr, "type", RV3D_VIEW_RIGHT); - RNA_boolean_set(km->ptr, "align_active", TRUE); - km= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(km->ptr, "type", RV3D_VIEW_TOP); - RNA_boolean_set(km->ptr, "align_active", TRUE); - km= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT|KM_CTRL, 0); - RNA_enum_set(km->ptr, "type", RV3D_VIEW_BACK); - RNA_boolean_set(km->ptr, "align_active", TRUE); - km= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_SHIFT|KM_CTRL, 0); - RNA_enum_set(km->ptr, "type", RV3D_VIEW_LEFT); - RNA_boolean_set(km->ptr, "align_active", TRUE); - km= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT|KM_CTRL, 0); - RNA_enum_set(km->ptr, "type", RV3D_VIEW_BOTTOM); - RNA_boolean_set(km->ptr, "align_active", TRUE); + kmi= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT, 0); + RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_FRONT); + RNA_boolean_set(kmi->ptr, "align_active", TRUE); + kmi= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_SHIFT, 0); + RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_RIGHT); + RNA_boolean_set(kmi->ptr, "align_active", TRUE); + kmi= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT, 0); + RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_TOP); + RNA_boolean_set(kmi->ptr, "align_active", TRUE); + kmi= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BACK); + RNA_boolean_set(kmi->ptr, "align_active", TRUE); + kmi= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_LEFT); + RNA_boolean_set(kmi->ptr, "align_active", TRUE); + kmi= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BOTTOM); + RNA_boolean_set(kmi->ptr, "align_active", TRUE); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD2, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPDOWN); @@ -211,20 +211,20 @@ void view3d_keymap(wmKeyConfig *keyconf) /* drawtype */ - km = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, 0, 0); - RNA_string_set(km->ptr, "path", "space_data.viewport_shading"); - RNA_string_set(km->ptr, "value_1", "SOLID"); - RNA_string_set(km->ptr, "value_2", "WIREFRAME"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "path", "space_data.viewport_shading"); + RNA_string_set(kmi->ptr, "value_1", "SOLID"); + RNA_string_set(kmi->ptr, "value_2", "WIREFRAME"); - km = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, KM_ALT, 0); - RNA_string_set(km->ptr, "path", "space_data.viewport_shading"); - RNA_string_set(km->ptr, "value_1", "TEXTURED"); - RNA_string_set(km->ptr, "value_2", "SOLID"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, KM_ALT, 0); + RNA_string_set(kmi->ptr, "path", "space_data.viewport_shading"); + RNA_string_set(kmi->ptr, "value_1", "TEXTURED"); + RNA_string_set(kmi->ptr, "value_2", "SOLID"); - km = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, KM_SHIFT, 0); - RNA_string_set(km->ptr, "path", "space_data.viewport_shading"); - RNA_string_set(km->ptr, "value_1", "SHADED"); - RNA_string_set(km->ptr, "value_2", "WIREFRAME"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, KM_SHIFT, 0); + RNA_string_set(kmi->ptr, "path", "space_data.viewport_shading"); + RNA_string_set(kmi->ptr, "value_1", "SHADED"); + RNA_string_set(kmi->ptr, "value_2", "WIREFRAME"); /* selection*/ WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0); @@ -233,19 +233,19 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "enumerate", TRUE); /* selection key-combinations */ - km = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0); - RNA_boolean_set(km->ptr, "center", TRUE); - RNA_boolean_set(km->ptr, "extend", TRUE); - km = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0); - RNA_boolean_set(km->ptr, "center", TRUE); - RNA_boolean_set(km->ptr, "enumerate", TRUE); - km = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0); - RNA_boolean_set(km->ptr, "extend", TRUE); - RNA_boolean_set(km->ptr, "enumerate", TRUE); - km = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL|KM_ALT, 0); - RNA_boolean_set(km->ptr, "center", TRUE); - RNA_boolean_set(km->ptr, "extend", TRUE); - RNA_boolean_set(km->ptr, "enumerate", TRUE); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + RNA_boolean_set(kmi->ptr, "center", TRUE); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "center", TRUE); + RNA_boolean_set(kmi->ptr, "enumerate", TRUE); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "enumerate", TRUE); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL|KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "center", TRUE); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "enumerate", TRUE); WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0); @@ -262,28 +262,28 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "VIEW3D_OT_snap_menu", SKEY, KM_PRESS, KM_SHIFT, 0); /* context ops */ - km = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, 0, 0); - RNA_string_set(km->ptr, "path", "space_data.pivot_point"); - RNA_string_set(km->ptr, "value", "BOUNDING_BOX_CENTER"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "path", "space_data.pivot_point"); + RNA_string_set(kmi->ptr, "value", "BOUNDING_BOX_CENTER"); - km = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, KM_CTRL, 0); /* 2.4x allowed Comma+Shift too, rather not use both */ - RNA_string_set(km->ptr, "path", "space_data.pivot_point"); - RNA_string_set(km->ptr, "value", "MEDIAN_POINT"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, KM_CTRL, 0); /* 2.4x allowed Comma+Shift too, rather not use both */ + RNA_string_set(kmi->ptr, "path", "space_data.pivot_point"); + RNA_string_set(kmi->ptr, "value", "MEDIAN_POINT"); - km = WM_keymap_add_item(keymap, "WM_OT_context_toggle", COMMAKEY, KM_PRESS, KM_ALT, 0); /* new in 2.5 */ - RNA_string_set(km->ptr, "path", "space_data.pivot_point_align"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", COMMAKEY, KM_PRESS, KM_ALT, 0); /* new in 2.5 */ + RNA_string_set(kmi->ptr, "path", "space_data.pivot_point_align"); - km = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, 0, 0); - RNA_string_set(km->ptr, "path", "space_data.pivot_point"); - RNA_string_set(km->ptr, "value", "CURSOR"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "path", "space_data.pivot_point"); + RNA_string_set(kmi->ptr, "value", "CURSOR"); - km = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, KM_CTRL, 0); - RNA_string_set(km->ptr, "path", "space_data.pivot_point"); - RNA_string_set(km->ptr, "value", "INDIVIDUAL_CENTERS"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, KM_CTRL, 0); + RNA_string_set(kmi->ptr, "path", "space_data.pivot_point"); + RNA_string_set(kmi->ptr, "value", "INDIVIDUAL_CENTERS"); - km = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, KM_ALT, 0); - RNA_string_set(km->ptr, "path", "space_data.pivot_point"); - RNA_string_set(km->ptr, "value", "ACTIVE_ELEMENT"); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, KM_ALT, 0); + RNA_string_set(kmi->ptr, "path", "space_data.pivot_point"); + RNA_string_set(kmi->ptr, "value", "ACTIVE_ELEMENT"); transform_keymap_for_space(keyconf, keymap, SPACE_VIEW3D); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index beb979dfa75..667633b4d90 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -179,6 +179,7 @@ static void rna_def_paint(BlenderRNA *brna) prop= RNA_def_property(srna, "active_brush_index", PROP_INT, PROP_NONE); RNA_def_property_int_funcs(prop, NULL, "rna_Paint_active_brush_index_set", "rna_Paint_active_brush_index_range"); RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_update(prop, NC_BRUSH|NA_EDITED, NULL); /* Fake property to get active brush directly, rather than integer index */ prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE); @@ -186,6 +187,7 @@ static void rna_def_paint(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, "rna_Paint_active_brush_get", "rna_Paint_active_brush_set", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Brush", "Active paint brush."); + RNA_def_property_update(prop, NC_BRUSH|NA_EDITED, NULL); } static void rna_def_sculpt(BlenderRNA *brna) |