Skip to content

Commit

Permalink
Improve input filtering in Graph Editor (#2134)
Browse files Browse the repository at this point in the history
- Move "show all inputs" to the top. 
- Make name field expand to right marge on panel.
- Format the title of the property editor.
- Remove extraneous "Inputs:" line since only inputs are displayed.
  • Loading branch information
kwokcb authored Dec 9, 2024
1 parent 1223580 commit 31d8240
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions source/MaterialXGraphEditor/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3288,15 +3288,32 @@ void Graph::graphButtons()

void Graph::propertyEditor()
{
// Get parent dimensions
ImVec2 textPos = ImGui::GetCursorScreenPos(); // Position for the background
float parentWidth = ImGui::GetContentRegionAvail().x; // Available width in the parent

// Draw the title bar
const ImGuiStyle& style = ImGui::GetStyle();
ImVec4 menuBarBgColor = style.Colors[ImGuiCol_MenuBarBg];
ImU32 bgColor = ImGui::ColorConvertFloat4ToU32(menuBarBgColor); // Convert to 32-bit color
ImDrawList* drawList = ImGui::GetWindowDrawList();
drawList->AddRectFilled(textPos,
ImVec2(textPos.x + parentWidth, textPos.y + ImGui::GetTextLineHeight()),
bgColor);
ImGui::Text("Node Property Editor");

if (_currUiNode)
{
// Set and edit name
ImGui::Text("Name: ");
ImGui::SameLine();
std::string original = _currUiNode->getName();
std::string temp = original;
float availableWidth = ImGui::GetContentRegionAvail().x;
ImGui::PushItemWidth(availableWidth);
ImGui::InputText("##edit", &temp);
ImGui::PopItemWidth();

std::string docString = "NodeDef Doc String: \n";
if (_currUiNode->getNode())
{
Expand Down Expand Up @@ -3423,7 +3440,8 @@ void Graph::propertyEditor()
ImGui::SetTooltip("%s", _currUiNode->getNode()->getNodeDef()->getDocString().c_str());
}

ImGui::Text("Inputs:");
ImGui::Checkbox("Show all inputs", &_currUiNode->_showAllInputs);

int count = 0;
for (UiPinPtr input : _currUiNode->inputPins)
{
Expand Down Expand Up @@ -3487,14 +3505,12 @@ void Graph::propertyEditor()
ImGui::SetWindowFontScale(1.0f);
}
}
ImGui::Checkbox("Show all inputs", &_currUiNode->_showAllInputs);
}

else if (_currUiNode->getInput() != nullptr)
{
ImGui::Text("%s", _currUiNode->getCategory().c_str());
std::vector<UiPinPtr> inputs = _currUiNode->inputPins;
ImGui::Text("Inputs:");

int count = static_cast<int>(inputs.size());
if (count)
Expand Down Expand Up @@ -3545,7 +3561,6 @@ void Graph::propertyEditor()
{
std::vector<UiPinPtr> inputs = _currUiNode->inputPins;
ImGui::Text("%s", _currUiNode->getCategory().c_str());
ImGui::Text("Inputs:");
int count = 0;
for (UiPinPtr input : inputs)
{
Expand Down

0 comments on commit 31d8240

Please sign in to comment.