diff options
author | Bastien Montagne <mont29> | 2021-10-13 14:33:58 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-10-13 14:35:17 +0300 |
commit | 59113df8ec3c90c123c6c215083365aca4ea4732 (patch) | |
tree | 031910cf187afab2997be1041ac578ce31ecb05e /source | |
parent | 8c0698460be9e435560b0b00474900492a614ac0 (diff) |
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
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 458ffd3f053..755a0fce7bc 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -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); + } } } |