forked from bartvdbraak/blender
Freestyle: Added .new() and .remove() to the collection type of Python style modules.
This commit is contained in:
parent
c08f025fe1
commit
19b82be61e
@ -52,10 +52,10 @@ void BKE_freestyle_config_free(FreestyleConfig *config);
|
|||||||
void BKE_freestyle_config_copy(FreestyleConfig *new_config, FreestyleConfig *config);
|
void BKE_freestyle_config_copy(FreestyleConfig *new_config, FreestyleConfig *config);
|
||||||
|
|
||||||
/* FreestyleConfig.modules */
|
/* FreestyleConfig.modules */
|
||||||
void BKE_freestyle_module_add(FreestyleConfig *config);
|
FreestyleModuleConfig *BKE_freestyle_module_add(FreestyleConfig *config);
|
||||||
void BKE_freestyle_module_delete(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
|
bool BKE_freestyle_module_delete(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
|
||||||
void BKE_freestyle_module_move_up(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
|
bool BKE_freestyle_module_move_up(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
|
||||||
void BKE_freestyle_module_move_down(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
|
bool BKE_freestyle_module_move_down(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
|
||||||
|
|
||||||
/* FreestyleConfig.linesets */
|
/* FreestyleConfig.linesets */
|
||||||
FreestyleLineSet *BKE_freestyle_lineset_add(FreestyleConfig *config, const char *name);
|
FreestyleLineSet *BKE_freestyle_lineset_add(FreestyleConfig *config, const char *name);
|
||||||
|
@ -127,12 +127,13 @@ static FreestyleModuleConfig *alloc_module(void)
|
|||||||
return (FreestyleModuleConfig *)MEM_callocN(sizeof(FreestyleModuleConfig), "style module configuration");
|
return (FreestyleModuleConfig *)MEM_callocN(sizeof(FreestyleModuleConfig), "style module configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_freestyle_module_add(FreestyleConfig *config)
|
FreestyleModuleConfig *BKE_freestyle_module_add(FreestyleConfig *config)
|
||||||
{
|
{
|
||||||
FreestyleModuleConfig *module_conf = alloc_module();
|
FreestyleModuleConfig *module_conf = alloc_module();
|
||||||
BLI_addtail(&config->modules, (void *)module_conf);
|
BLI_addtail(&config->modules, (void *)module_conf);
|
||||||
module_conf->script = NULL;
|
module_conf->script = NULL;
|
||||||
module_conf->is_displayed = 1;
|
module_conf->is_displayed = 1;
|
||||||
|
return module_conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copy_module(FreestyleModuleConfig *new_module, FreestyleModuleConfig *module)
|
static void copy_module(FreestyleModuleConfig *new_module, FreestyleModuleConfig *module)
|
||||||
@ -141,21 +142,30 @@ static void copy_module(FreestyleModuleConfig *new_module, FreestyleModuleConfig
|
|||||||
new_module->is_displayed = module->is_displayed;
|
new_module->is_displayed = module->is_displayed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_freestyle_module_delete(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
|
bool BKE_freestyle_module_delete(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
|
||||||
{
|
{
|
||||||
|
if (BLI_findindex(&config->modules, module_conf) == -1)
|
||||||
|
return false;
|
||||||
BLI_freelinkN(&config->modules, module_conf);
|
BLI_freelinkN(&config->modules, module_conf);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_freestyle_module_move_up(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
|
bool BKE_freestyle_module_move_up(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
|
||||||
{
|
{
|
||||||
|
if (BLI_findindex(&config->modules, module_conf) == -1)
|
||||||
|
return false;
|
||||||
BLI_remlink(&config->modules, module_conf);
|
BLI_remlink(&config->modules, module_conf);
|
||||||
BLI_insertlinkbefore(&config->modules, module_conf->prev, module_conf);
|
BLI_insertlinkbefore(&config->modules, module_conf->prev, module_conf);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_freestyle_module_move_down(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
|
bool BKE_freestyle_module_move_down(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
|
||||||
{
|
{
|
||||||
|
if (BLI_findindex(&config->modules, module_conf) == -1)
|
||||||
|
return false;
|
||||||
BLI_remlink(&config->modules, module_conf);
|
BLI_remlink(&config->modules, module_conf);
|
||||||
BLI_insertlinkafter(&config->modules, module_conf->next, module_conf);
|
BLI_insertlinkafter(&config->modules, module_conf->next, module_conf);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_freestyle_lineset_unique_name(FreestyleConfig *config, FreestyleLineSet *lineset)
|
void BKE_freestyle_lineset_unique_name(FreestyleConfig *config, FreestyleLineSet *lineset)
|
||||||
|
@ -334,6 +334,7 @@ EnumPropertyItem bake_save_mode_items[] = {
|
|||||||
#include "DNA_node_types.h"
|
#include "DNA_node_types.h"
|
||||||
#include "DNA_object_types.h"
|
#include "DNA_object_types.h"
|
||||||
#include "DNA_mesh_types.h"
|
#include "DNA_mesh_types.h"
|
||||||
|
#include "DNA_text_types.h"
|
||||||
|
|
||||||
#include "RNA_access.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);
|
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
|
#else
|
||||||
|
|
||||||
static void rna_def_transform_orientation(BlenderRNA *brna)
|
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);
|
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)
|
static void rna_def_freestyle_linesets(BlenderRNA *brna, PropertyRNA *cprop)
|
||||||
{
|
{
|
||||||
StructRNA *srna;
|
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_collection_sdna(prop, NULL, "modules", NULL);
|
||||||
RNA_def_property_struct_type(prop, "FreestyleModuleSettings");
|
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_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);
|
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
|
||||||
RNA_def_property_enum_sdna(prop, NULL, "mode");
|
RNA_def_property_enum_sdna(prop, NULL, "mode");
|
||||||
|
Loading…
Reference in New Issue
Block a user