Revision: 23787
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23787
Author:   campbellbarton
Date:     2009-10-12 18:00:39 +0200 (Mon, 12 Oct 2009)

Log Message:
-----------
texture slots up/down back

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/buttons_texture.py
    trunk/blender/source/blender/blenkernel/BKE_texture.h
    trunk/blender/source/blender/blenkernel/intern/texture.c
    trunk/blender/source/blender/editors/render/render_intern.h
    trunk/blender/source/blender/editors/render/render_ops.c
    trunk/blender/source/blender/editors/render/render_shading.c

Modified: trunk/blender/release/scripts/ui/buttons_texture.py
===================================================================
--- trunk/blender/release/scripts/ui/buttons_texture.py 2009-10-12 14:38:35 UTC 
(rev 23786)
+++ trunk/blender/release/scripts/ui/buttons_texture.py 2009-10-12 16:00:39 UTC 
(rev 23787)
@@ -75,6 +75,10 @@
                        split.template_ID(idblock, "active_texture", 
new="texture.new")
                elif tex:
                        split.template_ID(space, "pin_id")
+               
+               row = split.row(align=True)
+               row.item_enumO("texture.slot_move", "type", 'UP', text="", 
icon='ICON_TRIA_UP')
+               row.item_enumO("texture.slot_move", "type", 'DOWN', text="", 
icon='ICON_TRIA_DOWN')
 
                if (not space.pin_id) and (
                        context.sculpt_object or

Modified: trunk/blender/source/blender/blenkernel/BKE_texture.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_texture.h       2009-10-12 
14:38:35 UTC (rev 23786)
+++ trunk/blender/source/blender/blenkernel/BKE_texture.h       2009-10-12 
16:00:39 UTC (rev 23787)
@@ -75,6 +75,9 @@
 struct Tex *give_current_world_texture(struct World *world);
 struct Tex *give_current_brush_texture(struct Brush *br);
 
+int                     give_active_mtex(struct ID *id, struct MTex 
***mtex_ar, short *act);
+void            set_active_mtex(struct ID *id, short act);
+
 void set_current_brush_texture(struct Brush *br, struct Tex *tex);
 void set_current_world_texture(struct World *wo, struct Tex *tex);
 void set_current_material_texture(struct Material *ma, struct Tex *tex);

Modified: trunk/blender/source/blender/blenkernel/intern/texture.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/texture.c    2009-10-12 
14:38:35 UTC (rev 23786)
+++ trunk/blender/source/blender/blenkernel/intern/texture.c    2009-10-12 
16:00:39 UTC (rev 23787)
@@ -889,6 +889,55 @@
        return tex;
 }
 
