Skip to content

Commit 6e193a9

Browse files
committed
Fix vertical layout width with zero in or out ports
1 parent b212b20 commit 6e193a9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/DefaultVerticalNodeGeometry.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,13 @@ void DefaultVerticalNodeGeometry::recomputeSize(NodeId const nodeId) const
5454
unsigned int inPortWidth = maxPortsTextAdvance(nodeId, PortType::In);
5555
unsigned int outPortWidth = maxPortsTextAdvance(nodeId, PortType::Out);
5656

57-
unsigned int width = std::max(inPortWidth * nInPorts + _portSpasing * (nInPorts - 1),
58-
outPortWidth * nOutPorts + _portSpasing * (nOutPorts - 1));
57+
unsigned int totalInPortsWidth =
58+
nInPorts > 0 ? inPortWidth * nInPorts + _portSpasing * (nInPorts - 1) : 0;
59+
60+
unsigned int totalOutPortsWidth =
61+
nOutPorts > 0 ? outPortWidth * nOutPorts + _portSpasing * (nOutPorts - 1) : 0;
62+
63+
unsigned int width = std::max(totalInPortsWidth, totalOutPortsWidth);
5964

6065
if (auto w = _graphModel.nodeData<QWidget *>(nodeId, NodeRole::Widget)) {
6166
width = std::max(width, static_cast<unsigned int>(w->width()));

0 commit comments

Comments
 (0)