diff options
Diffstat (limited to 'source/blender/editors/space_buttons')
7 files changed, 109 insertions, 53 deletions
diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt new file mode 100644 index 00000000000..bb50ac0cc86 --- /dev/null +++ b/source/blender/editors/space_buttons/CMakeLists.txt @@ -0,0 +1,34 @@ +# $Id: CMakeLists.txt 12931 2007-12-17 18:20:48Z theeth $ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributor(s): Jacques Beaurain. +# +# ***** END GPL LICENSE BLOCK ***** + +FILE(GLOB SRC *.c) + +SET(INC + ../../blenkernel + ../../blenlib + ../include + ../../../../intern/guardedalloc + ../../makesdna + ../../makesrna + ../../windowmanager +) + +BLENDERLIB(bf_editor_space_buttons "${SRC}" "${INC}") diff --git a/source/blender/editors/space_buttons/Makefile b/source/blender/editors/space_buttons/Makefile index a4894ede06b..28758fb168b 100644 --- a/source/blender/editors/space_buttons/Makefile +++ b/source/blender/editors/space_buttons/Makefile @@ -15,7 +15,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # The Original Code is Copyright (C) 2007 Blender Foundation # All rights reserved. diff --git a/source/blender/editors/space_buttons/SConscript b/source/blender/editors/space_buttons/SConscript index a0a7dad4077..31438b641e0 100644 --- a/source/blender/editors/space_buttons/SConscript +++ b/source/blender/editors/space_buttons/SConscript @@ -9,7 +9,4 @@ incs += ' ../../makesrna ../../render/extern/include' defs = [] -if env['WITH_BF_GAMEENGINE']: - defs.append('GAMEBLENDER=1') - env.BlenderLib ( 'bf_editors_space_buttons', sources, Split(incs), defs, libtype=['core'], priority=[120] ) diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 961c3cf17ce..343237dee5e 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -36,11 +36,11 @@ #include "DNA_node_types.h" #include "DNA_scene_types.h" #include "DNA_world_types.h" +#include "DNA_brush_types.h" #include "BLI_listbase.h" #include "BKE_context.h" -#include "BKE_global.h" #include "BKE_action.h" #include "BKE_material.h" #include "BKE_modifier.h" @@ -49,7 +49,6 @@ #include "BKE_screen.h" #include "BKE_texture.h" #include "BKE_utildefines.h" -#include "BKE_world.h" #include "RNA_access.h" @@ -342,7 +341,7 @@ static int buttons_context_path_brush(const bContext *C, ButsContextPath *path) br= paint_brush(paint_get_active(scene)); if(br) { - RNA_id_pointer_create(&br->id, &path->ptr[path->len]); + RNA_id_pointer_create((ID *)br, &path->ptr[path->len]); path->len++; return 1; @@ -699,11 +698,20 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r Material *ma= ptr->data; /* if we have a node material, get slot from material in material node */ - if(ma && ma->use_nodes && ma->nodetree) + if(ma && ma->use_nodes && ma->nodetree) { + /* if there's an active texture node in the node tree, + * then that texture is in context directly, without a texture slot */ + if (give_current_material_texture_node(ma)) + return 0; + ma= give_node_material(ma); - - if(ma) + if (ma) + CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]); + else + return 0; + } else if(ma) { CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]); + } } else if((ptr=get_pointer_type(path, &RNA_Lamp))) { Lamp *la= ptr->data; diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index d8cbbb0cbae..ab756b638fa 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -30,20 +30,15 @@ #include <stdio.h> -#include "MEM_guardedalloc.h" #include "BLI_blenlib.h" #include "BKE_context.h" -#include "BKE_screen.h" -#include "BKE_utildefines.h" #include "ED_screen.h" #include "ED_types.h" -#include "BIF_gl.h" -#include "BIF_glutil.h" #include "UI_interface.h" #include "UI_resources.h" diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 9261e28cd6a..c4357008a9c 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -30,6 +30,9 @@ #include "MEM_guardedalloc.h" +#include "DNA_userdef_types.h" + +#include "BLI_fileops.h" #include "BKE_context.h" @@ -88,10 +91,10 @@ static int file_browse_exec(bContext *C, wmOperator *op) FileBrowseOp *fbo= op->customdata; char *str; - if (RNA_property_is_set(op->ptr, "path")==0 || fbo==NULL) + if (RNA_property_is_set(op->ptr, "filepath")==0 || fbo==NULL) return OPERATOR_CANCELLED; - str= RNA_string_get_alloc(op->ptr, "path", 0, 0); + str= RNA_string_get_alloc(op->ptr, "filepath", 0, 0); RNA_property_string_set(&fbo->ptr, fbo->prop, str); RNA_property_update(C, &fbo->ptr, fbo->prop); MEM_freeN(str); @@ -119,26 +122,53 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) if(!prop) return OPERATOR_CANCELLED; - - fbo= MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp"); - fbo->ptr= ptr; - fbo->prop= prop; - op->customdata= fbo; str= RNA_property_string_get_alloc(&ptr, prop, 0, 0); - RNA_string_set(op->ptr, "path", str); - MEM_freeN(str); - WM_event_add_fileselect(C, op); - - return OPERATOR_RUNNING_MODAL; + /* useful yet irritating feature, Shift+Click to open the file + * Alt+Click to browse a folder in the OS's browser */ + if(event->shift || event->alt) { + PointerRNA props_ptr; + + if(event->alt) { + char *lslash= BLI_last_slash(str); + if(lslash) + *lslash= '\0'; + } + + + WM_operator_properties_create(&props_ptr, "WM_OT_path_open"); + RNA_string_set(&props_ptr, "filepath", str); + WM_operator_name_call(C, "WM_OT_path_open", WM_OP_EXEC_DEFAULT, &props_ptr); + WM_operator_properties_free(&props_ptr); + + MEM_freeN(str); + return OPERATOR_CANCELLED; + } + else { + fbo= MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp"); + fbo->ptr= ptr; + fbo->prop= prop; + op->customdata= fbo; + + RNA_string_set(op->ptr, "filepath", str); + MEM_freeN(str); + + if(RNA_struct_find_property(op->ptr, "relative_path")) + if(!RNA_property_is_set(op->ptr, "relative_path")) + RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS); + + WM_event_add_fileselect(C, op); + + return OPERATOR_RUNNING_MODAL; + } } void BUTTONS_OT_file_browse(wmOperatorType *ot) { /* identifiers */ ot->name= "Accept"; - ot->description="Open a file browser"; + ot->description="Open a file browser, Hold Shift to open the file, Alt to browse containing directory"; ot->idname= "BUTTONS_OT_file_browse"; /* api callbacks */ @@ -147,6 +177,6 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot) ot->cancel= file_browse_cancel; /* properties */ - WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE); + WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); } diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 66068a4f23c..0b6e752574b 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -36,7 +36,6 @@ #include "BLI_math.h" #include "BLI_rand.h" -#include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_screen.h" @@ -191,39 +190,22 @@ void buttons_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "BUTTONS_OT_toolbox", RIGHTMOUSE, KM_PRESS, 0, 0); } -//#define PY_HEADER /* add handlers, stuff you only do once or on area/region changes */ static void buttons_header_area_init(wmWindowManager *wm, ARegion *ar) { -#ifdef PY_HEADER - ED_region_header_init(ar); -#else UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); -#endif } static void buttons_header_area_draw(const bContext *C, ARegion *ar) { -#ifdef PY_HEADER - ED_region_header(C, ar); -#else - - float col[3]; - /* clear */ - if(ED_screen_area_active(C)) - UI_GetThemeColor3fv(TH_HEADER, col); - else - UI_GetThemeColor3fv(TH_HEADERDESEL, col); - - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(ED_screen_area_active(C)?TH_HEADER:TH_HEADERDESEL); glClear(GL_COLOR_BUFFER_BIT); /* set view2d view matrix for scrolling (without scrollers) */ UI_view2d_view_ortho(C, &ar->v2d); buttons_header_buttons(C, ar); -#endif /* restore view matrix? */ UI_view2d_view_restore(C); @@ -268,6 +250,8 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) case ND_KEYINGSET: buttons_area_redraw(sa, BCONTEXT_SCENE); break; + case ND_RENDER_RESULT: + break; case ND_MODE: case ND_LAYER: default: @@ -297,8 +281,9 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) buttons_area_redraw(sa, BCONTEXT_CONSTRAINT); buttons_area_redraw(sa, BCONTEXT_BONE_CONSTRAINT); break; - case ND_PARTICLE_DATA: - buttons_area_redraw(sa, BCONTEXT_PARTICLE); + case ND_PARTICLE: + if (wmn->action == NA_EDITED) + buttons_area_redraw(sa, BCONTEXT_PARTICLE); break; case ND_DRAW: buttons_area_redraw(sa, BCONTEXT_OBJECT); @@ -344,9 +329,9 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_BRUSH: buttons_area_redraw(sa, BCONTEXT_TEXTURE); - sbuts->preview= 1; break; case NC_TEXTURE: + case NC_IMAGE: ED_area_tag_redraw(sa); sbuts->preview= 1; break; @@ -360,10 +345,17 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_ANIMATION: switch(wmn->data) { - case ND_KEYFRAME_EDIT: - ED_area_tag_redraw(sa); + case ND_KEYFRAME: + if (wmn->action == NA_EDITED) + ED_area_tag_redraw(sa); break; } + break; + /* Listener for preview render, when doing an global undo. */ + case NC_WINDOW: + ED_area_tag_redraw(sa); + sbuts->preview= 1; + break; } if(wmn->data == ND_KEYS) |