Merged changes in the trunk up to revision 26856.
[blender-staging.git] / source / blender / editors / render / render_shading.c
index e49981958cc6ea2d7de039d179712d36a1031abe..e3867ca61573c7157b8bfeeb3fd851abe1504e0e 100644 (file)
@@ -58,6 +58,8 @@
 
 #include "GPU_material.h"
 
+#include "FRS_freestyle.h"
+
 #include "RNA_access.h"
 #include "RNA_enum_types.h"
 
@@ -683,6 +685,126 @@ void SCENE_OT_render_layer_remove(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
+static int freestyle_module_add_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
+
+       FRS_add_module(&srl->freestyleConfig);
+
+       WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
+       
+       return OPERATOR_FINISHED;
+}
+
+void SCENE_OT_freestyle_module_add(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Add Freestyle Module";
+       ot->idname= "SCENE_OT_freestyle_module_add";
+       ot->description="Add a style module into the list of modules.";
+       
+       /* api callbacks */
+       ot->exec= freestyle_module_add_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int freestyle_module_remove_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
+       PointerRNA ptr= CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
+       FreestyleModuleConfig *module= ptr.data;
+
+       FRS_delete_module(&srl->freestyleConfig, module);
+
+       WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
+       
+       return OPERATOR_FINISHED;
+}
+
+void SCENE_OT_freestyle_module_remove(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Remove Freestyle Module";
+       ot->idname= "SCENE_OT_freestyle_module_remove";
+       ot->description="Remove the style module from the stack.";
+       
+       /* api callbacks */
+       ot->exec= freestyle_module_remove_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int freestyle_module_move_up_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
+       PointerRNA ptr= CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
+       FreestyleModuleConfig *module= ptr.data;
+       int active = RNA_boolean_get(op->ptr, "active");
+
+       if(active)
+               FRS_move_up_module(&srl->freestyleConfig, module);
+
+       WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
+       
+       return OPERATOR_FINISHED;
+}
+
+void SCENE_OT_freestyle_module_move_up(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Move Up Freestyle Module";
+       ot->idname= "SCENE_OT_freestyle_module_move_up";
+       ot->description="Move the style module up in the stack.";
+       
+       /* api callbacks */
+       ot->exec= freestyle_module_move_up_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+       /* props */
+       RNA_def_boolean(ot->srna, "active", 0, "Active", "True if the operator is enabled.");
+}
+
+static int freestyle_module_move_down_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
+       PointerRNA ptr= CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
+       FreestyleModuleConfig *module= ptr.data;
+       int active = RNA_boolean_get(op->ptr, "active");
+
+       if(active)
+               FRS_move_down_module(&srl->freestyleConfig, module);
+
+       WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
+       
+       return OPERATOR_FINISHED;
+}
+
+void SCENE_OT_freestyle_module_move_down(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Move Down Freestyle Module";
+       ot->idname= "SCENE_OT_freestyle_module_move_down";
+       ot->description="Move the style module down in the stack.";
+       
+       /* api callbacks */
+       ot->exec= freestyle_module_move_down_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+       /* props */
+       RNA_def_boolean(ot->srna, "active", 0, "Active", "True if the operator is enabled.");
+}
+
 static int texture_slot_move(bContext *C, wmOperator *op)
 {
        ID *id= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;