2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-24 10:33:10 +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-24 10:33:10 +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-24 10:33:10 +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
|
|
|
|
* \brief higher level node drawing for the node editor.
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
2019-02-27 12:34:56 +11:00
|
|
|
#include "DNA_light_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_linestyle_types.h"
|
2013-03-18 16:34:57 +00:00
|
|
|
#include "DNA_material_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_node_types.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
#include "DNA_screen_types.h"
|
2013-03-18 16:34:57 +00:00
|
|
|
#include "DNA_space_types.h"
|
|
|
|
#include "DNA_texture_types.h"
|
|
|
|
#include "DNA_world_types.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_math.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2012-03-17 14:42:44 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
#include "BKE_context.h"
|
2020-02-10 12:58:59 +01:00
|
|
|
#include "BKE_lib_id.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
#include "BKE_main.h"
|
2011-02-08 12:54:32 +00:00
|
|
|
#include "BKE_node.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
#include "BLF_api.h"
|
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "GPU_framebuffer.h"
|
2016-10-14 23:45:55 -04:00
|
|
|
#include "GPU_immediate.h"
|
2017-04-05 18:30:14 +10:00
|
|
|
#include "GPU_immediate_util.h"
|
2017-04-04 01:15:35 -04:00
|
|
|
#include "GPU_matrix.h"
|
2018-06-27 19:07:23 -06:00
|
|
|
#include "GPU_state.h"
|
2020-08-18 14:43:18 +02:00
|
|
|
#include "GPU_viewport.h"
|
2016-10-14 23:45:55 -04:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
#include "WM_api.h"
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
#include "WM_types.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2009-11-11 08:12:54 +00:00
|
|
|
#include "ED_gpencil.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "ED_node.h"
|
2012-06-29 14:34:46 +00:00
|
|
|
#include "ED_space_api.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
2009-09-16 18:59:13 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
2012-08-02 23:03:16 +00:00
|
|
|
#include "node_intern.h" /* own include */
|
2014-11-28 15:50:43 +01:00
|
|
|
|
|
|
|
#ifdef WITH_COMPOSITOR
|
|
|
|
# include "COM_compositor.h"
|
|
|
|
#endif
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2012-07-09 23:07:15 +00:00
|
|
|
/* XXX interface.h */
|
2014-11-09 21:20:40 +01:00
|
|
|
extern void ui_draw_dropshadow(
|
|
|
|
const rctf *rct, float radius, float aspect, float alpha, int select);
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2013-11-06 17:46:32 +00:00
|
|
|
float ED_node_grid_size(void)
|
|
|
|
{
|
|
|
|
return U.widget_unit;
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void ED_node_tree_update(const bContext *C)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2013-04-24 20:19:01 +00:00
|
|
|
if (snode) {
|
|
|
|
snode_set_context(C);
|
|
|
|
|
2015-11-11 20:18:50 +01:00
|
|
|
id_us_ensure_real(&snode->nodetree->id);
|
2013-04-24 20:19:01 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* id is supposed to contain a node tree */
|
|
|
|
static bNodeTree *node_tree_from_ID(ID *id)
|
2009-09-16 18:59:13 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
if (id) {
|
2020-04-16 12:06:01 +02:00
|
|
|
if (GS(id->name) == ID_NT) {
|
|
|
|
return (bNodeTree *)id;
|
|
|
|
}
|
2020-07-03 17:20:08 +02:00
|
|
|
return ntreeFromID(id);
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void ED_node_tag_update_id(ID *id)
|
|
|
|
{
|
|
|
|
bNodeTree *ntree = node_tree_from_ID(id);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (id == NULL || ntree == NULL) {
|
2013-03-18 16:34:57 +00:00
|
|
|
return;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-05-12 13:29:00 +05:00
|
|
|
/* TODO(sergey): With the new dependency graph it
|
2015-05-15 23:38:53 +10:00
|
|
|
* should be just enough to only tag ntree itself,
|
2015-05-12 13:29:00 +05:00
|
|
|
* all the users of this tree will have update
|
|
|
|
* flushed from the tree,
|
|
|
|
*/
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&ntree->id, 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (ntree->type == NTREE_SHADER) {
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(id, 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (GS(id->name) == ID_MA) {
|
2013-06-24 22:41:33 +00:00
|
|
|
WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else if (GS(id->name) == ID_LA) {
|
2013-06-24 22:41:33 +00:00
|
|
|
WM_main_add_notifier(NC_LAMP | ND_LIGHTING, id);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else if (GS(id->name) == ID_WO) {
|
2013-06-24 22:41:33 +00:00
|
|
|
WM_main_add_notifier(NC_WORLD | ND_WORLD, id);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
else if (ntree->type == NTREE_COMPOSIT) {
|
2012-07-09 19:58:36 +00:00
|
|
|
WM_main_add_notifier(NC_SCENE | ND_NODES, id);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
else if (ntree->type == NTREE_TEXTURE) {
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(id, 0);
|
2012-07-09 19:58:36 +00:00
|
|
|
WM_main_add_notifier(NC_TEXTURE | ND_NODES, id);
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
2020-12-02 13:25:25 +01:00
|
|
|
else if (ntree->type == NTREE_GEOMETRY) {
|
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, id);
|
|
|
|
}
|
2014-08-27 09:49:31 +10:00
|
|
|
else if (id == &ntree->id) {
|
2014-08-22 15:51:15 +02:00
|
|
|
/* node groups */
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(id, 0);
|
2014-08-22 15:51:15 +02:00
|
|
|
}
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
|
|
|
|
2016-02-05 01:39:42 +05:00
|
|
|
void ED_node_tag_update_nodetree(Main *bmain, bNodeTree *ntree, bNode *node)
|
2010-03-15 04:54:31 +00:00
|
|
|
{
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!ntree) {
|
2013-03-18 16:34:57 +00:00
|
|
|
return;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-02-05 01:39:42 +05:00
|
|
|
bool do_tag_update = true;
|
|
|
|
if (node != NULL) {
|
2018-06-09 15:16:44 +02:00
|
|
|
if (!node_connected_to_output(bmain, ntree, node)) {
|
2016-02-05 01:39:42 +05:00
|
|
|
do_tag_update = false;
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-03-15 04:54:31 +00:00
|
|
|
/* look through all datablocks, to support groups */
|
2016-02-05 01:39:42 +05:00
|
|
|
if (do_tag_update) {
|
2018-11-30 15:22:01 +11:00
|
|
|
FOREACH_NODETREE_BEGIN (bmain, tntree, id) {
|
2016-02-05 01:39:42 +05:00
|
|
|
/* check if nodetree uses the group */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ntreeHasTree(tntree, ntree)) {
|
2016-02-05 01:39:42 +05:00
|
|
|
ED_node_tag_update_id(id);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-11-30 15:22:01 +11:00
|
|
|
FOREACH_NODETREE_END;
|
2016-02-05 01:39:42 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ntree->type == NTREE_TEXTURE) {
|
2010-04-05 17:30:11 +00:00
|
|
|
ntreeTexCheckCyclics(ntree);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2010-03-15 04:54:31 +00:00
|
|
|
}
|
|
|
|
|
2015-04-20 23:37:04 +10:00
|
|
|
static bool compare_nodes(const bNode *a, const bNode *b)
|
2012-05-22 14:13:33 +00:00
|
|
|
{
|
|
|
|
/* These tell if either the node or any of the parent nodes is selected.
|
|
|
|
* A selected parent means an unselected node is also in foreground!
|
|
|
|
*/
|
2015-04-20 23:37:04 +10:00
|
|
|
bool a_select = (a->flag & NODE_SELECT) != 0, b_select = (b->flag & NODE_SELECT) != 0;
|
|
|
|
bool a_active = (a->flag & NODE_ACTIVE) != 0, b_active = (b->flag & NODE_ACTIVE) != 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
/* if one is an ancestor of the other */
|
2019-01-15 23:24:20 +11:00
|
|
|
/* XXX there might be a better sorting algorithm for stable topological sort,
|
|
|
|
* this is O(n^2) worst case */
|
2020-09-08 17:19:58 +02:00
|
|
|
for (bNode *parent = a->parent; parent; parent = parent->parent) {
|
2012-05-22 14:13:33 +00:00
|
|
|
/* if b is an ancestor, it is always behind a */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (parent == b) {
|
2020-09-02 19:10:18 +02:00
|
|
|
return true;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-05-22 14:13:33 +00:00
|
|
|
/* any selected ancestor moves the node forward */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (parent->flag & NODE_ACTIVE) {
|
2012-05-22 14:13:33 +00:00
|
|
|
a_active = 1;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
if (parent->flag & NODE_SELECT) {
|
2012-05-22 14:13:33 +00:00
|
|
|
a_select = 1;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
2020-09-08 17:19:58 +02:00
|
|
|
for (bNode *parent = b->parent; parent; parent = parent->parent) {
|
2012-05-22 14:13:33 +00:00
|
|
|
/* if a is an ancestor, it is always behind b */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (parent == a) {
|
2020-09-02 19:10:18 +02:00
|
|
|
return false;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-05-22 14:13:33 +00:00
|
|
|
/* any selected ancestor moves the node forward */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (parent->flag & NODE_ACTIVE) {
|
2012-05-22 14:13:33 +00:00
|
|
|
b_active = 1;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
if (parent->flag & NODE_SELECT) {
|
2012-05-22 14:13:33 +00:00
|
|
|
b_select = 1;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
/* if one of the nodes is in the background and the other not */
|
2019-03-26 21:16:47 +11:00
|
|
|
if ((a->flag & NODE_BACKGROUND) && !(b->flag & NODE_BACKGROUND)) {
|
2020-09-02 19:10:18 +02:00
|
|
|
return false;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2020-07-03 17:20:08 +02:00
|
|
|
if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND)) {
|
2020-09-02 19:10:18 +02:00
|
|
|
return true;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
/* if one has a higher selection state (active > selected > nothing) */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!b_active && a_active) {
|
2020-09-02 19:10:18 +02:00
|
|
|
return true;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2020-07-03 17:20:08 +02:00
|
|
|
if (!b_select && (a_active || a_select)) {
|
2020-09-02 19:10:18 +02:00
|
|
|
return true;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-02 19:10:18 +02:00
|
|
|
return false;
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Sorts nodes by selection: unselected nodes first, then selected,
|
|
|
|
* then the active node at the very end. Relative order is kept intact!
|
|
|
|
*/
|
|
|
|
void ED_node_sort(bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
/* merge sort is the algorithm of choice here */
|
2014-11-16 13:57:58 +01:00
|
|
|
int totnodes = BLI_listbase_count(&ntree->nodes);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-08 17:19:58 +02:00
|
|
|
int k = 1;
|
2012-05-22 14:13:33 +00:00
|
|
|
while (k < totnodes) {
|
2020-09-08 17:19:58 +02:00
|
|
|
bNode *first_a = ntree->nodes.first;
|
|
|
|
bNode *first_b = first_a;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
do {
|
|
|
|
/* setup first_b pointer */
|
2020-09-08 17:19:58 +02:00
|
|
|
for (int b = 0; b < k && first_b; b++) {
|
2012-05-22 14:13:33 +00:00
|
|
|
first_b = first_b->next;
|
|
|
|
}
|
|
|
|
/* all batches merged? */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (first_b == NULL) {
|
2012-05-22 14:13:33 +00:00
|
|
|
break;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
/* merge batches */
|
2020-09-08 17:19:58 +02:00
|
|
|
bNode *node_a = first_a;
|
|
|
|
bNode *node_b = first_b;
|
|
|
|
int a = 0;
|
|
|
|
int b = 0;
|
2012-05-22 14:13:33 +00:00
|
|
|
while (a < k && b < k && node_b) {
|
2012-07-09 19:58:36 +00:00
|
|
|
if (compare_nodes(node_a, node_b) == 0) {
|
2012-05-22 14:13:33 +00:00
|
|
|
node_a = node_a->next;
|
2012-08-22 16:44:32 +00:00
|
|
|
a++;
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
|
|
|
else {
|
2020-09-08 17:19:58 +02:00
|
|
|
bNode *tmp = node_b;
|
2012-05-22 14:13:33 +00:00
|
|
|
node_b = node_b->next;
|
2012-08-22 16:44:32 +00:00
|
|
|
b++;
|
2012-05-22 14:13:33 +00:00
|
|
|
BLI_remlink(&ntree->nodes, tmp);
|
|
|
|
BLI_insertlinkbefore(&ntree->nodes, node_a, tmp);
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
/* setup first pointers for next batch */
|
|
|
|
first_b = node_b;
|
2019-09-08 00:12:26 +10:00
|
|
|
for (; b < k; b++) {
|
2012-05-22 14:13:33 +00:00
|
|
|
/* all nodes sorted? */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (first_b == NULL) {
|
2012-05-22 14:13:33 +00:00
|
|
|
break;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-05-22 14:13:33 +00:00
|
|
|
first_b = first_b->next;
|
|
|
|
}
|
|
|
|
first_a = first_b;
|
|
|
|
} while (first_b);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
k = k << 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
static void do_node_internal_buttons(bContext *C, void *UNUSED(node_v), int event)
|
2009-09-16 18:59:13 +00:00
|
|
|
{
|
2012-07-09 19:58:36 +00:00
|
|
|
if (event == B_NODE_EXEC) {
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (snode && snode->id) {
|
2013-03-18 16:34:57 +00:00
|
|
|
ED_node_tag_update_id(snode->id);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2009-10-07 22:05:30 +00:00
|
|
|
}
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
|
|
|
|
2010-01-12 07:07:51 +00:00
|
|
|
static void node_uiblocks_init(const bContext *C, bNodeTree *ntree)
|
|
|
|
{
|
2011-11-22 17:49:06 +00:00
|
|
|
/* add node uiBlocks in drawing order - prevents events going to overlapping nodes */
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-09-08 17:19:58 +02:00
|
|
|
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
2012-01-11 09:33:44 +00:00
|
|
|
/* ui block */
|
2020-09-08 17:19:58 +02:00
|
|
|
char uiblockstr[32];
|
2012-01-11 12:56:31 +00:00
|
|
|
BLI_snprintf(uiblockstr, sizeof(uiblockstr), "node buttons %p", (void *)node);
|
2014-11-09 21:20:40 +01:00
|
|
|
node->block = UI_block_begin(C, CTX_wm_region(C), uiblockstr, UI_EMBOSS);
|
|
|
|
UI_block_func_handle_set(node->block, do_node_internal_buttons, node);
|
2012-01-11 09:33:44 +00:00
|
|
|
|
|
|
|
/* this cancels events for background nodes */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_flag_enable(node->block, UI_BLOCK_CLIP_EVENTS);
|
2010-01-12 07:07:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-15 10:48:22 -06:00
|
|
|
void node_to_view(const bNode *node, float x, float y, float *rx, float *ry)
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
{
|
|
|
|
nodeToView(node, x, y, rx, ry);
|
|
|
|
*rx *= UI_DPI_FAC;
|
|
|
|
*ry *= UI_DPI_FAC;
|
|
|
|
}
|
|
|
|
|
2021-01-15 10:48:22 -06:00
|
|
|
void node_to_updated_rect(const bNode *node, rctf *r_rect)
|
2015-08-01 16:16:16 +02:00
|
|
|
{
|
|
|
|
node_to_view(node, node->offsetx, node->offsety, &r_rect->xmin, &r_rect->ymax);
|
|
|
|
node_to_view(node,
|
|
|
|
node->offsetx + node->width,
|
|
|
|
node->offsety - node->height,
|
|
|
|
&r_rect->xmax,
|
|
|
|
&r_rect->ymin);
|
|
|
|
}
|
|
|
|
|
2021-01-15 10:48:22 -06:00
|
|
|
void node_from_view(const bNode *node, float x, float y, float *rx, float *ry)
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
{
|
|
|
|
x /= UI_DPI_FAC;
|
|
|
|
y /= UI_DPI_FAC;
|
|
|
|
nodeFromView(node, x, y, rx, ry);
|
|
|
|
}
|
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* based on settings in node, sets drawing rect info. each redraw! */
|
2011-09-05 21:01:50 +00:00
|
|
|
static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2020-09-08 17:19:58 +02:00
|
|
|
PointerRNA nodeptr;
|
2013-03-18 16:34:57 +00:00
|
|
|
RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* get "global" coords */
|
2020-09-08 17:19:58 +02:00
|
|
|
float locx, locy;
|
2013-03-18 16:34:57 +00:00
|
|
|
node_to_view(node, 0.0f, 0.0f, &locx, &locy);
|
2020-09-08 17:19:58 +02:00
|
|
|
float dy = locy;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* header */
|
|
|
|
dy -= NODE_DY;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* little bit space in top */
|
|
|
|
if (node->outputs.first) {
|
|
|
|
dy -= NODE_DYS / 2;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* output sockets */
|
|
|
|
bool add_output_space = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-08 17:19:58 +02:00
|
|
|
int buty;
|
|
|
|
LISTBASE_FOREACH (bNodeSocket *, nsock, &node->outputs) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (nodeSocketIsHidden(nsock)) {
|
|
|
|
continue;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2020-09-08 17:19:58 +02:00
|
|
|
PointerRNA sockptr;
|
2019-03-26 21:16:47 +11:00
|
|
|
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-12-14 17:48:57 -06:00
|
|
|
uiLayout *layout = UI_block_layout(node->block,
|
|
|
|
UI_LAYOUT_VERTICAL,
|
|
|
|
UI_LAYOUT_PANEL,
|
|
|
|
locx + NODE_DYS,
|
|
|
|
dy,
|
|
|
|
NODE_WIDTH(node) - NODE_DY,
|
|
|
|
NODE_DY,
|
|
|
|
0,
|
|
|
|
UI_style_get_dpi());
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->flag & NODE_MUTED) {
|
2019-03-28 17:39:54 +01:00
|
|
|
uiLayoutSetActive(layout, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
/* context pointers for current node and socket */
|
|
|
|
uiLayoutSetContextPointer(layout, "node", &nodeptr);
|
2013-03-18 16:34:57 +00:00
|
|
|
uiLayoutSetContextPointer(layout, "socket", &sockptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* align output buttons to the right */
|
2020-12-14 17:48:57 -06:00
|
|
|
uiLayout *row = uiLayoutRow(layout, true);
|
2013-03-18 16:34:57 +00:00
|
|
|
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT);
|
2020-02-11 15:31:40 +00:00
|
|
|
const char *socket_label = nodeSocketLabel(nsock);
|
|
|
|
nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(socket_label));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-10-10 11:33:20 +00:00
|
|
|
UI_block_align_end(node->block);
|
|
|
|
UI_block_layout_resolve(node->block, NULL, &buty);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 18:59:13 +00:00
|
|
|
/* ensure minimum socket height in case layout is empty */
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
buty = min_ii(buty, dy - NODE_DY);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
nsock->locx = locx + NODE_WIDTH(node);
|
2014-11-09 21:20:40 +01:00
|
|
|
/* place the socket circle in the middle of the layout */
|
|
|
|
nsock->locy = 0.5f * (dy + buty);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
dy = buty;
|
2014-11-09 21:20:40 +01:00
|
|
|
if (nsock->next) {
|
2013-03-21 13:21:18 +00:00
|
|
|
dy -= NODE_SOCKDY;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
add_output_space = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
if (add_output_space) {
|
2018-02-18 03:15:13 +01:00
|
|
|
dy -= NODE_DY / 4;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
node->prvr.xmin = locx + NODE_DYS;
|
|
|
|
node->prvr.xmax = locx + NODE_WIDTH(node) - NODE_DYS;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* preview rect? */
|
2019-03-28 17:39:54 +01:00
|
|
|
if (node->flag & NODE_PREVIEW) {
|
|
|
|
float aspect = 1.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (node->preview_xsize && node->preview_ysize) {
|
2013-10-10 11:33:20 +00:00
|
|
|
aspect = (float)node->preview_ysize / (float)node->preview_xsize;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2012-07-09 19:58:36 +00:00
|
|
|
dy -= NODE_DYS / 2;
|
|
|
|
node->prvr.ymax = dy;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-07-09 19:58:36 +00:00
|
|
|
if (aspect <= 1.0f) {
|
|
|
|
node->prvr.ymin = dy - aspect * (NODE_WIDTH(node) - NODE_DY);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
else {
|
|
|
|
/* width correction of image */
|
|
|
|
/* XXX huh? (ton) */
|
2014-11-09 21:20:40 +01:00
|
|
|
float dx = (NODE_WIDTH(node) - NODE_DYS) - (NODE_WIDTH(node) - NODE_DYS) / aspect;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
node->prvr.ymin = dy - (NODE_WIDTH(node) - NODE_DY);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
node->prvr.xmin += 0.5f * dx;
|
2012-07-09 19:58:36 +00:00
|
|
|
node->prvr.xmax -= 0.5f * dx;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
dy = node->prvr.ymin - NODE_DYS / 2;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* make sure that maximums are bigger or equal to minimums */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->prvr.xmax < node->prvr.xmin) {
|
2014-11-09 21:20:40 +01:00
|
|
|
SWAP(float, node->prvr.xmax, node->prvr.xmin);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->prvr.ymax < node->prvr.ymin) {
|
2014-11-09 21:20:40 +01:00
|
|
|
SWAP(float, node->prvr.ymax, node->prvr.ymin);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-14 11:14:21 +01:00
|
|
|
/* buttons rect? */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node->typeinfo->draw_buttons && (node->flag & NODE_OPTIONS)) {
|
2012-07-09 19:58:36 +00:00
|
|
|
dy -= NODE_DYS / 2;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-16 18:59:13 +00:00
|
|
|
/* set this for uifunc() that don't use layout engine yet */
|
2012-03-24 02:51:46 +00:00
|
|
|
node->butr.xmin = 0;
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
node->butr.xmax = NODE_WIDTH(node) - 2 * NODE_DYS;
|
2012-03-24 02:51:46 +00:00
|
|
|
node->butr.ymin = 0;
|
|
|
|
node->butr.ymax = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-12-14 17:48:57 -06:00
|
|
|
uiLayout *layout = UI_block_layout(node->block,
|
|
|
|
UI_LAYOUT_VERTICAL,
|
|
|
|
UI_LAYOUT_PANEL,
|
|
|
|
locx + NODE_DYS,
|
|
|
|
dy,
|
|
|
|
node->butr.xmax,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
UI_style_get_dpi());
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-28 17:39:54 +01:00
|
|
|
if (node->flag & NODE_MUTED) {
|
|
|
|
uiLayoutSetActive(layout, false);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
uiLayoutSetContextPointer(layout, "node", &nodeptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-10-10 13:07:09 +00:00
|
|
|
node->typeinfo->draw_buttons(layout, (bContext *)C, &nodeptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_end(node->block);
|
|
|
|
UI_block_layout_resolve(node->block, NULL, &buty);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-05-25 09:33:08 +00:00
|
|
|
dy = buty - NODE_DYS / 2;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2013-05-25 09:33:08 +00:00
|
|
|
/* input sockets */
|
2020-09-08 17:19:58 +02:00
|
|
|
LISTBASE_FOREACH (bNodeSocket *, nsock, &node->inputs) {
|
2013-03-18 16:34:57 +00:00
|
|
|
if (nodeSocketIsHidden(nsock)) {
|
|
|
|
continue;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2020-09-08 17:19:58 +02:00
|
|
|
PointerRNA sockptr;
|
2013-03-18 16:34:57 +00:00
|
|
|
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-12-14 17:48:57 -06:00
|
|
|
uiLayout *layout = UI_block_layout(node->block,
|
|
|
|
UI_LAYOUT_VERTICAL,
|
|
|
|
UI_LAYOUT_PANEL,
|
|
|
|
locx + NODE_DYS,
|
|
|
|
dy,
|
|
|
|
NODE_WIDTH(node) - NODE_DY,
|
|
|
|
NODE_DY,
|
|
|
|
0,
|
|
|
|
UI_style_get_dpi());
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-28 17:39:54 +01:00
|
|
|
if (node->flag & NODE_MUTED) {
|
2013-03-18 16:34:57 +00:00
|
|
|
uiLayoutSetActive(layout, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* context pointers for current node and socket */
|
|
|
|
uiLayoutSetContextPointer(layout, "node", &nodeptr);
|
|
|
|
uiLayoutSetContextPointer(layout, "socket", &sockptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-12-14 17:48:57 -06:00
|
|
|
uiLayout *row = uiLayoutRow(layout, true);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-02-11 15:31:40 +00:00
|
|
|
const char *socket_label = nodeSocketLabel(nsock);
|
|
|
|
nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(socket_label));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_end(node->block);
|
2013-03-18 16:34:57 +00:00
|
|
|
UI_block_layout_resolve(node->block, NULL, &buty);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* ensure minimum socket height in case layout is empty */
|
|
|
|
buty = min_ii(buty, dy - NODE_DY);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
nsock->locx = locx;
|
|
|
|
/* place the socket circle in the middle of the layout */
|
2013-03-21 13:21:18 +00:00
|
|
|
nsock->locy = 0.5f * (dy + buty);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
dy = buty;
|
2019-03-26 21:16:47 +11:00
|
|
|
if (nsock->next) {
|
2013-03-21 13:21:18 +00:00
|
|
|
dy -= NODE_SOCKDY;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* little bit space in end */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->inputs.first || (node->flag & (NODE_OPTIONS | NODE_PREVIEW)) == 0) {
|
2012-07-09 19:58:36 +00:00
|
|
|
dy -= NODE_DYS / 2;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 02:51:46 +00:00
|
|
|
node->totr.xmin = locx;
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
node->totr.xmax = locx + NODE_WIDTH(node);
|
2012-03-24 02:51:46 +00:00
|
|
|
node->totr.ymax = locy;
|
2012-10-23 13:28:22 +00:00
|
|
|
node->totr.ymin = min_ff(dy, locy - 2 * NODE_DY);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-22 17:49:06 +00:00
|
|
|
/* Set the block bounds to clip mouse events from underlying nodes.
|
|
|
|
* Add a margin for sockets on each side.
|
|
|
|
*/
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_bounds_set_explicit(node->block,
|
|
|
|
node->totr.xmin - NODE_SOCKSIZE,
|
|
|
|
node->totr.ymin,
|
|
|
|
node->totr.xmax + NODE_SOCKSIZE,
|
|
|
|
node->totr.ymax);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* based on settings in node, sets drawing rect info. each redraw! */
|
2010-10-15 04:27:09 +00:00
|
|
|
static void node_update_hidden(bNode *node)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2020-09-08 17:19:58 +02:00
|
|
|
int totin = 0, totout = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
/* get "global" coords */
|
2020-09-08 17:19:58 +02:00
|
|
|
float locx, locy;
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
node_to_view(node, 0.0f, 0.0f, &locx, &locy);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* calculate minimal radius */
|
2020-09-08 17:19:58 +02:00
|
|
|
LISTBASE_FOREACH (bNodeSocket *, nsock, &node->inputs) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!nodeSocketIsHidden(nsock)) {
|
2008-12-24 10:33:10 +00:00
|
|
|
totin++;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
}
|
2020-09-08 17:19:58 +02:00
|
|
|
LISTBASE_FOREACH (bNodeSocket *, nsock, &node->outputs) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!nodeSocketIsHidden(nsock)) {
|
2008-12-24 10:33:10 +00:00
|
|
|
totout++;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-08 17:19:58 +02:00
|
|
|
float hiddenrad = HIDDEN_RAD;
|
|
|
|
float tot = MAX2(totin, totout);
|
2012-07-09 19:58:36 +00:00
|
|
|
if (tot > 4) {
|
|
|
|
hiddenrad += 5.0f * (float)(tot - 4);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 02:51:46 +00:00
|
|
|
node->totr.xmin = locx;
|
2019-04-02 16:39:48 +02:00
|
|
|
node->totr.xmax = locx + max_ff(NODE_WIDTH(node), 2 * hiddenrad);
|
2012-07-09 19:58:36 +00:00
|
|
|
node->totr.ymax = locy + (hiddenrad - 0.5f * NODE_DY);
|
|
|
|
node->totr.ymin = node->totr.ymax - 2 * hiddenrad;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* output sockets */
|
2020-09-08 17:19:58 +02:00
|
|
|
float rad = (float)M_PI / (1.0f + (float)totout);
|
|
|
|
float drad = rad;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-08 17:19:58 +02:00
|
|
|
LISTBASE_FOREACH (bNodeSocket *, nsock, &node->outputs) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!nodeSocketIsHidden(nsock)) {
|
2013-01-12 14:28:23 +00:00
|
|
|
nsock->locx = node->totr.xmax - hiddenrad + sinf(rad) * hiddenrad;
|
|
|
|
nsock->locy = node->totr.ymin + hiddenrad + cosf(rad) * hiddenrad;
|
2012-07-09 19:58:36 +00:00
|
|
|
rad += drad;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* input sockets */
|
2012-07-09 19:58:36 +00:00
|
|
|
rad = drad = -(float)M_PI / (1.0f + (float)totin);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-08 17:19:58 +02:00
|
|
|
LISTBASE_FOREACH (bNodeSocket *, nsock, &node->inputs) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!nodeSocketIsHidden(nsock)) {
|
2013-01-12 14:28:23 +00:00
|
|
|
nsock->locx = node->totr.xmin + hiddenrad + sinf(rad) * hiddenrad;
|
|
|
|
nsock->locy = node->totr.ymin + hiddenrad + cosf(rad) * hiddenrad;
|
2012-07-09 19:58:36 +00:00
|
|
|
rad += drad;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2011-11-22 17:49:06 +00:00
|
|
|
/* Set the block bounds to clip mouse events from underlying nodes.
|
|
|
|
* Add a margin for sockets on each side.
|
|
|
|
*/
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_bounds_set_explicit(node->block,
|
|
|
|
node->totr.xmin - NODE_SOCKSIZE,
|
|
|
|
node->totr.ymin,
|
|
|
|
node->totr.xmax + NODE_SOCKSIZE,
|
|
|
|
node->totr.ymax);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void node_update_default(const bContext *C, bNodeTree *ntree, bNode *node)
|
|
|
|
{
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->flag & NODE_HIDDEN) {
|
2011-09-05 21:01:50 +00:00
|
|
|
node_update_hidden(node);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else {
|
2011-09-05 21:01:50 +00:00
|
|
|
node_update_basis(C, ntree, node);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
2012-06-01 12:38:03 +00:00
|
|
|
int node_select_area_default(bNode *node, int x, int y)
|
|
|
|
{
|
2012-08-23 18:25:45 +00:00
|
|
|
return BLI_rctf_isect_pt(&node->totr, x, y);
|
2012-06-01 12:38:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int node_tweak_area_default(bNode *node, int x, int y)
|
|
|
|
{
|
2012-08-23 18:25:45 +00:00
|
|
|
return BLI_rctf_isect_pt(&node->totr, x, y);
|
2012-06-01 12:38:03 +00:00
|
|
|
}
|
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
int node_get_colorid(bNode *node)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2013-01-19 04:20:53 +00:00
|
|
|
switch (node->typeinfo->nclass) {
|
2013-12-01 21:30:04 +01:00
|
|
|
case NODE_CLASS_INPUT:
|
|
|
|
return TH_NODE_INPUT;
|
|
|
|
case NODE_CLASS_OUTPUT:
|
|
|
|
return (node->flag & NODE_DO_OUTPUT) ? TH_NODE_OUTPUT : TH_NODE;
|
2013-01-19 04:20:53 +00:00
|
|
|
case NODE_CLASS_CONVERTOR:
|
|
|
|
return TH_NODE_CONVERTOR;
|
2013-12-01 21:30:04 +01:00
|
|
|
case NODE_CLASS_OP_COLOR:
|
|
|
|
return TH_NODE_COLOR;
|
|
|
|
case NODE_CLASS_OP_VECTOR:
|
|
|
|
return TH_NODE_VECTOR;
|
|
|
|
case NODE_CLASS_OP_FILTER:
|
|
|
|
return TH_NODE_FILTER;
|
2013-01-19 04:20:53 +00:00
|
|
|
case NODE_CLASS_GROUP:
|
|
|
|
return TH_NODE_GROUP;
|
2013-03-18 16:34:57 +00:00
|
|
|
case NODE_CLASS_INTERFACE:
|
|
|
|
return TH_NODE_INTERFACE;
|
2013-01-19 04:20:53 +00:00
|
|
|
case NODE_CLASS_MATTE:
|
|
|
|
return TH_NODE_MATTE;
|
|
|
|
case NODE_CLASS_DISTORT:
|
|
|
|
return TH_NODE_DISTORT;
|
2013-12-01 21:30:04 +01:00
|
|
|
case NODE_CLASS_TEXTURE:
|
|
|
|
return TH_NODE_TEXTURE;
|
|
|
|
case NODE_CLASS_SHADER:
|
|
|
|
return TH_NODE_SHADER;
|
|
|
|
case NODE_CLASS_SCRIPT:
|
|
|
|
return TH_NODE_SCRIPT;
|
|
|
|
case NODE_CLASS_PATTERN:
|
|
|
|
return TH_NODE_PATTERN;
|
|
|
|
case NODE_CLASS_LAYOUT:
|
|
|
|
return TH_NODE_LAYOUT;
|
2020-12-01 10:28:29 -05:00
|
|
|
case NODE_CLASS_GEOMETRY:
|
|
|
|
return TH_NODE_GEOMETRY;
|
|
|
|
case NODE_CLASS_ATTRIBUTE:
|
|
|
|
return TH_NODE_ATTRIBUTE;
|
2013-01-19 04:20:53 +00:00
|
|
|
default:
|
|
|
|
return TH_NODE;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-20 16:38:23 +00:00
|
|
|
/* note: in cmp_util.c is similar code, for node_compo_pass_on()
|
|
|
|
* the same goes for shader and texture nodes. */
|
2011-07-12 18:59:54 +00:00
|
|
|
/* note: in node_edit.c is similar code, for untangle node */
|
2021-01-15 10:48:22 -06:00
|
|
|
static void node_draw_mute_line(const View2D *v2d, const SpaceNode *snode, const bNode *node)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2011-11-20 16:38:23 +00:00
|
|
|
|
2021-01-15 10:48:22 -06:00
|
|
|
LISTBASE_FOREACH (const bNodeLink *, link, &node->internal_links) {
|
2018-04-05 15:41:17 +02:00
|
|
|
node_draw_link_bezier(v2d, snode, link, TH_REDALERT, TH_REDALERT, -1);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2011-11-20 16:38:23 +00:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2019-08-22 11:10:11 +02:00
|
|
|
/* flags used in gpu_shader_keyframe_diamond_frag.glsl */
|
|
|
|
#define MARKER_SHAPE_DIAMOND 0x1
|
|
|
|
#define MARKER_SHAPE_SQUARE 0xC
|
|
|
|
#define MARKER_SHAPE_CIRCLE 0x2
|
|
|
|
#define MARKER_SHAPE_INNER_DOT 0x10
|
|
|
|
|
2020-04-16 15:09:49 +02:00
|
|
|
static void node_socket_draw(const bNodeSocket *sock,
|
|
|
|
const float color[4],
|
|
|
|
const float color_outline[4],
|
|
|
|
float size,
|
|
|
|
int locx,
|
|
|
|
int locy,
|
2020-02-08 01:02:18 +11:00
|
|
|
uint pos_id,
|
|
|
|
uint col_id,
|
|
|
|
uint shape_id,
|
|
|
|
uint size_id,
|
2020-04-16 15:09:49 +02:00
|
|
|
uint outline_col_id)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2020-04-16 15:09:49 +02:00
|
|
|
int flags;
|
2019-08-22 11:10:11 +02:00
|
|
|
|
|
|
|
/* sets shape flags */
|
|
|
|
switch (sock->display_shape) {
|
|
|
|
case SOCK_DISPLAY_SHAPE_DIAMOND:
|
|
|
|
case SOCK_DISPLAY_SHAPE_DIAMOND_DOT:
|
|
|
|
flags = MARKER_SHAPE_DIAMOND;
|
|
|
|
break;
|
|
|
|
case SOCK_DISPLAY_SHAPE_SQUARE:
|
|
|
|
case SOCK_DISPLAY_SHAPE_SQUARE_DOT:
|
|
|
|
flags = MARKER_SHAPE_SQUARE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case SOCK_DISPLAY_SHAPE_CIRCLE:
|
|
|
|
case SOCK_DISPLAY_SHAPE_CIRCLE_DOT:
|
|
|
|
flags = MARKER_SHAPE_CIRCLE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ELEM(sock->display_shape,
|
|
|
|
SOCK_DISPLAY_SHAPE_DIAMOND_DOT,
|
|
|
|
SOCK_DISPLAY_SHAPE_SQUARE_DOT,
|
|
|
|
SOCK_DISPLAY_SHAPE_CIRCLE_DOT)) {
|
|
|
|
flags |= MARKER_SHAPE_INNER_DOT;
|
|
|
|
}
|
|
|
|
|
|
|
|
immAttr4fv(col_id, color);
|
|
|
|
immAttr1u(shape_id, flags);
|
2019-08-23 09:03:57 +10:00
|
|
|
immAttr1f(size_id, size);
|
2020-04-16 15:09:49 +02:00
|
|
|
immAttr4fv(outline_col_id, color_outline);
|
|
|
|
immVertex2f(pos_id, locx, locy);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_socket_outline_color_get(bool selected, float r_outline_color[4])
|
|
|
|
{
|
|
|
|
if (selected) {
|
|
|
|
UI_GetThemeColor4fv(TH_TEXT_HI, r_outline_color);
|
|
|
|
r_outline_color[3] = 0.9f;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
copy_v4_fl(r_outline_color, 0.0f);
|
|
|
|
r_outline_color[3] = 0.6f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Usual convention here would be node_socket_get_color(), but that's already used (for setting a
|
|
|
|
* color property socket). */
|
|
|
|
void node_socket_color_get(
|
|
|
|
bContext *C, bNodeTree *ntree, PointerRNA *node_ptr, bNodeSocket *sock, float r_color[4])
|
|
|
|
{
|
|
|
|
PointerRNA ptr;
|
|
|
|
BLI_assert(RNA_struct_is_a(node_ptr->type, &RNA_Node));
|
|
|
|
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
|
|
|
|
|
|
|
|
sock->typeinfo->draw_color(C, &ptr, node_ptr, r_color);
|
|
|
|
|
|
|
|
bNode *node = node_ptr->data;
|
|
|
|
if (node->flag & NODE_MUTED) {
|
|
|
|
r_color[3] *= 0.25f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_socket_draw_nested(const bContext *C,
|
|
|
|
bNodeTree *ntree,
|
|
|
|
PointerRNA *node_ptr,
|
|
|
|
bNodeSocket *sock,
|
|
|
|
uint pos_id,
|
|
|
|
uint col_id,
|
|
|
|
uint shape_id,
|
|
|
|
uint size_id,
|
|
|
|
uint outline_col_id,
|
|
|
|
float size,
|
|
|
|
bool selected)
|
|
|
|
{
|
|
|
|
float color[4];
|
|
|
|
float outline_color[4];
|
|
|
|
|
|
|
|
node_socket_color_get((bContext *)C, ntree, node_ptr, sock, color);
|
|
|
|
node_socket_outline_color_get(selected, outline_color);
|
|
|
|
|
|
|
|
node_socket_draw(sock,
|
|
|
|
color,
|
|
|
|
outline_color,
|
|
|
|
size,
|
|
|
|
sock->locx,
|
|
|
|
sock->locy,
|
|
|
|
pos_id,
|
|
|
|
col_id,
|
|
|
|
shape_id,
|
|
|
|
size_id,
|
|
|
|
outline_col_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw a single node socket at default size.
|
|
|
|
* \note this is only called from external code, internally #node_socket_draw_nested() is used for
|
|
|
|
* optimized drawing of multiple/all sockets of a node.
|
|
|
|
*/
|
|
|
|
void ED_node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[4], float scale)
|
|
|
|
{
|
|
|
|
const float size = 2.25f * NODE_SOCKSIZE * scale;
|
|
|
|
rcti draw_rect = *rect;
|
|
|
|
float outline_color[4] = {0};
|
|
|
|
|
|
|
|
node_socket_outline_color_get(sock->flag & SELECT, outline_color);
|
|
|
|
|
|
|
|
BLI_rcti_resize(&draw_rect, size, size);
|
|
|
|
|
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
|
|
|
uint col_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
|
|
|
|
uint shape_id = GPU_vertformat_attr_add(format, "flags", GPU_COMP_U32, 1, GPU_FETCH_INT);
|
|
|
|
uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
|
|
|
|
uint outline_col_id = GPU_vertformat_attr_add(
|
|
|
|
format, "outlineColor", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
|
|
|
|
|
2020-08-16 23:20:59 +02:00
|
|
|
eGPUBlend state = GPU_blend_get();
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2020-04-16 15:09:49 +02:00
|
|
|
GPU_program_point_size(true);
|
|
|
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
|
|
|
|
immUniform1f("outline_scale", 0.7f);
|
|
|
|
immUniform2f("ViewportSize", -1.0f, -1.0f);
|
|
|
|
|
|
|
|
/* Single point */
|
|
|
|
immBegin(GPU_PRIM_POINTS, 1);
|
|
|
|
node_socket_draw(sock,
|
|
|
|
color,
|
|
|
|
outline_color,
|
|
|
|
BLI_rcti_size_y(&draw_rect),
|
|
|
|
BLI_rcti_cent_x(&draw_rect),
|
|
|
|
BLI_rcti_cent_y(&draw_rect),
|
|
|
|
pos_id,
|
|
|
|
col_id,
|
|
|
|
shape_id,
|
|
|
|
size_id,
|
|
|
|
outline_col_id);
|
|
|
|
immEnd();
|
|
|
|
|
|
|
|
immUnbindProgram();
|
|
|
|
GPU_program_point_size(false);
|
2020-08-16 23:20:59 +02:00
|
|
|
|
|
|
|
/* Restore. */
|
|
|
|
GPU_blend(state);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ************** Socket callbacks *********** */
|
|
|
|
|
2020-08-19 11:37:35 +10:00
|
|
|
static void node_draw_preview_background(rctf *rect)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-18 16:12:56 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_CHECKER);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-18 16:12:56 +02:00
|
|
|
/* Drawing the checkerboard. */
|
|
|
|
const float checker_dark = UI_ALPHA_CHECKER_DARK / 255.0f;
|
|
|
|
const float checker_light = UI_ALPHA_CHECKER_LIGHT / 255.0f;
|
|
|
|
immUniform4f("color1", checker_dark, checker_dark, checker_dark, 1.0f);
|
|
|
|
immUniform4f("color2", checker_light, checker_light, checker_light, 1.0f);
|
|
|
|
immUniform1i("size", 8);
|
2016-11-08 11:10:47 -05:00
|
|
|
immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
|
|
|
|
immUnbindProgram();
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* not a callback */
|
|
|
|
static void node_draw_preview(bNodePreview *preview, rctf *prv)
|
|
|
|
{
|
|
|
|
float xrect = BLI_rctf_size_x(prv);
|
|
|
|
float yrect = BLI_rctf_size_y(prv);
|
|
|
|
float xscale = xrect / ((float)preview->xsize);
|
|
|
|
float yscale = yrect / ((float)preview->ysize);
|
|
|
|
float scale;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* uniform scale and offset */
|
2020-09-08 17:19:58 +02:00
|
|
|
rctf draw_rect = *prv;
|
2013-03-18 16:34:57 +00:00
|
|
|
if (xscale < yscale) {
|
|
|
|
float offset = 0.5f * (yrect - ((float)preview->ysize) * xscale);
|
|
|
|
draw_rect.ymin += offset;
|
|
|
|
draw_rect.ymax -= offset;
|
|
|
|
scale = xscale;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float offset = 0.5f * (xrect - ((float)preview->xsize) * yscale);
|
|
|
|
draw_rect.xmin += offset;
|
|
|
|
draw_rect.xmax -= offset;
|
|
|
|
scale = yscale;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-19 11:37:35 +10:00
|
|
|
node_draw_preview_background(&draw_rect);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-01-15 23:24:20 +11:00
|
|
|
/* premul graphics */
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-04-11 16:30:00 +02:00
|
|
|
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
|
|
|
immDrawPixelsTex(&state,
|
|
|
|
draw_rect.xmin,
|
|
|
|
draw_rect.ymin,
|
|
|
|
preview->xsize,
|
|
|
|
preview->ysize,
|
2020-07-26 19:50:15 +02:00
|
|
|
GPU_RGBA8,
|
|
|
|
true,
|
2017-04-11 16:30:00 +02:00
|
|
|
preview->rect,
|
2017-02-24 01:20:30 +01:00
|
|
|
scale,
|
|
|
|
scale,
|
|
|
|
NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2017-03-03 13:22:16 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformThemeColorShadeAlpha(TH_BACK, -15, +100);
|
2017-09-26 15:21:01 +10:00
|
|
|
imm_draw_box_wire_2d(pos, draw_rect.xmin, draw_rect.ymin, draw_rect.xmax, draw_rect.ymax);
|
2017-03-03 13:22:16 -05:00
|
|
|
immUnbindProgram();
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2011-12-18 12:51:50 +00:00
|
|
|
/* common handle function for operator buttons that need to select the node first */
|
|
|
|
static void node_toggle_button_cb(struct bContext *C, void *node_argv, void *op_argv)
|
|
|
|
{
|
2012-07-09 19:58:36 +00:00
|
|
|
bNode *node = (bNode *)node_argv;
|
2011-12-18 12:51:50 +00:00
|
|
|
const char *opname = (const char *)op_argv;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-12-18 12:51:50 +00:00
|
|
|
/* select & activate only the button's node */
|
|
|
|
node_select_single(C, node);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-12-18 12:51:50 +00:00
|
|
|
WM_operator_name_call(C, opname, WM_OP_INVOKE_DEFAULT, NULL);
|
|
|
|
}
|
|
|
|
|
2021-01-15 10:48:22 -06:00
|
|
|
void node_draw_shadow(const SpaceNode *snode, const bNode *node, float radius, float alpha)
|
2012-05-22 14:13:33 +00:00
|
|
|
{
|
2021-01-15 10:48:22 -06:00
|
|
|
const rctf *rct = &node->totr;
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
2021-01-19 16:43:08 -06:00
|
|
|
ui_draw_dropshadow(rct, radius, snode->runtime->aspect, alpha, node->flag & SELECT);
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
|
|
|
|
2021-01-15 10:48:22 -06:00
|
|
|
void node_draw_sockets(const View2D *v2d,
|
2016-10-15 02:49:00 -04:00
|
|
|
const bContext *C,
|
|
|
|
bNodeTree *ntree,
|
|
|
|
bNode *node,
|
|
|
|
bool draw_outputs,
|
|
|
|
bool select_all)
|
|
|
|
{
|
2018-07-08 13:19:10 +02:00
|
|
|
const uint total_input_len = BLI_listbase_count(&node->inputs);
|
|
|
|
const uint total_output_len = BLI_listbase_count(&node->outputs);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-08 13:19:10 +02:00
|
|
|
if (total_input_len + total_output_len == 0) {
|
2017-04-04 01:15:35 -04:00
|
|
|
return;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-15 02:49:00 -04:00
|
|
|
PointerRNA node_ptr;
|
|
|
|
RNA_pointer_create((ID *)ntree, &RNA_Node, node, &node_ptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-08-22 11:10:11 +02:00
|
|
|
bool selected = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
2019-08-22 11:10:11 +02:00
|
|
|
uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
|
|
|
uint col_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
|
|
|
|
uint shape_id = GPU_vertformat_attr_add(format, "flags", GPU_COMP_U32, 1, GPU_FETCH_INT);
|
|
|
|
uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
|
2019-08-23 09:03:57 +10:00
|
|
|
uint outline_col_id = GPU_vertformat_attr_add(
|
|
|
|
format, "outlineColor", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-05-28 17:14:22 +02:00
|
|
|
GPU_program_point_size(true);
|
2019-08-22 11:10:11 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
|
|
|
|
immUniform1f("outline_scale", 0.7f);
|
2019-08-25 16:37:06 +01:00
|
|
|
immUniform2f("ViewportSize", -1.0f, -1.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-15 02:49:00 -04:00
|
|
|
/* set handle size */
|
2019-08-22 11:10:11 +02:00
|
|
|
float scale;
|
|
|
|
UI_view2d_scale_get(v2d, &scale, NULL);
|
|
|
|
scale *= 2.25f * NODE_SOCKSIZE;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-15 02:49:00 -04:00
|
|
|
if (!select_all) {
|
2018-07-18 00:12:21 +02:00
|
|
|
immBeginAtMost(GPU_PRIM_POINTS, total_input_len + total_output_len);
|
2016-10-15 02:49:00 -04:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-15 02:49:00 -04:00
|
|
|
/* socket inputs */
|
2018-07-08 13:19:10 +02:00
|
|
|
short selected_input_len = 0;
|
2020-11-30 13:56:46 -05:00
|
|
|
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (nodeSocketIsHidden(sock)) {
|
2016-10-15 02:49:00 -04:00
|
|
|
continue;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2016-10-15 02:49:00 -04:00
|
|
|
if (select_all || (sock->flag & SELECT)) {
|
2019-09-08 00:12:26 +10:00
|
|
|
selected_input_len++;
|
2016-10-15 02:49:00 -04:00
|
|
|
continue;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-16 15:09:49 +02:00
|
|
|
node_socket_draw_nested(C,
|
|
|
|
ntree,
|
|
|
|
&node_ptr,
|
|
|
|
sock,
|
|
|
|
pos_id,
|
|
|
|
col_id,
|
|
|
|
shape_id,
|
|
|
|
size_id,
|
|
|
|
outline_col_id,
|
|
|
|
scale,
|
|
|
|
selected);
|
2016-10-15 02:49:00 -04:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-15 02:49:00 -04:00
|
|
|
/* socket outputs */
|
2018-07-08 13:19:10 +02:00
|
|
|
short selected_output_len = 0;
|
2016-10-15 02:49:00 -04:00
|
|
|
if (draw_outputs) {
|
2020-11-30 13:56:46 -05:00
|
|
|
LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (nodeSocketIsHidden(sock)) {
|
2016-10-15 02:49:00 -04:00
|
|
|
continue;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2016-10-15 02:49:00 -04:00
|
|
|
if (select_all || (sock->flag & SELECT)) {
|
2019-09-08 00:12:26 +10:00
|
|
|
selected_output_len++;
|
2016-10-15 02:49:00 -04:00
|
|
|
continue;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-16 15:09:49 +02:00
|
|
|
node_socket_draw_nested(C,
|
|
|
|
ntree,
|
|
|
|
&node_ptr,
|
|
|
|
sock,
|
|
|
|
pos_id,
|
|
|
|
col_id,
|
|
|
|
shape_id,
|
|
|
|
size_id,
|
|
|
|
outline_col_id,
|
|
|
|
scale,
|
|
|
|
selected);
|
2016-10-15 02:49:00 -04:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-15 02:49:00 -04:00
|
|
|
if (!select_all) {
|
|
|
|
immEnd();
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-15 02:49:00 -04:00
|
|
|
/* go back and draw selected sockets */
|
2018-07-08 13:19:10 +02:00
|
|
|
if (selected_input_len + selected_output_len > 0) {
|
2016-10-15 02:49:00 -04:00
|
|
|
/* outline for selected sockets */
|
2019-08-23 09:03:57 +10:00
|
|
|
|
2019-08-22 11:10:11 +02:00
|
|
|
selected = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_POINTS, selected_input_len + selected_output_len);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-08 13:19:10 +02:00
|
|
|
if (selected_input_len) {
|
2016-10-15 02:49:00 -04:00
|
|
|
/* socket inputs */
|
2020-11-30 13:56:46 -05:00
|
|
|
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (nodeSocketIsHidden(sock)) {
|
2016-10-15 02:49:00 -04:00
|
|
|
continue;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2016-10-15 02:49:00 -04:00
|
|
|
if (select_all || (sock->flag & SELECT)) {
|
2020-04-16 15:09:49 +02:00
|
|
|
node_socket_draw_nested(C,
|
|
|
|
ntree,
|
|
|
|
&node_ptr,
|
|
|
|
sock,
|
|
|
|
pos_id,
|
|
|
|
col_id,
|
|
|
|
shape_id,
|
|
|
|
size_id,
|
|
|
|
outline_col_id,
|
|
|
|
scale,
|
|
|
|
selected);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (--selected_input_len == 0) {
|
2016-10-15 02:49:00 -04:00
|
|
|
break; /* stop as soon as last one is drawn */
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2016-10-15 02:49:00 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-08 13:19:10 +02:00
|
|
|
if (selected_output_len) {
|
2016-10-15 02:49:00 -04:00
|
|
|
/* socket outputs */
|
2020-11-30 13:56:46 -05:00
|
|
|
LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (nodeSocketIsHidden(sock)) {
|
2016-10-15 02:49:00 -04:00
|
|
|
continue;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2016-10-15 02:49:00 -04:00
|
|
|
if (select_all || (sock->flag & SELECT)) {
|
2020-04-16 15:09:49 +02:00
|
|
|
node_socket_draw_nested(C,
|
|
|
|
ntree,
|
|
|
|
&node_ptr,
|
|
|
|
sock,
|
|
|
|
pos_id,
|
|
|
|
col_id,
|
|
|
|
shape_id,
|
|
|
|
size_id,
|
|
|
|
outline_col_id,
|
|
|
|
scale,
|
|
|
|
selected);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (--selected_output_len == 0) {
|
2016-10-15 02:49:00 -04:00
|
|
|
break; /* stop as soon as last one is drawn */
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2016-10-15 02:49:00 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-15 02:49:00 -04:00
|
|
|
immEnd();
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-15 02:49:00 -04:00
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-28 17:14:22 +02:00
|
|
|
GPU_program_point_size(false);
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2016-10-15 02:49:00 -04:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
static void node_draw_basis(const bContext *C,
|
2021-01-15 10:48:22 -06:00
|
|
|
const View2D *v2d,
|
|
|
|
const SpaceNode *snode,
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeTree *ntree,
|
|
|
|
bNode *node,
|
|
|
|
bNodeInstanceKey key)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2012-10-26 04:14:10 +00:00
|
|
|
/* float socket_size = NODE_SOCKSIZE*U.dpi/72; */ /* UNUSED */
|
2012-07-09 19:58:36 +00:00
|
|
|
float iconbutw = 0.8f * UI_UNIT_X;
|
2020-09-08 17:19:58 +02:00
|
|
|
|
2010-06-14 07:02:11 +00:00
|
|
|
/* skip if out of view */
|
2016-10-15 02:49:00 -04:00
|
|
|
if (BLI_rctf_isect(&node->totr, &v2d->cur, NULL) == false) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_end(C, node->block);
|
2012-07-09 19:58:36 +00:00
|
|
|
node->block = NULL;
|
2010-06-14 07:02:11 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
/* shadow */
|
2012-06-01 14:42:21 +00:00
|
|
|
node_draw_shadow(snode, node, BASIS_RAD, 1.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-08 17:19:58 +02:00
|
|
|
float color[4];
|
|
|
|
int color_id = node_get_colorid(node);
|
2017-04-04 01:15:35 -04:00
|
|
|
if (node->flag & NODE_MUTED) {
|
2019-03-28 17:39:54 +01:00
|
|
|
/* Muted nodes are semi-transparent and colorless. */
|
|
|
|
UI_GetThemeColor3fv(TH_NODE, color);
|
|
|
|
color[3] = 0.25f;
|
2017-04-04 01:15:35 -04:00
|
|
|
}
|
|
|
|
else {
|
2019-03-28 17:39:54 +01:00
|
|
|
/* Opaque headers for regular nodes. */
|
|
|
|
UI_GetThemeColor3fv(color_id, color);
|
2019-02-20 14:35:27 +01:00
|
|
|
color[3] = 1.0f;
|
2017-04-04 01:15:35 -04:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_width(1.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-08 17:19:58 +02:00
|
|
|
rctf *rct = &node->totr;
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
|
2017-04-06 19:15:26 -04:00
|
|
|
UI_draw_roundbox_aa(
|
2021-01-25 18:31:11 +11:00
|
|
|
&(const rctf){
|
|
|
|
.xmin = rct->xmin,
|
|
|
|
.xmax = rct->xmax,
|
|
|
|
.ymin = rct->ymax - NODE_DY,
|
|
|
|
.ymax = rct->ymax,
|
|
|
|
},
|
|
|
|
true,
|
|
|
|
BASIS_RAD,
|
|
|
|
color);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-12-18 12:51:50 +00:00
|
|
|
/* show/hide icons */
|
2020-09-08 17:19:58 +02:00
|
|
|
float iconofs = rct->xmax - 0.35f * U.widget_unit;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-12-18 12:51:50 +00:00
|
|
|
/* preview */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node->typeinfo->flag & NODE_PREVIEW) {
|
2012-07-09 19:58:36 +00:00
|
|
|
iconofs -= iconbutw;
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(node->block, UI_EMBOSS_NONE);
|
2020-11-30 13:56:46 -05:00
|
|
|
uiBut *but = uiDefIconBut(node->block,
|
|
|
|
UI_BTYPE_BUT_TOGGLE,
|
|
|
|
B_REDR,
|
|
|
|
ICON_MATERIAL,
|
|
|
|
iconofs,
|
|
|
|
rct->ymax - NODE_DY,
|
|
|
|
iconbutw,
|
|
|
|
UI_UNIT_Y,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
"");
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_preview_toggle");
|
2011-12-18 12:51:50 +00:00
|
|
|
/* XXX this does not work when node is activated and the operator called right afterwards,
|
|
|
|
* since active ID is not updated yet (needs to process the notifier).
|
|
|
|
* This can only work as visual indicator!
|
|
|
|
*/
|
|
|
|
// if (!(node->flag & (NODE_ACTIVE_ID|NODE_DO_OUTPUT)))
|
2014-11-09 21:20:40 +01:00
|
|
|
// UI_but_flag_enable(but, UI_BUT_DISABLED);
|
|
|
|
UI_block_emboss_set(node->block, UI_EMBOSS);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2011-12-18 12:51:50 +00:00
|
|
|
/* group edit */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node->type == NODE_GROUP) {
|
2012-07-09 19:58:36 +00:00
|
|
|
iconofs -= iconbutw;
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(node->block, UI_EMBOSS_NONE);
|
2020-11-30 13:56:46 -05:00
|
|
|
uiBut *but = uiDefIconBut(node->block,
|
|
|
|
UI_BTYPE_BUT_TOGGLE,
|
|
|
|
B_REDR,
|
|
|
|
ICON_NODETREE,
|
|
|
|
iconofs,
|
|
|
|
rct->ymax - NODE_DY,
|
|
|
|
iconbutw,
|
|
|
|
UI_UNIT_Y,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
"");
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_group_edit");
|
|
|
|
UI_block_emboss_set(node->block, UI_EMBOSS);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2020-03-16 18:25:23 +01:00
|
|
|
if (node->type == NODE_CUSTOM && node->typeinfo->ui_icon != ICON_NONE) {
|
|
|
|
iconofs -= iconbutw;
|
|
|
|
UI_block_emboss_set(node->block, UI_EMBOSS_NONE);
|
|
|
|
uiDefIconBut(node->block,
|
|
|
|
UI_BTYPE_BUT,
|
|
|
|
0,
|
|
|
|
node->typeinfo->ui_icon,
|
|
|
|
iconofs,
|
|
|
|
rct->ymax - NODE_DY,
|
|
|
|
iconbutw,
|
|
|
|
UI_UNIT_Y,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
"");
|
|
|
|
UI_block_emboss_set(node->block, UI_EMBOSS);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* title */
|
2017-02-14 13:00:22 +01:00
|
|
|
if (node->flag & SELECT) {
|
|
|
|
UI_GetThemeColor4fv(TH_SELECT, color);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UI_GetThemeColorBlendShade4fv(TH_SELECT, color_id, 0.4f, 10, color);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* open/close entirely? */
|
2011-12-18 12:51:50 +00:00
|
|
|
{
|
2019-03-25 13:59:11 +01:00
|
|
|
int but_size = U.widget_unit * 0.8f;
|
2011-12-18 12:51:50 +00:00
|
|
|
/* XXX button uses a custom triangle draw below, so make it invisible without icon */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(node->block, UI_EMBOSS_NONE);
|
2020-11-30 13:56:46 -05:00
|
|
|
uiBut *but = uiDefBut(node->block,
|
|
|
|
UI_BTYPE_BUT_TOGGLE,
|
|
|
|
B_REDR,
|
|
|
|
"",
|
|
|
|
rct->xmin + 0.35f * U.widget_unit,
|
|
|
|
rct->ymax - NODE_DY / 2.2f - but_size / 2,
|
|
|
|
but_size,
|
|
|
|
but_size,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
"");
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle");
|
|
|
|
UI_block_emboss_set(node->block, UI_EMBOSS);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-04 12:53:33 +02:00
|
|
|
UI_GetThemeColor4fv(TH_TEXT, color);
|
2011-12-18 12:51:50 +00:00
|
|
|
/* custom draw function for this button */
|
2019-03-25 13:59:11 +01:00
|
|
|
UI_draw_icon_tri(rct->xmin + 0.65f * U.widget_unit, rct->ymax - NODE_DY / 2.2f, 'v', color);
|
2011-12-18 12:51:50 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-08 17:19:58 +02:00
|
|
|
char showname[128]; /* 128 used below */
|
2013-11-12 18:18:04 +00:00
|
|
|
nodeLabel(ntree, node, showname, sizeof(showname));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-28 17:39:54 +01:00
|
|
|
uiBut *but = uiDefBut(node->block,
|
|
|
|
UI_BTYPE_LABEL,
|
|
|
|
0,
|
|
|
|
showname,
|
2020-06-18 12:21:38 +10:00
|
|
|
(int)(rct->xmin + NODE_MARGIN_X),
|
2019-03-28 17:39:54 +01:00
|
|
|
(int)(rct->ymax - NODE_DY),
|
2020-10-09 18:17:13 +11:00
|
|
|
(short)(iconofs - rct->xmin - (18.0f * U.dpi_fac)),
|
2019-03-28 17:39:54 +01:00
|
|
|
(short)NODE_DY,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0,
|
2019-04-17 06:17:24 +02:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
"");
|
2019-01-15 23:24:20 +11:00
|
|
|
if (node->flag & NODE_MUTED) {
|
|
|
|
UI_but_flag_enable(but, UI_BUT_INACTIVE);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2019-01-15 23:24:20 +11:00
|
|
|
/* body */
|
2020-11-19 14:23:48 +01:00
|
|
|
if (nodeTypeUndefined(node)) {
|
2019-01-15 23:24:20 +11:00
|
|
|
/* use warning color to indicate undefined types */
|
2017-02-14 13:00:22 +01:00
|
|
|
UI_GetThemeColor4fv(TH_REDALERT, color);
|
2019-03-28 17:39:54 +01:00
|
|
|
}
|
|
|
|
else if (node->flag & NODE_MUTED) {
|
|
|
|
/* Muted nodes are semi-transparent and colorless. */
|
|
|
|
UI_GetThemeColor4fv(TH_NODE, color);
|
2019-01-15 23:24:20 +11:00
|
|
|
}
|
2016-11-14 20:04:59 -05:00
|
|
|
else if (node->flag & NODE_CUSTOM_COLOR) {
|
2017-04-04 01:15:35 -04:00
|
|
|
rgba_float_args_set(color, node->color[0], node->color[1], node->color[2], 1.0f);
|
2016-11-14 20:04:59 -05:00
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
else {
|
2016-11-14 20:04:59 -05:00
|
|
|
UI_GetThemeColor4fv(TH_NODE, color);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-28 17:39:54 +01:00
|
|
|
if (node->flag & NODE_MUTED) {
|
|
|
|
color[3] = 0.5f;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT);
|
2017-04-06 19:15:26 -04:00
|
|
|
UI_draw_roundbox_aa(
|
2021-01-25 18:31:11 +11:00
|
|
|
&(const rctf){
|
|
|
|
.xmin = rct->xmin,
|
|
|
|
.xmax = rct->xmax,
|
|
|
|
.ymin = rct->ymin,
|
|
|
|
.ymax = rct->ymax - NODE_DY,
|
|
|
|
},
|
|
|
|
true,
|
|
|
|
BASIS_RAD,
|
|
|
|
color);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-01-09 18:59:35 +00:00
|
|
|
/* outline active and selected emphasis */
|
2012-08-01 09:44:25 +00:00
|
|
|
if (node->flag & SELECT) {
|
2016-10-15 02:49:00 -04:00
|
|
|
UI_GetThemeColorShadeAlpha4fv(
|
|
|
|
(node->flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, 0, -40, color);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
2021-01-25 18:31:11 +11:00
|
|
|
UI_draw_roundbox_aa(
|
|
|
|
&(const rctf){
|
|
|
|
.xmin = rct->xmin,
|
|
|
|
.xmax = rct->xmax,
|
|
|
|
.ymin = rct->ymin,
|
|
|
|
.ymax = rct->ymax,
|
|
|
|
},
|
|
|
|
false,
|
|
|
|
BASIS_RAD,
|
|
|
|
color);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* disable lines */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->flag & NODE_MUTED) {
|
2008-12-24 10:33:10 +00:00
|
|
|
node_draw_mute_line(v2d, snode, node);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-15 02:49:00 -04:00
|
|
|
node_draw_sockets(v2d, C, ntree, node, true, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* preview */
|
2020-09-08 17:19:58 +02:00
|
|
|
bNodeInstanceHash *previews = CTX_data_pointer_get(C, "node_previews").data;
|
2013-09-07 04:35:26 +00:00
|
|
|
if (node->flag & NODE_PREVIEW && previews) {
|
|
|
|
bNodePreview *preview = BKE_node_instance_hash_lookup(previews, key);
|
2013-09-07 06:56:27 +00:00
|
|
|
if (preview && (preview->xsize && preview->ysize)) {
|
2013-09-07 04:35:26 +00:00
|
|
|
if (preview->rect && !BLI_rctf_is_empty(&node->prvr)) {
|
|
|
|
node_draw_preview(preview, &node->prvr);
|
2009-09-30 18:18:32 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_end(C, node->block);
|
|
|
|
UI_block_draw(C, node->block);
|
2012-07-09 19:58:36 +00:00
|
|
|
node->block = NULL;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
static void node_draw_hidden(const bContext *C,
|
2021-01-15 10:48:22 -06:00
|
|
|
const View2D *v2d,
|
|
|
|
const SpaceNode *snode,
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeTree *ntree,
|
|
|
|
bNode *node,
|
|
|
|
bNodeInstanceKey UNUSED(key))
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2012-07-09 19:58:36 +00:00
|
|
|
rctf *rct = &node->totr;
|
2020-09-08 17:19:58 +02:00
|
|
|
float centy = BLI_rctf_cent_y(rct);
|
2012-09-15 11:48:20 +00:00
|
|
|
float hiddenrad = BLI_rctf_size_y(rct) / 2.0f;
|
2020-09-08 17:19:58 +02:00
|
|
|
|
|
|
|
float scale;
|
2017-04-04 01:15:35 -04:00
|
|
|
UI_view2d_scale_get(v2d, &scale, NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* shadow */
|
2012-06-01 14:42:21 +00:00
|
|
|
node_draw_shadow(snode, node, hiddenrad, 1.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* body */
|
2020-09-08 17:19:58 +02:00
|
|
|
float color[4];
|
|
|
|
int color_id = node_get_colorid(node);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->flag & NODE_MUTED) {
|
2019-03-28 17:39:54 +01:00
|
|
|
/* Muted nodes are semi-transparent and colorless. */
|
|
|
|
UI_GetThemeColor4fv(TH_NODE, color);
|
|
|
|
color[3] = 0.25f;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else {
|
2017-04-04 01:15:35 -04:00
|
|
|
UI_GetThemeColor4fv(color_id, color);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-01-25 18:31:11 +11:00
|
|
|
UI_draw_roundbox_aa(rct, true, hiddenrad, color);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-01-09 18:59:35 +00:00
|
|
|
/* outline active and selected emphasis */
|
2012-08-03 11:39:34 +00:00
|
|
|
if (node->flag & SELECT) {
|
2016-10-15 02:49:00 -04:00
|
|
|
UI_GetThemeColorShadeAlpha4fv(
|
|
|
|
(node->flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, 0, -40, color);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-01-25 18:31:11 +11:00
|
|
|
UI_draw_roundbox_aa(rct, false, hiddenrad, color);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-22 13:53:58 +00:00
|
|
|
/* custom color inline */
|
|
|
|
if (node->flag & NODE_CUSTOM_COLOR) {
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_smooth(true);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-01-25 18:31:11 +11:00
|
|
|
UI_draw_roundbox_3fv_alpha(
|
|
|
|
&(const rctf){
|
|
|
|
.xmin = rct->xmin + 1,
|
|
|
|
.xmax = rct->xmax - 1,
|
|
|
|
.ymin = rct->ymin + 1,
|
|
|
|
.ymax = rct->ymax - 1,
|
|
|
|
},
|
|
|
|
false,
|
|
|
|
hiddenrad,
|
|
|
|
node->color,
|
|
|
|
1.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_smooth(false);
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2013-03-22 13:53:58 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* title */
|
2017-02-14 13:00:22 +01:00
|
|
|
if (node->flag & SELECT) {
|
|
|
|
UI_GetThemeColor4fv(TH_SELECT, color);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UI_GetThemeColorBlendShade4fv(TH_SELECT, color_id, 0.4f, 10, color);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* open entirely icon */
|
2011-12-18 12:51:50 +00:00
|
|
|
{
|
2019-03-25 13:59:11 +01:00
|
|
|
int but_size = U.widget_unit * 0.8f;
|
2011-12-18 12:51:50 +00:00
|
|
|
/* XXX button uses a custom triangle draw below, so make it invisible without icon */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(node->block, UI_EMBOSS_NONE);
|
2020-11-30 13:56:46 -05:00
|
|
|
uiBut *but = uiDefBut(node->block,
|
|
|
|
UI_BTYPE_BUT_TOGGLE,
|
|
|
|
B_REDR,
|
|
|
|
"",
|
|
|
|
rct->xmin + 0.35f * U.widget_unit,
|
|
|
|
centy - but_size / 2,
|
|
|
|
but_size,
|
|
|
|
but_size,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
"");
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle");
|
|
|
|
UI_block_emboss_set(node->block, UI_EMBOSS);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-04 12:53:33 +02:00
|
|
|
UI_GetThemeColor4fv(TH_TEXT, color);
|
2011-12-18 12:51:50 +00:00
|
|
|
/* custom draw function for this button */
|
2019-03-25 13:59:11 +01:00
|
|
|
UI_draw_icon_tri(rct->xmin + 0.65f * U.widget_unit, centy, 'h', color);
|
2011-12-18 12:51:50 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* disable lines */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->flag & NODE_MUTED) {
|
2021-01-15 10:48:22 -06:00
|
|
|
node_draw_mute_line(v2d, snode, node);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-08 17:19:58 +02:00
|
|
|
char showname[128]; /* 128 is used below */
|
2019-04-02 16:39:48 +02:00
|
|
|
nodeLabel(ntree, node, showname, sizeof(showname));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-02 16:39:48 +02:00
|
|
|
/* XXX - don't print into self! */
|
2019-05-01 11:09:22 +10:00
|
|
|
// if (node->flag & NODE_MUTED)
|
2019-04-02 16:39:48 +02:00
|
|
|
// BLI_snprintf(showname, sizeof(showname), "[%s]", showname);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-02 16:39:48 +02:00
|
|
|
uiBut *but = uiDefBut(node->block,
|
|
|
|
UI_BTYPE_LABEL,
|
|
|
|
0,
|
|
|
|
showname,
|
|
|
|
round_fl_to_int(rct->xmin + NODE_MARGIN_X),
|
|
|
|
round_fl_to_int(centy - NODE_DY * 0.5f),
|
2020-10-09 18:17:13 +11:00
|
|
|
(short)(BLI_rctf_size_x(rct) - ((18.0f + 12.0f) * U.dpi_fac)),
|
2019-04-02 16:39:48 +02:00
|
|
|
(short)NODE_DY,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
"");
|
|
|
|
if (node->flag & NODE_MUTED) {
|
|
|
|
UI_but_flag_enable(but, UI_BUT_INACTIVE);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* scale widget thing */
|
2018-07-18 00:12:21 +02:00
|
|
|
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2017-03-06 20:29:09 -03:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-06 20:29:09 -03:00
|
|
|
immUniformThemeColorShade(color_id, -10);
|
2020-09-08 17:19:58 +02:00
|
|
|
float dx = 10.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 4);
|
2017-03-06 20:29:09 -03:00
|
|
|
immVertex2f(pos, rct->xmax - dx, centy - 4.0f);
|
|
|
|
immVertex2f(pos, rct->xmax - dx, centy + 4.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-01-19 16:43:08 -06:00
|
|
|
immVertex2f(pos, rct->xmax - dx - 3.0f * snode->runtime->aspect, centy - 4.0f);
|
|
|
|
immVertex2f(pos, rct->xmax - dx - 3.0f * snode->runtime->aspect, centy + 4.0f);
|
2017-03-06 20:29:09 -03:00
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-06 20:29:09 -03:00
|
|
|
immUniformThemeColorShade(color_id, 30);
|
2021-01-19 16:43:08 -06:00
|
|
|
dx -= snode->runtime->aspect;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 4);
|
2017-03-06 20:29:09 -03:00
|
|
|
immVertex2f(pos, rct->xmax - dx, centy - 4.0f);
|
|
|
|
immVertex2f(pos, rct->xmax - dx, centy + 4.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-01-19 16:43:08 -06:00
|
|
|
immVertex2f(pos, rct->xmax - dx - 3.0f * snode->runtime->aspect, centy - 4.0f);
|
|
|
|
immVertex2f(pos, rct->xmax - dx - 3.0f * snode->runtime->aspect, centy + 4.0f);
|
2017-03-06 20:29:09 -03:00
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-06 20:29:09 -03:00
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-15 02:49:00 -04:00
|
|
|
node_draw_sockets(v2d, C, ntree, node, true, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_end(C, node->block);
|
|
|
|
UI_block_draw(C, node->block);
|
2012-07-09 19:58:36 +00:00
|
|
|
node->block = NULL;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
int node_get_resize_cursor(int directions)
|
|
|
|
{
|
2019-03-26 21:16:47 +11:00
|
|
|
if (directions == 0) {
|
2019-09-26 14:31:48 +02:00
|
|
|
return WM_CURSOR_DEFAULT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2020-07-03 17:20:08 +02:00
|
|
|
if ((directions & ~(NODE_RESIZE_TOP | NODE_RESIZE_BOTTOM)) == 0) {
|
2019-09-26 14:31:48 +02:00
|
|
|
return WM_CURSOR_Y_MOVE;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2020-07-03 17:20:08 +02:00
|
|
|
if ((directions & ~(NODE_RESIZE_RIGHT | NODE_RESIZE_LEFT)) == 0) {
|
2019-09-26 14:31:48 +02:00
|
|
|
return WM_CURSOR_X_MOVE;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2020-07-03 17:20:08 +02:00
|
|
|
return WM_CURSOR_EDIT;
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
|
|
|
|
2013-09-05 13:03:03 +00:00
|
|
|
void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2])
|
2012-05-22 14:13:33 +00:00
|
|
|
{
|
|
|
|
bNodeTree *ntree = snode->edittree;
|
|
|
|
bNode *node;
|
|
|
|
bNodeSocket *sock;
|
2019-09-26 14:31:48 +02:00
|
|
|
int wmcursor = WM_CURSOR_DEFAULT;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-19 13:40:16 +00:00
|
|
|
if (ntree) {
|
2013-09-05 13:03:03 +00:00
|
|
|
if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_IN | SOCK_OUT)) {
|
2012-05-22 14:13:33 +00:00
|
|
|
/* pass */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* check nodes front to back */
|
2012-07-09 19:58:36 +00:00
|
|
|
for (node = ntree->nodes.last; node; node = node->prev) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (BLI_rctf_isect_pt(&node->totr, cursor[0], cursor[1])) {
|
2012-07-09 19:58:36 +00:00
|
|
|
break; /* first hit on node stops */
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
|
|
|
if (node) {
|
2013-09-05 13:03:03 +00:00
|
|
|
int dir = node->typeinfo->resize_area_func(node, cursor[0], cursor[1]);
|
|
|
|
wmcursor = node_get_resize_cursor(dir);
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-09-05 13:03:03 +00:00
|
|
|
WM_cursor_set(win, wmcursor);
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void node_draw_default(const bContext *C,
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region,
|
2013-03-18 16:34:57 +00:00
|
|
|
SpaceNode *snode,
|
|
|
|
bNodeTree *ntree,
|
|
|
|
bNode *node,
|
|
|
|
bNodeInstanceKey key)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2021-01-15 10:48:22 -06:00
|
|
|
const View2D *v2d = ®ion->v2d;
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->flag & NODE_HIDDEN) {
|
2021-01-15 10:48:22 -06:00
|
|
|
node_draw_hidden(C, v2d, snode, ntree, node, key);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else {
|
2021-01-15 10:48:22 -06:00
|
|
|
node_draw_basis(C, v2d, snode, ntree, node, key);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void node_update(const bContext *C, bNodeTree *ntree, bNode *node)
|
|
|
|
{
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->typeinfo->draw_nodetype_prepare) {
|
2013-10-10 11:33:20 +00:00
|
|
|
node->typeinfo->draw_nodetype_prepare(C, ntree, node);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void node_update_nodetree(const bContext *C, bNodeTree *ntree)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2015-01-14 11:14:21 +01:00
|
|
|
/* make sure socket "used" tags are correct, for displaying value buttons */
|
|
|
|
ntreeTagUsedSockets(ntree);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
/* update nodes front to back, so children sizes get updated before parents */
|
2020-09-08 17:19:58 +02:00
|
|
|
LISTBASE_FOREACH_BACKWARD (bNode *, node, &ntree->nodes) {
|
2011-09-05 21:01:50 +00:00
|
|
|
node_update(C, ntree, node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
static void node_draw(const bContext *C,
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region,
|
2013-03-18 16:34:57 +00:00
|
|
|
SpaceNode *snode,
|
|
|
|
bNodeTree *ntree,
|
|
|
|
bNode *node,
|
|
|
|
bNodeInstanceKey key)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->typeinfo->draw_nodetype) {
|
2020-03-06 16:56:42 +01:00
|
|
|
node->typeinfo->draw_nodetype(C, region, snode, ntree, node, key);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
2012-08-12 19:35:47 +00:00
|
|
|
#define USE_DRAW_TOT_UPDATE
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void node_draw_nodetree(const bContext *C,
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region,
|
2013-03-18 16:34:57 +00:00
|
|
|
SpaceNode *snode,
|
|
|
|
bNodeTree *ntree,
|
|
|
|
bNodeInstanceKey parent_key)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ntree == NULL) {
|
|
|
|
return; /* groups... */
|
|
|
|
}
|
2012-08-12 19:35:47 +00:00
|
|
|
|
|
|
|
#ifdef USE_DRAW_TOT_UPDATE
|
|
|
|
if (ntree->nodes.first) {
|
2020-03-06 16:56:42 +01:00
|
|
|
BLI_rctf_init_minmax(®ion->v2d.tot);
|
2012-08-12 19:35:47 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
/* draw background nodes, last nodes in front */
|
2021-01-15 10:48:22 -06:00
|
|
|
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
2012-08-12 19:35:47 +00:00
|
|
|
#ifdef USE_DRAW_TOT_UPDATE
|
|
|
|
/* unrelated to background nodes, update the v2d->tot,
|
|
|
|
* can be anywhere before we draw the scroll bars */
|
2020-03-06 16:56:42 +01:00
|
|
|
BLI_rctf_union(®ion->v2d.tot, &node->totr);
|
2012-08-12 19:35:47 +00:00
|
|
|
#endif
|
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!(node->flag & NODE_BACKGROUND)) {
|
2012-05-22 14:13:33 +00:00
|
|
|
continue;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-30 13:56:46 -05:00
|
|
|
bNodeInstanceKey key = BKE_node_instance_key(parent_key, ntree, node);
|
2020-03-06 16:56:42 +01:00
|
|
|
node_draw(C, region, snode, ntree, node, key);
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* node lines */
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2018-04-05 15:43:07 +02:00
|
|
|
nodelink_batch_start(snode);
|
2020-09-08 17:19:58 +02:00
|
|
|
LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!nodeLinkIsHidden(link)) {
|
2020-03-06 16:56:42 +01:00
|
|
|
node_draw_link(®ion->v2d, snode, link);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
2018-04-05 15:43:07 +02:00
|
|
|
nodelink_batch_end(snode);
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
/* draw foreground nodes, last nodes in front */
|
2021-01-15 10:48:22 -06:00
|
|
|
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->flag & NODE_BACKGROUND) {
|
2012-05-22 14:13:33 +00:00
|
|
|
continue;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-30 13:56:46 -05:00
|
|
|
bNodeInstanceKey key = BKE_node_instance_key(parent_key, ntree, node);
|
2020-03-06 16:56:42 +01:00
|
|
|
node_draw(C, region, snode, ntree, node, key);
|
2011-02-21 13:47:49 +00:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* draw tree path info in lower left corner */
|
|
|
|
static void draw_tree_path(SpaceNode *snode)
|
|
|
|
{
|
|
|
|
char info[256];
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
ED_node_tree_path_get_fixedbuf(snode, info, sizeof(info));
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2017-02-05 00:54:21 -05:00
|
|
|
UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
|
2013-04-24 23:09:29 +00:00
|
|
|
BLF_draw_default(1.5f * UI_UNIT_X, 1.5f * UI_UNIT_Y, 0.0f, info, sizeof(info));
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
static void snode_setup_v2d(SpaceNode *snode, ARegion *region, const float center[2])
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
2020-03-06 16:56:42 +01:00
|
|
|
View2D *v2d = ®ion->v2d;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* shift view to node tree center */
|
2014-04-21 18:46:52 +10:00
|
|
|
UI_view2d_center_set(v2d, center[0], center[1]);
|
2013-03-18 16:34:57 +00:00
|
|
|
UI_view2d_view_ortho(v2d);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* aspect+font, set each time */
|
2021-01-19 16:43:08 -06:00
|
|
|
snode->runtime->aspect = BLI_rctf_size_x(&v2d->cur) / (float)region->winx;
|
2013-03-18 16:34:57 +00:00
|
|
|
// XXX snode->curfont = uiSetCurFont_ext(snode->aspect);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_nodetree(const bContext *C,
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region,
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeTree *ntree,
|
|
|
|
bNodeInstanceKey parent_key)
|
|
|
|
{
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2017-05-15 13:47:48 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
node_uiblocks_init(C, ntree);
|
2017-05-15 13:47:48 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
node_update_nodetree(C, ntree);
|
2020-03-06 16:56:42 +01:00
|
|
|
node_draw_nodetree(C, region, snode, ntree, parent_key);
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* shade the parent node group and add a uiBlock to clip mouse events */
|
2020-03-06 16:56:42 +01:00
|
|
|
static void draw_group_overlay(const bContext *C, ARegion *region)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
2021-01-15 10:48:22 -06:00
|
|
|
const View2D *v2d = ®ion->v2d;
|
|
|
|
const rctf rect = v2d->cur;
|
2016-10-07 14:56:08 -04:00
|
|
|
float color[4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* shade node groups to separate them visually */
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-11 16:56:20 +01:00
|
|
|
UI_GetThemeColorShadeAlpha4fv(TH_NODE_GROUP, 0, 0, color);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_NONE);
|
2021-01-25 18:31:11 +11:00
|
|
|
UI_draw_roundbox_4fv(&rect, true, 0, color);
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* set the block bounds to clip mouse events from underlying nodes */
|
2020-11-30 13:56:46 -05:00
|
|
|
uiBlock *block = UI_block_begin(C, region, "node tree bounds block", UI_EMBOSS);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_bounds_set_explicit(block, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
|
|
|
UI_block_flag_enable(block, UI_BLOCK_CLIP_EVENTS);
|
|
|
|
UI_block_end(C, block);
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 11:41:13 +02:00
|
|
|
void node_draw_space(const bContext *C, ARegion *region)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2013-09-05 13:03:03 +00:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2012-07-09 19:58:36 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
View2D *v2d = ®ion->v2d;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-08-18 14:43:18 +02:00
|
|
|
/* Setup offscreen buffers. */
|
|
|
|
GPUViewport *viewport = WM_draw_region_get_viewport(region);
|
|
|
|
|
|
|
|
GPUFrameBuffer *framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport);
|
|
|
|
GPU_framebuffer_bind_no_srgb(framebuffer_overlay);
|
|
|
|
|
2020-08-18 16:04:41 +02:00
|
|
|
UI_view2d_view_ortho(v2d);
|
2010-04-06 07:02:16 +00:00
|
|
|
UI_ThemeClearColor(TH_BACK);
|
2020-08-20 16:38:34 +02:00
|
|
|
GPU_depth_test(GPU_DEPTH_NONE);
|
2020-08-23 11:11:27 +02:00
|
|
|
GPU_scissor_test(true);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-01-19 16:43:08 -06:00
|
|
|
/* XXX snode->runtime->cursor set in coordspace for placing new nodes, used for drawing noodles
|
|
|
|
* too */
|
2020-03-06 16:56:42 +01:00
|
|
|
UI_view2d_region_to_view(®ion->v2d,
|
|
|
|
win->eventstate->x - region->winrct.xmin,
|
|
|
|
win->eventstate->y - region->winrct.ymin,
|
2021-01-19 16:43:08 -06:00
|
|
|
&snode->runtime->cursor[0],
|
|
|
|
&snode->runtime->cursor[1]);
|
|
|
|
snode->runtime->cursor[0] /= UI_DPI_FAC;
|
|
|
|
snode->runtime->cursor[1] /= UI_DPI_FAC;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-02-28 14:07:21 +01:00
|
|
|
int grid_levels = UI_GetThemeValueType(TH_NODE_GRID_LEVELS, SPACE_NODE);
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* only set once */
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* nodes */
|
2013-03-18 16:34:57 +00:00
|
|
|
snode_set_context(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* draw parent node trees */
|
|
|
|
if (snode->treepath.last) {
|
|
|
|
static const int max_depth = 2;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-30 13:56:46 -05:00
|
|
|
bNodeTreePath *path = snode->treepath.last;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-25 01:59:49 +01:00
|
|
|
/* update tree path name (drawn in the bottom left) */
|
2016-08-30 12:32:31 +03:00
|
|
|
ID *name_id = (path->nodetree && path->nodetree != snode->nodetree) ? &path->nodetree->id :
|
|
|
|
snode->id;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-08-30 12:32:31 +03:00
|
|
|
if (name_id && UNLIKELY(!STREQ(path->node_name, name_id->name + 2))) {
|
|
|
|
BLI_strncpy(path->node_name, name_id->name + 2, sizeof(path->node_name));
|
2015-01-25 01:59:49 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* current View2D center, will be set temporarily for parent node trees */
|
2020-11-30 13:56:46 -05:00
|
|
|
float center[2];
|
2014-04-21 18:46:52 +10:00
|
|
|
UI_view2d_center_get(v2d, ¢er[0], ¢er[1]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-17 17:12:12 +00:00
|
|
|
/* store new view center in path and current edittree */
|
|
|
|
copy_v2_v2(path->view_center, center);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (snode->edittree) {
|
2013-03-18 16:34:57 +00:00
|
|
|
copy_v2_v2(snode->edittree->view_center, center);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-30 13:56:46 -05:00
|
|
|
int depth = 0;
|
2013-03-18 16:34:57 +00:00
|
|
|
while (path->prev && depth < max_depth) {
|
|
|
|
path = path->prev;
|
2019-09-08 00:12:26 +10:00
|
|
|
depth++;
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* parent node trees in the background */
|
2020-11-30 13:56:46 -05:00
|
|
|
for (int curdepth = depth; curdepth > 0; path = path->next, curdepth--) {
|
|
|
|
bNodeTree *ntree = path->nodetree;
|
2013-03-19 13:40:16 +00:00
|
|
|
if (ntree) {
|
2020-03-06 16:56:42 +01:00
|
|
|
snode_setup_v2d(snode, region, path->view_center);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
draw_nodetree(C, region, ntree, path->parent_key);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
draw_group_overlay(C, region);
|
2010-03-29 07:15:12 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2013-04-17 17:12:12 +00:00
|
|
|
/* top-level edit tree */
|
2020-11-30 13:56:46 -05:00
|
|
|
bNodeTree *ntree = path->nodetree;
|
2013-04-17 17:12:12 +00:00
|
|
|
if (ntree) {
|
2020-03-06 16:56:42 +01:00
|
|
|
snode_setup_v2d(snode, region, center);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-17 17:12:12 +00:00
|
|
|
/* grid, uses theme color based on node path depth */
|
2020-02-28 14:07:21 +01:00
|
|
|
UI_view2d_multi_grid_draw(v2d,
|
2020-09-15 18:42:38 -05:00
|
|
|
(depth > 0 ? TH_NODE_GROUP : TH_GRID),
|
2020-02-28 14:07:21 +01:00
|
|
|
ED_node_grid_size(),
|
|
|
|
NODE_GRID_STEPS,
|
|
|
|
grid_levels);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-17 17:12:12 +00:00
|
|
|
/* backdrop */
|
2020-03-06 16:56:42 +01:00
|
|
|
draw_nodespace_back_pix(C, region, snode, path->parent_key);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-29 22:06:59 +10:00
|
|
|
{
|
|
|
|
float original_proj[4][4];
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_projection_get(original_proj);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_push();
|
|
|
|
GPU_matrix_identity_set();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
wmOrtho2_pixelspace(region->winx, region->winy);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
WM_gizmomap_draw(region->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_pop();
|
|
|
|
GPU_matrix_projection_set(original_proj);
|
2017-05-29 22:06:59 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
draw_nodetree(C, region, ntree, path->parent_key);
|
2013-04-17 17:12:12 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* temporary links */
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_smooth(true);
|
2021-01-19 16:43:08 -06:00
|
|
|
LISTBASE_FOREACH (bNodeLinkDrag *, nldrag, &snode->runtime->linkdrag) {
|
2020-11-30 13:56:46 -05:00
|
|
|
LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
|
2013-03-18 16:34:57 +00:00
|
|
|
node_draw_link(v2d, snode, (bNodeLink *)linkdata->data);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_smooth(false);
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (snode->flag & SNODE_SHOW_GPENCIL) {
|
|
|
|
/* draw grease-pencil ('canvas' strokes) */
|
2019-03-19 11:01:27 +01:00
|
|
|
ED_annotation_draw_view2d(C, true);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
else {
|
|
|
|
/* default grid */
|
2020-09-15 18:42:38 -05:00
|
|
|
UI_view2d_multi_grid_draw(v2d, TH_GRID, ED_node_grid_size(), NODE_GRID_STEPS, grid_levels);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* backdrop */
|
2020-03-06 16:56:42 +01:00
|
|
|
draw_nodespace_back_pix(C, region, snode, NODE_INSTANCE_KEY_NONE);
|
2012-05-15 12:40:43 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_VIEW);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* reset view matrix */
|
|
|
|
UI_view2d_view_restore(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (snode->treepath.last) {
|
|
|
|
if (snode->flag & SNODE_SHOW_GPENCIL) {
|
2021-02-05 16:23:34 +11:00
|
|
|
/* Draw grease-pencil (screen strokes, and also paint-buffer). */
|
2019-03-19 11:01:27 +01:00
|
|
|
ED_annotation_draw_view2d(C, false);
|
2012-12-17 02:34:53 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* tree path info */
|
|
|
|
draw_tree_path(snode);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* scrollers */
|
2020-06-22 21:44:18 +02:00
|
|
|
UI_view2d_scrollers_draw(v2d, NULL);
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|