Fix #108722 : Measures not cleared when removing annotation layer #108749
|
@ -65,6 +65,7 @@
|
||||||
|
|
||||||
#include "ED_gpencil_legacy.h"
|
#include "ED_gpencil_legacy.h"
|
||||||
#include "ED_object.h"
|
#include "ED_object.h"
|
||||||
|
#include "ED_view3d.h"
|
||||||
|
|
||||||
#include "DEG_depsgraph.h"
|
#include "DEG_depsgraph.h"
|
||||||
#include "DEG_depsgraph_build.h"
|
#include "DEG_depsgraph_build.h"
|
||||||
|
@ -332,6 +333,10 @@ static int gpencil_layer_remove_exec(bContext *C, wmOperator *op)
|
||||||
BKE_gpencil_layer_active_set(gpd, gpl->next);
|
BKE_gpencil_layer_active_set(gpd, gpl->next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gpl->flag & GP_LAYER_IS_RULER) {
|
||||||
|
|||||||
|
ED_view3d_gizmo_ruler_remove_all(C);
|
||||||
|
}
|
||||||
|
|
||||||
/* delete the layer now... */
|
/* delete the layer now... */
|
||||||
BKE_gpencil_layer_delete(gpd, gpl);
|
BKE_gpencil_layer_delete(gpd, gpl);
|
||||||
|
|
||||||
|
|
|
@ -1364,6 +1364,13 @@ void ED_view3d_gizmo_mesh_preselect_get_active(struct bContext *C,
|
||||||
struct BMElem **r_ele);
|
struct BMElem **r_ele);
|
||||||
void ED_view3d_gizmo_mesh_preselect_clear(struct wmGizmo *gz);
|
void ED_view3d_gizmo_mesh_preselect_clear(struct wmGizmo *gz);
|
||||||
|
|
||||||
|
/* view3d_gizmo_ruler.cc */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all rulers when Annotation layer is removed.
|
||||||
|
*/
|
||||||
|
void ED_view3d_gizmo_ruler_remove_all(struct bContext *C);
|
||||||
|
|
||||||
/* space_view3d.cc */
|
/* space_view3d.cc */
|
||||||
|
|
||||||
void ED_view3d_buttons_region_layout_ex(const struct bContext *C,
|
void ED_view3d_buttons_region_layout_ex(const struct bContext *C,
|
||||||
|
|
|
@ -621,6 +621,20 @@ static bool view3d_ruler_from_gpencil(const bContext *C, wmGizmoGroup *gzgroup)
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ED_view3d_gizmo_ruler_remove_all(bContext *C)
|
||||||
|
{
|
||||||
|
ARegion *region = CTX_wm_region(C);
|
||||||
|
wmGizmoMap *gzmap = region->gizmo_map;
|
||||||
|
wmGizmoGroup *gzgroup = WM_gizmomap_group_find(gzmap, view3d_gzgt_ruler_id);
|
||||||
|
|
||||||
|
RulerItem *ruler_item;
|
||||||
|
while ((ruler_item = gzgroup_ruler_item_first_get(gzgroup))) {
|
||||||
|
ruler_item_remove(C, gzgroup, ruler_item);
|
||||||
|
}
|
||||||
|
|
||||||
|
ED_region_tag_redraw_editor_overlays(region);
|
||||||
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
@ -1189,7 +1203,9 @@ static void gizmo_ruler_exit(bContext *C, wmGizmo *gz, const bool cancel)
|
||||||
ruler_state_set(ruler_info, RULER_STATE_NORMAL);
|
ruler_state_set(ruler_info, RULER_STATE_NORMAL);
|
||||||
}
|
}
|
||||||
/* We could convert only the current gizmo, for now just re-generate. */
|
/* We could convert only the current gizmo, for now just re-generate. */
|
||||||
view3d_ruler_to_gpencil(C, gzgroup);
|
if (view3d_ruler_to_gpencil(C, gzgroup)) {
|
||||||
|
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MEM_SAFE_FREE(gz->interaction_data);
|
MEM_SAFE_FREE(gz->interaction_data);
|
||||||
|
|
Loading…
Reference in New Issue
Couldn't the
gpl
be passed to this function? it's possible there are multiple windows with different scenes active.Some other ways to ensure rulers are valid could work too, e.g. refresh all rulers based on grease pencil data, but I don't think there is much/any advantage in this.