diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-07-25 23:45:34 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-07-25 23:45:34 +0400 |
commit | 4ca9275b448fa62fa1c0d55007417558c6552d77 (patch) | |
tree | b1d639721eca0ad58464be6fb6cd085ab6089a0b /source/blender | |
parent | b66f541b426be7a5904459625627ad354c796ed2 (diff) |
Implement operator to select linked data from outliner
Supports selecting using object data, material and library.
Would be nice to hide this menu item from menus appearing for
datablocks which does not support such a selection, but that
could be done separately.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_object.h | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_select.c | 21 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_tools.c | 18 |
3 files changed, 40 insertions, 3 deletions
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 38f0077c368..09fb88fd5ac 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -41,6 +41,7 @@ struct bContext; struct bPoseChannel; struct Curve; struct EnumPropertyItem; +struct ID; struct KeyBlock; struct Lattice; struct Main; @@ -183,6 +184,9 @@ int ED_object_iter_other(struct Main *bmain, struct Object *orig_ob, int include int ED_object_multires_update_totlevels_cb(struct Object *ob, void *totlevel_v); +/* ibject_select.c */ +void ED_object_select_linked_by_id(struct bContext *C, struct ID *id); + #ifdef __cplusplus } #endif diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index f5f1ba61e8b..c83331a8eb7 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -372,6 +372,25 @@ static int object_select_all_by_library_obdata(bContext *C, Library *lib) return changed; } +void ED_object_select_linked_by_id(bContext *C, ID *id) +{ + int gs = GS(id->name); + int changed = FALSE; + + if (ELEM8(gs, ID_ME, ID_CU, ID_MB, ID_LT, ID_LA, ID_CA, ID_TXT, ID_SPK)) { + changed = object_select_all_by_obdata(C, id); + } + else if (gs == ID_MA) { + changed = object_select_all_by_material_texture(C, FALSE, (Material *)id, NULL); + } + else if (gs == ID_LI) { + changed = object_select_all_by_library(C, (Library *) id); + } + + if (changed) + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); +} + static int object_select_linked_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); @@ -1097,5 +1116,3 @@ void OBJECT_OT_select_random(wmOperatorType *ot) RNA_def_float_percentage(ot->srna, "percent", 50.f, 0.0f, 100.0f, "Percent", "Percentage of objects to select randomly", 0.f, 100.0f); RNA_def_boolean(ot->srna, "extend", FALSE, "Extend Selection", "Extend selection instead of deselecting everything first"); } - - diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 3d01de1c67a..acfaadb947d 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -324,6 +324,14 @@ static void id_fake_user_clear_cb(bContext *UNUSED(C), Scene *UNUSED(scene), Tre } } +static void id_select_linked_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), + TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + ID *id = tselem->id; + + ED_object_select_linked_by_id(C, id); +} + static void singleuser_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *tselem) { @@ -728,7 +736,9 @@ typedef enum eOutlinerIdOpTypes { OUTLINER_IDOP_FAKE_ADD, OUTLINER_IDOP_FAKE_CLEAR, - OUTLINER_IDOP_RENAME + OUTLINER_IDOP_RENAME, + + OUTLINER_IDOP_SELECT_LINKED } eOutlinerIdOpTypes; // TODO: implement support for changing the ID-block used @@ -740,6 +750,7 @@ static EnumPropertyItem prop_id_op_types[] = { "Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"}, {OUTLINER_IDOP_FAKE_CLEAR, "CLEAR_FAKE", 0, "Clear Fake User", ""}, {OUTLINER_IDOP_RENAME, "RENAME", 0, "Rename", ""}, + {OUTLINER_IDOP_SELECT_LINKED, "SELECT_LINKED", 0, "Select Linked", ""}, {0, NULL, 0, NULL, NULL} }; @@ -855,6 +866,11 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) ED_undo_push(C, "Rename"); } break; + + case OUTLINER_IDOP_SELECT_LINKED: + outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_select_linked_cb); + ED_undo_push(C, "Select"); + break; default: // invalid - unhandled |