Hello,
I'd like to visualize a graph where the nodes are boxes and they have text inside. The boxes should grow or shrink horizontally so the text doesn't go outside the box.
~~~~~~~~~~~~~~~~
| b label el |
b := RTView new.
el := RTBox new elementOn: 'hello world'.
label := RTLabeled new center.
b add: el.
el @ label.
"not robust"
el width: label lbl width.
el height: label lbl height.
b
~~~~~~~~~~~~~~~~~~~~~~
<image.png>
I found the unit tests for RTLabel (RTLabelTest) and I found another solution, but maybe it's equally fragile?
~~~~~~~~~~~~~~~~~~~~~~~~~
| text b lblBox lblForCalc dummyElement |
text := 'Text inside the box'.
b := RTView new.
lblBox := (RTBox new elementOn: text) + RTLabel.
lblForCalc := RTLabel new text: text.
dummyElement := RTElement new.
lblBox height: (lblForCalc heightFor: dummyElement).
lblBox width: (lblForCalc widthFor: dummyElement).
b add: lblBox.
b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<image.png>
I'd love to get some feedback on these approaches. Maybe there's a simpler robust way? Thanks!