Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--intern/cycles/blender/addon/ui.py6
-rw-r--r--release/scripts/startup/bl_ui/properties_texture.py41
-rw-r--r--source/blender/editors/include/ED_buttons.h39
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c75
-rw-r--r--source/blender/editors/space_buttons/buttons_header.c49
-rw-r--r--source/blender/editors/space_buttons/buttons_intern.h1
-rw-r--r--source/blender/editors/space_buttons/buttons_texture.c178
-rw-r--r--source/blender/makesdna/DNA_space_types.h20
-rw-r--r--source/blender/makesrna/intern/rna_space.c73
-rw-r--r--source/blenderplayer/bad_level_call_stubs/stubs.c6
10 files changed, 322 insertions, 166 deletions
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index b9e71a29f6c..d33422050a0 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -885,13 +885,15 @@ class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
use_pin_id = space.use_pin_id
user = context.texture_user
- if not use_pin_id or not isinstance(pin_id, bpy.types.Texture):
+ space.use_limited_texture_context = False
+
+ if not (use_pin_id and isinstance(pin_id, bpy.types.Texture)):
pin_id = None
if not pin_id:
layout.template_texture_user()
- if user:
+ if user or pin_id:
layout.separator()
split = layout.split(percentage=0.65)
diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py
index 2d064404828..8875161170a 100644
--- a/release/scripts/startup/bl_ui/properties_texture.py
+++ b/release/scripts/startup/bl_ui/properties_texture.py
@@ -125,15 +125,15 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel):
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
- if not (hasattr(context, "texture_slot") or hasattr(context, "texture_node")):
- return False
+ #if not (hasattr(context, "texture_slot") or hasattr(context, "texture_node")):
+ #return False
return ((context.material or
context.world or
context.lamp or
- context.brush or
context.texture or
context.particle_system or
- isinstance(context.space_data.pin_id, ParticleSettings)) and
+ isinstance(context.space_data.pin_id, ParticleSettings) or
+ context.texture_user) and
(engine in cls.COMPAT_ENGINES))
def draw(self, context):
@@ -146,12 +146,42 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel):
idblock = context_tex_datablock(context)
pin_id = space.pin_id
+ space.use_limited_texture_context = True
+
if space.use_pin_id and not isinstance(pin_id, Texture):
idblock = id_tex_datablock(pin_id)
pin_id = None
if not space.use_pin_id:
layout.prop(space, "texture_context", expand=True)
+ pin_id = None
+
+ if space.texture_context == 'OTHER':
+ if not pin_id:
+ layout.template_texture_user()
+ user = context.texture_user
+ if user or pin_id:
+ layout.separator()
+
+ split = layout.split(percentage=0.65)
+ col = split.column()
+
+ if pin_id:
+ col.template_ID(space, "pin_id")
+ else:
+ propname = context.texture_user_property.identifier
+ col.template_ID(user, propname, new="texture.new")
+
+ if tex:
+ split = layout.split(percentage=0.2)
+ if tex.use_nodes:
+ if slot:
+ split.label(text="Output:")
+ split.prop(slot, "output_node", text="")
+ else:
+ split.label(text="Type:")
+ split.prop(tex, "type", text="")
+ return
tex_collection = (pin_id is None) and (node is None) and (not isinstance(idblock, Brush))
@@ -177,13 +207,10 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel):
if tex:
split = layout.split(percentage=0.2)
-
if tex.use_nodes:
-
if slot:
split.label(text="Output:")
split.prop(slot, "output_node", text="")
-
else:
split.label(text="Type:")
split.prop(tex, "type", text="")
diff --git a/source/blender/editors/include/ED_buttons.h b/source/blender/editors/include/ED_buttons.h
new file mode 100644
index 00000000000..5cc399fdcee
--- /dev/null
+++ b/source/blender/editors/include/ED_buttons.h
@@ -0,0 +1,39 @@
+/*
+ * ***** 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) 2013, Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ED_buttons.h
+ * \ingroup editors
+ */
+
+#ifndef __ED_BUTTONS_H__
+#define __ED_BUTTONS_H__
+
+#include "BLI_utildefines.h"
+
+/* Used to check whether a given texture context is valid in current context. */
+bool ED_texture_context_check_world(const struct bContext *C);
+bool ED_texture_context_check_material(const struct bContext *C);
+bool ED_texture_context_check_lamp(const struct bContext *C);
+bool ED_texture_context_check_particles(const struct bContext *C);
+bool ED_texture_context_check_others(const struct bContext *C);
+
+#endif /* __ED_BUTTONS_H__ */
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 7b93eb2ff70..c0b5214f920 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -397,7 +397,7 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur
else if (GS(id->name) == ID_OB)
buttons_context_path_object(path);
}
-
+
if (ct->texture) {
RNA_id_pointer_create(&ct->texture->id, &path->ptr[path->len]);
path->len++;
@@ -409,31 +409,17 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur
/* old shading system */
Material *ma;
Lamp *la;
- Brush *br;
World *wo;
ParticleSystem *psys;
Tex *tex;
PointerRNA *ptr = &path->ptr[path->len - 1];
- int orig_len = path->len;
/* if we already have a (pinned) texture, we're done */
if (RNA_struct_is_a(ptr->type, &RNA_Texture)) {
return 1;
}
- /* try brush */
- if ((path->tex_ctx == SB_TEXC_BRUSH) && buttons_context_path_brush(path)) {
- br = path->ptr[path->len - 1].data;
-
- if (br) {
- tex = give_current_brush_texture(br);
-
- RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
- path->len++;
- return 1;
- }
- }
/* try world */
- if ((path->tex_ctx == SB_TEXC_WORLD) && buttons_context_path_world(path)) {
+ else if ((path->tex_ctx == SB_TEXC_WORLD) && buttons_context_path_world(path)) {
wo = path->ptr[path->len - 1].data;
if (wo && GS(wo->id.name) == ID_WO) {
@@ -445,7 +431,7 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur
}
}
/* try particles */
- if ((path->tex_ctx == SB_TEXC_PARTICLES) && buttons_context_path_particle(path)) {
+ else if ((path->tex_ctx == SB_TEXC_PARTICLES) && buttons_context_path_particle(path)) {
if (path->ptr[path->len - 1].type == &RNA_ParticleSettings) {
ParticleSettings *part = path->ptr[path->len - 1].data;
@@ -467,7 +453,7 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur
}
}
/* try material */
- if (buttons_context_path_material(path, 1)) {
+ else if ((path->tex_ctx == SB_TEXC_MATERIAL) && buttons_context_path_material(path, 1)) {
ma = path->ptr[path->len - 1].data;
if (ma) {
@@ -479,7 +465,7 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur
}
}
/* try lamp */
- if (buttons_context_path_data(path, OB_LAMP)) {
+ else if ((path->tex_ctx == SB_TEXC_LAMP) && buttons_context_path_data(path, OB_LAMP)) {
la = path->ptr[path->len - 1].data;
if (la) {
@@ -490,19 +476,6 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur
return 1;
}
}
- /* try brushes again in case of no material, lamp, etc */
- path->len = orig_len;
- if (buttons_context_path_brush(path)) {
- br = path->ptr[path->len - 1].data;
-
- if (br) {
- tex = give_current_brush_texture(br);
-
- RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
- path->len++;
- return 1;
- }
- }
}
/* no path to a texture possible */
@@ -813,8 +786,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
if (ct) {
/* new shading system */
- if (ct->user && ct->user->node)
+ if (ct->user && ct->user->node) {
CTX_data_pointer_set(result, &ct->user->ntree->id, &RNA_Node, ct->user->node);
+ }
return 1;
}
@@ -838,11 +812,18 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
ButsContextTexture *ct = sbuts->texuser;
PointerRNA *ptr;
- if ((ptr = get_pointer_type(path, &RNA_Material))) {
- Material *ma = ptr->data;
+ /* Particles slots are used in both old and new textures handling. */
+ if ((ptr = get_pointer_type(path, &RNA_ParticleSystem))) {
+ ParticleSettings *part = ((ParticleSystem *)ptr->data)->part;
- if (ct)
- return 0; /* new shading system */
+ if (part)
+ CTX_data_pointer_set(result, &part->id, &RNA_ParticleSettingsTextureSlot, part->mtex[(int)part->texact]);
+ }
+ else if (ct) {
+ return 0; /* new shading system */
+ }
+ else if ((ptr = get_pointer_type(path, &RNA_Material))) {
+ Material *ma = ptr->data;
/* if we have a node material, get slot from material in material node */
if (ma && ma->use_nodes && ma->nodetree) {
@@ -850,7 +831,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
* 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)
CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]);
@@ -864,33 +845,15 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
else if ((ptr = get_pointer_type(path, &RNA_Lamp))) {
Lamp *la = ptr->data;
- if (ct)
- return 0; /* new shading system */
-
if (la)
CTX_data_pointer_set(result, &la->id, &RNA_LampTextureSlot, la->mtex[(int)la->texact]);
}
else if ((ptr = get_pointer_type(path, &RNA_World))) {
World *wo = ptr->data;
- if (ct)
- return 0; /* new shading system */
-
if (wo)
CTX_data_pointer_set(result, &wo->id, &RNA_WorldTextureSlot, wo->mtex[(int)wo->texact]);
}
- else if ((ptr = get_pointer_type(path, &RNA_Brush))) { /* how to get this into context? */
- Brush *br = ptr->data;
-
- if (br)
- CTX_data_pointer_set(result, &br->id, &RNA_BrushTextureSlot, &br->mtex);
- }
- else if ((ptr = get_pointer_type(path, &RNA_ParticleSystem))) {
- ParticleSettings *part = ((ParticleSystem *)ptr->data)->part;
-
- if (part)
- CTX_data_pointer_set(result, &part->id, &RNA_ParticleSettingsTextureSlot, part->mtex[(int)part->texact]);
- }
return 1;
}
diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c
index 19bfe05e8a4..95f0b723828 100644
--- a/source/blender/editors/space_buttons/buttons_header.c
+++ b/source/blender/editors/space_buttons/buttons_header.c
@@ -38,10 +38,16 @@
#include "BLF_translation.h"
#include "BKE_context.h"
+#include "BKE_modifier.h"
+#include "BKE_paint.h"
+#include "BKE_scene.h"
+#include "ED_buttons.h"
#include "ED_screen.h"
#include "ED_types.h"
+#include "DNA_brush_types.h"
+#include "DNA_object_force.h"
#include "DNA_object_types.h"
#include "UI_interface.h"
@@ -54,25 +60,29 @@
#define B_CONTEXT_SWITCH 101
#define B_BUTSPREVIEW 102
-static void set_texture_context(bContext *C, SpaceButs *sbuts)
+static void set_texture_context(const bContext *C, SpaceButs *sbuts)
{
- switch (sbuts->mainb) {
- case BCONTEXT_MATERIAL:
- sbuts->texture_context = SB_TEXC_MAT_OR_LAMP;
- break;
- case BCONTEXT_DATA:
- {
- Object *ob = CTX_data_active_object(C);
- if (ob && ob->type == OB_LAMP)
- sbuts->texture_context = SB_TEXC_MAT_OR_LAMP;
- break;
- }
- case BCONTEXT_WORLD:
- sbuts->texture_context = SB_TEXC_WORLD;
- break;
- case BCONTEXT_PARTICLE:
- sbuts->texture_context = SB_TEXC_PARTICLES;
- break;
+ Scene *scene = CTX_data_scene(C);
+
+ if (BKE_scene_use_new_shading_nodes(scene)) {
+ return; /* No texture context in new shading mode */
+ }
+
+ if ((sbuts->mainb == BCONTEXT_WORLD) && ED_texture_context_check_world(C)) {
+ sbuts->texture_context = SB_TEXC_WORLD;
+ }
+ else if ((sbuts->mainb == BCONTEXT_MATERIAL) && ED_texture_context_check_material(C)) {
+ sbuts->texture_context = SB_TEXC_MATERIAL;
+ }
+ else if ((sbuts->mainb == BCONTEXT_DATA) && ED_texture_context_check_lamp(C)) {
+ sbuts->texture_context = SB_TEXC_LAMP;
+ }
+ else if ((sbuts->mainb == BCONTEXT_PARTICLE) && ED_texture_context_check_particles(C)) {
+ sbuts->texture_context = SB_TEXC_PARTICLES;
+ }
+ /* Else, just be sure that current context is valid! */
+ else {
+ buttons_check_texture_context(C, sbuts);
}
}
@@ -124,7 +134,8 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
#define BUTTON_HEADER_CTX(_ctx, _icon, _tip) \
if (sbuts->pathflag & (1 << _ctx)) { \
- but = uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, _icon, xco += BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)_ctx, 0, 0, TIP_(_tip)); \
+ but = uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, _icon, xco += BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, \
+ &(sbuts->mainb), 0.0, (float)_ctx, 0, 0, TIP_(_tip)); \
uiButClearFlag(but, UI_BUT_UNDO); \
} (void)0
diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h
index 5700d361e15..55c9bf0dffd 100644
--- a/source/blender/editors/space_buttons/buttons_intern.h
+++ b/source/blender/editors/space_buttons/buttons_intern.h
@@ -111,6 +111,7 @@ extern const char *buttons_context_dir[]; /* doc access */
/* buttons_texture.c */
void buttons_texture_context_compute(const struct bContext *C, struct SpaceButs *sbuts);
+void buttons_check_texture_context(const struct bContext *C, struct SpaceButs *sbuts);
/* buttons_ops.c */
void BUTTONS_OT_file_browse(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c
index 682e6ee2225..34ce81c3af8 100644
--- a/source/blender/editors/space_buttons/buttons_texture.c
+++ b/source/blender/editors/space_buttons/buttons_texture.c
@@ -65,6 +65,7 @@
#include "UI_interface.h"
#include "UI_resources.h"
+#include "ED_buttons.h"
#include "ED_node.h"
#include "ED_screen.h"
@@ -72,6 +73,109 @@
#include "buttons_intern.h" // own include
+/****************** "Old Shading" Texture Context ****************/
+
+bool ED_texture_context_check_world(const bContext *C)
+{
+ Scene *scene = CTX_data_scene(C);
+ return (scene && scene->world);
+}
+
+bool ED_texture_context_check_material(const bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+ return (ob && (ob->totcol != 0));
+}
+
+bool ED_texture_context_check_lamp(const bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+ return (ob && (ob->type == OB_LAMP));
+}
+
+bool ED_texture_context_check_particles(const bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+ return (ob && ob->particlesystem.first);
+}
+
+static void texture_context_check_modifier_foreach(void *userData, Object *UNUSED(ob), ModifierData *UNUSED(md),
+ const char *UNUSED(propname))
+{
+ *((bool *)userData) = true;
+}
+
+bool ED_texture_context_check_others(const bContext *C)
+{
+ /* We cannot rely on sbuts->texuser here, as it is NULL when in "old" tex handling, non-OTHERS tex context. */
+ Object *ob = CTX_data_active_object(C);
+
+ /* object */
+ if (ob) {
+ /* Tex force field. */
+ if (ob->pd && ob->pd->forcefield == PFIELD_TEXTURE) {
+ return true;
+ }
+
+ /* modifiers */
+ {
+ bool check = false;
+ modifiers_foreachTexLink(ob, texture_context_check_modifier_foreach, &check);
+ if (check) {
+ return true;
+ }
+ }
+ }
+
+ /* brush */
+ if (BKE_paint_brush(BKE_paint_get_active_from_context(C))) {
+ return true;
+ }
+
+ return false;
+}
+
+/* Only change texture context if current one is invalid! */
+void buttons_check_texture_context(const bContext *C, SpaceButs *sbuts)
+{
+ Scene *scene = CTX_data_scene(C);
+
+ if (BKE_scene_use_new_shading_nodes(scene)) {
+ return; /* No texture context in new shading mode */
+ }
+
+ {
+ bool valid_world = ED_texture_context_check_world(C);
+ bool valid_material = ED_texture_context_check_material(C);
+ bool valid_lamp = ED_texture_context_check_lamp(C);
+ bool valid_particles = ED_texture_context_check_particles(C);
+ bool valid_others = ED_texture_context_check_others(C);
+
+ if (((sbuts->texture_context == SB_TEXC_WORLD) && !valid_world) ||
+ ((sbuts->texture_context == SB_TEXC_MATERIAL) && !valid_material) ||
+ ((sbuts->texture_context == SB_TEXC_LAMP) && !valid_lamp) ||
+ ((sbuts->texture_context == SB_TEXC_PARTICLES) && !valid_particles) ||
+ ((sbuts->texture_context == SB_TEXC_OTHER) && !valid_others))
+ {
+ if (valid_others) {
+ sbuts->texture_context = SB_TEXC_OTHER;
+ }
+ else if (valid_world) {
+ sbuts->texture_context = SB_TEXC_WORLD;
+ }
+ else if (valid_material) {
+ sbuts->texture_context = SB_TEXC_MATERIAL;
+ }
+ else if (valid_lamp) {
+ sbuts->texture_context = SB_TEXC_LAMP;
+ }
+ else if (valid_particles) {
+ sbuts->texture_context = SB_TEXC_PARTICLES;
+ }
+ }
+ }
+}
+
/************************* Texture User **************************/
static void buttons_texture_user_property_add(ListBase *users, ID *id,
@@ -154,6 +258,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
World *wrld = NULL;
Brush *brush = NULL;
ID *pinid = sbuts->pinid;
+ bool limited_mode = sbuts->flag & SB_TEX_USER_LIMITED;
/* get data from context */
if (pinid) {
@@ -173,7 +278,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
if (!scene)
scene = CTX_data_scene(C);
-
+
if (!(pinid || pinid == &scene->id)) {
ob = (scene->basact) ? scene->basact->object : NULL;
wrld = scene->world;
@@ -188,11 +293,11 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
/* fill users */
users->first = users->last = NULL;
- if (ma)
+ if (ma && !limited_mode)
buttons_texture_users_find_nodetree(users, &ma->id, ma->nodetree, "Material");
- if (la)
+ if (la && !limited_mode)
buttons_texture_users_find_nodetree(users, &la->id, la->nodetree, "Lamp");
- if (wrld)
+ if (wrld && !limited_mode)
buttons_texture_users_find_nodetree(users, &wrld->id, wrld->nodetree, "World");
if (ob) {
@@ -204,7 +309,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
modifiers_foreachTexLink(ob, buttons_texture_modifier_foreach, users);
/* particle systems */
- if (psys) {
+ if (psys && !limited_mode) {
for (a = 0; a < MAX_MTEX; a++) {
mtex = psys->part->mtex[a];
@@ -261,14 +366,17 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts)
* properties editor, before the buttons are created. */
ButsContextTexture *ct = sbuts->texuser;
Scene *scene = CTX_data_scene(C);
+ ID *pinid = sbuts->pinid;
+
+ buttons_check_texture_context(C, sbuts);
- if (!BKE_scene_use_new_shading_nodes(scene)) {
+ if (!(BKE_scene_use_new_shading_nodes(scene) || (sbuts->texture_context == SB_TEXC_OTHER))) {
if (ct) {
BLI_freelistN(&ct->users);
MEM_freeN(ct);
sbuts->texuser = NULL;
}
-
+
return;
}
@@ -282,35 +390,41 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts)
buttons_texture_users_from_context(&ct->users, C, sbuts);
- /* set one user as active based on active index */
- if (ct->index >= BLI_countlist(&ct->users))
- ct->index = 0;
+ if (pinid && GS(pinid->name) == ID_TE) {
+ ct->user = NULL;
+ ct->texture = (Tex *)pinid;
+ }
+ else {
+ /* set one user as active based on active index */
+ if (ct->index >= BLI_countlist(&ct->users))
+ ct->index = 0;
- ct->user = BLI_findlink(&ct->users, ct->index);
- ct->texture = NULL;
+ ct->user = BLI_findlink(&ct->users, ct->index);
+ ct->texture = NULL;
- if (ct->user) {
- if (ct->user->ptr.data) {
- PointerRNA texptr;
- Tex *tex;
+ if (ct->user) {
+ if (ct->user->ptr.data) {
+ PointerRNA texptr;
+ Tex *tex;
- /* get texture datablock pointer if it's a property */
- texptr = RNA_property_pointer_get(&ct->user->ptr, ct->user->prop);
- tex = (RNA_struct_is_a(texptr.type, &RNA_Texture)) ? texptr.data : NULL;
+ /* get texture datablock pointer if it's a property */
+ texptr = RNA_property_pointer_get(&ct->user->ptr, ct->user->prop);
+ tex = (RNA_struct_is_a(texptr.type, &RNA_Texture)) ? texptr.data : NULL;
- ct->texture = tex;
- }
- else if (ct->user->node && !(ct->user->node->flag & NODE_ACTIVE_TEXTURE)) {
- ButsTextureUser *user;
-
- /* detect change of active texture node in same node tree, in that
- * case we also automatically switch to the other node */
- for (user = ct->users.first; user; user = user->next) {
- if (user->ntree == ct->user->ntree && user->node != ct->user->node) {
- if (user->node->flag & NODE_ACTIVE_TEXTURE) {
- ct->user = user;
- ct->index = BLI_findindex(&ct->users, user);
- break;
+ ct->texture = tex;
+ }
+ else if (ct->user->node && !(ct->user->node->flag & NODE_ACTIVE_TEXTURE)) {
+ ButsTextureUser *user;
+
+ /* detect change of active texture node in same node tree, in that
+ * case we also automatically switch to the other node */
+ for (user = ct->users.first; user; user = user->next) {
+ if (user->ntree == ct->user->ntree && user->node != ct->user->node) {
+ if (user->node->flag & NODE_ACTIVE_TEXTURE) {
+ ct->user = user;
+ ct->index = BLI_findindex(&ct->users, user);
+ break;
+ }
}
}
}
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 91987294572..6d7926b1e84 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -190,18 +190,22 @@ typedef enum eSpaceButtons_Context {
} eSpaceButtons_Context;
/* sbuts->flag */
-#define SB_PRV_OSA 1
-#define SB_PIN_CONTEXT 2
-//#define SB_WORLD_TEX 4 //not used anymore
-//#define SB_BRUSH_TEX 8 //not used anymore
-#define SB_SHADING_CONTEXT 16
+typedef enum eSpaceButtons_Flag {
+ SB_PRV_OSA = (1 << 0),
+ SB_PIN_CONTEXT = (1 << 1),
+ /* SB_WORLD_TEX = (1 << 2), */ /* not used anymore */
+ /* SB_BRUSH_TEX = (1 << 3), */ /* not used anymore */
+ SB_TEX_USER_LIMITED = (1 << 3), /* Do not add materials, particles, etc. in TemplateTextureUser list. */
+ SB_SHADING_CONTEXT = (1 << 4),
+} eSpaceButtons_Flag;
/* sbuts->texture_context */
typedef enum eSpaceButtons_Texture_Context {
- SB_TEXC_MAT_OR_LAMP = 0,
+ SB_TEXC_MATERIAL = 0,
SB_TEXC_WORLD = 1,
- SB_TEXC_BRUSH = 2,
+ SB_TEXC_LAMP = 2,
SB_TEXC_PARTICLES = 3,
+ SB_TEXC_OTHER = 4,
} eSpaceButtons_Texture_Context;
/* sbuts->align */
@@ -212,7 +216,7 @@ typedef enum eSpaceButtons_Align {
BUT_AUTO = 3,
} eSpaceButtons_Align;
-/* sbuts->scaflag */
+/* sbuts->scaflag */
#define BUTS_SENS_SEL 1
#define BUTS_SENS_ACT 2
#define BUTS_SENS_LINK 4
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 17543fa2ed1..ffaa2f379dc 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -120,6 +120,7 @@ EnumPropertyItem viewport_shade_items[] = {
{0, NULL, 0, NULL, NULL}
};
+
EnumPropertyItem clip_editor_mode_items[] = {
{SC_MODE_TRACKING, "TRACKING", ICON_ANIM_DATA, "Tracking", "Show tracking and solving tools"},
{SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", ICON_SNAP_FACE, "Reconstruction",
@@ -129,6 +130,16 @@ EnumPropertyItem clip_editor_mode_items[] = {
{0, NULL, 0, NULL, NULL}
};
+/* Actually populated dynamically trough a function, but helps for context-less access (e.g. doc, i18n...). */
+static EnumPropertyItem buttons_texture_context_items[] = {
+ {SB_TEXC_MATERIAL, "MATERIAL", ICON_MATERIAL, "", "Show material textures"},
+ {SB_TEXC_WORLD, "WORLD", ICON_WORLD, "", "Show world textures"},
+ {SB_TEXC_LAMP, "LAMP", ICON_LAMP, "", "Show lamp textures"},
+ {SB_TEXC_PARTICLES, "PARTICLES", ICON_PARTICLES, "", "Show particles textures"},
+ {SB_TEXC_OTHER, "OTHER", ICON_TEXTURE, "", "Show other data textures"},
+ {0, NULL, 0, NULL, NULL}
+};
+
#ifdef RNA_RUNTIME
#include "DNA_anim_types.h"
@@ -148,6 +159,7 @@ EnumPropertyItem clip_editor_mode_items[] = {
#include "BKE_screen.h"
#include "BKE_icons.h"
+#include "ED_buttons.h"
#include "ED_image.h"
#include "ED_node.h"
#include "ED_screen.h"
@@ -1113,51 +1125,28 @@ void rna_SpaceNodeEditor_path_pop(SpaceNode *snode, bContext *C)
static EnumPropertyItem *rna_SpaceProperties_texture_context_itemf(bContext *C, PointerRNA *UNUSED(ptr),
PropertyRNA *UNUSED(prop), int *free)
{
- Scene *scene = CTX_data_scene(C);
- Object *ob = CTX_data_active_object(C);
EnumPropertyItem *item = NULL;
- EnumPropertyItem tmp = {0, "", 0, "", ""};
int totitem = 0;
- if (ob) {
- if (ob->type == OB_LAMP) {
- tmp.value = SB_TEXC_MAT_OR_LAMP;
- tmp.description = "Show Lamp Textures";
- tmp.identifier = "LAMP";
- tmp.icon = ICON_LAMP_POINT;
- RNA_enum_item_add(&item, &totitem, &tmp);
- }
- else if (ob->totcol) {
- tmp.value = SB_TEXC_MAT_OR_LAMP;
- tmp.description = "Show Material Textures";
- tmp.identifier = "MATERIAL";
- tmp.icon = ICON_MATERIAL;
- RNA_enum_item_add(&item, &totitem, &tmp);
- }
+ if (ED_texture_context_check_world(C)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_WORLD);
+ }
- if (ob->particlesystem.first) {
- tmp.value = SB_TEXC_PARTICLES;
- tmp.description = "Show Particle Textures";
- tmp.identifier = "PARTICLE";
- tmp.icon = ICON_PARTICLES;
- RNA_enum_item_add(&item, &totitem, &tmp);
- }
+ if (ED_texture_context_check_lamp(C)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_LAMP);
+ }
+ else if (ED_texture_context_check_material(C)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_MATERIAL);
}
- if (scene && scene->world) {
- tmp.value = SB_TEXC_WORLD;
- tmp.description = "Show World Textures";
- tmp.identifier = "WORLD";
- tmp.icon = ICON_WORLD;
- RNA_enum_item_add(&item, &totitem, &tmp);
+ if (ED_texture_context_check_particles(C)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_PARTICLES);
+ }
+
+ if (ED_texture_context_check_others(C)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_texture_context_items, SB_TEXC_OTHER);
}
- tmp.value = SB_TEXC_BRUSH;
- tmp.description = "Show Brush Textures";
- tmp.identifier = "BRUSH";
- tmp.icon = ICON_BRUSH_DATA;
- RNA_enum_item_add(&item, &totitem, &tmp);
-
RNA_enum_item_end(&item, &totitem);
*free = 1;
@@ -2096,11 +2085,6 @@ static void rna_def_space_buttons(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
- static EnumPropertyItem buttons_texture_context_items[] = {
- {SB_TEXC_MAT_OR_LAMP, "MATERIAL", ICON_MATERIAL, "Material", "Material"},
- {0, NULL, 0, NULL, NULL}
- }; /*actually populated dynamically trough a function */
-
srna = RNA_def_struct(brna, "SpaceProperties", "Space");
RNA_def_struct_sdna(srna, "SpaceButs");
RNA_def_struct_ui_text(srna, "Properties Space", "Properties space data");
@@ -2125,6 +2109,11 @@ static void rna_def_space_buttons(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Texture Context", "Type of texture data to display and edit");
RNA_def_property_update(prop, NC_TEXTURE, NULL);
+ prop = RNA_def_property(srna, "use_limited_texture_context", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SB_TEX_USER_LIMITED);
+ RNA_def_property_ui_text(prop, "Limited Texture Context",
+ "Use the limited version of texture user (for 'old shading' mode)");
+
/* pinned data */
prop = RNA_def_property(srna, "pin_id", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "pinid");
diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c
index d6dde26a272..d0445236740 100644
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ b/source/blenderplayer/bad_level_call_stubs/stubs.c
@@ -391,6 +391,12 @@ float ED_rollBoneToVector(struct EditBone *bone, float new_up_axis[3]) {STUB_ASS
void ED_space_image_get_size(struct SpaceImage *sima, int *width, int *height) {STUB_ASSERT(0);}
int ED_space_image_check_show_maskedit(struct Scene *scene, struct SpaceImage *sima) {STUB_ASSERT(0); return 0;}
+bool ED_texture_context_check_world(struct bContext *C) {STUB_ASSERT(0); return false;}
+bool ED_texture_context_check_material(struct bContext *C) {STUB_ASSERT(0); return false;}
+bool ED_texture_context_check_lamp(struct bContext *C) {STUB_ASSERT(0); return false;}
+bool ED_texture_context_check_particles(struct bContext *C) {STUB_ASSERT(0); return false;}
+bool ED_texture_context_check_others(struct bContext *C) {STUB_ASSERT(0); return false;}
+
void ED_nurb_set_spline_type(struct Nurb *nu, int type) {STUB_ASSERT(0);}
void ED_mball_transform(struct MetaBall *mb, float *mat) {STUB_ASSERT(0);}