UI: Cleanup Dialog to Manage Orphaned Data #106653
|
@ -12,6 +12,7 @@ set(INC
|
||||||
../../makesrna
|
../../makesrna
|
||||||
../../sequencer
|
../../sequencer
|
||||||
../../windowmanager
|
../../windowmanager
|
||||||
|
../../../../extern/fmtlib/include
|
||||||
|
|
||||||
# RNA_prototypes.h
|
# RNA_prototypes.h
|
||||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||||
|
@ -137,6 +138,7 @@ set(LIB
|
||||||
bf_editor_undo
|
bf_editor_undo
|
||||||
PRIVATE bf::intern::clog
|
PRIVATE bf::intern::clog
|
||||||
PRIVATE bf::intern::guardedalloc
|
PRIVATE bf::intern::guardedalloc
|
||||||
|
extern_fmtlib
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,10 @@
|
||||||
#include "tree/tree_element_rna.hh"
|
#include "tree/tree_element_rna.hh"
|
||||||
#include "tree/tree_iterator.hh"
|
#include "tree/tree_iterator.hh"
|
||||||
|
|
||||||
|
#include "wm_window.hh"
|
||||||
|
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
using namespace blender::ed::outliner;
|
using namespace blender::ed::outliner;
|
||||||
|
|
||||||
namespace blender::ed::outliner {
|
namespace blender::ed::outliner {
|
||||||
|
@ -2322,18 +2326,17 @@ static std::string orphan_desc(bContext *C, bool local, bool linked, bool recurs
|
||||||
bool is_first = true;
|
bool is_first = true;
|
||||||
for (int i = 0; i < INDEX_ID_MAX - 2; i++) {
|
for (int i = 0; i < INDEX_ID_MAX - 2; i++) {
|
||||||
if (num_tagged[i] != 0) {
|
if (num_tagged[i] != 0) {
|
||||||
if (!is_first) {
|
desc += fmt::format(
|
||||||
desc.append(", ");
|
"{}{} {}",
|
||||||
}
|
(is_first) ? "" : ", ",
|
||||||
Harley marked this conversation as resolved
Outdated
|
|||||||
else {
|
num_tagged[i],
|
||||||
is_first = false;
|
(num_tagged[i] > 1) ?
|
||||||
}
|
TIP_(BKE_idtype_idcode_to_name_plural(BKE_idtype_idcode_from_index(i))) :
|
||||||
desc.append<>(std::to_string(num_tagged[i]) + " ");
|
TIP_(BKE_idtype_idcode_to_name(BKE_idtype_idcode_from_index(i))));
|
||||||
desc.append(num_tagged[i] > 1 ?
|
is_first = false;
|
||||||
TIP_(BKE_idtype_idcode_to_name_plural(BKE_idtype_idcode_from_index(i))) :
|
|
||||||
TIP_(BKE_idtype_idcode_to_name(BKE_idtype_idcode_from_index(i))));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desc.empty()) {
|
if (desc.empty()) {
|
||||||
desc = "Nothing";
|
desc = "Nothing";
|
||||||
}
|
}
|
||||||
|
@ -2460,16 +2463,23 @@ void OUTLINER_OT_orphans_cleanup(wmOperatorType *ot)
|
||||||
ot->exec = outliner_orphans_cleanup_exec;
|
ot->exec = outliner_orphans_cleanup_exec;
|
||||||
Harley marked this conversation as resolved
Bastien Montagne
commented
Missing Missing `OPTYPE_UNDO` I think? Otherwise, a comment explaining why it's not needed would be good to have.
|
|||||||
|
|
||||||
/* flags */
|
/* flags */
|
||||||
ot->flag = OPTYPE_REGISTER;
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
Harley marked this conversation as resolved
Outdated
Bastien Montagne
commented
Would be better to adjust these default values to the available screen space? On some modern screens, 500x500 is a fairly small window... Would be better to adjust these default values to the available screen space? On some modern screens, 500x500 is a fairly small window...
|
|||||||
static int outliner_orphans_manage_exec(bContext *C, wmOperator * /*op*/)
|
static int outliner_orphans_manage_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
|
int width = 800;
|
||||||
|
int height = 500;
|
||||||
|
if (wm_get_screensize(&width, &height)) {
|
||||||
|
width /= 2;
|
||||||
|
height /= 2;
|
||||||
|
}
|
||||||
|
|
||||||
const rcti window_rect = {
|
const rcti window_rect = {
|
||||||
/*xmin*/ 0,
|
/*xmin*/ 0,
|
||||||
/*xmax*/ 500,
|
/*xmax*/ width,
|
||||||
/*ymin*/ 0,
|
/*ymin*/ 0,
|
||||||
/*ymax*/ 500,
|
/*ymax*/ height,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (WM_window_open(C,
|
if (WM_window_open(C,
|
||||||
|
@ -2485,8 +2495,9 @@ static int outliner_orphans_manage_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
SpaceOutliner *soutline = (SpaceOutliner *)CTX_wm_area(C)->spacedata.first;
|
SpaceOutliner *soutline = (SpaceOutliner *)CTX_wm_area(C)->spacedata.first;
|
||||||
soutline->outlinevis = SO_ID_ORPHANS;
|
soutline->outlinevis = SO_ID_ORPHANS;
|
||||||
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OUTLINER_OT_orphans_manage(wmOperatorType *ot)
|
void OUTLINER_OT_orphans_manage(wmOperatorType *ot)
|
||||||
|
|
Loading…
Reference in New Issue
No reason to use
append
on strings afaik, just use+=
operator?That kind of formatting could also benefit from using
fmt::format
from ourextern/fmtlib
library.