2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2008 Blender Foundation. All rights reserved. */
|
2008-12-24 10:33:10 +00:00
|
|
|
|
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
|
|
|
*/
|
|
|
|
|
|
2021-12-06 16:50:44 -05:00
|
|
|
#include <iomanip>
|
|
|
|
|
|
2021-02-11 01:16:17 -06:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
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"
|
2021-12-05 17:12:25 -05:00
|
|
|
#include "DNA_text_types.h"
|
2013-03-18 16:34:57 +00:00
|
|
|
#include "DNA_texture_types.h"
|
|
|
|
|
#include "DNA_world_types.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
#include "BLI_array.hh"
|
2021-02-16 17:15:08 -06:00
|
|
|
#include "BLI_map.hh"
|
2021-03-11 18:53:29 +01:00
|
|
|
#include "BLI_set.hh"
|
2021-02-16 17:15:08 -06:00
|
|
|
#include "BLI_span.hh"
|
|
|
|
|
#include "BLI_string_ref.hh"
|
|
|
|
|
#include "BLI_vector.hh"
|
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"
|
2021-07-14 11:16:43 +02:00
|
|
|
#include "BKE_idtype.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"
|
2021-02-16 17:15:08 -06:00
|
|
|
#include "BKE_object.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"
|
2021-10-26 11:05:01 -05:00
|
|
|
#include "ED_screen.h"
|
2012-06-29 14:34:46 +00:00
|
|
|
#include "ED_space_api.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2021-10-26 11:05:01 -05:00
|
|
|
#include "UI_interface.hh"
|
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"
|
2022-03-14 16:54:46 +01:00
|
|
|
#include "RNA_prototypes.h"
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2021-07-07 11:20:19 +02:00
|
|
|
#include "NOD_geometry_nodes_eval_log.hh"
|
2021-09-24 17:02:51 +02:00
|
|
|
#include "NOD_node_declaration.hh"
|
2022-06-03 09:57:37 +02:00
|
|
|
#include "NOD_socket_declarations_geometry.hh"
|
2021-07-07 11:20:19 +02:00
|
|
|
|
2022-04-01 08:40:45 -05:00
|
|
|
#include "FN_field.hh"
|
2021-09-11 13:05:20 +02:00
|
|
|
#include "FN_field_cpp_type.hh"
|
|
|
|
|
|
2021-11-12 12:12:27 -06:00
|
|
|
#include "node_intern.hh" /* own include */
|
2014-11-28 15:50:43 +01:00
|
|
|
|
2022-03-19 08:26:29 +01:00
|
|
|
using blender::GPointer;
|
2021-09-11 13:05:20 +02:00
|
|
|
using blender::fn::GField;
|
2021-07-07 11:20:19 +02:00
|
|
|
namespace geo_log = blender::nodes::geometry_nodes_eval_log;
|
2022-06-01 14:38:06 +10:00
|
|
|
using geo_log::eNamedAttrUsage;
|
2021-02-16 17:15:08 -06:00
|
|
|
|
2021-02-16 10:55:10 -06:00
|
|
|
extern "C" {
|
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);
|
2021-02-16 10:55:10 -06:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2021-12-08 00:31:20 -05:00
|
|
|
float ED_node_grid_size()
|
2013-11-06 17:46:32 +00:00
|
|
|
{
|
|
|
|
|
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
|
|
|
{
|
2022-01-20 10:36:56 -06:00
|
|
|
using namespace blender::ed::space_node;
|
|
|
|
|
|
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) {
|
2021-12-03 16:25:17 -05:00
|
|
|
snode_set_context(*C);
|
2013-04-24 20:19:01 +00:00
|
|
|
|
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
|
|
|
|
2021-02-16 10:55:10 -06:00
|
|
|
return nullptr;
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
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);
|
2021-02-16 10:55:10 -06:00
|
|
|
if (id == nullptr || ntree == nullptr) {
|
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
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* TODO(sergey): With the new dependency graph it should be just enough to only tag ntree itself.
|
|
|
|
|
* 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) {
|
2021-02-17 13:34:49 -06: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
|
|
|
}
|
|
|
|
|
|
2022-01-20 10:36:56 -06:00
|
|
|
namespace blender::ed::space_node {
|
|
|
|
|
|
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.
|
2021-02-17 13:34:49 -06:00
|
|
|
* 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
|
|
|
|
2021-02-17 13:34:49 -06: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,
|
2021-02-17 13:34:49 -06:00
|
|
|
* this is O(n^2) worst case. */
|
2020-09-08 17:19:58 +02:00
|
|
|
for (bNode *parent = a->parent; parent; parent = parent->parent) {
|
2021-02-17 13:34:49 -06: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
|
|
|
}
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Any selected ancestor moves the node forward. */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (parent->flag & NODE_ACTIVE) {
|
2021-02-16 10:55:10 -06:00
|
|
|
a_active = true;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
|
if (parent->flag & NODE_SELECT) {
|
2021-02-16 10:55:10 -06:00
|
|
|
a_select = true;
|
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) {
|
2021-02-17 13:34:49 -06: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
|
|
|
}
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Any selected ancestor moves the node forward. */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (parent->flag & NODE_ACTIVE) {
|
2021-02-16 10:55:10 -06:00
|
|
|
b_active = true;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
|
if (parent->flag & NODE_SELECT) {
|
2021-02-16 10:55:10 -06:00
|
|
|
b_select = true;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* 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
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
|
2022-01-18 13:32:36 -06:00
|
|
|
void node_sort(bNodeTree &ntree)
|
2012-05-22 14:13:33 +00:00
|
|
|
{
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Merge sort is the algorithm of choice here. */
|
2022-01-18 13:32:36 -06: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) {
|
2022-01-18 13:32:36 -06:00
|
|
|
bNode *first_a = (bNode *)ntree.nodes.first;
|
2020-09-08 17:19:58 +02:00
|
|
|
bNode *first_b = first_a;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
do {
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Set up 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;
|
|
|
|
|
}
|
2021-02-17 13:34:49 -06:00
|
|
|
/* All batches merged? */
|
2021-02-16 10:55:10 -06:00
|
|
|
if (first_b == nullptr) {
|
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
|
|
|
|
2021-02-17 13:34:49 -06: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++;
|
2022-01-18 13:32:36 -06:00
|
|
|
BLI_remlink(&ntree.nodes, tmp);
|
|
|
|
|
BLI_insertlinkbefore(&ntree.nodes, node_a, tmp);
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Set up first pointers for next batch. */
|
2012-05-22 14:13:33 +00:00
|
|
|
first_b = node_b;
|
2019-09-08 00:12:26 +10:00
|
|
|
for (; b < k; b++) {
|
2021-02-17 13:34:49 -06:00
|
|
|
/* All nodes sorted? */
|
2021-02-16 10:55:10 -06:00
|
|
|
if (first_b == nullptr) {
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
static Array<uiBlock *> node_uiblocks_init(const bContext &C, Span<bNode *> nodes)
|
2010-01-12 07:07:51 +00:00
|
|
|
{
|
2021-12-14 11:19:47 -06:00
|
|
|
Array<uiBlock *> blocks(nodes.size());
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Add node uiBlocks in drawing order - prevents events going to overlapping nodes. */
|
2021-12-14 11:19:47 -06:00
|
|
|
for (const int i : nodes.index_range()) {
|
|
|
|
|
const std::string block_name = "node_" + std::string(nodes[i]->name);
|
|
|
|
|
blocks[i] = UI_block_begin(&C, CTX_wm_region(&C), block_name.c_str(), UI_EMBOSS);
|
2012-01-11 09:33:44 +00:00
|
|
|
/* this cancels events for background nodes */
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_flag_enable(blocks[i], UI_BLOCK_CLIP_EVENTS);
|
2010-01-12 07:07:51 +00:00
|
|
|
}
|
2021-12-14 11:19:47 -06:00
|
|
|
|
|
|
|
|
return blocks;
|
2010-01-12 07:07:51 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-08 09:44:02 -05:00
|
|
|
float2 node_to_view(const bNode &node, const float2 &co)
|
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
|
|
|
{
|
2021-12-08 09:44:02 -05:00
|
|
|
float2 result;
|
|
|
|
|
nodeToView(&node, co.x, co.y, &result.x, &result.y);
|
|
|
|
|
return result * UI_DPI_FAC;
|
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
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
void node_to_updated_rect(const bNode &node, rctf &r_rect)
|
2015-08-01 16:16:16 +02:00
|
|
|
{
|
2021-12-08 09:44:02 -05:00
|
|
|
const float2 xmin_ymax = node_to_view(node, {node.offsetx, node.offsety});
|
|
|
|
|
r_rect.xmin = xmin_ymax.x;
|
|
|
|
|
r_rect.ymax = xmin_ymax.y;
|
|
|
|
|
const float2 xmax_ymin = node_to_view(node,
|
|
|
|
|
{node.offsetx + node.width, node.offsety - node.height});
|
|
|
|
|
r_rect.xmax = xmax_ymin.x;
|
|
|
|
|
r_rect.ymin = xmax_ymin.y;
|
2015-08-01 16:16:16 +02:00
|
|
|
}
|
|
|
|
|
|
2021-12-08 09:44:02 -05:00
|
|
|
float2 node_from_view(const bNode &node, const float2 &co)
|
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
|
|
|
{
|
2021-12-08 09:44:02 -05:00
|
|
|
const float x = co.x / UI_DPI_FAC;
|
|
|
|
|
const float y = co.y / UI_DPI_FAC;
|
|
|
|
|
float2 result;
|
|
|
|
|
nodeFromView(&node, x, y, &result.x, &result.y);
|
|
|
|
|
return result;
|
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
|
|
|
}
|
|
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/**
|
|
|
|
|
* Based on settings and sockets in node, set drawing rect info.
|
|
|
|
|
*/
|
2021-12-14 11:19:47 -06:00
|
|
|
static void node_update_basis(const bContext &C, bNodeTree &ntree, bNode &node, uiBlock &block)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2020-09-08 17:19:58 +02:00
|
|
|
PointerRNA nodeptr;
|
2021-12-03 16:25:17 -05:00
|
|
|
RNA_pointer_create(&ntree.id, &RNA_Node, &node, &nodeptr);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-12-17 08:03:47 -06:00
|
|
|
const bool node_options = node.typeinfo->draw_buttons && (node.flag & NODE_OPTIONS);
|
|
|
|
|
const bool inputs_first = node.inputs.first &&
|
|
|
|
|
!(node.outputs.first || (node.flag & NODE_PREVIEW) || node_options);
|
|
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Get "global" coordinates. */
|
2021-12-08 09:44:02 -05:00
|
|
|
float2 loc = node_to_view(node, float2(0));
|
2021-08-27 11:25:30 -07:00
|
|
|
/* Round the node origin because text contents are always pixel-aligned. */
|
2021-12-08 09:44:02 -05:00
|
|
|
loc.x = round(loc.x);
|
|
|
|
|
loc.y = round(loc.y);
|
2021-08-27 11:25:30 -07:00
|
|
|
|
2021-12-08 09:44:02 -05:00
|
|
|
int dy = loc.y;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Header. */
|
2013-03-18 16:34:57 +00:00
|
|
|
dy -= NODE_DY;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-01 22:04:44 -05:00
|
|
|
/* Add a little bit of padding above the top socket. */
|
2021-12-17 08:03:47 -06:00
|
|
|
if (node.outputs.first || inputs_first) {
|
2013-03-18 16:34:57 +00:00
|
|
|
dy -= NODE_DYS / 2;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Output sockets. */
|
2013-03-18 16:34:57 +00:00
|
|
|
bool add_output_space = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-08 17:19:58 +02:00
|
|
|
int buty;
|
2021-12-03 16:25:17 -05:00
|
|
|
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;
|
2021-12-03 16:25:17 -05:00
|
|
|
RNA_pointer_create(&ntree.id, &RNA_NodeSocket, nsock, &sockptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
uiLayout *layout = UI_block_layout(&block,
|
2020-12-14 17:48:57 -06:00
|
|
|
UI_LAYOUT_VERTICAL,
|
|
|
|
|
UI_LAYOUT_PANEL,
|
2021-12-08 09:44:02 -05:00
|
|
|
loc.x + NODE_DYS,
|
2020-12-14 17:48:57 -06:00
|
|
|
dy,
|
|
|
|
|
NODE_WIDTH(node) - NODE_DY,
|
|
|
|
|
NODE_DY,
|
|
|
|
|
0,
|
|
|
|
|
UI_style_get_dpi());
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-03 16:25:17 -05: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
|
|
|
}
|
|
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Context pointers for current node and socket. */
|
2019-03-26 21:16:47 +11:00
|
|
|
uiLayoutSetContextPointer(layout, "node", &nodeptr);
|
2013-03-18 16:34:57 +00:00
|
|
|
uiLayoutSetContextPointer(layout, "socket", &sockptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06: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);
|
2021-12-03 16:25:17 -05:00
|
|
|
nsock->typeinfo->draw((bContext *)&C, row, &sockptr, &nodeptr, IFACE_(socket_label));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
UI: Add support for showing socket descriptions in tooltips
Currently, hovering over a socket itself shows no tooltip at all, while
hovering over its value field shows "Default value", which is not helpful.
This patch therefore implements socket tooltips following the proposal at
https://blender.community/c/rightclickselect/2Qgbbc/.
A lot of the basic functionality was already implemented for Geometry Nodes,
where hovering over the socket itself shows introspection info.
This patch extends this by:
- Supporting dynamic tooltips on labels, which is important for good tooltip
coverage in a socket's region of the node.
- Adding a function to setting a dynamic tooltip for an entire uiLayout, which
avoids needing to set it manually for a wide variety of socket types.
- Hiding the property label field in a tooltip when dynamic tooltip is also
provided. If really needed, this label can be restored through the dynamic
tooltip, but in all current cases the label is actually pointless anyways
since the dynamic tooltip gives more accurate and specific information.
- Adding dynamic tooltips to a socket's UI layout row if it has a description
configured, both in the Node Editor as well as in the Material Properties.
Note that the patch does not add any actual tooltip content yet, just the
infrastructure to show them. By default, sockets without a description still
show the old "Default value" tooltip.
For an example of how to add socket descriptions, check the Cylinder node
in the Geometry Nodes.
Differential Revision: https://developer.blender.org/D9967
2022-04-11 02:02:12 +02:00
|
|
|
node_socket_add_tooltip(&ntree, &node, nsock, row);
|
|
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_align_end(&block);
|
|
|
|
|
UI_block_layout_resolve(&block, nullptr, &buty);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06: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
|
|
|
|
2021-08-27 11:25:30 -07:00
|
|
|
/* Round the socket location to stop it from jiggling. */
|
2021-12-08 09:44:02 -05:00
|
|
|
nsock->locx = round(loc.x + NODE_WIDTH(node));
|
2022-02-08 14:55:02 +11:00
|
|
|
nsock->locy = round(dy - NODE_DYS);
|
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
|
|
|
}
|
|
|
|
|
|
2021-12-08 09:44:02 -05:00
|
|
|
node.prvr.xmin = loc.x + NODE_DYS;
|
|
|
|
|
node.prvr.xmax = loc.x + NODE_WIDTH(node) - NODE_DYS;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* preview rect? */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & NODE_PREVIEW) {
|
2019-03-28 17:39:54 +01:00
|
|
|
float aspect = 1.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.preview_xsize && node.preview_ysize) {
|
|
|
|
|
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;
|
2021-12-03 16:25:17 -05:00
|
|
|
node.prvr.ymax = dy;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-07-09 19:58:36 +00:00
|
|
|
if (aspect <= 1.0f) {
|
2021-12-03 16:25:17 -05:00
|
|
|
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 {
|
2021-02-17 13:34:49 -06:00
|
|
|
/* 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
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
node.prvr.ymin = dy - (NODE_WIDTH(node) - NODE_DY);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
node.prvr.xmin += 0.5f * dx;
|
|
|
|
|
node.prvr.xmax -= 0.5f * dx;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
dy = node.prvr.ymin - NODE_DYS / 2;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Make sure that maximums are bigger or equal to minimums. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.prvr.xmax < node.prvr.xmin) {
|
|
|
|
|
SWAP(float, node.prvr.xmax, node.prvr.xmin);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.prvr.ymax < node.prvr.ymin) {
|
|
|
|
|
SWAP(float, node.prvr.ymax, node.prvr.ymin);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Buttons rect? */
|
2021-12-17 08:03:47 -06:00
|
|
|
if (node_options) {
|
2012-07-09 19:58:36 +00:00
|
|
|
dy -= NODE_DYS / 2;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
uiLayout *layout = UI_block_layout(&block,
|
2020-12-14 17:48:57 -06:00
|
|
|
UI_LAYOUT_VERTICAL,
|
|
|
|
|
UI_LAYOUT_PANEL,
|
2021-12-08 09:44:02 -05:00
|
|
|
loc.x + NODE_DYS,
|
2020-12-14 17:48:57 -06:00
|
|
|
dy,
|
2021-12-10 13:52:02 -06:00
|
|
|
NODE_WIDTH(node) - NODE_DY,
|
2020-12-14 17:48:57 -06:00
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
UI_style_get_dpi());
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-03 16:25:17 -05: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
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
uiLayoutSetContextPointer(layout, "node", &nodeptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
node.typeinfo->draw_buttons(layout, (bContext *)&C, &nodeptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_align_end(&block);
|
|
|
|
|
UI_block_layout_resolve(&block, nullptr, &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
|
|
|
}
|
|
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Input sockets. */
|
2021-12-03 16:25:17 -05: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;
|
2021-12-03 16:25:17 -05:00
|
|
|
RNA_pointer_create(&ntree.id, &RNA_NodeSocket, nsock, &sockptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-11 01:16:17 -06:00
|
|
|
/* Add the half the height of a multi-input socket to cursor Y
|
|
|
|
|
* to account for the increased height of the taller sockets. */
|
|
|
|
|
float multi_input_socket_offset = 0.0f;
|
|
|
|
|
if (nsock->flag & SOCK_MULTI_INPUT) {
|
|
|
|
|
if (nsock->total_inputs > 2) {
|
|
|
|
|
multi_input_socket_offset = (nsock->total_inputs - 2) * NODE_MULTI_INPUT_LINK_GAP;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dy -= multi_input_socket_offset * 0.5f;
|
|
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
uiLayout *layout = UI_block_layout(&block,
|
2020-12-14 17:48:57 -06:00
|
|
|
UI_LAYOUT_VERTICAL,
|
|
|
|
|
UI_LAYOUT_PANEL,
|
2021-12-08 09:44:02 -05:00
|
|
|
loc.x + NODE_DYS,
|
2020-12-14 17:48:57 -06:00
|
|
|
dy,
|
|
|
|
|
NODE_WIDTH(node) - NODE_DY,
|
|
|
|
|
NODE_DY,
|
|
|
|
|
0,
|
|
|
|
|
UI_style_get_dpi());
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-03 16:25:17 -05: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
|
|
|
}
|
|
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Context pointers for current node and socket. */
|
2013-03-18 16:34:57 +00:00
|
|
|
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);
|
2021-12-03 16:25:17 -05:00
|
|
|
nsock->typeinfo->draw((bContext *)&C, row, &sockptr, &nodeptr, IFACE_(socket_label));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
UI: Add support for showing socket descriptions in tooltips
Currently, hovering over a socket itself shows no tooltip at all, while
hovering over its value field shows "Default value", which is not helpful.
This patch therefore implements socket tooltips following the proposal at
https://blender.community/c/rightclickselect/2Qgbbc/.
A lot of the basic functionality was already implemented for Geometry Nodes,
where hovering over the socket itself shows introspection info.
This patch extends this by:
- Supporting dynamic tooltips on labels, which is important for good tooltip
coverage in a socket's region of the node.
- Adding a function to setting a dynamic tooltip for an entire uiLayout, which
avoids needing to set it manually for a wide variety of socket types.
- Hiding the property label field in a tooltip when dynamic tooltip is also
provided. If really needed, this label can be restored through the dynamic
tooltip, but in all current cases the label is actually pointless anyways
since the dynamic tooltip gives more accurate and specific information.
- Adding dynamic tooltips to a socket's UI layout row if it has a description
configured, both in the Node Editor as well as in the Material Properties.
Note that the patch does not add any actual tooltip content yet, just the
infrastructure to show them. By default, sockets without a description still
show the old "Default value" tooltip.
For an example of how to add socket descriptions, check the Cylinder node
in the Geometry Nodes.
Differential Revision: https://developer.blender.org/D9967
2022-04-11 02:02:12 +02:00
|
|
|
node_socket_add_tooltip(&ntree, &node, nsock, row);
|
|
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_align_end(&block);
|
|
|
|
|
UI_block_layout_resolve(&block, nullptr, &buty);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Ensure minimum socket height in case layout is empty. */
|
2013-03-18 16:34:57 +00:00
|
|
|
buty = min_ii(buty, dy - NODE_DY);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-08 09:44:02 -05:00
|
|
|
nsock->locx = loc.x;
|
2021-08-27 11:25:30 -07:00
|
|
|
/* Round the socket vertical position to stop it from jiggling. */
|
2022-02-08 14:55:02 +11:00
|
|
|
nsock->locy = round(dy - NODE_DYS);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-11 01:16:17 -06:00
|
|
|
dy = buty - multi_input_socket_offset * 0.5;
|
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
|
|
|
}
|
|
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Little bit of space in end. */
|
2021-12-03 16:25:17 -05: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
|
|
|
|
2021-12-08 09:44:02 -05:00
|
|
|
node.totr.xmin = loc.x;
|
|
|
|
|
node.totr.xmax = loc.x + NODE_WIDTH(node);
|
|
|
|
|
node.totr.ymax = loc.y;
|
|
|
|
|
node.totr.ymin = min_ff(dy, loc.y - 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.
|
2021-02-17 13:34:49 -06:00
|
|
|
* Add a margin for sockets on each side. */
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_bounds_set_explicit(&block,
|
2021-12-03 16:25:17 -05:00
|
|
|
node.totr.xmin - NODE_SOCKSIZE,
|
|
|
|
|
node.totr.ymin,
|
|
|
|
|
node.totr.xmax + NODE_SOCKSIZE,
|
|
|
|
|
node.totr.ymax);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/**
|
|
|
|
|
* Based on settings in node, sets drawing rect info.
|
|
|
|
|
*/
|
2021-12-14 11:19:47 -06:00
|
|
|
static void node_update_hidden(bNode &node, uiBlock &block)
|
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
|
|
|
|
2021-12-08 09:44:02 -05:00
|
|
|
/* Get "global" coordinates. */
|
|
|
|
|
float2 loc = node_to_view(node, float2(0));
|
2021-08-27 11:25:30 -07:00
|
|
|
/* Round the node origin because text contents are always pixel-aligned. */
|
2021-12-08 09:44:02 -05:00
|
|
|
loc.x = round(loc.x);
|
|
|
|
|
loc.y = round(loc.y);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Calculate minimal radius. */
|
2021-12-03 16:25:17 -05: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
|
|
|
}
|
|
|
|
|
}
|
2021-12-03 16:25:17 -05: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
|
|
|
|
2021-12-08 09:44:02 -05:00
|
|
|
node.totr.xmin = loc.x;
|
|
|
|
|
node.totr.xmax = loc.x + max_ff(NODE_WIDTH(node), 2 * hiddenrad);
|
|
|
|
|
node.totr.ymax = loc.y + (hiddenrad - 0.5f * NODE_DY);
|
2021-12-03 16:25:17 -05:00
|
|
|
node.totr.ymin = node.totr.ymax - 2 * hiddenrad;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06: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
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
LISTBASE_FOREACH (bNodeSocket *, nsock, &node.outputs) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!nodeSocketIsHidden(nsock)) {
|
2021-08-27 11:25:30 -07:00
|
|
|
/* Round the socket location to stop it from jiggling. */
|
2021-12-03 16:25:17 -05:00
|
|
|
nsock->locx = round(node.totr.xmax - hiddenrad + sinf(rad) * hiddenrad);
|
|
|
|
|
nsock->locy = round(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
|
|
|
}
|
|
|
|
|
|
2021-02-17 13:34:49 -06: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
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
LISTBASE_FOREACH (bNodeSocket *, nsock, &node.inputs) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!nodeSocketIsHidden(nsock)) {
|
2021-08-27 11:25:30 -07:00
|
|
|
/* Round the socket location to stop it from jiggling. */
|
2021-12-03 16:25:17 -05:00
|
|
|
nsock->locx = round(node.totr.xmin + hiddenrad + sinf(rad) * hiddenrad);
|
|
|
|
|
nsock->locy = round(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.
|
2021-02-17 13:34:49 -06:00
|
|
|
* Add a margin for sockets on each side. */
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_bounds_set_explicit(&block,
|
2021-12-03 16:25:17 -05:00
|
|
|
node.totr.xmin - NODE_SOCKSIZE,
|
|
|
|
|
node.totr.ymin,
|
|
|
|
|
node.totr.xmax + NODE_SOCKSIZE,
|
|
|
|
|
node.totr.ymax);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-11 09:51:53 -06:00
|
|
|
static int node_get_colorid(const bNode &node)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2022-02-07 15:29:16 +00:00
|
|
|
const int nclass = (node.typeinfo->ui_class == nullptr) ? node.typeinfo->nclass :
|
|
|
|
|
node.typeinfo->ui_class(&node);
|
|
|
|
|
switch (nclass) {
|
2013-12-01 21:30:04 +01:00
|
|
|
case NODE_CLASS_INPUT:
|
|
|
|
|
return TH_NODE_INPUT;
|
|
|
|
|
case NODE_CLASS_OUTPUT:
|
2021-12-03 16:25:17 -05:00
|
|
|
return (node.flag & NODE_DO_OUTPUT) ? TH_NODE_OUTPUT : TH_NODE;
|
2021-08-23 16:23:58 +02:00
|
|
|
case NODE_CLASS_CONVERTER:
|
|
|
|
|
return TH_NODE_CONVERTER;
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
static void node_draw_mute_line(const bContext &C,
|
|
|
|
|
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-12-03 16:25:17 -05:00
|
|
|
LISTBASE_FOREACH (const bNodeLink *, link, &node.internal_links) {
|
2022-08-23 10:35:38 +02:00
|
|
|
if (!nodeLinkIsHidden(link)) {
|
|
|
|
|
node_draw_link_bezier(C, v2d, snode, *link, TH_WIRE_INNER, TH_WIRE_INNER, TH_WIRE, false);
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
static void node_socket_draw(const bNodeSocket &sock,
|
2020-04-16 15:09:49 +02:00
|
|
|
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
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Set shape flags. */
|
2021-12-03 16:25:17 -05:00
|
|
|
switch (sock.display_shape) {
|
2019-08-22 11:10:11 +02:00
|
|
|
case SOCK_DISPLAY_SHAPE_DIAMOND:
|
|
|
|
|
case SOCK_DISPLAY_SHAPE_DIAMOND_DOT:
|
2021-09-23 15:53:38 +02:00
|
|
|
flags = GPU_KEYFRAME_SHAPE_DIAMOND;
|
2019-08-22 11:10:11 +02:00
|
|
|
break;
|
|
|
|
|
case SOCK_DISPLAY_SHAPE_SQUARE:
|
|
|
|
|
case SOCK_DISPLAY_SHAPE_SQUARE_DOT:
|
2021-09-23 15:53:38 +02:00
|
|
|
flags = GPU_KEYFRAME_SHAPE_SQUARE;
|
2019-08-22 11:10:11 +02:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
case SOCK_DISPLAY_SHAPE_CIRCLE:
|
|
|
|
|
case SOCK_DISPLAY_SHAPE_CIRCLE_DOT:
|
2021-09-23 15:53:38 +02:00
|
|
|
flags = GPU_KEYFRAME_SHAPE_CIRCLE;
|
2019-08-22 11:10:11 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
if (ELEM(sock.display_shape,
|
2019-08-22 11:10:11 +02:00
|
|
|
SOCK_DISPLAY_SHAPE_DIAMOND_DOT,
|
|
|
|
|
SOCK_DISPLAY_SHAPE_SQUARE_DOT,
|
|
|
|
|
SOCK_DISPLAY_SHAPE_CIRCLE_DOT)) {
|
2021-09-23 15:53:38 +02:00
|
|
|
flags |= GPU_KEYFRAME_SHAPE_INNER_DOT;
|
2019-08-22 11:10:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 01:16:17 -06:00
|
|
|
static void node_socket_draw_multi_input(const float color[4],
|
|
|
|
|
const float color_outline[4],
|
|
|
|
|
const float width,
|
|
|
|
|
const float height,
|
|
|
|
|
const int locx,
|
|
|
|
|
const int locy)
|
|
|
|
|
{
|
2022-02-28 18:05:12 -05:00
|
|
|
/* The other sockets are drawn with the keyframe shader. There, the outline has a base thickness
|
|
|
|
|
* that can be varied but always scales with the size the socket is drawn at. Using `U.dpi_fac`
|
2022-03-10 11:32:48 +11:00
|
|
|
* has the same effect here. It scales the outline correctly across different screen DPI's
|
2022-02-28 18:05:12 -05:00
|
|
|
* and UI scales without being affected by the 'line-width'. */
|
|
|
|
|
const float outline_width = NODE_SOCK_OUTLINE_SCALE * U.dpi_fac;
|
|
|
|
|
|
2021-02-11 01:16:17 -06:00
|
|
|
/* UI_draw_roundbox draws the outline on the outer side, so compensate for the outline width. */
|
|
|
|
|
const rctf rect = {
|
2021-02-16 12:02:45 -06:00
|
|
|
locx - width + outline_width * 0.5f,
|
|
|
|
|
locx + width - outline_width * 0.5f,
|
|
|
|
|
locy - height + outline_width * 0.5f,
|
|
|
|
|
locy + height - outline_width * 0.5f,
|
2021-02-11 01:16:17 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
|
|
|
|
UI_draw_roundbox_4fv_ex(
|
2021-02-16 10:55:10 -06:00
|
|
|
&rect, color, nullptr, 1.0f, color_outline, outline_width, width - outline_width * 0.5f);
|
2021-02-11 01:16:17 -06:00
|
|
|
}
|
|
|
|
|
|
2021-02-24 13:01:24 -06:00
|
|
|
static const float virtual_node_socket_outline_color[4] = {0.5, 0.5, 0.5, 1.0};
|
|
|
|
|
|
|
|
|
|
static void node_socket_outline_color_get(const bool selected,
|
|
|
|
|
const int socket_type,
|
|
|
|
|
float r_outline_color[4])
|
2020-04-16 15:09:49 +02:00
|
|
|
{
|
|
|
|
|
if (selected) {
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
UI_GetThemeColor4fv(TH_ACTIVE, r_outline_color);
|
2020-04-16 15:09:49 +02:00
|
|
|
}
|
2022-06-23 12:22:23 -05:00
|
|
|
else if (socket_type == SOCK_CUSTOM) {
|
|
|
|
|
/* Until there is a better place for per socket color,
|
|
|
|
|
* the outline color for virtual sockets is set here. */
|
|
|
|
|
copy_v4_v4(r_outline_color, virtual_node_socket_outline_color);
|
|
|
|
|
}
|
2020-04-16 15:09:49 +02:00
|
|
|
else {
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
UI_GetThemeColor4fv(TH_WIRE, r_outline_color);
|
2022-09-01 19:46:19 +02:00
|
|
|
r_outline_color[3] = 1.0f;
|
2020-04-16 15:09:49 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
void node_socket_color_get(const bContext &C,
|
|
|
|
|
const bNodeTree &ntree,
|
|
|
|
|
PointerRNA &node_ptr,
|
|
|
|
|
const bNodeSocket &sock,
|
|
|
|
|
float r_color[4])
|
2020-04-16 15:09:49 +02:00
|
|
|
{
|
|
|
|
|
PointerRNA ptr;
|
2021-12-03 16:25:17 -05:00
|
|
|
BLI_assert(RNA_struct_is_a(node_ptr.type, &RNA_Node));
|
|
|
|
|
RNA_pointer_create((ID *)&ntree, &RNA_NodeSocket, &const_cast<bNodeSocket &>(sock), &ptr);
|
2020-04-16 15:09:49 +02:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
sock.typeinfo->draw_color((bContext *)&C, &ptr, &node_ptr, r_color);
|
2020-04-16 15:09:49 +02:00
|
|
|
}
|
|
|
|
|
|
2021-07-14 11:16:43 +02:00
|
|
|
struct SocketTooltipData {
|
|
|
|
|
bNodeTree *ntree;
|
|
|
|
|
bNode *node;
|
|
|
|
|
bNodeSocket *socket;
|
|
|
|
|
};
|
|
|
|
|
|
2021-11-23 14:47:25 +01:00
|
|
|
static void create_inspection_string_for_generic_value(const GPointer value, std::stringstream &ss)
|
2021-07-14 11:16:43 +02:00
|
|
|
{
|
2022-04-28 15:05:56 -05:00
|
|
|
auto id_to_inspection_string = [&](const ID *id, const short idcode) {
|
2022-04-28 15:11:26 -05:00
|
|
|
ss << (id ? id->name + 2 : TIP_("None")) << " (" << TIP_(BKE_idtype_idcode_to_name(idcode))
|
|
|
|
|
<< ")";
|
2021-07-14 11:16:43 +02:00
|
|
|
};
|
|
|
|
|
|
2021-09-11 13:05:20 +02:00
|
|
|
const CPPType &type = *value.type();
|
2021-11-23 14:47:25 +01:00
|
|
|
const void *buffer = value.get();
|
2021-10-26 12:48:29 +02:00
|
|
|
if (type.is<Object *>()) {
|
2022-04-28 15:05:56 -05:00
|
|
|
id_to_inspection_string(*static_cast<const ID *const *>(buffer), ID_OB);
|
2021-07-14 11:16:43 +02:00
|
|
|
}
|
2021-09-11 13:05:20 +02:00
|
|
|
else if (type.is<Material *>()) {
|
2022-04-28 15:05:56 -05:00
|
|
|
id_to_inspection_string(*static_cast<const ID *const *>(buffer), ID_MA);
|
2021-07-14 11:16:43 +02:00
|
|
|
}
|
2021-09-11 13:05:20 +02:00
|
|
|
else if (type.is<Tex *>()) {
|
2022-04-28 15:05:56 -05:00
|
|
|
id_to_inspection_string(*static_cast<const ID *const *>(buffer), ID_TE);
|
2021-07-14 11:16:43 +02:00
|
|
|
}
|
2021-10-14 14:18:24 +01:00
|
|
|
else if (type.is<Image *>()) {
|
2022-04-28 15:05:56 -05:00
|
|
|
id_to_inspection_string(*static_cast<const ID *const *>(buffer), ID_IM);
|
2021-10-14 14:18:24 +01:00
|
|
|
}
|
2021-09-11 13:05:20 +02:00
|
|
|
else if (type.is<Collection *>()) {
|
2022-04-28 15:05:56 -05:00
|
|
|
id_to_inspection_string(*static_cast<const ID *const *>(buffer), ID_GR);
|
2021-11-23 14:47:25 +01:00
|
|
|
}
|
|
|
|
|
else if (type.is<int>()) {
|
|
|
|
|
ss << *(int *)buffer << TIP_(" (Integer)");
|
|
|
|
|
}
|
|
|
|
|
else if (type.is<float>()) {
|
|
|
|
|
ss << *(float *)buffer << TIP_(" (Float)");
|
|
|
|
|
}
|
|
|
|
|
else if (type.is<blender::float3>()) {
|
|
|
|
|
ss << *(blender::float3 *)buffer << TIP_(" (Vector)");
|
|
|
|
|
}
|
|
|
|
|
else if (type.is<bool>()) {
|
|
|
|
|
ss << ((*(bool *)buffer) ? TIP_("True") : TIP_("False")) << TIP_(" (Boolean)");
|
|
|
|
|
}
|
|
|
|
|
else if (type.is<std::string>()) {
|
|
|
|
|
ss << *(std::string *)buffer << TIP_(" (String)");
|
2021-07-14 11:16:43 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-26 12:48:29 +02:00
|
|
|
static void create_inspection_string_for_gfield(const geo_log::GFieldValueLog &value_log,
|
|
|
|
|
std::stringstream &ss)
|
|
|
|
|
{
|
|
|
|
|
const CPPType &type = value_log.type();
|
|
|
|
|
const GField &field = value_log.field();
|
|
|
|
|
const Span<std::string> input_tooltips = value_log.input_tooltips();
|
|
|
|
|
|
|
|
|
|
if (input_tooltips.is_empty()) {
|
|
|
|
|
if (field) {
|
|
|
|
|
BUFFER_FOR_CPP_TYPE_VALUE(type, buffer);
|
|
|
|
|
blender::fn::evaluate_constant_field(field, buffer);
|
2021-11-23 14:47:25 +01:00
|
|
|
create_inspection_string_for_generic_value({type, buffer}, ss);
|
2021-10-26 12:48:29 +02:00
|
|
|
type.destruct(buffer);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Constant values should always be logged. */
|
|
|
|
|
BLI_assert_unreachable();
|
|
|
|
|
ss << "Value has not been logged";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (type.is<int>()) {
|
2021-10-26 15:32:01 +02:00
|
|
|
ss << TIP_("Integer field");
|
2021-10-26 12:48:29 +02:00
|
|
|
}
|
|
|
|
|
else if (type.is<float>()) {
|
2021-10-26 15:32:01 +02:00
|
|
|
ss << TIP_("Float field");
|
2021-10-26 12:48:29 +02:00
|
|
|
}
|
|
|
|
|
else if (type.is<blender::float3>()) {
|
2021-10-26 15:32:01 +02:00
|
|
|
ss << TIP_("Vector field");
|
2021-10-26 12:48:29 +02:00
|
|
|
}
|
|
|
|
|
else if (type.is<bool>()) {
|
2021-10-26 15:32:01 +02:00
|
|
|
ss << TIP_("Boolean field");
|
2021-10-26 12:48:29 +02:00
|
|
|
}
|
|
|
|
|
else if (type.is<std::string>()) {
|
2021-10-26 15:32:01 +02:00
|
|
|
ss << TIP_("String field");
|
2021-10-26 12:48:29 +02:00
|
|
|
}
|
|
|
|
|
else if (type.is<blender::ColorGeometry4f>()) {
|
2021-10-26 15:32:01 +02:00
|
|
|
ss << TIP_("Color field");
|
2021-10-26 12:48:29 +02:00
|
|
|
}
|
|
|
|
|
ss << TIP_(" based on:\n");
|
|
|
|
|
|
|
|
|
|
for (const int i : input_tooltips.index_range()) {
|
|
|
|
|
const blender::StringRef tooltip = input_tooltips[i];
|
|
|
|
|
ss << "\u2022 " << tooltip;
|
|
|
|
|
if (i < input_tooltips.size() - 1) {
|
|
|
|
|
ss << ".\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-14 11:16:43 +02:00
|
|
|
static void create_inspection_string_for_geometry(const geo_log::GeometryValueLog &value_log,
|
2022-06-03 09:57:37 +02:00
|
|
|
std::stringstream &ss,
|
|
|
|
|
const nodes::decl::Geometry *geometry)
|
2021-07-14 11:16:43 +02:00
|
|
|
{
|
|
|
|
|
Span<GeometryComponentType> component_types = value_log.component_types();
|
|
|
|
|
if (component_types.is_empty()) {
|
|
|
|
|
ss << TIP_("Empty Geometry");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto to_string = [](int value) {
|
|
|
|
|
char str[16];
|
|
|
|
|
BLI_str_format_int_grouped(str, value);
|
|
|
|
|
return std::string(str);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ss << TIP_("Geometry:\n");
|
|
|
|
|
for (GeometryComponentType type : component_types) {
|
|
|
|
|
const char *line_end = (type == component_types.last()) ? "" : ".\n";
|
|
|
|
|
switch (type) {
|
|
|
|
|
case GEO_COMPONENT_TYPE_MESH: {
|
|
|
|
|
const geo_log::GeometryValueLog::MeshInfo &mesh_info = *value_log.mesh_info;
|
|
|
|
|
char line[256];
|
|
|
|
|
BLI_snprintf(line,
|
|
|
|
|
sizeof(line),
|
|
|
|
|
TIP_("\u2022 Mesh: %s vertices, %s edges, %s faces"),
|
2022-05-11 12:59:58 +10:00
|
|
|
to_string(mesh_info.verts_num).c_str(),
|
|
|
|
|
to_string(mesh_info.edges_num).c_str(),
|
|
|
|
|
to_string(mesh_info.faces_num).c_str());
|
2021-07-14 11:16:43 +02:00
|
|
|
ss << line << line_end;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case GEO_COMPONENT_TYPE_POINT_CLOUD: {
|
|
|
|
|
const geo_log::GeometryValueLog::PointCloudInfo &pointcloud_info =
|
|
|
|
|
*value_log.pointcloud_info;
|
|
|
|
|
char line[256];
|
|
|
|
|
BLI_snprintf(line,
|
|
|
|
|
sizeof(line),
|
|
|
|
|
TIP_("\u2022 Point Cloud: %s points"),
|
2022-05-11 12:59:58 +10:00
|
|
|
to_string(pointcloud_info.points_num).c_str());
|
2021-07-14 11:16:43 +02:00
|
|
|
ss << line << line_end;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case GEO_COMPONENT_TYPE_CURVE: {
|
|
|
|
|
const geo_log::GeometryValueLog::CurveInfo &curve_info = *value_log.curve_info;
|
|
|
|
|
char line[256];
|
|
|
|
|
BLI_snprintf(line,
|
|
|
|
|
sizeof(line),
|
|
|
|
|
TIP_("\u2022 Curve: %s splines"),
|
2022-05-11 12:59:58 +10:00
|
|
|
to_string(curve_info.splines_num).c_str());
|
2021-07-14 11:16:43 +02:00
|
|
|
ss << line << line_end;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case GEO_COMPONENT_TYPE_INSTANCES: {
|
|
|
|
|
const geo_log::GeometryValueLog::InstancesInfo &instances_info = *value_log.instances_info;
|
|
|
|
|
char line[256];
|
|
|
|
|
BLI_snprintf(line,
|
|
|
|
|
sizeof(line),
|
|
|
|
|
TIP_("\u2022 Instances: %s"),
|
2022-05-11 12:59:58 +10:00
|
|
|
to_string(instances_info.instances_num).c_str());
|
2021-07-14 11:16:43 +02:00
|
|
|
ss << line << line_end;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case GEO_COMPONENT_TYPE_VOLUME: {
|
|
|
|
|
ss << TIP_("\u2022 Volume") << line_end;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-07-22 15:39:41 +02:00
|
|
|
case GEO_COMPONENT_TYPE_EDIT: {
|
|
|
|
|
if (value_log.edit_data_info.has_value()) {
|
|
|
|
|
const geo_log::GeometryValueLog::EditDataInfo &edit_info = *value_log.edit_data_info;
|
|
|
|
|
char line[256];
|
|
|
|
|
BLI_snprintf(line,
|
|
|
|
|
sizeof(line),
|
|
|
|
|
TIP_("\u2022 Edit Curves: %s, %s"),
|
|
|
|
|
edit_info.has_deformed_positions ? TIP_("positions") : TIP_("no positions"),
|
|
|
|
|
edit_info.has_deform_matrices ? TIP_("matrices") : TIP_("no matrices"));
|
|
|
|
|
ss << line << line_end;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-07-14 11:16:43 +02:00
|
|
|
}
|
|
|
|
|
}
|
2022-06-03 09:57:37 +02:00
|
|
|
|
|
|
|
|
/* If the geometry declaration is null, as is the case for input to group output,
|
|
|
|
|
* or it is an output socket don't show supported types. */
|
|
|
|
|
if (geometry == nullptr || geometry->in_out() == SOCK_OUT) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Span<GeometryComponentType> supported_types = geometry->supported_types();
|
|
|
|
|
if (supported_types.is_empty()) {
|
|
|
|
|
ss << ".\n\n" << TIP_("Supported: All Types");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ss << ".\n\n" << TIP_("Supported: ");
|
|
|
|
|
for (GeometryComponentType type : supported_types) {
|
|
|
|
|
switch (type) {
|
|
|
|
|
case GEO_COMPONENT_TYPE_MESH: {
|
|
|
|
|
ss << TIP_("Mesh");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case GEO_COMPONENT_TYPE_POINT_CLOUD: {
|
|
|
|
|
ss << TIP_("Point Cloud");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case GEO_COMPONENT_TYPE_CURVE: {
|
|
|
|
|
ss << TIP_("Curve");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case GEO_COMPONENT_TYPE_INSTANCES: {
|
|
|
|
|
ss << TIP_("Instances");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case GEO_COMPONENT_TYPE_VOLUME: {
|
|
|
|
|
ss << TIP_("Volume");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-07-22 15:39:41 +02:00
|
|
|
case GEO_COMPONENT_TYPE_EDIT: {
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-06-03 09:57:37 +02:00
|
|
|
}
|
|
|
|
|
ss << ((type == supported_types.last()) ? "" : ", ");
|
|
|
|
|
}
|
2021-07-14 11:16:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static std::optional<std::string> create_socket_inspection_string(bContext *C,
|
|
|
|
|
bNode &node,
|
|
|
|
|
bNodeSocket &socket)
|
|
|
|
|
{
|
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
UI: Add support for showing socket descriptions in tooltips
Currently, hovering over a socket itself shows no tooltip at all, while
hovering over its value field shows "Default value", which is not helpful.
This patch therefore implements socket tooltips following the proposal at
https://blender.community/c/rightclickselect/2Qgbbc/.
A lot of the basic functionality was already implemented for Geometry Nodes,
where hovering over the socket itself shows introspection info.
This patch extends this by:
- Supporting dynamic tooltips on labels, which is important for good tooltip
coverage in a socket's region of the node.
- Adding a function to setting a dynamic tooltip for an entire uiLayout, which
avoids needing to set it manually for a wide variety of socket types.
- Hiding the property label field in a tooltip when dynamic tooltip is also
provided. If really needed, this label can be restored through the dynamic
tooltip, but in all current cases the label is actually pointless anyways
since the dynamic tooltip gives more accurate and specific information.
- Adding dynamic tooltips to a socket's UI layout row if it has a description
configured, both in the Node Editor as well as in the Material Properties.
Note that the patch does not add any actual tooltip content yet, just the
infrastructure to show them. By default, sockets without a description still
show the old "Default value" tooltip.
For an example of how to add socket descriptions, check the Cylinder node
in the Geometry Nodes.
Differential Revision: https://developer.blender.org/D9967
2022-04-11 02:02:12 +02:00
|
|
|
if (snode == nullptr) {
|
|
|
|
|
return {};
|
|
|
|
|
};
|
|
|
|
|
|
2021-07-14 11:16:43 +02:00
|
|
|
const geo_log::SocketLog *socket_log = geo_log::ModifierLog::find_socket_by_node_editor_context(
|
|
|
|
|
*snode, node, socket);
|
|
|
|
|
if (socket_log == nullptr) {
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
const geo_log::ValueLog *value_log = socket_log->value();
|
|
|
|
|
if (value_log == nullptr) {
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::stringstream ss;
|
|
|
|
|
if (const geo_log::GenericValueLog *generic_value_log =
|
|
|
|
|
dynamic_cast<const geo_log::GenericValueLog *>(value_log)) {
|
2021-11-23 14:47:25 +01:00
|
|
|
create_inspection_string_for_generic_value(generic_value_log->value(), ss);
|
2021-07-14 11:16:43 +02:00
|
|
|
}
|
2021-10-26 12:48:29 +02:00
|
|
|
if (const geo_log::GFieldValueLog *gfield_value_log =
|
|
|
|
|
dynamic_cast<const geo_log::GFieldValueLog *>(value_log)) {
|
|
|
|
|
create_inspection_string_for_gfield(*gfield_value_log, ss);
|
|
|
|
|
}
|
2021-07-14 11:16:43 +02:00
|
|
|
else if (const geo_log::GeometryValueLog *geo_value_log =
|
|
|
|
|
dynamic_cast<const geo_log::GeometryValueLog *>(value_log)) {
|
2022-06-03 09:57:37 +02:00
|
|
|
create_inspection_string_for_geometry(
|
|
|
|
|
*geo_value_log,
|
|
|
|
|
ss,
|
|
|
|
|
dynamic_cast<const nodes::decl::Geometry *>(socket.runtime->declaration));
|
2021-07-14 11:16:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ss.str();
|
|
|
|
|
}
|
|
|
|
|
|
UI: Add support for showing socket descriptions in tooltips
Currently, hovering over a socket itself shows no tooltip at all, while
hovering over its value field shows "Default value", which is not helpful.
This patch therefore implements socket tooltips following the proposal at
https://blender.community/c/rightclickselect/2Qgbbc/.
A lot of the basic functionality was already implemented for Geometry Nodes,
where hovering over the socket itself shows introspection info.
This patch extends this by:
- Supporting dynamic tooltips on labels, which is important for good tooltip
coverage in a socket's region of the node.
- Adding a function to setting a dynamic tooltip for an entire uiLayout, which
avoids needing to set it manually for a wide variety of socket types.
- Hiding the property label field in a tooltip when dynamic tooltip is also
provided. If really needed, this label can be restored through the dynamic
tooltip, but in all current cases the label is actually pointless anyways
since the dynamic tooltip gives more accurate and specific information.
- Adding dynamic tooltips to a socket's UI layout row if it has a description
configured, both in the Node Editor as well as in the Material Properties.
Note that the patch does not add any actual tooltip content yet, just the
infrastructure to show them. By default, sockets without a description still
show the old "Default value" tooltip.
For an example of how to add socket descriptions, check the Cylinder node
in the Geometry Nodes.
Differential Revision: https://developer.blender.org/D9967
2022-04-11 02:02:12 +02:00
|
|
|
static bool node_socket_has_tooltip(bNodeTree *ntree, bNodeSocket *socket)
|
|
|
|
|
{
|
|
|
|
|
if (ntree->type == NTREE_GEOMETRY) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-30 15:31:13 +02:00
|
|
|
if (socket->runtime->declaration != nullptr) {
|
|
|
|
|
const blender::nodes::SocketDeclaration &socket_decl = *socket->runtime->declaration;
|
UI: Add support for showing socket descriptions in tooltips
Currently, hovering over a socket itself shows no tooltip at all, while
hovering over its value field shows "Default value", which is not helpful.
This patch therefore implements socket tooltips following the proposal at
https://blender.community/c/rightclickselect/2Qgbbc/.
A lot of the basic functionality was already implemented for Geometry Nodes,
where hovering over the socket itself shows introspection info.
This patch extends this by:
- Supporting dynamic tooltips on labels, which is important for good tooltip
coverage in a socket's region of the node.
- Adding a function to setting a dynamic tooltip for an entire uiLayout, which
avoids needing to set it manually for a wide variety of socket types.
- Hiding the property label field in a tooltip when dynamic tooltip is also
provided. If really needed, this label can be restored through the dynamic
tooltip, but in all current cases the label is actually pointless anyways
since the dynamic tooltip gives more accurate and specific information.
- Adding dynamic tooltips to a socket's UI layout row if it has a description
configured, both in the Node Editor as well as in the Material Properties.
Note that the patch does not add any actual tooltip content yet, just the
infrastructure to show them. By default, sockets without a description still
show the old "Default value" tooltip.
For an example of how to add socket descriptions, check the Cylinder node
in the Geometry Nodes.
Differential Revision: https://developer.blender.org/D9967
2022-04-11 02:02:12 +02:00
|
|
|
return !socket_decl.description().is_empty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *node_socket_get_tooltip(bContext *C,
|
|
|
|
|
bNodeTree *ntree,
|
|
|
|
|
bNode *node,
|
|
|
|
|
bNodeSocket *socket)
|
|
|
|
|
{
|
|
|
|
|
std::stringstream output;
|
2022-05-30 15:31:13 +02:00
|
|
|
if (socket->runtime->declaration != nullptr) {
|
|
|
|
|
const blender::nodes::SocketDeclaration &socket_decl = *socket->runtime->declaration;
|
UI: Add support for showing socket descriptions in tooltips
Currently, hovering over a socket itself shows no tooltip at all, while
hovering over its value field shows "Default value", which is not helpful.
This patch therefore implements socket tooltips following the proposal at
https://blender.community/c/rightclickselect/2Qgbbc/.
A lot of the basic functionality was already implemented for Geometry Nodes,
where hovering over the socket itself shows introspection info.
This patch extends this by:
- Supporting dynamic tooltips on labels, which is important for good tooltip
coverage in a socket's region of the node.
- Adding a function to setting a dynamic tooltip for an entire uiLayout, which
avoids needing to set it manually for a wide variety of socket types.
- Hiding the property label field in a tooltip when dynamic tooltip is also
provided. If really needed, this label can be restored through the dynamic
tooltip, but in all current cases the label is actually pointless anyways
since the dynamic tooltip gives more accurate and specific information.
- Adding dynamic tooltips to a socket's UI layout row if it has a description
configured, both in the Node Editor as well as in the Material Properties.
Note that the patch does not add any actual tooltip content yet, just the
infrastructure to show them. By default, sockets without a description still
show the old "Default value" tooltip.
For an example of how to add socket descriptions, check the Cylinder node
in the Geometry Nodes.
Differential Revision: https://developer.blender.org/D9967
2022-04-11 02:02:12 +02:00
|
|
|
blender::StringRef description = socket_decl.description();
|
|
|
|
|
if (!description.is_empty()) {
|
|
|
|
|
output << TIP_(description.data());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ntree->type == NTREE_GEOMETRY) {
|
|
|
|
|
if (!output.str().empty()) {
|
|
|
|
|
output << ".\n\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::optional<std::string> socket_inspection_str = create_socket_inspection_string(
|
|
|
|
|
C, *node, *socket);
|
|
|
|
|
if (socket_inspection_str.has_value()) {
|
|
|
|
|
output << *socket_inspection_str;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
output << TIP_("The socket value has not been computed yet");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (output.str().empty()) {
|
|
|
|
|
output << nodeSocketLabel(socket);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return BLI_strdup(output.str().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void node_socket_add_tooltip(bNodeTree *ntree, bNode *node, bNodeSocket *sock, uiLayout *layout)
|
|
|
|
|
{
|
|
|
|
|
if (!node_socket_has_tooltip(ntree, sock)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SocketTooltipData *data = MEM_cnew<SocketTooltipData>(__func__);
|
|
|
|
|
data->ntree = ntree;
|
|
|
|
|
data->node = node;
|
|
|
|
|
data->socket = sock;
|
|
|
|
|
|
|
|
|
|
uiLayoutSetTooltipFunc(
|
|
|
|
|
layout,
|
|
|
|
|
[](bContext *C, void *argN, const char *UNUSED(tip)) {
|
|
|
|
|
SocketTooltipData *data = static_cast<SocketTooltipData *>(argN);
|
|
|
|
|
return node_socket_get_tooltip(C, data->ntree, data->node, data->socket);
|
|
|
|
|
},
|
|
|
|
|
data,
|
|
|
|
|
MEM_dupallocN,
|
|
|
|
|
MEM_freeN);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
static void node_socket_draw_nested(const bContext &C,
|
|
|
|
|
bNodeTree &ntree,
|
|
|
|
|
PointerRNA &node_ptr,
|
2021-12-14 11:19:47 -06:00
|
|
|
uiBlock &block,
|
2021-12-03 16:25:17 -05:00
|
|
|
bNodeSocket &sock,
|
|
|
|
|
const uint pos_id,
|
|
|
|
|
const uint col_id,
|
|
|
|
|
const uint shape_id,
|
|
|
|
|
const uint size_id,
|
|
|
|
|
const uint outline_col_id,
|
|
|
|
|
const float size,
|
|
|
|
|
const bool selected)
|
2020-04-16 15:09:49 +02:00
|
|
|
{
|
|
|
|
|
float color[4];
|
|
|
|
|
float outline_color[4];
|
|
|
|
|
|
2021-11-02 18:29:35 +02:00
|
|
|
node_socket_color_get(C, ntree, node_ptr, sock, color);
|
2021-12-03 16:25:17 -05:00
|
|
|
node_socket_outline_color_get(selected, sock.type, outline_color);
|
2020-04-16 15:09:49 +02:00
|
|
|
|
|
|
|
|
node_socket_draw(sock,
|
|
|
|
|
color,
|
|
|
|
|
outline_color,
|
|
|
|
|
size,
|
2021-12-03 16:25:17 -05:00
|
|
|
sock.locx,
|
|
|
|
|
sock.locy,
|
2020-04-16 15:09:49 +02:00
|
|
|
pos_id,
|
|
|
|
|
col_id,
|
|
|
|
|
shape_id,
|
|
|
|
|
size_id,
|
|
|
|
|
outline_col_id);
|
2021-07-14 11:16:43 +02:00
|
|
|
|
UI: Add support for showing socket descriptions in tooltips
Currently, hovering over a socket itself shows no tooltip at all, while
hovering over its value field shows "Default value", which is not helpful.
This patch therefore implements socket tooltips following the proposal at
https://blender.community/c/rightclickselect/2Qgbbc/.
A lot of the basic functionality was already implemented for Geometry Nodes,
where hovering over the socket itself shows introspection info.
This patch extends this by:
- Supporting dynamic tooltips on labels, which is important for good tooltip
coverage in a socket's region of the node.
- Adding a function to setting a dynamic tooltip for an entire uiLayout, which
avoids needing to set it manually for a wide variety of socket types.
- Hiding the property label field in a tooltip when dynamic tooltip is also
provided. If really needed, this label can be restored through the dynamic
tooltip, but in all current cases the label is actually pointless anyways
since the dynamic tooltip gives more accurate and specific information.
- Adding dynamic tooltips to a socket's UI layout row if it has a description
configured, both in the Node Editor as well as in the Material Properties.
Note that the patch does not add any actual tooltip content yet, just the
infrastructure to show them. By default, sockets without a description still
show the old "Default value" tooltip.
For an example of how to add socket descriptions, check the Cylinder node
in the Geometry Nodes.
Differential Revision: https://developer.blender.org/D9967
2022-04-11 02:02:12 +02:00
|
|
|
if (!node_socket_has_tooltip(&ntree, &sock)) {
|
2021-07-14 11:16:43 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Ideally sockets themselves should be buttons, but they aren't currently. So add an invisible
|
|
|
|
|
* button on top of them for the tooltip. */
|
2021-12-14 11:19:47 -06:00
|
|
|
const eUIEmbossType old_emboss = UI_block_emboss_get(&block);
|
|
|
|
|
UI_block_emboss_set(&block, UI_EMBOSS_NONE);
|
|
|
|
|
uiBut *but = uiDefIconBut(&block,
|
2021-07-14 11:16:43 +02:00
|
|
|
UI_BTYPE_BUT,
|
|
|
|
|
0,
|
|
|
|
|
ICON_NONE,
|
2021-12-03 16:25:17 -05:00
|
|
|
sock.locx - size / 2,
|
|
|
|
|
sock.locy - size / 2,
|
2021-07-14 11:16:43 +02:00
|
|
|
size,
|
|
|
|
|
size,
|
|
|
|
|
nullptr,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
nullptr);
|
|
|
|
|
|
|
|
|
|
SocketTooltipData *data = (SocketTooltipData *)MEM_mallocN(sizeof(SocketTooltipData), __func__);
|
2021-12-03 16:25:17 -05:00
|
|
|
data->ntree = &ntree;
|
|
|
|
|
data->node = (bNode *)node_ptr.data;
|
|
|
|
|
data->socket = &sock;
|
2021-07-14 11:16:43 +02:00
|
|
|
|
|
|
|
|
UI_but_func_tooltip_set(
|
|
|
|
|
but,
|
|
|
|
|
[](bContext *C, void *argN, const char *UNUSED(tip)) {
|
|
|
|
|
SocketTooltipData *data = (SocketTooltipData *)argN;
|
UI: Add support for showing socket descriptions in tooltips
Currently, hovering over a socket itself shows no tooltip at all, while
hovering over its value field shows "Default value", which is not helpful.
This patch therefore implements socket tooltips following the proposal at
https://blender.community/c/rightclickselect/2Qgbbc/.
A lot of the basic functionality was already implemented for Geometry Nodes,
where hovering over the socket itself shows introspection info.
This patch extends this by:
- Supporting dynamic tooltips on labels, which is important for good tooltip
coverage in a socket's region of the node.
- Adding a function to setting a dynamic tooltip for an entire uiLayout, which
avoids needing to set it manually for a wide variety of socket types.
- Hiding the property label field in a tooltip when dynamic tooltip is also
provided. If really needed, this label can be restored through the dynamic
tooltip, but in all current cases the label is actually pointless anyways
since the dynamic tooltip gives more accurate and specific information.
- Adding dynamic tooltips to a socket's UI layout row if it has a description
configured, both in the Node Editor as well as in the Material Properties.
Note that the patch does not add any actual tooltip content yet, just the
infrastructure to show them. By default, sockets without a description still
show the old "Default value" tooltip.
For an example of how to add socket descriptions, check the Cylinder node
in the Geometry Nodes.
Differential Revision: https://developer.blender.org/D9967
2022-04-11 02:02:12 +02:00
|
|
|
return node_socket_get_tooltip(C, data->ntree, data->node, data->socket);
|
2021-07-14 11:16:43 +02:00
|
|
|
},
|
|
|
|
|
data,
|
|
|
|
|
MEM_freeN);
|
2022-02-23 18:24:08 +11:00
|
|
|
/* Disable the button so that clicks on it are ignored the link operator still works. */
|
2021-07-14 11:16:43 +02:00
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_emboss_set(&block, old_emboss);
|
2020-04-16 15:09:49 +02:00
|
|
|
}
|
|
|
|
|
|
2022-01-20 10:36:56 -06:00
|
|
|
} // namespace blender::ed::space_node
|
|
|
|
|
|
2020-04-16 15:09:49 +02:00
|
|
|
void ED_node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[4], float scale)
|
|
|
|
|
{
|
2022-01-20 10:36:56 -06:00
|
|
|
using namespace blender::ed::space_node;
|
|
|
|
|
|
2022-02-28 18:05:12 -05:00
|
|
|
const float size = NODE_SOCKSIZE_DRAW_MULIPLIER * NODE_SOCKSIZE * scale;
|
2020-04-16 15:09:49 +02:00
|
|
|
rcti draw_rect = *rect;
|
|
|
|
|
float outline_color[4] = {0};
|
|
|
|
|
|
2021-02-24 13:01:24 -06:00
|
|
|
node_socket_outline_color_get(sock->flag & SELECT, sock->type, outline_color);
|
2020-04-16 15:09:49 +02:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2021-09-23 15:53:38 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_SHAPE);
|
2022-02-28 18:05:12 -05:00
|
|
|
immUniform1f("outline_scale", NODE_SOCK_OUTLINE_SCALE);
|
2020-04-16 15:09:49 +02:00
|
|
|
immUniform2f("ViewportSize", -1.0f, -1.0f);
|
|
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Single point. */
|
2020-04-16 15:09:49 +02:00
|
|
|
immBegin(GPU_PRIM_POINTS, 1);
|
2021-12-03 16:25:17 -05:00
|
|
|
node_socket_draw(*sock,
|
2020-04-16 15:09:49 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2022-01-20 10:36:56 -06:00
|
|
|
namespace blender::ed::space_node {
|
|
|
|
|
|
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
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Not a callback. */
|
2013-03-18 16:34:57 +00:00
|
|
|
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
|
|
|
|
2021-02-17 13:34:49 -06: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);
|
2021-02-17 13:34:49 -06: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);
|
2022-01-17 18:13:54 +01:00
|
|
|
immDrawPixelsTexTiled(&state,
|
|
|
|
|
draw_rect.xmin,
|
|
|
|
|
draw_rect.ymin,
|
|
|
|
|
preview->xsize,
|
|
|
|
|
preview->ysize,
|
|
|
|
|
GPU_RGBA8,
|
|
|
|
|
true,
|
|
|
|
|
preview->rect,
|
|
|
|
|
scale,
|
|
|
|
|
scale,
|
|
|
|
|
nullptr);
|
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
|
|
|
}
|
|
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Common handle function for operator buttons that need to select the node first. */
|
2011-12-18 12:51:50 +00:00
|
|
|
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
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Select & activate only the button's node. */
|
2021-12-03 16:25:17 -05:00
|
|
|
node_select_single(*C, *node);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2022-03-11 22:49:47 +11:00
|
|
|
WM_operator_name_call(C, opname, WM_OP_INVOKE_DEFAULT, nullptr, nullptr);
|
2011-12-18 12:51:50 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-05 17:12:25 -05:00
|
|
|
static void node_draw_shadow(const SpaceNode &snode,
|
|
|
|
|
const bNode &node,
|
|
|
|
|
const float radius,
|
|
|
|
|
const float alpha)
|
2012-05-22 14:13:33 +00:00
|
|
|
{
|
2021-12-03 16:25:17 -05:00
|
|
|
const rctf &rct = node.totr;
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
2021-12-03 16:25:17 -05:00
|
|
|
ui_draw_dropshadow(&rct, radius, snode.runtime->aspect, alpha, node.flag & SELECT);
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-05 17:12:25 -05:00
|
|
|
static void node_draw_sockets(const View2D &v2d,
|
|
|
|
|
const bContext &C,
|
|
|
|
|
bNodeTree &ntree,
|
|
|
|
|
bNode &node,
|
2021-12-14 11:19:47 -06:00
|
|
|
uiBlock &block,
|
2021-12-05 17:12:25 -05:00
|
|
|
const bool draw_outputs,
|
|
|
|
|
const bool select_all)
|
2016-10-15 02:49:00 -04:00
|
|
|
{
|
2021-12-03 16:25:17 -05: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;
|
2021-12-03 16:25:17 -05:00
|
|
|
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);
|
2021-09-23 15:53:38 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_SHAPE);
|
2022-02-28 18:05:12 -05:00
|
|
|
immUniform1f("outline_scale", NODE_SOCK_OUTLINE_SCALE);
|
2019-08-25 16:37:06 +01:00
|
|
|
immUniform2f("ViewportSize", -1.0f, -1.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Set handle size. */
|
2022-02-28 18:05:12 -05:00
|
|
|
const float socket_draw_size = NODE_SOCKSIZE * NODE_SOCKSIZE_DRAW_MULIPLIER;
|
2019-08-22 11:10:11 +02:00
|
|
|
float scale;
|
2021-12-03 16:25:17 -05:00
|
|
|
UI_view2d_scale_get(&v2d, &scale, nullptr);
|
2022-02-28 18:05:12 -05:00
|
|
|
scale *= socket_draw_size;
|
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
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Socket inputs. */
|
2018-07-08 13:19:10 +02:00
|
|
|
short selected_input_len = 0;
|
2021-12-03 16:25:17 -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)) {
|
2022-02-28 18:05:12 -05:00
|
|
|
if (!(sock->flag & SOCK_MULTI_INPUT)) {
|
|
|
|
|
/* Don't add multi-input sockets here since they are drawn in a different batch. */
|
|
|
|
|
selected_input_len++;
|
|
|
|
|
}
|
2016-10-15 02:49:00 -04:00
|
|
|
continue;
|
|
|
|
|
}
|
2021-02-11 01:16:17 -06:00
|
|
|
/* Don't draw multi-input sockets here since they are drawn in a different batch. */
|
|
|
|
|
if (sock->flag & SOCK_MULTI_INPUT) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-16 15:09:49 +02:00
|
|
|
node_socket_draw_nested(C,
|
|
|
|
|
ntree,
|
2021-12-03 16:25:17 -05:00
|
|
|
node_ptr,
|
2021-12-14 11:19:47 -06:00
|
|
|
block,
|
2021-12-03 16:25:17 -05:00
|
|
|
*sock,
|
2020-04-16 15:09:49 +02:00
|
|
|
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
|
|
|
|
2021-02-17 13:34:49 -06: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) {
|
2021-12-03 16:25:17 -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,
|
2021-12-03 16:25:17 -05:00
|
|
|
node_ptr,
|
2021-12-14 11:19:47 -06:00
|
|
|
block,
|
2021-12-03 16:25:17 -05:00
|
|
|
*sock,
|
2020-04-16 15:09:49 +02:00
|
|
|
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
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Go back and draw selected sockets. */
|
2018-07-08 13:19:10 +02:00
|
|
|
if (selected_input_len + selected_output_len > 0) {
|
2021-02-17 13:34:49 -06: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) {
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Socket inputs. */
|
2021-12-03 16:25:17 -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
|
|
|
}
|
2022-02-28 18:05:12 -05:00
|
|
|
/* Don't draw multi-input sockets here since they are drawn in a different batch. */
|
|
|
|
|
if (sock->flag & SOCK_MULTI_INPUT) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
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,
|
2021-12-03 16:25:17 -05:00
|
|
|
node_ptr,
|
2021-12-14 11:19:47 -06:00
|
|
|
block,
|
2021-12-03 16:25:17 -05:00
|
|
|
*sock,
|
2020-04-16 15:09:49 +02:00
|
|
|
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) {
|
2021-02-17 13:34:49 -06: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) {
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Socket outputs. */
|
2021-12-03 16:25:17 -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,
|
2021-12-03 16:25:17 -05:00
|
|
|
node_ptr,
|
2021-12-14 11:19:47 -06:00
|
|
|
block,
|
2021-12-03 16:25:17 -05:00
|
|
|
*sock,
|
2020-04-16 15:09:49 +02:00
|
|
|
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) {
|
2021-02-17 13:34:49 -06: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);
|
2021-02-11 01:16:17 -06:00
|
|
|
|
2021-02-12 07:47:02 +11:00
|
|
|
/* Draw multi-input sockets after the others because they are drawn with `UI_draw_roundbox`
|
|
|
|
|
* rather than with `GL_POINT`. */
|
2021-12-03 16:25:17 -05:00
|
|
|
LISTBASE_FOREACH (bNodeSocket *, socket, &node.inputs) {
|
2021-02-11 01:16:17 -06:00
|
|
|
if (nodeSocketIsHidden(socket)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (!(socket->flag & SOCK_MULTI_INPUT)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
const bool is_node_hidden = (node.flag & NODE_HIDDEN);
|
2022-02-28 18:05:12 -05:00
|
|
|
const float width = 0.5f * socket_draw_size;
|
2021-12-03 16:25:17 -05:00
|
|
|
float height = is_node_hidden ? width : node_socket_calculate_height(*socket) - width;
|
2021-02-11 01:16:17 -06:00
|
|
|
|
|
|
|
|
float color[4];
|
|
|
|
|
float outline_color[4];
|
2021-12-03 16:25:17 -05:00
|
|
|
node_socket_color_get(C, ntree, node_ptr, *socket, color);
|
2022-02-28 18:05:12 -05:00
|
|
|
node_socket_outline_color_get(socket->flag & SELECT, socket->type, outline_color);
|
2021-02-11 01:16:17 -06:00
|
|
|
|
|
|
|
|
node_socket_draw_multi_input(color, outline_color, width, height, socket->locx, socket->locy);
|
|
|
|
|
}
|
2016-10-15 02:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2021-07-07 11:20:19 +02:00
|
|
|
static int node_error_type_to_icon(const geo_log::NodeWarningType type)
|
2021-02-16 17:15:08 -06:00
|
|
|
{
|
|
|
|
|
switch (type) {
|
2021-07-07 11:20:19 +02:00
|
|
|
case geo_log::NodeWarningType::Error:
|
2021-02-16 17:15:08 -06:00
|
|
|
return ICON_ERROR;
|
2021-07-07 11:20:19 +02:00
|
|
|
case geo_log::NodeWarningType::Warning:
|
2021-02-16 17:15:08 -06:00
|
|
|
return ICON_ERROR;
|
2021-07-07 11:20:19 +02:00
|
|
|
case geo_log::NodeWarningType::Info:
|
2021-02-16 17:15:08 -06:00
|
|
|
return ICON_INFO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_assert(false);
|
|
|
|
|
return ICON_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-07 11:20:19 +02:00
|
|
|
static uint8_t node_error_type_priority(const geo_log::NodeWarningType type)
|
2021-02-16 17:15:08 -06:00
|
|
|
{
|
|
|
|
|
switch (type) {
|
2021-07-07 11:20:19 +02:00
|
|
|
case geo_log::NodeWarningType::Error:
|
2021-02-16 17:15:08 -06:00
|
|
|
return 3;
|
2021-07-07 11:20:19 +02:00
|
|
|
case geo_log::NodeWarningType::Warning:
|
2021-02-16 17:15:08 -06:00
|
|
|
return 2;
|
2021-07-07 11:20:19 +02:00
|
|
|
case geo_log::NodeWarningType::Info:
|
2021-02-16 17:15:08 -06:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_assert(false);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-07 11:20:19 +02:00
|
|
|
static geo_log::NodeWarningType node_error_highest_priority(Span<geo_log::NodeWarning> warnings)
|
2021-02-16 17:15:08 -06:00
|
|
|
{
|
|
|
|
|
uint8_t highest_priority = 0;
|
2021-07-07 11:20:19 +02:00
|
|
|
geo_log::NodeWarningType highest_priority_type = geo_log::NodeWarningType::Info;
|
|
|
|
|
for (const geo_log::NodeWarning &warning : warnings) {
|
2021-02-16 17:15:08 -06:00
|
|
|
const uint8_t priority = node_error_type_priority(warning.type);
|
|
|
|
|
if (priority > highest_priority) {
|
|
|
|
|
highest_priority = priority;
|
|
|
|
|
highest_priority_type = warning.type;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return highest_priority_type;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-07 11:20:19 +02:00
|
|
|
struct NodeErrorsTooltipData {
|
|
|
|
|
Span<geo_log::NodeWarning> warnings;
|
|
|
|
|
};
|
|
|
|
|
|
2021-02-19 12:31:27 +01:00
|
|
|
static char *node_errors_tooltip_fn(bContext *UNUSED(C), void *argN, const char *UNUSED(tip))
|
2021-02-16 17:15:08 -06:00
|
|
|
{
|
2021-07-07 11:20:19 +02:00
|
|
|
NodeErrorsTooltipData &data = *(NodeErrorsTooltipData *)argN;
|
2021-02-16 17:15:08 -06:00
|
|
|
|
|
|
|
|
std::string complete_string;
|
|
|
|
|
|
2021-07-07 11:20:19 +02:00
|
|
|
for (const geo_log::NodeWarning &warning : data.warnings.drop_back(1)) {
|
2021-02-16 17:15:08 -06:00
|
|
|
complete_string += warning.message;
|
2021-03-03 12:58:33 -06:00
|
|
|
/* Adding the period is not ideal for multi-line messages, but it is consistent
|
|
|
|
|
* with other tooltip implementations in Blender, so it is added here. */
|
|
|
|
|
complete_string += '.';
|
2021-02-16 17:15:08 -06:00
|
|
|
complete_string += '\n';
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-03 12:58:33 -06:00
|
|
|
/* Let the tooltip system automatically add the last period. */
|
2021-07-07 11:20:19 +02:00
|
|
|
complete_string += data.warnings.last().message;
|
2021-02-16 17:15:08 -06:00
|
|
|
|
|
|
|
|
return BLI_strdupn(complete_string.c_str(), complete_string.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define NODE_HEADER_ICON_SIZE (0.8f * U.widget_unit)
|
|
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
static void node_add_error_message_button(
|
|
|
|
|
const bContext &C, bNode &node, uiBlock &block, const rctf &rect, float &icon_offset)
|
2021-02-16 17:15:08 -06:00
|
|
|
{
|
2021-12-03 16:25:17 -05:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(&C);
|
2021-07-07 11:20:19 +02:00
|
|
|
const geo_log::NodeLog *node_log = geo_log::ModifierLog::find_node_by_node_editor_context(*snode,
|
|
|
|
|
node);
|
|
|
|
|
if (node_log == nullptr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Span<geo_log::NodeWarning> warnings = node_log->warnings();
|
|
|
|
|
|
|
|
|
|
if (warnings.is_empty()) {
|
2021-02-16 17:15:08 -06:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-07 11:20:19 +02:00
|
|
|
NodeErrorsTooltipData *tooltip_data = (NodeErrorsTooltipData *)MEM_mallocN(
|
|
|
|
|
sizeof(NodeErrorsTooltipData), __func__);
|
|
|
|
|
tooltip_data->warnings = warnings;
|
2021-02-16 17:15:08 -06:00
|
|
|
|
2021-07-07 11:20:19 +02:00
|
|
|
const geo_log::NodeWarningType display_type = node_error_highest_priority(warnings);
|
2021-02-16 17:15:08 -06:00
|
|
|
|
|
|
|
|
icon_offset -= NODE_HEADER_ICON_SIZE;
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_emboss_set(&block, UI_EMBOSS_NONE);
|
|
|
|
|
uiBut *but = uiDefIconBut(&block,
|
2021-02-16 17:15:08 -06:00
|
|
|
UI_BTYPE_BUT,
|
|
|
|
|
0,
|
|
|
|
|
node_error_type_to_icon(display_type),
|
|
|
|
|
icon_offset,
|
|
|
|
|
rect.ymax - NODE_DY,
|
|
|
|
|
NODE_HEADER_ICON_SIZE,
|
|
|
|
|
UI_UNIT_Y,
|
|
|
|
|
nullptr,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
nullptr);
|
2021-07-07 11:20:19 +02:00
|
|
|
UI_but_func_tooltip_set(but, node_errors_tooltip_fn, tooltip_data, MEM_freeN);
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_emboss_set(&block, UI_EMBOSS);
|
2021-02-16 17:15:08 -06:00
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
static void get_exec_time_other_nodes(const bNode &node,
|
|
|
|
|
const SpaceNode &snode,
|
2021-11-23 17:37:31 +01:00
|
|
|
std::chrono::microseconds &exec_time,
|
|
|
|
|
int &node_count)
|
|
|
|
|
{
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.type == NODE_GROUP) {
|
2021-11-23 17:37:31 +01:00
|
|
|
const geo_log::TreeLog *root_tree_log = geo_log::ModifierLog::find_tree_by_node_editor_context(
|
2021-12-03 16:25:17 -05:00
|
|
|
snode);
|
2021-11-23 17:37:31 +01:00
|
|
|
if (root_tree_log == nullptr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-12-03 16:25:17 -05:00
|
|
|
const geo_log::TreeLog *tree_log = root_tree_log->lookup_child_log(node.name);
|
2021-11-23 17:37:31 +01:00
|
|
|
if (tree_log == nullptr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
tree_log->foreach_node_log([&](const geo_log::NodeLog &node_log) {
|
|
|
|
|
exec_time += node_log.execution_time();
|
|
|
|
|
node_count++;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
const geo_log::NodeLog *node_log = geo_log::ModifierLog::find_node_by_node_editor_context(
|
2021-12-03 16:25:17 -05:00
|
|
|
snode, node);
|
2021-11-23 17:37:31 +01:00
|
|
|
if (node_log) {
|
|
|
|
|
exec_time += node_log->execution_time();
|
|
|
|
|
node_count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
static std::chrono::microseconds node_get_execution_time(const bNodeTree &ntree,
|
|
|
|
|
const bNode &node,
|
|
|
|
|
const SpaceNode &snode,
|
2021-11-23 17:37:31 +01:00
|
|
|
int &node_count)
|
|
|
|
|
{
|
|
|
|
|
std::chrono::microseconds exec_time = std::chrono::microseconds::zero();
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.type == NODE_GROUP_OUTPUT) {
|
2021-11-23 17:37:31 +01:00
|
|
|
const geo_log::TreeLog *tree_log = geo_log::ModifierLog::find_tree_by_node_editor_context(
|
2021-12-03 16:25:17 -05:00
|
|
|
snode);
|
2021-11-23 17:37:31 +01:00
|
|
|
|
|
|
|
|
if (tree_log == nullptr) {
|
|
|
|
|
return exec_time;
|
|
|
|
|
}
|
|
|
|
|
tree_log->foreach_node_log([&](const geo_log::NodeLog &node_log) {
|
|
|
|
|
exec_time += node_log.execution_time();
|
|
|
|
|
node_count++;
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-12-03 16:25:17 -05:00
|
|
|
else if (node.type == NODE_FRAME) {
|
2021-11-23 17:37:31 +01:00
|
|
|
/* Could be cached in the future if this recursive code turns out to be slow. */
|
2021-12-03 16:25:17 -05:00
|
|
|
LISTBASE_FOREACH (bNode *, tnode, &ntree.nodes) {
|
|
|
|
|
if (tnode->parent != &node) {
|
2021-11-23 17:37:31 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tnode->type == NODE_FRAME) {
|
2021-12-03 16:25:17 -05:00
|
|
|
exec_time += node_get_execution_time(ntree, *tnode, snode, node_count);
|
2021-11-23 17:37:31 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2021-12-03 16:25:17 -05:00
|
|
|
get_exec_time_other_nodes(*tnode, snode, exec_time, node_count);
|
2021-11-23 17:37:31 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
get_exec_time_other_nodes(node, snode, exec_time, node_count);
|
|
|
|
|
}
|
|
|
|
|
return exec_time;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
static std::string node_get_execution_time_label(const SpaceNode &snode, const bNode &node)
|
2021-11-23 17:37:31 +01:00
|
|
|
{
|
|
|
|
|
int node_count = 0;
|
|
|
|
|
std::chrono::microseconds exec_time = node_get_execution_time(
|
2022-07-25 12:27:45 +02:00
|
|
|
*snode.edittree, node, snode, node_count);
|
2021-11-23 17:37:31 +01:00
|
|
|
|
|
|
|
|
if (node_count == 0) {
|
|
|
|
|
return std::string("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint64_t exec_time_us = exec_time.count();
|
|
|
|
|
|
|
|
|
|
/* Don't show time if execution time is 0 microseconds. */
|
|
|
|
|
if (exec_time_us == 0) {
|
|
|
|
|
return std::string("-");
|
|
|
|
|
}
|
2021-11-23 12:49:45 -05:00
|
|
|
if (exec_time_us < 100) {
|
2021-11-23 17:37:31 +01:00
|
|
|
return std::string("< 0.1 ms");
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-23 12:49:45 -05:00
|
|
|
int precision = 0;
|
|
|
|
|
/* Show decimal if value is below 1ms */
|
|
|
|
|
if (exec_time_us < 1000) {
|
|
|
|
|
precision = 2;
|
2021-11-23 17:37:31 +01:00
|
|
|
}
|
2021-11-23 12:49:45 -05:00
|
|
|
else if (exec_time_us < 10000) {
|
|
|
|
|
precision = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::stringstream stream;
|
|
|
|
|
stream << std::fixed << std::setprecision(precision) << (exec_time_us / 1000.0f);
|
|
|
|
|
return stream.str() + " ms";
|
2021-11-23 17:37:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct NodeExtraInfoRow {
|
|
|
|
|
std::string text;
|
|
|
|
|
int icon;
|
2022-04-14 16:31:09 +02:00
|
|
|
const char *tooltip = nullptr;
|
|
|
|
|
|
|
|
|
|
uiButToolTipFunc tooltip_fn = nullptr;
|
|
|
|
|
void *tooltip_fn_arg = nullptr;
|
|
|
|
|
void (*tooltip_fn_free_arg)(void *) = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct NamedAttributeTooltipArg {
|
2022-06-01 14:38:06 +10:00
|
|
|
Map<std::string, eNamedAttrUsage> usage_by_attribute;
|
2021-11-23 17:37:31 +01:00
|
|
|
};
|
|
|
|
|
|
2022-04-14 16:31:09 +02:00
|
|
|
static char *named_attribute_tooltip(bContext *UNUSED(C), void *argN, const char *UNUSED(tip))
|
|
|
|
|
{
|
|
|
|
|
NamedAttributeTooltipArg &arg = *static_cast<NamedAttributeTooltipArg *>(argN);
|
|
|
|
|
|
|
|
|
|
std::stringstream ss;
|
2022-04-25 16:28:21 +02:00
|
|
|
ss << TIP_("Accessed named attributes:\n");
|
2022-04-25 16:00:43 +02:00
|
|
|
|
|
|
|
|
struct NameWithUsage {
|
|
|
|
|
StringRefNull name;
|
2022-06-01 14:38:06 +10:00
|
|
|
eNamedAttrUsage usage;
|
2022-04-25 16:00:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Vector<NameWithUsage> sorted_used_attribute;
|
2022-04-14 16:31:09 +02:00
|
|
|
for (auto &&item : arg.usage_by_attribute.items()) {
|
|
|
|
|
sorted_used_attribute.append({item.key, item.value});
|
|
|
|
|
}
|
2022-04-25 16:00:43 +02:00
|
|
|
std::sort(sorted_used_attribute.begin(),
|
|
|
|
|
sorted_used_attribute.end(),
|
|
|
|
|
[](const NameWithUsage &a, const NameWithUsage &b) {
|
|
|
|
|
return BLI_strcasecmp_natural(a.name.c_str(), b.name.c_str()) <= 0;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (const NameWithUsage &attribute : sorted_used_attribute) {
|
|
|
|
|
const StringRefNull name = attribute.name;
|
2022-06-01 14:38:06 +10:00
|
|
|
const eNamedAttrUsage usage = attribute.usage;
|
2022-04-14 16:31:09 +02:00
|
|
|
ss << " \u2022 \"" << name << "\": ";
|
|
|
|
|
Vector<std::string> usages;
|
2022-06-01 14:38:06 +10:00
|
|
|
if ((usage & eNamedAttrUsage::Read) != eNamedAttrUsage::None) {
|
2022-04-14 16:31:09 +02:00
|
|
|
usages.append(TIP_("read"));
|
|
|
|
|
}
|
2022-06-01 14:38:06 +10:00
|
|
|
if ((usage & eNamedAttrUsage::Write) != eNamedAttrUsage::None) {
|
2022-04-14 16:31:09 +02:00
|
|
|
usages.append(TIP_("write"));
|
|
|
|
|
}
|
2022-06-01 14:38:06 +10:00
|
|
|
if ((usage & eNamedAttrUsage::Remove) != eNamedAttrUsage::None) {
|
2022-04-14 16:31:09 +02:00
|
|
|
usages.append(TIP_("remove"));
|
|
|
|
|
}
|
|
|
|
|
for (const int i : usages.index_range()) {
|
|
|
|
|
ss << usages[i];
|
|
|
|
|
if (i < usages.size() - 1) {
|
|
|
|
|
ss << ", ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ss << "\n";
|
|
|
|
|
}
|
|
|
|
|
ss << "\n";
|
|
|
|
|
ss << TIP_(
|
|
|
|
|
"Attributes with these names used within the group may conflict with existing attributes");
|
|
|
|
|
return BLI_strdup(ss.str().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NodeExtraInfoRow row_from_used_named_attribute(
|
2022-06-01 14:38:06 +10:00
|
|
|
const Map<std::string, eNamedAttrUsage> &usage_by_attribute_name)
|
2022-04-14 16:31:09 +02:00
|
|
|
{
|
2022-04-25 16:28:21 +02:00
|
|
|
const int attributes_num = usage_by_attribute_name.size();
|
|
|
|
|
|
2022-04-14 16:31:09 +02:00
|
|
|
NodeExtraInfoRow row;
|
2022-04-25 16:28:21 +02:00
|
|
|
row.text = std::to_string(attributes_num) +
|
|
|
|
|
TIP_(attributes_num == 1 ? " Named Attribute" : " Named Attributes");
|
2022-04-14 16:31:09 +02:00
|
|
|
row.icon = ICON_SPREADSHEET;
|
|
|
|
|
row.tooltip_fn = named_attribute_tooltip;
|
|
|
|
|
row.tooltip_fn_arg = new NamedAttributeTooltipArg{usage_by_attribute_name};
|
|
|
|
|
row.tooltip_fn_free_arg = [](void *arg) { delete static_cast<NamedAttributeTooltipArg *>(arg); };
|
|
|
|
|
return row;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static std::optional<NodeExtraInfoRow> node_get_accessed_attributes_row(const SpaceNode &snode,
|
|
|
|
|
const bNode &node)
|
|
|
|
|
{
|
|
|
|
|
if (node.type == NODE_GROUP) {
|
|
|
|
|
const geo_log::TreeLog *root_tree_log = geo_log::ModifierLog::find_tree_by_node_editor_context(
|
|
|
|
|
snode);
|
|
|
|
|
if (root_tree_log == nullptr) {
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
const geo_log::TreeLog *tree_log = root_tree_log->lookup_child_log(node.name);
|
|
|
|
|
if (tree_log == nullptr) {
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-01 14:38:06 +10:00
|
|
|
Map<std::string, eNamedAttrUsage> usage_by_attribute;
|
2022-04-14 16:31:09 +02:00
|
|
|
tree_log->foreach_node_log([&](const geo_log::NodeLog &node_log) {
|
|
|
|
|
for (const geo_log::UsedNamedAttribute &used_attribute : node_log.used_named_attributes()) {
|
|
|
|
|
usage_by_attribute.lookup_or_add_as(used_attribute.name,
|
|
|
|
|
used_attribute.usage) |= used_attribute.usage;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (usage_by_attribute.is_empty()) {
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return row_from_used_named_attribute(usage_by_attribute);
|
|
|
|
|
}
|
|
|
|
|
if (ELEM(node.type,
|
|
|
|
|
GEO_NODE_STORE_NAMED_ATTRIBUTE,
|
|
|
|
|
GEO_NODE_REMOVE_ATTRIBUTE,
|
|
|
|
|
GEO_NODE_INPUT_NAMED_ATTRIBUTE)) {
|
|
|
|
|
/* Only show the overlay when the name is passed in from somewhere else. */
|
|
|
|
|
LISTBASE_FOREACH (bNodeSocket *, socket, &node.inputs) {
|
|
|
|
|
if (STREQ(socket->name, "Name")) {
|
|
|
|
|
if ((socket->flag & SOCK_IN_USE) == 0) {
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const geo_log::NodeLog *node_log = geo_log::ModifierLog::find_node_by_node_editor_context(
|
|
|
|
|
snode, node.name);
|
|
|
|
|
if (node_log == nullptr) {
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
2022-06-01 14:38:06 +10:00
|
|
|
Map<std::string, eNamedAttrUsage> usage_by_attribute;
|
2022-04-14 16:31:09 +02:00
|
|
|
for (const geo_log::UsedNamedAttribute &used_attribute : node_log->used_named_attributes()) {
|
|
|
|
|
usage_by_attribute.lookup_or_add_as(used_attribute.name,
|
|
|
|
|
used_attribute.usage) |= used_attribute.usage;
|
|
|
|
|
}
|
|
|
|
|
if (usage_by_attribute.is_empty()) {
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
return row_from_used_named_attribute(usage_by_attribute);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
static Vector<NodeExtraInfoRow> node_get_extra_info(const SpaceNode &snode, const bNode &node)
|
2021-11-23 17:37:31 +01:00
|
|
|
{
|
|
|
|
|
Vector<NodeExtraInfoRow> rows;
|
2021-12-03 16:25:17 -05:00
|
|
|
if (!(snode.overlay.flag & SN_OVERLAY_SHOW_OVERLAYS)) {
|
2021-11-23 17:37:31 +01:00
|
|
|
return rows;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-25 16:03:34 +02:00
|
|
|
if (snode.overlay.flag & SN_OVERLAY_SHOW_NAMED_ATTRIBUTES &&
|
|
|
|
|
snode.edittree->type == NTREE_GEOMETRY) {
|
|
|
|
|
if (std::optional<NodeExtraInfoRow> row = node_get_accessed_attributes_row(snode, node)) {
|
|
|
|
|
rows.append(std::move(*row));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
if (snode.overlay.flag & SN_OVERLAY_SHOW_TIMINGS && snode.edittree->type == NTREE_GEOMETRY &&
|
|
|
|
|
(ELEM(node.typeinfo->nclass, NODE_CLASS_GEOMETRY, NODE_CLASS_GROUP, NODE_CLASS_ATTRIBUTE) ||
|
|
|
|
|
ELEM(node.type, NODE_FRAME, NODE_GROUP_OUTPUT))) {
|
2021-11-23 17:37:31 +01:00
|
|
|
NodeExtraInfoRow row;
|
|
|
|
|
row.text = node_get_execution_time_label(snode, node);
|
|
|
|
|
if (!row.text.empty()) {
|
|
|
|
|
row.tooltip = TIP_(
|
|
|
|
|
"The execution time from the node tree's latest evaluation. For frame and group nodes, "
|
|
|
|
|
"the time for all sub-nodes");
|
|
|
|
|
row.icon = ICON_PREVIEW_RANGE;
|
|
|
|
|
rows.append(std::move(row));
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-03 16:25:17 -05:00
|
|
|
const geo_log::NodeLog *node_log = geo_log::ModifierLog::find_node_by_node_editor_context(snode,
|
|
|
|
|
node);
|
2021-11-24 13:39:09 +01:00
|
|
|
if (node_log != nullptr) {
|
|
|
|
|
for (const std::string &message : node_log->debug_messages()) {
|
|
|
|
|
NodeExtraInfoRow row;
|
|
|
|
|
row.text = message;
|
|
|
|
|
row.icon = ICON_INFO;
|
|
|
|
|
rows.append(std::move(row));
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-14 16:31:09 +02:00
|
|
|
|
2021-11-23 17:37:31 +01:00
|
|
|
return rows;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
static void node_draw_extra_info_row(const bNode &node,
|
2021-12-14 11:19:47 -06:00
|
|
|
uiBlock &block,
|
2021-12-03 16:25:17 -05:00
|
|
|
const rctf &rect,
|
2021-11-23 17:37:31 +01:00
|
|
|
const int row,
|
|
|
|
|
const NodeExtraInfoRow &extra_info_row)
|
|
|
|
|
{
|
2022-04-25 16:28:21 +02:00
|
|
|
const float but_icon_left = rect.xmin + 6.0f * U.dpi_fac;
|
|
|
|
|
const float but_icon_width = NODE_HEADER_ICON_SIZE * 0.8f;
|
|
|
|
|
const float but_icon_right = but_icon_left + but_icon_width;
|
|
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_emboss_set(&block, UI_EMBOSS_NONE);
|
|
|
|
|
uiBut *but_icon = uiDefIconBut(&block,
|
2021-11-23 17:37:31 +01:00
|
|
|
UI_BTYPE_BUT,
|
|
|
|
|
0,
|
|
|
|
|
extra_info_row.icon,
|
2022-04-25 16:28:21 +02:00
|
|
|
(int)but_icon_left,
|
2021-12-03 16:25:17 -05:00
|
|
|
(int)(rect.ymin + row * (20.0f * U.dpi_fac)),
|
2022-04-25 16:28:21 +02:00
|
|
|
but_icon_width,
|
2021-11-23 17:37:31 +01:00
|
|
|
UI_UNIT_Y,
|
|
|
|
|
nullptr,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
extra_info_row.tooltip);
|
2022-04-15 11:59:02 -05:00
|
|
|
if (extra_info_row.tooltip_fn != nullptr) {
|
2022-04-14 16:31:09 +02:00
|
|
|
UI_but_func_tooltip_set(but_icon,
|
|
|
|
|
extra_info_row.tooltip_fn,
|
|
|
|
|
extra_info_row.tooltip_fn_arg,
|
|
|
|
|
extra_info_row.tooltip_fn_free_arg);
|
|
|
|
|
}
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_emboss_set(&block, UI_EMBOSS);
|
2022-04-25 16:28:21 +02:00
|
|
|
|
|
|
|
|
const float but_text_left = but_icon_right + 6.0f * U.dpi_fac;
|
|
|
|
|
const float but_text_right = rect.xmax;
|
|
|
|
|
const float but_text_width = but_text_right - but_text_left;
|
|
|
|
|
|
|
|
|
|
uiBut *but_text = uiDefBut(&block,
|
|
|
|
|
UI_BTYPE_LABEL,
|
|
|
|
|
0,
|
|
|
|
|
extra_info_row.text.c_str(),
|
|
|
|
|
(int)but_text_left,
|
|
|
|
|
(int)(rect.ymin + row * (20.0f * U.dpi_fac)),
|
|
|
|
|
(short)but_text_width,
|
|
|
|
|
(short)NODE_DY,
|
|
|
|
|
nullptr,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
"");
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & NODE_MUTED) {
|
2022-04-14 16:31:09 +02:00
|
|
|
UI_but_flag_enable(but_text, UI_BUT_INACTIVE);
|
2021-11-23 17:37:31 +01:00
|
|
|
UI_but_flag_enable(but_icon, UI_BUT_INACTIVE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
static void node_draw_extra_info_panel(const SpaceNode &snode, const bNode &node, uiBlock &block)
|
2021-11-23 17:37:31 +01:00
|
|
|
{
|
|
|
|
|
Vector<NodeExtraInfoRow> extra_info_rows = node_get_extra_info(snode, node);
|
|
|
|
|
|
|
|
|
|
if (extra_info_rows.size() == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
const rctf &rct = node.totr;
|
2021-11-23 17:37:31 +01:00
|
|
|
float color[4];
|
|
|
|
|
rctf extra_info_rect;
|
|
|
|
|
|
2022-04-25 16:28:21 +02:00
|
|
|
const float width = (node.width - 6.0f) * U.dpi_fac;
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.type == NODE_FRAME) {
|
|
|
|
|
extra_info_rect.xmin = rct.xmin;
|
|
|
|
|
extra_info_rect.xmax = rct.xmin + 95.0f * U.dpi_fac;
|
|
|
|
|
extra_info_rect.ymin = rct.ymin + 2.0f * U.dpi_fac;
|
|
|
|
|
extra_info_rect.ymax = rct.ymin + 2.0f * U.dpi_fac;
|
2021-11-23 17:37:31 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2021-12-03 16:25:17 -05:00
|
|
|
extra_info_rect.xmin = rct.xmin + 3.0f * U.dpi_fac;
|
2022-04-25 16:28:21 +02:00
|
|
|
extra_info_rect.xmax = rct.xmin + width;
|
2021-12-03 16:25:17 -05:00
|
|
|
extra_info_rect.ymin = rct.ymax;
|
|
|
|
|
extra_info_rect.ymax = rct.ymax + extra_info_rows.size() * (20.0f * U.dpi_fac);
|
2021-11-23 17:37:31 +01:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & NODE_MUTED) {
|
2021-11-23 17:37:31 +01:00
|
|
|
UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.2f, color);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.75f, color);
|
|
|
|
|
}
|
|
|
|
|
color[3] -= 0.35f;
|
|
|
|
|
UI_draw_roundbox_corner_set(
|
|
|
|
|
UI_CNR_ALL & ~UI_CNR_BOTTOM_LEFT &
|
2021-12-03 16:25:17 -05:00
|
|
|
((rct.xmax) > extra_info_rect.xmax ? ~UI_CNR_BOTTOM_RIGHT : UI_CNR_ALL));
|
2021-11-23 17:37:31 +01:00
|
|
|
UI_draw_roundbox_4fv(&extra_info_rect, true, BASIS_RAD, color);
|
|
|
|
|
|
|
|
|
|
/* Draw outline. */
|
|
|
|
|
const float outline_width = 1.0f;
|
2021-12-03 16:25:17 -05:00
|
|
|
extra_info_rect.xmin = rct.xmin + 3.0f * U.dpi_fac - outline_width;
|
2022-04-25 16:28:21 +02:00
|
|
|
extra_info_rect.xmax = rct.xmin + width + outline_width;
|
2021-12-03 16:25:17 -05:00
|
|
|
extra_info_rect.ymin = rct.ymax - outline_width;
|
|
|
|
|
extra_info_rect.ymax = rct.ymax + outline_width + extra_info_rows.size() * (20.0f * U.dpi_fac);
|
2021-11-23 17:37:31 +01:00
|
|
|
|
|
|
|
|
UI_GetThemeColorBlendShade4fv(TH_BACK, TH_NODE, 0.4f, -20, color);
|
|
|
|
|
UI_draw_roundbox_corner_set(
|
|
|
|
|
UI_CNR_ALL & ~UI_CNR_BOTTOM_LEFT &
|
2021-12-03 16:25:17 -05:00
|
|
|
((rct.xmax) > extra_info_rect.xmax ? ~UI_CNR_BOTTOM_RIGHT : UI_CNR_ALL));
|
2021-11-23 17:37:31 +01:00
|
|
|
UI_draw_roundbox_4fv(&extra_info_rect, false, BASIS_RAD, color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int row : extra_info_rows.index_range()) {
|
2021-12-14 11:19:47 -06:00
|
|
|
node_draw_extra_info_row(node, block, extra_info_rect, row, extra_info_rows[row]);
|
2021-11-23 17:37:31 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
static void node_draw_basis(const bContext &C,
|
|
|
|
|
const View2D &v2d,
|
|
|
|
|
const SpaceNode &snode,
|
|
|
|
|
bNodeTree &ntree,
|
|
|
|
|
bNode &node,
|
2021-12-14 11:19:47 -06:00
|
|
|
uiBlock &block,
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeInstanceKey key)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2021-02-16 17:15:08 -06:00
|
|
|
const float iconbutw = NODE_HEADER_ICON_SIZE;
|
2020-09-08 17:19:58 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Skip if out of view. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (BLI_rctf_isect(&node.totr, &v2d.cur, nullptr) == false) {
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_end(&C, &block);
|
2010-06-14 07:02:11 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06: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
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
const rctf &rct = node.totr;
|
2020-09-08 17:19:58 +02:00
|
|
|
float color[4];
|
|
|
|
|
int color_id = node_get_colorid(node);
|
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
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
node_draw_extra_info_panel(snode, node, block);
|
2021-11-23 17:37:31 +01:00
|
|
|
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
/* Header. */
|
2021-02-16 10:55:10 -06:00
|
|
|
{
|
|
|
|
|
const rctf rect = {
|
2021-12-03 16:25:17 -05:00
|
|
|
rct.xmin,
|
|
|
|
|
rct.xmax,
|
|
|
|
|
rct.ymax - NODE_DY,
|
|
|
|
|
rct.ymax,
|
2021-02-16 10:55:10 -06:00
|
|
|
};
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
|
|
|
|
|
float color_header[4];
|
|
|
|
|
|
|
|
|
|
/* Muted nodes get a mix of the background with the node color. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & NODE_MUTED) {
|
2021-10-27 01:24:19 +02:00
|
|
|
UI_GetThemeColorBlend4f(TH_BACK, color_id, 0.1f, color_header);
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2021-10-27 01:24:19 +02:00
|
|
|
UI_GetThemeColorBlend4f(TH_NODE, color_id, 0.4f, color_header);
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
|
|
|
|
|
UI_draw_roundbox_4fv(&rect, true, BASIS_RAD, color_header);
|
2021-02-16 10:55:10 -06:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Show/hide icons. */
|
2021-12-03 16:25:17 -05:00
|
|
|
float iconofs = rct.xmax - 0.35f * U.widget_unit;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Preview. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.typeinfo->flag & NODE_PREVIEW) {
|
2012-07-09 19:58:36 +00:00
|
|
|
iconofs -= iconbutw;
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_emboss_set(&block, UI_EMBOSS_NONE);
|
|
|
|
|
uiBut *but = uiDefIconBut(&block,
|
2020-11-30 13:56:46 -05:00
|
|
|
UI_BTYPE_BUT_TOGGLE,
|
2021-02-24 14:53:37 -06:00
|
|
|
0,
|
2020-11-30 13:56:46 -05:00
|
|
|
ICON_MATERIAL,
|
|
|
|
|
iconofs,
|
2021-12-03 16:25:17 -05:00
|
|
|
rct.ymax - NODE_DY,
|
2020-11-30 13:56:46 -05:00
|
|
|
iconbutw,
|
|
|
|
|
UI_UNIT_Y,
|
2021-02-16 10:55:10 -06:00
|
|
|
nullptr,
|
2020-11-30 13:56:46 -05:00
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
"");
|
2021-12-03 16:25:17 -05: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).
|
2021-02-17 13:34:49 -06:00
|
|
|
* This can only work as visual indicator! */
|
2021-12-03 16:25:17 -05:00
|
|
|
// 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);
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_emboss_set(&block, UI_EMBOSS);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Group edit. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.type == NODE_GROUP) {
|
2012-07-09 19:58:36 +00:00
|
|
|
iconofs -= iconbutw;
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_emboss_set(&block, UI_EMBOSS_NONE);
|
|
|
|
|
uiBut *but = uiDefIconBut(&block,
|
2020-11-30 13:56:46 -05:00
|
|
|
UI_BTYPE_BUT_TOGGLE,
|
2021-02-24 14:53:37 -06:00
|
|
|
0,
|
2020-11-30 13:56:46 -05:00
|
|
|
ICON_NODETREE,
|
|
|
|
|
iconofs,
|
2021-12-03 16:25:17 -05:00
|
|
|
rct.ymax - NODE_DY,
|
2020-11-30 13:56:46 -05:00
|
|
|
iconbutw,
|
|
|
|
|
UI_UNIT_Y,
|
2021-02-16 10:55:10 -06:00
|
|
|
nullptr,
|
2020-11-30 13:56:46 -05:00
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
"");
|
2021-12-03 16:25:17 -05:00
|
|
|
UI_but_func_set(but, node_toggle_button_cb, &node, (void *)"NODE_OT_group_edit");
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_emboss_set(&block, UI_EMBOSS);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.type == NODE_CUSTOM && node.typeinfo->ui_icon != ICON_NONE) {
|
2020-03-16 18:25:23 +01:00
|
|
|
iconofs -= iconbutw;
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_emboss_set(&block, UI_EMBOSS_NONE);
|
|
|
|
|
uiDefIconBut(&block,
|
2020-03-16 18:25:23 +01:00
|
|
|
UI_BTYPE_BUT,
|
|
|
|
|
0,
|
2021-12-03 16:25:17 -05:00
|
|
|
node.typeinfo->ui_icon,
|
2020-03-16 18:25:23 +01:00
|
|
|
iconofs,
|
2021-12-03 16:25:17 -05:00
|
|
|
rct.ymax - NODE_DY,
|
2020-03-16 18:25:23 +01:00
|
|
|
iconbutw,
|
|
|
|
|
UI_UNIT_Y,
|
2021-02-16 10:55:10 -06:00
|
|
|
nullptr,
|
2020-03-16 18:25:23 +01:00
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
"");
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_emboss_set(&block, UI_EMBOSS);
|
2020-03-16 18:25:23 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
node_add_error_message_button(C, node, block, rct, iconofs);
|
2021-02-16 17:15:08 -06:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Title. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & SELECT) {
|
2017-02-14 13:00:22 +01:00
|
|
|
UI_GetThemeColor4fv(TH_SELECT, color);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
UI_GetThemeColorBlendShade4fv(TH_SELECT, color_id, 0.4f, 10, color);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
/* Collapse/expand icon. */
|
2011-12-18 12:51:50 +00:00
|
|
|
{
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
const int but_size = U.widget_unit * 0.8f;
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_emboss_set(&block, UI_EMBOSS_NONE);
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
uiBut *but = uiDefIconBut(&block,
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
UI_BTYPE_BUT_TOGGLE,
|
|
|
|
|
0,
|
|
|
|
|
ICON_DOWNARROW_HLT,
|
2021-12-03 16:25:17 -05:00
|
|
|
rct.xmin + (NODE_MARGIN_X / 3),
|
|
|
|
|
rct.ymax - NODE_DY / 2.2f - but_size / 2,
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
but_size,
|
|
|
|
|
but_size,
|
|
|
|
|
nullptr,
|
|
|
|
|
0.0f,
|
|
|
|
|
0.0f,
|
|
|
|
|
0.0f,
|
|
|
|
|
0.0f,
|
|
|
|
|
"");
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
UI_but_func_set(but, node_toggle_button_cb, &node, (void *)"NODE_OT_hide_toggle");
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_emboss_set(&block, UI_EMBOSS);
|
2011-12-18 12:51:50 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
char showname[128];
|
2021-12-03 16:25:17 -05:00
|
|
|
nodeLabel(&ntree, &node, showname, sizeof(showname));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
uiBut *but = uiDefBut(&block,
|
2019-03-28 17:39:54 +01:00
|
|
|
UI_BTYPE_LABEL,
|
|
|
|
|
0,
|
|
|
|
|
showname,
|
2021-12-03 16:25:17 -05:00
|
|
|
(int)(rct.xmin + NODE_MARGIN_X + 0.4f),
|
|
|
|
|
(int)(rct.ymax - NODE_DY),
|
|
|
|
|
(short)(iconofs - rct.xmin - (18.0f * U.dpi_fac)),
|
2019-03-28 17:39:54 +01:00
|
|
|
(short)NODE_DY,
|
2021-02-16 10:55:10 -06:00
|
|
|
nullptr,
|
2019-03-28 17:39:54 +01:00
|
|
|
0,
|
|
|
|
|
0,
|
2019-04-17 06:17:24 +02:00
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
"");
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & NODE_MUTED) {
|
2019-01-15 23:24:20 +11:00
|
|
|
UI_but_flag_enable(but, UI_BUT_INACTIVE);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
/* Wire across the node when muted/disabled. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & NODE_MUTED) {
|
2021-11-02 18:29:35 +02:00
|
|
|
node_draw_mute_line(C, v2d, snode, node);
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
}
|
|
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Body. */
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
const float outline_width = 1.0f;
|
|
|
|
|
{
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Use warning color to indicate undefined types. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (nodeTypeUndefined(&node)) {
|
2021-10-27 01:24:19 +02:00
|
|
|
UI_GetThemeColorBlend4f(TH_REDALERT, TH_NODE, 0.4f, color);
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
}
|
|
|
|
|
/* Muted nodes get a mix of the background with the node color. */
|
2021-12-03 16:25:17 -05:00
|
|
|
else if (node.flag & NODE_MUTED) {
|
2021-10-27 01:24:19 +02:00
|
|
|
UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.2f, color);
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
}
|
2021-12-03 16:25:17 -05:00
|
|
|
else if (node.flag & NODE_CUSTOM_COLOR) {
|
|
|
|
|
rgba_float_args_set(color, node.color[0], node.color[1], node.color[2], 1.0f);
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
UI_GetThemeColor4fv(TH_NODE, color);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
/* Draw selected nodes fully opaque. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & SELECT) {
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
color[3] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Draw muted nodes slightly transparent so the wires inside are visible. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & NODE_MUTED) {
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
color[3] -= 0.2f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const rctf rect = {
|
2021-12-03 16:25:17 -05:00
|
|
|
rct.xmin,
|
|
|
|
|
rct.xmax,
|
|
|
|
|
rct.ymin,
|
|
|
|
|
rct.ymax - (NODE_DY + outline_width),
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT);
|
|
|
|
|
UI_draw_roundbox_4fv(&rect, true, BASIS_RAD, color);
|
2019-03-28 17:39:54 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
/* Header underline. */
|
2021-02-16 10:55:10 -06:00
|
|
|
{
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
float color_underline[4];
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & NODE_MUTED) {
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
UI_GetThemeColor4fv(TH_WIRE, color_underline);
|
2022-09-01 19:46:19 +02:00
|
|
|
color_underline[3] = 1.0f;
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2021-10-27 04:33:12 +02:00
|
|
|
UI_GetThemeColorBlend4f(TH_BACK, color_id, 0.2f, color_underline);
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
}
|
|
|
|
|
|
2021-02-16 10:55:10 -06:00
|
|
|
const rctf rect = {
|
2021-12-03 16:25:17 -05:00
|
|
|
rct.xmin,
|
|
|
|
|
rct.xmax,
|
|
|
|
|
rct.ymax - (NODE_DY + outline_width),
|
|
|
|
|
rct.ymax - NODE_DY,
|
2021-02-16 10:55:10 -06:00
|
|
|
};
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
|
|
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_NONE);
|
|
|
|
|
UI_draw_roundbox_4fv(&rect, true, 0.0f, color_underline);
|
2021-02-16 10:55:10 -06:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
/* Outline. */
|
|
|
|
|
{
|
|
|
|
|
const rctf rect = {
|
2021-12-03 16:25:17 -05:00
|
|
|
rct.xmin - outline_width,
|
|
|
|
|
rct.xmax + outline_width,
|
|
|
|
|
rct.ymin - outline_width,
|
|
|
|
|
rct.ymax + outline_width,
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
/* Color the outline according to active, selected, or undefined status. */
|
|
|
|
|
float color_outline[4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & SELECT) {
|
|
|
|
|
UI_GetThemeColor4fv((node.flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, color_outline);
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
}
|
2021-12-03 16:25:17 -05:00
|
|
|
else if (nodeTypeUndefined(&node)) {
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
UI_GetThemeColor4fv(TH_REDALERT, color_outline);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
UI_GetThemeColorBlendShade4fv(TH_BACK, TH_NODE, 0.4f, -20, color_outline);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
2022-01-31 12:31:07 -05:00
|
|
|
UI_draw_roundbox_4fv(&rect, false, BASIS_RAD + outline_width, color_outline);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-11-18 21:21:10 +01:00
|
|
|
float scale;
|
2021-12-03 16:25:17 -05:00
|
|
|
UI_view2d_scale_get(&v2d, &scale, nullptr);
|
2021-11-18 21:21:10 +01:00
|
|
|
|
|
|
|
|
/* Skip slow socket drawing if zoom is small. */
|
|
|
|
|
if (scale > 0.2f) {
|
2021-12-14 11:19:47 -06:00
|
|
|
node_draw_sockets(v2d, C, ntree, node, block, true, false);
|
2021-11-18 21:21:10 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Preview. */
|
2021-12-03 16:25:17 -05:00
|
|
|
bNodeInstanceHash *previews =
|
|
|
|
|
(bNodeInstanceHash *)CTX_data_pointer_get(&C, "node_previews").data;
|
|
|
|
|
if (node.flag & NODE_PREVIEW && previews) {
|
2021-02-16 10:55:10 -06:00
|
|
|
bNodePreview *preview = (bNodePreview *)BKE_node_instance_hash_lookup(previews, key);
|
2013-09-07 06:56:27 +00:00
|
|
|
if (preview && (preview->xsize && preview->ysize)) {
|
2021-12-03 16:25:17 -05: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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_end(&C, &block);
|
|
|
|
|
UI_block_draw(&C, &block);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
static void node_draw_hidden(const bContext &C,
|
|
|
|
|
const View2D &v2d,
|
|
|
|
|
const SpaceNode &snode,
|
|
|
|
|
bNodeTree &ntree,
|
|
|
|
|
bNode &node,
|
|
|
|
|
uiBlock &block)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2021-12-03 16:25:17 -05:00
|
|
|
const rctf &rct = node.totr;
|
|
|
|
|
float centy = BLI_rctf_cent_y(&rct);
|
|
|
|
|
float hiddenrad = BLI_rctf_size_y(&rct) / 2.0f;
|
2020-09-08 17:19:58 +02:00
|
|
|
|
|
|
|
|
float scale;
|
2021-12-03 16:25:17 -05:00
|
|
|
UI_view2d_scale_get(&v2d, &scale, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
const int color_id = node_get_colorid(node);
|
|
|
|
|
|
2022-04-25 16:39:13 +02:00
|
|
|
node_draw_extra_info_panel(snode, node, block);
|
|
|
|
|
|
2021-02-17 13:34:49 -06: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
|
|
|
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
/* Wire across the node when muted/disabled. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & NODE_MUTED) {
|
2021-11-02 18:29:35 +02:00
|
|
|
node_draw_mute_line(C, v2d, snode, node);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
/* Body. */
|
|
|
|
|
float color[4];
|
|
|
|
|
{
|
2021-12-03 16:25:17 -05:00
|
|
|
if (nodeTypeUndefined(&node)) {
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
/* Use warning color to indicate undefined types. */
|
2021-10-27 01:24:19 +02:00
|
|
|
UI_GetThemeColorBlend4f(TH_REDALERT, TH_NODE, 0.4f, color);
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
}
|
2021-12-03 16:25:17 -05:00
|
|
|
else if (node.flag & NODE_MUTED) {
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
/* Muted nodes get a mix of the background with the node color. */
|
|
|
|
|
UI_GetThemeColorBlendShade4fv(TH_BACK, color_id, 0.1f, 0, color);
|
|
|
|
|
}
|
2021-12-03 16:25:17 -05:00
|
|
|
else if (node.flag & NODE_CUSTOM_COLOR) {
|
|
|
|
|
rgba_float_args_set(color, node.color[0], node.color[1], node.color[2], 1.0f);
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2021-10-27 01:24:19 +02:00
|
|
|
UI_GetThemeColorBlend4f(TH_NODE, color_id, 0.4f, color);
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
/* Draw selected nodes fully opaque. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & SELECT) {
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
color[3] = 1.0f;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
/* Draw muted nodes slightly transparent so the wires inside are visible. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & NODE_MUTED) {
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
color[3] -= 0.2f;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
UI_draw_roundbox_4fv(&rct, true, hiddenrad, color);
|
2013-03-22 13:53:58 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Title. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & SELECT) {
|
2017-02-14 13:00:22 +01:00
|
|
|
UI_GetThemeColor4fv(TH_SELECT, color);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
UI_GetThemeColorBlendShade4fv(TH_SELECT, color_id, 0.4f, 10, color);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
/* Collapse/expand icon. */
|
2011-12-18 12:51:50 +00:00
|
|
|
{
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
const int but_size = U.widget_unit * 1.0f;
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_emboss_set(&block, UI_EMBOSS_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
uiBut *but = uiDefIconBut(&block,
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
UI_BTYPE_BUT_TOGGLE,
|
|
|
|
|
0,
|
|
|
|
|
ICON_RIGHTARROW,
|
2021-12-03 16:25:17 -05:00
|
|
|
rct.xmin + (NODE_MARGIN_X / 3),
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
centy - but_size / 2,
|
|
|
|
|
but_size,
|
|
|
|
|
but_size,
|
|
|
|
|
nullptr,
|
|
|
|
|
0.0f,
|
|
|
|
|
0.0f,
|
|
|
|
|
0.0f,
|
|
|
|
|
0.0f,
|
|
|
|
|
"");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
UI_but_func_set(but, node_toggle_button_cb, &node, (void *)"NODE_OT_hide_toggle");
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_emboss_set(&block, UI_EMBOSS);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
char showname[128];
|
2021-12-03 16:25:17 -05:00
|
|
|
nodeLabel(&ntree, &node, showname, sizeof(showname));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
uiBut *but = uiDefBut(&block,
|
2019-04-02 16:39:48 +02:00
|
|
|
UI_BTYPE_LABEL,
|
|
|
|
|
0,
|
|
|
|
|
showname,
|
2021-12-03 16:25:17 -05:00
|
|
|
round_fl_to_int(rct.xmin + NODE_MARGIN_X),
|
2019-04-02 16:39:48 +02:00
|
|
|
round_fl_to_int(centy - NODE_DY * 0.5f),
|
2021-12-03 16:25:17 -05: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,
|
2021-02-16 10:55:10 -06:00
|
|
|
nullptr,
|
2019-04-02 16:39:48 +02:00
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
"");
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
|
|
|
|
|
/* Outline. */
|
|
|
|
|
{
|
|
|
|
|
const float outline_width = 1.0f;
|
|
|
|
|
const rctf rect = {
|
2021-12-03 16:25:17 -05:00
|
|
|
rct.xmin - outline_width,
|
|
|
|
|
rct.xmax + outline_width,
|
|
|
|
|
rct.ymin - outline_width,
|
|
|
|
|
rct.ymax + outline_width,
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Color the outline according to active, selected, or undefined status. */
|
|
|
|
|
float color_outline[4];
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & SELECT) {
|
|
|
|
|
UI_GetThemeColor4fv((node.flag & NODE_ACTIVE) ? TH_ACTIVE : TH_SELECT, color_outline);
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
}
|
2021-12-03 16:25:17 -05:00
|
|
|
else if (nodeTypeUndefined(&node)) {
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
UI_GetThemeColor4fv(TH_REDALERT, color_outline);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
UI_GetThemeColorBlendShade4fv(TH_BACK, TH_NODE, 0.4f, -20, color_outline);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
|
|
|
|
UI_draw_roundbox_4fv(&rect, false, hiddenrad, color_outline);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node.flag & NODE_MUTED) {
|
2019-04-02 16:39:48 +02:00
|
|
|
UI_but_flag_enable(but, UI_BUT_INACTIVE);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06: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);
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2017-03-06 20:29:09 -03:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
immUniformThemeColorShadeAlpha(TH_TEXT, -40, -180);
|
2021-11-03 16:50:43 +01:00
|
|
|
float dx = 0.5f * U.widget_unit;
|
2021-12-03 16:25:17 -05:00
|
|
|
const float dx2 = 0.15f * U.widget_unit * snode.runtime->aspect;
|
2021-11-03 16:50:43 +01:00
|
|
|
const float dy = 0.2f * U.widget_unit;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 4);
|
2021-12-03 16:25:17 -05:00
|
|
|
immVertex2f(pos, rct.xmax - dx, centy - dy);
|
|
|
|
|
immVertex2f(pos, rct.xmax - dx, centy + dy);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
immVertex2f(pos, rct.xmax - dx - dx2, centy - dy);
|
|
|
|
|
immVertex2f(pos, rct.xmax - dx - dx2, centy + dy);
|
2017-03-06 20:29:09 -03:00
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
immUniformThemeColorShadeAlpha(TH_TEXT, 0, -180);
|
2021-12-03 16:25:17 -05: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);
|
2021-12-03 16:25:17 -05:00
|
|
|
immVertex2f(pos, rct.xmax - dx, centy - dy);
|
|
|
|
|
immVertex2f(pos, rct.xmax - dx, centy + dy);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
immVertex2f(pos, rct.xmax - dx - dx2, centy - dy);
|
|
|
|
|
immVertex2f(pos, rct.xmax - dx - dx2, centy + dy);
|
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();
|
Node Editor: Style update to nodes
This patch changes how nodes look visually, in an attempt to fix a number of issues:
* The header background is currently drawn using a theme color fully opaque, this limits the colors we can use because the node name/label is drawn on top.
* Hard-coded transparency makes nodes hard to read. The node backdrop already has alpha so if the user wants it they can set it. This patch uses alpha from the theme.
* Better muted status indicator, instead of simply making everything transparent and the wires inside red, draw a red outline around the node, darken the header and backdrop.
* On muted nodes, display wires behind the backdrop to not interfere with text/widgets inside the node.
Nodes:
* Darken header to improve readability of node label.
* Draw a line under the header
* Thicker outline.
* Do not hard-code transparency on nodes, use the theme's node backdrop alpha component.
* Use angle icon instead of triangle (to be consistent with the [[ https://developer.blender.org/D12814 | changes ]] to panels)
Style adjustment to sockets drawing:
* Do not hard-code the socket outline color to black, use `TH_WIRE` instead
* Do not use `TH_TEXT_HI` for selected sockets, use `TH_ACTIVE` (active node outline)
* Do not draw sockets background transparent on muted nodes.
* Thicker outline to help contrast and readability
{F11496707, size=full}
Reviewed By: #user_interface, HooglyBoogly
Differential Revision: https://developer.blender.org/D12884
2021-10-26 20:07:26 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
node_draw_sockets(v2d, C, ntree, node, block, true, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_end(&C, &block);
|
|
|
|
|
UI_block_draw(&C, &block);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-03 11:05:59 -05:00
|
|
|
int node_get_resize_cursor(NodeResizeDirection directions)
|
2012-05-22 14:13:33 +00:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
void node_set_cursor(wmWindow &win, SpaceNode &snode, const float2 &cursor)
|
2012-05-22 14:13:33 +00:00
|
|
|
{
|
2021-12-03 16:25:17 -05:00
|
|
|
const bNodeTree *ntree = snode.edittree;
|
|
|
|
|
if (ntree == nullptr) {
|
|
|
|
|
WM_cursor_set(&win, WM_CURSOR_DEFAULT);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
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
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node_find_indicated_socket(
|
|
|
|
|
snode, &node, &sock, cursor, (eNodeSocketInOut)(SOCK_IN | SOCK_OUT))) {
|
|
|
|
|
WM_cursor_set(&win, WM_CURSOR_DEFAULT);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check nodes front to back. */
|
|
|
|
|
for (node = (bNode *)ntree->nodes.last; node; node = node->prev) {
|
|
|
|
|
if (BLI_rctf_isect_pt(&node->totr, cursor[0], cursor[1])) {
|
|
|
|
|
break; /* First hit on node stops. */
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
2021-12-03 16:25:17 -05:00
|
|
|
if (node) {
|
2021-12-05 16:45:41 -05:00
|
|
|
NodeResizeDirection dir = node_get_resize_direction(node, cursor[0], cursor[1]);
|
2021-12-03 16:25:17 -05:00
|
|
|
wmcursor = node_get_resize_cursor(dir);
|
2022-01-05 12:32:00 +01:00
|
|
|
/* We want to indicate that Frame nodes can be moved/selected on their borders. */
|
|
|
|
|
if (node->type == NODE_FRAME && dir == NODE_RESIZE_NONE) {
|
|
|
|
|
const rctf frame_inside = node_frame_rect_inside(*node);
|
|
|
|
|
if (!BLI_rctf_isect_pt(&frame_inside, cursor[0], cursor[1])) {
|
|
|
|
|
wmcursor = WM_CURSOR_NSEW_SCROLL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-03 16:25:17 -05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
WM_cursor_set(&win, wmcursor);
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
static void count_multi_input_socket_links(bNodeTree &ntree, SpaceNode &snode)
|
2021-02-11 01:16:17 -06:00
|
|
|
{
|
2021-06-14 10:04:32 +02:00
|
|
|
Map<bNodeSocket *, int> counts;
|
2021-12-03 16:25:17 -05:00
|
|
|
LISTBASE_FOREACH (bNodeLink *, link, &ntree.links) {
|
2021-06-14 10:04:32 +02:00
|
|
|
if (link->tosock->flag & SOCK_MULTI_INPUT) {
|
|
|
|
|
int &count = counts.lookup_or_add(link->tosock, 0);
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* Count temporary links going into this socket. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (snode.runtime->linkdrag) {
|
|
|
|
|
for (const bNodeLink *link : snode.runtime->linkdrag->links) {
|
2021-06-14 10:04:32 +02:00
|
|
|
if (link->tosock && (link->tosock->flag & SOCK_MULTI_INPUT)) {
|
|
|
|
|
int &count = counts.lookup_or_add(link->tosock, 0);
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-19 15:36:32 -05:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
LISTBASE_FOREACH (bNode *, node, &ntree.nodes) {
|
2021-06-14 10:04:32 +02:00
|
|
|
LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
|
2021-02-11 01:16:17 -06:00
|
|
|
if (socket->flag & SOCK_MULTI_INPUT) {
|
2021-06-14 10:04:32 +02:00
|
|
|
socket->total_inputs = counts.lookup_default(socket, 0);
|
2021-02-11 01:16:17 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-05 16:45:41 -05:00
|
|
|
/* XXX Does a bounding box update by iterating over all children.
|
|
|
|
|
* Not ideal to do this in every draw call, but doing as transform callback doesn't work,
|
2021-12-14 12:16:28 -06:00
|
|
|
* since the child node totr rects are not updated properly at that point. */
|
|
|
|
|
static void frame_node_prepare_for_draw(bNode &node, Span<bNode *> nodes)
|
2021-12-05 16:45:41 -05:00
|
|
|
{
|
|
|
|
|
const float margin = 1.5f * U.widget_unit;
|
|
|
|
|
NodeFrame *data = (NodeFrame *)node.storage;
|
|
|
|
|
|
|
|
|
|
/* init rect from current frame size */
|
|
|
|
|
rctf rect;
|
2021-12-08 09:44:02 -05:00
|
|
|
node_to_updated_rect(node, rect);
|
2021-12-05 16:45:41 -05:00
|
|
|
|
|
|
|
|
/* frame can be resized manually only if shrinking is disabled or no children are attached */
|
|
|
|
|
data->flag |= NODE_FRAME_RESIZEABLE;
|
|
|
|
|
/* for shrinking bbox, initialize the rect from first child node */
|
|
|
|
|
bool bbinit = (data->flag & NODE_FRAME_SHRINK);
|
|
|
|
|
/* fit bounding box to all children */
|
2021-12-14 11:19:47 -06:00
|
|
|
for (const bNode *tnode : nodes) {
|
2021-12-05 16:45:41 -05:00
|
|
|
if (tnode->parent != &node) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* add margin to node rect */
|
|
|
|
|
rctf noderect = tnode->totr;
|
|
|
|
|
noderect.xmin -= margin;
|
|
|
|
|
noderect.xmax += margin;
|
|
|
|
|
noderect.ymin -= margin;
|
|
|
|
|
noderect.ymax += margin;
|
|
|
|
|
|
|
|
|
|
/* first child initializes frame */
|
|
|
|
|
if (bbinit) {
|
|
|
|
|
bbinit = false;
|
|
|
|
|
rect = noderect;
|
|
|
|
|
data->flag &= ~NODE_FRAME_RESIZEABLE;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_rctf_union(&rect, &noderect);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* now adjust the frame size from view-space bounding box */
|
2021-12-08 09:44:02 -05:00
|
|
|
const float2 offset = node_from_view(node, {rect.xmin, rect.ymax});
|
|
|
|
|
node.offsetx = offset.x;
|
|
|
|
|
node.offsety = offset.y;
|
|
|
|
|
const float2 max = node_from_view(node, {rect.xmax, rect.ymin});
|
|
|
|
|
node.width = max.x - node.offsetx;
|
|
|
|
|
node.height = -max.y + node.offsety;
|
2021-12-05 16:45:41 -05:00
|
|
|
|
|
|
|
|
node.totr = rect;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void reroute_node_prepare_for_draw(bNode &node)
|
|
|
|
|
{
|
|
|
|
|
/* get "global" coords */
|
2021-12-08 09:44:02 -05:00
|
|
|
const float2 loc = node_to_view(node, float2(0));
|
2021-12-05 16:45:41 -05:00
|
|
|
|
|
|
|
|
/* reroute node has exactly one input and one output, both in the same place */
|
|
|
|
|
bNodeSocket *nsock = (bNodeSocket *)node.outputs.first;
|
2021-12-08 09:44:02 -05:00
|
|
|
nsock->locx = loc.x;
|
|
|
|
|
nsock->locy = loc.y;
|
2021-12-05 16:45:41 -05:00
|
|
|
|
|
|
|
|
nsock = (bNodeSocket *)node.inputs.first;
|
2021-12-08 09:44:02 -05:00
|
|
|
nsock->locx = loc.x;
|
|
|
|
|
nsock->locy = loc.y;
|
2021-12-05 16:45:41 -05:00
|
|
|
|
|
|
|
|
const float size = 8.0f;
|
|
|
|
|
node.width = size * 2;
|
2021-12-08 09:44:02 -05:00
|
|
|
node.totr.xmin = loc.x - size;
|
|
|
|
|
node.totr.xmax = loc.x + size;
|
|
|
|
|
node.totr.ymax = loc.y + size;
|
|
|
|
|
node.totr.ymin = loc.y - size;
|
2021-12-05 16:45:41 -05:00
|
|
|
}
|
|
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
static void node_update_nodetree(const bContext &C,
|
|
|
|
|
bNodeTree &ntree,
|
|
|
|
|
Span<bNode *> nodes,
|
|
|
|
|
Span<uiBlock *> blocks)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Make sure socket "used" tags are correct, for displaying value buttons. */
|
2021-12-03 16:25:17 -05:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(&C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
count_multi_input_socket_links(ntree, *snode);
|
2021-02-11 01:16:17 -06:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Update nodes front to back, so children sizes get updated before parents. */
|
2021-12-14 11:19:47 -06:00
|
|
|
for (const int i : nodes.index_range()) {
|
|
|
|
|
bNode &node = *nodes[i];
|
|
|
|
|
uiBlock &block = *blocks[i];
|
|
|
|
|
if (node.type == NODE_FRAME) {
|
2021-12-18 13:27:05 -06:00
|
|
|
/* Frame sizes are calculated after all other nodes have calculating their #totr. */
|
|
|
|
|
continue;
|
2021-12-05 16:45:41 -05:00
|
|
|
}
|
2021-12-18 13:27:05 -06:00
|
|
|
|
|
|
|
|
if (node.type == NODE_REROUTE) {
|
2021-12-14 11:19:47 -06:00
|
|
|
reroute_node_prepare_for_draw(node);
|
2021-12-05 16:45:41 -05:00
|
|
|
}
|
|
|
|
|
else {
|
2021-12-14 11:19:47 -06:00
|
|
|
if (node.flag & NODE_HIDDEN) {
|
|
|
|
|
node_update_hidden(node, block);
|
2021-12-05 16:45:41 -05:00
|
|
|
}
|
|
|
|
|
else {
|
2021-12-14 11:19:47 -06:00
|
|
|
node_update_basis(C, ntree, node, block);
|
2021-12-05 16:45:41 -05:00
|
|
|
}
|
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2021-12-18 13:27:05 -06:00
|
|
|
|
|
|
|
|
/* Now calculate the size of frame nodes, which can depend on the size of other nodes. */
|
|
|
|
|
for (const int i : nodes.index_range()) {
|
|
|
|
|
if (nodes[i]->type == NODE_FRAME) {
|
|
|
|
|
frame_node_prepare_for_draw(*nodes[i], nodes);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-11 09:51:53 -06:00
|
|
|
static void frame_node_draw_label(const bNodeTree &ntree,
|
|
|
|
|
const bNode &node,
|
|
|
|
|
const SpaceNode &snode)
|
2021-12-05 17:12:25 -05:00
|
|
|
{
|
|
|
|
|
const float aspect = snode.runtime->aspect;
|
|
|
|
|
/* XXX font id is crap design */
|
|
|
|
|
const int fontid = UI_style_get()->widgetlabel.uifont_id;
|
2021-12-11 09:51:53 -06:00
|
|
|
const NodeFrame *data = (const NodeFrame *)node.storage;
|
2021-12-05 17:12:25 -05:00
|
|
|
const float font_size = data->label_size / aspect;
|
|
|
|
|
|
|
|
|
|
char label[MAX_NAME];
|
|
|
|
|
nodeLabel(&ntree, &node, label, sizeof(label));
|
|
|
|
|
|
|
|
|
|
BLF_enable(fontid, BLF_ASPECT);
|
|
|
|
|
BLF_aspect(fontid, aspect, aspect, 1.0f);
|
|
|
|
|
/* clamp otherwise it can suck up a LOT of memory */
|
2022-05-30 19:19:07 +02:00
|
|
|
BLF_size(fontid, MIN2(24.0f, font_size) * U.pixelsize, U.dpi);
|
2021-12-05 17:12:25 -05:00
|
|
|
|
|
|
|
|
/* title color */
|
|
|
|
|
int color_id = node_get_colorid(node);
|
|
|
|
|
uchar color[3];
|
|
|
|
|
UI_GetThemeColorBlendShade3ubv(TH_TEXT, color_id, 0.4f, 10, color);
|
|
|
|
|
BLF_color3ubv(fontid, color);
|
|
|
|
|
|
|
|
|
|
const float margin = (float)(NODE_DY / 4);
|
|
|
|
|
const float width = BLF_width(fontid, label, sizeof(label));
|
|
|
|
|
const float ascender = BLF_ascender(fontid);
|
|
|
|
|
const int label_height = ((margin / aspect) + (ascender * aspect));
|
|
|
|
|
|
|
|
|
|
/* 'x' doesn't need aspect correction */
|
|
|
|
|
const rctf &rct = node.totr;
|
|
|
|
|
/* XXX a bit hacky, should use separate align values for x and y */
|
|
|
|
|
float x = BLI_rctf_cent_x(&rct) - (0.5f * width);
|
|
|
|
|
float y = rct.ymax - label_height;
|
|
|
|
|
|
|
|
|
|
/* label */
|
|
|
|
|
const bool has_label = node.label[0] != '\0';
|
|
|
|
|
if (has_label) {
|
|
|
|
|
BLF_position(fontid, x, y, 0);
|
2022-01-12 12:49:36 +01:00
|
|
|
BLF_draw(fontid, label, sizeof(label));
|
2021-12-05 17:12:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* draw text body */
|
|
|
|
|
if (node.id) {
|
2021-12-11 09:51:53 -06:00
|
|
|
const Text *text = (const Text *)node.id;
|
2021-12-05 17:12:25 -05:00
|
|
|
const int line_height_max = BLF_height_max(fontid);
|
|
|
|
|
const float line_spacing = (line_height_max * aspect);
|
|
|
|
|
const float line_width = (BLI_rctf_size_x(&rct) - margin) / aspect;
|
|
|
|
|
|
|
|
|
|
/* 'x' doesn't need aspect correction */
|
|
|
|
|
x = rct.xmin + margin;
|
|
|
|
|
y = rct.ymax - label_height - (has_label ? line_spacing : 0);
|
|
|
|
|
|
|
|
|
|
/* early exit */
|
|
|
|
|
int y_min = y + ((margin * 2) - (y - rct.ymin));
|
|
|
|
|
|
|
|
|
|
BLF_enable(fontid, BLF_CLIPPING | BLF_WORD_WRAP);
|
|
|
|
|
BLF_clipping(fontid,
|
|
|
|
|
rct.xmin,
|
|
|
|
|
/* round to avoid clipping half-way through a line */
|
|
|
|
|
y - (floorf(((y - rct.ymin) - (margin * 2)) / line_spacing) * line_spacing),
|
|
|
|
|
rct.xmin + line_width,
|
|
|
|
|
rct.ymax);
|
|
|
|
|
|
|
|
|
|
BLF_wordwrap(fontid, line_width);
|
|
|
|
|
|
2021-12-11 09:51:53 -06:00
|
|
|
LISTBASE_FOREACH (const TextLine *, line, &text->lines) {
|
2021-12-05 17:12:25 -05:00
|
|
|
struct ResultBLF info;
|
|
|
|
|
if (line->line[0]) {
|
|
|
|
|
BLF_position(fontid, x, y, 0);
|
|
|
|
|
BLF_draw_ex(fontid, line->line, line->len, &info);
|
|
|
|
|
y -= line_spacing * info.lines;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
y -= line_spacing;
|
|
|
|
|
}
|
|
|
|
|
if (y < y_min) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLF_disable(fontid, BLF_CLIPPING | BLF_WORD_WRAP);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLF_disable(fontid, BLF_ASPECT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void frame_node_draw(const bContext &C,
|
|
|
|
|
const ARegion ®ion,
|
|
|
|
|
const SpaceNode &snode,
|
|
|
|
|
bNodeTree &ntree,
|
2021-12-14 11:19:47 -06:00
|
|
|
bNode &node,
|
|
|
|
|
uiBlock &block)
|
2021-12-05 17:12:25 -05:00
|
|
|
{
|
|
|
|
|
/* skip if out of view */
|
|
|
|
|
if (BLI_rctf_isect(&node.totr, ®ion.v2d.cur, nullptr) == false) {
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_end(&C, &block);
|
2021-12-05 17:12:25 -05:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float color[4];
|
|
|
|
|
UI_GetThemeColor4fv(TH_NODE_FRAME, color);
|
|
|
|
|
const float alpha = color[3];
|
|
|
|
|
|
|
|
|
|
/* shadow */
|
|
|
|
|
node_draw_shadow(snode, node, BASIS_RAD, alpha);
|
|
|
|
|
|
|
|
|
|
/* body */
|
|
|
|
|
if (node.flag & NODE_CUSTOM_COLOR) {
|
|
|
|
|
rgba_float_args_set(color, node.color[0], node.color[1], node.color[2], alpha);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
UI_GetThemeColor4fv(TH_NODE_FRAME, color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const rctf &rct = node.totr;
|
|
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
|
|
|
|
UI_draw_roundbox_4fv(&rct, true, BASIS_RAD, color);
|
|
|
|
|
|
|
|
|
|
/* outline active and selected emphasis */
|
|
|
|
|
if (node.flag & SELECT) {
|
|
|
|
|
if (node.flag & NODE_ACTIVE) {
|
|
|
|
|
UI_GetThemeColorShadeAlpha4fv(TH_ACTIVE, 0, -40, color);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
UI_GetThemeColorShadeAlpha4fv(TH_SELECT, 0, -40, color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UI_draw_roundbox_aa(&rct, false, BASIS_RAD, color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* label and text */
|
|
|
|
|
frame_node_draw_label(ntree, node, snode);
|
|
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
node_draw_extra_info_panel(snode, node, block);
|
2021-12-05 17:12:25 -05:00
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_end(&C, &block);
|
|
|
|
|
UI_block_draw(&C, &block);
|
2021-12-05 17:12:25 -05:00
|
|
|
}
|
|
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
static void reroute_node_draw(
|
|
|
|
|
const bContext &C, ARegion ®ion, bNodeTree &ntree, bNode &node, uiBlock &block)
|
2021-12-05 17:12:25 -05:00
|
|
|
{
|
|
|
|
|
char showname[128]; /* 128 used below */
|
|
|
|
|
const rctf &rct = node.totr;
|
|
|
|
|
|
|
|
|
|
/* skip if out of view */
|
|
|
|
|
if (rct.xmax < region.v2d.cur.xmin || rct.xmin > region.v2d.cur.xmax ||
|
|
|
|
|
rct.ymax < region.v2d.cur.ymin || node.totr.ymin > region.v2d.cur.ymax) {
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_end(&C, &block);
|
2021-12-05 17:12:25 -05:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (node.label[0] != '\0') {
|
|
|
|
|
/* draw title (node label) */
|
|
|
|
|
BLI_strncpy(showname, node.label, sizeof(showname));
|
2022-03-29 23:39:50 +02:00
|
|
|
const short width = 512;
|
|
|
|
|
const int x = BLI_rctf_cent_x(&node.totr) - (width / 2);
|
|
|
|
|
const int y = node.totr.ymax;
|
|
|
|
|
|
2022-04-05 07:51:48 +10:00
|
|
|
uiBut *label_but = uiDefBut(&block,
|
|
|
|
|
UI_BTYPE_LABEL,
|
|
|
|
|
0,
|
|
|
|
|
showname,
|
|
|
|
|
x,
|
|
|
|
|
y,
|
|
|
|
|
width,
|
|
|
|
|
(short)NODE_DY,
|
|
|
|
|
nullptr,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
nullptr);
|
2022-03-29 23:39:50 +02:00
|
|
|
|
|
|
|
|
UI_but_drawflag_disable(label_but, UI_BUT_TEXT_LEFT);
|
2021-12-05 17:12:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* only draw input socket. as they all are placed on the same position.
|
|
|
|
|
* highlight also if node itself is selected, since we don't display the node body separately!
|
|
|
|
|
*/
|
2021-12-14 11:19:47 -06:00
|
|
|
node_draw_sockets(region.v2d, C, ntree, node, block, false, node.flag & SELECT);
|
2021-12-05 17:12:25 -05:00
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
UI_block_end(&C, &block);
|
|
|
|
|
UI_block_draw(&C, &block);
|
2021-12-05 17:12:25 -05:00
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
static void node_draw(const bContext &C,
|
|
|
|
|
ARegion ®ion,
|
2021-12-05 17:12:25 -05:00
|
|
|
const SpaceNode &snode,
|
2021-12-03 16:25:17 -05:00
|
|
|
bNodeTree &ntree,
|
|
|
|
|
bNode &node,
|
2021-12-14 11:19:47 -06:00
|
|
|
uiBlock &block,
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeInstanceKey key)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2021-12-05 17:12:25 -05:00
|
|
|
if (node.type == NODE_FRAME) {
|
2021-12-14 11:19:47 -06:00
|
|
|
frame_node_draw(C, region, snode, ntree, node, block);
|
2021-12-05 17:12:25 -05:00
|
|
|
}
|
|
|
|
|
else if (node.type == NODE_REROUTE) {
|
2021-12-14 11:19:47 -06:00
|
|
|
reroute_node_draw(C, region, ntree, node, block);
|
2021-12-05 17:12:25 -05:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
const View2D &v2d = region.v2d;
|
|
|
|
|
if (node.flag & NODE_HIDDEN) {
|
2021-12-14 11:19:47 -06:00
|
|
|
node_draw_hidden(C, v2d, snode, ntree, node, block);
|
2021-12-05 17:12:25 -05:00
|
|
|
}
|
|
|
|
|
else {
|
2021-12-14 11:19:47 -06:00
|
|
|
node_draw_basis(C, v2d, snode, ntree, node, block, key);
|
2021-12-05 17:12:25 -05:00
|
|
|
}
|
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
|
|
|
|
|
|
2021-12-05 17:12:25 -05:00
|
|
|
static void node_draw_nodetree(const bContext &C,
|
|
|
|
|
ARegion ®ion,
|
|
|
|
|
SpaceNode &snode,
|
|
|
|
|
bNodeTree &ntree,
|
2021-12-14 11:19:47 -06:00
|
|
|
Span<bNode *> nodes,
|
|
|
|
|
Span<uiBlock *> blocks,
|
2021-12-05 17:12:25 -05:00
|
|
|
bNodeInstanceKey parent_key)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2012-08-12 19:35:47 +00:00
|
|
|
#ifdef USE_DRAW_TOT_UPDATE
|
2021-12-14 11:19:47 -06:00
|
|
|
BLI_rctf_init_minmax(®ion.v2d.tot);
|
2012-08-12 19:35:47 +00:00
|
|
|
#endif
|
|
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Draw background nodes, last nodes in front. */
|
2021-12-14 11:19:47 -06:00
|
|
|
for (const int i : nodes.index_range()) {
|
2012-08-12 19:35:47 +00:00
|
|
|
#ifdef USE_DRAW_TOT_UPDATE
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Unrelated to background nodes, update the v2d->tot,
|
|
|
|
|
* can be anywhere before we draw the scroll bars. */
|
2021-12-14 11:19:47 -06:00
|
|
|
BLI_rctf_union(®ion.v2d.tot, &nodes[i]->totr);
|
2012-08-12 19:35:47 +00:00
|
|
|
#endif
|
|
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
if (!(nodes[i]->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
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
bNodeInstanceKey key = BKE_node_instance_key(parent_key, &ntree, nodes[i]);
|
|
|
|
|
node_draw(C, region, snode, ntree, *nodes[i], *blocks[i], key);
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06: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);
|
2021-02-11 01:16:17 -06:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
LISTBASE_FOREACH (bNodeLink *, link, &ntree.links) {
|
2022-02-28 15:52:00 -05:00
|
|
|
if (!nodeLinkIsHidden(link) && !nodeLinkIsSelected(link)) {
|
|
|
|
|
node_draw_link(C, region.v2d, snode, *link, false);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
2022-02-28 15:52:00 -05:00
|
|
|
|
|
|
|
|
/* Draw selected node links after the unselected ones, so they are shown on top. */
|
|
|
|
|
LISTBASE_FOREACH (bNodeLink *, link, &ntree.links) {
|
|
|
|
|
if (!nodeLinkIsHidden(link) && nodeLinkIsSelected(link)) {
|
|
|
|
|
node_draw_link(C, region.v2d, snode, *link, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-28 18:05:12 -05: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
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Draw foreground nodes, last nodes in front. */
|
2021-12-14 11:19:47 -06:00
|
|
|
for (const int i : nodes.index_range()) {
|
|
|
|
|
if (nodes[i]->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
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
bNodeInstanceKey key = BKE_node_instance_key(parent_key, &ntree, nodes[i]);
|
|
|
|
|
node_draw(C, region, snode, ntree, *nodes[i], *blocks[i], key);
|
2011-02-21 13:47:49 +00:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-26 11:05:01 -05:00
|
|
|
/* Draw the breadcrumb on the bottom of the editor. */
|
|
|
|
|
static void draw_tree_path(const bContext &C, ARegion ®ion)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
2021-10-26 11:05:01 -05:00
|
|
|
using namespace blender;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-10-26 11:05:01 -05:00
|
|
|
GPU_matrix_push_projection();
|
|
|
|
|
wmOrtho2_region_pixelspace(®ion);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-10-26 11:05:01 -05:00
|
|
|
const rcti *rect = ED_region_visible_rect(®ion);
|
|
|
|
|
|
|
|
|
|
const uiStyle *style = UI_style_get_dpi();
|
|
|
|
|
const float padding_x = 16 * UI_DPI_FAC;
|
|
|
|
|
const int x = rect->xmin + padding_x;
|
|
|
|
|
const int y = region.winy - UI_UNIT_Y * 0.6f;
|
|
|
|
|
const int width = BLI_rcti_size_x(rect) - 2 * padding_x;
|
|
|
|
|
|
|
|
|
|
uiBlock *block = UI_block_begin(&C, ®ion, __func__, UI_EMBOSS_NONE);
|
|
|
|
|
uiLayout *layout = UI_block_layout(
|
|
|
|
|
block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y, width, 1, 0, style);
|
|
|
|
|
|
|
|
|
|
Vector<ui::ContextPathItem> context_path = ed::space_node::context_path_for_space_node(C);
|
|
|
|
|
ui::template_breadcrumbs(*layout, context_path);
|
|
|
|
|
|
|
|
|
|
UI_block_layout_resolve(block, nullptr, nullptr);
|
|
|
|
|
UI_block_end(&C, block);
|
|
|
|
|
UI_block_draw(&C, block);
|
|
|
|
|
|
|
|
|
|
GPU_matrix_pop_projection();
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
static void snode_setup_v2d(SpaceNode &snode, ARegion ®ion, const float2 ¢er)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
2021-12-03 16:25:17 -05:00
|
|
|
View2D &v2d = region.v2d;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Shift view to node tree center. */
|
2021-12-03 16:25:17 -05:00
|
|
|
UI_view2d_center_set(&v2d, center[0], center[1]);
|
|
|
|
|
UI_view2d_view_ortho(&v2d);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Aspect + font, set each time. */
|
2021-12-03 16:25:17 -05: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);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
static void draw_nodetree(const bContext &C,
|
|
|
|
|
ARegion ®ion,
|
|
|
|
|
bNodeTree &ntree,
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeInstanceKey parent_key)
|
|
|
|
|
{
|
2021-12-03 16:25:17 -05:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(&C);
|
2017-05-15 13:47:48 +02:00
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
Vector<bNode *> nodes = ntree.nodes;
|
|
|
|
|
|
|
|
|
|
Array<uiBlock *> blocks = node_uiblocks_init(C, nodes);
|
2017-05-15 13:47:48 +02:00
|
|
|
|
2021-12-14 11:19:47 -06:00
|
|
|
node_update_nodetree(C, ntree, nodes, blocks);
|
|
|
|
|
node_draw_nodetree(C, region, *snode, ntree, nodes, blocks, parent_key);
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-08 11:43:52 +02:00
|
|
|
/**
|
2021-10-12 17:52:35 +11:00
|
|
|
* Make the background slightly brighter to indicate that users are inside a node-group.
|
2021-10-08 16:01:49 +02:00
|
|
|
*/
|
2021-12-03 16:25:17 -05:00
|
|
|
static void draw_background_color(const SpaceNode &snode)
|
2021-10-08 11:43:52 +02:00
|
|
|
{
|
2021-10-11 09:32:29 +02:00
|
|
|
const int max_tree_length = 3;
|
2021-10-08 11:43:52 +02:00
|
|
|
const float bright_factor = 0.25f;
|
|
|
|
|
|
2021-10-11 09:32:29 +02:00
|
|
|
/* We ignore the first element of the path since it is the top-most tree and it doesn't need to
|
|
|
|
|
* be brighter. We also set a cap to how many levels we want to set apart, to avoid the
|
|
|
|
|
* background from getting too bright. */
|
2021-12-03 16:25:17 -05:00
|
|
|
const int clamped_tree_path_length = BLI_listbase_count_at_most(&snode.treepath,
|
2021-10-11 09:32:29 +02:00
|
|
|
max_tree_length);
|
|
|
|
|
const int depth = max_ii(0, clamped_tree_path_length - 1);
|
2021-10-08 16:01:49 +02:00
|
|
|
|
2021-10-08 11:43:52 +02:00
|
|
|
float color[3];
|
|
|
|
|
UI_GetThemeColor3fv(TH_BACK, color);
|
|
|
|
|
mul_v3_fl(color, 1.0f + bright_factor * depth);
|
|
|
|
|
GPU_clear_color(color[0], color[1], color[2], 1.0);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
void node_draw_space(const bContext &C, ARegion ®ion)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2021-12-03 16:25:17 -05:00
|
|
|
wmWindow *win = CTX_wm_window(&C);
|
|
|
|
|
SpaceNode &snode = *CTX_wm_space_node(&C);
|
|
|
|
|
View2D &v2d = region.v2d;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-07-26 12:32:42 +10:00
|
|
|
/* Setup off-screen buffers. */
|
2021-12-03 16:25:17 -05:00
|
|
|
GPUViewport *viewport = WM_draw_region_get_viewport(®ion);
|
2020-08-18 14:43:18 +02:00
|
|
|
|
|
|
|
|
GPUFrameBuffer *framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport);
|
|
|
|
|
GPU_framebuffer_bind_no_srgb(framebuffer_overlay);
|
|
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
UI_view2d_view_ortho(&v2d);
|
2021-10-08 11:43:52 +02:00
|
|
|
draw_background_color(snode);
|
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-02-17 15:04:29 +11:00
|
|
|
/* XXX `snode->runtime->cursor` set in coordinate-space for placing new nodes,
|
|
|
|
|
* used for drawing noodles too. */
|
2021-12-03 16:25:17 -05:00
|
|
|
UI_view2d_region_to_view(®ion.v2d,
|
|
|
|
|
win->eventstate->xy[0] - region.winrct.xmin,
|
|
|
|
|
win->eventstate->xy[1] - region.winrct.ymin,
|
|
|
|
|
&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
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
ED_region_draw_cb_draw(&C, ®ion, REGION_DRAW_PRE_VIEW);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06: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
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Nodes. */
|
2013-03-18 16:34:57 +00:00
|
|
|
snode_set_context(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-26 13:03:09 -05:00
|
|
|
const int grid_levels = UI_GetThemeValueType(TH_NODE_GRID_LEVELS, SPACE_NODE);
|
2021-12-03 16:25:17 -05:00
|
|
|
UI_view2d_dot_grid_draw(&v2d, TH_GRID, NODE_GRID_STEP_SIZE, grid_levels);
|
2021-10-26 13:03:09 -05:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Draw parent node trees. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (snode.treepath.last) {
|
|
|
|
|
bNodeTreePath *path = (bNodeTreePath *)snode.treepath.last;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Update tree path name (drawn in the bottom left). */
|
2021-12-03 16:25:17 -05:00
|
|
|
ID *name_id = (path->nodetree && path->nodetree != snode.nodetree) ? &path->nodetree->id :
|
|
|
|
|
snode.id;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-01 14:36:44 +02:00
|
|
|
if (name_id && UNLIKELY(!STREQ(path->display_name, name_id->name + 2))) {
|
|
|
|
|
BLI_strncpy(path->display_name, name_id->name + 2, sizeof(path->display_name));
|
2015-01-25 01:59:49 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Current View2D center, will be set temporarily for parent node trees. */
|
2020-11-30 13:56:46 -05:00
|
|
|
float center[2];
|
2021-12-03 16:25:17 -05:00
|
|
|
UI_view2d_center_get(&v2d, ¢er[0], ¢er[1]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Store new view center in path and current edit tree. */
|
2013-04-17 17:12:12 +00:00
|
|
|
copy_v2_v2(path->view_center, center);
|
2021-12-03 16:25:17 -05:00
|
|
|
if (snode.edittree) {
|
|
|
|
|
copy_v2_v2(snode.edittree->view_center, center);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06: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
|
|
|
|
2021-02-17 13:34:49 -06: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
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
wmOrtho2_pixelspace(region.winx, region.winy);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-03 16:25:17 -05: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
|
|
|
|
2021-12-03 16:25:17 -05: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
|
|
|
|
2021-02-17 13:34:49 -06: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-12-03 16:25:17 -05:00
|
|
|
if (snode.runtime->linkdrag) {
|
|
|
|
|
for (const bNodeLink *link : snode.runtime->linkdrag->links) {
|
2022-09-01 19:46:19 +02:00
|
|
|
node_draw_link_dragged(C, v2d, snode, *link);
|
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
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
if (snode.overlay.flag & SN_OVERLAY_SHOW_OVERLAYS && snode.flag & SNODE_SHOW_GPENCIL) {
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Draw grease-pencil annotations. */
|
2021-12-03 16:25:17 -05: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 {
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06: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
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
ED_region_draw_cb_draw(&C, ®ion, REGION_DRAW_POST_VIEW);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Reset view matrix. */
|
2021-12-03 16:25:17 -05:00
|
|
|
UI_view2d_view_restore(&C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-03 16:25:17 -05:00
|
|
|
if (snode.overlay.flag & SN_OVERLAY_SHOW_OVERLAYS) {
|
|
|
|
|
if (snode.flag & SNODE_SHOW_GPENCIL && snode.treepath.last) {
|
2021-02-05 16:23:34 +11:00
|
|
|
/* Draw grease-pencil (screen strokes, and also paint-buffer). */
|
2021-12-03 16:25:17 -05:00
|
|
|
ED_annotation_draw_view2d(&C, false);
|
2012-12-17 02:34:53 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-01 21:45:41 -05:00
|
|
|
/* Draw context path. */
|
2021-12-03 16:25:17 -05:00
|
|
|
if (snode.overlay.flag & SN_OVERLAY_SHOW_PATH && snode.edittree) {
|
|
|
|
|
draw_tree_path(C, region);
|
2021-12-01 21:45:41 -05:00
|
|
|
}
|
2021-10-26 11:05:01 -05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-17 13:34:49 -06:00
|
|
|
/* Scrollers. */
|
2021-12-03 16:25:17 -05:00
|
|
|
UI_view2d_scrollers_draw(&v2d, nullptr);
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
2022-01-20 10:36:56 -06:00
|
|
|
|
|
|
|
|
} // namespace blender::ed::space_node
|