diff options
author | Bastien Montagne <bastien@blender.org> | 2021-09-23 11:43:31 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-09-23 12:01:00 +0300 |
commit | 3042994c91667f9c8a1ecadc11e69c012c33d581 (patch) | |
tree | 304a8b52bf2abf07661ad73254741f74d0c02e1e /source/blender/windowmanager/intern/wm_files_link.c | |
parent | 12924ed573c9c4faf025a7cd2f61c53732667ad5 (diff) |
Link/Append: Refactor flags.
Flags controlling link/append code are split between two enums, one in
`DNA_space_types.h` and one in `BLO_readfile.h`.
This commit:
- Moves flags exclusively used in WM and BLO code to `eBLOLibLinkFlags`
in `BLO_readfile.h`. Flags in `eFileSel_Params_Flag` from
`DNA_space_types.h` are now only the ones effectively used by the
file browser editor code too.
- Fixes some internal utils in `readfile.c` still taking `short` flag
parameter instead of proper `int` one.
NOTE: there are a few other flags that could probably be moved to
`eBLOLibLinkFlags` (at the very least `FILE_LINK`, probably also
`FILE_AUTOSELECT` and `FILE_ACTIVE_COLLECTION`), since those are not
effectively used by the file browser, and control linking/appending
behavior, not filebrowser behavior.
However for now think it's safer to not touch that.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_files_link.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_files_link.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c index 321c7da3765..820a5990479 100644 --- a/source/blender/windowmanager/intern/wm_files_link.c +++ b/source/blender/windowmanager/intern/wm_files_link.c @@ -127,10 +127,10 @@ static int wm_link_append_invoke(bContext *C, wmOperator *op, const wmEvent *UNU return OPERATOR_RUNNING_MODAL; } -static short wm_link_append_flag(wmOperator *op) +static int wm_link_append_flag(wmOperator *op) { PropertyRNA *prop; - short flag = 0; + int flag = 0; if (RNA_boolean_get(op->ptr, "autoselect")) { flag |= FILE_AUTOSELECT; @@ -147,17 +147,17 @@ static short wm_link_append_flag(wmOperator *op) } else { if (RNA_boolean_get(op->ptr, "use_recursive")) { - flag |= FILE_APPEND_RECURSIVE; + flag |= BLO_LIBLINK_APPEND_RECURSIVE; } if (RNA_boolean_get(op->ptr, "set_fake")) { - flag |= FILE_APPEND_SET_FAKEUSER; + flag |= BLO_LIBLINK_APPEND_SET_FAKEUSER; } } if (RNA_boolean_get(op->ptr, "instance_collections")) { - flag |= FILE_COLLECTION_INSTANCE; + flag |= BLO_LIBLINK_COLLECTION_INSTANCE; } if (RNA_boolean_get(op->ptr, "instance_object_data")) { - flag |= FILE_OBDATA_INSTANCE; + flag |= BLO_LIBLINK_OBDATA_INSTANCE; } return flag; @@ -396,7 +396,7 @@ static void wm_append_loose_data_instantiate(WMLinkAppendData *lapp_data, LinkNode *itemlink; Collection *active_collection = NULL; - const bool do_obdata = (lapp_data->flag & FILE_OBDATA_INSTANCE) != 0; + const bool do_obdata = (lapp_data->flag & BLO_LIBLINK_OBDATA_INSTANCE) != 0; const bool object_set_selected = (lapp_data->flag & FILE_AUTOSELECT) != 0; /* Do NOT make base active here! screws up GUI stuff, @@ -472,7 +472,7 @@ static void wm_append_loose_data_instantiate(WMLinkAppendData *lapp_data, /* In case user requested instantiation of collections as empties, we do so for the one they * explicitly selected (originally directly linked IDs). */ - if ((lapp_data->flag & FILE_COLLECTION_INSTANCE) != 0 && + if ((lapp_data->flag & BLO_LIBLINK_COLLECTION_INSTANCE) != 0 && (item->append_tag & WM_APPEND_TAG_INDIRECT) == 0) { /* BKE_object_add(...) messes with the selection. */ Object *ob = BKE_object_add_only_object(bmain, OB_EMPTY, collection->id.name + 2); @@ -626,8 +626,8 @@ static void wm_append_do(WMLinkAppendData *lapp_data, { BLI_assert((lapp_data->flag & FILE_LINK) == 0); - const bool do_recursive = (lapp_data->flag & FILE_APPEND_RECURSIVE) != 0; - const bool set_fakeuser = (lapp_data->flag & FILE_APPEND_SET_FAKEUSER) != 0; + const bool do_recursive = (lapp_data->flag & BLO_LIBLINK_APPEND_RECURSIVE) != 0; + const bool set_fakeuser = (lapp_data->flag & BLO_LIBLINK_APPEND_SET_FAKEUSER) != 0; LinkNode *itemlink; @@ -1057,7 +1057,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - short flag = wm_link_append_flag(op); + int flag = wm_link_append_flag(op); const bool do_append = (flag & FILE_LINK) == 0; /* sanity checks for flag */ @@ -1066,12 +1066,10 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) RPT_WARNING, "Scene '%s' is linked, instantiation of objects is disabled", scene->id.name + 2); - flag &= ~(FILE_COLLECTION_INSTANCE | FILE_OBDATA_INSTANCE); + flag &= ~(BLO_LIBLINK_COLLECTION_INSTANCE | BLO_LIBLINK_OBDATA_INSTANCE); scene = NULL; } - /* We need to add nothing from #eBLOLibLinkFlags to flag here. */ - /* from here down, no error returns */ if (view_layer && RNA_boolean_get(op->ptr, "autoselect")) { @@ -1305,7 +1303,8 @@ static ID *wm_file_link_append_datablock_ex(Main *bmain, BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, true); /* Define working data, with just the one item we want to link. */ - WMLinkAppendData *lapp_data = wm_link_append_data_new(do_append ? FILE_APPEND_RECURSIVE : 0); + WMLinkAppendData *lapp_data = wm_link_append_data_new(do_append ? BLO_LIBLINK_APPEND_RECURSIVE : + 0); wm_link_append_data_library_add(lapp_data, filepath); WMLinkAppendDataItem *item = wm_link_append_data_item_add(lapp_data, id_name, id_code, NULL); |