Re: Using clones for boxes with text in block diagram

Thanks for the replies.
I asked:
What I'm after is a way to be able to change things like colours and line thicknesses just once, and have those changes affect all of the boxes [containg text] of that class. Is cloning the best way to do this?
Bulia suggested:
Don't clone the group - clone only the rect. Made the clone of the rect first, then group rect with text; clone will not be affected, it will only reflect the rect as before. Then you can duplicate the clone as many times as you need to get more clones of the same rect.
OK, I've tried it, and it works. Thanks! Unfortnately it looks as if resizing the clones (i.e. so that they fit the text that they contain) always resizes the box stroke width, even if the "scale stroke width" button is off, so this doesn't really do what I wanted.
Mental suggested:
This is basically what CSS classes are for; I think we do have sufficient CSS support to use them now, but not good UI for CSS yet.
Great, I can do CSS, and "instance of a class" is a more familiar mental model (HTML+CSS, C++) than "duplicate of a clone".
So, I can set a class attribute on things using the XML editor [is there an easier way?] and I can write a CSS stylesheet in a text editor. Can you help me to associate the stylesheet with the document?
Cheers,
--Phil.

Quoting Phil Endecott <spam_from_inkscape_users@...1394...>:
Mental suggested:
This is basically what CSS classes are for; I think we do have sufficient CSS support to use them now, but not good UI for CSS yet.
Great, I can do CSS, and "instance of a class" is a more familiar mental model (HTML+CSS, C++) than "duplicate of a clone".
So, I can set a class attribute on things using the XML editor [is there an easier way?] and I can write a CSS stylesheet in a text editor. Can you help me to associate the stylesheet with the document?
Yes, you're stuck with the XML editor at the moment.
For now, you'll also need to embed the stylesheet in the document; use an svg:style element inside svg:defs, give it a type="text/css" attribute, and add a single text node inside it to hold the actual stylesheet. The XML editor includes a simple text editor for modifying text nodes.
[ You will find "unset" fills helpful here too, to allow the class properties to "take over". ]
Hopefully our CSS support is mature enough to handle this now; I haven't tried this yet, but I know peter has been working on it a lot.
-mental

mental@...32... wrote:
Quoting Phil Endecott <spam_from_inkscape_users@...1394...>:
Mental suggested:
This is basically what CSS classes are for; I think we do have sufficient CSS support to use them now, but not good UI for CSS yet.
So, I can set a class attribute on things using the XML editor [is there an easier way?] and I can write a CSS stylesheet in a text editor. Can you help me to associate the stylesheet with the document?
For now, you'll also need to embed the stylesheet in the document; use an svg:style element inside svg:defs, give it a type="text/css" attribute, and add a single text node inside it to hold the actual stylesheet. The XML editor includes a simple text editor for modifying text nodes.
[ You will find "unset" fills helpful here too, to allow the class properties to "take over". ]
I've had a go and it doesn't immediately work; maybe I'm missing something? (This is with the Debian package of 0.43.) Here's what I did:
I created a rectangle. I set a class="foo" attribute using the XML editor.
I created an svg:style type="text/css" as a child of svg:defs containing:
.foo { color: green; background-color: blue; }
[As an aside, I tried pressing ctrl+enter to save the content of the text node, as is necessary for attributes, but got this:
** (inkscape:10764): CRITICAL **: virtual void Inkscape::XML::SimpleNode::setAttribute(const gchar*, const gchar*, bool): assertion `name && *name' failed
I'll assume that there's no need to save the text node contents.]
I selected my rectangle and chose undefined paint for the fill and stroke.
I was hoping to see some green and blue stuff at this point, but didn't. Looking at the style attribute on the rectangle I noticed that color: was still defined, so I removed it manually. Still no luck.
I decided to save the file so that I could try and view it with another SVG viewer, or post it here, but I got an internal error.
The file was saved though, and looks sensible. rsvg-view also doesn't show the green and blue that I was asking for, but I don't know if they claim to do css at all.
I've also tried with #rect1309 as the css selector, and #RRGGBB colour values, without any luck.
So, the file is attached. Am I doing something wrong, or have I just gone beyond what Inkscape currently supports?
Cheers,
--Phil.
participants (2)
-
unknown@example.com
-
Phil Endecott