LeGoffLoic / Nodz

Nodz : Visualize your data - Free nodes based graph generator.
MIT License
421 stars 108 forks source link

Fixed attribute text not correctly displayed when it has several lines #23

Closed glm-ypinczon closed 6 years ago

glm-ypinczon commented 6 years ago

Fixed attribute text not correctly displayed when it has several lines even if the "node_attr_height" config value is set with enough room to display it.

To demonstrate the bug, add the following node in the nodz_demo.py:

textToDisplay='This is my attribute.\nIt has several lines,and I\nchanged the node_attr_height\nto a bigger value in the presets\nto display it all.\nBut my concern is that it\'s not\ncentered on the box and so not\ncompletelly displayed even if\nthere is enough room for\neverything.'
nodzObject = nodz.createNode(name='Note', preset='node_preset_1', position=None)
nodz.createAttribute(node=nodzObject, name=textToDisplay, index=-1, plug=False, socket=False, dataType=str)
nodz.createAttribute(node=nodzObject, name='Note Attribute 2.', index=-1, plug=False, socket=False, dataType=str)

And change the "node_attr_height" setting to 170 in the default_config.json

This commit fix the issue by centering the attribute text vertically in its rect.

Here is the bug:

And here is the result with the same parameters once fixed: