UI: Manage Unused Data Operator
An operator that brings up a window with Outliner in "Unused Data" mode to allow users fine-grained control over protecting and purging. Pull Request: https://projects.blender.org/blender/blender/pulls/118435
This commit is contained in:
parent
6872963e4f
commit
f04bd961fd
|
@ -239,7 +239,8 @@ class TOPBAR_MT_file_cleanup(Menu):
|
|||
layout = self.layout
|
||||
layout.separator()
|
||||
|
||||
props = layout.operator("outliner.orphans_purge", text="Unused Data-Blocks")
|
||||
layout.operator("outliner.orphans_purge", text="Purge Unused Data")
|
||||
layout.operator("outliner.orphans_manage", text="Manage Unused Data")
|
||||
|
||||
|
||||
class TOPBAR_MT_file(Menu):
|
||||
|
|
|
@ -71,6 +71,8 @@
|
|||
#include "tree/tree_element_rna.hh"
|
||||
#include "tree/tree_iterator.hh"
|
||||
|
||||
#include "wm_window.hh"
|
||||
|
||||
using namespace blender::ed::outliner;
|
||||
|
||||
namespace blender::ed::outliner {
|
||||
|
@ -2344,4 +2346,53 @@ void OUTLINER_OT_orphans_purge(wmOperatorType *ot)
|
|||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Manage Orphan Data-Blocks Operator
|
||||
* \{ */
|
||||
|
||||
static int outliner_orphans_manage_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
|
||||
{
|
||||
const int sizex = int(450.0f * UI_SCALE_FAC);
|
||||
const int sizey = int(450.0f * UI_SCALE_FAC);
|
||||
const rcti window_rect = {
|
||||
/*xmin*/ event->xy[0],
|
||||
/*xmax*/ event->xy[0] + sizex,
|
||||
/*ymin*/ event->xy[1],
|
||||
/*ymax*/ event->xy[1] + sizey,
|
||||
};
|
||||
|
||||
if (WM_window_open(C,
|
||||
IFACE_("Manage Unused Data"),
|
||||
&window_rect,
|
||||
SPACE_OUTLINER,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
WIN_ALIGN_LOCATION_CENTER,
|
||||
nullptr,
|
||||
nullptr) != nullptr)
|
||||
{
|
||||
SpaceOutliner *soutline = CTX_wm_space_outliner(C);
|
||||
soutline->outlinevis = SO_ID_ORPHANS;
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
void OUTLINER_OT_orphans_manage(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->idname = "OUTLINER_OT_orphans_manage";
|
||||
ot->name = "Manage Unused Data";
|
||||
ot->description = "Open a window to manage unused data";
|
||||
|
||||
/* callbacks */
|
||||
ot->invoke = outliner_orphans_manage_invoke;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
} // namespace blender::ed::outliner
|
||||
|
|
|
@ -507,6 +507,7 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot);
|
|||
void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot);
|
||||
|
||||
void OUTLINER_OT_orphans_purge(wmOperatorType *ot);
|
||||
void OUTLINER_OT_orphans_manage(wmOperatorType *ot);
|
||||
|
||||
/* `outliner_query.cc` */
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ void outliner_operatortypes()
|
|||
WM_operatortype_append(OUTLINER_OT_drivers_delete_selected);
|
||||
|
||||
WM_operatortype_append(OUTLINER_OT_orphans_purge);
|
||||
WM_operatortype_append(OUTLINER_OT_orphans_manage);
|
||||
|
||||
WM_operatortype_append(OUTLINER_OT_parent_drop);
|
||||
WM_operatortype_append(OUTLINER_OT_parent_clear);
|
||||
|
|
Loading…
Reference in New Issue