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:
authorBastien Montagne <montagne29@wanadoo.fr>2013-05-17 11:10:10 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2013-05-17 11:10:10 +0400
commit9d567dd3662e5d79c98c64829f3d039e75697395 (patch)
treeaf8b0cd080b62b72f24729df0e15d3f38d61f64a /source/blender/makesrna/intern/rna_space.c
parent308d014b498be3aaf3fd74aeee0ed52947d0b6cc (diff)
This commit addresses the somewhat weak handling of stackless textures in Blender with default (BI) renderer. To do so, it's defining an "other" texture context, and when in this one, it switches to using the "new shading" texture handling already known with Cycles engine.
So now, in the new "other" tex context, you can (depending on active data) have direct access to modifiers', force's or brushes' textures... I also refactored a bit how texture contexts are handled (once again, we had some quite similar code in both space_buttons and RNA sources). This should also solve some harmless glitches like "no texture context selected in UI" sometimes when you remove data related to current texture (see e.g. after removing the material from default cube, in startup scene). This usage of two different systems for textures, and the handling of switches between them, has been a bit tricky to get working right, but it is OK now I think. I also had to add a bool flag to buttons space, SB_TEX_USER_LIMITED (use_limited_texture_context in RNA), which indicates "new shading" texture code whether it has to ignore materials, lamps etc. (BI) or not (Cycles). Btw, pinned textures from modifiers/force/etc. were also broken (showing nothing), now it should work too. Thanks to Brecht for reviewing.
Diffstat (limited to 'source/blender/makesrna/intern/rna_space.c')
-rw-r--r--source/blender/makesrna/intern/rna_space.c73
1 files changed, 31 insertions, 42 deletions
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");