From dce577ad85e9c3349000143cf4e7647254c01cb9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Jun 2011 15:28:39 +0000 Subject: use directory selector for properties defined as PROP_DIRPATH, user preferences 'File' buttons for eg. --- .../blender/editors/space_buttons/buttons_intern.h | 1 + source/blender/editors/space_buttons/buttons_ops.c | 24 +++++++++++++++++++--- .../blender/editors/space_buttons/space_buttons.c | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/space_buttons') 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) -- cgit v1.2.3 From 74536efa9180da90daf651b162296a474e5bfde8 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 13 Jul 2011 17:52:23 +0000 Subject: Fix #26704: activating a texture node inside material nodes did not show that texture in the texture properties. --- source/blender/editors/space_buttons/buttons_context.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/space_buttons') diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index f91e830d52e..8e1a4b2d16c 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -218,7 +218,7 @@ static int buttons_context_path_modifier(ButsContextPath *path) return 0; } -static int buttons_context_path_material(ButsContextPath *path) +static int buttons_context_path_material(ButsContextPath *path, int for_texture) { Object *ob; PointerRNA *ptr= &path->ptr[path->len-1]; @@ -236,6 +236,9 @@ static int buttons_context_path_material(ButsContextPath *path) ma= give_current_material(ob, ob->actcol); RNA_id_pointer_create(&ma->id, &path->ptr[path->len]); path->len++; + + if(for_texture && give_current_material_texture_node(ma)) + return 1; ma= give_node_material(ma); if(ma) { @@ -432,7 +435,7 @@ static int buttons_context_path_texture(ButsContextPath *path) } } /* try material */ - if(buttons_context_path_material(path)) { + if(buttons_context_path_material(path, 1)) { ma= path->ptr[path->len-1].data; if(ma) { @@ -524,7 +527,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma found= buttons_context_path_particle(path); break; case BCONTEXT_MATERIAL: - found= buttons_context_path_material(path); + found= buttons_context_path_material(path, 0); break; case BCONTEXT_TEXTURE: found= buttons_context_path_texture(path); -- cgit v1.2.3