issue174:inkscape
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
issue174:inkscape [2021/11/01 13:13] – d52fr | issue174:inkscape [2021/11/04 09:23] (Version actuelle) – auntiee | ||
---|---|---|---|
Ligne 5: | Ligne 5: | ||
This, essentially, | This, essentially, | ||
+ | |||
+ | Ce mois-ci, nous allons continuer à étudier la boîte de dialogue Sélecteurs et CSS (ou simplement « dialogue des Sélecteurs »). C'est le moment idéal pour revoir les deux derniers épisodes, si nécessaire, | ||
+ | |||
+ | Le mois dernier, je vous ai montré, à partir d'un dialogue des Sélecteurs vierge, comment sélectionner le premier élément de chaque rangée (Ctrl-Maj + un clic sur chacun d'eux) et comment leur ajouter une nouvelle classe pour qu'ils apparaissent dans la boîte de dialogue. Faisons la même chose cette fois-ci : | ||
+ | |||
+ | Précédemment, | ||
+ | |||
+ | En gros, cela nous ramène à la capacité de la boîte de dialogue Ensembles de sélection, qui a été introduite dans la version 0.92, mais supprimée dans la version 1.0. | ||
+ | |||
**The Selection Sets dialog allowed you to name (and re-name) your sets, change the label for each object, and add or remove items from sets. The new Selectors dialog is slightly more limited. Double-clicking on the CSS selector won’t let you edit it – so you’re stuck with the class name you initially created. The listed items are now shown as IDs rather than labels (they include the “#” prefix that CSS uses for IDs, making this difference a little clearer). Double-clicking on an ID just selects it, it doesn’t allow you to edit the label or the ID of the object in question. | **The Selection Sets dialog allowed you to name (and re-name) your sets, change the label for each object, and add or remove items from sets. The new Selectors dialog is slightly more limited. Double-clicking on the CSS selector won’t let you edit it – so you’re stuck with the class name you initially created. The listed items are now shown as IDs rather than labels (they include the “#” prefix that CSS uses for IDs, making this difference a little clearer). Double-clicking on an ID just selects it, it doesn’t allow you to edit the label or the ID of the object in question. | ||
Ligne 11: | Ligne 20: | ||
You can still, however, add and remove things from the “set” – though in reality what you’re actually doing is adding and removing the class from the object. We looked at removing items last time – you just need to click on the delete button to the left of each thing you want to remove. Doing this will also remove any style overrides, most likely returning you to a black fill with no stroke, but if you’re using this dialog just for managing selection sets and haven’t modified any styles, then this won’t be a concern.** | You can still, however, add and remove things from the “set” – though in reality what you’re actually doing is adding and removing the class from the object. We looked at removing items last time – you just need to click on the delete button to the left of each thing you want to remove. Doing this will also remove any style overrides, most likely returning you to a black fill with no stroke, but if you’re using this dialog just for managing selection sets and haven’t modified any styles, then this won’t be a concern.** | ||
+ | |||
+ | Le dialogue Ensembles de sélection vous permettait de nommer (et de renommer) vos ensembles, de modifier l' | ||
+ | |||
+ | Toutefois, la boîte de dialogue Sélecteurs se met à jour en temps réel en fonction des modifications du contenu du SVG, donc si vous voulez vraiment changer le nom de votre classe, vous pouvez le modifier dans la boîte de dialogue Édition > Éditeur XML. Sachez seulement que la modification du nom du sélecteur dans la feuille de style n' | ||
+ | |||
+ | Cependant, vous pouvez toujours ajouter et supprimer des éléments de l' | ||
+ | |||
**Adding new items to the set is also pretty straightforward. You simply have to select them on the canvas, then click the “+” button next to the CSS selector. In this example, I’ve selected the items from the second column and clicked the button, and you can clearly now see that the set contains eight items. | **Adding new items to the set is also pretty straightforward. You simply have to select them on the canvas, then click the “+” button next to the CSS selector. In this example, I’ve selected the items from the second column and clicked the button, and you can clearly now see that the set contains eight items. | ||
Ligne 21: | Ligne 37: | ||
• Select all the squares, by Ctrl-Shift-Clicking each of them. | • Select all the squares, by Ctrl-Shift-Clicking each of them. | ||
• Click the “+” next to the “.squares” CSS selector line in order to add the “squares” class to each item, thus making them appear in the set.** | • Click the “+” next to the “.squares” CSS selector line in order to add the “squares” class to each item, thus making them appear in the set.** | ||
+ | |||
+ | L' | ||
+ | |||
+ | En cliquant sur le sélecteur CSS (l' | ||
+ | |||
+ | Grâce à cette technique, vous pouvez créer de nouvelles classes (c' | ||
+ | ••Désélectionnez tout, en utilisant Édition > Désélectionner, | ||
+ | ••Cliquez sur le bouton « + » en bas de la boîte de dialogue Sélecteurs. Malheureusement, | ||
+ | ••Sélectionnez tous les carrés, en faisant Ctrl-Shift + un clic sur chacun d' | ||
+ | ••Cliquez sur le « + » à côté de la ligne du sélecteur CSS « .squares » afin d' | ||
+ | |||
**If done correctly, the dialog should now be showing both the “.squares” class (with four items) and the “.Class1” class (with the eight items we added previously). The sections can be collapsed and expanded using the toggle triangles next to the class name, and selecting either of them will select the corresponding set of items on the page. | **If done correctly, the dialog should now be showing both the “.squares” class (with four items) and the “.Class1” class (with the eight items we added previously). The sections can be collapsed and expanded using the toggle triangles next to the class name, and selecting either of them will select the corresponding set of items on the page. | ||
Ligne 27: | Ligne 54: | ||
As mentioned, clicking on a class selector in the second pane will not only show you the relevant CSS properties on the left, but it will also select all the objects with that class on the page – a replacement for the Selection Sets dialog. You should use this capability carefully, however. I recommend treating “Selection Set” classes and “Styling” classes as two different things.** | As mentioned, clicking on a class selector in the second pane will not only show you the relevant CSS properties on the left, but it will also select all the objects with that class on the page – a replacement for the Selection Sets dialog. You should use this capability carefully, however. I recommend treating “Selection Set” classes and “Styling” classes as two different things.** | ||
+ | |||
+ | Si cela a été fait correctement, | ||
+ | |||
+ | À tout moment, vous pouvez sélectionner d' | ||
+ | |||
+ | Comme nous l' | ||
+ | |||
**What do I mean by that? Last time, I demonstrated how you could use classes to change the style of the selected elements. But if you do that, it’s very easy to end up with elements that have no styling applied at all, if you subsequently remove the class name from them. So if you want to use this dialog to manage classes as though they were selection sets, it’s best not to also apply any styles as part of those classes. I recommend using one class (or set of classes) for selections, with no style changes in the left-hand pane, and different classes for styling changes, even if it means you have two classes that actually select the same objects. | **What do I mean by that? Last time, I demonstrated how you could use classes to change the style of the selected elements. But if you do that, it’s very easy to end up with elements that have no styling applied at all, if you subsequently remove the class name from them. So if you want to use this dialog to manage classes as though they were selection sets, it’s best not to also apply any styles as part of those classes. I recommend using one class (or set of classes) for selections, with no style changes in the left-hand pane, and different classes for styling changes, even if it means you have two classes that actually select the same objects. | ||
Here’s that method in practice: the “.squares” class is as it was before, it just selects all the squares, but doesn’t change their style. The “.yellow-fill” class contains exactly the same objects, but changes their fill color. Now if I want to also change the stars to have a yellow fill, I can add them to the latter class, without disrupting the “selection set” formed by the “.squares” class.** | Here’s that method in practice: the “.squares” class is as it was before, it just selects all the squares, but doesn’t change their style. The “.yellow-fill” class contains exactly the same objects, but changes their fill color. Now if I want to also change the stars to have a yellow fill, I can add them to the latter class, without disrupting the “selection set” formed by the “.squares” class.** | ||
+ | |||
+ | Qu' | ||
+ | |||
+ | Voici cette méthode en pratique : la classe « .squares » est comme avant, elle sélectionne simplement tous les carrés, mais ne change pas leur style. La classe « .yellow-fill » contient exactement les mêmes objets, mais change leur couleur de remplissage. Maintenant, si je veux aussi changer les étoiles pour qu' | ||
+ | |||
**Up to now, I’ve looked at creating just class-based selectors in this dialog, but you can also use it to create other types of rules in your stylesheet. So far, we’ve added the “squares” and “yellow-fill” classes to all of the squares in the image, but because these are all the same type of SVG primitive, there’s an easier way to select or style them all: the element selector. The squares are all < | **Up to now, I’ve looked at creating just class-based selectors in this dialog, but you can also use it to create other types of rules in your stylesheet. So far, we’ve added the “squares” and “yellow-fill” classes to all of the squares in the image, but because these are all the same type of SVG primitive, there’s an easier way to select or style them all: the element selector. The squares are all < | ||
Inkscape did not automatically prefix the word “rect” with a dot, as it would have done when creating a class selector. This implies that the program must maintain a whitelist of element names which are allowed to pass through untouched. To avoid accidentally creating an element selector when you meant to create a class selector, therefore, I recommend always including the leading dot when entering a new class name. In this case, for example, typing “.rect” into the prompt does create a class selector as expected, whereas omitting the dot creates an element selector.** | Inkscape did not automatically prefix the word “rect” with a dot, as it would have done when creating a class selector. This implies that the program must maintain a whitelist of element names which are allowed to pass through untouched. To avoid accidentally creating an element selector when you meant to create a class selector, therefore, I recommend always including the leading dot when entering a new class name. In this case, for example, typing “.rect” into the prompt does create a class selector as expected, whereas omitting the dot creates an element selector.** | ||
+ | |||
+ | Jusqu' | ||
+ | |||
+ | Inkscape n'a pas automatiquement fait précéder le mot « rect » d'un point, comme il l' | ||
+ | |||
**One advantage of element selectors is that they are dynamic in nature. Add another rectangle to the page and it will automatically be included in your “rect” selector. But be aware that inclusion in the selector may not be enough for it to behave the way you expect. In the example above, the “rect” selector defines a thick blue stroke, yet drawing a new rectangle doesn’t produce that result. | **One advantage of element selectors is that they are dynamic in nature. Add another rectangle to the page and it will automatically be included in your “rect” selector. But be aware that inclusion in the selector may not be enough for it to behave the way you expect. In the example above, the “rect” selector defines a thick blue stroke, yet drawing a new rectangle doesn’t produce that result. | ||
The reason for this is that the new elements you draw will have their style properties set via their “style” attribute, as usual. As we found out previously, these will override those in the stylesheet, preventing the element rules from working. The solution is to remove the override rules from the “style” attribute – which can be done by selecting the element and then deleting the rules from the “element” section of the left pane in the Selectors dialog. Nevertheless, | The reason for this is that the new elements you draw will have their style properties set via their “style” attribute, as usual. As we found out previously, these will override those in the stylesheet, preventing the element rules from working. The solution is to remove the override rules from the “style” attribute – which can be done by selecting the element and then deleting the rules from the “element” section of the left pane in the Selectors dialog. Nevertheless, | ||
+ | |||
+ | L'un des avantages des sélecteurs d' | ||
+ | |||
+ | La raison en est que les nouveaux éléments que vous dessinez verront leurs propriétés de style définies via leur attribut « style », comme d' | ||
**Element selectors also exhibit some odd behaviour within the dialog. Each matching element has its ID shown below the selector, as you would expect, but they still have delete buttons next to them. Clicking one of those buttons does nothing: it doesn’t delete the element itself (which would be the only practical way to remove them from the selector), so they appear to be completely redundant. Worse than that, clicking the selector itself ,then the “-” button at the bottom of the dialog, does not delete the selector. Removing an accidentally created element selector, or one that is no longer needed, requires a trip to the XML editor. | **Element selectors also exhibit some odd behaviour within the dialog. Each matching element has its ID shown below the selector, as you would expect, but they still have delete buttons next to them. Clicking one of those buttons does nothing: it doesn’t delete the element itself (which would be the only practical way to remove them from the selector), so they appear to be completely redundant. Worse than that, clicking the selector itself ,then the “-” button at the bottom of the dialog, does not delete the selector. Removing an accidentally created element selector, or one that is no longer needed, requires a trip to the XML editor. | ||
Element and class-based aren’t the only types of CSS selectors supported by this dialog, however. The other types also come with a few potential inconsistencies and problems, but that’s the subject of next month’s instalment…** | Element and class-based aren’t the only types of CSS selectors supported by this dialog, however. The other types also come with a few potential inconsistencies and problems, but that’s the subject of next month’s instalment…** | ||
+ | |||
+ | Les sélecteurs d' | ||
+ | |||
+ | Les sélecteurs d' | ||
+ | |||
issue174/inkscape.1635768815.txt.gz · Dernière modification : 2021/11/01 13:13 de d52fr