[Bf-blender-cvs] [e3db258efda] custom-manipulators: Manipulator: Name access
Campbell Barton
noreply at git.blender.org
Fri Jun 23 08:13:56 CEST 2017
Commit: e3db258efda476dec0ee1c7e353991b79b31dbd1
Author: Campbell Barton
Date: Fri Jun 23 16:18:31 2017 +1000
Branches: custom-manipulators
https://developer.blender.org/rBe3db258efda476dec0ee1c7e353991b79b31dbd1
Manipulator: Name access
===================================================================
M source/blender/makesrna/intern/rna_wm_manipulator.c
M source/blender/windowmanager/manipulators/WM_manipulator_api.h
M source/blender/windowmanager/manipulators/intern/wm_manipulator.c
===================================================================
diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c
index 2cc3e441506..9c7dd5f047d 100644
--- a/source/blender/makesrna/intern/rna_wm_manipulator.c
+++ b/source/blender/makesrna/intern/rna_wm_manipulator.c
@@ -249,7 +249,7 @@ static wmManipulator *rna_ManipulatorProperties_find_operator(PointerRNA *ptr)
/* We could try workaruond this lookup, but not trivial. */
for (bScreen *screen = G.main->screen.first; screen; screen = screen->id.next) {
- IDProperty *properties = (IDProperty *)ptr->data;
+ IDProperty *properties = ptr->data;
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->manipulator_map) {
@@ -361,6 +361,24 @@ RNA_MANIPULATOR_FLAG_RO_DEF(state_is_highlight, state, WM_MANIPULATOR_STATE_HIGH
RNA_MANIPULATOR_FLAG_RO_DEF(state_is_active, state, WM_MANIPULATOR_STATE_ACTIVE);
RNA_MANIPULATOR_FLAG_RO_DEF(state_select, state, WM_MANIPULATOR_STATE_SELECT);
+static void rna_Manipulator_name_get(PointerRNA *ptr, char *value)
+{
+ wmManipulator *mpr = ptr->data;
+ strcpy(value, mpr->name);
+}
+
+static void rna_Manipulator_name_set(PointerRNA *ptr, const char *value)
+{
+ wmManipulator *mpr = ptr->data;
+ WM_manipulator_name_set(mpr->parent_mgroup, mpr, value);
+}
+
+static int rna_Manipulator_name_length(PointerRNA *ptr)
+{
+ wmManipulator *mpr = ptr->data;
+ return strlen(mpr->name);
+}
+
static void rna_Manipulator_unregister(struct Main *bmain, StructRNA *type);
void BPY_RNA_manipulator_wrapper(wmManipulatorType *wgt, void *userdata);
@@ -859,7 +877,6 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Manipulator_bl_idname_set");
/* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
RNA_def_property_flag(prop, PROP_REGISTER);
- RNA_def_struct_name_property(srna, prop);
RNA_define_verify_sdna(1); /* not in sdna */
@@ -956,6 +973,13 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop)
/* -------------------------------------------------------------------- */
/* Instance Variables */
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_funcs(
+ prop, "rna_Manipulator_name_get", "rna_Manipulator_name_length", "rna_Manipulator_name_set");
+ RNA_def_property_ui_text(prop, "Name", "");
+ RNA_def_struct_name_property(srna, prop);
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
+
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_array(prop, 4);
RNA_def_property_float_funcs(prop, "rna_Manipulator_color_get", "rna_Manipulator_color_set", NULL);
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_api.h b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
index d6e468089f8..e252bd6aac0 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_api.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
@@ -66,6 +66,8 @@ void WM_manipulator_free(
ListBase *manipulatorlist, struct wmManipulatorMap *mmap, struct wmManipulator *mpr,
struct bContext *C);
+void WM_manipulator_name_set(struct wmManipulatorGroup *mgroup, struct wmManipulator *mpr, const char *name);
+
struct PointerRNA *WM_manipulator_set_operator(struct wmManipulator *, struct wmOperatorType *ot);
/* callbacks */
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
index ba0e720485a..3c02fd8969c 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
@@ -142,6 +142,15 @@ static void manipulator_unique_idname_set(wmManipulatorGroup *mgroup, wmManipula
offsetof(wmManipulator, name), sizeof(mpr->name));
}
+void WM_manipulator_name_set(wmManipulatorGroup *mgroup, wmManipulator *mpr, const char *name)
+{
+ BLI_strncpy(mpr->name, name, sizeof(mpr->name));
+
+ /* ensure name is unique, append '.001', '.002', etc if not */
+ BLI_uniquename(&mgroup->manipulators, mpr, "Manipulator", '.',
+ offsetof(wmManipulator, name), sizeof(mpr->name));
+}
+
/**
* Initialize default values and allocate needed memory for members.
*/
More information about the Bf-blender-cvs
mailing list