Feature: Flow chart nodes resize based on inputs/outputs
This commit is contained in:
parent
b5955faaa2
commit
3479dbeb8a
@ -511,31 +511,41 @@ class NodeGraphicsItem(GraphicsObject):
|
|||||||
|
|
||||||
|
|
||||||
def updateTerminals(self):
|
def updateTerminals(self):
|
||||||
bounds = self.bounds
|
|
||||||
self.terminals = {}
|
self.terminals = {}
|
||||||
inp = self.node.inputs()
|
inp = self.node.inputs()
|
||||||
dy = bounds.height() / (len(inp)+1)
|
out = self.node.outputs()
|
||||||
y = dy
|
|
||||||
|
maxNode = max(len(inp), len(out))
|
||||||
|
titleOffset = 25
|
||||||
|
nodeOffset = 12
|
||||||
|
|
||||||
|
# calculate new height
|
||||||
|
newHeight = titleOffset+maxNode*nodeOffset
|
||||||
|
|
||||||
|
# if current height is not equal to new height, update
|
||||||
|
if not self.bounds.height() == newHeight:
|
||||||
|
self.bounds.setHeight(newHeight)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
# Populate inputs
|
||||||
|
y = titleOffset
|
||||||
for i, t in inp.items():
|
for i, t in inp.items():
|
||||||
item = t.graphicsItem()
|
item = t.graphicsItem()
|
||||||
item.setParentItem(self)
|
item.setParentItem(self)
|
||||||
#item.setZValue(self.zValue()+1)
|
#item.setZValue(self.zValue()+1)
|
||||||
br = self.bounds
|
|
||||||
item.setAnchor(0, y)
|
item.setAnchor(0, y)
|
||||||
self.terminals[i] = (t, item)
|
self.terminals[i] = (t, item)
|
||||||
y += dy
|
y += nodeOffset
|
||||||
|
|
||||||
out = self.node.outputs()
|
# Populate inputs
|
||||||
dy = bounds.height() / (len(out)+1)
|
y = titleOffset
|
||||||
y = dy
|
|
||||||
for i, t in out.items():
|
for i, t in out.items():
|
||||||
item = t.graphicsItem()
|
item = t.graphicsItem()
|
||||||
item.setParentItem(self)
|
item.setParentItem(self)
|
||||||
item.setZValue(self.zValue())
|
item.setZValue(self.zValue())
|
||||||
br = self.bounds
|
item.setAnchor(self.bounds.width(), y)
|
||||||
item.setAnchor(bounds.width(), y)
|
|
||||||
self.terminals[i] = (t, item)
|
self.terminals[i] = (t, item)
|
||||||
y += dy
|
y += nodeOffset
|
||||||
|
|
||||||
#self.buildMenu()
|
#self.buildMenu()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user