use a look for paint brush switching keys
authorCampbell Barton <ideasman42@gmail.com>
Mon, 16 Jan 2012 10:05:53 +0000 (10:05 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 16 Jan 2012 10:05:53 +0000 (10:05 +0000)
source/blender/editors/sculpt_paint/paint_ops.c

index c8d166976f9d302d87b1b3f46879c069ee1a12d0..2a0ebb8316df86900b30ce6638481b0ec995f0bb 100644 (file)
@@ -395,67 +395,14 @@ void ED_operatortypes_paint(void)
 static void ed_keymap_paint_brush_switch(wmKeyMap *keymap, const char *mode)
 {
        wmKeyMapItem *kmi;
-
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ONEKEY, KM_PRESS, 0, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 0);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", TWOKEY, KM_PRESS, 0, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 1);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", THREEKEY, KM_PRESS, 0, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 2);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FOURKEY, KM_PRESS, 0, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 3);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FIVEKEY, KM_PRESS, 0, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 4);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SIXKEY, KM_PRESS, 0, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 5);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SEVENKEY, KM_PRESS, 0, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 6);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", EIGHTKEY, KM_PRESS, 0, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 7);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", NINEKEY, KM_PRESS, 0, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 8);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ZEROKEY, KM_PRESS, 0, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 9);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ONEKEY, KM_PRESS, KM_SHIFT, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 10);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", TWOKEY, KM_PRESS, KM_SHIFT, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 11);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", THREEKEY, KM_PRESS, KM_SHIFT, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 12);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FOURKEY, KM_PRESS, KM_SHIFT, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 13);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FIVEKEY, KM_PRESS, KM_SHIFT, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 14);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SIXKEY, KM_PRESS, KM_SHIFT, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 15);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SEVENKEY, KM_PRESS, KM_SHIFT, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 16);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", EIGHTKEY, KM_PRESS, KM_SHIFT, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 17);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", NINEKEY, KM_PRESS, KM_SHIFT, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 18);
-       kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ZEROKEY, KM_PRESS, KM_SHIFT, 0);
-       RNA_string_set(kmi->ptr, "mode", mode);
-       RNA_int_set(kmi->ptr, "index", 19);
+       int i;
+       /* index 0-9 (zero key is tenth), shift key for index 10-19 */
+       for (i = 0; i < 20; i++) {
+               kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set",
+                                       ZEROKEY + ((i + 1) % 10), KM_PRESS, i < 10 ? 0 : KM_SHIFT, 0);
+               RNA_string_set(kmi->ptr, "mode", mode);
+               RNA_int_set(kmi->ptr, "index", i);
+       }
 }
 
 static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *UNUSED(path))