From 811a1b910ca8f699ce499645ab99552fc2c83937 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 8 Feb 2011 14:29:48 +0000 Subject: Texture context selector for texture panel: * Texture context was previously determined by going to the appropriate panel, for example "world panel -> texture panel" to access world textures. Additionally there was a separate button to access brush textures. * Now the texture context can be selected directly through an expanded icon menu, which shows the available context options. * This context selector is now at the top of the texture panel, but this could later be perhaps integrated to the context path somehow to be more intuitive. --- source/blender/makesrna/intern/rna_space.c | 56 ++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 3 deletions(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index afb0b82b8a5..0a1ae8fdc5f 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -742,6 +742,51 @@ static void rna_BackgroundImage_opacity_set(PointerRNA *ptr, float value) bgpic->blend = 1.0f - value; } +static EnumPropertyItem *rna_SpaceProperties_texture_context_itemf(bContext *C, PointerRNA *ptr, 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(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); + } + + 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; + + return item; +} + #else static void rna_def_space(BlenderRNA *brna) @@ -1323,6 +1368,10 @@ static void rna_def_space_buttons(BlenderRNA *brna) {BUT_HORIZONTAL, "HORIZONTAL", 0, "Horizontal", ""}, {BUT_VERTICAL, "VERTICAL", 0, "Vertical", ""}, {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"); @@ -1342,9 +1391,10 @@ static void rna_def_space_buttons(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Align", "Arrangement of the panels"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_PROPERTIES, NULL); - prop= RNA_def_property(srna, "show_brush_texture", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SB_BRUSH_TEX); - RNA_def_property_ui_text(prop, "Brush Texture", "Show brush textures"); + prop= RNA_def_property(srna, "texture_context", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, buttons_texture_context_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_SpaceProperties_texture_context_itemf"); + RNA_def_property_ui_text(prop, "Texture Context", "Type of texture data to display and edit"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_PROPERTIES, NULL); /* pinned data */ -- cgit v1.2.3