Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/context.c
| Show All 11 Lines | |||||
| #include "DNA_collection_types.h" | #include "DNA_collection_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_linestyle_types.h" | #include "DNA_linestyle_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_video_edit_types.h" | |||||
| #include "DNA_view3d_types.h" | #include "DNA_view3d_types.h" | ||||
| #include "DNA_windowmanager_types.h" | #include "DNA_windowmanager_types.h" | ||||
| #include "DNA_workspace_types.h" | #include "DNA_workspace_types.h" | ||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | struct { | ||||
| */ | */ | ||||
| struct bContextPollMsgDyn_Params operator_poll_msg_dyn_params; | struct bContextPollMsgDyn_Params operator_poll_msg_dyn_params; | ||||
| } wm; | } wm; | ||||
| /* data context */ | /* data context */ | ||||
| struct { | struct { | ||||
| struct Main *main; | struct Main *main; | ||||
| struct Scene *scene; | struct Scene *scene; | ||||
| struct VideoEdit *video_edit; | |||||
| int recursion; | int recursion; | ||||
| /** True if python is initialized. */ | /** True if python is initialized. */ | ||||
| bool py_init; | bool py_init; | ||||
| void *py_context; | void *py_context; | ||||
| /** | /** | ||||
| * If we need to remove members, do so in a copy | * If we need to remove members, do so in a copy | ||||
| * (keep this to check if the copy needs freeing). | * (keep this to check if the copy needs freeing). | ||||
| ▲ Show 20 Lines • Show All 861 Lines • ▼ Show 20 Lines | void CTX_wm_manager_set(bContext *C, wmWindowManager *wm) | ||||
| C->wm.area = NULL; | C->wm.area = NULL; | ||||
| C->wm.region = NULL; | C->wm.region = NULL; | ||||
| } | } | ||||
| #ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||
| # define PYCTX_REGION_MEMBERS "region", "region_data" | # define PYCTX_REGION_MEMBERS "region", "region_data" | ||||
| # define PYCTX_AREA_MEMBERS "area", "space_data", PYCTX_REGION_MEMBERS | # define PYCTX_AREA_MEMBERS "area", "space_data", PYCTX_REGION_MEMBERS | ||||
| # define PYCTX_SCREEN_MEMBERS "screen", PYCTX_AREA_MEMBERS | # define PYCTX_SCREEN_MEMBERS "screen", PYCTX_AREA_MEMBERS | ||||
| # define PYCTX_WINDOW_MEMBERS "window", "scene", "workspace", PYCTX_SCREEN_MEMBERS | # define PYCTX_WINDOW_MEMBERS "window", "scene", "video_edit", "workspace", PYCTX_SCREEN_MEMBERS | ||||
| #endif | #endif | ||||
| void CTX_wm_window_set(bContext *C, wmWindow *win) | void CTX_wm_window_set(bContext *C, wmWindow *win) | ||||
| { | { | ||||
| C->wm.window = win; | C->wm.window = win; | ||||
| if (win) { | if (win) { | ||||
| C->data.scene = win->scene; | C->data.scene = win->scene; | ||||
| C->data.video_edit = win->video_edit; | |||||
| } | } | ||||
| C->wm.workspace = (win) ? BKE_workspace_active_get(win->workspace_hook) : NULL; | C->wm.workspace = (win) ? BKE_workspace_active_get(win->workspace_hook) : NULL; | ||||
| C->wm.screen = (win) ? BKE_workspace_active_screen_get(win->workspace_hook) : NULL; | C->wm.screen = (win) ? BKE_workspace_active_screen_get(win->workspace_hook) : NULL; | ||||
| C->wm.area = NULL; | C->wm.area = NULL; | ||||
| C->wm.region = NULL; | C->wm.region = NULL; | ||||
| #ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||
| if (C->data.py_context != NULL) { | if (C->data.py_context != NULL) { | ||||
| ▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | if (win) { | ||||
| if (view_layer) { | if (view_layer) { | ||||
| return view_layer; | return view_layer; | ||||
| } | } | ||||
| } | } | ||||
| return BKE_view_layer_default_view(scene); | return BKE_view_layer_default_view(scene); | ||||
| } | } | ||||
| VideoEdit *CTX_data_video_edit(const bContext *C) | |||||
| { | |||||
| VideoEdit *video_edit; | |||||
| if (ctx_data_pointer_verify(C, "video_edit", (void *)&video_edit)) { | |||||
| return video_edit; | |||||
| } | |||||
| return C->data.video_edit; | |||||
| } | |||||
| RenderEngineType *CTX_data_engine_type(const bContext *C) | RenderEngineType *CTX_data_engine_type(const bContext *C) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| return RE_engines_find(scene->r.engine); | return RE_engines_find(scene->r.engine); | ||||
| } | } | ||||
| LayerCollection *CTX_data_layer_collection(const bContext *C) | LayerCollection *CTX_data_layer_collection(const bContext *C) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | |||||
| #ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||
| if (C->data.py_context != NULL) { | if (C->data.py_context != NULL) { | ||||
| BPY_context_dict_clear_members(C, "scene"); | BPY_context_dict_clear_members(C, "scene"); | ||||
| } | } | ||||
| #endif | #endif | ||||
| } | } | ||||
| void CTX_data_video_edit_set(bContext *C, VideoEdit *video_edit) | |||||
| { | |||||
| C->data.video_edit = video_edit; | |||||
| #ifdef WITH_PYTHON | |||||
| if (C->data.py_context != NULL) { | |||||
| BPY_context_dict_clear_members(C, "video_edit"); | |||||
| } | |||||
| #endif | |||||
| } | |||||
| ToolSettings *CTX_data_tool_settings(const bContext *C) | ToolSettings *CTX_data_tool_settings(const bContext *C) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| if (scene) { | if (scene) { | ||||
| return scene->toolsettings; | return scene->toolsettings; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 253 Lines • Show Last 20 Lines | |||||