2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-28 00:08:34 +00:00
|
|
|
* 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
|
2018-06-01 18:19:39 +02:00
|
|
|
* of the License, or (at your option) any later version.
|
2008-12-28 00:08:34 +00:00
|
|
|
*
|
|
|
|
|
* 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-28 00:08:34 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup spnode
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
#include <array>
|
|
|
|
|
#include <cstdlib>
|
2013-04-02 03:51:42 +00:00
|
|
|
|
2008-12-28 00:08:34 +00:00
|
|
|
#include "DNA_node_types.h"
|
2020-05-25 10:43:44 +02:00
|
|
|
#include "DNA_windowmanager_types.h"
|
2008-12-28 00:08:34 +00:00
|
|
|
|
2018-02-18 21:27:33 +11:00
|
|
|
#include "BLI_lasso_2d.h"
|
2020-04-03 17:38:58 +02:00
|
|
|
#include "BLI_listbase.h"
|
2014-07-04 14:17:54 +02:00
|
|
|
#include "BLI_math.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_rect.h"
|
2013-04-01 15:07:22 +00:00
|
|
|
#include "BLI_string.h"
|
2020-09-09 13:44:39 +02:00
|
|
|
#include "BLI_string_search.h"
|
2014-07-04 14:17:54 +02:00
|
|
|
#include "BLI_string_utf8.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-28 00:08:34 +00:00
|
|
|
|
2013-01-24 21:57:13 +00:00
|
|
|
#include "BKE_context.h"
|
|
|
|
|
#include "BKE_main.h"
|
|
|
|
|
#include "BKE_node.h"
|
2020-05-25 10:43:44 +02:00
|
|
|
#include "BKE_workspace.h"
|
2013-01-24 21:57:13 +00:00
|
|
|
|
2012-08-02 23:03:16 +00:00
|
|
|
#include "ED_node.h" /* own include */
|
2008-12-28 00:08:34 +00:00
|
|
|
#include "ED_screen.h"
|
2018-08-14 10:28:41 +10:00
|
|
|
#include "ED_select_utils.h"
|
2021-07-05 10:46:00 +02:00
|
|
|
#include "ED_spreadsheet.h"
|
2020-05-25 10:43:44 +02:00
|
|
|
#include "ED_view3d.h"
|
2008-12-28 00:08:34 +00:00
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
2013-04-01 15:07:22 +00:00
|
|
|
#include "UI_interface.h"
|
|
|
|
|
#include "UI_resources.h"
|
2008-12-28 00:08:34 +00:00
|
|
|
#include "UI_view2d.h"
|
2012-08-22 13:34:06 +00:00
|
|
|
|
2020-05-11 10:29:41 -03:00
|
|
|
#include "DEG_depsgraph.h"
|
|
|
|
|
|
2012-08-22 13:34:06 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2012-08-02 23:03:16 +00:00
|
|
|
#include "node_intern.h" /* own include */
|
2010-01-06 03:00:19 +00:00
|
|
|
|
2021-01-20 15:15:38 +11:00
|
|
|
/**
|
|
|
|
|
* Function to detect if there is a visible view3d that uses workbench in texture mode.
|
2020-05-25 10:43:44 +02:00
|
|
|
* This function is for fixing T76970 for Blender 2.83. The actual fix should add a mechanism in
|
|
|
|
|
* the depsgraph that can be used by the draw engines to check if they need to be redrawn.
|
|
|
|
|
*
|
|
|
|
|
* We don't want to add these risky changes this close before releasing 2.83 without good testing
|
|
|
|
|
* hence this workaround. There are still cases were too many updates happen. For example when you
|
|
|
|
|
* have both a Cycles and workbench with textures viewport.
|
2021-01-20 15:15:38 +11:00
|
|
|
*/
|
2020-05-25 10:43:44 +02:00
|
|
|
static bool has_workbench_in_texture_color(const wmWindowManager *wm,
|
|
|
|
|
const Scene *scene,
|
|
|
|
|
const Object *ob)
|
|
|
|
|
{
|
|
|
|
|
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
|
|
|
|
if (win->scene != scene) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
|
|
|
|
|
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
|
|
|
|
if (area->spacetype == SPACE_VIEW3D) {
|
2021-06-02 17:19:36 +02:00
|
|
|
const View3D *v3d = (const View3D *)area->spacedata.first;
|
2020-05-25 10:43:44 +02:00
|
|
|
|
|
|
|
|
if (ED_view3d_has_workbench_in_texture_color(scene, ob, v3d)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-08 16:59:48 +11:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Public Node Selection API
|
|
|
|
|
* \{ */
|
2010-01-06 03:00:19 +00:00
|
|
|
|
2012-06-01 12:38:03 +00:00
|
|
|
static bNode *node_under_mouse_select(bNodeTree *ntree, int mx, int my)
|
2010-01-06 03:00:19 +00:00
|
|
|
{
|
|
|
|
|
bNode *node;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (node = (bNode *)ntree->nodes.last; node; node = node->prev) {
|
2012-06-01 12:38:03 +00:00
|
|
|
if (node->typeinfo->select_area_func) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->typeinfo->select_area_func(node, mx, my)) {
|
2012-06-01 12:38:03 +00:00
|
|
|
return node;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-06-01 12:38:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
2021-06-02 17:19:36 +02:00
|
|
|
return nullptr;
|
2012-06-01 12:38:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bNode *node_under_mouse_tweak(bNodeTree *ntree, int mx, int my)
|
|
|
|
|
{
|
|
|
|
|
bNode *node;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (node = (bNode *)ntree->nodes.last; node; node = node->prev) {
|
2012-06-01 12:38:03 +00:00
|
|
|
if (node->typeinfo->tweak_area_func) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->typeinfo->tweak_area_func(node, mx, my)) {
|
2012-06-01 12:38:03 +00:00
|
|
|
return node;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-06-01 12:38:03 +00:00
|
|
|
}
|
2010-01-06 03:00:19 +00:00
|
|
|
}
|
2021-06-02 17:19:36 +02:00
|
|
|
return nullptr;
|
2010-01-06 03:00:19 +00:00
|
|
|
}
|
|
|
|
|
|
2018-12-20 10:55:30 +01:00
|
|
|
static bool is_position_over_node_or_socket(SpaceNode *snode, float mouse[2])
|
|
|
|
|
{
|
|
|
|
|
if (node_under_mouse_tweak(snode->edittree, mouse[0], mouse[1])) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bNode *node;
|
|
|
|
|
bNodeSocket *sock;
|
|
|
|
|
if (node_find_indicated_socket(snode, &node, &sock, mouse, SOCK_IN | SOCK_OUT)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool is_event_over_node_or_socket(bContext *C, const wmEvent *event)
|
|
|
|
|
{
|
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2018-12-20 10:55:30 +01:00
|
|
|
float mouse[2];
|
2020-03-06 16:56:42 +01:00
|
|
|
UI_view2d_region_to_view(®ion->v2d, event->mval[0], event->mval[1], &mouse[0], &mouse[1]);
|
2018-12-20 10:55:30 +01:00
|
|
|
return is_position_over_node_or_socket(snode, mouse);
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-09 10:16:41 +00:00
|
|
|
static void node_toggle(bNode *node)
|
|
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
nodeSetSelected(node, !(node->flag & SELECT));
|
2012-03-09 10:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-14 18:10:57 +00:00
|
|
|
void node_socket_select(bNode *node, bNodeSocket *sock)
|
2012-03-09 10:16:41 +00:00
|
|
|
{
|
|
|
|
|
sock->flag |= SELECT;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-09 10:16:41 +00:00
|
|
|
/* select node too */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node) {
|
2012-03-09 10:16:41 +00:00
|
|
|
node->flag |= SELECT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-03-09 10:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
void node_socket_deselect(bNode *node, bNodeSocket *sock, const bool deselect_node)
|
2012-03-09 10:16:41 +00:00
|
|
|
{
|
|
|
|
|
sock->flag &= ~SELECT;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-09 10:16:41 +00:00
|
|
|
if (node && deselect_node) {
|
2021-06-02 17:19:36 +02:00
|
|
|
bool sel = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-09 10:16:41 +00:00
|
|
|
/* if no selected sockets remain, also deselect the node */
|
2021-06-02 17:19:36 +02:00
|
|
|
for (sock = (bNodeSocket *)node->inputs.first; sock; sock = sock->next) {
|
2012-03-09 10:16:41 +00:00
|
|
|
if (sock->flag & SELECT) {
|
2021-06-02 17:19:36 +02:00
|
|
|
sel = true;
|
2012-03-09 10:16:41 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-02 17:19:36 +02:00
|
|
|
for (sock = (bNodeSocket *)node->outputs.first; sock; sock = sock->next) {
|
2012-03-09 10:16:41 +00:00
|
|
|
if (sock->flag & SELECT) {
|
2021-06-02 17:19:36 +02:00
|
|
|
sel = true;
|
2012-03-09 10:16:41 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!sel) {
|
2012-03-09 10:16:41 +00:00
|
|
|
node->flag &= ~SELECT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-03-09 10:16:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void node_socket_toggle(bNode *node, bNodeSocket *sock, int deselect_node)
|
|
|
|
|
{
|
2019-03-26 21:16:47 +11:00
|
|
|
if (sock->flag & SELECT) {
|
2012-03-09 10:16:41 +00:00
|
|
|
node_socket_deselect(node, sock, deselect_node);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-09 10:16:41 +00:00
|
|
|
node_socket_select(node, sock);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-03-09 10:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-18 12:51:50 +00:00
|
|
|
/* no undo here! */
|
|
|
|
|
void node_deselect_all(SpaceNode *snode)
|
|
|
|
|
{
|
|
|
|
|
bNode *node;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
2014-04-01 11:34:00 +11:00
|
|
|
nodeSetSelected(node, false);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-03-09 10:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
void node_deselect_all_input_sockets(SpaceNode *snode, const bool deselect_nodes)
|
2012-03-09 10:16:41 +00:00
|
|
|
{
|
|
|
|
|
bNode *node;
|
|
|
|
|
bNodeSocket *sock;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-09 10:16:41 +00:00
|
|
|
/* XXX not calling node_socket_deselect here each time, because this does iteration
|
|
|
|
|
* over all node sockets internally to check if the node stays selected.
|
|
|
|
|
* We can do that more efficiently here.
|
|
|
|
|
*/
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
2012-08-04 12:54:27 +00:00
|
|
|
int sel = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (sock = (bNodeSocket *)node->inputs.first; sock; sock = sock->next) {
|
2012-03-09 10:16:41 +00:00
|
|
|
sock->flag &= ~SELECT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-09 10:16:41 +00:00
|
|
|
/* if no selected sockets remain, also deselect the node */
|
|
|
|
|
if (deselect_nodes) {
|
2021-06-02 17:19:36 +02:00
|
|
|
for (sock = (bNodeSocket *)node->outputs.first; sock; sock = sock->next) {
|
2012-03-09 10:16:41 +00:00
|
|
|
if (sock->flag & SELECT) {
|
|
|
|
|
sel = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!sel) {
|
2012-03-09 10:16:41 +00:00
|
|
|
node->flag &= ~SELECT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-03-09 10:16:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
void node_deselect_all_output_sockets(SpaceNode *snode, const bool deselect_nodes)
|
2012-03-09 10:16:41 +00:00
|
|
|
{
|
|
|
|
|
bNode *node;
|
|
|
|
|
bNodeSocket *sock;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-09 10:16:41 +00:00
|
|
|
/* XXX not calling node_socket_deselect here each time, because this does iteration
|
|
|
|
|
* over all node sockets internally to check if the node stays selected.
|
|
|
|
|
* We can do that more efficiently here.
|
|
|
|
|
*/
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
2014-02-03 18:55:59 +11:00
|
|
|
bool sel = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (sock = (bNodeSocket *)node->outputs.first; sock; sock = sock->next) {
|
2012-03-09 10:16:41 +00:00
|
|
|
sock->flag &= ~SELECT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-09 10:16:41 +00:00
|
|
|
/* if no selected sockets remain, also deselect the node */
|
|
|
|
|
if (deselect_nodes) {
|
2021-06-02 17:19:36 +02:00
|
|
|
for (sock = (bNodeSocket *)node->inputs.first; sock; sock = sock->next) {
|
2012-03-09 10:16:41 +00:00
|
|
|
if (sock->flag & SELECT) {
|
2021-06-02 17:19:36 +02:00
|
|
|
sel = true;
|
2012-03-09 10:16:41 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!sel) {
|
2012-03-09 10:16:41 +00:00
|
|
|
node->flag &= ~SELECT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-03-09 10:16:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-12-18 12:51:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-08 16:59:48 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Select Grouped Operator
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2014-07-04 14:17:54 +02:00
|
|
|
/* Return true if we need redraw, otherwise false. */
|
|
|
|
|
|
|
|
|
|
static bool node_select_grouped_type(SpaceNode *snode, bNode *node_act)
|
2011-12-18 12:51:50 +00:00
|
|
|
{
|
2014-07-04 14:17:54 +02:00
|
|
|
bNode *node;
|
2014-07-05 17:58:21 +02:00
|
|
|
bool changed = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
2014-07-04 14:17:54 +02:00
|
|
|
if ((node->flag & SELECT) == 0) {
|
|
|
|
|
if (node->type == node_act->type) {
|
|
|
|
|
nodeSetSelected(node, true);
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-12-18 12:51:50 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-04 14:17:54 +02:00
|
|
|
return changed;
|
|
|
|
|
}
|
2011-12-18 12:51:50 +00:00
|
|
|
|
2014-07-04 14:17:54 +02:00
|
|
|
static bool node_select_grouped_color(SpaceNode *snode, bNode *node_act)
|
|
|
|
|
{
|
|
|
|
|
bNode *node;
|
|
|
|
|
bool changed = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
2014-07-04 14:17:54 +02:00
|
|
|
if ((node->flag & SELECT) == 0) {
|
|
|
|
|
if (compare_v3v3(node->color, node_act->color, 0.005f)) {
|
|
|
|
|
nodeSetSelected(node, true);
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
2011-12-18 12:51:50 +00:00
|
|
|
}
|
2014-07-04 14:17:54 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-04 14:17:54 +02:00
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool node_select_grouped_name(SpaceNode *snode, bNode *node_act, const bool from_right)
|
|
|
|
|
{
|
|
|
|
|
bNode *node;
|
|
|
|
|
bool changed = false;
|
2020-04-03 16:21:24 +11:00
|
|
|
const uint delims[] = {'.', '-', '_', '\0'};
|
2014-09-24 20:26:21 +02:00
|
|
|
size_t pref_len_act, pref_len_curr;
|
2015-06-27 11:00:47 +02:00
|
|
|
const char *sep, *suf_act, *suf_curr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-06-27 10:22:29 +02:00
|
|
|
pref_len_act = BLI_str_partition_ex_utf8(
|
2021-06-02 17:19:36 +02:00
|
|
|
node_act->name, nullptr, delims, &sep, &suf_act, from_right);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-07-03 23:08:40 +10:00
|
|
|
/* NOTE: in case we are searching for suffix, and found none, use whole name as suffix. */
|
2014-09-24 20:26:21 +02:00
|
|
|
if (from_right && !(sep && suf_act)) {
|
|
|
|
|
pref_len_act = 0;
|
|
|
|
|
suf_act = node_act->name;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
2014-09-24 20:26:21 +02:00
|
|
|
if (node->flag & SELECT) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2015-06-27 10:22:29 +02:00
|
|
|
pref_len_curr = BLI_str_partition_ex_utf8(
|
2021-06-02 17:19:36 +02:00
|
|
|
node->name, nullptr, delims, &sep, &suf_curr, from_right);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-09-24 20:26:21 +02:00
|
|
|
/* Same as with active node name! */
|
|
|
|
|
if (from_right && !(sep && suf_curr)) {
|
|
|
|
|
pref_len_curr = 0;
|
|
|
|
|
suf_curr = node->name;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-09-24 20:26:21 +02:00
|
|
|
if ((from_right && STREQ(suf_act, suf_curr)) ||
|
|
|
|
|
(!from_right && (pref_len_act == pref_len_curr) &&
|
|
|
|
|
STREQLEN(node_act->name, node->name, pref_len_act))) {
|
|
|
|
|
nodeSetSelected(node, true);
|
|
|
|
|
changed = true;
|
2011-12-18 12:51:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-04 14:17:54 +02:00
|
|
|
return changed;
|
2011-12-18 12:51:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-04 14:17:54 +02:00
|
|
|
enum {
|
|
|
|
|
NODE_SELECT_GROUPED_TYPE = 0,
|
|
|
|
|
NODE_SELECT_GROUPED_COLOR = 1,
|
|
|
|
|
NODE_SELECT_GROUPED_PREFIX = 2,
|
|
|
|
|
NODE_SELECT_GROUPED_SUFIX = 3,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int node_select_grouped_exec(bContext *C, wmOperator *op)
|
2011-12-18 12:51:50 +00:00
|
|
|
{
|
2014-07-04 14:17:54 +02:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
|
bNode *node_act = nodeGetActive(snode->edittree);
|
2021-03-18 16:47:14 +01:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
if (node_act == nullptr) {
|
2021-03-18 16:47:14 +01:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-04 14:17:54 +02:00
|
|
|
bNode *node;
|
|
|
|
|
bool changed = false;
|
|
|
|
|
const bool extend = RNA_boolean_get(op->ptr, "extend");
|
|
|
|
|
const int type = RNA_enum_get(op->ptr, "type");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-04 14:17:54 +02:00
|
|
|
if (!extend) {
|
2021-06-02 17:19:36 +02:00
|
|
|
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
2014-07-04 14:17:54 +02:00
|
|
|
nodeSetSelected(node, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
nodeSetSelected(node_act, true);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-04 14:17:54 +02:00
|
|
|
switch (type) {
|
|
|
|
|
case NODE_SELECT_GROUPED_TYPE:
|
|
|
|
|
changed = node_select_grouped_type(snode, node_act);
|
|
|
|
|
break;
|
|
|
|
|
case NODE_SELECT_GROUPED_COLOR:
|
|
|
|
|
changed = node_select_grouped_color(snode, node_act);
|
|
|
|
|
break;
|
|
|
|
|
case NODE_SELECT_GROUPED_PREFIX:
|
|
|
|
|
changed = node_select_grouped_name(snode, node_act, false);
|
|
|
|
|
break;
|
|
|
|
|
case NODE_SELECT_GROUPED_SUFIX:
|
|
|
|
|
changed = node_select_grouped_name(snode, node_act, true);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2011-12-18 12:51:50 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-04 14:17:54 +02:00
|
|
|
if (changed) {
|
|
|
|
|
ED_node_sort(snode->edittree);
|
2021-06-02 17:19:36 +02:00
|
|
|
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
2014-07-04 14:17:54 +02:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-04 14:17:54 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
2011-12-18 12:51:50 +00:00
|
|
|
|
2014-07-04 14:17:54 +02:00
|
|
|
void NODE_OT_select_grouped(wmOperatorType *ot)
|
|
|
|
|
{
|
2021-08-25 17:59:47 +10:00
|
|
|
PropertyRNA *prop;
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem prop_select_grouped_types[] = {
|
2014-07-04 14:17:54 +02:00
|
|
|
{NODE_SELECT_GROUPED_TYPE, "TYPE", 0, "Type", ""},
|
|
|
|
|
{NODE_SELECT_GROUPED_COLOR, "COLOR", 0, "Color", ""},
|
|
|
|
|
{NODE_SELECT_GROUPED_PREFIX, "PREFIX", 0, "Prefix", ""},
|
|
|
|
|
{NODE_SELECT_GROUPED_SUFIX, "SUFFIX", 0, "Suffix", ""},
|
2021-06-02 17:19:36 +02:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2014-07-04 14:17:54 +02:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-04 14:17:54 +02:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Select Grouped";
|
|
|
|
|
ot->description = "Select nodes with similar properties";
|
|
|
|
|
ot->idname = "NODE_OT_select_grouped";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-04 14:17:54 +02:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
|
ot->exec = node_select_grouped_exec;
|
|
|
|
|
ot->poll = ED_operator_node_active;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-04 14:17:54 +02:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-04 14:17:54 +02:00
|
|
|
/* properties */
|
2021-08-25 17:59:47 +10:00
|
|
|
prop = RNA_def_boolean(ot->srna,
|
|
|
|
|
"extend",
|
|
|
|
|
false,
|
|
|
|
|
"Extend",
|
|
|
|
|
"Extend selection instead of deselecting everything first");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2014-07-04 14:17:54 +02:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", "");
|
2011-12-18 12:51:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-08 16:59:48 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Select (Cursor Pick) Operator
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2011-12-18 12:51:50 +00:00
|
|
|
void node_select_single(bContext *C, bNode *node)
|
|
|
|
|
{
|
2012-08-04 12:54:27 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2020-05-25 10:43:44 +02:00
|
|
|
const Object *ob = CTX_data_active_object(C);
|
|
|
|
|
const Scene *scene = CTX_data_scene(C);
|
|
|
|
|
const wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
|
bool active_texture_changed = false;
|
2012-03-09 10:16:41 +00:00
|
|
|
bNode *tnode;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (tnode = (bNode *)snode->edittree->nodes.first; tnode; tnode = tnode->next) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (tnode != node) {
|
2014-04-01 11:34:00 +11:00
|
|
|
nodeSetSelected(tnode, false);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
|
}
|
2014-04-01 11:34:00 +11:00
|
|
|
nodeSetSelected(node, true);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-07-05 10:46:00 +02:00
|
|
|
ED_node_set_active(bmain, snode, snode->edittree, node, &active_texture_changed);
|
2013-04-24 16:36:50 +00:00
|
|
|
ED_node_set_active_viewer_key(snode);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
ED_node_sort(snode->edittree);
|
2020-05-25 10:43:44 +02:00
|
|
|
if (active_texture_changed && has_workbench_in_texture_color(wm, scene, ob)) {
|
|
|
|
|
DEG_id_tag_update(&snode->edittree->id, ID_RECALC_COPY_ON_WRITE);
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
2011-12-18 12:51:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-05-14 15:51:49 +02:00
|
|
|
static int node_mouse_select(bContext *C,
|
2019-10-01 21:47:19 +02:00
|
|
|
wmOperator *op,
|
2019-04-29 12:12:50 +02:00
|
|
|
const int mval[2],
|
2019-10-01 21:47:19 +02:00
|
|
|
bool wait_to_deselect_others)
|
2008-12-28 00:08:34 +00:00
|
|
|
{
|
2019-05-14 15:51:49 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2020-05-25 10:43:44 +02:00
|
|
|
const Object *ob = CTX_data_active_object(C);
|
|
|
|
|
const Scene *scene = CTX_data_scene(C);
|
|
|
|
|
const wmWindowManager *wm = CTX_wm_manager(C);
|
2012-03-09 10:16:41 +00:00
|
|
|
bNode *node, *tnode;
|
2021-06-02 17:19:36 +02:00
|
|
|
bNodeSocket *sock = nullptr;
|
2019-03-22 17:03:02 +01:00
|
|
|
bNodeSocket *tsock;
|
2013-09-05 13:03:03 +00:00
|
|
|
float cursor[2];
|
2019-05-14 15:51:49 +02:00
|
|
|
int ret_value = OPERATOR_CANCELLED;
|
|
|
|
|
|
2019-10-01 21:47:19 +02:00
|
|
|
const bool extend = RNA_boolean_get(op->ptr, "extend");
|
|
|
|
|
/* always do socket_select when extending selection. */
|
|
|
|
|
const bool socket_select = extend || RNA_boolean_get(op->ptr, "socket_select");
|
|
|
|
|
const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
|
|
|
|
|
|
|
|
|
|
/* These cases are never modal. */
|
|
|
|
|
if (extend || socket_select) {
|
|
|
|
|
wait_to_deselect_others = false;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-20 04:19:57 +00:00
|
|
|
/* get mouse coordinates in view2d space */
|
2020-03-06 16:56:42 +01:00
|
|
|
UI_view2d_region_to_view(®ion->v2d, mval[0], mval[1], &cursor[0], &cursor[1]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-22 17:03:02 +01:00
|
|
|
/* first do socket selection, these generally overlap with nodes. */
|
|
|
|
|
if (socket_select) {
|
2013-09-05 13:03:03 +00:00
|
|
|
if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_IN)) {
|
2019-05-06 20:34:01 +02:00
|
|
|
/* NOTE: SOCK_IN does not take into account the extend case...
|
|
|
|
|
* This feature is not really used anyway currently? */
|
|
|
|
|
node_socket_toggle(node, sock, true);
|
2019-05-14 15:51:49 +02:00
|
|
|
ret_value = OPERATOR_FINISHED;
|
2012-03-09 10:16:41 +00:00
|
|
|
}
|
2013-09-05 13:03:03 +00:00
|
|
|
else if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_OUT)) {
|
2012-03-09 10:16:41 +00:00
|
|
|
if (sock->flag & SELECT) {
|
2019-03-22 17:03:02 +01:00
|
|
|
if (extend) {
|
2019-05-06 20:34:01 +02:00
|
|
|
node_socket_deselect(node, sock, true);
|
2019-03-22 17:03:02 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2019-05-14 15:51:49 +02:00
|
|
|
ret_value = OPERATOR_FINISHED;
|
2019-03-22 17:03:02 +01:00
|
|
|
}
|
2012-03-09 10:16:41 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2019-05-06 20:34:01 +02:00
|
|
|
/* Only allow one selected output per node, for sensible linking.
|
|
|
|
|
* Allow selecting outputs from different nodes though, if extend is true. */
|
2012-03-09 10:16:41 +00:00
|
|
|
if (node) {
|
2021-06-02 17:19:36 +02:00
|
|
|
for (tsock = (bNodeSocket *)node->outputs.first; tsock; tsock = tsock->next) {
|
2019-05-06 20:34:01 +02:00
|
|
|
if (tsock == sock) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
node_socket_deselect(node, tsock, true);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-03-09 10:16:41 +00:00
|
|
|
}
|
2019-05-06 20:34:01 +02:00
|
|
|
if (!extend) {
|
2021-06-02 17:19:36 +02:00
|
|
|
for (tnode = (bNode *)snode->edittree->nodes.first; tnode; tnode = tnode->next) {
|
2019-05-06 20:34:01 +02:00
|
|
|
if (tnode == node) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2021-06-02 17:19:36 +02:00
|
|
|
for (tsock = (bNodeSocket *)tnode->outputs.first; tsock; tsock = tsock->next) {
|
2019-05-06 20:34:01 +02:00
|
|
|
node_socket_deselect(tnode, tsock, true);
|
2019-03-22 17:03:02 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-09 10:16:41 +00:00
|
|
|
node_socket_select(node, sock);
|
2019-05-14 15:51:49 +02:00
|
|
|
ret_value = OPERATOR_FINISHED;
|
2012-03-09 10:16:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-03-22 17:03:02 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-23 16:23:44 +02:00
|
|
|
if (!sock) {
|
2019-05-06 20:34:01 +02:00
|
|
|
/* find the closest visible node */
|
|
|
|
|
node = node_under_mouse_select(snode->edittree, (int)cursor[0], (int)cursor[1]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-06 20:34:01 +02:00
|
|
|
if (extend) {
|
2021-06-02 17:19:36 +02:00
|
|
|
if (node != nullptr) {
|
2019-05-06 20:34:01 +02:00
|
|
|
/* If node is selected but not active, we want to make it active,
|
|
|
|
|
* but not toggle (deselect) it. */
|
|
|
|
|
if (!((node->flag & SELECT) && (node->flag & NODE_ACTIVE) == 0)) {
|
2012-08-02 16:01:05 +00:00
|
|
|
node_toggle(node);
|
|
|
|
|
}
|
2019-05-14 15:51:49 +02:00
|
|
|
ret_value = OPERATOR_FINISHED;
|
2012-03-14 17:52:50 +00:00
|
|
|
}
|
2008-12-28 00:08:34 +00:00
|
|
|
}
|
2021-06-02 17:19:36 +02:00
|
|
|
else if (deselect_all && node == nullptr) {
|
2021-03-24 12:13:14 +01:00
|
|
|
/* Rather than deselecting others, users may want to drag to box-select (drag from empty
|
|
|
|
|
* space) or tweak-translate an already selected item. If these cases may apply, delay
|
|
|
|
|
* deselection. */
|
|
|
|
|
if (wait_to_deselect_others) {
|
|
|
|
|
ret_value = OPERATOR_RUNNING_MODAL;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Deselect in empty space. */
|
2021-06-02 17:19:36 +02:00
|
|
|
for (tnode = (bNode *)snode->edittree->nodes.first; tnode; tnode = tnode->next) {
|
2021-03-24 12:13:14 +01:00
|
|
|
nodeSetSelected(tnode, false);
|
|
|
|
|
}
|
|
|
|
|
ret_value = OPERATOR_FINISHED;
|
2019-05-14 15:51:49 +02:00
|
|
|
}
|
|
|
|
|
}
|
2021-06-02 17:19:36 +02:00
|
|
|
else if (node != nullptr) {
|
2019-05-14 15:51:49 +02:00
|
|
|
/* When clicking on an already selected node, we want to wait to deselect
|
|
|
|
|
* others and allow the user to start moving the node without that. */
|
|
|
|
|
if (wait_to_deselect_others && (node->flag & SELECT)) {
|
|
|
|
|
ret_value = OPERATOR_RUNNING_MODAL;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
nodeSetSelected(node, true);
|
|
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (tnode = (bNode *)snode->edittree->nodes.first; tnode; tnode = tnode->next) {
|
2019-05-14 15:51:49 +02:00
|
|
|
if (tnode != node) {
|
|
|
|
|
nodeSetSelected(tnode, false);
|
|
|
|
|
}
|
2019-04-29 12:12:50 +02:00
|
|
|
}
|
2019-05-14 15:51:49 +02:00
|
|
|
|
|
|
|
|
ret_value = OPERATOR_FINISHED;
|
2013-03-18 18:25:05 +00:00
|
|
|
}
|
2012-03-09 10:16:41 +00:00
|
|
|
}
|
2008-12-28 00:08:34 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-14 17:52:50 +00:00
|
|
|
/* update node order */
|
2019-05-14 15:51:49 +02:00
|
|
|
if (ret_value != OPERATOR_CANCELLED) {
|
2020-05-25 10:43:44 +02:00
|
|
|
bool active_texture_changed = false;
|
2021-07-05 10:46:00 +02:00
|
|
|
bool viewer_node_changed = false;
|
2021-06-02 17:19:36 +02:00
|
|
|
if (node != nullptr && ret_value != OPERATOR_RUNNING_MODAL) {
|
2021-07-05 10:46:00 +02:00
|
|
|
viewer_node_changed = (node->flag & NODE_DO_OUTPUT) == 0 && node->type == GEO_NODE_VIEWER;
|
|
|
|
|
ED_node_set_active(bmain, snode, snode->edittree, node, &active_texture_changed);
|
|
|
|
|
}
|
|
|
|
|
else if (node != nullptr && node->type == GEO_NODE_VIEWER) {
|
|
|
|
|
ED_spreadsheet_context_paths_set_geometry_node(bmain, snode, node);
|
2019-05-06 20:34:01 +02:00
|
|
|
}
|
2013-04-24 16:36:50 +00:00
|
|
|
ED_node_set_active_viewer_key(snode);
|
2012-05-22 14:13:33 +00:00
|
|
|
ED_node_sort(snode->edittree);
|
2021-07-05 10:46:00 +02:00
|
|
|
if ((active_texture_changed && has_workbench_in_texture_color(wm, scene, ob)) ||
|
|
|
|
|
viewer_node_changed) {
|
2020-05-25 10:43:44 +02:00
|
|
|
DEG_id_tag_update(&snode->edittree->id, ID_RECALC_COPY_ON_WRITE);
|
|
|
|
|
}
|
2019-05-14 15:51:49 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
2013-04-24 16:36:50 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-14 15:51:49 +02:00
|
|
|
return ret_value;
|
2008-12-28 00:08:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int node_select_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2019-10-04 15:19:30 +02:00
|
|
|
const bool wait_to_deselect_others = RNA_boolean_get(op->ptr, "wait_to_deselect_others");
|
|
|
|
|
|
2009-11-20 04:19:57 +00:00
|
|
|
/* get settings from RNA properties for operator */
|
2019-10-01 21:47:19 +02:00
|
|
|
int mval[2];
|
2009-11-20 04:19:57 +00:00
|
|
|
mval[0] = RNA_int_get(op->ptr, "mouse_x");
|
|
|
|
|
mval[1] = RNA_int_get(op->ptr, "mouse_y");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-20 04:19:57 +00:00
|
|
|
/* perform the select */
|
2019-10-04 15:19:30 +02:00
|
|
|
const int ret_value = node_mouse_select(C, op, mval, wait_to_deselect_others);
|
2019-05-14 15:51:49 +02:00
|
|
|
|
|
|
|
|
/* allow tweak event to work too */
|
|
|
|
|
return ret_value | OPERATOR_PASS_THROUGH;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-28 00:08:34 +00:00
|
|
|
void NODE_OT_select(wmOperatorType *ot)
|
|
|
|
|
{
|
2019-10-04 15:19:30 +02:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
2008-12-28 00:08:34 +00:00
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Select";
|
|
|
|
|
ot->idname = "NODE_OT_select";
|
|
|
|
|
ot->description = "Select the node under the cursor";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-28 00:08:34 +00:00
|
|
|
/* api callbacks */
|
2013-07-12 08:31:39 +00:00
|
|
|
ot->exec = node_select_exec;
|
2019-10-04 15:19:30 +02:00
|
|
|
ot->invoke = WM_generic_select_invoke;
|
|
|
|
|
ot->modal = WM_generic_select_modal;
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_node_active;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* flags */
|
2012-08-04 12:54:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-20 04:19:57 +00:00
|
|
|
/* properties */
|
2019-10-04 15:19:30 +02:00
|
|
|
WM_operator_properties_generic_select(ot);
|
2021-08-03 23:24:18 +10:00
|
|
|
prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2019-03-22 17:03:02 +01:00
|
|
|
RNA_def_boolean(ot->srna, "socket_select", false, "Socket Select", "");
|
2019-04-29 17:01:05 +02:00
|
|
|
prop = RNA_def_boolean(ot->srna,
|
|
|
|
|
"deselect_all",
|
|
|
|
|
false,
|
|
|
|
|
"Deselect On Nothing",
|
|
|
|
|
"Deselect all when nothing under the cursor");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2008-12-28 00:08:34 +00:00
|
|
|
}
|
2009-01-05 23:53:04 +00:00
|
|
|
|
2019-03-08 16:59:48 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Box Select Operator
|
|
|
|
|
* \{ */
|
2009-01-05 23:53:04 +00:00
|
|
|
|
2018-10-05 10:27:04 +10:00
|
|
|
static int node_box_select_exec(bContext *C, wmOperator *op)
|
2009-01-05 23:53:04 +00:00
|
|
|
{
|
2012-08-04 12:54:27 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2009-01-05 23:53:04 +00:00
|
|
|
rctf rectf;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-04-21 16:47:16 +10:00
|
|
|
WM_operator_properties_border_to_rctf(op, &rectf);
|
2020-03-06 16:56:42 +01:00
|
|
|
UI_view2d_region_to_view_rctf(®ion->v2d, &rectf, &rectf);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
const eSelectOp sel_op = (eSelectOp)RNA_enum_get(op->ptr, "mode");
|
2019-03-07 20:33:57 +11:00
|
|
|
const bool select = (sel_op != SEL_OP_SUB);
|
|
|
|
|
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
|
|
|
|
|
ED_node_select_all(&snode->edittree->nodes, SEL_DESELECT);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
|
2017-10-16 21:58:51 +11:00
|
|
|
bool is_inside;
|
2015-10-24 01:06:28 +11:00
|
|
|
if (node->type == NODE_FRAME) {
|
2017-10-16 21:58:51 +11:00
|
|
|
is_inside = BLI_rctf_inside_rctf(&rectf, &node->totr);
|
2015-10-24 01:06:28 +11:00
|
|
|
}
|
|
|
|
|
else {
|
2021-06-02 17:19:36 +02:00
|
|
|
is_inside = BLI_rctf_isect(&rectf, &node->totr, nullptr);
|
2015-10-24 01:06:28 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-16 21:58:51 +11:00
|
|
|
if (is_inside) {
|
|
|
|
|
nodeSetSelected(node, select);
|
2009-01-05 23:53:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
ED_node_sort(snode->edittree);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-05 23:53:04 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-05 10:27:04 +10:00
|
|
|
static int node_box_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2010-01-06 03:00:19 +00:00
|
|
|
{
|
2014-02-03 18:55:59 +11:00
|
|
|
const bool tweak = RNA_boolean_get(op->ptr, "tweak");
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-12-20 10:55:30 +01:00
|
|
|
if (tweak && is_event_over_node_or_socket(C, event)) {
|
|
|
|
|
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
|
2010-01-06 03:00:19 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-10-05 10:27:04 +10:00
|
|
|
return WM_gesture_box_invoke(C, op, event);
|
2010-01-06 03:00:19 +00:00
|
|
|
}
|
|
|
|
|
|
2018-10-05 10:27:04 +10:00
|
|
|
void NODE_OT_select_box(wmOperatorType *ot)
|
2009-01-05 23:53:04 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2018-10-05 10:27:04 +10:00
|
|
|
ot->name = "Box Select";
|
|
|
|
|
ot->idname = "NODE_OT_select_box";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->description = "Use box selection to select nodes";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-05 23:53:04 +00:00
|
|
|
/* api callbacks */
|
2018-10-05 10:27:04 +10:00
|
|
|
ot->invoke = node_box_select_invoke;
|
|
|
|
|
ot->exec = node_box_select_exec;
|
|
|
|
|
ot->modal = WM_gesture_box_modal;
|
|
|
|
|
ot->cancel = WM_gesture_box_cancel;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_node_active;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* flags */
|
2012-08-04 12:54:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-07 20:33:57 +11:00
|
|
|
/* properties */
|
2010-01-06 03:00:19 +00:00
|
|
|
RNA_def_boolean(ot->srna,
|
|
|
|
|
"tweak",
|
2021-06-02 17:19:36 +02:00
|
|
|
false,
|
2010-01-06 03:00:19 +00:00
|
|
|
"Tweak",
|
2021-02-24 13:25:44 -06:00
|
|
|
"Only activate when mouse is not over a node (useful for tweak gesture)");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-07 20:33:57 +11:00
|
|
|
WM_operator_properties_gesture_box(ot);
|
|
|
|
|
WM_operator_properties_select_operation_simple(ot);
|
2009-01-16 23:53:11 +00:00
|
|
|
}
|
2009-09-14 08:47:13 +00:00
|
|
|
|
2019-03-08 16:59:48 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Circle Select Operator
|
|
|
|
|
* \{ */
|
2013-11-06 19:21:42 +00:00
|
|
|
|
|
|
|
|
static int node_circleselect_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2013-11-06 19:21:42 +00:00
|
|
|
bNode *node;
|
|
|
|
|
|
2017-10-16 21:58:51 +11:00
|
|
|
int x, y, radius;
|
2013-11-06 19:21:42 +00:00
|
|
|
float offset[2];
|
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
float zoom = (float)(BLI_rcti_size_x(®ion->winrct)) /
|
|
|
|
|
(float)(BLI_rctf_size_x(®ion->v2d.cur));
|
2013-11-06 19:21:42 +00:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
const eSelectOp sel_op = ED_select_op_modal(
|
|
|
|
|
(eSelectOp)RNA_enum_get(op->ptr, "mode"),
|
|
|
|
|
WM_gesture_is_modal_first((const wmGesture *)op->customdata));
|
2019-03-05 22:26:45 +11:00
|
|
|
const bool select = (sel_op != SEL_OP_SUB);
|
|
|
|
|
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
|
|
|
|
|
ED_node_select_all(&snode->edittree->nodes, SEL_DESELECT);
|
|
|
|
|
}
|
2013-11-06 19:21:42 +00:00
|
|
|
|
|
|
|
|
/* get operator properties */
|
|
|
|
|
x = RNA_int_get(op->ptr, "x");
|
|
|
|
|
y = RNA_int_get(op->ptr, "y");
|
|
|
|
|
radius = RNA_int_get(op->ptr, "radius");
|
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
UI_view2d_region_to_view(®ion->v2d, x, y, &offset[0], &offset[1]);
|
2013-11-06 19:21:42 +00:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
2013-11-06 19:21:42 +00:00
|
|
|
if (BLI_rctf_isect_circle(&node->totr, offset, radius / zoom)) {
|
2017-10-16 21:58:51 +11:00
|
|
|
nodeSetSelected(node, select);
|
2013-11-06 19:21:42 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
2013-11-06 19:21:42 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NODE_OT_select_circle(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Circle Select";
|
|
|
|
|
ot->idname = "NODE_OT_select_circle";
|
|
|
|
|
ot->description = "Use circle selection to select nodes";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->invoke = WM_gesture_circle_invoke;
|
|
|
|
|
ot->exec = node_circleselect_exec;
|
|
|
|
|
ot->modal = WM_gesture_circle_modal;
|
|
|
|
|
|
|
|
|
|
ot->poll = ED_operator_node_active;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
|
2017-10-16 15:32:09 +11:00
|
|
|
/* properties */
|
2019-03-05 22:26:45 +11:00
|
|
|
WM_operator_properties_gesture_circle(ot);
|
|
|
|
|
WM_operator_properties_select_operation_simple(ot);
|
2013-11-06 19:21:42 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-08 16:59:48 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Lasso Select Operator
|
|
|
|
|
* \{ */
|
2012-08-22 13:34:06 +00:00
|
|
|
|
2018-12-20 10:55:30 +01:00
|
|
|
static int node_lasso_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|
|
|
|
{
|
|
|
|
|
const bool tweak = RNA_boolean_get(op->ptr, "tweak");
|
|
|
|
|
|
|
|
|
|
if (tweak && is_event_over_node_or_socket(C, event)) {
|
|
|
|
|
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return WM_gesture_lasso_invoke(C, op, event);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-04 19:50:06 +10:00
|
|
|
static bool do_lasso_select_node(bContext *C,
|
|
|
|
|
const int mcoords[][2],
|
2020-05-05 16:12:36 +10:00
|
|
|
const int mcoords_len,
|
2020-05-04 19:50:06 +10:00
|
|
|
eSelectOp sel_op)
|
2012-08-22 13:34:06 +00:00
|
|
|
{
|
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
|
bNode *node;
|
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2012-08-22 13:34:06 +00:00
|
|
|
|
|
|
|
|
rcti rect;
|
2013-11-26 06:39:14 +11:00
|
|
|
bool changed = false;
|
2012-08-22 13:34:06 +00:00
|
|
|
|
2019-03-07 23:41:32 +11:00
|
|
|
const bool select = (sel_op != SEL_OP_SUB);
|
|
|
|
|
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
|
|
|
|
|
ED_node_select_all(&snode->edittree->nodes, SEL_DESELECT);
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 13:34:06 +00:00
|
|
|
/* get rectangle from operator */
|
2020-05-04 19:50:06 +10:00
|
|
|
BLI_lasso_boundbox(&rect, mcoords, mcoords_len);
|
2012-08-22 13:34:06 +00:00
|
|
|
|
|
|
|
|
/* do actual selection */
|
2021-06-02 17:19:36 +02:00
|
|
|
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
2018-05-13 09:37:53 +02:00
|
|
|
|
2019-03-07 23:41:32 +11:00
|
|
|
if (select && (node->flag & NODE_SELECT)) {
|
2018-05-13 09:37:53 +02:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 13:34:06 +00:00
|
|
|
int screen_co[2];
|
2012-09-15 11:48:20 +00:00
|
|
|
const float cent[2] = {BLI_rctf_cent_x(&node->totr), BLI_rctf_cent_y(&node->totr)};
|
2012-08-22 13:34:06 +00:00
|
|
|
|
|
|
|
|
/* marker in screen coords */
|
2020-03-06 16:56:42 +01:00
|
|
|
if (UI_view2d_view_to_region_clip(
|
|
|
|
|
®ion->v2d, cent[0], cent[1], &screen_co[0], &screen_co[1]) &&
|
2014-04-21 18:11:47 +10:00
|
|
|
BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) &&
|
2020-05-04 19:50:06 +10:00
|
|
|
BLI_lasso_is_point_inside(mcoords, mcoords_len, screen_co[0], screen_co[1], INT_MAX)) {
|
2013-03-18 16:34:57 +00:00
|
|
|
nodeSetSelected(node, select);
|
2013-11-26 06:39:14 +11:00
|
|
|
changed = true;
|
2012-08-22 13:34:06 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-26 06:39:14 +11:00
|
|
|
if (changed) {
|
2021-06-02 17:19:36 +02:00
|
|
|
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
2012-08-22 13:34:06 +00:00
|
|
|
}
|
|
|
|
|
|
2013-11-26 06:39:14 +11:00
|
|
|
return changed;
|
2012-08-22 13:34:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int node_lasso_select_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2020-05-04 19:50:06 +10:00
|
|
|
int mcoords_len;
|
|
|
|
|
const int(*mcoords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcoords_len);
|
2012-08-22 13:34:06 +00:00
|
|
|
|
2020-05-04 19:50:06 +10:00
|
|
|
if (mcoords) {
|
2021-06-02 17:19:36 +02:00
|
|
|
const eSelectOp sel_op = (eSelectOp)RNA_enum_get(op->ptr, "mode");
|
2019-03-07 23:41:32 +11:00
|
|
|
|
2020-05-04 19:50:06 +10:00
|
|
|
do_lasso_select_node(C, mcoords, mcoords_len, sel_op);
|
2012-08-22 13:34:06 +00:00
|
|
|
|
2020-05-04 19:50:06 +10:00
|
|
|
MEM_freeN((void *)mcoords);
|
2012-08-22 13:34:06 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NODE_OT_select_lasso(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Lasso Select";
|
|
|
|
|
ot->description = "Select nodes using lasso selection";
|
|
|
|
|
ot->idname = "NODE_OT_select_lasso";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-08-22 13:34:06 +00:00
|
|
|
/* api callbacks */
|
2018-12-20 10:55:30 +01:00
|
|
|
ot->invoke = node_lasso_select_invoke;
|
2012-08-22 13:34:06 +00:00
|
|
|
ot->modal = WM_gesture_lasso_modal;
|
|
|
|
|
ot->exec = node_lasso_select_exec;
|
|
|
|
|
ot->poll = ED_operator_node_active;
|
|
|
|
|
ot->cancel = WM_gesture_lasso_cancel;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-08-22 13:34:06 +00:00
|
|
|
/* flags */
|
2021-09-17 12:09:26 +10:00
|
|
|
ot->flag = OPTYPE_UNDO | OPTYPE_DEPENDS_ON_CURSOR;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-08-22 13:34:06 +00:00
|
|
|
/* properties */
|
2018-12-20 10:55:30 +01:00
|
|
|
RNA_def_boolean(ot->srna,
|
|
|
|
|
"tweak",
|
2021-06-02 17:19:36 +02:00
|
|
|
false,
|
2018-12-20 10:55:30 +01:00
|
|
|
"Tweak",
|
2021-02-24 13:25:44 -06:00
|
|
|
"Only activate when mouse is not over a node (useful for tweak gesture)");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-07 23:41:32 +11:00
|
|
|
WM_operator_properties_gesture_lasso(ot);
|
|
|
|
|
WM_operator_properties_select_operation_simple(ot);
|
2012-08-22 13:34:06 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-08 16:59:48 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name (De)select All Operator
|
|
|
|
|
* \{ */
|
2009-09-14 08:47:13 +00:00
|
|
|
|
2012-08-01 13:28:19 +00:00
|
|
|
static int node_select_all_exec(bContext *C, wmOperator *op)
|
2009-09-14 08:47:13 +00:00
|
|
|
{
|
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2012-08-01 13:28:19 +00:00
|
|
|
ListBase *node_lb = &snode->edittree->nodes;
|
|
|
|
|
int action = RNA_enum_get(op->ptr, "action");
|
2009-09-14 08:47:13 +00:00
|
|
|
|
2019-03-05 18:30:06 +11:00
|
|
|
ED_node_select_all(node_lb, action);
|
2012-08-01 13:28:19 +00:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
ED_node_sort(snode->edittree);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
2009-09-14 08:47:13 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NODE_OT_select_all(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-17 19:14:08 +00:00
|
|
|
ot->name = "(De)select All";
|
2010-02-10 21:15:44 +00:00
|
|
|
ot->description = "(De)select all nodes";
|
2009-09-14 08:47:13 +00:00
|
|
|
ot->idname = "NODE_OT_select_all";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-09-14 08:47:13 +00:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = node_select_all_exec;
|
|
|
|
|
ot->poll = ED_operator_node_active;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-09-14 08:47:13 +00:00
|
|
|
/* flags */
|
2012-08-04 12:54:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2012-08-01 13:28:19 +00:00
|
|
|
|
|
|
|
|
WM_operator_properties_select_all(ot);
|
2009-09-14 08:47:13 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-08 16:59:48 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Select Linked To Operator
|
|
|
|
|
* \{ */
|
2009-09-14 08:47:13 +00:00
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-09-14 08:47:13 +00:00
|
|
|
{
|
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
|
bNodeLink *link;
|
|
|
|
|
bNode *node;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
2009-09-14 08:47:13 +00:00
|
|
|
node->flag &= ~NODE_TEST;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (link = (bNodeLink *)snode->edittree->links.first; link; link = link->next) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (nodeLinkIsHidden(link)) {
|
2013-03-18 16:34:57 +00:00
|
|
|
continue;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
|
if (link->fromnode && link->tonode && (link->fromnode->flag & NODE_SELECT)) {
|
2009-09-14 08:47:13 +00:00
|
|
|
link->tonode->flag |= NODE_TEST;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2009-11-20 04:19:57 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->flag & NODE_TEST) {
|
2014-04-01 11:34:00 +11:00
|
|
|
nodeSetSelected(node, true);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2009-11-20 04:19:57 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
ED_node_sort(snode->edittree);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
2009-09-14 08:47:13 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NODE_OT_select_linked_to(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Select Linked To";
|
2010-02-10 21:15:44 +00:00
|
|
|
ot->description = "Select nodes linked to the selected ones";
|
2009-09-14 08:47:13 +00:00
|
|
|
ot->idname = "NODE_OT_select_linked_to";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-09-14 08:47:13 +00:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = node_select_linked_to_exec;
|
|
|
|
|
ot->poll = ED_operator_node_active;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-09-14 08:47:13 +00:00
|
|
|
/* flags */
|
2012-08-04 12:54:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-09-14 08:47:13 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-08 16:59:48 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Select Linked From Operator
|
|
|
|
|
* \{ */
|
2009-09-14 08:47:13 +00:00
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-09-14 08:47:13 +00:00
|
|
|
{
|
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
|
bNodeLink *link;
|
|
|
|
|
bNode *node;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
2009-09-14 08:47:13 +00:00
|
|
|
node->flag &= ~NODE_TEST;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (link = (bNodeLink *)snode->edittree->links.first; link; link = link->next) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (nodeLinkIsHidden(link)) {
|
2013-03-18 16:34:57 +00:00
|
|
|
continue;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
|
if (link->fromnode && link->tonode && (link->tonode->flag & NODE_SELECT)) {
|
2009-09-14 08:47:13 +00:00
|
|
|
link->fromnode->flag |= NODE_TEST;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2009-11-20 04:19:57 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->flag & NODE_TEST) {
|
2014-04-01 11:34:00 +11:00
|
|
|
nodeSetSelected(node, true);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2009-11-20 04:19:57 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
ED_node_sort(snode->edittree);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
2009-09-14 08:47:13 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NODE_OT_select_linked_from(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Select Linked From";
|
2010-02-10 21:15:44 +00:00
|
|
|
ot->description = "Select nodes linked from the selected ones";
|
2009-09-14 08:47:13 +00:00
|
|
|
ot->idname = "NODE_OT_select_linked_from";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-09-14 08:47:13 +00:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = node_select_linked_from_exec;
|
|
|
|
|
ot->poll = ED_operator_node_active;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-09-14 08:47:13 +00:00
|
|
|
/* flags */
|
2012-08-04 12:54:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-09-14 08:47:13 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-08 16:59:48 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Select Same Type Step Operator
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2013-03-27 18:28:25 +00:00
|
|
|
static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
|
2013-03-27 17:22:12 +00:00
|
|
|
{
|
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2013-03-27 17:22:12 +00:00
|
|
|
bNode **node_array;
|
|
|
|
|
bNode *active = nodeGetActive(snode->edittree);
|
|
|
|
|
int totnodes;
|
2014-02-03 18:55:59 +11:00
|
|
|
const bool revert = RNA_boolean_get(op->ptr, "prev");
|
2021-06-02 17:19:36 +02:00
|
|
|
const bool same_type = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-27 17:22:12 +00:00
|
|
|
ntreeGetDependencyList(snode->edittree, &node_array, &totnodes);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-27 17:22:12 +00:00
|
|
|
if (totnodes > 1) {
|
|
|
|
|
int a;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-27 17:22:12 +00:00
|
|
|
for (a = 0; a < totnodes; a++) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node_array[a] == active) {
|
2013-03-27 17:22:12 +00:00
|
|
|
break;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-03-27 17:22:12 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-27 17:22:12 +00:00
|
|
|
if (same_type) {
|
2021-06-02 17:19:36 +02:00
|
|
|
bNode *node = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
while (node == nullptr) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (revert) {
|
|
|
|
|
a--;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
a++;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (a < 0 || a >= totnodes) {
|
2013-03-27 17:22:12 +00:00
|
|
|
break;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-27 17:22:12 +00:00
|
|
|
node = node_array[a];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->type == active->type) {
|
2013-03-27 17:22:12 +00:00
|
|
|
break;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2021-06-02 17:19:36 +02:00
|
|
|
node = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node) {
|
2013-03-27 17:22:12 +00:00
|
|
|
active = node;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2013-03-27 17:22:12 +00:00
|
|
|
else {
|
|
|
|
|
if (revert) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (a == 0) {
|
2013-03-27 17:22:12 +00:00
|
|
|
active = node_array[totnodes - 1];
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
|
else {
|
2013-03-27 17:22:12 +00:00
|
|
|
active = node_array[a - 1];
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2013-03-27 17:22:12 +00:00
|
|
|
else {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (a == totnodes - 1) {
|
2013-03-27 17:22:12 +00:00
|
|
|
active = node_array[0];
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
|
else {
|
2013-03-27 17:22:12 +00:00
|
|
|
active = node_array[a + 1];
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2013-03-27 17:22:12 +00:00
|
|
|
node_select_single(C, active);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-27 17:22:12 +00:00
|
|
|
/* is note outside view? */
|
2020-03-06 16:56:42 +01:00
|
|
|
if (active->totr.xmax < region->v2d.cur.xmin || active->totr.xmin > region->v2d.cur.xmax ||
|
|
|
|
|
active->totr.ymax < region->v2d.cur.ymin || active->totr.ymin > region->v2d.cur.ymax) {
|
2013-09-16 04:04:44 +00:00
|
|
|
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
|
2020-03-06 16:56:42 +01:00
|
|
|
space_node_view_flag(C, snode, region, NODE_SELECT, smooth_viewtx);
|
2013-03-28 19:33:14 +00:00
|
|
|
}
|
2013-03-27 17:22:12 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node_array) {
|
2013-03-27 17:22:12 +00:00
|
|
|
MEM_freeN(node_array);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-27 17:22:12 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-27 18:28:25 +00:00
|
|
|
void NODE_OT_select_same_type_step(wmOperatorType *ot)
|
2013-03-27 17:22:12 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2013-03-27 18:28:25 +00:00
|
|
|
ot->name = "Activate Same Type Next/Prev";
|
|
|
|
|
ot->description = "Activate and view same node type, step by step";
|
|
|
|
|
ot->idname = "NODE_OT_select_same_type_step";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-27 17:22:12 +00:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = node_select_same_type_step_exec;
|
|
|
|
|
ot->poll = ED_operator_node_active;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-04-01 15:07:22 +00:00
|
|
|
/* flags */
|
2013-03-27 17:22:12 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
RNA_def_boolean(ot->srna, "prev", false, "Previous", "");
|
2013-03-27 17:22:12 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-08 16:59:48 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Find Node by Name Operator
|
|
|
|
|
* \{ */
|
2013-04-01 15:07:22 +00:00
|
|
|
|
2020-09-09 13:44:39 +02:00
|
|
|
static void node_find_create_label(const bNode *node, char *str, int maxlen)
|
|
|
|
|
{
|
|
|
|
|
if (node->label[0]) {
|
|
|
|
|
BLI_snprintf(str, maxlen, "%s (%s)", node->name, node->label);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_strncpy(str, node->name, maxlen);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-23 16:56:00 +10:00
|
|
|
/* Generic search invoke. */
|
2020-05-08 12:01:35 +10:00
|
|
|
static void node_find_update_fn(const struct bContext *C,
|
|
|
|
|
void *UNUSED(arg),
|
|
|
|
|
const char *str,
|
UI: Expose an "is first search" boolean to search button callbacks
Currently when you open an RNA collection search button, like a
vertex group selector, the search filter isn't applied until you
start typing, in order to display every option at the start.
Otherwise they wouldn't be visible, since the search filter would
run for the current text.
Currently this check happens in one place, but it relies on the
`changed` value of `uiBut`. This is fine in the interface directory,
but anywhere else it would require exposing `uiBut.changed`, which
is probably too low-level to expose.
The solution is adding an `is_first` argument to the search callbacks,
which is nice for a few reasons:
- They work at a higher level of abstraction, meaning they don't
have to worry about how exactly to tell if this is the first
search.
- It makes it easier to do special behavior when the search menu
is first opened.
- Then, obviously, it makes that state accessible without including
`interface_intern.h`.
Needed for attribute search: T85658
Differential Revision: https://developer.blender.org/D10528
2021-03-02 11:42:05 -06:00
|
|
|
uiSearchItems *items,
|
|
|
|
|
const bool UNUSED(is_first))
|
2013-04-01 15:07:22 +00:00
|
|
|
{
|
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-09 13:44:39 +02:00
|
|
|
StringSearch *search = BLI_string_search_new();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-09 13:44:39 +02:00
|
|
|
LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
|
|
|
|
|
char name[256];
|
|
|
|
|
node_find_create_label(node, name, ARRAY_SIZE(name));
|
|
|
|
|
BLI_string_search_add(search, name, node);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-09 13:44:39 +02:00
|
|
|
bNode **filtered_nodes;
|
|
|
|
|
int filtered_amount = BLI_string_search_query(search, str, (void ***)&filtered_nodes);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < filtered_amount; i++) {
|
|
|
|
|
bNode *node = filtered_nodes[i];
|
|
|
|
|
char name[256];
|
|
|
|
|
node_find_create_label(node, name, ARRAY_SIZE(name));
|
|
|
|
|
if (!UI_search_item_add(items, name, node, ICON_NONE, 0, 0)) {
|
|
|
|
|
break;
|
2013-04-01 15:07:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
2020-09-09 13:44:39 +02:00
|
|
|
|
|
|
|
|
MEM_freeN(filtered_nodes);
|
|
|
|
|
BLI_string_search_free(search);
|
2013-04-01 15:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
2020-05-08 12:01:35 +10:00
|
|
|
static void node_find_exec_fn(struct bContext *C, void *UNUSED(arg1), void *arg2)
|
2013-04-01 15:07:22 +00:00
|
|
|
{
|
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2021-06-02 17:19:36 +02:00
|
|
|
bNode *active = (bNode *)arg2;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-01 15:07:22 +00:00
|
|
|
if (active) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2013-04-01 15:07:22 +00:00
|
|
|
node_select_single(C, active);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-01 15:07:22 +00:00
|
|
|
/* is note outside view? */
|
2020-03-06 16:56:42 +01:00
|
|
|
if (active->totr.xmax < region->v2d.cur.xmin || active->totr.xmin > region->v2d.cur.xmax ||
|
|
|
|
|
active->totr.ymax < region->v2d.cur.ymin || active->totr.ymin > region->v2d.cur.ymax) {
|
|
|
|
|
space_node_view_flag(C, snode, region, NODE_SELECT, U.smooth_viewtx);
|
2013-04-01 15:07:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
static uiBlock *node_find_menu(bContext *C, ARegion *region, void *arg_op)
|
2013-04-01 15:07:22 +00:00
|
|
|
{
|
|
|
|
|
static char search[256] = "";
|
|
|
|
|
uiBlock *block;
|
|
|
|
|
uiBut *but;
|
|
|
|
|
wmOperator *op = (wmOperator *)arg_op;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
block = UI_block_begin(C, region, "_popup", UI_EMBOSS);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU);
|
2018-09-11 10:56:08 +10:00
|
|
|
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-08-27 12:16:16 +02:00
|
|
|
but = uiDefSearchBut(block,
|
|
|
|
|
search,
|
|
|
|
|
0,
|
|
|
|
|
ICON_VIEWZOOM,
|
|
|
|
|
sizeof(search),
|
|
|
|
|
10,
|
|
|
|
|
10,
|
|
|
|
|
UI_searchbox_size_x(),
|
|
|
|
|
UI_UNIT_Y,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
"");
|
2021-04-14 11:11:51 -05:00
|
|
|
UI_but_func_search_set(
|
2021-06-02 17:19:36 +02:00
|
|
|
but, nullptr, node_find_update_fn, op->type, false, nullptr, node_find_exec_fn, nullptr);
|
2019-03-22 00:54:07 +11:00
|
|
|
UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-01 15:07:22 +00:00
|
|
|
/* fake button, it holds space for search items */
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block,
|
|
|
|
|
UI_BTYPE_LABEL,
|
|
|
|
|
0,
|
|
|
|
|
"",
|
|
|
|
|
10,
|
|
|
|
|
10 - UI_searchbox_size_y(),
|
|
|
|
|
UI_searchbox_size_x(),
|
|
|
|
|
UI_searchbox_size_y(),
|
2021-06-02 17:19:36 +02:00
|
|
|
nullptr,
|
2014-11-09 21:20:40 +01:00
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
2021-06-02 17:19:36 +02:00
|
|
|
nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-13 16:35:24 +11:00
|
|
|
/* Move it downwards, mouse over button. */
|
2021-06-02 17:19:36 +02:00
|
|
|
std::array<int, 2> bounds_offset = {0, -UI_UNIT_Y};
|
|
|
|
|
UI_block_bounds_set_popup(block, 0.3f * U.widget_unit, bounds_offset.data());
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-01 15:07:22 +00:00
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int node_find_node_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
|
|
|
|
{
|
2021-06-02 17:19:36 +02:00
|
|
|
UI_popup_block_invoke(C, node_find_menu, op, nullptr);
|
2013-04-01 15:07:22 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NODE_OT_find_node(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Find Node";
|
2020-11-18 16:14:48 -05:00
|
|
|
ot->description = "Search for a node by name and focus and select it";
|
2013-04-01 15:07:22 +00:00
|
|
|
ot->idname = "NODE_OT_find_node";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-04-01 15:07:22 +00:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->invoke = node_find_node_invoke;
|
|
|
|
|
ot->poll = ED_operator_node_active;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* flags */
|
2013-04-01 15:07:22 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-06-02 17:19:36 +02:00
|
|
|
RNA_def_boolean(ot->srna, "prev", false, "Previous", "");
|
2013-04-01 15:07:22 +00:00
|
|
|
}
|
2019-03-08 16:59:48 +11:00
|
|
|
|
|
|
|
|
/** \} */
|