From 20bb0aca5747dd3cba0c9accceba72cc49f076a0 Mon Sep 17 00:00:00 2001 From: "anthony@rabine.fr" Date: Fri, 3 Oct 2025 14:35:25 +0200 Subject: [PATCH] Working custom socket --- .../src/node_editor/base_node_widget.cpp | 2 +- .../src/node_editor/node_editor_page.h | 25 ++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/story-editor/src/node_editor/base_node_widget.cpp b/story-editor/src/node_editor/base_node_widget.cpp index 0f4084d..bda8b35 100644 --- a/story-editor/src/node_editor/base_node_widget.cpp +++ b/story-editor/src/node_editor/base_node_widget.cpp @@ -29,7 +29,7 @@ void BaseNodeWidget::DrawSocket(const Nw::Pin &pin) { ImDrawList* draw_list = ImGui::GetWindowDrawList(); - // Taille du socket + // Taille du socket float socket_size = 4.0f; // Définir les 5 points du polygone (flèche pointant vers la droite pour Output) diff --git a/story-editor/src/node_editor/node_editor_page.h b/story-editor/src/node_editor/node_editor_page.h index 251ac84..b3d84a7 100644 --- a/story-editor/src/node_editor/node_editor_page.h +++ b/story-editor/src/node_editor/node_editor_page.h @@ -37,6 +37,7 @@ public: if (port.customSocketIcon) { ImFlow::BaseNode::addIN(label, 0, ImFlow::ConnectionFilter::SameType())->renderer([this, i](ImFlow::Pin* p) { + ImGui::Dummy(ImVec2(20.0f, 20.0f)); // Ajustez la taille selon vos besoins Nw::Pin pin; pin.index = i; pin.isConnected = p->isConnected(); @@ -62,17 +63,23 @@ public: std::string label = (port.type == ::BaseNode::Port::Type::EXECUTION_PORT) ? "" : port.label; if (port.customSocketIcon) { - ImFlow::BaseNode::addOUT(label, nullptr)->renderer([this, i](ImFlow::Pin* p) { + ImFlow::BaseNode::addOUT(label, nullptr)->renderer([this, i, cached_pin = Nw::Pin{}](ImFlow::Pin* p) mutable { - Nw::Pin pin; - pin.index = i; - pin.isConnected = p->isConnected(); - pin.pinKind = Nw::PinKind::Output; - pin.pinPoint = p->pinPoint(); - pin.pos = p->getPos(); - pin.size = p->getSize(); + if (p->getName().empty()) { + ImGui::Dummy(ImVec2(1.0f, 10.0f)); + } else { + ImGui::Text("%s", p->getName().c_str()); + } - m_widget->DrawSocket(pin); + + cached_pin.index = i; + cached_pin.isConnected = p->isConnected(); + cached_pin.pinKind = Nw::PinKind::Output; + cached_pin.pinPoint = p->pinPoint(); + cached_pin.pos = p->getPos(); + cached_pin.size = p->getSize(); + + m_widget->DrawSocket(cached_pin); }); } else