Fix T92113: On assets, replace "Fake User" button with "Clear Asset" button.
Change is simple enough, but we abuse a bit the UI code here to get a similar 'look' as the fake user button for the new Asset one, while still being able to call an operator instead of editing directly a RNA value. Reviewed By: Severin, sybren Maniphest Tasks: T92113 Differential Revision: https://developer.blender.org/D12839
This commit is contained in:
parent
8c0698460b
commit
59113df8ec
Notes:
blender-bot
2023-02-14 06:42:54 +01:00
Referenced by issue #92113, On assets, replace "Fake User" button with "Clear Asset" button
|
@ -1112,24 +1112,41 @@ static void template_ID(const bContext *C,
|
|||
UI_but_flag_enable(but, UI_BUT_REDALERT);
|
||||
}
|
||||
|
||||
if (!ID_IS_LINKED(id) && !(ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_OB, ID_WS)) &&
|
||||
(hide_buttons == false)) {
|
||||
uiDefIconButR(block,
|
||||
UI_BTYPE_ICON_TOGGLE,
|
||||
0,
|
||||
ICON_FAKE_USER_OFF,
|
||||
0,
|
||||
0,
|
||||
UI_UNIT_X,
|
||||
UI_UNIT_Y,
|
||||
&idptr,
|
||||
"use_fake_user",
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
-1,
|
||||
-1,
|
||||
NULL);
|
||||
if (!ID_IS_LINKED(id)) {
|
||||
if (ID_IS_ASSET(id)) {
|
||||
uiDefIconButO(block,
|
||||
/* Using `_N` version allows us to get the 'active' state by default. */
|
||||
UI_BTYPE_ICON_TOGGLE_N,
|
||||
"ASSET_OT_clear",
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
/* 'active' state of a toggle button uses icon + 1, so to get proper asset
|
||||
* icon we need to pass its value - 1 here. */
|
||||
ICON_ASSET_MANAGER - 1,
|
||||
0,
|
||||
0,
|
||||
UI_UNIT_X,
|
||||
UI_UNIT_Y,
|
||||
NULL);
|
||||
}
|
||||
else if (!(ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_OB, ID_WS)) &&
|
||||
(hide_buttons == false)) {
|
||||
uiDefIconButR(block,
|
||||
UI_BTYPE_ICON_TOGGLE,
|
||||
0,
|
||||
ICON_FAKE_USER_OFF,
|
||||
0,
|
||||
0,
|
||||
UI_UNIT_X,
|
||||
UI_UNIT_Y,
|
||||
&idptr,
|
||||
"use_fake_user",
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
-1,
|
||||
-1,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue