Commit: 6d4f08467715030e7ef8833758b8da986280f236
Author: Campbell Barton
Date: Tue Jun 6 03:34:09 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB6d4f08467715030e7ef8833758b8da986280f236
WM: pass manipulator-map when creating wmManipulatorGroup
Also store parent-pointer in wmManipulatorGroup's,
since its not always possible to access the parent pointer.
===================================================================
M source/blender/makesdna/DNA_manipulator_types.h
M source/blender/windowmanager/manipulators/intern/wm_manipulator.c
M source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
M source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup.c
M source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c
===================================================================
diff --git a/source/blender/makesdna/DNA_manipulator_types.h
b/source/blender/makesdna/DNA_manipulator_types.h
index 7b75806f7c0..006a308162b 100644
--- a/source/blender/makesdna/DNA_manipulator_types.h
+++ b/source/blender/makesdna/DNA_manipulator_types.h
@@ -31,6 +31,8 @@ typedef struct wmManipulatorGroup {
struct wmManipulatorGroupType *type;
ListBase manipulators;
+ struct wmManipulatorMap *parent_mmap;
+
void *py_instance; /* python stores the class instance here
*/
struct ReportList *reports; /* errors and warnings storage */
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
index de2096dbde9..3d44e0c5d59 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
@@ -232,7 +232,7 @@ void WM_manipulator_delete(ListBase *manipulatorlist,
wmManipulatorMap *mmap, wm
wmManipulatorGroup *wm_manipulator_get_parent_group(const wmManipulator
*manipulator)
{
- return manipulator->mgroup;
+ return manipulator->parent_mgroup;
}
@@ -295,7 +295,7 @@ void WM_manipulator_set_custom_handler(
*/
void WM_manipulator_set_func_select(wmManipulator *manipulator,
wmManipulatorSelectFunc select)
{
- BLI_assert(manipulator->mgroup->type->flag &
WM_MANIPULATORGROUPTYPE_SELECTABLE);
+ BLI_assert(manipulator->parent_mgroup->type->flag &
WM_MANIPULATORGROUPTYPE_SELECTABLE);
manipulator->select = select;
}
@@ -421,7 +421,7 @@ void wm_manipulator_calculate_scale(wmManipulator
*manipulator, const bContext *
const RegionView3D *rv3d = CTX_wm_region_view3d(C);
float scale = 1.0f;
- if (manipulator->mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SCALE_3D)
{
+ if (manipulator->parent_mgroup->type->flag &
WM_MANIPULATORGROUPTYPE_SCALE_3D) {
if (rv3d /*&& (U.manipulator_flag & V3D_DRAW_MANIPULATOR) ==
0*/) { /* UserPref flag might be useful for later */
if (manipulator->get_final_position) {
float position[3];
diff --git
a/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
b/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
index 595eb4034a4..d2f81951f28 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
@@ -41,7 +41,7 @@ struct wmManipulator {
char idname[MAX_NAME + 4]; /* + 4 for unique '.001', '.002', etc suffix
*/
/* pointer back to group this manipulator is in (just for quick access)
*/
- struct wmManipulatorGroup *mgroup;
+ struct wmManipulatorGroup *parent_mgroup;
/* could become wmManipulatorType */
/* draw manipulator */
@@ -153,8 +153,9 @@ enum {
TWEAK_MODAL_PRECISION_OFF,
};
-struct wmManipulatorGroup *wm_manipulatorgroup_new_from_type(struct
wmManipulatorGroupType *mgrouptype);
-void wm_manipulatorgroup_free(bContext *C, struct wmManipulatorMap *mmap,
struct wmManipulatorGroup *mgroup);
+struct wmManipulatorGroup *wm_manipulatorgroup_new_from_type(
+ struct wmManipulatorMap *mmap, struct wmManipulatorGroupType
*mgrouptype);
+void wm_manipulatorgroup_free(bContext *C, struct wmManipulatorGroup *mgroup);
void wm_manipulatorgroup_manipulator_register(struct wmManipulatorGroup
*mgroup, struct wmManipulator *manipulator);
struct wmManipulator *wm_manipulatorgroup_find_intersected_mainpulator(
const struct wmManipulatorGroup *mgroup, struct bContext *C, const
struct wmEvent *event,
diff --git
a/source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup.c
b/source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup.c
index 11fc1b32047..ad31b1f7618 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup.c
@@ -73,16 +73,23 @@ enum {
/**
* Create a new manipulator-group from \a mgrouptype.
*/
-wmManipulatorGroup *wm_manipulatorgroup_new_from_type(wmManipulatorGroupType
*mgrouptype)
+wmManipulatorGroup *wm_manipulatorgroup_new_from_type(
+ wmManipulatorMap *mmap, wmManipulatorGroupType *mgrouptype)
{
wmManipulatorGroup *mgroup = MEM_callocN(sizeof(*mgroup),
"manipulator-group");
mgroup->type = mgrouptype;
+ /* keep back-link */
+ mgroup->parent_mmap = mmap;
+
+ BLI_addtail(&mmap->manipulator_groups, mgroup);
+
return mgroup;
}
-void wm_manipulatorgroup_free(bContext *C, wmManipulatorMap *mmap,
wmManipulatorGroup *mgroup)
+void wm_manipulatorgroup_free(bContext *C, wmManipulatorGroup *mgroup)
{
+ wmManipulatorMap *mmap = mgroup->parent_mmap;
for (wmManipulator *manipulator = mgroup->manipulators.first;
manipulator;) {
wmManipulator *manipulator_next = manipulator->next;
WM_manipulator_delete(&mgroup->manipulators, mmap, manipulator,
C);
@@ -121,7 +128,7 @@ void
wm_manipulatorgroup_manipulator_register(wmManipulatorGroup *mgroup, wmMani
{
BLI_assert(!BLI_findstring(&mgroup->manipulators, manipulator->idname,
offsetof(wmManipulator, idname)));
BLI_addtail(&mgroup->manipulators, manipulator);
- manipulator->mgroup = mgroup;
+ manipulator->parent_mgroup = mgroup;
}
void wm_manipulatorgroup_attach_to_modal_handler(
@@ -570,10 +577,9 @@ void WM_manipulatorgrouptype_init_runtime(
for (ARegion *ar = lb->first; ar; ar =
ar->next) {
wmManipulatorMap *mmap =
ar->manipulator_map;
if (mmap->type == mmaptype) {
- wmManipulatorGroup *mgroup =
wm_manipulatorgroup_new_from_type(mgrouptype);
+
wm_manipulatorgroup_new_from_type(mmap, mgrouptype);
/* just add here, drawing will
occur on next update */
-
BLI_addtail(&mmap->manipulator_groups, mgroup);
wm_manipulatormap_set_highlighted_manipulator(mmap, NULL, NULL, 0);
ED_region_tag_redraw(ar);
}
@@ -596,7 +602,8 @@ void WM_manipulatorgrouptype_unregister(bContext *C, Main
*bmain, wmManipulatorG
for (mgroup =
mmap->manipulator_groups.first; mgroup; mgroup = mgroup_next) {
mgroup_next = mgroup->next;
if (mgroup->type == mgrouptype)
{
-
wm_manipulatorgroup_free(C, mmap, mgroup);
+
BLI_assert(mgroup->parent_mmap == mmap);
+
wm_manipulatorgroup_free(C, mgroup);
ED_region_tag_redraw(ar);
}
}
diff --git
a/source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c
b/source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c
index cfc393c30b3..faf76a47d7a 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c
@@ -93,8 +93,7 @@ wmManipulatorMap *WM_manipulatormap_new_from_type(const
struct wmManipulatorMapT
mgrouptype;
mgrouptype = mgrouptype->next)
{
- wmManipulatorGroup *mgroup =
wm_manipulatorgroup_new_from_type(mgrouptype);
- BLI_addtail(&mmap->manipulator_groups, mgroup);
+ wm_manipulatorgroup_new_from_type(mmap, mgrouptype);
}
return mmap;
@@ -113,7 +112,8 @@ void wm_manipulatormap_delete(wmManipulatorMap *mmap)
for (wmManipulatorGroup *mgroup = mmap->manipulator_groups.first,
*mgroup_next; mgroup; mgroup = mgroup_next) {
mgroup_next = mgroup->next;
- wm_manipulatorgroup_free(NULL, mmap, mgroup);
+ BLI_assert(mgroup->parent_mmap == mmap);
+ wm_manipulatorgroup_free(NULL, mgroup);
}
BLI_assert(BLI_listbase_is_empty(&mmap->manipulator_groups));
@@ -462,7 +462,7 @@ bool wm_manipulatormap_deselect_all(wmManipulatorMap *mmap,
wmManipulator ***sel
BLI_INLINE bool manipulator_selectable_poll(const wmManipulator *manipulator,
void *UNUSED(data))
{
- return (manipulator->mgroup->type->flag &
WM_MANIPULATORGROUPTYPE_SELECTABLE);
+ return (manipulator->parent_mgroup->type->flag &
WM_MANIPULATORGROUPTYPE_SELECTABLE);
}
/**
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs