From 216ba20942249c96f808d9e5c7ca4cc47c6b77f5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Jun 2011 12:48:25 +0000 Subject: [PATCH 001/131] fix [#27671] Transforming sequencer effects strips crashes --- .../editors/transform/transform_conversions.c | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index bf14b6e99ec..669c3195dfd 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3725,27 +3725,8 @@ void flushTransGraphData(TransInfo *t) * seq->depth must be set before running this function so we know if the strips * are root level or not */ -#define XXX_DURIAN_ANIM_TX_HACK static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count, int *flag) { - -#ifdef XXX_DURIAN_ANIM_TX_HACK - /* hack */ - if((seq->flag & SELECT)==0 && seq->type & SEQ_EFFECT) { - Sequence *seq_t[3]; - int i; - - seq_t[0]= seq->seq1; - seq_t[1]= seq->seq2; - seq_t[2]= seq->seq3; - - for(i=0; i<3; i++) { - if (seq_t[i] && ((seq_t[i])->flag & SELECT) && !(seq_t[i]->flag & SEQ_LOCK) && !(seq_t[i]->flag & (SEQ_LEFTSEL|SEQ_RIGHTSEL))) - seq->flag |= SELECT; - } - } -#endif - /* for extend we need to do some tricks */ if (t->mode == TFM_TIME_EXTEND) { @@ -4105,6 +4086,7 @@ static void freeSeqData(TransInfo *t) static void createTransSeqData(bContext *C, TransInfo *t) { +#define XXX_DURIAN_ANIM_TX_HACK View2D *v2d= UI_view2d_fromcontext(C); Scene *scene= t->scene; @@ -4135,6 +4117,24 @@ static void createTransSeqData(bContext *C, TransInfo *t) t->frame_side = 'B'; } +#ifdef XXX_DURIAN_ANIM_TX_HACK + { + Sequence *seq; + for(seq= ed->seqbasep->first; seq; seq= seq->next) { + /* hack */ + if((seq->flag & SELECT)==0 && seq->type & SEQ_EFFECT) { + Sequence *seq_user; + int i; + for(i=0; i<3; i++) { + seq_user= *((&seq->seq1) + i); + if (seq_user && (seq_user->flag & SELECT) && !(seq_user->flag & SEQ_LOCK) && !(seq_user->flag & (SEQ_LEFTSEL|SEQ_RIGHTSEL))) { + seq->flag |= SELECT; + } + } + } + } + } +#endif count = SeqTransCount(t, ed->seqbasep, 0); @@ -4154,6 +4154,8 @@ static void createTransSeqData(bContext *C, TransInfo *t) /* loop 2: build transdata array */ SeqToTransData_Recursive(t, ed->seqbasep, td, td2d, tdsq); + +#undef XXX_DURIAN_ANIM_TX_HACK } From fd24c99b5ddd251ee64f95ae227ba76bcf9cb561 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Jun 2011 15:01:22 +0000 Subject: [PATCH 002/131] directory only filesel for operators which don't have a filepath or filename property. --- source/blender/editors/space_file/file_draw.c | 24 ++++++++++-------- source/blender/editors/space_file/file_ops.c | 11 +++++--- source/blender/editors/space_file/filelist.c | 2 ++ source/blender/editors/space_file/filesel.c | 21 +++++++++++++--- source/blender/makesdna/DNA_space_types.h | 25 ++++++++++--------- 5 files changed, 52 insertions(+), 31 deletions(-) diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index a6fee359197..9fecfda7764 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -185,16 +185,18 @@ void file_draw_buttons(const bContext *C, ARegion *ar) uiButSetCompleteFunc(but, autocomplete_directory, NULL); uiButSetFlag(but, UI_BUT_NO_UTF8); - but = uiDefBut(block, TEX, B_FS_FILENAME, "", - min_x, line2_y, line2_w-chan_offs, btn_h, - params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0, - overwrite_alert ?"File name, overwrite existing." : "File name."); - uiButSetCompleteFunc(but, autocomplete_file, NULL); - uiButSetFlag(but, UI_BUT_NO_UTF8); - - /* check if this overrides a file and if the operator option is used */ - if(overwrite_alert) { - uiButSetFlag(but, UI_BUT_REDALERT); + if((params->flag & FILE_DIRSEL_ONLY) == 0) { + but = uiDefBut(block, TEX, B_FS_FILENAME, "", + min_x, line2_y, line2_w-chan_offs, btn_h, + params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0, + overwrite_alert ?"File name, overwrite existing." : "File name."); + uiButSetCompleteFunc(but, autocomplete_file, NULL); + uiButSetFlag(but, UI_BUT_NO_UTF8); + + /* check if this overrides a file and if the operator option is used */ + if(overwrite_alert) { + uiButSetFlag(but, UI_BUT_REDALERT); + } } /* clear func */ @@ -202,7 +204,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) } /* Filename number increment / decrement buttons. */ - if (fnumbuttons) { + if (fnumbuttons && (params->flag & FILE_DIRSEL_ONLY) == 0) { uiBlockBeginAlign(block); but = uiDefIconButO(block, BUT, "FILE_OT_filenum", 0, ICON_ZOOMOUT, min_x + line2_w + separator - chan_offs, line2_y, diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index a5d516a1417..11e7040d4c9 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -205,9 +205,10 @@ static FileSelect file_select(bContext* C, const rcti* rect, FileSelType select, SpaceFile *sfile= CTX_wm_space_file(C); FileSelect retval = FILE_SELECT_NOTHING; FileSelection sel= file_selection_get(C, rect, fill); /* get the selection */ + const FileCheckType check_type= (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_ALL; /* flag the files as selected in the filelist */ - filelist_select(sfile->files, &sel, select, SELECTED_FILE, CHECK_ALL); + filelist_select(sfile->files, &sel, select, SELECTED_FILE, check_type); /* Don't act on multiple selected files */ if (sel.first != sel.last) select = 0; @@ -216,7 +217,7 @@ static FileSelect file_select(bContext* C, const rcti* rect, FileSelType select, if ( (sel.last >= 0) && ((select == FILE_SEL_ADD) || (select == FILE_SEL_TOGGLE)) ) { /* Check last selection, if selected, act on the file or dir */ - if (filelist_is_selected(sfile->files, sel.last, CHECK_ALL)) { + if (filelist_is_selected(sfile->files, sel.last, check_type)) { retval = file_select_do(C, sel.last); } } @@ -378,8 +379,10 @@ static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) /* select all only if previously no file was selected */ if (is_selected) { filelist_select(sfile->files, &sel, FILE_SEL_REMOVE, SELECTED_FILE, CHECK_ALL); - } else { - filelist_select(sfile->files, &sel, FILE_SEL_ADD, SELECTED_FILE, CHECK_FILES); + } + else { + const FileCheckType check_type= (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_FILES; + filelist_select(sfile->files, &sel, FILE_SEL_ADD, SELECTED_FILE, check_type); } ED_area_tag_redraw(sa); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 32b725e0b1f..6736230e84f 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -915,6 +915,8 @@ void filelist_select_file(struct FileList* filelist, int index, FileSelType sele int check_ok = 0; switch (check) { case CHECK_DIRS: + check_ok = S_ISDIR(file->type); + break; case CHECK_ALL: check_ok = 1; break; diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 45193a38ef5..3dbfdc9f7d0 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -121,6 +121,9 @@ short ED_fileselect_set_params(SpaceFile *sfile) /* set the parameters from the operator, if it exists */ if (op) { + short is_filename= FALSE; + short is_dir= FALSE; + BLI_strncpy(params->title, op->type->name, sizeof(params->title)); if(RNA_struct_find_property(op->ptr, "filemode")) @@ -128,7 +131,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) else params->type = FILE_SPECIAL; - if (RNA_struct_find_property(op->ptr, "filepath") && RNA_property_is_set(op->ptr, "filepath")) { + if ((is_dir= is_filename= RNA_struct_find_property(op->ptr, "filepath")!=NULL) && RNA_property_is_set(op->ptr, "filepath")) { char name[FILE_MAX]; RNA_string_get(op->ptr, "filepath", name); if (params->type == FILE_LOADLIB) { @@ -140,12 +143,13 @@ short ED_fileselect_set_params(SpaceFile *sfile) } } else { - if (RNA_struct_find_property(op->ptr, "directory") && RNA_property_is_set(op->ptr, "directory")) { + if ((is_dir= RNA_struct_find_property(op->ptr, "directory")!=NULL) && RNA_property_is_set(op->ptr, "directory")) { RNA_string_get(op->ptr, "directory", params->dir); sfile->params->file[0]= '\0'; + is_dir= TRUE; } - if (RNA_struct_find_property(op->ptr, "filename") && RNA_property_is_set(op->ptr, "filename")) { + if ((is_filename= RNA_struct_find_property(op->ptr, "filename")!=NULL) && RNA_property_is_set(op->ptr, "filename")) { RNA_string_get(op->ptr, "filename", params->file); } } @@ -155,6 +159,13 @@ short ED_fileselect_set_params(SpaceFile *sfile) BLI_path_abs(params->dir, G.main->name); } + if(is_dir==TRUE && is_filename==FALSE) { + params->flag |= FILE_DIRSEL_ONLY; + } + else { + params->flag &= ~FILE_DIRSEL_ONLY; + } + params->filter = 0; if(RNA_struct_find_property(op->ptr, "filter_blender")) params->filter |= RNA_boolean_get(op->ptr, "filter_blender") ? BLENDERFILE : 0; @@ -216,10 +227,12 @@ short ED_fileselect_set_params(SpaceFile *sfile) params->display= FILE_SHORTDISPLAY; } - } else { + } + else { /* default values, if no operator */ params->type = FILE_UNIX; params->flag |= FILE_HIDE_DOT; + params->flag &= ~FILE_DIRSEL_ONLY; params->display = FILE_SHORTDISPLAY; params->filter = 0; params->filter_glob[0] = '\0'; diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index e120cd14775..2b039060e47 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -696,18 +696,19 @@ enum FileSortTypeE { #define FILE_OPENFILE 0 #define FILE_SAVE 1 -/* sfile->flag and simasel->flag */ -#define FILE_SHOWSHORT 1 -#define FILE_RELPATH 2 /* was FILE_STRINGCODE */ -#define FILE_LINK 4 -#define FILE_HIDE_DOT 8 -#define FILE_AUTOSELECT 16 -#define FILE_ACTIVELAY 32 -#define FILE_ATCURSOR 64 -#define FILE_SYNCPOSE 128 -#define FILE_FILTER 256 -#define FILE_BOOKMARKS 512 -#define FILE_GROUP_INSTANCE 1024 +/* sfile->params->flag and simasel->flag */ +#define FILE_SHOWSHORT (1<<0) +#define FILE_RELPATH (1<<1) /* was FILE_STRINGCODE */ +#define FILE_LINK (1<<2) +#define FILE_HIDE_DOT (1<<3) +#define FILE_AUTOSELECT (1<<4) +#define FILE_ACTIVELAY (1<<5) +#define FILE_ATCURSOR (1<<6) +#define FILE_DIRSEL_ONLY (1<<7) +#define FILE_FILTER (1<<8) +#define FILE_BOOKMARKS (1<<9) +#define FILE_GROUP_INSTANCE (1<<10) + /* files in filesel list: file types */ #define BLENDERFILE (1<<2) From dce577ad85e9c3349000143cf4e7647254c01cb9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Jun 2011 15:28:39 +0000 Subject: [PATCH 003/131] use directory selector for properties defined as PROP_DIRPATH, user preferences 'File' buttons for eg. --- .../editors/interface/interface_layout.c | 5 +++- .../editors/space_buttons/buttons_intern.h | 1 + .../editors/space_buttons/buttons_ops.c | 24 ++++++++++++++++--- .../editors/space_buttons/space_buttons.c | 1 + 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 55c1488291b..79a90fb9d1d 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -534,7 +534,10 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w-UI_UNIT_X, h); /* BUTTONS_OT_file_browse calls uiFileBrowseContextProperty */ - but= uiDefIconButO(block, BUT, "BUTTONS_OT_file_browse", WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL); + but= uiDefIconButO(block, BUT, subtype==PROP_DIRPATH ? + "BUTTONS_OT_directory_browse" : + "BUTTONS_OT_file_browse", + WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL); } else if(flag & UI_ITEM_R_EVENT) { uiDefButR(block, KEYEVT, 0, name, x, y, w, h, ptr, RNA_property_identifier(prop), index, 0, 0, -1, -1, NULL); diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index 925223b43ea..d25bd7940ab 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -71,6 +71,7 @@ extern const char *buttons_context_dir[]; /* doc access */ /* buttons_ops.c */ void BUTTONS_OT_file_browse(struct wmOperatorType *ot); +void BUTTONS_OT_directory_browse(struct wmOperatorType *ot); void BUTTONS_OT_toolbox(struct wmOperatorType *ot); #endif /* ED_BUTTONS_INTERN_H */ diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 9b914df1b3c..99e5c6d693e 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -104,11 +104,12 @@ static int file_browse_exec(bContext *C, wmOperator *op) FileBrowseOp *fbo= op->customdata; ID *id; char *base, *str, path[FILE_MAX]; + const char *path_prop= RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath"; - if (RNA_property_is_set(op->ptr, "filepath")==0 || fbo==NULL) + if (RNA_property_is_set(op->ptr, path_prop)==0 || fbo==NULL) return OPERATOR_CANCELLED; - str= RNA_string_get_alloc(op->ptr, "filepath", NULL, 0); + str= RNA_string_get_alloc(op->ptr, path_prop, NULL, 0); /* add slash for directories, important for some properties */ if(RNA_property_subtype(fbo->prop) == PROP_DIRPATH) { @@ -191,12 +192,13 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } else { + const char *path_prop= RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath"; fbo= MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp"); fbo->ptr= ptr; fbo->prop= prop; op->customdata= fbo; - RNA_string_set(op->ptr, "filepath", str); + RNA_string_set(op->ptr, path_prop, str); MEM_freeN(str); if(RNA_struct_find_property(op->ptr, "relative_path")) { @@ -227,3 +229,19 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot) WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); } +/* second operator, only difference from BUTTONS_OT_file_browse is WM_FILESEL_DIRECTORY */ +void BUTTONS_OT_directory_browse(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Accept"; + ot->description="Open a directory browser, Hold Shift to open the file, Alt to browse containing directory"; + ot->idname= "BUTTONS_OT_directory_browse"; + + /* api callbacks */ + ot->invoke= file_browse_invoke; + ot->exec= file_browse_exec; + ot->cancel= file_browse_cancel; + + /* properties */ + WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH); +} diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 16c4df59420..e2d80e9e775 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -187,6 +187,7 @@ static void buttons_operatortypes(void) { WM_operatortype_append(BUTTONS_OT_toolbox); WM_operatortype_append(BUTTONS_OT_file_browse); + WM_operatortype_append(BUTTONS_OT_directory_browse); } static void buttons_keymap(struct wmKeyConfig *keyconf) From 30823cbb8713b7d3f41256f9ec3ef8d24262b998 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 16 Jun 2011 16:13:26 +0000 Subject: [PATCH 004/131] Python Docs: update layout.html to match blender.org development submenu changes. --- doc/python_api/blender-org/layout.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/python_api/blender-org/layout.html b/doc/python_api/blender-org/layout.html index a37ed730c22..88db31e1586 100644 --- a/doc/python_api/blender-org/layout.html +++ b/doc/python_api/blender-org/layout.html @@ -8,7 +8,7 @@ {%- macro relbar() %}