Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-05-13 06:50:54 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-05-13 11:18:32 +0400
commit19b82be61e47cd30b72b7b215bd46c78e8207c89 (patch)
tree60fc81c8e1a5cfd1bcc6caf2ee6fdcc1f71802a8 /source/blender/makesrna
parentc08f025fe1111a60fdd0a90606ed5b08d991b78d (diff)
Freestyle: Added .new() and .remove() to the collection type of Python style modules.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_scene.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 49c14e9036e..08fe2701915 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -334,6 +334,7 @@ EnumPropertyItem bake_save_mode_items[] = {
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
+#include "DNA_text_types.h"
#include "RNA_access.h"
@@ -1640,6 +1641,37 @@ static void rna_FreestyleSettings_active_lineset_index_set(PointerRNA *ptr, int
BKE_freestyle_lineset_set_active_index(config, value);
}
+static FreestyleModuleConfig *rna_FreestyleSettings_module_add(ID *id, FreestyleSettings *config)
+{
+ Scene *scene = (Scene *)id;
+ FreestyleModuleConfig *module = BKE_freestyle_module_add((FreestyleConfig *)config);
+
+ DAG_id_tag_update(&scene->id, 0);
+ WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+ return module;
+}
+
+static void rna_FreestyleSettings_module_remove(ID *id, FreestyleSettings *config, ReportList *reports,
+ PointerRNA *module_ptr)
+{
+ Scene *scene = (Scene *)id;
+ FreestyleModuleConfig *module = module_ptr->data;
+
+ if (!BKE_freestyle_module_delete((FreestyleConfig *)config, module)) {
+ if (module->script)
+ BKE_reportf(reports, RPT_ERROR, "Style module '%s' could not be removed", module->script->id.name+2);
+ else
+ BKE_reportf(reports, RPT_ERROR, "Style module could not be removed");
+ return;
+ }
+
+ RNA_POINTER_INVALIDATE(module_ptr);
+
+ DAG_id_tag_update(&scene->id, 0);
+ WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL);
+}
+
#else
static void rna_def_transform_orientation(BlenderRNA *brna)
@@ -2652,6 +2684,31 @@ void rna_def_render_layer_common(StructRNA *srna, int scene)
else RNA_def_property_clear_flag(prop, PROP_EDITABLE);
}
+static void rna_def_freestyle_modules(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "FreestyleModules");
+ srna = RNA_def_struct(brna, "FreestyleModules", NULL);
+ RNA_def_struct_sdna(srna, "FreestyleSettings");
+ RNA_def_struct_ui_text(srna, "Style Modules", "A list of style modules (to be applied from top to bottom)");
+
+ func = RNA_def_function(srna, "new", "rna_FreestyleSettings_module_add");
+ RNA_def_function_ui_description(func, "Add a style module to scene render layer Freestyle settings");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID);
+ parm = RNA_def_pointer(func, "module", "FreestyleModuleSettings", "", "Newly created style module");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove", "rna_FreestyleSettings_module_remove");
+ RNA_def_function_ui_description(func, "Remove a style module from scene render layer Freestyle settings");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS);
+ parm = RNA_def_pointer(func, "module", "FreestyleModuleSettings", "", "Style module to remove");
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
+}
+
static void rna_def_freestyle_linesets(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
@@ -2988,6 +3045,7 @@ static void rna_def_freestyle_settings(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "modules", NULL);
RNA_def_property_struct_type(prop, "FreestyleModuleSettings");
RNA_def_property_ui_text(prop, "Style Modules", "A list of style modules (to be applied from top to bottom)");
+ rna_def_freestyle_modules(brna, prop);
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "mode");