2011-07-11 10:59:53 +00:00
|
|
|
/*
|
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2004 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Joshua Leung
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** \file blender/editors/space_outliner/outliner_tools.c
|
|
|
|
|
* \ingroup spoutliner
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_anim_types.h"
|
|
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
|
#include "DNA_group_types.h"
|
|
|
|
|
#include "DNA_lamp_types.h"
|
2014-04-23 15:08:41 +09:00
|
|
|
#include "DNA_linestyle_types.h"
|
2011-07-11 10:59:53 +00:00
|
|
|
#include "DNA_material_types.h"
|
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
#include "DNA_meta_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
2012-05-29 05:45:06 +00:00
|
|
|
#include "DNA_sequence_types.h"
|
2011-07-11 10:59:53 +00:00
|
|
|
#include "DNA_world_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
2015-02-12 07:25:36 +11:00
|
|
|
#include "DNA_constraint_types.h"
|
|
|
|
|
#include "DNA_modifier_types.h"
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
|
|
|
|
#include "BKE_animsys.h"
|
|
|
|
|
#include "BKE_context.h"
|
2015-02-12 07:25:36 +11:00
|
|
|
#include "BKE_constraint.h"
|
2011-07-11 10:59:53 +00:00
|
|
|
#include "BKE_depsgraph.h"
|
|
|
|
|
#include "BKE_fcurve.h"
|
|
|
|
|
#include "BKE_group.h"
|
|
|
|
|
#include "BKE_library.h"
|
|
|
|
|
#include "BKE_main.h"
|
|
|
|
|
#include "BKE_report.h"
|
|
|
|
|
#include "BKE_scene.h"
|
2012-05-29 05:45:06 +00:00
|
|
|
#include "BKE_sequencer.h"
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
#include "ED_armature.h"
|
|
|
|
|
#include "ED_object.h"
|
|
|
|
|
#include "ED_screen.h"
|
2012-05-29 05:45:06 +00:00
|
|
|
#include "ED_sequencer.h"
|
2011-07-11 10:59:53 +00:00
|
|
|
#include "ED_util.h"
|
|
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
|
#include "UI_view2d.h"
|
2015-02-12 07:25:36 +11:00
|
|
|
#include "UI_resources.h"
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
#include "RNA_enum_types.h"
|
|
|
|
|
|
|
|
|
|
#include "outliner_intern.h"
|
|
|
|
|
|
2013-03-10 17:19:03 +00:00
|
|
|
|
2011-07-11 10:59:53 +00:00
|
|
|
/* ****************************************************** */
|
|
|
|
|
|
|
|
|
|
/* ************ SELECTION OPERATIONS ********* */
|
|
|
|
|
|
|
|
|
|
static void set_operation_types(SpaceOops *soops, ListBase *lb,
|
2012-05-07 17:56:30 +00:00
|
|
|
int *scenelevel,
|
|
|
|
|
int *objectlevel,
|
|
|
|
|
int *idlevel,
|
|
|
|
|
int *datalevel)
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
|
|
|
|
TreeElement *te;
|
|
|
|
|
TreeStoreElem *tselem;
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
for (te = lb->first; te; te = te->next) {
|
|
|
|
|
tselem = TREESTORE(te);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (tselem->flag & TSE_SELECTED) {
|
|
|
|
|
if (tselem->type) {
|
2012-05-07 17:56:30 +00:00
|
|
|
if (*datalevel == 0)
|
|
|
|
|
*datalevel = tselem->type;
|
|
|
|
|
else if (*datalevel != tselem->type)
|
|
|
|
|
*datalevel = -1;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-05-07 17:56:30 +00:00
|
|
|
int idcode = GS(tselem->id->name);
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (idcode) {
|
2011-07-11 10:59:53 +00:00
|
|
|
case ID_SCE:
|
2012-05-07 17:56:30 +00:00
|
|
|
*scenelevel = 1;
|
2011-07-11 10:59:53 +00:00
|
|
|
break;
|
|
|
|
|
case ID_OB:
|
2012-05-07 17:56:30 +00:00
|
|
|
*objectlevel = 1;
|
2011-07-11 10:59:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_ME: case ID_CU: case ID_MB: case ID_LT:
|
2011-08-01 11:44:20 +00:00
|
|
|
case ID_LA: case ID_AR: case ID_CA: case ID_SPK:
|
2011-07-11 10:59:53 +00:00
|
|
|
case ID_MA: case ID_TE: case ID_IP: case ID_IM:
|
|
|
|
|
case ID_SO: case ID_KE: case ID_WO: case ID_AC:
|
2013-09-04 01:15:23 +00:00
|
|
|
case ID_NLA: case ID_TXT: case ID_GR: case ID_LS:
|
2012-05-07 17:56:30 +00:00
|
|
|
if (*idlevel == 0) *idlevel = idcode;
|
|
|
|
|
else if (*idlevel != idcode) *idlevel = -1;
|
|
|
|
|
break;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-04-29 15:47:02 +00:00
|
|
|
if (TSELEM_OPEN(tselem, soops)) {
|
2011-07-11 10:59:53 +00:00
|
|
|
set_operation_types(soops, &te->subtree,
|
2012-04-29 15:47:02 +00:00
|
|
|
scenelevel, objectlevel, idlevel, datalevel);
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void unlink_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
|
|
|
|
|
TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem))
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
|
|
|
|
/* just set action to NULL */
|
|
|
|
|
BKE_animdata_set_action(CTX_wm_reports(C), tsep->id, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te,
|
|
|
|
|
TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem))
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
Material **matar = NULL;
|
|
|
|
|
int a, totcol = 0;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
if (GS(tsep->id->name) == ID_OB) {
|
|
|
|
|
Object *ob = (Object *)tsep->id;
|
|
|
|
|
totcol = ob->totcol;
|
|
|
|
|
matar = ob->mat;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2012-05-07 17:56:30 +00:00
|
|
|
else if (GS(tsep->id->name) == ID_ME) {
|
|
|
|
|
Mesh *me = (Mesh *)tsep->id;
|
|
|
|
|
totcol = me->totcol;
|
|
|
|
|
matar = me->mat;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2012-05-07 17:56:30 +00:00
|
|
|
else if (GS(tsep->id->name) == ID_CU) {
|
|
|
|
|
Curve *cu = (Curve *)tsep->id;
|
|
|
|
|
totcol = cu->totcol;
|
|
|
|
|
matar = cu->mat;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2012-05-07 17:56:30 +00:00
|
|
|
else if (GS(tsep->id->name) == ID_MB) {
|
|
|
|
|
MetaBall *mb = (MetaBall *)tsep->id;
|
|
|
|
|
totcol = mb->totcol;
|
|
|
|
|
matar = mb->mat;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2012-11-01 09:56:18 +00:00
|
|
|
else {
|
|
|
|
|
BLI_assert(0);
|
|
|
|
|
}
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-11-01 09:56:18 +00:00
|
|
|
if (LIKELY(matar != NULL)) {
|
|
|
|
|
for (a = 0; a < totcol; a++) {
|
|
|
|
|
if (a == te->index && matar[a]) {
|
|
|
|
|
matar[a]->id.us--;
|
|
|
|
|
matar[a] = NULL;
|
|
|
|
|
}
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te,
|
|
|
|
|
TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem))
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
MTex **mtex = NULL;
|
2011-07-11 10:59:53 +00:00
|
|
|
int a;
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
if (GS(tsep->id->name) == ID_MA) {
|
|
|
|
|
Material *ma = (Material *)tsep->id;
|
|
|
|
|
mtex = ma->mtex;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2012-05-07 17:56:30 +00:00
|
|
|
else if (GS(tsep->id->name) == ID_LA) {
|
|
|
|
|
Lamp *la = (Lamp *)tsep->id;
|
|
|
|
|
mtex = la->mtex;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2012-05-07 17:56:30 +00:00
|
|
|
else if (GS(tsep->id->name) == ID_WO) {
|
|
|
|
|
World *wrld = (World *)tsep->id;
|
|
|
|
|
mtex = wrld->mtex;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2014-04-23 15:08:41 +09:00
|
|
|
else if (GS(tsep->id->name) == ID_LS) {
|
|
|
|
|
FreestyleLineStyle *ls = (FreestyleLineStyle *)tsep->id;
|
|
|
|
|
mtex = ls->mtex;
|
|
|
|
|
}
|
2013-03-09 03:46:30 +00:00
|
|
|
else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
for (a = 0; a < MAX_MTEX; a++) {
|
|
|
|
|
if (a == te->index && mtex[a]) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex[a]->tex) {
|
2011-07-11 10:59:53 +00:00
|
|
|
mtex[a]->tex->id.us--;
|
2012-05-07 17:56:30 +00:00
|
|
|
mtex[a]->tex = NULL;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void unlink_group_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te),
|
|
|
|
|
TreeStoreElem *tsep, TreeStoreElem *tselem)
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
Group *group = (Group *)tselem->id;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (tsep) {
|
2012-05-07 17:56:30 +00:00
|
|
|
if (GS(tsep->id->name) == ID_OB) {
|
|
|
|
|
Object *ob = (Object *)tsep->id;
|
|
|
|
|
ob->dup_group = NULL;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_group_unlink(group);
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void unlink_world_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te),
|
|
|
|
|
TreeStoreElem *tsep, TreeStoreElem *tselem)
|
2011-11-16 00:13:38 +00:00
|
|
|
{
|
|
|
|
|
Scene *parscene = (Scene *)tsep->id;
|
|
|
|
|
World *wo = (World *)tselem->id;
|
|
|
|
|
|
|
|
|
|
/* need to use parent scene not just scene, otherwise may end up getting wrong one */
|
|
|
|
|
id_us_min(&wo->id);
|
|
|
|
|
parscene->world = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-11 10:59:53 +00:00
|
|
|
static void outliner_do_libdata_operation(bContext *C, Scene *scene, SpaceOops *soops, ListBase *lb,
|
2012-05-31 18:40:06 +00:00
|
|
|
void (*operation_cb)(bContext *C, Scene *scene, TreeElement *,
|
|
|
|
|
TreeStoreElem *, TreeStoreElem *))
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
|
|
|
|
TreeElement *te;
|
|
|
|
|
TreeStoreElem *tselem;
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
for (te = lb->first; te; te = te->next) {
|
|
|
|
|
tselem = TREESTORE(te);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (tselem->flag & TSE_SELECTED) {
|
2012-05-07 17:56:30 +00:00
|
|
|
if (tselem->type == 0) {
|
2012-05-28 15:37:43 +00:00
|
|
|
TreeStoreElem *tsep = te->parent ? TREESTORE(te->parent) : NULL;
|
2011-07-11 10:59:53 +00:00
|
|
|
operation_cb(C, scene, te, tsep, tselem);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-04-29 15:47:02 +00:00
|
|
|
if (TSELEM_OPEN(tselem, soops)) {
|
2011-07-11 10:59:53 +00:00
|
|
|
outliner_do_libdata_operation(C, scene, soops, &te->subtree, operation_cb);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* */
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te,
|
|
|
|
|
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
Base *base = (Base *)te->directdata;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id);
|
|
|
|
|
if (base && ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0)) {
|
2011-07-11 10:59:53 +00:00
|
|
|
base->flag |= SELECT;
|
|
|
|
|
base->object->flag |= SELECT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-10 17:19:03 +00:00
|
|
|
static void object_select_hierarchy_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
|
|
|
|
|
TreeStoreElem *UNUSED(tsep), TreeStoreElem *UNUSED(tselem))
|
|
|
|
|
{
|
|
|
|
|
/* From where do i get the x,y coordinate of the mouse event ? */
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
int x = win->eventstate->mval[0];
|
|
|
|
|
int y = win->eventstate->mval[1];
|
|
|
|
|
outliner_item_do_activate(C, x, y, true, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te,
|
|
|
|
|
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
Base *base = (Base *)te->directdata;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (base) {
|
2011-07-11 10:59:53 +00:00
|
|
|
base->flag &= ~SELECT;
|
|
|
|
|
base->object->flag &= ~SELECT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te,
|
|
|
|
|
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
Base *base = (Base *)te->directdata;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
if (base == NULL)
|
|
|
|
|
base = BKE_scene_base_find(scene, (Object *)tselem->id);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (base) {
|
2011-07-11 10:59:53 +00:00
|
|
|
// check also library later
|
2012-05-07 17:56:30 +00:00
|
|
|
if (scene->obedit == base->object)
|
2013-03-21 14:18:17 +00:00
|
|
|
ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO);
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
ED_base_object_free_and_unlink(CTX_data_main(C), scene, base);
|
2012-05-07 17:56:30 +00:00
|
|
|
te->directdata = NULL;
|
|
|
|
|
tselem->id = NULL;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void id_local_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
|
|
|
|
|
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
2011-07-20 01:12:57 +00:00
|
|
|
if (tselem->id->lib && (tselem->id->flag & LIB_EXTERN)) {
|
2011-11-30 00:32:13 +00:00
|
|
|
/* if the ID type has no special local function,
|
|
|
|
|
* just clear the lib */
|
2013-03-10 05:46:24 +00:00
|
|
|
if (id_make_local(tselem->id, false) == false) {
|
2012-05-07 17:56:30 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2011-11-30 00:32:13 +00:00
|
|
|
id_clear_lib_data(bmain, tselem->id);
|
|
|
|
|
}
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void id_fake_user_set_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te),
|
|
|
|
|
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
|
2011-07-20 01:12:57 +00:00
|
|
|
{
|
|
|
|
|
ID *id = tselem->id;
|
|
|
|
|
|
|
|
|
|
if ((id) && ((id->flag & LIB_FAKEUSER) == 0)) {
|
|
|
|
|
id->flag |= LIB_FAKEUSER;
|
|
|
|
|
id_us_plus(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void id_fake_user_clear_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te),
|
|
|
|
|
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
|
2011-07-20 01:12:57 +00:00
|
|
|
{
|
|
|
|
|
ID *id = tselem->id;
|
|
|
|
|
|
|
|
|
|
if ((id) && (id->flag & LIB_FAKEUSER)) {
|
|
|
|
|
id->flag &= ~LIB_FAKEUSER;
|
|
|
|
|
id_us_min(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-07-25 19:45:34 +00:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void singleuser_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
|
|
|
|
|
TreeStoreElem *tsep, TreeStoreElem *tselem)
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
|
|
|
|
ID *id = tselem->id;
|
|
|
|
|
|
|
|
|
|
if (id) {
|
|
|
|
|
IdAdtTemplate *iat = (IdAdtTemplate *)tsep->id;
|
2011-09-16 08:20:21 +00:00
|
|
|
PointerRNA ptr = {{NULL}};
|
2011-07-11 10:59:53 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
RNA_pointer_create(&iat->id, &RNA_AnimData, iat->adt, &ptr);
|
|
|
|
|
prop = RNA_struct_find_property(&ptr, "action");
|
|
|
|
|
|
|
|
|
|
id_single_user(C, id, &ptr, prop);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void singleuser_world_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
|
|
|
|
|
TreeStoreElem *tsep, TreeStoreElem *tselem)
|
2011-11-16 00:13:38 +00:00
|
|
|
{
|
|
|
|
|
ID *id = tselem->id;
|
|
|
|
|
|
|
|
|
|
/* need to use parent scene not just scene, otherwise may end up getting wrong one */
|
|
|
|
|
if (id) {
|
|
|
|
|
Scene *parscene = (Scene *)tsep->id;
|
|
|
|
|
PointerRNA ptr = {{NULL}};
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
RNA_id_pointer_create(&parscene->id, &ptr);
|
|
|
|
|
prop = RNA_struct_find_property(&ptr, "world");
|
|
|
|
|
|
|
|
|
|
id_single_user(C, id, &ptr, prop);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te),
|
|
|
|
|
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
Group *group = (Group *)tselem->id;
|
2011-07-11 10:59:53 +00:00
|
|
|
GroupObject *gob;
|
|
|
|
|
Base *base;
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
for (gob = group->gobject.first; gob; gob = gob->next) {
|
|
|
|
|
base = BKE_scene_base_find(scene, gob->ob);
|
2011-07-11 10:59:53 +00:00
|
|
|
if (base) {
|
|
|
|
|
base->object->flag |= SELECT;
|
|
|
|
|
base->flag |= SELECT;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2011-07-11 10:59:53 +00:00
|
|
|
/* link to scene */
|
2012-05-07 17:56:30 +00:00
|
|
|
base = MEM_callocN(sizeof(Base), "add_base");
|
2011-07-11 10:59:53 +00:00
|
|
|
BLI_addhead(&scene->base, base);
|
2013-02-27 10:19:31 +00:00
|
|
|
base->lay = gob->ob->lay;
|
2011-07-11 10:59:53 +00:00
|
|
|
gob->ob->flag |= SELECT;
|
|
|
|
|
base->flag = gob->ob->flag;
|
2012-05-07 17:56:30 +00:00
|
|
|
base->object = gob->ob;
|
2012-03-09 00:41:09 +00:00
|
|
|
id_lib_extern((ID *)gob->ob); /* in case these are from a linked group */
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-06 19:20:39 +00:00
|
|
|
static void group_instance_cb(bContext *C, Scene *scene, TreeElement *UNUSED(te),
|
|
|
|
|
TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
|
|
|
|
|
{
|
|
|
|
|
Group *group = (Group *)tselem->id;
|
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
Object *ob = ED_object_add_type(C, OB_EMPTY, scene->cursor, NULL, false, scene->layact);
|
2012-06-06 19:20:39 +00:00
|
|
|
rename_id(&ob->id, group->id.name + 2);
|
|
|
|
|
ob->dup_group = group;
|
|
|
|
|
ob->transflag |= OB_DUPLIGROUP;
|
|
|
|
|
id_lib_extern(&group->id);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-11 10:59:53 +00:00
|
|
|
void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOops *soops, ListBase *lb,
|
2012-05-31 18:40:06 +00:00
|
|
|
void (*operation_cb)(bContext *C, Scene *scene, TreeElement *,
|
|
|
|
|
TreeStoreElem *, TreeStoreElem *))
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
|
|
|
|
TreeElement *te;
|
|
|
|
|
TreeStoreElem *tselem;
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
for (te = lb->first; te; te = te->next) {
|
|
|
|
|
tselem = TREESTORE(te);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (tselem->flag & TSE_SELECTED) {
|
2012-05-07 17:56:30 +00:00
|
|
|
if (tselem->type == 0 && te->idcode == ID_OB) {
|
2011-07-11 10:59:53 +00:00
|
|
|
// when objects selected in other scenes... dunno if that should be allowed
|
2012-05-07 17:56:30 +00:00
|
|
|
Scene *scene_owner = (Scene *)outliner_search_back(soops, te, ID_SCE);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scene_owner && scene_act != scene_owner) {
|
2012-03-07 16:43:42 +00:00
|
|
|
ED_screen_set_scene(C, CTX_wm_screen(C), scene_owner);
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
/* important to use 'scene_owner' not scene_act else deleting objects can crash.
|
|
|
|
|
* only use 'scene_act' when 'scene_owner' is NULL, which can happen when the
|
2012-03-18 07:38:51 +00:00
|
|
|
* outliner isn't showing scenes: Visible Layer draw mode for eg. */
|
2011-07-11 10:59:53 +00:00
|
|
|
operation_cb(C, scene_owner ? scene_owner : scene_act, te, NULL, tselem);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-04-29 15:47:02 +00:00
|
|
|
if (TSELEM_OPEN(tselem, soops)) {
|
2011-07-11 10:59:53 +00:00
|
|
|
outliner_do_object_operation(C, scene_act, soops, &te->subtree, operation_cb);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ******************************************** */
|
|
|
|
|
|
2014-07-06 20:55:10 +12:00
|
|
|
static void clear_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te),
|
|
|
|
|
TreeStoreElem *tselem, void *UNUSED(arg))
|
|
|
|
|
{
|
|
|
|
|
BKE_free_animdata(tselem->id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void unlinkact_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te),
|
|
|
|
|
TreeStoreElem *tselem, void *UNUSED(arg))
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
|
|
|
|
/* just set action to NULL */
|
|
|
|
|
BKE_animdata_set_action(NULL, tselem->id, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void cleardrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te),
|
|
|
|
|
TreeStoreElem *tselem, void *UNUSED(arg))
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
|
|
|
|
IdAdtTemplate *iat = (IdAdtTemplate *)tselem->id;
|
|
|
|
|
|
|
|
|
|
/* just free drivers - stored as a list of F-Curves */
|
|
|
|
|
free_fcurves(&iat->adt->drivers);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static void refreshdrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te),
|
|
|
|
|
TreeStoreElem *tselem, void *UNUSED(arg))
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
|
|
|
|
IdAdtTemplate *iat = (IdAdtTemplate *)tselem->id;
|
|
|
|
|
FCurve *fcu;
|
|
|
|
|
|
|
|
|
|
/* loop over drivers, performing refresh (i.e. check graph_buttons.c and rna_fcurve.c for details) */
|
2012-05-07 17:56:30 +00:00
|
|
|
for (fcu = iat->adt->drivers.first; fcu; fcu = fcu->next) {
|
2011-07-11 10:59:53 +00:00
|
|
|
fcu->flag &= ~FCURVE_DISABLED;
|
|
|
|
|
|
|
|
|
|
if (fcu->driver)
|
|
|
|
|
fcu->driver->flag &= ~DRIVER_FLAG_INVALID;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* --------------------------------- */
|
|
|
|
|
|
2015-01-22 10:47:53 +11:00
|
|
|
typedef enum eOutliner_PropDataOps {
|
2015-02-12 07:25:36 +11:00
|
|
|
OL_DOP_SELECT = 1,
|
2015-01-22 10:47:53 +11:00
|
|
|
OL_DOP_DESELECT,
|
|
|
|
|
OL_DOP_HIDE,
|
|
|
|
|
OL_DOP_UNHIDE,
|
|
|
|
|
OL_DOP_SELECT_LINKED,
|
|
|
|
|
} eOutliner_PropDataOps;
|
|
|
|
|
|
2015-02-12 07:25:36 +11:00
|
|
|
typedef enum eOutliner_PropConstraintOps {
|
|
|
|
|
OL_CONSTRAINTOP_ENABLE = 1,
|
|
|
|
|
OL_CONSTRAINTOP_DISABLE,
|
|
|
|
|
OL_CONSTRAINTOP_DELETE
|
|
|
|
|
} eOutliner_PropConstraintOps;
|
|
|
|
|
|
|
|
|
|
typedef enum eOutliner_PropModifierOps {
|
|
|
|
|
OL_MODIFIER_OP_TOGVIS = 1,
|
|
|
|
|
OL_MODIFIER_OP_TOGREN,
|
|
|
|
|
OL_MODIFIER_OP_DELETE
|
|
|
|
|
} eOutliner_PropModifierOps;
|
|
|
|
|
|
2012-05-29 05:45:06 +00:00
|
|
|
static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg))
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
bPoseChannel *pchan = (bPoseChannel *)te->directdata;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2015-01-22 10:47:53 +11:00
|
|
|
if (event == OL_DOP_SELECT)
|
2011-07-11 10:59:53 +00:00
|
|
|
pchan->bone->flag |= BONE_SELECTED;
|
2015-01-22 10:47:53 +11:00
|
|
|
else if (event == OL_DOP_DESELECT)
|
2011-07-11 10:59:53 +00:00
|
|
|
pchan->bone->flag &= ~BONE_SELECTED;
|
2015-01-22 10:47:53 +11:00
|
|
|
else if (event == OL_DOP_HIDE) {
|
2011-07-11 10:59:53 +00:00
|
|
|
pchan->bone->flag |= BONE_HIDDEN_P;
|
|
|
|
|
pchan->bone->flag &= ~BONE_SELECTED;
|
|
|
|
|
}
|
2015-01-22 10:47:53 +11:00
|
|
|
else if (event == OL_DOP_UNHIDE)
|
2011-07-11 10:59:53 +00:00
|
|
|
pchan->bone->flag &= ~BONE_HIDDEN_P;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-29 05:45:06 +00:00
|
|
|
static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg))
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
Bone *bone = (Bone *)te->directdata;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2015-01-22 10:47:53 +11:00
|
|
|
if (event == OL_DOP_SELECT)
|
2011-07-11 10:59:53 +00:00
|
|
|
bone->flag |= BONE_SELECTED;
|
2015-01-22 10:47:53 +11:00
|
|
|
else if (event == OL_DOP_DESELECT)
|
2011-07-11 10:59:53 +00:00
|
|
|
bone->flag &= ~BONE_SELECTED;
|
2015-01-22 10:47:53 +11:00
|
|
|
else if (event == OL_DOP_HIDE) {
|
2011-07-11 10:59:53 +00:00
|
|
|
bone->flag |= BONE_HIDDEN_P;
|
|
|
|
|
bone->flag &= ~BONE_SELECTED;
|
|
|
|
|
}
|
2015-01-22 10:47:53 +11:00
|
|
|
else if (event == OL_DOP_UNHIDE)
|
2011-07-11 10:59:53 +00:00
|
|
|
bone->flag &= ~BONE_HIDDEN_P;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-29 05:45:06 +00:00
|
|
|
static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg))
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
EditBone *ebone = (EditBone *)te->directdata;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2015-01-22 10:47:53 +11:00
|
|
|
if (event == OL_DOP_SELECT)
|
2011-07-11 10:59:53 +00:00
|
|
|
ebone->flag |= BONE_SELECTED;
|
2015-01-22 10:47:53 +11:00
|
|
|
else if (event == OL_DOP_DESELECT)
|
2011-07-11 10:59:53 +00:00
|
|
|
ebone->flag &= ~BONE_SELECTED;
|
2015-01-22 10:47:53 +11:00
|
|
|
else if (event == OL_DOP_HIDE) {
|
2011-07-11 10:59:53 +00:00
|
|
|
ebone->flag |= BONE_HIDDEN_A;
|
2012-05-07 17:56:30 +00:00
|
|
|
ebone->flag &= ~BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2015-01-22 10:47:53 +11:00
|
|
|
else if (event == OL_DOP_UNHIDE)
|
2011-07-11 10:59:53 +00:00
|
|
|
ebone->flag &= ~BONE_HIDDEN_A;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-29 05:45:06 +00:00
|
|
|
static void sequence_cb(int event, TreeElement *te, TreeStoreElem *tselem, void *scene_ptr)
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
2012-05-29 05:45:06 +00:00
|
|
|
Sequence *seq = (Sequence *)te->directdata;
|
2015-01-22 10:47:53 +11:00
|
|
|
if (event == OL_DOP_SELECT) {
|
2012-05-29 05:45:06 +00:00
|
|
|
Scene *scene = (Scene *)scene_ptr;
|
2013-03-08 04:00:06 +00:00
|
|
|
Editing *ed = BKE_sequencer_editing_get(scene, false);
|
2012-05-29 05:45:06 +00:00
|
|
|
if (BLI_findindex(ed->seqbasep, seq) != -1) {
|
2013-03-08 04:00:06 +00:00
|
|
|
ED_sequencer_select_sequence_single(scene, seq, true);
|
2012-05-29 05:45:06 +00:00
|
|
|
}
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2012-05-29 05:45:06 +00:00
|
|
|
|
|
|
|
|
(void)tselem;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
2012-07-25 20:17:38 +00:00
|
|
|
static void data_select_linked_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *C_v)
|
|
|
|
|
{
|
2015-01-22 10:47:53 +11:00
|
|
|
if (event == OL_DOP_SELECT_LINKED) {
|
2012-07-25 20:17:38 +00:00
|
|
|
if (RNA_struct_is_ID(te->rnaptr.type)) {
|
|
|
|
|
bContext *C = (bContext *) C_v;
|
|
|
|
|
ID *id = te->rnaptr.data;
|
|
|
|
|
|
|
|
|
|
ED_object_select_linked_by_id(C, id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-12 07:25:36 +11:00
|
|
|
static void constraint_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *C_v)
|
|
|
|
|
{
|
|
|
|
|
bContext *C = C_v;
|
|
|
|
|
SpaceOops *soops = CTX_wm_space_outliner(C);
|
|
|
|
|
bConstraint *constraint = (bConstraint *)te->directdata;
|
|
|
|
|
Object *ob = (Object *)outliner_search_back(soops, te, ID_OB);
|
|
|
|
|
|
|
|
|
|
if (event == OL_CONSTRAINTOP_ENABLE) {
|
|
|
|
|
constraint->flag &= ~CONSTRAINT_OFF;
|
|
|
|
|
ED_object_constraint_update(ob);
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
|
|
|
|
|
}
|
|
|
|
|
else if (event == OL_CONSTRAINTOP_DISABLE) {
|
|
|
|
|
constraint->flag = CONSTRAINT_OFF;
|
|
|
|
|
ED_object_constraint_update(ob);
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
|
|
|
|
|
}
|
|
|
|
|
else if (event == OL_CONSTRAINTOP_DELETE) {
|
|
|
|
|
ListBase *lb = NULL;
|
|
|
|
|
|
|
|
|
|
if (TREESTORE(te->parent->parent)->type == TSE_POSE_CHANNEL) {
|
|
|
|
|
lb = &((bPoseChannel *)te->parent->parent->directdata)->constraints;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
lb = &ob->constraints;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BKE_constraint_remove_ex(lb, ob, constraint, true)) {
|
|
|
|
|
/* there's no active constraint now, so make sure this is the case */
|
|
|
|
|
BKE_constraints_active_set(&ob->constraints, NULL);
|
|
|
|
|
ED_object_constraint_update(ob); /* needed to set the flags on posebones correctly */
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob);
|
|
|
|
|
te->store_elem->flag &= ~TSE_SELECTED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void modifier_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *Carg)
|
|
|
|
|
{
|
|
|
|
|
bContext *C = (bContext *)Carg;
|
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
|
SpaceOops *soops = CTX_wm_space_outliner(C);
|
|
|
|
|
ModifierData *md = (ModifierData *)te->directdata;
|
|
|
|
|
Object *ob = (Object *)outliner_search_back(soops, te, ID_OB);
|
|
|
|
|
|
|
|
|
|
if (event == OL_MODIFIER_OP_TOGVIS) {
|
|
|
|
|
md->mode ^= eModifierMode_Realtime;
|
|
|
|
|
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
|
|
|
|
|
}
|
|
|
|
|
else if (event == OL_MODIFIER_OP_TOGREN) {
|
|
|
|
|
md->mode ^= eModifierMode_Render;
|
|
|
|
|
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
|
|
|
|
|
}
|
|
|
|
|
else if (event == OL_MODIFIER_OP_DELETE) {
|
|
|
|
|
ED_object_modifier_remove(NULL, bmain, ob, md);
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER | NA_REMOVED, ob);
|
|
|
|
|
te->store_elem->flag &= ~TSE_SELECTED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-29 05:45:06 +00:00
|
|
|
static void outliner_do_data_operation(SpaceOops *soops, int type, int event, ListBase *lb,
|
|
|
|
|
void (*operation_cb)(int, TreeElement *, TreeStoreElem *, void *),
|
|
|
|
|
void *arg)
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
|
|
|
|
TreeElement *te;
|
|
|
|
|
TreeStoreElem *tselem;
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
for (te = lb->first; te; te = te->next) {
|
|
|
|
|
tselem = TREESTORE(te);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (tselem->flag & TSE_SELECTED) {
|
2012-05-07 17:56:30 +00:00
|
|
|
if (tselem->type == type) {
|
2012-05-29 05:45:06 +00:00
|
|
|
operation_cb(event, te, tselem, arg);
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-04-29 15:47:02 +00:00
|
|
|
if (TSELEM_OPEN(tselem, soops)) {
|
2012-05-29 05:45:06 +00:00
|
|
|
outliner_do_data_operation(soops, type, event, &te->subtree, operation_cb, arg);
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-17 14:49:03 +01:00
|
|
|
static void outline_delete_hierarchy(bContext *C, Scene *scene, Base *base)
|
|
|
|
|
{
|
|
|
|
|
Base *child_base;
|
|
|
|
|
Object *parent;
|
|
|
|
|
|
|
|
|
|
if (!base) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (child_base = scene->base.first; child_base; child_base = child_base->next) {
|
|
|
|
|
for (parent = child_base->object->parent; parent && (parent != base->object); parent = parent->parent);
|
|
|
|
|
if (parent) {
|
|
|
|
|
outline_delete_hierarchy(C, scene, child_base);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ED_base_object_free_and_unlink(CTX_data_main(C), scene, base);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void object_delete_hierarchy_cb(
|
|
|
|
|
bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
|
|
|
|
|
{
|
|
|
|
|
Base *base = (Base *)te->directdata;
|
|
|
|
|
Object *obedit = scene->obedit;
|
|
|
|
|
|
|
|
|
|
if (!base) {
|
|
|
|
|
base = BKE_scene_base_find(scene, (Object *)tselem->id);
|
|
|
|
|
}
|
|
|
|
|
if (base) {
|
|
|
|
|
/* Check also library later. */
|
|
|
|
|
for (; obedit && (obedit != base->object); obedit = obedit->parent);
|
|
|
|
|
if (obedit == base->object) {
|
|
|
|
|
ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
outline_delete_hierarchy(C, scene, base);
|
|
|
|
|
te->directdata = NULL;
|
|
|
|
|
tselem->id = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-11 10:59:53 +00:00
|
|
|
/* **************************************** */
|
|
|
|
|
|
2013-03-10 17:19:03 +00:00
|
|
|
enum {
|
2015-02-12 07:25:36 +11:00
|
|
|
OL_OP_SELECT = 1,
|
2013-03-10 17:19:03 +00:00
|
|
|
OL_OP_DESELECT,
|
|
|
|
|
OL_OP_SELECT_HIERARCHY,
|
|
|
|
|
OL_OP_DELETE,
|
2015-01-17 14:49:03 +01:00
|
|
|
OL_OP_DELETE_HIERARCHY,
|
2013-03-10 17:19:03 +00:00
|
|
|
OL_OP_LOCALIZED, /* disabled, see below */
|
|
|
|
|
OL_OP_TOGVIS,
|
|
|
|
|
OL_OP_TOGSEL,
|
|
|
|
|
OL_OP_TOGREN,
|
|
|
|
|
OL_OP_RENAME
|
|
|
|
|
};
|
|
|
|
|
|
2011-07-11 10:59:53 +00:00
|
|
|
static EnumPropertyItem prop_object_op_types[] = {
|
2013-03-10 17:19:03 +00:00
|
|
|
{OL_OP_SELECT, "SELECT", 0, "Select", ""},
|
|
|
|
|
{OL_OP_DESELECT, "DESELECT", 0, "Deselect", ""},
|
|
|
|
|
{OL_OP_SELECT_HIERARCHY, "SELECT_HIERARCHY", 0, "Select Hierarchy", ""},
|
|
|
|
|
{OL_OP_DELETE, "DELETE", 0, "Delete", ""},
|
2015-01-17 14:49:03 +01:00
|
|
|
{OL_OP_DELETE_HIERARCHY, "DELETE_HIERARCHY", 0, "Delete Hierarchy", ""},
|
2013-03-10 17:19:03 +00:00
|
|
|
{OL_OP_TOGVIS, "TOGVIS", 0, "Toggle Visible", ""},
|
|
|
|
|
{OL_OP_TOGSEL, "TOGSEL", 0, "Toggle Selectable", ""},
|
|
|
|
|
{OL_OP_TOGREN, "TOGREN", 0, "Toggle Renderable", ""},
|
|
|
|
|
{OL_OP_RENAME, "RENAME", 0, "Rename", ""},
|
2015-02-12 07:25:36 +11:00
|
|
|
{0, NULL, 0, NULL, NULL}
|
2011-07-11 10:59:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int outliner_object_operation_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
SpaceOops *soops = CTX_wm_space_outliner(C);
|
2011-07-11 10:59:53 +00:00
|
|
|
int event;
|
2012-05-07 17:56:30 +00:00
|
|
|
const char *str = NULL;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
/* check for invalid states */
|
|
|
|
|
if (soops == NULL)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
event = RNA_enum_get(op->ptr, "type");
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2013-03-10 17:19:03 +00:00
|
|
|
if (event == OL_OP_SELECT) {
|
2012-05-07 17:56:30 +00:00
|
|
|
Scene *sce = scene; // to be able to delete, scenes are set...
|
2011-07-11 10:59:53 +00:00
|
|
|
outliner_do_object_operation(C, scene, soops, &soops->tree, object_select_cb);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scene != sce) {
|
2012-03-07 16:43:42 +00:00
|
|
|
ED_screen_set_scene(C, CTX_wm_screen(C), sce);
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
str = "Select Objects";
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2013-03-10 17:19:03 +00:00
|
|
|
else if (event == OL_OP_SELECT_HIERARCHY) {
|
|
|
|
|
Scene *sce = scene; // to be able to delete, scenes are set...
|
|
|
|
|
outliner_do_object_operation(C, scene, soops, &soops->tree, object_select_hierarchy_cb);
|
|
|
|
|
if (scene != sce) {
|
|
|
|
|
ED_screen_set_scene(C, CTX_wm_screen(C), sce);
|
|
|
|
|
}
|
|
|
|
|
str = "Select Object Hierarchy";
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
|
|
|
|
}
|
|
|
|
|
else if (event == OL_OP_DESELECT) {
|
2011-07-11 10:59:53 +00:00
|
|
|
outliner_do_object_operation(C, scene, soops, &soops->tree, object_deselect_cb);
|
2012-05-07 17:56:30 +00:00
|
|
|
str = "Deselect Objects";
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2013-03-10 17:19:03 +00:00
|
|
|
else if (event == OL_OP_DELETE) {
|
2011-07-11 10:59:53 +00:00
|
|
|
outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb);
|
2011-11-24 20:24:03 +00:00
|
|
|
|
|
|
|
|
/* XXX: tree management normally happens from draw_outliner(), but when
|
2012-03-03 16:31:46 +00:00
|
|
|
* you're clicking to fast on Delete object from context menu in
|
|
|
|
|
* outliner several mouse events can be handled in one cycle without
|
|
|
|
|
* handling notifiers/redraw which leads to deleting the same object twice.
|
|
|
|
|
* cleanup tree here to prevent such cases. */
|
2011-11-24 20:24:03 +00:00
|
|
|
outliner_cleanup_tree(soops);
|
|
|
|
|
|
2013-02-21 19:33:04 +00:00
|
|
|
DAG_relations_tag_update(bmain);
|
2012-05-07 17:56:30 +00:00
|
|
|
str = "Delete Objects";
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2015-01-17 14:49:03 +01:00
|
|
|
else if (event == OL_OP_DELETE_HIERARCHY) {
|
|
|
|
|
outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_hierarchy_cb);
|
|
|
|
|
|
|
|
|
|
/* XXX: See OL_OP_DELETE comment above. */
|
|
|
|
|
outliner_cleanup_tree(soops);
|
|
|
|
|
|
|
|
|
|
DAG_relations_tag_update(bmain);
|
|
|
|
|
str = "Delete Object Hierarchy";
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
|
|
|
|
|
}
|
2013-03-10 17:19:03 +00:00
|
|
|
else if (event == OL_OP_LOCALIZED) { /* disabled, see above enum (ton) */
|
2011-07-11 10:59:53 +00:00
|
|
|
outliner_do_object_operation(C, scene, soops, &soops->tree, id_local_cb);
|
2012-05-07 17:56:30 +00:00
|
|
|
str = "Localized Objects";
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2013-03-10 17:19:03 +00:00
|
|
|
else if (event == OL_OP_TOGVIS) {
|
2011-07-11 10:59:53 +00:00
|
|
|
outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb);
|
2012-05-07 17:56:30 +00:00
|
|
|
str = "Toggle Visibility";
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene);
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2013-03-10 17:19:03 +00:00
|
|
|
else if (event == OL_OP_TOGSEL) {
|
2011-07-11 10:59:53 +00:00
|
|
|
outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_selectability_cb);
|
2012-05-07 17:56:30 +00:00
|
|
|
str = "Toggle Selectability";
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2013-03-10 17:19:03 +00:00
|
|
|
else if (event == OL_OP_TOGREN) {
|
2011-07-11 10:59:53 +00:00
|
|
|
outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb);
|
2012-05-07 17:56:30 +00:00
|
|
|
str = "Toggle Renderability";
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, scene);
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2013-03-10 17:19:03 +00:00
|
|
|
else if (event == OL_OP_RENAME) {
|
2011-09-02 08:35:46 +00:00
|
|
|
outliner_do_object_operation(C, scene, soops, &soops->tree, item_rename_cb);
|
2012-05-07 17:56:30 +00:00
|
|
|
str = "Rename Object";
|
2011-09-02 08:35:46 +00:00
|
|
|
}
|
2013-08-02 13:21:32 +00:00
|
|
|
else {
|
|
|
|
|
BLI_assert(0);
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
ED_undo_push(C, str);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OUTLINER_OT_object_operation(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Outliner Object Operation";
|
|
|
|
|
ot->idname = "OUTLINER_OT_object_operation";
|
|
|
|
|
ot->description = "";
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
/* callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
|
ot->exec = outliner_object_operation_exec;
|
|
|
|
|
ot->poll = ED_operator_outliner_active;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = 0;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", prop_object_op_types, 0, "Object Operation", "");
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* **************************************** */
|
|
|
|
|
|
2015-02-12 07:43:32 +11:00
|
|
|
typedef enum eOutliner_PropGroupOps {
|
|
|
|
|
OL_GROUPOP_UNLINK = 1,
|
|
|
|
|
OL_GROUPOP_LOCAL,
|
|
|
|
|
OL_GROUPOP_LINK,
|
|
|
|
|
OL_GROUPOP_INSTANCE,
|
|
|
|
|
OL_GROUPOP_TOGVIS,
|
|
|
|
|
OL_GROUPOP_TOGSEL,
|
|
|
|
|
OL_GROUPOP_TOGREN,
|
|
|
|
|
OL_GROUPOP_RENAME,
|
|
|
|
|
} eOutliner_PropGroupOps;
|
|
|
|
|
|
2011-07-11 10:59:53 +00:00
|
|
|
static EnumPropertyItem prop_group_op_types[] = {
|
2015-02-12 07:43:32 +11:00
|
|
|
{OL_GROUPOP_UNLINK, "UNLINK", 0, "Unlink Group", ""},
|
|
|
|
|
{OL_GROUPOP_LOCAL, "LOCAL", 0, "Make Local Group", ""},
|
|
|
|
|
{OL_GROUPOP_LINK, "LINK", 0, "Link Group Objects to Scene", ""},
|
|
|
|
|
{OL_GROUPOP_INSTANCE, "INSTANCE", 0, "Instance Groups in Scene", ""},
|
|
|
|
|
{OL_GROUPOP_TOGVIS, "TOGVIS", 0, "Toggle Visible Group", ""},
|
|
|
|
|
{OL_GROUPOP_TOGSEL, "TOGSEL", 0, "Toggle Selectable", ""},
|
|
|
|
|
{OL_GROUPOP_TOGREN, "TOGREN", 0, "Toggle Renderable", ""},
|
|
|
|
|
{OL_GROUPOP_RENAME, "RENAME", 0, "Rename", ""},
|
2011-07-11 10:59:53 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int outliner_group_operation_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
SpaceOops *soops = CTX_wm_space_outliner(C);
|
2011-07-11 10:59:53 +00:00
|
|
|
int event;
|
|
|
|
|
|
|
|
|
|
/* check for invalid states */
|
|
|
|
|
if (soops == NULL)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
event = RNA_enum_get(op->ptr, "type");
|
2012-06-06 19:20:39 +00:00
|
|
|
|
|
|
|
|
switch (event) {
|
2015-02-12 07:43:32 +11:00
|
|
|
case OL_GROUPOP_UNLINK:
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb);
|
|
|
|
|
break;
|
|
|
|
|
case OL_GROUPOP_LOCAL:
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb);
|
|
|
|
|
break;
|
|
|
|
|
case OL_GROUPOP_LINK:
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb);
|
|
|
|
|
break;
|
|
|
|
|
case OL_GROUPOP_INSTANCE:
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_instance_cb);
|
|
|
|
|
break;
|
|
|
|
|
case OL_GROUPOP_TOGVIS:
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_visibility_cb);
|
|
|
|
|
break;
|
|
|
|
|
case OL_GROUPOP_TOGSEL:
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_selectability_cb);
|
|
|
|
|
break;
|
|
|
|
|
case OL_GROUPOP_TOGREN:
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_renderability_cb);
|
|
|
|
|
break;
|
|
|
|
|
case OL_GROUPOP_RENAME:
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb);
|
|
|
|
|
break;
|
2012-06-06 19:20:39 +00:00
|
|
|
default:
|
|
|
|
|
BLI_assert(0);
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-06 19:20:39 +00:00
|
|
|
|
|
|
|
|
if (event == 3) { /* instance */
|
|
|
|
|
/* works without this except if you try render right after, see: 22027 */
|
2013-02-21 19:33:04 +00:00
|
|
|
DAG_relations_tag_update(CTX_data_main(C));
|
2012-06-06 19:20:39 +00:00
|
|
|
}
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-06-06 19:20:39 +00:00
|
|
|
ED_undo_push(C, prop_group_op_types[event].name);
|
2011-07-11 10:59:53 +00:00
|
|
|
WM_event_add_notifier(C, NC_GROUP, NULL);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OUTLINER_OT_group_operation(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Outliner Group Operation";
|
|
|
|
|
ot->idname = "OUTLINER_OT_group_operation";
|
|
|
|
|
ot->description = "";
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
/* callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
|
ot->exec = outliner_group_operation_exec;
|
|
|
|
|
ot->poll = ED_operator_outliner_active;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = 0;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", prop_group_op_types, 0, "Group Operation", "");
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* **************************************** */
|
|
|
|
|
|
|
|
|
|
typedef enum eOutlinerIdOpTypes {
|
|
|
|
|
OUTLINER_IDOP_INVALID = 0,
|
2011-07-20 01:12:57 +00:00
|
|
|
|
2011-07-11 10:59:53 +00:00
|
|
|
OUTLINER_IDOP_UNLINK,
|
|
|
|
|
OUTLINER_IDOP_LOCAL,
|
2011-07-20 01:12:57 +00:00
|
|
|
OUTLINER_IDOP_SINGLE,
|
|
|
|
|
|
|
|
|
|
OUTLINER_IDOP_FAKE_ADD,
|
2011-09-02 08:35:46 +00:00
|
|
|
OUTLINER_IDOP_FAKE_CLEAR,
|
2012-07-25 19:45:34 +00:00
|
|
|
OUTLINER_IDOP_RENAME,
|
|
|
|
|
|
|
|
|
|
OUTLINER_IDOP_SELECT_LINKED
|
2011-07-11 10:59:53 +00:00
|
|
|
} eOutlinerIdOpTypes;
|
|
|
|
|
|
|
|
|
|
// TODO: implement support for changing the ID-block used
|
|
|
|
|
static EnumPropertyItem prop_id_op_types[] = {
|
|
|
|
|
{OUTLINER_IDOP_UNLINK, "UNLINK", 0, "Unlink", ""},
|
|
|
|
|
{OUTLINER_IDOP_LOCAL, "LOCAL", 0, "Make Local", ""},
|
|
|
|
|
{OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""},
|
2012-05-31 18:40:06 +00:00
|
|
|
{OUTLINER_IDOP_FAKE_ADD, "ADD_FAKE", 0, "Add Fake User",
|
2012-12-22 01:08:42 +00:00
|
|
|
"Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"},
|
2011-07-20 01:12:57 +00:00
|
|
|
{OUTLINER_IDOP_FAKE_CLEAR, "CLEAR_FAKE", 0, "Clear Fake User", ""},
|
2011-09-02 08:35:46 +00:00
|
|
|
{OUTLINER_IDOP_RENAME, "RENAME", 0, "Rename", ""},
|
2012-07-25 19:45:34 +00:00
|
|
|
{OUTLINER_IDOP_SELECT_LINKED, "SELECT_LINKED", 0, "Select Linked", ""},
|
2011-07-11 10:59:53 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int outliner_id_operation_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
SpaceOops *soops = CTX_wm_space_outliner(C);
|
|
|
|
|
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
|
2011-07-11 10:59:53 +00:00
|
|
|
eOutlinerIdOpTypes event;
|
|
|
|
|
|
|
|
|
|
/* check for invalid states */
|
|
|
|
|
if (soops == NULL)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
event = RNA_enum_get(op->ptr, "type");
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
switch (event) {
|
|
|
|
|
case OUTLINER_IDOP_UNLINK:
|
|
|
|
|
{
|
|
|
|
|
/* unlink datablock from its parent */
|
|
|
|
|
switch (idlevel) {
|
|
|
|
|
case ID_AC:
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_action_cb);
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
|
2011-07-11 10:59:53 +00:00
|
|
|
ED_undo_push(C, "Unlink action");
|
|
|
|
|
break;
|
|
|
|
|
case ID_MA:
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_material_cb);
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL);
|
2011-07-11 10:59:53 +00:00
|
|
|
ED_undo_push(C, "Unlink material");
|
|
|
|
|
break;
|
|
|
|
|
case ID_TE:
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_texture_cb);
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL);
|
2011-07-11 10:59:53 +00:00
|
|
|
ED_undo_push(C, "Unlink texture");
|
|
|
|
|
break;
|
2011-11-16 00:13:38 +00:00
|
|
|
case ID_WO:
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_world_cb);
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL);
|
2011-11-16 00:13:38 +00:00
|
|
|
ED_undo_push(C, "Unlink world");
|
|
|
|
|
break;
|
2011-07-11 10:59:53 +00:00
|
|
|
default:
|
2012-10-24 14:45:23 +00:00
|
|
|
BKE_report(op->reports, RPT_WARNING, "Not yet implemented");
|
2011-07-11 10:59:53 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
case OUTLINER_IDOP_LOCAL:
|
|
|
|
|
{
|
|
|
|
|
/* make local */
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb);
|
|
|
|
|
ED_undo_push(C, "Localized Data");
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
case OUTLINER_IDOP_SINGLE:
|
|
|
|
|
{
|
|
|
|
|
/* make single user */
|
|
|
|
|
switch (idlevel) {
|
|
|
|
|
case ID_AC:
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, singleuser_action_cb);
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
|
2011-07-11 10:59:53 +00:00
|
|
|
ED_undo_push(C, "Single-User Action");
|
|
|
|
|
break;
|
|
|
|
|
|
2011-11-16 00:13:38 +00:00
|
|
|
case ID_WO:
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, singleuser_world_cb);
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL);
|
2011-11-16 00:13:38 +00:00
|
|
|
ED_undo_push(C, "Single-User World");
|
|
|
|
|
break;
|
|
|
|
|
|
2011-07-11 10:59:53 +00:00
|
|
|
default:
|
2012-10-24 14:45:23 +00:00
|
|
|
BKE_report(op->reports, RPT_WARNING, "Not yet implemented");
|
2011-07-11 10:59:53 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2011-07-20 01:12:57 +00:00
|
|
|
case OUTLINER_IDOP_FAKE_ADD:
|
|
|
|
|
{
|
|
|
|
|
/* set fake user */
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_fake_user_set_cb);
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
|
2011-07-20 01:12:57 +00:00
|
|
|
ED_undo_push(C, "Add Fake User");
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2011-07-20 01:12:57 +00:00
|
|
|
}
|
|
|
|
|
case OUTLINER_IDOP_FAKE_CLEAR:
|
|
|
|
|
{
|
|
|
|
|
/* clear fake user */
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_fake_user_clear_cb);
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
|
2011-07-20 01:12:57 +00:00
|
|
|
ED_undo_push(C, "Clear Fake User");
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2011-07-20 01:12:57 +00:00
|
|
|
}
|
2011-09-02 08:35:46 +00:00
|
|
|
case OUTLINER_IDOP_RENAME:
|
2011-11-16 00:13:38 +00:00
|
|
|
{
|
2011-09-02 08:35:46 +00:00
|
|
|
/* rename */
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb);
|
2011-11-16 00:13:38 +00:00
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
|
2011-09-02 08:35:46 +00:00
|
|
|
ED_undo_push(C, "Rename");
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2011-11-16 00:13:38 +00:00
|
|
|
}
|
2012-07-25 19:45:34 +00:00
|
|
|
case OUTLINER_IDOP_SELECT_LINKED:
|
|
|
|
|
outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_select_linked_cb);
|
|
|
|
|
ED_undo_push(C, "Select");
|
|
|
|
|
break;
|
2011-07-20 01:12:57 +00:00
|
|
|
|
2011-07-11 10:59:53 +00:00
|
|
|
default:
|
|
|
|
|
// invalid - unhandled
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* wrong notifier still... */
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
// XXX: this is just so that outliner is always up to date
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL);
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OUTLINER_OT_id_operation(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Outliner ID data Operation";
|
|
|
|
|
ot->idname = "OUTLINER_OT_id_operation";
|
|
|
|
|
ot->description = "";
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
/* callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
|
ot->exec = outliner_id_operation_exec;
|
|
|
|
|
ot->poll = ED_operator_outliner_active;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = 0;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", prop_id_op_types, 0, "ID data Operation", "");
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* **************************************** */
|
|
|
|
|
|
|
|
|
|
static void outliner_do_id_set_operation(SpaceOops *soops, int type, ListBase *lb, ID *newid,
|
2012-05-07 17:56:30 +00:00
|
|
|
void (*operation_cb)(TreeElement *, TreeStoreElem *, TreeStoreElem *, ID *))
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
|
|
|
|
TreeElement *te;
|
|
|
|
|
TreeStoreElem *tselem;
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
for (te = lb->first; te; te = te->next) {
|
|
|
|
|
tselem = TREESTORE(te);
|
2011-07-11 10:59:53 +00:00
|
|
|
if (tselem->flag & TSE_SELECTED) {
|
2012-05-07 17:56:30 +00:00
|
|
|
if (tselem->type == type) {
|
2012-05-28 15:37:43 +00:00
|
|
|
TreeStoreElem *tsep = te->parent ? TREESTORE(te->parent) : NULL;
|
2011-07-11 10:59:53 +00:00
|
|
|
operation_cb(te, tselem, tsep, newid);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-04-29 15:47:02 +00:00
|
|
|
if (TSELEM_OPEN(tselem, soops)) {
|
2011-07-11 10:59:53 +00:00
|
|
|
outliner_do_id_set_operation(soops, type, &te->subtree, newid, operation_cb);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------ */
|
|
|
|
|
|
2011-08-30 09:50:31 +00:00
|
|
|
static void actionset_id_cb(TreeElement *UNUSED(te), TreeStoreElem *tselem, TreeStoreElem *tsep, ID *actId)
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
|
|
|
|
bAction *act = (bAction *)actId;
|
|
|
|
|
|
|
|
|
|
if (tselem->type == TSE_ANIM_DATA) {
|
|
|
|
|
/* "animation" entries - action is child of this */
|
|
|
|
|
BKE_animdata_set_action(NULL, tselem->id, act);
|
|
|
|
|
}
|
|
|
|
|
/* TODO: if any other "expander" channels which own actions need to support this menu,
|
|
|
|
|
* add: tselem->type = ...
|
|
|
|
|
*/
|
|
|
|
|
else if (tsep && (tsep->type == TSE_ANIM_DATA)) {
|
|
|
|
|
/* "animation" entries case again */
|
|
|
|
|
BKE_animdata_set_action(NULL, tsep->id, act);
|
|
|
|
|
}
|
|
|
|
|
// TODO: other cases not supported yet
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int outliner_action_set_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
SpaceOops *soops = CTX_wm_space_outliner(C);
|
|
|
|
|
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
bAction *act;
|
|
|
|
|
|
|
|
|
|
/* check for invalid states */
|
|
|
|
|
if (soops == NULL)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
|
|
|
|
|
|
|
|
|
|
/* get action to use */
|
2012-05-07 17:56:30 +00:00
|
|
|
act = BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action"));
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
if (act == NULL) {
|
2012-10-26 17:32:50 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "No valid action to add");
|
2011-07-11 10:59:53 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
else if (act->idroot == 0) {
|
|
|
|
|
/* hopefully in this case (i.e. library of userless actions), the user knows what they're doing... */
|
|
|
|
|
BKE_reportf(op->reports, RPT_WARNING,
|
2012-10-16 07:53:10 +00:00
|
|
|
"Action '%s' does not specify what datablocks it can be used on "
|
|
|
|
|
"(try setting the 'ID Root Type' setting from the Datablocks Editor "
|
2012-10-26 17:32:50 +00:00
|
|
|
"for this action to avoid future problems)",
|
2012-05-07 17:56:30 +00:00
|
|
|
act->id.name + 2);
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* perform action if valid channel */
|
|
|
|
|
if (datalevel == TSE_ANIM_DATA)
|
2012-05-07 17:56:30 +00:00
|
|
|
outliner_do_id_set_operation(soops, datalevel, &soops->tree, (ID *)act, actionset_id_cb);
|
2011-07-11 10:59:53 +00:00
|
|
|
else if (idlevel == ID_AC)
|
2012-05-07 17:56:30 +00:00
|
|
|
outliner_do_id_set_operation(soops, idlevel, &soops->tree, (ID *)act, actionset_id_cb);
|
2011-07-11 10:59:53 +00:00
|
|
|
else
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
/* set notifier that things have changed */
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
|
2011-07-11 10:59:53 +00:00
|
|
|
ED_undo_push(C, "Set action");
|
|
|
|
|
|
|
|
|
|
/* done */
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OUTLINER_OT_action_set(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Outliner Set Action";
|
|
|
|
|
ot->idname = "OUTLINER_OT_action_set";
|
|
|
|
|
ot->description = "Change the active action used";
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_enum_search_invoke;
|
|
|
|
|
ot->exec = outliner_action_set_exec;
|
|
|
|
|
ot->poll = ED_operator_outliner_active;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = 0;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
/* props */
|
2012-05-07 17:56:30 +00:00
|
|
|
// TODO: this would be nicer as an ID-pointer...
|
|
|
|
|
prop = RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", "");
|
2011-07-11 10:59:53 +00:00
|
|
|
RNA_def_enum_funcs(prop, RNA_action_itemf);
|
2014-05-05 15:09:29 +10:00
|
|
|
RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = prop;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* **************************************** */
|
|
|
|
|
|
|
|
|
|
typedef enum eOutliner_AnimDataOps {
|
|
|
|
|
OUTLINER_ANIMOP_INVALID = 0,
|
|
|
|
|
|
2014-07-06 20:55:10 +12:00
|
|
|
OUTLINER_ANIMOP_CLEAR_ADT,
|
|
|
|
|
|
2011-07-11 10:59:53 +00:00
|
|
|
OUTLINER_ANIMOP_SET_ACT,
|
|
|
|
|
OUTLINER_ANIMOP_CLEAR_ACT,
|
|
|
|
|
|
|
|
|
|
OUTLINER_ANIMOP_REFRESH_DRV,
|
|
|
|
|
OUTLINER_ANIMOP_CLEAR_DRV
|
|
|
|
|
|
|
|
|
|
//OUTLINER_ANIMOP_COPY_DRIVERS,
|
|
|
|
|
//OUTLINER_ANIMOP_PASTE_DRIVERS
|
|
|
|
|
} eOutliner_AnimDataOps;
|
|
|
|
|
|
|
|
|
|
static EnumPropertyItem prop_animdata_op_types[] = {
|
2014-07-06 20:55:10 +12:00
|
|
|
{OUTLINER_ANIMOP_CLEAR_ADT, "CLEAR_ANIMDATA", 0, "Clear Animation Data", "Remove this animation data container"},
|
2011-07-11 10:59:53 +00:00
|
|
|
{OUTLINER_ANIMOP_SET_ACT, "SET_ACT", 0, "Set Action", ""},
|
|
|
|
|
{OUTLINER_ANIMOP_CLEAR_ACT, "CLEAR_ACT", 0, "Unlink Action", ""},
|
|
|
|
|
{OUTLINER_ANIMOP_REFRESH_DRV, "REFRESH_DRIVERS", 0, "Refresh Drivers", ""},
|
|
|
|
|
//{OUTLINER_ANIMOP_COPY_DRIVERS, "COPY_DRIVERS", 0, "Copy Drivers", ""},
|
|
|
|
|
//{OUTLINER_ANIMOP_PASTE_DRIVERS, "PASTE_DRIVERS", 0, "Paste Drivers", ""},
|
|
|
|
|
{OUTLINER_ANIMOP_CLEAR_DRV, "CLEAR_DRIVERS", 0, "Clear Drivers", ""},
|
|
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int outliner_animdata_operation_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
SpaceOops *soops = CTX_wm_space_outliner(C);
|
|
|
|
|
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
|
2011-07-11 10:59:53 +00:00
|
|
|
eOutliner_AnimDataOps event;
|
|
|
|
|
short updateDeps = 0;
|
|
|
|
|
|
|
|
|
|
/* check for invalid states */
|
|
|
|
|
if (soops == NULL)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
event = RNA_enum_get(op->ptr, "type");
|
2011-07-11 10:59:53 +00:00
|
|
|
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
|
|
|
|
|
|
|
|
|
|
if (datalevel != TSE_ANIM_DATA)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
/* perform the core operation */
|
|
|
|
|
switch (event) {
|
2014-07-06 20:55:10 +12:00
|
|
|
case OUTLINER_ANIMOP_CLEAR_ADT:
|
|
|
|
|
/* Remove Animation Data - this may remove the active action, in some cases... */
|
|
|
|
|
outliner_do_data_operation(soops, datalevel, event, &soops->tree, clear_animdata_cb, NULL);
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
|
|
|
|
|
ED_undo_push(C, "Clear Animation Data");
|
|
|
|
|
break;
|
|
|
|
|
|
2011-07-11 10:59:53 +00:00
|
|
|
case OUTLINER_ANIMOP_SET_ACT:
|
|
|
|
|
/* delegate once again... */
|
|
|
|
|
WM_operator_name_call(C, "OUTLINER_OT_action_set", WM_OP_INVOKE_REGION_WIN, NULL);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OUTLINER_ANIMOP_CLEAR_ACT:
|
|
|
|
|
/* clear active action - using standard rules */
|
2012-05-29 05:45:06 +00:00
|
|
|
outliner_do_data_operation(soops, datalevel, event, &soops->tree, unlinkact_animdata_cb, NULL);
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
|
2011-07-11 10:59:53 +00:00
|
|
|
ED_undo_push(C, "Unlink action");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OUTLINER_ANIMOP_REFRESH_DRV:
|
2012-05-29 05:45:06 +00:00
|
|
|
outliner_do_data_operation(soops, datalevel, event, &soops->tree, refreshdrivers_animdata_cb, NULL);
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL);
|
2011-07-11 10:59:53 +00:00
|
|
|
//ED_undo_push(C, "Refresh Drivers"); /* no undo needed - shouldn't have any impact? */
|
|
|
|
|
updateDeps = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OUTLINER_ANIMOP_CLEAR_DRV:
|
2012-05-29 05:45:06 +00:00
|
|
|
outliner_do_data_operation(soops, datalevel, event, &soops->tree, cleardrivers_animdata_cb, NULL);
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL);
|
2011-07-11 10:59:53 +00:00
|
|
|
ED_undo_push(C, "Clear Drivers");
|
|
|
|
|
updateDeps = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default: // invalid
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* update dependencies */
|
|
|
|
|
if (updateDeps) {
|
|
|
|
|
/* rebuild depsgraph for the new deps */
|
2013-02-21 19:33:04 +00:00
|
|
|
DAG_relations_tag_update(CTX_data_main(C));
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OUTLINER_OT_animdata_operation(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Outliner Animation Data Operation";
|
|
|
|
|
ot->idname = "OUTLINER_OT_animdata_operation";
|
|
|
|
|
ot->description = "";
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
/* callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
|
ot->exec = outliner_animdata_operation_exec;
|
|
|
|
|
ot->poll = ED_operator_outliner_active;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = 0;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", prop_animdata_op_types, 0, "Animation Operation", "");
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* **************************************** */
|
|
|
|
|
|
2015-02-12 07:25:36 +11:00
|
|
|
static EnumPropertyItem prop_constraint_op_types[] = {
|
|
|
|
|
{OL_CONSTRAINTOP_ENABLE, "ENABLE", ICON_RESTRICT_VIEW_OFF, "Enable", ""},
|
|
|
|
|
{OL_CONSTRAINTOP_DISABLE, "DISABLE", ICON_RESTRICT_VIEW_ON, "Disable", ""},
|
|
|
|
|
{OL_CONSTRAINTOP_DELETE, "DELETE", ICON_X, "Delete", ""},
|
|
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int outliner_constraint_operation_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
SpaceOops *soops = CTX_wm_space_outliner(C);
|
|
|
|
|
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
|
|
|
|
|
eOutliner_PropConstraintOps event;
|
|
|
|
|
|
|
|
|
|
event = RNA_enum_get(op->ptr, "type");
|
|
|
|
|
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
|
|
|
|
|
|
|
|
|
|
outliner_do_data_operation(soops, datalevel, event, &soops->tree, constraint_cb, C);
|
|
|
|
|
|
|
|
|
|
if (event == OL_CONSTRAINTOP_DELETE) {
|
|
|
|
|
outliner_cleanup_tree(soops);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ED_undo_push(C, "Constraint operation");
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OUTLINER_OT_constraint_operation(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Outliner Constraint Operation";
|
|
|
|
|
ot->idname = "OUTLINER_OT_constraint_operation";
|
2015-02-16 20:00:20 +01:00
|
|
|
ot->description = "";
|
2015-02-12 07:25:36 +11:00
|
|
|
|
|
|
|
|
/* callbacks */
|
|
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
|
ot->exec = outliner_constraint_operation_exec;
|
|
|
|
|
ot->poll = ED_operator_outliner_active;
|
|
|
|
|
|
|
|
|
|
ot->flag = 0;
|
|
|
|
|
|
|
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", prop_constraint_op_types, 0, "Constraint Operation", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ******************** */
|
|
|
|
|
|
|
|
|
|
static EnumPropertyItem prop_modifier_op_types[] = {
|
|
|
|
|
{OL_MODIFIER_OP_TOGVIS, "TOGVIS", ICON_RESTRICT_VIEW_OFF, "Toggle viewport use", ""},
|
|
|
|
|
{OL_MODIFIER_OP_TOGREN, "TOGREN", ICON_RESTRICT_RENDER_OFF, "Toggle render use", ""},
|
|
|
|
|
{OL_MODIFIER_OP_DELETE, "DELETE", ICON_X, "Delete", ""},
|
|
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int outliner_modifier_operation_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
SpaceOops *soops = CTX_wm_space_outliner(C);
|
|
|
|
|
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
|
|
|
|
|
eOutliner_PropModifierOps event;
|
|
|
|
|
|
|
|
|
|
event = RNA_enum_get(op->ptr, "type");
|
|
|
|
|
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
|
|
|
|
|
|
|
|
|
|
outliner_do_data_operation(soops, datalevel, event, &soops->tree, modifier_cb, C);
|
|
|
|
|
|
|
|
|
|
if (event == OL_MODIFIER_OP_DELETE) {
|
|
|
|
|
outliner_cleanup_tree(soops);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ED_undo_push(C, "Modifier operation");
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OUTLINER_OT_modifier_operation(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Outliner Modifier Operation";
|
|
|
|
|
ot->idname = "OUTLINER_OT_modifier_operation";
|
2015-02-16 20:00:20 +01:00
|
|
|
ot->description = "";
|
2015-02-12 07:25:36 +11:00
|
|
|
|
|
|
|
|
/* callbacks */
|
|
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
|
ot->exec = outliner_modifier_operation_exec;
|
|
|
|
|
ot->poll = ED_operator_outliner_active;
|
|
|
|
|
|
|
|
|
|
ot->flag = 0;
|
|
|
|
|
|
|
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", prop_modifier_op_types, 0, "Modifier Operation", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ******************** */
|
|
|
|
|
|
2011-07-11 10:59:53 +00:00
|
|
|
static EnumPropertyItem prop_data_op_types[] = {
|
2015-01-22 10:47:53 +11:00
|
|
|
{OL_DOP_SELECT, "SELECT", 0, "Select", ""},
|
|
|
|
|
{OL_DOP_DESELECT, "DESELECT", 0, "Deselect", ""},
|
|
|
|
|
{OL_DOP_HIDE, "HIDE", 0, "Hide", ""},
|
|
|
|
|
{OL_DOP_UNHIDE, "UNHIDE", 0, "Unhide", ""},
|
|
|
|
|
{OL_DOP_SELECT_LINKED, "SELECT_LINKED", 0, "Select Linked", ""},
|
2011-07-11 10:59:53 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int outliner_data_operation_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
SpaceOops *soops = CTX_wm_space_outliner(C);
|
|
|
|
|
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
|
2015-01-22 10:47:53 +11:00
|
|
|
eOutliner_PropDataOps event;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
/* check for invalid states */
|
|
|
|
|
if (soops == NULL)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
event = RNA_enum_get(op->ptr, "type");
|
2011-07-11 10:59:53 +00:00
|
|
|
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
|
|
|
|
|
|
2012-10-08 08:44:48 +00:00
|
|
|
switch (datalevel) {
|
|
|
|
|
case TSE_POSE_CHANNEL:
|
|
|
|
|
{
|
2012-05-29 05:45:06 +00:00
|
|
|
outliner_do_data_operation(soops, datalevel, event, &soops->tree, pchan_cb, NULL);
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
|
2011-07-11 10:59:53 +00:00
|
|
|
ED_undo_push(C, "PoseChannel operation");
|
|
|
|
|
}
|
2012-10-08 08:44:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TSE_BONE:
|
|
|
|
|
{
|
2012-05-29 05:45:06 +00:00
|
|
|
outliner_do_data_operation(soops, datalevel, event, &soops->tree, bone_cb, NULL);
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
|
2011-07-11 10:59:53 +00:00
|
|
|
ED_undo_push(C, "Bone operation");
|
|
|
|
|
}
|
2012-10-08 08:44:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TSE_EBONE:
|
|
|
|
|
{
|
2012-05-29 05:45:06 +00:00
|
|
|
outliner_do_data_operation(soops, datalevel, event, &soops->tree, ebone_cb, NULL);
|
2012-05-07 17:56:30 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
|
2011-07-11 10:59:53 +00:00
|
|
|
ED_undo_push(C, "EditBone operation");
|
|
|
|
|
}
|
2012-10-08 08:44:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TSE_SEQUENCE:
|
|
|
|
|
{
|
2012-05-29 05:45:06 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
outliner_do_data_operation(soops, datalevel, event, &soops->tree, sequence_cb, scene);
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
2012-10-08 08:44:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TSE_RNA_STRUCT:
|
2015-01-22 10:47:53 +11:00
|
|
|
if (event == OL_DOP_SELECT_LINKED) {
|
2012-10-08 08:44:48 +00:00
|
|
|
outliner_do_data_operation(soops, datalevel, event, &soops->tree, data_select_linked_cb, C);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2012-10-24 14:45:23 +00:00
|
|
|
BKE_report(op->reports, RPT_WARNING, "Not yet implemented");
|
2012-10-08 08:44:48 +00:00
|
|
|
break;
|
2012-07-25 20:17:38 +00:00
|
|
|
}
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OUTLINER_OT_data_operation(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Outliner Data Operation";
|
|
|
|
|
ot->idname = "OUTLINER_OT_data_operation";
|
|
|
|
|
ot->description = "";
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
/* callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
|
ot->exec = outliner_data_operation_exec;
|
|
|
|
|
ot->poll = ED_operator_outliner_active;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = 0;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", prop_data_op_types, 0, "Data Operation", "");
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ******************** */
|
|
|
|
|
|
|
|
|
|
|
2012-05-31 18:40:06 +00:00
|
|
|
static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops,
|
2013-03-13 09:03:46 +00:00
|
|
|
TreeElement *te, const wmEvent *event, const float mval[2])
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
|
|
|
|
ReportList *reports = CTX_wm_reports(C); // XXX...
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) {
|
|
|
|
|
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
|
|
|
|
|
TreeStoreElem *tselem = TREESTORE(te);
|
2011-07-11 10:59:53 +00:00
|
|
|
|
|
|
|
|
/* select object that's clicked on and popup context menu */
|
|
|
|
|
if (!(tselem->flag & TSE_SELECTED)) {
|
|
|
|
|
|
2014-01-16 19:15:53 +11:00
|
|
|
if (outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1))
|
2011-07-11 10:59:53 +00:00
|
|
|
outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0);
|
|
|
|
|
|
|
|
|
|
tselem->flag |= TSE_SELECTED;
|
|
|
|
|
/* redraw, same as outliner_select function */
|
|
|
|
|
soops->storeflag |= SO_TREESTORE_REDRAW;
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel);
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scenelevel) {
|
2012-04-21 12:51:47 +00:00
|
|
|
//if (objectlevel || datalevel || idlevel) error("Mixed selection");
|
2011-07-11 10:59:53 +00:00
|
|
|
//else pupmenu("Scene Operations%t|Delete");
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (objectlevel) {
|
2011-07-11 10:59:53 +00:00
|
|
|
WM_operator_name_call(C, "OUTLINER_OT_object_operation", WM_OP_INVOKE_REGION_WIN, NULL);
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (idlevel) {
|
2013-03-09 03:46:30 +00:00
|
|
|
if (idlevel == -1 || datalevel) {
|
|
|
|
|
BKE_report(reports, RPT_WARNING, "Mixed selection");
|
|
|
|
|
}
|
2011-07-11 10:59:53 +00:00
|
|
|
else {
|
2012-05-07 17:56:30 +00:00
|
|
|
if (idlevel == ID_GR)
|
2011-07-11 10:59:53 +00:00
|
|
|
WM_operator_name_call(C, "OUTLINER_OT_group_operation", WM_OP_INVOKE_REGION_WIN, NULL);
|
|
|
|
|
else
|
|
|
|
|
WM_operator_name_call(C, "OUTLINER_OT_id_operation", WM_OP_INVOKE_REGION_WIN, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (datalevel) {
|
2013-03-09 03:46:30 +00:00
|
|
|
if (datalevel == -1) {
|
|
|
|
|
BKE_report(reports, RPT_WARNING, "Mixed selection");
|
|
|
|
|
}
|
2011-07-11 10:59:53 +00:00
|
|
|
else {
|
|
|
|
|
if (datalevel == TSE_ANIM_DATA)
|
|
|
|
|
WM_operator_name_call(C, "OUTLINER_OT_animdata_operation", WM_OP_INVOKE_REGION_WIN, NULL);
|
2012-10-14 13:08:19 +00:00
|
|
|
else if (datalevel == TSE_DRIVER_BASE) {
|
|
|
|
|
/* do nothing... no special ops needed yet */
|
|
|
|
|
}
|
2014-07-20 01:30:29 +10:00
|
|
|
else if (ELEM(datalevel, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS)) {
|
2012-10-14 13:08:19 +00:00
|
|
|
/*WM_operator_name_call(C, "OUTLINER_OT_renderdata_operation", WM_OP_INVOKE_REGION_WIN, NULL)*/
|
|
|
|
|
}
|
2015-02-16 00:19:47 +13:00
|
|
|
else if (datalevel == TSE_ID_BASE) {
|
|
|
|
|
/* do nothing... there are no ops needed here yet */
|
|
|
|
|
}
|
2015-02-12 07:25:36 +11:00
|
|
|
else if (datalevel == TSE_CONSTRAINT) {
|
|
|
|
|
WM_operator_name_call(C, "OUTLINER_OT_constraint_operation", WM_OP_INVOKE_REGION_WIN, NULL);
|
|
|
|
|
}
|
|
|
|
|
else if (datalevel == TSE_MODIFIER) {
|
|
|
|
|
WM_operator_name_call(C, "OUTLINER_OT_modifier_operation", WM_OP_INVOKE_REGION_WIN, NULL);
|
|
|
|
|
}
|
2012-10-14 13:08:19 +00:00
|
|
|
else {
|
2011-07-11 10:59:53 +00:00
|
|
|
WM_operator_name_call(C, "OUTLINER_OT_data_operation", WM_OP_INVOKE_REGION_WIN, NULL);
|
2012-10-14 13:08:19 +00:00
|
|
|
}
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
for (te = te->subtree.first; te; te = te->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (do_outliner_operation_event(C, scene, ar, soops, te, event, mval))
|
2011-07-11 10:59:53 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int outliner_operation(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
|
2011-07-11 10:59:53 +00:00
|
|
|
{
|
2012-05-07 17:56:30 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
ARegion *ar = CTX_wm_region(C);
|
|
|
|
|
SpaceOops *soops = CTX_wm_space_outliner(C);
|
2011-07-11 10:59:53 +00:00
|
|
|
TreeElement *te;
|
|
|
|
|
float fmval[2];
|
2012-10-14 13:08:19 +00:00
|
|
|
|
2014-04-21 16:47:16 +10:00
|
|
|
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-05-07 17:56:30 +00:00
|
|
|
for (te = soops->tree.first; te; te = te->next) {
|
2012-10-14 13:08:19 +00:00
|
|
|
if (do_outliner_operation_event(C, scene, ar, soops, te, event, fmval)) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Menu only! Calls other operators */
|
|
|
|
|
void OUTLINER_OT_operation(wmOperatorType *ot)
|
|
|
|
|
{
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Execute Operation";
|
|
|
|
|
ot->idname = "OUTLINER_OT_operation";
|
|
|
|
|
ot->description = "Context menu for item operations";
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = outliner_operation;
|
2011-07-11 10:59:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_outliner_active;
|
2011-07-11 10:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ****************************************************** */
|