wokwi / wokwi-features

Wokwi Feature requests & Bug Reports
https://wokwi.com
69 stars 17 forks source link

text element option #43

Open matititam opened 3 years ago

matititam commented 3 years ago

sometimes picture needs some text to save time

a label kind of feature which can be placed so that,

  1. I can tell how to give a long press
  2. I can tell what the buttons are for
  3. I can tell, what does the extreme ends of the potentiometer to
  4. etc
stevesigma commented 3 years ago

Maybe it would be used for global label assigned to any element, for example when sharing scheme. Something like:

 <id="resistor1" type="wokwi-resistor" label="R1"...
 <id="btn1" type="wokwi-pressbutton" label="Change color"...
urish commented 3 years ago

That's an interesting thought. So there are two alternatives:

  1. Adding some kind of text/label primitive, which you can place in the diagram anywhere you like
  2. Adding a new attribute to parts which will let you specify additional information. I'm not sure if I'd call it label, perhaps comment or description make more sense?
stevesigma commented 3 years ago
  1. would need fixed position, z-index, colors... that would make sometimes small problems. (when zooming?) Less code for You.
  2. the position should be calculated on the fly while zooming. Labels could be connected with object by thin line/arrow. Style has to be autmatically. Should have some opaque background, could dissapear. More code for You. name of attribute was just an example.
alto777 commented 2 years ago

I found this searching for a feature.

+1 on some kind of document annotation mechanism, not terribly important really, but once there are more than a few switches and LEDs it gets a bit of work to figure out which are which. Especially for others if you are sharing.

alto777

rcwilcox commented 2 years ago

That's an interesting thought. So there are two alternatives:

  1. Adding some kind of text/label primitive, which you can place in the diagram anywhere you like
  2. Adding a new attribute to parts which will let you specify additional information. I'm not sure if I'd call it label, perhaps comment or description make more sense?

I like (1)

If attached, they would move if the part moved, which would be nice. Also be nice to be able to to be attached (Relative Attribute) to a NET (e.g. Arduino Pin 11 - MOSI), should also be able to rotate and perhaps offset from attached object. Visually connect to part as suggested by @stevesigma. Should also allow an absolute position (Fixed Attribute) test box for Diagram notes, usage etc.

matititam commented 2 years ago

random thought - just wanted to pin it here

How about making the text note a mouse hover display (or when we click on the part (when the simulation is not running)

rcwilcox commented 2 years ago

random thought - just wanted to pin it here

How about making the text note a mouse hover display (or when we click on the part (when the simulation is not running)

That would help declutter (if you had lots of text labels), downside would be that any screen shots would not have the text visible. My 'too much of anything is just enough' and 'retched excess' gene says - Have both with a persistence attribute of static or dynamic. Of course, Fixed text objects (notes, tables, etc.) should be static.

M-square commented 2 years ago

Of all the options above, I think a simple, independent (new) object that is just the text.

How it is handled in zoom is up to the implementation (scales or remains fixed size) whatever is simpler.

Text can have lots and lots of options (size, font, colour, alignment ...) - use the KISS principle.

marvinschwartz commented 2 years ago

When you have lots of similar components on a screen you need some way to know what they are. eg. multiple stepper motors, multiple leds, multiple switches and buttons etc. This would make the diagrams far more useful and much better when sharing. Just a simple text element would be a significant improvement.

urish commented 1 year ago

Update: we have a proof-of-concept implementation of a wokwi-text element:

https://wokwi.com/projects/341085054102930004

The details (element name, attrs, default behavior, etc) are subject to change - looking to get some feedback so we can ship this soon.

urish commented 1 year ago

Apparently, the current implementation breaks the text differently depending on the screen sizes (e.g. desktop v.s. mobile), so we need some deterministic method of defining the size of the text element.

janoc commented 1 year ago

Having the option 2 from https://github.com/wokwi/wokwi-features/issues/43#issuecomment-766184841 would be really useful if those labels could be actually attached to wires - and exported as part of the logic analyzer files too. It would make the analyzer a lot more useful when debugging multiple signals at once.

urish commented 1 year ago

Thanks for the input @janoc, that's a good point! I'm curious - what have you been building/debugging with Wokwi?

janoc commented 1 year ago

Trying some RP2040 PIO code. It seems Wokwi is the only thing around that has a sensible simulator available.

drf5n commented 1 year ago

Update: we have a proof-of-concept implementation of a wokwi-text element:

https://wokwi.com/projects/341085054102930004

The details (element name, attrs, default behavior, etc) are subject to change - looking to get some feedback so we can ship this soon.

For folks who ended up here while looking for documentation, the block of json in the diagram is:

{
  "type": "wokwi-text",
  "id": "led1",
  "top": -40.7,
  "left": 67.67,
  "attrs": { "text": "This is an example of\nText Labels for Wokwi." }
}

With commas for easy pasting, a label that won't clash with led1, and a comment for documentation:

,
{
  "docUrl":"https://github.com/wokwi/wokwi-features/issues/43#issuecomment-1453481794",
  "type": "wokwi-text",
  "id": "title1",
  "top": -40.7,
  "left": 67.67,
  "attrs": { "text": "This is an example of\nText Labels for Wokwi." }
}
,

You can use un-recognised attributes, such as "docUrl" in the above code, in JSON for comments.

drf5n commented 1 year ago

Does the element have extra attributes like:

"size": "10"   // canvas units? Font points?  
"justification": ""    // "", "left",  "center", "right" 
"font": ""                  // css type?
Knelfy commented 1 year ago

Would there be a possible way to change the text colour, or maybe the background colour would be more in keeping with it being a part (and thus not impacted by dark mode). I have it in dark mode hence the ask because the black text isn't very clear on the dark background. PS tried color attribute but no luck.

shaos commented 1 year ago

Why attribute for proposed wokwi-text is called "text"? There is a perfect attribute that is doing similar thing for other parts - "label" 🙂 So technically object wokwi-text could be an empty part with a label 😉 From other side label is always 1-line text and wokwi-text could be multi-line (with \n separating lines) so this is a perfect time to make label multi-line to cover both use cases ;) UPDATE: Apparently label attribute works only for pushbuttons and LEDs :) Even though it looks like gates have space below for 1-line label, but label doesn't appear there...