Collections Settings: Added Bool type.

This commit is contained in:
Clément Foucault 2017-02-15 18:17:50 +01:00
parent 574d6011f4
commit 69b96e27ee
5 changed files with 50 additions and 0 deletions

View File

@ -114,11 +114,14 @@ void BKE_layer_collection_engine_settings_list_free(struct ListBase *lb);
void BKE_collection_engine_property_add_float(struct CollectionEngineSettings *ces, const char *name, float value);
void BKE_collection_engine_property_add_int(struct CollectionEngineSettings *ces, const char *name, int value);
void BKE_collection_engine_property_add_bool(struct CollectionEngineSettings *ces, const char *name, bool value);
struct CollectionEngineProperty *BKE_collection_engine_property_get(struct CollectionEngineSettings *ces, const char *name);
int BKE_collection_engine_property_value_get_int(struct CollectionEngineSettings *ces, const char *name);
float BKE_collection_engine_property_value_get_float(struct CollectionEngineSettings *ces, const char *name);
bool BKE_collection_engine_property_value_get_bool(struct CollectionEngineSettings *ces, const char *name);
void BKE_collection_engine_property_value_set_int(struct CollectionEngineSettings *ces, const char *name, int value);
void BKE_collection_engine_property_value_set_float(struct CollectionEngineSettings *ces, const char *name, float value);
void BKE_collection_engine_property_value_set_bool(struct CollectionEngineSettings *ces, const char *name, bool value);
bool BKE_collection_engine_property_use_get(struct CollectionEngineSettings *ces, const char *name);
void BKE_collection_engine_property_use_set(struct CollectionEngineSettings *ces, const char *name, bool value);

View File

@ -892,6 +892,16 @@ void BKE_collection_engine_property_add_int(CollectionEngineSettings *ces, const
BLI_addtail(&ces->properties, prop);
}
void BKE_collection_engine_property_add_bool(CollectionEngineSettings *ces, const char *name, bool value)
{
CollectionEnginePropertyBool *prop;
prop = MEM_callocN(sizeof(CollectionEnginePropertyBool), "collection engine settings bool");
prop->data.type = COLLECTION_PROP_TYPE_BOOL;
BLI_strncpy_utf8(prop->data.name, name, sizeof(prop->data.name));
prop->value = value;
BLI_addtail(&ces->properties, prop);
}
CollectionEngineProperty *BKE_collection_engine_property_get(CollectionEngineSettings *ces, const char *name)
{
return BLI_findstring(&ces->properties, name, offsetof(CollectionEngineProperty, name));
@ -911,6 +921,13 @@ float BKE_collection_engine_property_value_get_float(CollectionEngineSettings *c
return prop->value;
}
bool BKE_collection_engine_property_value_get_bool(CollectionEngineSettings *ces, const char *name)
{
CollectionEnginePropertyBool *prop;
prop = (CollectionEnginePropertyBool *)BLI_findstring(&ces->properties, name, offsetof(CollectionEngineProperty, name));
return prop->value;
}
void BKE_collection_engine_property_value_set_int(CollectionEngineSettings *ces, const char *name, int value)
{
CollectionEnginePropertyInt *prop;
@ -927,6 +944,14 @@ void BKE_collection_engine_property_value_set_float(CollectionEngineSettings *ce
prop->data.flag |= COLLECTION_PROP_USE;
}
void BKE_collection_engine_property_value_set_bool(CollectionEngineSettings *ces, const char *name, bool value)
{
CollectionEnginePropertyBool *prop;
prop = (CollectionEnginePropertyBool *)BLI_findstring(&ces->properties, name, offsetof(CollectionEngineProperty, name));
prop->value = value;
prop->data.flag |= COLLECTION_PROP_USE;
}
bool BKE_collection_engine_property_use_get(CollectionEngineSettings *ces, const char *name)
{
CollectionEngineProperty *prop;
@ -995,6 +1020,9 @@ static void collection_engine_property_set (CollectionEngineProperty *prop_dst,
case COLLECTION_PROP_TYPE_INT:
((CollectionEnginePropertyInt *)prop_dst)->value = ((CollectionEnginePropertyInt *)prop_src)->value;
break;
case COLLECTION_PROP_TYPE_BOOL:
((CollectionEnginePropertyBool *)prop_dst)->value = ((CollectionEnginePropertyBool *)prop_src)->value;
break;
default:
BLI_assert(false);
break;

View File

@ -2582,6 +2582,9 @@ static void write_collection_engine_settings(WriteData *wd, ListBase *lb)
case COLLECTION_PROP_TYPE_INT:
writestruct(wd, DATA, CollectionEnginePropertyInt, 1, prop);
break;
case COLLECTION_PROP_TYPE_BOOL:
writestruct(wd, DATA, CollectionEnginePropertyBool, 1, prop);
break;
default:
; /* error: don't know how to write this file */
}

View File

@ -127,6 +127,12 @@ typedef struct CollectionEnginePropertyInt {
int pad;
} CollectionEnginePropertyInt;
typedef struct CollectionEnginePropertyBool {
struct CollectionEngineProperty data;
int value;
int pad;
} CollectionEnginePropertyBool;
typedef struct CollectionEnginePropertyFloat {
struct CollectionEngineProperty data;
float value;
@ -150,6 +156,7 @@ enum {
typedef enum CollectionEnginePropertyType {
COLLECTION_PROP_TYPE_FLOAT = 0,
COLLECTION_PROP_TYPE_INT = 1,
COLLECTION_PROP_TYPE_BOOL = 2,
} CollectionEnginePropertyType;
/* CollectionEngineSettings->type */

View File

@ -2426,6 +2426,9 @@ static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_set(PointerRNA *ptr,
#define RNA_LAYER_ENGINE_CLAY_GET_SET_INT(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(int, Clay, COLLECTION_MODE_NONE, _NAME_)
#define RNA_LAYER_ENGINE_CLAY_GET_SET_BOOL(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(int, Clay, COLLECTION_MODE_NONE, _NAME_)
/* mode engines */
#define RNA_LAYER_MODE_OBJECT_GET_SET_FLOAT(_NAME_) \
@ -2434,12 +2437,18 @@ static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_set(PointerRNA *ptr,
#define RNA_LAYER_MODE_OBJECT_GET_SET_INT(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(int, ObjectMode, COLLECTION_MODE_OBJECT, _NAME_)
#define RNA_LAYER_MODE_OBJECT_GET_SET_BOOL(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(bool, ObjectMode, COLLECTION_MODE_OBJECT, _NAME_)
#define RNA_LAYER_MODE_EDIT_GET_SET_FLOAT(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(float, EditMode, COLLECTION_MODE_EDIT, _NAME_)
#define RNA_LAYER_MODE_EDIT_GET_SET_INT(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(int, EditMode, COLLECTION_MODE_EDIT, _NAME_)
#define RNA_LAYER_MODE_EDIT_GET_SET_BOOL(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(bool, EditMode, COLLECTION_MODE_EDIT, _NAME_)
/* clay engine */
RNA_LAYER_ENGINE_CLAY_GET_SET_INT(type)