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:
authorCampbell Barton <ideasman42@gmail.com>2017-06-16 19:31:21 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-06-16 19:38:49 +0300
commit2b8d599b3a93c78661ff9a2c460b7144278409be (patch)
treeab00a7d46316ba0d005fd4b32138283399b4c2fa /source/blender
parent946bc4d3c1da45b11f7da045074bb297d45487cd (diff)
Manipulator: add array get/set functions
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/windowmanager/manipulators/WM_manipulator_api.h13
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c48
2 files changed, 49 insertions, 12 deletions
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_api.h b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
index 6a7585740cb..13c5e024b9d 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_api.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
@@ -121,10 +121,19 @@ void WM_manipulator_property_def_func(
bool WM_manipulator_property_is_valid(
const struct wmManipulatorProperty *mpr_prop);
-void WM_manipulator_property_value_set(
- struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop, const float value);
float WM_manipulator_property_value_get(
const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop);
+void WM_manipulator_property_value_set(
+ struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop,
+ const float value);
+
+void WM_manipulator_property_value_get_array(
+ const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop,
+ float *value, const int value_len);
+void WM_manipulator_property_value_set_array(
+ struct bContext *C, const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop,
+ const float *value, const int value_len);
+
void WM_manipulator_property_range_get(
const struct wmManipulator *mpr, struct wmManipulatorProperty *mpr_prop,
float range[2]);
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c
index 5a8eb1d68dc..e280fc6db79 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c
@@ -123,6 +123,23 @@ bool WM_manipulator_property_is_valid(const wmManipulatorProperty *mpr_prop)
(mpr_prop->custom_func.value_get_fn && mpr_prop->custom_func.value_set_fn));
}
+float WM_manipulator_property_value_get(
+ const wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
+{
+ if (mpr_prop->custom_func.value_get_fn) {
+ float value = 0.0f;
+ mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, mpr_prop->custom_func.user_data, &value, 1);
+ return value;
+ }
+
+ if (mpr_prop->index == -1) {
+ return RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop);
+ }
+ else {
+ return RNA_property_float_get_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index);
+ }
+}
+
void WM_manipulator_property_value_set(
bContext *C, const wmManipulator *mpr,
wmManipulatorProperty *mpr_prop, const float value)
@@ -142,21 +159,32 @@ void WM_manipulator_property_value_set(
RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
}
-float WM_manipulator_property_value_get(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop)
+void WM_manipulator_property_value_get_array(
+ const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+ float *value, const int value_len)
{
if (mpr_prop->custom_func.value_get_fn) {
- float value = 0.0f;
- mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, mpr_prop->custom_func.user_data, &value, 1);
- return value;
+ mpr_prop->custom_func.value_get_fn(mpr, mpr_prop, mpr_prop->custom_func.user_data, value, value_len);
+ return;
}
- if (mpr_prop->index == -1) {
- return RNA_property_float_get(&mpr_prop->ptr, mpr_prop->prop);
- }
- else {
- return RNA_property_float_get_index(&mpr_prop->ptr, mpr_prop->prop, mpr_prop->index);
+ BLI_assert(RNA_property_array_length(&mpr_prop->ptr, mpr_prop->prop) == value_len);
+ return RNA_property_float_get_array(&mpr_prop->ptr, mpr_prop->prop, value);
+}
+
+void WM_manipulator_property_value_set_array(
+ bContext *C, const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
+ const float *value, const int value_len)
+{
+ if (mpr_prop->custom_func.value_set_fn) {
+ mpr_prop->custom_func.value_set_fn(mpr, mpr_prop, mpr_prop->custom_func.user_data, value, value_len);
+ return;
}
+
+ BLI_assert(RNA_property_array_length(&mpr_prop->ptr, mpr_prop->prop) == value_len);
+ RNA_property_float_set_array(&mpr_prop->ptr, mpr_prop->prop, value);
+
+ RNA_property_update(C, &mpr_prop->ptr, mpr_prop->prop);
}
void WM_manipulator_property_range_get(