Compare commits
1 Commits
profiler-e
...
temp-tools
Author | SHA1 | Date | |
---|---|---|---|
60d402d715 |
@@ -59,7 +59,12 @@ bool ED_gizmo_poll_or_unlink_delayed_from_tool_ex(const bContext *C,
|
||||
{
|
||||
bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C);
|
||||
if ((tref_rt == NULL) || !STREQ(gzgt_idname, tref_rt->gizmo_group)) {
|
||||
WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params);
|
||||
WM_gizmo_group_unlink_delayed_ptr_from_space(gzgt, gzmap_type, sa);
|
||||
if (gzgt->users == 0) {
|
||||
WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@@ -34,6 +34,7 @@ struct GHashIterator;
|
||||
struct IDProperty;
|
||||
struct Main;
|
||||
struct PropertyRNA;
|
||||
struct ScrArea;
|
||||
struct wmGizmo;
|
||||
struct wmGizmoGroup;
|
||||
struct wmGizmoGroupType;
|
||||
@@ -165,6 +166,9 @@ void WM_gizmoconfig_update_tag_group_type_remove(struct wmGizmoMapType *gzmap_ty
|
||||
struct wmGizmoGroupType *gzgt);
|
||||
void WM_gizmoconfig_update(struct Main *bmain);
|
||||
|
||||
/* XXX */
|
||||
void WM_gizmoconfig_update_tag_remove_single_group(void);
|
||||
|
||||
/* wm_maniulator_target_props.c */
|
||||
struct wmGizmoProperty *WM_gizmo_target_property_array(struct wmGizmo *gz);
|
||||
struct wmGizmoProperty *WM_gizmo_target_property_at_index(struct wmGizmo *gz, int index);
|
||||
@@ -353,6 +357,10 @@ void WM_gizmo_group_type_unlink_delayed_ptr_ex(struct wmGizmoGroupType *gzgt,
|
||||
void WM_gizmo_group_type_unlink_delayed_ptr(struct wmGizmoGroupType *gzgt);
|
||||
void WM_gizmo_group_type_unlink_delayed(const char *idname);
|
||||
|
||||
void WM_gizmo_group_unlink_delayed_ptr_from_space(struct wmGizmoGroupType *gzgt,
|
||||
struct wmGizmoMapType *gzmap_type,
|
||||
struct ScrArea *sa);
|
||||
|
||||
/* Has the result of unlinking and linking (re-initializes gizmo's). */
|
||||
void WM_gizmo_group_type_reinit_ptr_ex(struct Main *bmain,
|
||||
struct wmGizmoGroupType *gzgt,
|
||||
@@ -365,4 +373,6 @@ bool WM_gizmo_context_check_drawstep(const struct bContext *C, eWM_GizmoFlagMapD
|
||||
|
||||
bool WM_gizmo_group_type_poll(const struct bContext *C, const struct wmGizmoGroupType *gzgt);
|
||||
|
||||
void WM_gizmo_group_tag_remove(struct wmGizmoGroup *gzgroup);
|
||||
|
||||
#endif /* __WM_GIZMO_API_H__ */
|
||||
|
@@ -417,6 +417,12 @@ typedef struct wmGizmoGroupType {
|
||||
/** Same as gizmo-maps, so registering/unregistering goes to the correct region. */
|
||||
struct wmGizmoMapType_Params gzmap_params;
|
||||
|
||||
/**
|
||||
* Number of #wmGizmoGroup instances.
|
||||
* Decremented when 'tag_remove' is set, or when removed.
|
||||
*/
|
||||
int users;
|
||||
|
||||
} wmGizmoGroupType;
|
||||
|
||||
typedef struct wmGizmoGroup {
|
||||
@@ -432,6 +438,8 @@ typedef struct wmGizmoGroup {
|
||||
/** Errors and warnings storage. */
|
||||
struct ReportList *reports;
|
||||
|
||||
bool tag_remove;
|
||||
|
||||
void *customdata;
|
||||
/** For freeing customdata from above. */
|
||||
void (*customdata_free)(void *);
|
||||
|
@@ -70,7 +70,9 @@
|
||||
wmGizmoGroup *wm_gizmogroup_new_from_type(wmGizmoMap *gzmap, wmGizmoGroupType *gzgt)
|
||||
{
|
||||
wmGizmoGroup *gzgroup = MEM_callocN(sizeof(*gzgroup), "gizmo-group");
|
||||
|
||||
gzgroup->type = gzgt;
|
||||
gzgroup->type->users += 1;
|
||||
|
||||
/* keep back-link */
|
||||
gzgroup->parent_gzmap = gzmap;
|
||||
@@ -125,9 +127,25 @@ void wm_gizmogroup_free(bContext *C, wmGizmoGroup *gzgroup)
|
||||
|
||||
BLI_remlink(&gzmap->groups, gzgroup);
|
||||
|
||||
if (gzgroup->tag_remove == false) {
|
||||
gzgroup->type->users -= 1;
|
||||
}
|
||||
|
||||
MEM_freeN(gzgroup);
|
||||
}
|
||||
|
||||
void WM_gizmo_group_tag_remove(wmGizmoGroup *gzgroup)
|
||||
{
|
||||
if (gzgroup->tag_remove == false) {
|
||||
gzgroup->tag_remove = true;
|
||||
gzgroup->type->users -= 1;
|
||||
BLI_assert(gzgroup->type->users >= 0);
|
||||
printf("Now users %d\n", gzgroup->type->users);
|
||||
|
||||
WM_gizmoconfig_update_tag_remove_single_group();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add \a gizmo to \a gzgroup and make sure its name is unique within the group.
|
||||
*/
|
||||
@@ -1066,4 +1084,20 @@ void WM_gizmo_group_type_unlink_delayed(const char *idname)
|
||||
WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
|
||||
}
|
||||
|
||||
void WM_gizmo_group_unlink_delayed_ptr_from_space(wmGizmoGroupType *gzgt,
|
||||
wmGizmoMapType *gzmap_type,
|
||||
ScrArea *sa)
|
||||
{
|
||||
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
wmGizmoMap *gzmap = ar->gizmo_map;
|
||||
if (gzmap && gzmap->type == gzmap_type) {
|
||||
for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
|
||||
if (gzgroup->type == gzgt) {
|
||||
WM_gizmo_group_tag_remove(gzgroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@@ -71,6 +71,9 @@ static ListBase gizmomaptypes = {NULL, NULL};
|
||||
typedef enum eWM_GizmoFlagGroupTypeGlobalFlag {
|
||||
WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT = (1 << 0),
|
||||
WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE = (1 << 1),
|
||||
|
||||
/* XXX. */
|
||||
WM_GIZMOTYPE_GLOBAL_UPDATE_REMOVE = (1 << 2),
|
||||
} eWM_GizmoFlagGroupTypeGlobalFlag;
|
||||
|
||||
static eWM_GizmoFlagGroupTypeGlobalFlag wm_gzmap_type_update_flag = 0;
|
||||
@@ -1257,6 +1260,11 @@ void WM_gizmoconfig_update_tag_group_type_remove(wmGizmoMapType *gzmap_type,
|
||||
wm_gzmap_type_update_flag |= WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE;
|
||||
}
|
||||
|
||||
void WM_gizmoconfig_update_tag_remove_single_group(void)
|
||||
{
|
||||
wm_gzmap_type_update_flag |= WM_GIZMOTYPE_GLOBAL_UPDATE_REMOVE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run in case new types have been added (runs often, early exit where possible).
|
||||
* Follows #WM_keyconfig_update conventions.
|
||||
@@ -1271,6 +1279,32 @@ void WM_gizmoconfig_update(struct Main *bmain)
|
||||
return;
|
||||
}
|
||||
|
||||
if (wm_gzmap_type_update_flag & WM_GIZMOTYPE_GLOBAL_UPDATE_REMOVE) {
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
|
||||
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
|
||||
for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
|
||||
wmGizmoMap *gzmap = ar->gizmo_map;
|
||||
if (gzmap != NULL) {
|
||||
|
||||
for (wmGizmoGroup *gzgroup = gzmap->groups.first, *gzgroup_next; gzgroup;
|
||||
gzgroup = gzgroup_next) {
|
||||
gzgroup_next = gzgroup->next;
|
||||
if (gzgroup->tag_remove) {
|
||||
printf("Removing tagged\n");
|
||||
wm_gizmogroup_free(NULL, gzgroup);
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
wm_gzmap_type_update_flag &= ~WM_GIZMOTYPE_GLOBAL_UPDATE_REMOVE;
|
||||
}
|
||||
|
||||
if (wm_gzmap_type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE) {
|
||||
for (wmGizmoMapType *gzmap_type = gizmomaptypes.first; gzmap_type;
|
||||
gzmap_type = gzmap_type->next) {
|
||||
|
Reference in New Issue
Block a user