UI: Outliner "File Mode" Manage User Count #118691
|
@ -1686,6 +1686,8 @@ int UI_search_items_find_index(uiSearchItems *items, const char *name);
|
|||
*/
|
||||
void UI_but_hint_drawstr_set(uiBut *but, const char *string);
|
||||
void UI_but_icon_indicator_number_set(uiBut *but, const int indicator_number);
|
||||
void UI_but_icon_indicator_set(uiBut *but, const char *string);
|
||||
void UI_but_icon_indicator_color_set(uiBut *but, const uchar color[4]);
|
||||
|
||||
void UI_but_node_link_set(uiBut *but, bNodeSocket *socket, const float draw_color[4]);
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ struct IconFile {
|
|||
|
||||
struct IconTextOverlay {
|
||||
char text[5];
|
||||
uchar color[4] = {0};
|
||||
|
||||
};
|
||||
|
||||
#define UI_NO_ICON_OVERLAY_TEXT NULL
|
||||
|
|
|
@ -6258,6 +6258,16 @@ void UI_but_icon_indicator_number_set(uiBut *but, const int indicator_number)
|
|||
UI_icon_text_overlay_init_from_count(&but->icon_overlay_text, indicator_number);
|
||||
}
|
||||
|
||||
void UI_but_icon_indicator_set(uiBut *but, const char *string)
|
||||
{
|
||||
STRNCPY(but->icon_overlay_text.text, string);
|
||||
}
|
||||
|
||||
void UI_but_icon_indicator_color_set(uiBut *but, const uchar color[4])
|
||||
{
|
||||
copy_v4_v4_uchar(but->icon_overlay_text.color, color);
|
||||
}
|
||||
|
||||
void UI_but_node_link_set(uiBut *but, bNodeSocket *socket, const float draw_color[4])
|
||||
{
|
||||
but->flag |= UI_BUT_NODE_LINK;
|
||||
|
|
|
@ -1883,8 +1883,12 @@ static void icon_draw_texture(float x,
|
|||
if (show_indicator) {
|
||||
/* Handle the little numbers on top of the icon. */
|
||||
uchar text_color[4];
|
||||
UI_GetThemeColor3ubv(TH_TEXT, text_color);
|
||||
text_color[3] = 255;
|
||||
if (text_overlay->color[3]) {
|
||||
copy_v4_v4_uchar(text_color, text_overlay->color);
|
||||
}
|
||||
else {
|
||||
UI_GetThemeColor4ubv(TH_TEXT, text_color);
|
||||
}
|
||||
|
||||
uiFontStyle fstyle_small = *UI_FSTYLE_WIDGET;
|
||||
fstyle_small.points *= zoom_factor;
|
||||
|
|
|
@ -1761,25 +1761,26 @@ static void outliner_draw_userbuts(uiBlock *block,
|
|||
}
|
||||
|
||||
const TreeStoreElem *tselem = TREESTORE(te);
|
||||
if (tselem->type != TSE_SOME_ID) {
|
||||
ID *id = tselem->id;
|
||||
|
||||
if (tselem->type != TSE_SOME_ID || id->tag & LIB_TAG_EXTRAUSER) {
|
||||
return;
|
||||
}
|
||||
|
||||
uiBut *bt;
|
||||
ID *id = tselem->id;
|
||||
const char *tip = nullptr;
|
||||
char buf[BLI_STR_FORMAT_INT32_GROUPED_SIZE] = "";
|
||||
int but_flag = UI_BUT_DRAG_LOCK;
|
||||
const int real_users = id->us - ID_FAKE_USERS(id);
|
||||
const bool has_fake_user = id->flag & LIB_FAKEUSER;
|
||||
const bool is_linked = ID_IS_LINKED(id);
|
||||
const bool is_object = GS(id->name) == ID_OB;
|
||||
char overlay[5];
|
||||
BLI_str_format_integer_unit(overlay, id->us);
|
||||
|
||||
if (ID_IS_LINKED(id)) {
|
||||
but_flag |= UI_BUT_DISABLED;
|
||||
}
|
||||
|
||||
BLI_str_format_int_grouped(buf, id->us);
|
||||
if (is_object) {
|
||||
bt = uiDefBut(block,
|
||||
UI_BTYPE_BUT,
|
||||
1,
|
||||
buf,
|
||||
0,
|
||||
overlay,
|
||||
int(region->v2d.cur.xmax - OL_TOG_USER_BUTS_USERS),
|
||||
te->ys,
|
||||
UI_UNIT_X,
|
||||
|
@ -1787,21 +1788,32 @@ static void outliner_draw_userbuts(uiBlock *block,
|
|||
nullptr,
|
||||
0.0,
|
||||
0.0,
|
||||
TIP_("Number of users of this data-block"));
|
||||
UI_but_flag_enable(bt, but_flag);
|
||||
|
||||
if (id->flag & LIB_FAKEUSER) {
|
||||
tip = TIP_("Data-block will be retained using a fake user");
|
||||
TIP_("Number of users"));
|
||||
}
|
||||
else {
|
||||
tip = TIP_("Data-block has no users and will be deleted");
|
||||
|
||||
if (has_fake_user) {
|
||||
tip = is_linked ? TIP_("Item is protected from deletion") :
|
||||
TIP_("Click to remove protection from deletion");
|
||||
}
|
||||
else {
|
||||
if (real_users) {
|
||||
tip = is_linked ? TIP_("Item is not protected from deletion") :
|
||||
TIP_("Click to add protection from deletion");
|
||||
}
|
||||
else {
|
||||
tip = is_linked ?
|
||||
TIP_("Item has no users and will be removed") :
|
||||
TIP_("Item has no users and will be removed.\nClick to protect from deletion");
|
||||
}
|
||||
}
|
||||
|
||||
bt = uiDefIconButBitS(block,
|
||||
UI_BTYPE_ICON_TOGGLE,
|
||||
LIB_FAKEUSER,
|
||||
1,
|
||||
ICON_FAKE_USER_OFF,
|
||||
int(region->v2d.cur.xmax - OL_TOG_USER_BUTS_STATUS),
|
||||
int(region->v2d.cur.xmax - OL_TOG_USER_BUTS_USERS),
|
||||
te->ys,
|
||||
UI_UNIT_X,
|
||||
UI_UNIT_Y,
|
||||
|
@ -1809,8 +1821,23 @@ static void outliner_draw_userbuts(uiBlock *block,
|
|||
0,
|
||||
0,
|
||||
tip);
|
||||
|
||||
if (is_linked) {
|
||||
UI_but_flag_enable(bt, UI_BUT_DISABLED);
|
||||
}
|
||||
else {
|
||||
UI_but_func_set(bt, restrictbutton_id_user_toggle, id, nullptr);
|
||||
UI_but_flag_enable(bt, but_flag);
|
||||
/* Allow _inaccurate_ dragging over multiple toggles. */
|
||||
Hans Goudey
commented
Could you add a comment about why Could you add a comment about why `UI_BUT_DRAG_LOCK` is set here? I think it was discussed in the PR but I'm not sure myself here now.
Harley Acheson
commented
I'm not adding this flag here, it is also set here in existing code. But I wasn't sure what it did to be honest until now. It does not enable you to drag down a column of items to set/unset them all at once easily - that is allowed regardless. What this adds is it allows you to drag inaccurately once dragging starts. Without this flag you must stay within the bounds of the checkboxes, but with it you can veer off quite a bit and it will toggle them. Nice feature. Will add a comment. I'm not adding this flag here, it is also set here in existing code.
But I wasn't sure what it did to be honest until now. It does not enable you to drag down a column of items to set/unset them all at once easily - that is allowed regardless.
What this adds is it allows you to drag **inaccurately** once dragging starts. Without this flag you must stay within the bounds of the checkboxes, but with it you can veer off quite a bit and it will toggle them. Nice feature.
Will add a comment.
|
||||
UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
|
||||
}
|
||||
|
||||
if (!real_users && !has_fake_user) {
|
||||
uchar overlay_color[4];
|
||||
UI_GetThemeColor4ubv(TH_REDALERT, overlay_color);
|
||||
UI_but_icon_indicator_color_set(bt, overlay_color);
|
||||
}
|
||||
UI_but_icon_indicator_set(bt, overlay);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -4040,8 +4067,7 @@ void draw_outliner(const bContext *C)
|
|||
outliner_draw_rnabuts(block, region, space_outliner, buttons_start_x);
|
||||
UI_block_emboss_set(block, UI_EMBOSS_NONE_OR_STATUS);
|
||||
}
|
||||
else if (space_outliner->outlinevis == SO_ID_ORPHANS) {
|
||||
/* draw user toggle columns */
|
||||
else if (ELEM(space_outliner->outlinevis, SO_ID_ORPHANS, SO_LIBRARIES)) {
|
||||
outliner_draw_userbuts(block, region, space_outliner);
|
||||
}
|
||||
else if (space_outliner->outlinevis == SO_OVERRIDES_LIBRARY) {
|
||||
|
|
|
@ -203,8 +203,7 @@ enum eOLSetState {
|
|||
/* size constants */
|
||||
#define OL_Y_OFFSET 2
|
||||
|
||||
#define OL_TOG_USER_BUTS_USERS (UI_UNIT_X * 2.0f + V2D_SCROLL_WIDTH)
|
||||
#define OL_TOG_USER_BUTS_STATUS (UI_UNIT_X + V2D_SCROLL_WIDTH)
|
||||
#define OL_TOG_USER_BUTS_USERS (UI_UNIT_X * 1.2f + V2D_SCROLL_WIDTH)
|
||||
|
||||
#define OL_RNA_COLX (UI_UNIT_X * 15)
|
||||
#define OL_RNA_COL_SIZEX (UI_UNIT_X * 7.5f)
|
||||
|
|
Loading…
Reference in New Issue
I think the zero initialization here is unnecessary?
Weirdly it is. At least with my compiler...
uiBut initializes this like this:
And I would expect with C++17 that the above would recursively initialize all parts of this to zero. But instead I see the color value with initial 204 junk value instead. I have only managed to start off with zeros by initializing in the struct itself.
Good to know! No big deal, thanks for checking.