diff options
Diffstat (limited to 'source/blender/editors/space_buttons/buttons_context.c')
-rw-r--r-- | source/blender/editors/space_buttons/buttons_context.c | 79 |
1 files changed, 78 insertions, 1 deletions
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 895c38747c1..3f5d7de5cd0 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -45,6 +45,7 @@ #include "DNA_scene_types.h" #include "DNA_world_types.h" #include "DNA_brush_types.h" +#include "DNA_linestyle_types.h" #include "BKE_context.h" #include "BKE_action.h" @@ -139,6 +140,30 @@ static int buttons_context_path_world(ButsContextPath *path) return 0; } +static int buttons_context_path_linestyle(ButsContextPath *path) +{ + Scene *scene; + FreestyleLineStyle *linestyle; + PointerRNA *ptr = &path->ptr[path->len - 1]; + + /* if we already have a (pinned) linestyle, we're done */ + if (RNA_struct_is_a(ptr->type, &RNA_FreestyleLineStyle)) { + return 1; + } + /* if we have a scene, use the lineset's linestyle */ + else if (buttons_context_path_scene(path)) { + scene = path->ptr[path->len - 1].data; + linestyle = CTX_data_linestyle_from_scene(scene); + if (linestyle) { + RNA_id_pointer_create(&linestyle->id, &path->ptr[path->len]); + path->len++; + return 1; + } + } + + /* no path to a linestyle possible */ + return 0; +} static int buttons_context_path_object(ButsContextPath *path) { @@ -395,6 +420,8 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur buttons_context_path_particle(path); else if (GS(id->name) == ID_OB) buttons_context_path_object(path); + else if (GS(id->name) == ID_LS) + buttons_context_path_linestyle(path); } if (ct->texture) { @@ -410,6 +437,7 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur Lamp *la; World *wo; ParticleSystem *psys; + FreestyleLineStyle *ls; Tex *tex; PointerRNA *ptr = &path->ptr[path->len - 1]; @@ -475,12 +503,40 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur return 1; } } + /* try linestyle */ + else if ((path->tex_ctx == SB_TEXC_LINESTYLE) && buttons_context_path_linestyle(path)) { + ls = path->ptr[path->len - 1].data; + + if (ls) { + tex = give_current_linestyle_texture(ls); + + RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); + path->len++; + return 1; + } + } } /* no path to a texture possible */ return 0; } +static bool buttons_context_linestyle_pinnable(const bContext *C) +{ + Scene *scene = CTX_data_scene(C); + SpaceButs *sbuts; + + /* if Freestyle is disabled in the scene */ + if ((scene->r.mode & R_EDGE_FRS) == 0) { + return false; + } + /* if the scene has already been pinned */ + sbuts = CTX_wm_space_buts(C); + if (sbuts->pinid && sbuts->pinid == &scene->id) { + return false; + } + return true; +} static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag) { @@ -512,7 +568,17 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma switch (mainb) { case BCONTEXT_SCENE: case BCONTEXT_RENDER: + found = buttons_context_path_scene(path); + break; case BCONTEXT_RENDER_LAYER: +#ifdef WITH_FREESTYLE + if (buttons_context_linestyle_pinnable(C)) { + found = buttons_context_path_linestyle(path); + if (found) { + break; + } + } +#endif found = buttons_context_path_scene(path); break; case BCONTEXT_WORLD: @@ -662,7 +728,8 @@ const char *buttons_context_dir[] = { "meta_ball", "lamp", "speaker", "camera", "material", "material_slot", "texture", "texture_user", "texture_user_property", "bone", "edit_bone", "pose_bone", "particle_system", "particle_system_editable", "particle_settings", - "cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint", NULL + "cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint", + "line_style", NULL }; int buttons_context(const bContext *C, const char *member, bContextDataResult *result) @@ -860,6 +927,12 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r if (wo) CTX_data_pointer_set(result, &wo->id, &RNA_WorldTextureSlot, wo->mtex[(int)wo->texact]); } + else if ((ptr = get_pointer_type(path, &RNA_FreestyleLineStyle))) { + FreestyleLineStyle *ls = ptr->data; + + if (ls) + CTX_data_pointer_set(result, &ls->id, &RNA_LineStyleTextureSlot, ls->mtex[(int)ls->texact]); + } return 1; } @@ -972,6 +1045,10 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } } + else if (CTX_data_equals(member, "line_style")) { + set_pointer_type(path, result, &RNA_FreestyleLineStyle); + return 1; + } else { return 0; /* not found */ } |