Fix #27550: texture node editor header was still showing texture datablock
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 1 Jun 2011 16:17:38 +0000 (16:17 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 1 Jun 2011 16:17:38 +0000 (16:17 +0000)
selector even if there is no active texture slot or node, now it's disabled
in that case.

source/blender/blenkernel/BKE_texture.h
source/blender/blenkernel/intern/texture.c
source/blender/editors/space_node/space_node.c
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_lamp.c
source/blender/makesrna/intern/rna_material.c
source/blender/makesrna/intern/rna_particle.c
source/blender/makesrna/intern/rna_world.c

index c8fa7a5e81f7e1fc66cb127c20f9494e5b7ed016..9fb93f60fd54ad542e40d0d39eb0c83ac8834e6c 100644 (file)
@@ -103,6 +103,8 @@ void set_current_material_texture(struct Material *ma, struct Tex *tex);
 void set_current_lamp_texture(struct Lamp *la, struct Tex *tex);
 void set_current_particle_texture(struct ParticleSettings *part, struct Tex *tex);
 
+int has_current_material_texture(struct Material *ma);
+
 struct TexMapping *add_mapping(void);
 void init_mapping(struct TexMapping *texmap);
 
index 9cd07de31dc27798bb65f0d7959b80982182b7d2..64f3c1114343cf0d08a1d55b4b248a69f3e8c7d8 100644 (file)
@@ -1191,6 +1191,28 @@ void set_current_material_texture(Material *ma, Tex *newtex)
        }
 }
 
+int has_current_material_texture(Material *ma)
+{
+       bNode *node;
+
+       if(ma && ma->use_nodes && ma->nodetree) {
+               node= nodeGetActiveID(ma->nodetree, ID_TE);
+
+               if(node) {
+                       return 1;
+               }
+               else {
+                       node= nodeGetActiveID(ma->nodetree, ID_MA);
+                       if(node)
+                               ma= (Material*)node->id;
+                       else
+                               ma= NULL;
+               }
+       }
+
+       return (ma != NULL);
+}
+
 Tex *give_current_world_texture(World *world)
 {
        MTex *mtex= NULL;
index 96ce19b76018242f0c06adb4fb2cda2c57f62679..29316c5645ac1558ab2e64c99feece58b3daaf2f 100644 (file)
@@ -222,6 +222,8 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
                case NC_NODE:
                        if (wmn->action == NA_EDITED)
                                ED_area_tag_refresh(sa);
+                       else if (wmn->action == NA_SELECTED)
+                               ED_area_tag_redraw(sa);
                        break;
 
                case NC_IMAGE:
index a9fb545ec3fc8223a7132e694b36b6fc6b4a0a5b..9175806e2bb9f44ebb4e43d83aa6b4e01778636f 100644 (file)
@@ -187,7 +187,7 @@ void rna_def_animviz_common(struct StructRNA *srna);
 void rna_def_motionpath_common(struct StructRNA *srna);
 
 void rna_def_texmat_common(struct StructRNA *srna, const char *texspace_editable);
-void rna_def_mtex_common(struct BlenderRNA *brna, struct StructRNA *srna, const char *begin, const char *activeget, const char *activeset, const char *structname, const char *structname_slots, const char *update);
+void rna_def_mtex_common(struct BlenderRNA *brna, struct StructRNA *srna, const char *begin, const char *activeget, const char *activeset, const char *activeeditable, const char *structname, const char *structname_slots, const char *update);
 void rna_def_render_layer_common(struct StructRNA *srna, int scene);
 
 void rna_ID_name_get(struct PointerRNA *ptr, char *value);
index d16e06812af75e10f5bae22a9e5c8cacc5727a5d..f18308591dbf0b942caeababd4d470a91e1e3b6b 100644 (file)
@@ -374,7 +374,7 @@ static void rna_def_lamp(BlenderRNA *brna)
        
        /* textures */
        rna_def_mtex_common(brna, srna, "rna_Lamp_mtex_begin", "rna_Lamp_active_texture_get",
-               "rna_Lamp_active_texture_set", "LampTextureSlot", "LampTextureSlots", "rna_Lamp_update");
+               "rna_Lamp_active_texture_set", NULL, "LampTextureSlot", "LampTextureSlots", "rna_Lamp_update");
 }
 
 static void rna_def_lamp_falloff(StructRNA *srna)
