Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/context.c
| Show First 20 Lines • Show All 1,442 Lines • ▼ Show 20 Lines | int CTX_data_editable_gpencil_layers(const bContext *C, ListBase *list) | ||||
| return ctx_data_collection_get(C, "editable_gpencil_layers", list); | return ctx_data_collection_get(C, "editable_gpencil_layers", list); | ||||
| } | } | ||||
| int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list) | int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list) | ||||
| { | { | ||||
| return ctx_data_collection_get(C, "editable_gpencil_strokes", list); | return ctx_data_collection_get(C, "editable_gpencil_strokes", list); | ||||
| } | } | ||||
| const AssetLibraryReference *CTX_wm_asset_library(const bContext *C) | |||||
| { | |||||
| return ctx_data_pointer_get(C, "asset_library"); | |||||
| } | |||||
| AssetHandle CTX_wm_asset_handle(const bContext *C, bool *r_is_valid) | |||||
| { | |||||
| AssetHandle *asset_handle_p = | |||||
| (AssetHandle *)CTX_data_pointer_get_type(C, "asset_handle", &RNA_AssetHandle).data; | |||||
| if (asset_handle_p) { | |||||
| *r_is_valid = true; | |||||
| return *asset_handle_p; | |||||
| } | |||||
| /* If the asset handle was not found in context directly, try if there's an active file with | |||||
| * asset data there instead. Not nice to have this here, would be better to have this in | |||||
| * `ED_asset.h`, but we can't include that in BKE. Even better would be not needing this at all | |||||
| * and being able to have editors return this in the usual `context` callback. But that would | |||||
| * require returning a non-owning pointer, which we don't have in the Asset Browser (yet). */ | |||||
| FileDirEntry *file = | |||||
| (FileDirEntry *)CTX_data_pointer_get_type(C, "active_file", &RNA_FileSelectEntry).data; | |||||
| if (file && file->asset_data) { | |||||
| *r_is_valid = true; | |||||
| return (AssetHandle){.file_data = file}; | |||||
| } | |||||
| *r_is_valid = false; | |||||
| return (AssetHandle){0}; | |||||
| } | |||||
| Depsgraph *CTX_data_depsgraph_pointer(const bContext *C) | Depsgraph *CTX_data_depsgraph_pointer(const bContext *C) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer); | Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer); | ||||
| /* Dependency graph might have been just allocated, and hence it will not be marked. | /* Dependency graph might have been just allocated, and hence it will not be marked. | ||||
| * This confuses redo system due to the lack of flushing changes back to the original data. | * This confuses redo system due to the lack of flushing changes back to the original data. | ||||
| Show All 29 Lines | |||||