+int give_active_mtex(ID *id, MTex ***mtex_ar, short *act)
+{
+       switch(GS(id->name)) {
+       case ID_MA:
+               *mtex_ar=               ((Material *)id)->mtex;
+               if(act) *act=   (((Material *)id)->texact);
+               break;
+       case ID_WO:
+               *mtex_ar=               ((World *)id)->mtex;
+               if(act) *act=   (((World *)id)->texact);
+               break;
+       case ID_LA:
+               *mtex_ar=               ((Lamp *)id)->mtex;
+               if(act) *act=   (((Lamp *)id)->texact);
+               break;
+       case ID_BR:
+               *mtex_ar=               ((Brush *)id)->mtex;
+               if(act) *act=   (((Brush *)id)->texact);
+               break;
+       default:
+               *mtex_ar = NULL;
+               if(act) *act=   0;
+               return FALSE;
+       }
+
+       return TRUE;
+}
+
+void set_active_mtex(ID *id, short act)
+{
+       if(act<0)                               act= 0;
+       else if(act>=MAX_MTEX)  act= MAX_MTEX-1;
+
+       switch(GS(id->name)) {
+       case ID_MA:
+               ((Material *)id)->texact= act;
+               break;
+       case ID_WO:
+               ((World *)id)->texact= act;
+               break;
+       case ID_LA:
+               ((Lamp *)id)->texact= act;
+               break;
+       case ID_BR:
+               ((Brush *)id)->texact= act;
+               break;
+       }
+}
+
 void set_current_material_texture(Material *ma, Tex *newtex)
 {
        Tex *tex= NULL;

Modified: trunk/blender/source/blender/editors/render/render_intern.h
===================================================================
--- trunk/blender/source/blender/editors/render/render_intern.h 2009-10-12 
14:38:35 UTC (rev 23786)
+++ trunk/blender/source/blender/editors/render/render_intern.h 2009-10-12 
16:00:39 UTC (rev 23787)
@@ -46,5 +46,8 @@
 void SCENE_OT_render_layer_add(struct wmOperatorType *ot);
 void SCENE_OT_render_layer_remove(struct wmOperatorType *ot);
 
+void TEXTURE_OT_slot_move(struct wmOperatorType *ot);
+
+
 #endif /* RENDER_INTERN_H */
 

Modified: trunk/blender/source/blender/editors/render/render_ops.c
===================================================================
--- trunk/blender/source/blender/editors/render/render_ops.c    2009-10-12 
14:38:35 UTC (rev 23786)
+++ trunk/blender/source/blender/editors/render/render_ops.c    2009-10-12 
16:00:39 UTC (rev 23787)
@@ -51,5 +51,7 @@
 
        WM_operatortype_append(SCENE_OT_render_layer_add);
        WM_operatortype_append(SCENE_OT_render_layer_remove);
+
+       WM_operatortype_append(TEXTURE_OT_slot_move);
 }
 

Modified: trunk/blender/source/blender/editors/render/render_shading.c
===================================================================
--- trunk/blender/source/blender/editors/render/render_shading.c        
2009-10-12 14:38:35 UTC (rev 23786)
+++ trunk/blender/source/blender/editors/render/render_shading.c        
2009-10-12 16:00:39 UTC (rev 23787)
@@ -681,3 +681,58 @@
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
+static int texture_slot_move(bContext *C, wmOperator *op)
+{
+       ID *id= CTX_data_pointer_get_type(C, "texture_slot", 
&RNA_TextureSlot).id.data;
+
+       if(id) {
+               MTex **mtex_ar, *mtexswap;
+               short act;
+               int type= RNA_enum_get(op->ptr, "type");
+
+               give_active_mtex(id, &mtex_ar, &act);
+
+               if(type == -1) { /* Up */
+                       if(act > 0) {
+                               mtexswap = mtex_ar[act];
+                               mtex_ar[act] = mtex_ar[act-1];
+                               mtex_ar[act-1] = mtexswap;
+                               set_active_mtex(id, act-1);
+                       }
+               }
+               else { /* Down */
+                       if(act < MAX_MTEX-1) {
+                               mtexswap = mtex_ar[act];
+                               mtex_ar[act] = mtex_ar[act+1];
+                               mtex_ar[act+1] = mtexswap;
+                               set_active_mtex(id, act+1);
+                       }
+               }
+
+               WM_event_add_notifier(C, NC_TEXTURE, CTX_data_scene(C));
+       }
+
+       return OPERATOR_FINISHED;
+}
+
+void TEXTURE_OT_slot_move(wmOperatorType *ot)
+{
+       static EnumPropertyItem slot_move[] = {
+               {-1, "UP", 0, "Up", ""},
+               {1, "DOWN", 0, "Down", ""},
+               {0, NULL, 0, NULL, NULL}
+       };
+
+       /* identifiers */
+       ot->name= "Move Texture Slot";
+       ot->idname= "TEXTURE_OT_slot_move";
+       ot->description="Move texture slots up and down.";
+
+       /* api callbacks */
+       ot->exec= texture_slot_move;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+       RNA_def_enum(ot->srna, "type", slot_move, 0, "Type", "");
+}


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to