Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/context.c
| Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | struct { | ||||
| const char *operator_poll_msg; /* reason for poll failing */ | const char *operator_poll_msg; /* reason for poll failing */ | ||||
| } wm; | } wm; | ||||
| /* data context */ | /* data context */ | ||||
| struct { | struct { | ||||
| struct Main *main; | struct Main *main; | ||||
| struct Scene *scene; | struct Scene *scene; | ||||
| struct SceneLayer *render_layer; | struct SceneLayer *render_layer; | ||||
| struct SceneCollection *scene_collection; | |||||
| int recursion; | int recursion; | ||||
| int py_init; /* true if python is initialized */ | int py_init; /* true if python is initialized */ | ||||
| void *py_context; | void *py_context; | ||||
| } data; | } data; | ||||
| /* data evaluation */ | /* data evaluation */ | ||||
| #if 0 | #if 0 | ||||
| ▲ Show 20 Lines • Show All 807 Lines • ▼ Show 20 Lines | Scene *CTX_data_scene(const bContext *C) | ||||
| else | else | ||||
| return C->data.scene; | return C->data.scene; | ||||
| } | } | ||||
| SceneLayer *CTX_data_scene_layer(const bContext *C) | SceneLayer *CTX_data_scene_layer(const bContext *C) | ||||
| { | { | ||||
| SceneLayer *sl; | SceneLayer *sl; | ||||
| if (ctx_data_pointer_verify(C, "render_layer", (void *)&sl)) { | if (ctx_data_pointer_verify(C, "render_layer", (void *)&sl)) { | ||||
sergey: Picky: Always use parenthesis, avoid noise and possible mistakes in the future. | |||||
Done Inline ActionsBy parenthesis you mean curly brackets? dfelinto: By parenthesis you mean curly brackets? | |||||
Done Inline Actionsyes, {/} mont29: yes, `{`/`}` | |||||
| return sl; | return sl; | ||||
| } | } | ||||
| else { | else { | ||||
| return C->data.render_layer; | return C->data.render_layer; | ||||
| } | } | ||||
| } | } | ||||
| SceneCollection *CTX_data_scene_collection(const bContext *C) | |||||
| { | |||||
| SceneCollection *sc; | |||||
| if (ctx_data_pointer_verify(C, "scene_collection", (void *)&sc)) { | |||||
| return sc; | |||||
| } | |||||
| else { | |||||
| return C->data.scene_collection; | |||||
| } | |||||
| } | |||||
| int CTX_data_mode_enum(const bContext *C) | int CTX_data_mode_enum(const bContext *C) | ||||
| { | { | ||||
| Object *obedit = CTX_data_edit_object(C); | Object *obedit = CTX_data_edit_object(C); | ||||
| if (obedit) { | if (obedit) { | ||||
| switch (obedit->type) { | switch (obedit->type) { | ||||
| case OB_MESH: | case OB_MESH: | ||||
| return CTX_MODE_EDIT_MESH; | return CTX_MODE_EDIT_MESH; | ||||
| ▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | void CTX_data_scene_set(bContext *C, Scene *scene) | ||||
| TODO_LAYER_CONTEXT | TODO_LAYER_CONTEXT | ||||
| /* render_layer comes from workspace (or even viewport) actually | /* render_layer comes from workspace (or even viewport) actually | ||||
| * this is only while we wait for workspace changes to be merged | * this is only while we wait for workspace changes to be merged | ||||
| */ | */ | ||||
| CTX_data_scene_layer_set(C, scene->render_layers.last); | CTX_data_scene_layer_set(C, scene->render_layers.last); | ||||
| } | } | ||||
| void CTX_data_scene_collection_set(bContext *C, SceneCollection *sc) | |||||
| { | |||||
| C->data.scene_collection = sc; | |||||
| } | |||||
| void CTX_data_scene_layer_set(bContext *C, SceneLayer *sl) | void CTX_data_scene_layer_set(bContext *C, SceneLayer *sl) | ||||
| { | { | ||||
| C->data.render_layer = sl; | C->data.render_layer = sl; | ||||
| /* update the related data */ | |||||
| LayerCollection *lc = BKE_layer_collection_active(sl); | |||||
| CTX_data_scene_collection_set(C, lc->scene_collection); | |||||
| } | } | ||||
| 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 56 Lines • ▼ Show 20 Lines | int CTX_data_selectable_bases(const bContext *C, ListBase *list) | ||||
| return ctx_data_collection_get(C, "selectable_bases", list); | return ctx_data_collection_get(C, "selectable_bases", list); | ||||
| } | } | ||||
| struct Object *CTX_data_active_object(const bContext *C) | struct Object *CTX_data_active_object(const bContext *C) | ||||
| { | { | ||||
| return ctx_data_pointer_get(C, "active_object"); | return ctx_data_pointer_get(C, "active_object"); | ||||
| } | } | ||||
| struct Base *CTX_data_active_base(const bContext *C) | struct ObjectBase *CTX_data_active_base(const bContext *C) | ||||
| { | { | ||||
| return ctx_data_pointer_get(C, "active_base"); | return ctx_data_pointer_get(C, "active_base"); | ||||
| } | } | ||||
| struct Object *CTX_data_edit_object(const bContext *C) | struct Object *CTX_data_edit_object(const bContext *C) | ||||
| { | { | ||||
| return ctx_data_pointer_get(C, "edit_object"); | return ctx_data_pointer_get(C, "edit_object"); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 111 Lines • Show Last 20 Lines | |||||
Picky: Always use parenthesis, avoid noise and possible mistakes in the future.