index 8c3be7290f4cdb529e0e158b7dad33c51632e881..b86a91967a6715752a4b57bb24f0cfdeb998939b 100644 (file)
@@ -170,6 +170,13 @@ static void rna_Material_active_texture_set(PointerRNA *ptr, PointerRNA value)
        set_current_material_texture(ma, value.data);
 }
 
+static int rna_Material_active_texture_editable(PointerRNA *ptr)
+{
+       Material *ma= (Material*)ptr->id.data;
+
+       return has_current_material_texture(ma);
+}
+
 static PointerRNA rna_Material_active_node_material_get(PointerRNA *ptr)
 {
        Material *ma= give_node_material((Material*)ptr->data);
@@ -1841,7 +1848,8 @@ void RNA_def_material(BlenderRNA *brna)
        /* common */
        rna_def_animdata_common(srna);
        rna_def_mtex_common(brna, srna, "rna_Material_mtex_begin", "rna_Material_active_texture_get",
-               "rna_Material_active_texture_set", "MaterialTextureSlot", "MaterialTextureSlots", "rna_Material_update");
+               "rna_Material_active_texture_set", "rna_Material_active_texture_editable",
+               "MaterialTextureSlot", "MaterialTextureSlots", "rna_Material_update");
 
        /* only material has this one */
        prop= RNA_def_property(srna, "use_textures", PROP_BOOLEAN, PROP_NONE);
@@ -1899,7 +1907,9 @@ static void rna_def_texture_slots(BlenderRNA *brna, PropertyRNA *cprop, const ch
        RNA_def_property_flag(parm, PROP_REQUIRED);
 }
 
-void rna_def_mtex_common(BlenderRNA *brna, StructRNA *srna, const char *begin, const char *activeget, const char *activeset, const char *structname, const char *structname_slots, const char *update)
+void rna_def_mtex_common(BlenderRNA *brna, StructRNA *srna, const char *begin,
+       const char *activeget, const char *activeset, const char *activeeditable,
+       const char *structname, const char *structname_slots, const char *update)
 {
        PropertyRNA *prop;
 
@@ -1913,6 +1923,8 @@ void rna_def_mtex_common(BlenderRNA *brna, StructRNA *srna, const char *begin, c
        prop= RNA_def_property(srna, "active_texture", PROP_POINTER, PROP_NONE);
        RNA_def_property_struct_type(prop, "Texture");
        RNA_def_property_flag(prop, PROP_EDITABLE);
+       if(activeeditable)
+               RNA_def_property_editable_func(prop, activeeditable);
        RNA_def_property_pointer_funcs(prop, activeget, activeset, NULL, NULL);
        RNA_def_property_ui_text(prop, "Active Texture", "Active texture slot being displayed");
        RNA_def_property_update(prop, 0, update);
index 5615e7141ee26c96ee5facf0ef71c6f14231f094..4913e98a0af04d143800cc255392d98ec3769077 100644 (file)
@@ -1560,7 +1560,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
        RNA_def_struct_ui_icon(srna, ICON_PARTICLE_DATA);
 
        rna_def_mtex_common(brna, srna, "rna_ParticleSettings_mtex_begin", "rna_ParticleSettings_active_texture_get",
-               "rna_ParticleSettings_active_texture_set", "ParticleSettingsTextureSlot", "ParticleSettingsTextureSlots", "rna_Particle_reset");
+               "rna_ParticleSettings_active_texture_set", NULL, "ParticleSettingsTextureSlot", "ParticleSettingsTextureSlots", "rna_Particle_reset");
 
        /* fluid particle type can't be checked from the type value in rna as it's not shown in the menu */
        prop= RNA_def_property(srna, "is_fluid", PROP_BOOLEAN, PROP_NONE);
index b8f8f5f5deda43ab8d6e6945af4bb375179eba39..72b54dce47392ddb2adb4f6437642bfd2af963d5 100644 (file)
@@ -494,7 +494,7 @@ void RNA_def_world(BlenderRNA *brna)
 
        rna_def_animdata_common(srna);
        rna_def_mtex_common(brna, srna, "rna_World_mtex_begin", "rna_World_active_texture_get",
-               "rna_World_active_texture_set", "WorldTextureSlot", "WorldTextureSlots", "rna_World_update");
+               "rna_World_active_texture_set", NULL, "WorldTextureSlot", "WorldTextureSlots", "rna_World_update");
 
        /* colors */
        prop= RNA_def_property(srna, "horizon_color", PROP_FLOAT, PROP_COLOR);