sverweij / mscgen_js

text => sequence charts
https://mscgen.js.org
GNU General Public License v3.0
206 stars 25 forks source link

Entity header text wraps #246

Closed daledude closed 7 years ago

daledude commented 7 years ago

Expected Behavior

How would I get the lines of the event-text to not wrap? I'm using "wordwraparcs=false" but it's not working and probably isn't supposed to for the headers.

Steps to Reproduce (for bugs)

See the bookmarked graph here.

Most of the headers have 2 lines. Top is text and the second is an IP address.

Maybe worth noting is that I can have anywhere from 2 to 12 entity headers. I currently use logic to set the width depending on how may. If under 6 then set width=auto otherwise over 6 I dynamically calculate the width.

Your Environment

sverweij commented 7 years ago

I agree that doesn't look very nice.

As you already surmised wordwraparcs is to switch auto wrapping of text on arcs ("messages" in other modelling language speak) and not on entities or any of the other box-like elements.

Wrapping text in boxes is a bit of a balancing act. You don't want text to trespass the box boundaries; you don't want to chop words half way (like in your example).

Auto wrap The current default. The algorithm is ok in most cases, but not in all - like in your example. And in this one :-/

screen shot 2017-03-31 at 22 46 37

Fit box to content

screen shot 2017-03-31 at 22 22 32

Just don't wrap And make wrapping totally manual. E.g. without any manual line breaks:

screen shot 2017-03-31 at 22 17 58

... and with some choice manual line breaks

screen shot 2017-03-31 at 22 45 56

=> I think this about what you expect (check?)

That'd mean introducing one or two options to the and msgenny languages, e.g. wordwrapentities and wordwrapboxes.

sverweij commented 7 years ago

@daledude I've added the options wordwrapentities and wordwrapboxes. They work the same as the wordwraparcs option, except they work on entities and boxes respectively and are true by default (so if you leave them out sequence charts render in a backward compatible manner).

I've applied the former to the sample you provided - here's the sample you provided with the wordwrapentities option on false.

I need some time to do some little things (update the documentation, tweak the syntax highlighting for codemirror, atom and visual studio code to name a few) before actually releasing version 1.10.0 everywhere, but mscgen.js.org already has it.

Let me know what you think!

daledude commented 7 years ago

@sverweij Thanks for the feature! It works as intended but highlights an issue with the entity box width. Notice on this link that the last entity extends beyond the border. I notice all rect are set to width 100. Is it possible to auto extend the width of the entity rect to the size of the enclosed text? Or, allow me to change it through an arc option?

If just the entity box color were changeable I would set it to white and be done with it. But changing the linecolor, obviously, changes the whole line. And, changing the entity css class makes the line under the entity also disappear so there is a large gap between the entity and the lines. I'm not experienced enough to make the entity border just an underline.

sverweij commented 7 years ago

Auto-expanding the boxes to fit content - I have to think how to approach that (both functionally and technically). I also want to think about improving the line wrapping algorithm - because that's the root cause for this issue.

About making the border of entities transparent: there's currently two things you can do:

daledude commented 7 years ago

Thanks for the transparent tip. That provides a good alternative to text extending outside the entity box.

Something you may already think about but anyway...At some point you won't be able to save a user from themselves regarding width problems with wordwrapentities. I think for this feature to be complete you would have to extend the boundaries of the non-wrapping entities until they get within certain pixel distance of their neighbors and then start to wrap. So, depending how much effort you want to put into this I, personally, would be ok dealing with the consequences of my text inevitably being to long and breaking display and finding a way to deal with that in my code. Similar to removing the box around the entity which actually makes the display cleaner.

sverweij commented 7 years ago

You're right, there'd be a need to put limits to expanding the box.

I've been sketching a bit.

This how it would look if the entity box just expands without boxes around it (1)

screen shot 2017-04-05 at 21 29 19

... with boxes

screen shot 2017-04-05 at 21 11 46

An additional step is to keep the space between entity borders the same (2)

screen shot 2017-04-05 at 20 55 34

My target is (2) - but I'll have to pass (1) anyway

sverweij commented 7 years ago

@daledude I have hacked something quick & irresponsible in core for (1) - would this work for you?

haksel

If so I'll try to do some polishing in the coming days & publish

(animation is a bit slow & choppy - sorry 'bout that)

daledude commented 7 years ago

That looks like it would certainly work.

sverweij commented 7 years ago

@daledude I've published new versions to npm and mscgen.js.org with the entity width scaling. Let me know how it works out for you.

daledude commented 7 years ago

Seems to work great so far. Thanks!