UI: Manage Unused Data Operator #118435

Merged
Harley Acheson merged 3 commits from Harley/blender:ManageUnused into main 2024-02-27 23:47:49 +01:00
4 changed files with 55 additions and 1 deletions

View File

@ -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):

View File

@ -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,
Harley marked this conversation as resolved Outdated

I think we should use a fixed size like the preferences for consistency, not this logic which I guess is slightly different from all other windows in Blender.

I think we should use a fixed size like the preferences for consistency, not this logic which I guess is slightly different from all other windows in Blender.
};
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)
Harley marked this conversation as resolved

Can use CTX_wm_space_outliner(C) directly.

Can use `CTX_wm_space_outliner(C)` directly.
{
/* 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

View File

@ -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` */

View File

@ -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);