diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_texture.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 49 | ||||
-rw-r--r-- | source/blender/editors/render/render_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/render/render_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/render/render_shading.c | 55 |
5 files changed, 112 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index c7a6e20cc8b..b9dc5916e69 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -75,6 +75,9 @@ struct Tex *give_current_lamp_texture(struct Lamp *la); 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); diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index d1c26b5a1b4..33dfcfca76e 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -889,6 +889,55 @@ Tex *give_current_material_texture(Material *ma) 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; diff --git a/source/blender/editors/render/render_intern.h b/source/blender/editors/render/render_intern.h index d3ecbbc56e8..7b4c0194c5d 100644 --- a/source/blender/editors/render/render_intern.h +++ b/source/blender/editors/render/render_intern.h @@ -46,5 +46,8 @@ void WORLD_OT_new(struct wmOperatorType *ot); 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 */ diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c index 7d35dff7493..8c0c1b18fca 100644 --- a/source/blender/editors/render/render_ops.c +++ b/source/blender/editors/render/render_ops.c @@ -51,5 +51,7 @@ void ED_operatortypes_render(void) WM_operatortype_append(SCENE_OT_render_layer_add); WM_operatortype_append(SCENE_OT_render_layer_remove); + + WM_operatortype_append(TEXTURE_OT_slot_move); } diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 26df0df935b..4a2c88f54a7 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -681,3 +681,58 @@ void SCENE_OT_render_layer_remove(wmOperatorType *ot) 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", ""); +} |