Geometry Node: Multi-input socket tooltip #104468

Merged
Jacques Lucke merged 33 commits from mod_moder/blender:multi_input_tooltip into main 2024-04-22 19:49:08 +02:00
7 changed files with 51 additions and 26 deletions
Showing only changes of commit 88ce58b0d2 - Show all commits

@ -1 +1 @@
Subproject commit 4a581c54af9b92cb670d750951b9382160f10f3e
Subproject commit 8b4e4e9190467e0d71f200681681b9d67281d01d

@ -1 +1 @@
Subproject commit 0b0052bd53ad8249ed07dfb87705c338af698bde
Subproject commit d4c8ec5cdff2337c34838b2ff83108697e1d4abe

@ -1 +1 @@
Subproject commit 96143b1a8b037ea3c81f065f557025db9fe1ace3
Subproject commit bdcfdd47ec3451822b21d1cff2ea2db751093c9a

View File

@ -1039,32 +1039,42 @@ static std::optional<std::string> create_socket_inspection_string(TreeDrawContex
}
tree_draw_ctx.geo_tree_log->ensure_socket_values();
ValueLog *value_log = tree_draw_ctx.geo_tree_log->find_socket_value_log(socket);
if (value_log == nullptr) {
return std::nullopt;
}
bool newline = false;
std::stringstream ss;
if (const geo_log::GenericValueLog *generic_value_log =
dynamic_cast<const geo_log::GenericValueLog *>(value_log)) {
create_inspection_string_for_generic_value(socket, generic_value_log->value, ss);
}
else if (const geo_log::FieldInfoLog *gfield_value_log =
dynamic_cast<const geo_log::FieldInfoLog *>(value_log)) {
create_inspection_string_for_field_info(socket, *gfield_value_log, ss);
}
else if (const geo_log::GeometryInfoLog *geo_value_log =
dynamic_cast<const geo_log::GeometryInfoLog *>(value_log)) {
create_inspection_string_for_geometry_info(
*geo_value_log,
ss,
dynamic_cast<const nodes::decl::Geometry *>(socket.runtime->declaration));
}
tree_draw_ctx.geo_tree_log->socket_logs_callback(socket, [&](const ValueLog *value_log){
if (newline){
ss << "\n";
}
if (value_log == nullptr) {
return;
}
if (const geo_log::GenericValueLog *generic_value_log =
dynamic_cast<const geo_log::GenericValueLog *>(value_log)) {
create_inspection_string_for_generic_value(socket, generic_value_log->value, ss);
}
else if (const geo_log::FieldInfoLog *gfield_value_log =
dynamic_cast<const geo_log::FieldInfoLog *>(value_log)) {
create_inspection_string_for_field_info(socket, *gfield_value_log, ss);
}
else if (const geo_log::GeometryInfoLog *geo_value_log =
dynamic_cast<const geo_log::GeometryInfoLog *>(value_log)) {
create_inspection_string_for_geometry_info(
*geo_value_log,
ss,
dynamic_cast<const nodes::decl::Geometry *>(socket.runtime->declaration));
}
newline = true;
});
std::string str = ss.str();
if (str.empty()) {
return std::nullopt;
if (!str.empty()){
return str;
}
return str;
return std::nullopt;
}
static bool node_socket_has_tooltip(const bNodeTree &ntree, const bNodeSocket &socket)

View File

@ -30,6 +30,7 @@
#include "BLI_enumerable_thread_specific.hh"
#include "BLI_generic_pointer.hh"
mod_moder marked this conversation as resolved Outdated

Necessary to add this include?

Necessary to add this include?
#include "BLI_multi_value_map.hh"
#include "BLI_function_ref.hh"
#include "BKE_attribute.h"
#include "BKE_geometry_set.hh"
@ -288,6 +289,7 @@ class GeoTreeLog {
void ensure_debug_messages();
ValueLog *find_socket_value_log(const bNodeSocket &query_socket);
void socket_logs_callback(const bNodeSocket &query_socket, FunctionRef<void(ValueLog *value_log)> callback);
};
mod_moder marked this conversation as resolved Outdated

I don't think this needs to be inline, it's not really a trivial function.

I don't think this needs to be inline, it's not really a trivial function.
/**

View File

@ -8,6 +8,8 @@
#include "BKE_node_runtime.hh"
#include "BKE_viewer_path.h"
#include "BLI_function_ref.hh"
#include "FN_field_cpp_type.hh"
#include "DNA_modifier_types.h"
@ -352,6 +354,17 @@ void GeoTreeLog::ensure_debug_messages()
reduced_debug_messages_ = true;
}
void GeoTreeLog::socket_logs_callback(const bNodeSocket &query_socket, FunctionRef<void(ValueLog *value_log)> callback)
{
if (!query_socket.is_multi_input()){
callback(this->find_socket_value_log(query_socket));
}else{
for (const bNodeSocket *socket : query_socket.directly_linked_sockets()){
callback(this->find_socket_value_log(*socket));
}
}
}
ValueLog *GeoTreeLog::find_socket_value_log(const bNodeSocket &query_socket)
{
/**

@ -1 +1 @@
Subproject commit 9e33a8678a3b97d2fdb833349657c3cc1c04811f
Subproject commit fdfa2fcb9495d87571f2dfe2ae9fa0e032536600