diff options
Diffstat (limited to 'source/blender/editors/space_buttons')
7 files changed, 92 insertions, 21 deletions
diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt index 7233d4623d1..10080c62594 100644 --- a/source/blender/editors/space_buttons/CMakeLists.txt +++ b/source/blender/editors/space_buttons/CMakeLists.txt @@ -48,4 +48,8 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +if(WITH_FREESTYLE) + add_definitions(-DWITH_FREESTYLE) +endif() + blender_add_lib(bf_editor_space_buttons "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_buttons/SConscript b/source/blender/editors/space_buttons/SConscript index 92579b6dedf..1f7939598c8 100644 --- a/source/blender/editors/space_buttons/SConscript +++ b/source/blender/editors/space_buttons/SConscript @@ -1,4 +1,30 @@ -#!/usr/bin/python +#!/usr/bin/env python +# +# ***** 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. +# +# The Original Code is Copyright (C) 2006, Blender Foundation +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): Nathan Letwory. +# +# ***** END GPL LICENSE BLOCK ***** + Import ('env') sources = env.Glob('*.c') @@ -12,4 +38,7 @@ defs = [] if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') +if env['WITH_BF_FREESTYLE']: + defs.append('WITH_FREESTYLE') + 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 2a5b64cd6ed..95d43fd334e 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -36,6 +36,8 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "DNA_armature_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" @@ -538,6 +540,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma switch (mainb) { case BCONTEXT_SCENE: case BCONTEXT_RENDER: + case BCONTEXT_RENDER_LAYER: found = buttons_context_path_scene(path); break; case BCONTEXT_WORLD: @@ -1028,7 +1031,8 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) 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, 0, 0, 0, 0, "Follow context or keep fixed datablock displayed"); + but = uiDefIconButBitC(block, ICONTOG, SB_PIN_CONTEXT, 0, ICON_UNPINNED, 0, 0, UI_UNIT_X, UI_UNIT_Y, &sbuts->flag, + 0, 0, 0, 0, IFACE_("Follow context or keep fixed datablock displayed")); uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ uiButSetFunc(but, pin_cb, NULL, NULL); @@ -1043,7 +1047,7 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) name = RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL); if (name) { - if (!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE) && ptr->type == &RNA_Scene) + if (!ELEM3(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_RENDER_LAYER) && ptr->type == &RNA_Scene) uiItemLDrag(row, ptr, "", icon); /* save some space */ else uiItemLDrag(row, ptr, name, icon); @@ -1068,7 +1072,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, "Context"); + strcpy(pt->label, N_("Context")); /* XXX C panels are not available through RNA (bpy.types)! */ pt->draw = buttons_panel_context; pt->flag = PNL_NO_HEADER; BLI_addtail(&art->paneltypes, pt); diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index ebba7d92819..19bfe05e8a4 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -97,14 +97,15 @@ static void do_buttons_buttons(bContext *C, void *UNUSED(arg), int event) sbuts->mainbuser = sbuts->mainb; } -#define BUT_UNIT_X (UI_UNIT_X + 2) +#define BUT_UNIT_X (UI_UNIT_X + 2 * U.pixelsize) void buttons_header_buttons(const bContext *C, ARegion *ar) { SpaceButs *sbuts = CTX_wm_space_buts(C); uiBlock *block; uiBut *but; - int xco, yco = 2; + int headery = ED_area_headersize(); + int xco, yco = 0.5f * (headery - UI_UNIT_Y); buttons_context_compute(C, sbuts); @@ -128,6 +129,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) } (void)0 BUTTON_HEADER_CTX(BCONTEXT_RENDER, ICON_SCENE, N_("Render")); + BUTTON_HEADER_CTX(BCONTEXT_RENDER_LAYER, ICON_RENDERLAYERS, N_("Render Layers")); BUTTON_HEADER_CTX(BCONTEXT_SCENE, ICON_SCENE_DATA, N_("Scene")); BUTTON_HEADER_CTX(BCONTEXT_WORLD, ICON_WORLD, N_("World")); BUTTON_HEADER_CTX(BCONTEXT_OBJECT, ICON_OBJECT_DATA, N_("Object")); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index d40426a5bc9..dcc61cfa544 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -35,10 +35,12 @@ #include "DNA_userdef_types.h" +#include "BLI_utildefines.h" #include "BLI_fileops.h" #include "BLI_path_util.h" #include "BLI_string.h" -#include "BLI_utildefines.h" + +#include "BLF_translation.h" #include "BKE_context.h" #include "BKE_global.h" @@ -60,7 +62,7 @@ /********************** toolbox operator *********************/ -static int toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) +static int toolbox_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) { bScreen *sc = CTX_wm_screen(C); SpaceButs *sbuts = CTX_wm_space_buts(C); @@ -70,7 +72,7 @@ static int toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(e RNA_pointer_create(&sc->id, &RNA_SpaceProperties, sbuts, &ptr); - pup = uiPupMenuBegin(C, "Align", ICON_NONE); + pup = uiPupMenuBegin(C, IFACE_("Align"), ICON_NONE); layout = uiPupMenuLayout(pup); uiItemsEnumR(layout, &ptr, "align"); uiPupMenuEnd(C, pup); @@ -111,19 +113,28 @@ static int file_browse_exec(bContext *C, wmOperator *op) /* add slash for directories, important for some properties */ if (RNA_property_subtype(fbo->prop) == PROP_DIRPATH) { - char name[FILE_MAX]; - + int is_relative = RNA_boolean_get(op->ptr, "relative_path"); id = fbo->ptr.id.data; BLI_strncpy(path, str, FILE_MAX); BLI_path_abs(path, id ? ID_BLEND_PATH(G.main, id) : G.main->name); if (BLI_is_dir(path)) { - str = MEM_reallocN(str, strlen(str) + 2); + if (is_relative) { + BLI_strncpy(path, str, FILE_MAX); + BLI_path_rel(path, G.main->name); + str = MEM_reallocN(str, strlen(path) + 2); + BLI_strncpy(str, path, FILE_MAX); + } + else { + str = MEM_reallocN(str, strlen(str) + 2); + } BLI_add_slash(str); } - else - BLI_splitdirstring(str, name); + else { + char * const lslash = (char *)BLI_last_slash(str); + if (lslash) lslash[1] = '\0'; + } } RNA_property_string_set(&fbo->ptr, fbo->prop, str); @@ -154,7 +165,7 @@ static int file_browse_cancel(bContext *UNUSED(C), wmOperator *op) return OPERATOR_CANCELLED; } -static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event) { PointerRNA ptr; PropertyRNA *prop; @@ -179,7 +190,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) PointerRNA props_ptr; if (event->alt) { - char *lslash = BLI_last_slash(str); + char *lslash = (char *)BLI_last_slash(str); if (lslash) *lslash = '\0'; } diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index abfefba02b9..b108f9fa4b5 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -37,6 +37,8 @@ #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "DNA_brush_types.h" #include "DNA_ID.h" #include "DNA_lamp_types.h" @@ -116,10 +118,10 @@ static void buttons_texture_users_find_nodetree(ListBase *users, ID *id, if (node->typeinfo->nclass == NODE_CLASS_TEXTURE) { PointerRNA ptr; /* PropertyRNA *prop; */ /* UNUSED */ - + RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); /* prop = RNA_struct_find_property(&ptr, "texture"); */ /* UNUSED */ - + buttons_texture_user_node_add(users, id, ntree, node, category, RNA_struct_ui_icon(ptr.type), node->name); } @@ -358,7 +360,17 @@ static void template_texture_user_menu(bContext *C, uiLayout *layout, void *UNUS } /* create button */ - BLI_snprintf(name, UI_MAX_NAME_STR, " %s", user->name); + if (user->prop) { + PointerRNA texptr = RNA_property_pointer_get(&user->ptr, user->prop); + Tex *tex = texptr.data; + + if (tex) + BLI_snprintf(name, UI_MAX_NAME_STR, " %s - %s", user->name, tex->id.name + 2); + else + BLI_snprintf(name, UI_MAX_NAME_STR, " %s", user->name); + } + 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, NULL, 0.0, 0.0, 0.0, 0.0, ""); @@ -387,12 +399,12 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C) user = ct->user; if (!user) { - uiItemL(layout, "No textures in context.", ICON_NONE); + uiItemL(layout, IFACE_("No textures in context"), ICON_NONE); return; } /* create button */ - BLI_snprintf(name, UI_MAX_NAME_STR, "%s", user->name); + BLI_strncpy(name, user->name, UI_MAX_NAME_STR); if (user->icon) { but = uiDefIconTextMenuBut(block, template_texture_user_menu, NULL, diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index c98d213e949..6367ca893d1 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -155,6 +155,8 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar) ED_region_panels(C, ar, vertical, "scene", sbuts->mainb); else if (sbuts->mainb == BCONTEXT_RENDER) ED_region_panels(C, ar, vertical, "render", sbuts->mainb); + else if (sbuts->mainb == BCONTEXT_RENDER_LAYER) + ED_region_panels(C, ar, vertical, "render_layer", sbuts->mainb); else if (sbuts->mainb == BCONTEXT_WORLD) ED_region_panels(C, ar, vertical, "world", sbuts->mainb); else if (sbuts->mainb == BCONTEXT_OBJECT) @@ -239,6 +241,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) switch (wmn->data) { case ND_RENDER_OPTIONS: buttons_area_redraw(sa, BCONTEXT_RENDER); + buttons_area_redraw(sa, BCONTEXT_RENDER_LAYER); break; case ND_FRAME: /* any buttons area can have animated properties so redraw all */ @@ -375,6 +378,12 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_redraw(sa); sbuts->preview = 1; break; +#ifdef WITH_FREESTYLE + case NC_LINESTYLE: + ED_area_tag_redraw(sa); + sbuts->preview = 1; + break; +#endif } if (wmn->data == ND_KEYS) |