diff options
Diffstat (limited to 'source/blender/editors/space_buttons')
7 files changed, 108 insertions, 60 deletions
diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt index 9e045a39a0c..397d79e1dbe 100644 --- a/source/blender/editors/space_buttons/CMakeLists.txt +++ b/source/blender/editors/space_buttons/CMakeLists.txt @@ -20,13 +20,15 @@ set(INC ../include - ../../blenfont ../../blenkernel ../../blenlib + ../../blentranslation + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -46,6 +48,8 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +add_definitions(${GL_DEFINITIONS}) + if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) endif() diff --git a/source/blender/editors/space_buttons/SConscript b/source/blender/editors/space_buttons/SConscript index 61f9b6f496e..c39df449647 100644 --- a/source/blender/editors/space_buttons/SConscript +++ b/source/blender/editors/space_buttons/SConscript @@ -31,12 +31,14 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', - '../../blenfont', '../../blenkernel', '../../blenlib', + '../../blentranslation', '../../bmesh', + '../../gpu', '../../imbuf', '../../makesdna', '../../makesrna', @@ -44,7 +46,9 @@ incs = [ '../../windowmanager', ] incs = ' '.join(incs) + defs = [] +defs += env['BF_GL_DEFINITIONS'] if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 524a42ba388..42e2d6b90f0 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -36,7 +36,7 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BLF_translation.h" +#include "BLT_translation.h" #include "DNA_armature_types.h" #include "DNA_lamp_types.h" @@ -59,6 +59,7 @@ #include "RNA_access.h" +#include "ED_buttons.h" #include "ED_armature.h" #include "ED_screen.h" #include "ED_physics.h" @@ -1103,11 +1104,11 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT); block = uiLayoutGetBlock(row); - uiBlockSetEmboss(block, UI_EMBOSSN); - but = uiDefIconButBitC(block, ICONTOG, SB_PIN_CONTEXT, 0, ICON_UNPINNED, 0, 0, UI_UNIT_X, UI_UNIT_Y, &sbuts->flag, + UI_block_emboss_set(block, UI_EMBOSS_NONE); + but = uiDefIconButBitC(block, UI_BTYPE_ICON_TOGGLE, SB_PIN_CONTEXT, 0, ICON_UNPINNED, 0, 0, UI_UNIT_X, UI_UNIT_Y, &sbuts->flag, 0, 0, 0, 0, TIP_("Follow context or keep fixed datablock displayed")); - uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ - uiButSetFunc(but, pin_cb, NULL, NULL); + UI_but_flag_disable(but, UI_BUT_UNDO); /* skip undo on screen buttons */ + UI_but_func_set(but, pin_cb, NULL, NULL); for (a = 0; a < path->len; a++) { ptr = &path->ptr[a]; @@ -1146,7 +1147,7 @@ void buttons_context_register(ARegionType *art) pt = MEM_callocN(sizeof(PanelType), "spacetype buttons panel context"); strcpy(pt->idname, "BUTTONS_PT_context"); strcpy(pt->label, N_("Context")); /* XXX C panels are not available through RNA (bpy.types)! */ - strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA); + strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); pt->draw = buttons_panel_context; pt->flag = PNL_NO_HEADER; BLI_addtail(&art->paneltypes, pt); @@ -1179,3 +1180,33 @@ ID *buttons_context_id_path(const bContext *C) return NULL; } + +void ED_buttons_id_unref(SpaceButs *sbuts, const ID *id) +{ + if (sbuts->pinid == id) { + sbuts->pinid = NULL; + sbuts->flag &= ~SB_PIN_CONTEXT; + } + + if (sbuts->path) { + ButsContextPath *path = sbuts->path; + int i; + + for (i = 0; i < path->len; i++) { + if (path->ptr[i].id.data == id) { + break; + } + } + + if (i == path->len) { + /* pass */ + } + else if (i == 0) { + MEM_SAFE_FREE(sbuts->path); + } + else { + memset(&path->ptr[i], 0, sizeof(path->ptr[i]) * (path->len - i)); + path->len = i; + } + } +} diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index f294729ae97..7fc35a6b1e7 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -34,7 +34,6 @@ #include "DNA_listBase.h" #include "RNA_types.h" -struct ARegion; struct ARegionType; struct ID; struct SpaceButs; diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index b651d684bf6..b8b56f8f848 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -40,7 +40,7 @@ #include "BLI_path_util.h" #include "BLI_string.h" -#include "BLF_translation.h" +#include "BLT_translation.h" #include "BKE_context.h" #include "BKE_global.h" @@ -72,12 +72,12 @@ static int toolbox_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UN RNA_pointer_create(&sc->id, &RNA_SpaceProperties, sbuts, &ptr); - pup = uiPupMenuBegin(C, IFACE_("Align"), ICON_NONE); - layout = uiPupMenuLayout(pup); + pup = UI_popup_menu_begin(C, IFACE_("Align"), ICON_NONE); + layout = UI_popup_menu_layout(pup); uiItemsEnumR(layout, &ptr, "align"); - uiPupMenuEnd(C, pup); + UI_popup_menu_end(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } void BUTTONS_OT_toolbox(wmOperatorType *ot) @@ -97,6 +97,7 @@ void BUTTONS_OT_toolbox(wmOperatorType *ot) typedef struct FileBrowseOp { PointerRNA ptr; PropertyRNA *prop; + bool is_undo; } FileBrowseOp; static int file_browse_exec(bContext *C, wmOperator *op) @@ -142,6 +143,10 @@ static int file_browse_exec(bContext *C, wmOperator *op) RNA_property_update(C, &fbo->ptr, fbo->prop); MEM_freeN(str); + if (fbo->is_undo) { + const char *undostr = RNA_property_identifier(fbo->prop); + ED_undo_push(C, undostr); + } /* special, annoying exception, filesel on redo panel [#26618] */ { @@ -168,6 +173,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event) { PointerRNA ptr; PropertyRNA *prop; + bool is_undo; FileBrowseOp *fbo; char *str; @@ -176,7 +182,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED; } - uiFileBrowseContextProperty(C, &ptr, &prop); + UI_context_active_but_prop_get_filebrowser(C, &ptr, &prop, &is_undo); if (!prop) return OPERATOR_CANCELLED; @@ -186,6 +192,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* 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) { + wmOperatorType *ot = WM_operatortype_find("WM_OT_path_open", true); PointerRNA props_ptr; if (event->alt) { @@ -195,19 +202,21 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event) } - WM_operator_properties_create(&props_ptr, "WM_OT_path_open"); + WM_operator_properties_create_ptr(&props_ptr, ot); RNA_string_set(&props_ptr, "filepath", str); - WM_operator_name_call(C, "WM_OT_path_open", WM_OP_EXEC_DEFAULT, &props_ptr); + WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &props_ptr); WM_operator_properties_free(&props_ptr); MEM_freeN(str); return OPERATOR_CANCELLED; } else { + PropertyRNA *prop_relpath; 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; + fbo->is_undo = is_undo; op->customdata = fbo; RNA_string_set(op->ptr, path_prop, str); @@ -215,10 +224,10 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* normally ED_fileselect_get_params would handle this but we need to because of stupid * user-prefs exception - campbell */ - if (RNA_struct_find_property(op->ptr, "relative_path")) { - if (!RNA_struct_property_is_set(op->ptr, "relative_path")) { + if ((prop_relpath = RNA_struct_find_property(op->ptr, "relative_path"))) { + if (!RNA_property_is_set(op->ptr, prop_relpath)) { /* annoying exception!, if were dealing with the user prefs, default relative to be off */ - RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS && (ptr.data != &U)); + RNA_property_boolean_set(op->ptr, prop_relpath, U.flag & USER_RELPATHS && (ptr.data != &U)); } } WM_event_add_fileselect(C, op); @@ -239,11 +248,12 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot) ot->exec = file_browse_exec; ot->cancel = file_browse_cancel; - ot->flag |= OPTYPE_UNDO; + /* conditional undo based on button flag */ + ot->flag = 0; /* properties */ WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, - WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); + WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA); } /* second operator, only difference from BUTTONS_OT_file_browse is WM_FILESEL_DIRECTORY */ @@ -259,9 +269,10 @@ void BUTTONS_OT_directory_browse(wmOperatorType *ot) ot->exec = file_browse_exec; ot->cancel = file_browse_cancel; - ot->flag |= OPTYPE_UNDO; + /* conditional undo based on button flag */ + ot->flag = 0; /* properties */ WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, - WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); + WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA); } diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index 020d477fc39..b56ff850c35 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -37,7 +37,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLF_translation.h" +#include "BLT_translation.h" #include "DNA_brush_types.h" #include "DNA_ID.h" @@ -61,7 +61,9 @@ #include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_scene.h" -#include "BKE_freestyle.h" +#ifdef WITH_FREESTYLE +# include "BKE_freestyle.h" +#endif #include "RNA_access.h" @@ -256,7 +258,7 @@ static void buttons_texture_user_property_add(ListBase *users, ID *id, user->category = category; user->icon = icon; user->name = name; - user->index = BLI_countlist(users); + user->index = BLI_listbase_count(users); BLI_addtail(users, user); } @@ -273,7 +275,7 @@ static void buttons_texture_user_node_add(ListBase *users, ID *id, user->category = category; user->icon = icon; user->name = name; - user->index = BLI_countlist(users); + user->index = BLI_listbase_count(users); BLI_addtail(users, user); } @@ -468,7 +470,7 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) } else { /* set one user as active based on active index */ - if (ct->index >= BLI_countlist(&ct->users)) + if (ct->index == BLI_listbase_count_ex(&ct->users, ct->index + 1)) ct->index = 0; ct->user = BLI_findlink(&ct->users, ct->index); @@ -557,7 +559,7 @@ static void template_texture_user_menu(bContext *C, uiLayout *layout, void *UNUS char name[UI_MAX_NAME_STR]; /* add label per category */ - if (!last_category || strcmp(last_category, user->category) != 0) { + if (!last_category || !STREQ(last_category, user->category)) { uiItemL(layout, user->category, ICON_NONE); but = block->buttons.last; but->drawflag = UI_BUT_TEXT_LEFT; @@ -576,9 +578,9 @@ static void template_texture_user_menu(bContext *C, uiLayout *layout, void *UNUS else BLI_snprintf(name, UI_MAX_NAME_STR, " %s", user->name); - but = uiDefIconTextBut(block, BUT, 0, user->icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, + but = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, user->icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, ""); - uiButSetNFunc(but, template_texture_select, MEM_dupallocN(user), NULL); + UI_but_funcN_set(but, template_texture_select, MEM_dupallocN(user), NULL); last_category = user->category; } @@ -620,9 +622,9 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C) } /* some cosmetic tweaks */ - uiButSetMenuFromPulldown(but); + UI_but_type_set_menu_from_pulldown(but); - but->flag &= ~UI_ICON_SUBMENU; + but->flag &= ~UI_BUT_ICON_SUBMENU; } /************************* Texture Show **************************/ @@ -675,9 +677,9 @@ void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, Prope uiBlock *block = uiLayoutGetBlock(layout); uiBut *but; - but = uiDefIconBut(block, BUT, 0, ICON_BUTS, 0, 0, UI_UNIT_X, UI_UNIT_Y, + but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_BUTS, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Show texture in texture tab"); - uiButSetFunc(but, template_texture_show, user->ptr.data, user->prop); + UI_but_func_set(but, template_texture_show, user->ptr.data, user->prop); } } diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 4d62f528915..e28ad686d2a 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -28,7 +28,6 @@ * \ingroup spbuttons */ - #include <string.h> #include <stdio.h> @@ -46,10 +45,6 @@ #include "WM_api.h" #include "WM_types.h" -#include "UI_resources.h" -#include "UI_view2d.h" - - #include "buttons_intern.h" /* own include */ /* ******************** default callbacks for buttons space ***************** */ @@ -142,38 +137,38 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ SpaceButs *sbuts = CTX_wm_space_buts(C); - int vertical = (sbuts->align == BUT_VERTICAL); + const bool vertical = (sbuts->align == BUT_VERTICAL); buttons_context_compute(C, sbuts); if (sbuts->mainb == BCONTEXT_SCENE) - ED_region_panels(C, ar, vertical, "scene", sbuts->mainb); + ED_region_panels(C, ar, "scene", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_RENDER) - ED_region_panels(C, ar, vertical, "render", sbuts->mainb); + ED_region_panels(C, ar, "render", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_RENDER_LAYER) - ED_region_panels(C, ar, vertical, "render_layer", sbuts->mainb); + ED_region_panels(C, ar, "render_layer", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_WORLD) - ED_region_panels(C, ar, vertical, "world", sbuts->mainb); + ED_region_panels(C, ar, "world", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_OBJECT) - ED_region_panels(C, ar, vertical, "object", sbuts->mainb); + ED_region_panels(C, ar, "object", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_DATA) - ED_region_panels(C, ar, vertical, "data", sbuts->mainb); + ED_region_panels(C, ar, "data", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_MATERIAL) - ED_region_panels(C, ar, vertical, "material", sbuts->mainb); + ED_region_panels(C, ar, "material", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_TEXTURE) - ED_region_panels(C, ar, vertical, "texture", sbuts->mainb); + ED_region_panels(C, ar, "texture", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_PARTICLE) - ED_region_panels(C, ar, vertical, "particle", sbuts->mainb); + ED_region_panels(C, ar, "particle", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_PHYSICS) - ED_region_panels(C, ar, vertical, "physics", sbuts->mainb); + ED_region_panels(C, ar, "physics", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_BONE) - ED_region_panels(C, ar, vertical, "bone", sbuts->mainb); + ED_region_panels(C, ar, "bone", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_MODIFIER) - ED_region_panels(C, ar, vertical, "modifier", sbuts->mainb); + ED_region_panels(C, ar, "modifier", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_CONSTRAINT) - ED_region_panels(C, ar, vertical, "constraint", sbuts->mainb); + ED_region_panels(C, ar, "constraint", sbuts->mainb, vertical); else if (sbuts->mainb == BCONTEXT_BONE_CONSTRAINT) - ED_region_panels(C, ar, vertical, "bone_constraint", sbuts->mainb); + ED_region_panels(C, ar, "bone_constraint", sbuts->mainb, vertical); sbuts->re_align = 0; sbuts->mainbo = sbuts->mainb; @@ -376,9 +371,11 @@ static void buttons_area_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier * } break; /* Listener for preview render, when doing an global undo. */ - case NC_WINDOW: - ED_area_tag_redraw(sa); - sbuts->preview = 1; + case NC_WM: + if (wmn->data == ND_UNDO) { + ED_area_tag_redraw(sa); + sbuts->preview = 1; + } break; #ifdef WITH_FREESTYLE case NC_LINESTYLE: |