diff options
Diffstat (limited to 'source/blender/editors/render')
-rw-r--r-- | source/blender/editors/render/render_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/render/render_ops.c | 3 | ||||
-rw-r--r-- | source/blender/editors/render/render_shading.c | 59 |
3 files changed, 65 insertions, 0 deletions
diff --git a/source/blender/editors/render/render_intern.h b/source/blender/editors/render/render_intern.h index 7b4c0194c5d..846edd67736 100644 --- a/source/blender/editors/render/render_intern.h +++ b/source/blender/editors/render/render_intern.h @@ -43,6 +43,9 @@ void MATERIAL_OT_new(struct wmOperatorType *ot); void TEXTURE_OT_new(struct wmOperatorType *ot); void WORLD_OT_new(struct wmOperatorType *ot); +void MATERIAL_OT_copy(struct wmOperatorType *ot); +void MATERIAL_OT_paste(struct wmOperatorType *ot); + void SCENE_OT_render_layer_add(struct wmOperatorType *ot); void SCENE_OT_render_layer_remove(struct wmOperatorType *ot); diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c index 3e1643fab7b..0672709d364 100644 --- a/source/blender/editors/render/render_ops.c +++ b/source/blender/editors/render/render_ops.c @@ -52,6 +52,9 @@ void ED_operatortypes_render(void) WM_operatortype_append(MATERIAL_OT_new); WM_operatortype_append(TEXTURE_OT_new); WM_operatortype_append(WORLD_OT_new); + + WM_operatortype_append(MATERIAL_OT_copy); + WM_operatortype_append(MATERIAL_OT_paste); WM_operatortype_append(SCENE_OT_render_layer_add); WM_operatortype_append(SCENE_OT_render_layer_remove); diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 4be35a4a2c4..413d9889b5d 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -758,3 +758,62 @@ void TEXTURE_OT_slot_move(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", slot_move, 0, "Type", ""); } + + + +/* material copy/paste */ +static int copy_material_exec(bContext *C, wmOperator *op) +{ + Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data; + + if(ma==NULL) + return; + + copy_matcopybuf(ma); + + WM_event_add_notifier(C, NC_MATERIAL, ma); + + return OPERATOR_FINISHED; +} + +void MATERIAL_OT_copy(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Copy Material"; + ot->idname= "MATERIAL_OT_copy"; + ot->description="Copy the material settings and nodes."; + + /* api callbacks */ + ot->exec= copy_material_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int paste_material_exec(bContext *C, wmOperator *op) +{ + Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data; + + if(ma==NULL) + return; + + paste_matcopybuf(ma); + + WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING_DRAW, ma); + + return OPERATOR_FINISHED; +} + +void MATERIAL_OT_paste(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Paste Material"; + ot->idname= "MATERIAL_OT_paste"; + ot->description="Copy the material settings and nodes."; + + /* api callbacks */ + ot->exec= paste_material_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} |