Revision: 34720
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34720
Author:   jhk
Date:     2011-02-08 14:29:48 +0000 (Tue, 08 Feb 2011)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/properties_texture.py
    trunk/blender/source/blender/editors/space_buttons/buttons_context.c
    trunk/blender/source/blender/editors/space_buttons/buttons_header.c
    trunk/blender/source/blender/makesdna/DNA_space_types.h
    trunk/blender/source/blender/makesrna/intern/rna_space.c

Modified: trunk/blender/release/scripts/ui/properties_texture.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_texture.py      2011-02-08 
13:48:06 UTC (rev 34719)
+++ trunk/blender/release/scripts/ui/properties_texture.py      2011-02-08 
14:29:48 UTC (rev 34720)
@@ -99,6 +99,9 @@
         if not isinstance(pin_id, bpy.types.Material):
             pin_id = None
 
+        if not space.use_pin_id:
+            layout.prop(space, "texture_context", expand=True)
+
         tex_collection = (pin_id is None) and (node is None) and (not 
isinstance(idblock, bpy.types.Brush))
 
         if tex_collection:
@@ -126,9 +129,6 @@
 
         col = split.column()
 
-        if not space.pin_id:
-            col.prop(space, "show_brush_texture", text="Brush", toggle=True)
-
         if tex:
             split = layout.split(percentage=0.2)
 

Modified: trunk/blender/source/blender/editors/space_buttons/buttons_context.c
===================================================================
--- trunk/blender/source/blender/editors/space_buttons/buttons_context.c        
2011-02-08 13:48:06 UTC (rev 34719)
+++ trunk/blender/source/blender/editors/space_buttons/buttons_context.c        
2011-02-08 14:29:48 UTC (rev 34720)
@@ -66,6 +66,7 @@
        PointerRNA ptr[8];
        int len;
        int flag;
+       int tex_ctx;
 } ButsContextPath;
 
 static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, 
StructRNA *type)
@@ -368,7 +369,7 @@
                return 1;
        }
        /* try brush */
-       if((path->flag & SB_BRUSH_TEX) && buttons_context_path_brush(path)) {
+       if((path->tex_ctx == SB_TEXC_BRUSH) && 
buttons_context_path_brush(path)) {
                br= path->ptr[path->len-1].data;
                
                if(br) {
@@ -380,7 +381,7 @@
                }
        }
        /* try world */
-       if((path->flag & SB_WORLD_TEX) && buttons_context_path_world(path)) {
+       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) {
@@ -442,6 +443,7 @@
 
        memset(path, 0, sizeof(*path));
        path->flag= flag;
+       path->tex_ctx = sbuts->texture_context;
 
        /* if some ID datablock is pinned, set the root pointer */
        if(sbuts->pinid) {
@@ -534,13 +536,12 @@
 {
        ButsContextPath *path;
        PointerRNA *ptr;
-       int a, pflag, flag= 0;
+       int a, pflag= 0, flag= 0;
 
        if(!sbuts->path)
                sbuts->path= MEM_callocN(sizeof(ButsContextPath), 
"ButsContextPath");
        
        path= sbuts->path;
-       pflag= (sbuts->flag & (SB_WORLD_TEX|SB_BRUSH_TEX));
        
        /* for each context, see if we can compute a valid path to it, if
         * this is the case, we know we have to display the button */

Modified: trunk/blender/source/blender/editors/space_buttons/buttons_header.c
===================================================================
--- trunk/blender/source/blender/editors/space_buttons/buttons_header.c 
2011-02-08 13:48:06 UTC (rev 34719)
+++ trunk/blender/source/blender/editors/space_buttons/buttons_header.c 
2011-02-08 14:29:48 UTC (rev 34720)
@@ -62,12 +62,6 @@
                case B_BUTSPREVIEW:
                        ED_area_tag_redraw(CTX_wm_area(C));
 
-                       /* silly exception */
-                       if(sbuts->mainb == BCONTEXT_WORLD)
-                               sbuts->flag |= SB_WORLD_TEX;
-                       else if(sbuts->mainb != BCONTEXT_TEXTURE)
-                               sbuts->flag &= ~SB_WORLD_TEX;
-
                        sbuts->preview= 1;
                        break;
        }

Modified: trunk/blender/source/blender/makesdna/DNA_space_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_space_types.h     2011-02-08 
13:48:06 UTC (rev 34719)
+++ trunk/blender/source/blender/makesdna/DNA_space_types.h     2011-02-08 
14:29:48 UTC (rev 34720)
@@ -135,7 +135,8 @@
        short mainb, mainbo, mainbuser; /* context tabs */
        short re_align, align;                  /* align for panels */
        short preview;                                  /* preview is signal to 
refresh */
-       char flag, pad[3];
+       short texture_context;                  /* texture context selector 
(material, world, brush)*/
+       char flag, pad;
        
        void *path;                                             /* runtime */
        int pathflag, dataicon;                 /* runtime */
@@ -627,10 +628,15 @@
 /* sbuts->flag */
 #define SB_PRV_OSA                     1
 #define SB_PIN_CONTEXT         2
-#define SB_WORLD_TEX           4
-#define SB_BRUSH_TEX           8
+//#define SB_WORLD_TEX         4       //not used anymore
+//#define SB_BRUSH_TEX         8       //not used anymore      
 #define SB_SHADING_CONTEXT     16
 
+/* sbuts->texture_context */
+#define SB_TEXC_MAT_OR_LAMP    0
+#define SB_TEXC_WORLD          1
+#define SB_TEXC_BRUSH          2
+
 /* sbuts->align */
 #define BUT_FREE               0
 #define BUT_HORIZONTAL  1

Modified: trunk/blender/source/blender/makesrna/intern/rna_space.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_space.c    2011-02-08 
13:48:06 UTC (rev 34719)
+++ trunk/blender/source/blender/makesrna/intern/rna_space.c    2011-02-08 
14:29:48 UTC (rev 34720)
@@ -742,6 +742,51 @@
        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 @@
                {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 @@
        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 */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to