mirror of
https://github.com/arabine/open-story-teller.git
synced 2025-12-06 17:09:06 +01:00
Working custom socket
This commit is contained in:
parent
d58967710a
commit
20bb0aca57
2 changed files with 17 additions and 10 deletions
|
|
@ -29,7 +29,7 @@ void BaseNodeWidget::DrawSocket(const Nw::Pin &pin)
|
||||||
{
|
{
|
||||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||||
|
|
||||||
// Taille du socket
|
// Taille du socket
|
||||||
float socket_size = 4.0f;
|
float socket_size = 4.0f;
|
||||||
|
|
||||||
// Définir les 5 points du polygone (flèche pointant vers la droite pour Output)
|
// Définir les 5 points du polygone (flèche pointant vers la droite pour Output)
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ public:
|
||||||
if (port.customSocketIcon)
|
if (port.customSocketIcon)
|
||||||
{
|
{
|
||||||
ImFlow::BaseNode::addIN<int>(label, 0, ImFlow::ConnectionFilter::SameType())->renderer([this, i](ImFlow::Pin* p) {
|
ImFlow::BaseNode::addIN<int>(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;
|
Nw::Pin pin;
|
||||||
pin.index = i;
|
pin.index = i;
|
||||||
pin.isConnected = p->isConnected();
|
pin.isConnected = p->isConnected();
|
||||||
|
|
@ -62,17 +63,23 @@ public:
|
||||||
std::string label = (port.type == ::BaseNode::Port::Type::EXECUTION_PORT) ? "" : port.label;
|
std::string label = (port.type == ::BaseNode::Port::Type::EXECUTION_PORT) ? "" : port.label;
|
||||||
if (port.customSocketIcon)
|
if (port.customSocketIcon)
|
||||||
{
|
{
|
||||||
ImFlow::BaseNode::addOUT<int>(label, nullptr)->renderer([this, i](ImFlow::Pin* p) {
|
ImFlow::BaseNode::addOUT<int>(label, nullptr)->renderer([this, i, cached_pin = Nw::Pin{}](ImFlow::Pin* p) mutable {
|
||||||
|
|
||||||
Nw::Pin pin;
|
if (p->getName().empty()) {
|
||||||
pin.index = i;
|
ImGui::Dummy(ImVec2(1.0f, 10.0f));
|
||||||
pin.isConnected = p->isConnected();
|
} else {
|
||||||
pin.pinKind = Nw::PinKind::Output;
|
ImGui::Text("%s", p->getName().c_str());
|
||||||
pin.pinPoint = p->pinPoint();
|
}
|
||||||
pin.pos = p->getPos();
|
|
||||||
pin.size = p->getSize();
|
|
||||||
|
|
||||||
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
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue