2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-13 18:09:49 +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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-13 18:09:49 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_node/node_header.c
|
|
|
|
|
* \ingroup spnode
|
|
|
|
|
*/
|
|
|
|
|
|
2008-12-13 18:09:49 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "DNA_space_types.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
#include "DNA_node_types.h"
|
2008-12-13 18:09:49 +00:00
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-13 18:09:49 +00:00
|
|
|
|
2011-09-20 07:39:25 +00:00
|
|
|
#include "BLF_translation.h"
|
2011-07-13 14:41:12 +00:00
|
|
|
|
2012-09-12 11:09:27 +00:00
|
|
|
#include "BKE_blender.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "BKE_global.h"
|
2008-12-25 18:29:56 +00:00
|
|
|
#include "BKE_main.h"
|
2011-11-02 19:24:30 +00:00
|
|
|
#include "BKE_node.h"
|
|
|
|
|
#include "BKE_scene.h"
|
|
|
|
|
#include "BKE_screen.h"
|
2008-12-13 18:09:49 +00:00
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
2010-09-23 20:16:45 +00:00
|
|
|
#include "UI_view2d.h"
|
2008-12-13 18:09:49 +00:00
|
|
|
|
2012-08-02 23:03:16 +00:00
|
|
|
#include "node_intern.h" /* own include */
|
2008-12-13 18:09:49 +00:00
|
|
|
|
2009-08-19 00:55:30 +00:00
|
|
|
/* ************************ add menu *********************** */
|
2008-12-13 18:09:49 +00:00
|
|
|
|
2009-08-19 00:55:30 +00:00
|
|
|
static void node_menu_add(const bContext *C, Menu *menu)
|
2008-12-25 18:29:56 +00:00
|
|
|
{
|
2012-08-04 12:54:27 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
|
uiLayout *layout = menu->layout;
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeTree *ntree = snode->edittree;
|
2008-12-25 18:29:56 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (!ntree || !ntree->typeinfo || !ntree->typeinfo->draw_add_menu) {
|
2012-06-19 23:08:16 +00:00
|
|
|
uiLayoutSetActive(layout, FALSE);
|
2013-03-18 16:34:57 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-08 16:44:16 +00:00
|
|
|
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
|
2013-02-15 14:30:36 +00:00
|
|
|
uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Search ..."), 0, "NODE_OT_add_search");
|
2012-08-08 16:44:16 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
ntree->typeinfo->draw_add_menu(C, layout, ntree);
|
2008-12-25 18:29:56 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-15 09:07:19 +00:00
|
|
|
void node_menus_register(void)
|
2009-08-19 00:55:30 +00:00
|
|
|
{
|
|
|
|
|
MenuType *mt;
|
|
|
|
|
|
2012-08-04 12:54:27 +00:00
|
|
|
mt = MEM_callocN(sizeof(MenuType), "spacetype node menu add");
|
2009-08-19 00:55:30 +00:00
|
|
|
strcpy(mt->idname, "NODE_MT_add");
|
2013-03-27 19:09:50 +00:00
|
|
|
strcpy(mt->label, N_("Add"));
|
|
|
|
|
strcpy(mt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA);
|
2012-08-04 12:54:27 +00:00
|
|
|
mt->draw = node_menu_add;
|
2009-10-08 19:06:32 +00:00
|
|
|
WM_menutype_add(mt);
|
2009-08-19 00:55:30 +00:00
|
|
|
}
|