LibrePCB / librepcb-rfcs

MOVED TO https://librepcb.discourse.group/
Apache License 2.0
3 stars 0 forks source link

Add text functionality to schematic editor #33

Closed dbrgn closed 5 years ago

dbrgn commented 5 years ago

Right now text cannot be placed in the schematics. Would be nice to have that.

Desired functionality

Brainstorming

ouabache commented 5 years ago

Yes for Text. Select font,size and color. Do not place on snap grid,You need a finer adjustment for location.

If you do place on snap grid then allow for the 9 placement modifiers: above left,above,above right,left ,cent etc.

John Eaton

ubruhin commented 5 years ago

Support for text in schematics is needed for sure. But I'm not sure about Markdown because it's very limited and many EDA users probably don't know Markdown and thus aren't comfortable with it. But I would agree to use Markdown just as an optional, alternative input method for texts.

Qt would support a subset of HTML out of the box. With that it shouldn't be too hard to support rich text in LibrePCB...

Choosing fonts is tricky. Actually only fonts bundled with LibrePCB should be used, the use of system fonts would break portability of LibrePCB projects.

dbrgn commented 5 years ago

With that it shouldn't be too hard to support rich text in LibrePCB...

Sure, but if you want to do invisible markup (bold/italic/etc) by marking a span of text and clicking a format button, you'll descend into the seven hells of building rich text editors :slightly_smiling_face: You probably know from using those how buggy they can be at times.

The advantage of markdown is that it's visible how the markup should be applied, so you won't have issues with incorrectly nested markup (or it will be obvious why it doesn't work).

ubruhin commented 5 years ago

Sure, but if you want to do invisible markup (bold/italic/etc) by marking a span of text and clicking a format button, you'll descend into the seven hells of building rich text editors

I guess this is pretty easy with Qt. See for example their rich text edit example or this complete text editor widget.

The advantage of markdown is that it's visible how the markup should be applied

Of course, I also like explicit markup. But unfortunately Markdown is very limited (not even text color is supported, so you can't for example place a warning in red color on the schematic). And most EDA users aren't software engineers or "hackers" and thus don't know Markdown, I think many of them want to have a text editor similar to MS Word. It's intuitive, and everyone knows how to use it.

In the end, we have to draw the text on the QGraphicsScene of a schematic. As far as I can see, there are two options:

If we use HTML, we still have the option to allow writing text in Markdown, as Markdown can easily be converted to HTML. But then each text probably needs to have a property which defined if the text is HTML or Markdown. Very cool would be if HTML could be converted back to Markdown, then we only have to store HTML in schematic files, and the user can still edit these texts with Markdown syntax :)

So maybe we should allow the user to choose what kind of text they want to place on schematics:

dbrgn commented 5 years ago

I guess this is pretty easy with Qt.

Ah, I wasn't aware of that :slightly_smiling_face: I guess you would then store the text as HTML inside the schema file?

Does Qt allow passing in a whitelist of HTML tags and attributes allowed?

So maybe we should allow the user to choose what kind of text they want to place on schematics

Yeah, I think that would be good: Three different types of text elements.

I could imagine a "add text" button in the toolbar that has a context menu where you can choose which variant to add (and then the chosen variant becomes the new default). Not sure if that's doable with Qt out of the box.

ubruhin commented 5 years ago

This issue was moved to https://librepcb.discourse.group/t/add-text-functionality-to-schematic-editor/19