SymbolsDialog

From Inkscape Wiki
Jump to navigation Jump to search

Symbols Dialog

Features

Allows copying and pasting symbols (<symbol> elements) from both the document being edited and from symbol libraries.

Use

  • Open Symbol dialog:
    • Object ▶︎ Symbol dialog..., or
    • Ctrl-Shift-Y. (Note, the shortcut was used for Edit ▶︎ Undo. I am guessing that this shortcut is pretty unused.)
  • Select symbol set
  • Drag and drop symbol into document, or
  • Copy and paste by
    • Click on symbol to copy to clipboard
    • Paste (Ctrl-V) to document.

Symbol Libraries

Symbol libraries are sets of symbols located in one SVG document. Inkscape will look for libraries in the share/symbols directories (both system and personal). Any <symbol> elements defined in the <defs> section will be picked up. (<symbol> elements are allowed anywhere in an SVG document according to the spec, but Inkscape seems to have some trouble if they are not in the <defs> section.)

Note that since a symbol library is an ordinary SVG file, one can also include documentation and/or sample diagrams in the same file.

There are two sample sets of symbols, one with Logic symbols and with AIGA/DOT transportation symbols.

Symbols and Styles

In order to allow styling of symbols from within Inkscape, styling should be kept out of <symbol> elements as much as possible. It is then possible for a symbol to inherit the styling of the <use> element that references it. In order to provide a default style to a <symbol> one can either provide a general default style in the root <svg> element of the library or add a symbol specific default style by putting a style string in the inkscape:symbol-style attribute inside the <symbol> element. When a symbol is selected in the Symbol dialog, the style will be added to the <use> element in the clipboard.

Other Sources of Symbols

Visio stencil files (.vss) can also be used as a source of symbols by dropping the files into the share/symbols directory (if libvisio has been linked in).


Editing Symbols

Original Draft & Implementation

Two commands are available to allow editing of symbols from within Inkscape:

  • Object ▶︎ Symbol to Group:

This converts the <symbol> referenced by the selected <use> element to a group located in the untransformed position of the symbol. The new group is left selected. Any <use> element (clone) that referenced the symbol should be left referencing the group. No default styling is applied to the group itself (since there is no <use> element to inherit it from).

  • Object ▶︎ Group to Symbol

This converts a selected group to a <symbol> element. No <use> element is created. Any <use> elements that referenced the group will now reference the symbol. The new symbol can be selected in the Symbol dialog in the Current Document Symbol set. (You may need to unselect and then reselect the Current Document set to get the symbol to show.)

A lot of alternative ways were tried to be able to round-trip symbols to groups and back. This method seemed the most straightforward and avoids issues with transforms and styling.

Copying (Ctrl-C) and then pasting a symbol, or duplicating a symbol creates a new <use> element (clone) referencing the same symbol.

To copy a <symbol> for creating a new <symbol>, first convert the symbol to a group, copy the group, edit the copied group, and convert both groups back to symbols (give the new group useful id and title attributes via the Object Properties dialog).

Current implementation in 0.91

The implementation of this feature was later changed (TODO: update with detailed description for current status in 0.91 - Bug #1419345).

Bugs/Issues

  • Full list of Symbols Bugs: Launchpad Bug List
  • Switching Desktop should switch Document Symbol set. (At the moment this is not an issue as each desktop gets its own Symbol dialog.)
  • Symbol to Group/Group to Symbol should trigger an update to the symbols shown in the Symbol dialog when symbol set Current Document is selected.
  • Editing a symbol should result in updating the image in the Symbol's dialog.
  • Symbols have not been tested well inside Inkscape.
  • Symbols referring to external elements (gradients, etc.) probably won't work.
  • Symbols can have their own viewbox, this has not been tested.

Future Enhancements

  • Generic symbols: It should be possible to extend the Symbol dialog to include <g> elements as well as <symbol> elements. A group could be marked as a symbol by adding an <inkscape:symbol> tag. In this way one can put place holders in for things like text:
<g role="inkscape:symbol">
 <symbol id="wrapperBox">...</symbol>
 <text id="label">...</text>
</g>
  • Connectors: Symbols beg for the use of connectors. It would be easy to define connection points inside a symbol. The Logic symbols include extra nodes to make snapping of input/output lines to the correct places easier. These nodes would be better defined as connection points. Work on an SVG Connector proposal is in progress.