Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_buttons/buttons_context.c
| Show First 20 Lines • Show All 180 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| PointerRNA *ptr = &path->ptr[path->len - 1]; | PointerRNA *ptr = &path->ptr[path->len - 1]; | ||||
| /* if we already have a (pinned) Collection, we're done */ | /* if we already have a (pinned) Collection, we're done */ | ||||
| if (RNA_struct_is_a(ptr->type, &RNA_LayerCollection)) { | if (RNA_struct_is_a(ptr->type, &RNA_LayerCollection)) { | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| SceneLayer *sl = ptr->data; | ViewLayer *sl = ptr->data; | ||||
| LayerCollection *sc = BKE_layer_collection_get_active(sl); | LayerCollection *sc = BKE_layer_collection_get_active(sl); | ||||
| if (sc) { | if (sc) { | ||||
| RNA_pointer_create(NULL, &RNA_LayerCollection, sc, &path->ptr[path->len]); | RNA_pointer_create(NULL, &RNA_LayerCollection, sc, &path->ptr[path->len]); | ||||
| path->len++; | path->len++; | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| /* no path to a collection possible */ | /* no path to a collection possible */ | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static int buttons_context_path_object(ButsContextPath *path) | static int buttons_context_path_object(ButsContextPath *path) | ||||
| { | { | ||||
| PointerRNA *ptr = &path->ptr[path->len - 1]; | PointerRNA *ptr = &path->ptr[path->len - 1]; | ||||
| /* if we already have a (pinned) object, we're done */ | /* if we already have a (pinned) object, we're done */ | ||||
| if (RNA_struct_is_a(ptr->type, &RNA_Object)) { | if (RNA_struct_is_a(ptr->type, &RNA_Object)) { | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| SceneLayer *sl = ptr->data; | ViewLayer *sl = ptr->data; | ||||
| Object *ob = (sl->basact) ? sl->basact->object : NULL; | Object *ob = (sl->basact) ? sl->basact->object : NULL; | ||||
| if (ob) { | if (ob) { | ||||
| RNA_id_pointer_create(&ob->id, &path->ptr[path->len]); | RNA_id_pointer_create(&ob->id, &path->ptr[path->len]); | ||||
| path->len++; | path->len++; | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | static int buttons_context_path_brush(const bContext *C, ButsContextPath *path) | ||||
| if (RNA_struct_is_a(ptr->type, &RNA_Brush)) { | if (RNA_struct_is_a(ptr->type, &RNA_Brush)) { | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| /* if we have a scene, use the toolsettings brushes */ | /* if we have a scene, use the toolsettings brushes */ | ||||
| else if (buttons_context_path_scene(path)) { | else if (buttons_context_path_scene(path)) { | ||||
| scene = path->ptr[path->len - 1].data; | scene = path->ptr[path->len - 1].data; | ||||
| if (scene) { | if (scene) { | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| br = BKE_paint_brush(BKE_paint_get_active(scene, sl)); | br = BKE_paint_brush(BKE_paint_get_active(scene, sl)); | ||||
| } | } | ||||
| if (br) { | if (br) { | ||||
| RNA_id_pointer_create((ID *)br, &path->ptr[path->len]); | RNA_id_pointer_create((ID *)br, &path->ptr[path->len]); | ||||
| path->len++; | path->len++; | ||||
| return 1; | return 1; | ||||
| ▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | static int buttons_context_path_texture(const bContext *C, ButsContextPath *path, ButsContextTexture *ct) | ||||
| /* no path to a texture possible */ | /* no path to a texture possible */ | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| #ifdef WITH_FREESTYLE | #ifdef WITH_FREESTYLE | ||||
| static bool buttons_context_linestyle_pinnable(const bContext *C) | static bool buttons_context_linestyle_pinnable(const bContext *C) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *active_scene_layer; | ViewLayer *active_view_layer; | ||||
| FreestyleConfig *config; | FreestyleConfig *config; | ||||
| SpaceButs *sbuts; | SpaceButs *sbuts; | ||||
| /* if Freestyle is disabled in the scene */ | /* if Freestyle is disabled in the scene */ | ||||
| if ((scene->r.mode & R_EDGE_FRS) == 0) { | if ((scene->r.mode & R_EDGE_FRS) == 0) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* if Freestyle is not in the Parameter Editor mode */ | /* if Freestyle is not in the Parameter Editor mode */ | ||||
| active_scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | active_view_layer = BLI_findlink(&scene->view_layers, scene->active_view_layer); | ||||
| config = &active_scene_layer->freestyle_config; | config = &active_view_layer->freestyle_config; | ||||
| if (config->mode != FREESTYLE_CONTROL_EDITOR_MODE) { | if (config->mode != FREESTYLE_CONTROL_EDITOR_MODE) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* if the scene has already been pinned */ | /* if the scene has already been pinned */ | ||||
| sbuts = CTX_wm_space_buts(C); | sbuts = CTX_wm_space_buts(C); | ||||
| if (sbuts->pinid && sbuts->pinid == &scene->id) { | if (sbuts->pinid && sbuts->pinid == &scene->id) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| Show All 20 Lines | if (sbuts->pinid) { | ||||
| id = sbuts->pinid; | id = sbuts->pinid; | ||||
| RNA_id_pointer_create(id, &path->ptr[0]); | RNA_id_pointer_create(id, &path->ptr[0]); | ||||
| path->len++; | path->len++; | ||||
| } | } | ||||
| /* No pinned root, use scene or workspace as initial root. */ | /* No pinned root, use scene or workspace as initial root. */ | ||||
| else { | else { | ||||
| if ((mainb != BCONTEXT_WORKSPACE) && (use_scene_settings || | if ((mainb != BCONTEXT_WORKSPACE) && (use_scene_settings || | ||||
| ELEM(mainb, BCONTEXT_SCENE, BCONTEXT_RENDER, BCONTEXT_RENDER_LAYER, BCONTEXT_WORLD))) | ELEM(mainb, BCONTEXT_SCENE, BCONTEXT_RENDER, BCONTEXT_VIEW_LAYER, BCONTEXT_WORLD))) | ||||
| { | { | ||||
| RNA_id_pointer_create(&scene->id, &path->ptr[0]); | RNA_id_pointer_create(&scene->id, &path->ptr[0]); | ||||
| path->len++; | path->len++; | ||||
| } | } | ||||
| else { | else { | ||||
| RNA_id_pointer_create(&workspace->id, &path->ptr[0]); | RNA_id_pointer_create(&workspace->id, &path->ptr[0]); | ||||
| path->len++; | path->len++; | ||||
| } | } | ||||
| } | } | ||||
| if (!ELEM(mainb, BCONTEXT_WORKSPACE, BCONTEXT_SCENE, BCONTEXT_RENDER, BCONTEXT_RENDER_LAYER, BCONTEXT_WORLD)) { | if (!ELEM(mainb, BCONTEXT_WORKSPACE, BCONTEXT_SCENE, BCONTEXT_RENDER, BCONTEXT_VIEW_LAYER, BCONTEXT_WORLD)) { | ||||
| SceneLayer *scene_layer = BKE_scene_layer_from_workspace_get(scene, workspace); | ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace); | ||||
| RNA_pointer_create(NULL, &RNA_SceneLayer, scene_layer, &path->ptr[path->len]); | RNA_pointer_create(NULL, &RNA_ViewLayer, view_layer, &path->ptr[path->len]); | ||||
| path->len++; | path->len++; | ||||
| } | } | ||||
| /* now for each buttons context type, we try to construct a path, | /* now for each buttons context type, we try to construct a path, | ||||
| * tracing back recursively */ | * tracing back recursively */ | ||||
| switch (mainb) { | switch (mainb) { | ||||
| case BCONTEXT_SCENE: | case BCONTEXT_SCENE: | ||||
| case BCONTEXT_RENDER: | case BCONTEXT_RENDER: | ||||
| found = buttons_context_path_scene(path); | found = buttons_context_path_scene(path); | ||||
| break; | break; | ||||
| case BCONTEXT_RENDER_LAYER: | case BCONTEXT_VIEW_LAYER: | ||||
| #ifdef WITH_FREESTYLE | #ifdef WITH_FREESTYLE | ||||
| if (buttons_context_linestyle_pinnable(C)) { | if (buttons_context_linestyle_pinnable(C)) { | ||||
| found = buttons_context_path_linestyle(path); | found = buttons_context_path_linestyle(path); | ||||
| if (found) { | if (found) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| ▲ Show 20 Lines • Show All 537 Lines • ▼ Show 20 Lines | for (a = 0; a < path->len; a++) { | ||||
| if (a != 0) | if (a != 0) | ||||
| uiItemL(row, "", VICO_SMALL_TRI_RIGHT_VEC); | uiItemL(row, "", VICO_SMALL_TRI_RIGHT_VEC); | ||||
| if (ptr->data) { | if (ptr->data) { | ||||
| icon = RNA_struct_ui_icon(ptr->type); | icon = RNA_struct_ui_icon(ptr->type); | ||||
| name = RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL); | name = RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL); | ||||
| if (name) { | if (name) { | ||||
| if ((!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_RENDER_LAYER) && ptr->type == &RNA_Scene) || | if ((!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_VIEW_LAYER) && ptr->type == &RNA_Scene) || | ||||
| (!ELEM(sbuts->mainb, BCONTEXT_WORKSPACE) && ptr->type == &RNA_WorkSpace)) | (!ELEM(sbuts->mainb, BCONTEXT_WORKSPACE) && ptr->type == &RNA_WorkSpace)) | ||||
| { | { | ||||
| uiItemLDrag(row, ptr, "", icon); /* save some space */ | uiItemLDrag(row, ptr, "", icon); /* save some space */ | ||||
| } | } | ||||
| else { | else { | ||||
| uiItemLDrag(row, ptr, name, icon); | uiItemLDrag(row, ptr, name, icon); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines | |||||