Outliner: Use restriction columns in "Orphaned Datablocks" view to manage usercounts
When in "Orphaned Datablocks" mode, the restriction columns are used to display usercount indicators and toggles to manage whether datablocks get saved or not. * The first column shows an icon to indicate whether that datablock is going to get saved. A tick indicates the datablock will be saved, while a cross indicates the opposite. Clicking on this changes whether the datablock will get saved. * The second column shows the usercount. * The third column shows whether the datablock has a fake user. Notes: * The second and third columns are pretty much redundant (functionally speaking). While it is possible to also toggle fake users by clicking in the third column, its role here is more as information for power users (and hopefully to allow others to connect the relationship between the saved/not saved status and fake users) * I'm not sure whether the use of the X here for the "not saved" state stands out enough to draw user's attention to items which are "in the danger zone".
This commit is contained in:
parent
030b0aab43
commit
16689a1db0
|
@ -447,6 +447,20 @@ static void restrictbutton_gr_restrict_render(bContext *C, void *poin, void *poi
|
|||
WM_event_add_notifier(C, NC_GROUP, NULL);
|
||||
}
|
||||
|
||||
static void restrictbutton_id_user_toggle(bContext *C, void *poin, void *UNUSED(poin2))
|
||||
{
|
||||
ID *id = (ID *)poin;
|
||||
|
||||
BLI_assert(id != NULL);
|
||||
|
||||
if (id->flag & LIB_FAKEUSER) {
|
||||
id_us_plus(id);
|
||||
}
|
||||
else {
|
||||
id_us_min(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void namebutton_cb(bContext *C, void *tsep, char *oldname)
|
||||
{
|
||||
|
@ -792,6 +806,65 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
|
|||
}
|
||||
}
|
||||
|
||||
static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOops *soops, ListBase *lb)
|
||||
{
|
||||
uiBut *bt;
|
||||
TreeElement *te;
|
||||
TreeStoreElem *tselem;
|
||||
|
||||
for (te = lb->first; te; te = te->next) {
|
||||
tselem = TREESTORE(te);
|
||||
if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) {
|
||||
if (tselem->type == 0) {
|
||||
ID *id = tselem->id;
|
||||
const char *tip = NULL;
|
||||
int icon = ICON_NONE;
|
||||
char buf[16] = "";
|
||||
int but_flag = UI_BUT_DRAG_LOCK;
|
||||
|
||||
if (id->lib)
|
||||
but_flag |= UI_BUT_DISABLED;
|
||||
|
||||
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
||||
|
||||
if (id->flag & LIB_FAKEUSER) {
|
||||
icon = ICON_FILE_TICK;
|
||||
tip = TIP_("Datablock will be retained using a fake user");
|
||||
}
|
||||
else {
|
||||
icon = ICON_X;
|
||||
tip = TIP_("Datablock has no users and will be deleted");
|
||||
}
|
||||
bt = uiDefIconButBitS(block, UI_BTYPE_TOGGLE, LIB_FAKEUSER, 1, icon,
|
||||
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y,
|
||||
&id->flag, 0, 0, 0, 0, tip);
|
||||
UI_but_func_set(bt, restrictbutton_id_user_toggle, id, NULL);
|
||||
UI_but_flag_enable(bt, but_flag);
|
||||
|
||||
|
||||
BLI_str_format_int_grouped(buf, id->us);
|
||||
bt = uiDefBut(block, UI_BTYPE_BUT, 1, buf,
|
||||
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys,
|
||||
UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0,
|
||||
TIP_("Number of users of this datablock"));
|
||||
UI_but_flag_enable(bt, but_flag);
|
||||
|
||||
|
||||
bt = uiDefButBitS(block, UI_BTYPE_TOGGLE, LIB_FAKEUSER, 1, (id->flag & LIB_FAKEUSER) ? "F" : " ",
|
||||
(int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y,
|
||||
&id->flag, 0, 0, 0, 0,
|
||||
TIP_("Datablock has a 'fake' user which will keep it in the flie even if nothing else uses it"));
|
||||
UI_but_func_set(bt, restrictbutton_id_user_toggle, id, NULL);
|
||||
UI_but_flag_enable(bt, but_flag);
|
||||
|
||||
UI_block_emboss_set(block, UI_EMBOSS);
|
||||
}
|
||||
}
|
||||
|
||||
if (TSELEM_OPEN(tselem, soops)) outliner_draw_userbuts(block, ar, soops, &te->subtree);
|
||||
}
|
||||
}
|
||||
|
||||
static void outliner_draw_rnacols(ARegion *ar, int sizex)
|
||||
{
|
||||
View2D *v2d = &ar->v2d;
|
||||
|
@ -1779,6 +1852,11 @@ void draw_outliner(const bContext *C)
|
|||
outliner_draw_rnacols(ar, sizex_rna);
|
||||
outliner_draw_rnabuts(block, scene, ar, soops, sizex_rna, &soops->tree);
|
||||
}
|
||||
else if ((soops->outlinevis == SO_ID_ORPHANS) && !(soops->flag & SO_HIDE_RESTRICTCOLS)) {
|
||||
/* draw user toggle columns */
|
||||
outliner_draw_restrictcols(ar);
|
||||
outliner_draw_userbuts(block, ar, soops, &soops->tree);
|
||||
}
|
||||
else if (!(soops->flag & SO_HIDE_RESTRICTCOLS)) {
|
||||
/* draw restriction columns */
|
||||
outliner_draw_restrictcols(ar);
|
||||
|
|
Loading…
Reference in New Issue