diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_file/file_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 29 | ||||
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 63 |
3 files changed, 86 insertions, 7 deletions
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index 668e14c95e6..5a440be6962 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -67,6 +67,7 @@ void FILE_OT_cancel(struct wmOperatorType *ot); void FILE_OT_parent(struct wmOperatorType *ot); void FILE_OT_refresh(struct wmOperatorType *ot); void FILE_OT_bookmark_toggle(struct wmOperatorType *ot); +void FILE_OT_filenum(struct wmOperatorType *ot); int file_exec(bContext *C, struct wmOperator *unused); int file_cancel_exec(bContext *C, struct wmOperator *unused); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index aaa1793efbb..fa377c06184 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -685,3 +685,32 @@ void FILE_OT_bookmark_toggle(struct wmOperatorType *ot) ot->exec= file_bookmark_toggle_exec; ot->poll= ED_operator_file_active; /* <- important, handler is on window level */ } + + +int file_filenum_exec(bContext *C, wmOperator *op) +{ + SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + + int inc = RNA_int_get(op->ptr, "increment"); + if(sfile->params && (inc != 0)) { + BLI_newname(sfile->params->file, inc); + WM_event_add_notifier(C, NC_WINDOW, NULL); + } + + return OPERATOR_FINISHED; + +} + +void FILE_OT_filenum(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Increment Number in Filename"; + ot->idname= "FILE_OT_filenum"; + + /* api callbacks */ + ot->exec= file_filenum_exec; + ot->poll= ED_operator_file_active; /* <- important, handler is on window level */ + + /* props */ + RNA_def_int(ot->srna, "increment", 1, 0, 100, "Increment", "", 0,100); +}
\ No newline at end of file diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 156c7d6f9be..99c0c44078b 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -211,8 +211,11 @@ static void file_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); - /* own keymap */ - keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0); /* XXX weak? */ + /* own keymaps */ + keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0); + WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + + keymap= WM_keymap_listbase(wm, "FileMain", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -295,30 +298,67 @@ void file_operatortypes(void) WM_operatortype_append(FILE_OT_add_bookmark); WM_operatortype_append(FILE_OT_delete_bookmark); WM_operatortype_append(FILE_OT_hidedot); + WM_operatortype_append(FILE_OT_filenum); } /* NOTE: do not add .blend file reading on this level */ void file_keymap(struct wmWindowManager *wm) { + wmKeymapItem *kmi; + /* keys for all areas */ ListBase *keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0); WM_keymap_add_item(keymap, "FILE_OT_bookmark_toggle", NKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "FILE_OT_parent", PKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "FILE_OT_add_bookmark", BKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "FILE_OT_hidedot", HKEY, KM_PRESS, 0, 0); + + /* keys for main area */ + keymap= WM_keymap_listbase(wm, "FileMain", SPACE_FILE, 0); WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_select_border", BKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_highlight", MOUSEMOVE, KM_ANY, 0, 0); - WM_keymap_add_item(keymap, "FILE_OT_parent", PKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "FILE_OT_add_bookmark", BKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "FILE_OT_hidedot", HKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_loadimages", TIMER1, KM_ANY, KM_ANY, 0); + kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0); + RNA_int_set(kmi->ptr, "increment", 1); + kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_SHIFT, 0); + RNA_int_set(kmi->ptr, "increment", 10); + kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); + RNA_int_set(kmi->ptr, "increment", 100); + kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, 0,0); + RNA_int_set(kmi->ptr, "increment", -1); + kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_SHIFT, 0); + RNA_int_set(kmi->ptr, "increment", -10); + kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_CTRL, 0); + RNA_int_set(kmi->ptr, "increment",-100); - keymap= WM_keymap_listbase(wm, "FileBookmark", SPACE_FILE, 0); - WM_keymap_add_item(keymap, "FILE_OT_select_bookmark", LEFTMOUSE, KM_PRESS, 0, 0); + /* keys for button area (top) */ + keymap= WM_keymap_listbase(wm, "FileButtons", SPACE_FILE, 0); + WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0); + kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0); + RNA_int_set(kmi->ptr, "increment", 1); + kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_SHIFT, 0); + RNA_int_set(kmi->ptr, "increment", 10); + kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); + RNA_int_set(kmi->ptr, "increment", 100); + kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, 0, 0); + RNA_int_set(kmi->ptr, "increment", -1); + kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_SHIFT,0); + RNA_int_set(kmi->ptr, "increment", -10); + kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_CTRL,0); + RNA_int_set(kmi->ptr, "increment",-100); } static void file_channel_area_init(wmWindowManager *wm, ARegion *ar) { + ListBase *keymap; + ED_region_panels_init(wm, ar); + + /* own keymaps */ + keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0); + WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } static void file_channel_area_draw(const bContext *C, ARegion *ar) @@ -348,7 +388,16 @@ static void file_header_area_draw(const bContext *C, ARegion *ar) /* add handlers, stuff you only do once or on area/region changes */ static void file_ui_area_init(wmWindowManager *wm, ARegion *ar) { + ListBase *keymap; + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); + + /* own keymap */ + keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0); /* XXX weak? */ + WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + + keymap= WM_keymap_listbase(wm, "FileButtons", SPACE_FILE, 0); /* XXX weak? */ + WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } static void file_ui_area_draw(const bContext *C, ARegion *ar) |