Revision: 21377 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21377 Author: elubie Date: 2009-07-06 00:26:43 +0200 (Mon, 06 Jul 2009)
Log Message: ----------- 2.5 filebrowser * bringing back file numbering operator (PADPLUSKEY, PADMINUS) * Note: discovered conflicting key with View2D zooming that causes it to not work in panel area. Modified Paths: -------------- branches/blender2.5/blender/source/blender/editors/space_file/file_intern.h branches/blender2.5/blender/source/blender/editors/space_file/file_ops.c branches/blender2.5/blender/source/blender/editors/space_file/space_file.c Modified: branches/blender2.5/blender/source/blender/editors/space_file/file_intern.h =================================================================== --- branches/blender2.5/blender/source/blender/editors/space_file/file_intern.h 2009-07-05 22:00:44 UTC (rev 21376) +++ branches/blender2.5/blender/source/blender/editors/space_file/file_intern.h 2009-07-05 22:26:43 UTC (rev 21377) @@ -67,6 +67,7 @@ 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); Modified: branches/blender2.5/blender/source/blender/editors/space_file/file_ops.c =================================================================== --- branches/blender2.5/blender/source/blender/editors/space_file/file_ops.c 2009-07-05 22:00:44 UTC (rev 21376) +++ branches/blender2.5/blender/source/blender/editors/space_file/file_ops.c 2009-07-05 22:26:43 UTC (rev 21377) @@ -685,3 +685,32 @@ 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 Modified: branches/blender2.5/blender/source/blender/editors/space_file/space_file.c =================================================================== --- branches/blender2.5/blender/source/blender/editors/space_file/space_file.c 2009-07-05 22:00:44 UTC (rev 21376) +++ branches/blender2.5/blender/source/blender/editors/space_file/space_file.c 2009-07-05 22:26:43 UTC (rev 21377) @@ -211,9 +211,12 @@ 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 @@ 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 @@ /* 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) _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs