Skip to content

Commit

Permalink
Fixed issue #1543
Browse files Browse the repository at this point in the history
  • Loading branch information
ethomare-ilm committed Oct 12, 2023
1 parent c7f01d8 commit 65e5b3f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
34 changes: 34 additions & 0 deletions source/MaterialXGraphEditor/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3707,6 +3707,39 @@ void Graph::searchNodePopup(bool cursor)
}
}

bool Graph::isPinHovered() {
ed::PinId currentPin = ed::GetHoveredPin();
ed::PinId nullPin = 0;
return currentPin != nullPin;
}

void Graph::addPinPopup() {
// Add a floating popup to pin when hovered
if (isPinHovered()) {
ed::Suspend();
UiPinPtr pin = getPin(ed::GetHoveredPin());
std::string connected = "";
std::string value = "";
if (pin->_connected) {
connected = "\nConnected to";
if (pin->_name == "out") {
for (UiPinPtr connectedPins : pin->getConnections()) {
connected = connected + " " + connectedPins->_name + ",";
}
}
else {
connected = connected + " out";
}
}
else {
value = "\nValue: " + pin->_input->getValueString();
}
std::string const message{ "Name: " + pin->_name + "\nType: " + pin->_type + value + connected};
ImGui::SetTooltip(message.c_str());
ed::Resume();
}
}

void Graph::readOnlyPopup()
{
if (_popup)
Expand Down Expand Up @@ -3823,6 +3856,7 @@ void Graph::drawGraph(ImVec2 mousePos)
ImGui::SetNextWindowSizeConstraints(ImVec2(250.0f, 300.0f), ImVec2(-1.0f, 500.0f));
addNodePopup(TextCursor);
searchNodePopup(TextCursor);
addPinPopup();
readOnlyPopup();
ImGui::PopStyleVar();

Expand Down
2 changes: 2 additions & 0 deletions source/MaterialXGraphEditor/Graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ class Graph

void addNodePopup(bool cursor);
void searchNodePopup(bool cursor);
bool isPinHovered();
void addPinPopup();
bool readOnly();
void readOnlyPopup();

Expand Down

0 comments on commit 65e5b3f

Please sign in to comment.