issue173:inkscape
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue173:inkscape [2021/09/26 11:05] – créée auntiee | issue173:inkscape [2021/10/03 17:34] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | Last time, I indulged in a whistle-stop tour of CSS support in SVG files, in preparation for this month’s topic: the Selectors and CSS dialog. As I noted previously, this dialog first appeared as a hidden option in Inkscape version 1.0, and was then officially exposed in version 1.0.1. It can be opened using the Ctrl-Shift-Q keyboard shortcut (even on v1.0), with later releases also exposing it via the Object menu. In my experience, it’s still a little buggy, even in version 1.1, and can lead to full application crashes, so please make sure to save regularly if you decide to use it. | + | **Last time, I indulged in a whistle-stop tour of CSS support in SVG files, in preparation for this month’s topic: the Selectors and CSS dialog. As I noted previously, this dialog first appeared as a hidden option in Inkscape version 1.0, and was then officially exposed in version 1.0.1. It can be opened using the Ctrl-Shift-Q keyboard shortcut (even on v1.0), with later releases also exposing it via the Object menu. In my experience, it’s still a little buggy, even in version 1.1, and can lead to full application crashes, so please make sure to save regularly if you decide to use it. |
To describe the operation of this dialog requires a sample document on which to work – preferably one with a mixture of elements to target via CSS selectors. For the purposes of this article, therefore, I’ve created a collection of sixteen elements (four squares, four circles, four stars, and four Bézier paths), arranged as four rows, with the content of each row being grouped. | To describe the operation of this dialog requires a sample document on which to work – preferably one with a mixture of elements to target via CSS selectors. For the purposes of this article, therefore, I’ve created a collection of sixteen elements (four squares, four circles, four stars, and four Bézier paths), arranged as four rows, with the content of each row being grouped. | ||
- | The style of each object is the same, and that information is stored in the element’s “style” property, as Inkscape does by default. Looking at the first row, therefore, the structure of the SVG content boils down to something like that shown top right. | + | The style of each object is the same, and that information is stored in the element’s “style” property, as Inkscape does by default. Looking at the first row, therefore, the structure of the SVG content boils down to something like that shown top right.** |
- | As usual, I’ve omitted a lot of the SVG content for clarity, including additional style properties and the namespaces of most of the elements and attributes. Note the first path, however, where I have specifically included the sodipodi: | + | La dernière fois, je me suis livré à un rapide tour du support CSS dans les fichiers SVG, en préparation du sujet de ce mois-ci : le dialogue Sélecteurs et CSS. Comme je l'ai indiqué précédemment, |
+ | |||
+ | Pour décrire le fonctionnement de cette boîte de dialogue, il faut disposer d'un document type sur lequel travailler - de préférence un document comportant un mélange d' | ||
+ | |||
+ | Le style de chaque objet est le même et cette information est stockée dans la propriété « style » de l' | ||
+ | |||
+ | |||
+ | **As usual, I’ve omitted a lot of the SVG content for clarity, including additional style properties and the namespaces of most of the elements and attributes. Note the first path, however, where I have specifically included the sodipodi: | ||
Now it’s time to open the Selectors and CSS dialog (hereafter referred to as the Selectors dialog, for brevity), via the Object > Selectors and CSS… menu entry. With nothing selected on the page, be prepared for something of a disappointment, | Now it’s time to open the Selectors and CSS dialog (hereafter referred to as the Selectors dialog, for brevity), via the Object > Selectors and CSS… menu entry. With nothing selected on the page, be prepared for something of a disappointment, | ||
- | The buttons in the bottom-right corner can be used to switch between horizontal and vertical orientation – though in both cases, in my opinion, the panels are presented in the wrong order. The only other interactive elements at this stage are the plus and minus buttons in the bottom-right corner. The latter does nothing right now (and should probably be disabled), leaving us with little to do but press the plus (+) button. This will open a small “CSS Selector” dialog, pre-filled with a class name (including the preceding dot, as required in CSS syntax). | + | The buttons in the bottom-right corner can be used to switch between horizontal and vertical orientation – though in both cases, in my opinion, the panels are presented in the wrong order. The only other interactive elements at this stage are the plus and minus buttons in the bottom-right corner. The latter does nothing right now (and should probably be disabled), leaving us with little to do but press the plus (+) button. This will open a small “CSS Selector” dialog, pre-filled with a class name (including the preceding dot, as required in CSS syntax).** |
- | Let’s just run with this for now, accepting the default selector value by clicking the Add button. Brace yourself for the overwhelming complexity of the change it makes to the main dialog. | + | Comme d' |
+ | |||
+ | Il est maintenant temps d' | ||
+ | |||
+ | Les boutons dans le coin inférieur droit peuvent être utilisés pour passer de l' | ||
+ | |||
+ | |||
+ | **Let’s just run with this for now, accepting the default selector value by clicking the Add button. Brace yourself for the overwhelming complexity of the change it makes to the main dialog. | ||
When you’ve fully recovered from the excitement, you might want to take a moment to really appreciate what has happened: there’s now an entry in the right-hand panel labelled “.Class1”, | When you’ve fully recovered from the excitement, you might want to take a moment to really appreciate what has happened: there’s now an entry in the right-hand panel labelled “.Class1”, | ||
- | The purpose of this button is to add the class name to any selected SVG elements, causing them to match the CSS selector and appear in the dialog. Let’s look at a practical example by selecting the first element from each row. Remember that each row is a separate group, so we have to hold Ctrl+Shift to select an object within the group (Ctrl) and add to the existing selection (Shift). With those keys held, it’s a simple task to click on the first object in each row, giving us a selection of four items. Clicking on the plus button now will add the “Class1” class to each of the elements, and the Selectors dialog updates to show us the IDs of the elements that match the selector. | + | The purpose of this button is to add the class name to any selected SVG elements, causing them to match the CSS selector and appear in the dialog. Let’s look at a practical example by selecting the first element from each row. Remember that each row is a separate group, so we have to hold Ctrl+Shift to select an object within the group (Ctrl) and add to the existing selection (Shift). With those keys held, it’s a simple task to click on the first object in each row, giving us a selection of four items. Clicking on the plus button now will add the “Class1” class to each of the elements, and the Selectors dialog updates to show us the IDs of the elements that match the selector.** |
- | In the XML code those elements now look something like this: | + | Pour l' |
+ | |||
+ | Lorsque vous serez complètement remis de cette excitation, vous voudrez peut-être prendre un moment pour vraiment apprécier ce qui s'est passé : il y a maintenant une entrée dans le panneau de droite étiquetée « .Class1 » et avec un autre bouton « plus » à côté ! Vous pouvez sélectionner la nouvelle ligne, mais un double-clic ne vous permettra pas de modifier la valeur ; il n'y a aucun moyen de modifier un sélecteur une fois qu'il a été ajouté, aussi, si vous faites une erreur, votre seul recours est de le supprimer et de recommencer. En parlant de suppression, | ||
+ | |||
+ | Le but de ce bouton est d' | ||
+ | |||
+ | |||
+ | **In the XML code those elements now look something like this: | ||
<rect class=" | <rect class=" | ||
Ligne 22: | Ligne 43: | ||
Note that Inkscape gives < | Note that Inkscape gives < | ||
- | The left pane shows the CSS properties that apply to the currently selected elements, in this case reflecting the stylesheet that Inkscape has created in the head of the document. The plus button lets us add more properties. The UI is a little clunky, but when you click the button, a new blank entry will be created with the property name field focused, ready for you to type into. Put in the property name, then press Enter or Tab to move to the value field, where you can type a suitable value for your property. Here, for example, is what happens to our selection when I set a couple of CSS colors, one for the stroke and another for the fill. | + | The left pane shows the CSS properties that apply to the currently selected elements, in this case reflecting the stylesheet that Inkscape has created in the head of the document. The plus button lets us add more properties. The UI is a little clunky, but when you click the button, a new blank entry will be created with the property name field focused, ready for you to type into. Put in the property name, then press Enter or Tab to move to the value field, where you can type a suitable value for your property. Here, for example, is what happens to our selection when I set a couple of CSS colors, one for the stroke and another for the fill.** |
- | Each property has a button, which can be used to remove it completely, and a checkbox that can be used to toggle it on and off. But these don’t necessarily work the way you might expect. In this example, you might think that turning off (or deleting) the fill property would revert the objects back to their previous red fill, but that’s not the case at all. Instead the fill changes to black. | + | Dans le code XML, ces éléments ressemblent maintenant à quelque chose comme ceci : |
+ | |||
+ | <rect class=" | ||
+ | |||
+ | Notez qu' | ||
+ | |||
+ | Le volet de gauche affiche les propriétés CSS qui s' | ||
+ | |||
+ | |||
+ | **Each property has a button, which can be used to remove it completely, and a checkbox that can be used to toggle it on and off. But these don’t necessarily work the way you might expect. In this example, you might think that turning off (or deleting) the fill property would revert the objects back to their previous red fill, but that’s not the case at all. Instead the fill changes to black. | ||
What’s going on here? Remember from last month that CSS properties in a “style” attribute override those from the stylesheet. But our elements all had their fill and stroke set via style attributes when we created them, so how did the yellow fill (which comes from the stylesheet) ever work in the first place? The answer is that Inkscape automatically deletes conflicting properties from the style attribute when you start adding them via the Selectors dialog. | What’s going on here? Remember from last month that CSS properties in a “style” attribute override those from the stylesheet. But our elements all had their fill and stroke set via style attributes when we created them, so how did the yellow fill (which comes from the stylesheet) ever work in the first place? The answer is that Inkscape automatically deletes conflicting properties from the style attribute when you start adding them via the Selectors dialog. | ||
- | In this case, it means that the red fill from the style attribute was removed as soon as the yellow fill was added to the stylesheet. Turn that entry off, however, and Inkscape no longer has any idea what fill color to use. In that case the SVG spec is quite clear: the initial value for fill – the one that Inkscape falls back to – is black. The spec also defines the initial value for stroke to be “none” - so disabling or deleting the stroke property actually results in the whole stroke being removed, rather than a thick black stroke remaining. | + | In this case, it means that the red fill from the style attribute was removed as soon as the yellow fill was added to the stylesheet. Turn that entry off, however, and Inkscape no longer has any idea what fill color to use. In that case the SVG spec is quite clear: the initial value for fill – the one that Inkscape falls back to – is black. The spec also defines the initial value for stroke to be “none” - so disabling or deleting the stroke property actually results in the whole stroke being removed, rather than a thick black stroke remaining.** |
- | Side effects like this mean that working with the Selectors dialog can be a little tricky if you’re not careful, or don’t have a thorough understanding of the SVG and CSS rules. It’s easy to assume that you can add a fill color, then just delete it to revert your change if you want, but, as this example demonstrates, | + | Chaque propriété possède un bouton, qui permet de la supprimer complètement, |
+ | |||
+ | Qu' | ||
+ | |||
+ | Dans ce cas, cela signifie que le remplissage rouge de l' | ||
+ | |||
+ | |||
+ | **Side effects like this mean that working with the Selectors dialog can be a little tricky if you’re not careful, or don’t have a thorough understanding of the SVG and CSS rules. It’s easy to assume that you can add a fill color, then just delete it to revert your change if you want, but, as this example demonstrates, | ||
With both rules re-enabled, let’s take a look at the left-hand pane when only a single ID entry is selected in the right pane. | With both rules re-enabled, let’s take a look at the left-hand pane when only a single ID entry is selected in the right pane. | ||
- | The left pane now shows not only the rules that are applied due to the new class that was added, but also those that are defined in the style attribute on the object itself in a section labelled “element”. You can edit existing values, or add new ones via this part of the dialog. If we set the fill color on the element itself, you’ll also note that the value supplied by the class – the one from the stylesheet – acquires a strike-through to indicate that the property has been overridden by another one. | + | The left pane now shows not only the rules that are applied due to the new class that was added, but also those that are defined in the style attribute on the object itself in a section labelled “element”. You can edit existing values, or add new ones via this part of the dialog. If we set the fill color on the element itself, you’ll also note that the value supplied by the class – the one from the stylesheet – acquires a strike-through to indicate that the property has been overridden by another one.** |
- | Hopefully you can now see why I think these panes are in the wrong order: you first have to select an item in the right-hand pane in order to populate the content in the left one, whereas conventional left-to-right UI design (for an LTR based language) would suggest the pane in which you perform the action should be to the left of the one which reacts to that action. | + | Les effets secondaires de ce genre signifient que le travail avec la boîte de dialogue Sélecteurs peut être un peu délicat si vous n' |
+ | |||
+ | Les deux règles étant réactivées, | ||
+ | |||
+ | Le volet de gauche affiche maintenant non seulement les règles qui sont appliquées en raison de la nouvelle classe ajoutée, mais aussi celles qui sont définies dans l' | ||
+ | |||
+ | |||
+ | **Hopefully you can now see why I think these panes are in the wrong order: you first have to select an item in the right-hand pane in order to populate the content in the left one, whereas conventional left-to-right UI design (for an LTR based language) would suggest the pane in which you perform the action should be to the left of the one which reacts to that action. | ||
As well as buttons to delete individual properties, you’ve no-doubt noticed that there are delete buttons next to the IDs in the right hand pane. Clicking one of these will remove the class name from that element’s “class” property, removing it from the dialog, and removing any class rules that apply to it. Once again, however, any conflicting rules that were previously in the “style” attribute are long since gone, so you’re likely to end up with a black fill and no stroke once more. | As well as buttons to delete individual properties, you’ve no-doubt noticed that there are delete buttons next to the IDs in the right hand pane. Clicking one of these will remove the class name from that element’s “class” property, removing it from the dialog, and removing any class rules that apply to it. Once again, however, any conflicting rules that were previously in the “style” attribute are long since gone, so you’re likely to end up with a black fill and no stroke once more. | ||
- | Next time, we’ll add a few more items to our selection, look at how best to use this dialog as a replacement for the old “Selection Sets” feature, and begin to explore some of the more varied CSS selectors that can be used in this dialog – albeit with some pretty big caveats! | + | Next time, we’ll add a few more items to our selection, look at how best to use this dialog as a replacement for the old “Selection Sets” feature, and begin to explore some of the more varied CSS selectors that can be used in this dialog – albeit with some pretty big caveats!** |
+ | |||
+ | J' | ||
+ | |||
+ | En plus des boutons permettant de supprimer des propriétés individuelles, | ||
+ | |||
+ | La prochaine fois, nous ajouterons quelques éléments supplémentaires à notre sélection, nous verrons comment utiliser au mieux cette boîte de dialogue en remplacement de l' | ||
issue173/inkscape.1632647156.txt.gz · Dernière modification : 2021/09/26 11:05 de auntiee