forked from bartvdbraak/blender
texture slots up/down back
This commit is contained in:
parent
50fd4f967f
commit
fbde77ce80
@ -75,6 +75,10 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel):
|
||||
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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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", "");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user