Inkscape
Vector Graphics Editor
|
The SelectorsDialog class A list of CSS selectors will show up in this dialog. More...
#include <selectorsdialog.h>
Classes | |
class | ModelColumns |
class | TreeStore |
Public Member Functions | |
SelectorsDialog () | |
Constructor A treeview and a set of two buttons are added to the dialog. | |
~SelectorsDialog () final | |
void | update () final |
The update() method is essential to Gtk state management. | |
void | desktopReplaced () final |
Called when the desktop has certainly changed. | |
void | documentReplaced () final |
void | selectionChanged (Selection *selection) final |
![]() | |
DialogBase (char const *prefs_path=nullptr, Glib::ustring dialog_type={}) | |
DialogBase constructor. | |
DialogBase (DialogBase const &)=delete | |
DialogBase & | operator= (DialogBase const &)=delete |
~DialogBase () override | |
void | setDesktop (SPDesktop *new_desktop) |
Called when the desktop might have changed for this dialog. | |
void | on_map () override |
Glib::ustring const & | get_name () const |
Glib::ustring const & | getPrefsPath () const |
Glib::ustring const & | get_type () const |
const Glib::ustring & | get_icon () const |
void | blink () |
Highlight notebook where dialog already exists. | |
virtual void | focus_dialog () |
void | defocus_dialog () |
bool | getShowing () |
void | fix_inner_scroll (Gtk::ScrolledWindow &scrollwin) |
SPDesktop * | getDesktop () const |
Private Types | |
enum | SelectorType { CLASS , ID , TAG } |
enum | coltype { OBJECT , SELECTOR , OTHER } |
Private Member Functions | |
void | removeObservers () |
void | _nodeAdded (Inkscape::XML::Node &repr) |
void | _nodeRemoved (Inkscape::XML::Node &repr) |
void | _nodeChanged (Inkscape::XML::Node &repr) |
Inkscape::XML::Node * | _getStyleTextNode (bool create_if_missing=false) |
void | _readStyleElement () |
Fill the internal Gtk::TreeStore from the svg:style element. | |
void | _insertSyntacticElement (CSS::RuleStatement const &rule, bool expand, Gtk::TreeIter< Gtk::TreeRow > where) |
Populate a tree row with a representation of a CSS rule statement. | |
void | _insertSyntacticElement (CSS::BlockAtStatement const &block_at, bool expand, Gtk::TreeIter< Gtk::TreeRow > where) |
Populate a tree row with a representation of a CSS block -statement. | |
void | _insertSyntacticElement (CSS::OtherStatement const &other, bool, Gtk::TreeIter< Gtk::TreeRow > where) |
Populate a tree row with a representation of a generic ("other") CSS statement. | |
void | _writeStyleElement () |
Update the content of the style element as selectors (or objects) are added/removed. | |
Glib::ustring | _formatRowAsCSS (Gtk::TreeConstRow const &row) const |
Return the representation of the contents of a tree row in the dialog as a CSS string. | |
std::vector< SPObject * > | getSelectedObjects () |
void | _addToSelector (Gtk::TreeModel::Row row) |
void | _removeFromSelector (Gtk::TreeModel::Row row) |
Glib::ustring | _getIdList (std::vector< SPObject * >) |
std::vector< SPObject * > | _getObjVec (Glib::ustring const &selector) |
void | _insertClass (const std::vector< SPObject * > &objVec, const Glib::ustring &className) |
void | _insertClass (SPObject *obj, const Glib::ustring &className) |
void | _removeClass (const std::vector< SPObject * > &objVec, const Glib::ustring &className, bool all=false) |
void | _removeClass (SPObject *obj, const Glib::ustring &className, bool all=false) |
void | _toggleDirection (Gtk::ToggleButton *vertical) |
void | _showWidgets () |
void | _rowExpand (const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &path) |
void | _rowCollapse (const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &path) |
void | _closeDialog (Gtk::Dialog *textDialogPtr) |
void | _addSelector () |
This function opens a dialog to add a selector. | |
void | _delSelector () |
This function deletes selector when '-' at the bottom is clicked. | |
void | onTreeViewClickReleased (int n_press, double x, double y) |
void | _selectRow () |
This function selects the row in treeview corresponding to an object selected in the drawing. | |
void | _vscroll () |
void | _styleButton (Gtk::Button &btn, char const *iconName, char const *tooltip) |
Static Private Member Functions | |
static Glib::ustring | _getSelectorClasses (Glib::ustring selector) |
Private Attributes | |
ModelColumns | _mColumns |
Glib::RefPtr< Gtk::TreeModelFilter > | _modelfilter |
Glib::RefPtr< TreeStore > | _store |
Gtk::TreeView | _treeView |
Gtk::TreeModel::Path | _lastpath |
StyleDialog * | _style_dialog |
Gtk::Paned | _paned |
Glib::RefPtr< Gtk::Adjustment > | _vadj |
Gtk::Box | _button_box |
Gtk::Box | _selectors_box |
Gtk::ScrolledWindow | _scrolled_window_selectors |
Gtk::Button | _del |
Gtk::Button | _create |
std::unique_ptr< Inkscape::XML::NodeObserver > | m_nodewatcher |
std::unique_ptr< Inkscape::XML::NodeObserver > | m_styletextwatcher |
double | _scrollpos {0.0} |
bool | _scrollock {false} |
bool | _updating {false} |
Inkscape::XML::Node * | m_root {nullptr} |
Inkscape::XML::Node * | _textNode {nullptr} |
Inkscape::XML::SignalObserver | _objObserver |
Additional Inherited Members | |
![]() | |
InkscapeApplication * | getApp () const |
SPDocument * | getDocument () const |
Selection * | getSelection () const |
void | setShowing (bool showing) |
function called from notebook dialog that performs an update of the dialog and sets the dialog showing state true | |
![]() | |
Glib::ustring | _name |
Glib::ustring const | _prefs_path |
Glib::ustring const | _dialog_type |
The SelectorsDialog class A list of CSS selectors will show up in this dialog.
This dialog allows one to add and delete selectors. Elements can be added to and removed from the selectors in the dialog. Selection of any selector row selects the matching objects in the drawing and vice-versa. (Only simple selectors supported for now.)
This class must keep two things in sync:
Definition at line 54 of file selectorsdialog.h.
|
private |
Enumerator | |
---|---|
OBJECT | |
SELECTOR | |
OTHER |
Definition at line 78 of file selectorsdialog.h.
|
private |
Enumerator | |
---|---|
CLASS | |
ID | |
TAG |
Definition at line 73 of file selectorsdialog.h.
Inkscape::UI::Dialog::SelectorsDialog::SelectorsDialog | ( | ) |
Constructor A treeview and a set of two buttons are added to the dialog.
_addSelector adds selectors to treeview. _delSelector deletes the selector from the dialog. Any addition/deletion of the selectors updates XML style element accordingly.
Definition at line 221 of file selectorsdialog.cpp.
References _addToSelector(), Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_colSelector, Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_colType, _del, Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_fontWeight, _mColumns, _removeFromSelector(), _rowCollapse(), _rowExpand(), _scrollpos, _selectRow(), _showWidgets(), _store, _treeView, _updating, _vadj, _vscroll(), Inkscape::UI::Dialog::SelectorsDialog::TreeStore::create(), label, m_nodewatcher, and m_styletextwatcher.
|
final |
Definition at line 1142 of file selectorsdialog.cpp.
|
private |
This function opens a dialog to add a selector.
The dialog is prefilled with an 'id' selector containing a list of the id's of selected objects or with a 'class' selector if no objects are selected.
By default, the entrybox contains 'Class1' as text. However, if object(s) is(are) selected and user clicks '+' at the bottom of dialog, the entrybox will have the id(s) of the selected objects as text.
selectorValue This string stores selector name. The text from entrybox is saved as name for selector. If the entrybox is empty, the text (thus selectorName) is set to ".Class1"
Definition at line 956 of file selectorsdialog.cpp.
References cr_selector_destroy(), cr_selector_parse_from_buf(), CR_UTF_8, Inkscape::UI::dialog_run(), FONT_WEIGHT_NORMAL, Inkscape::UI::pack_start(), result, Inkscape::CSS::selector_to_validated_string(), Inkscape::UI::shrink, Inkscape::Util::trim(), and Inkscape::UI::Dialog::vector_contains().
Referenced by _showWidgets().
|
private |
row | Add selected objects on the desktop to the selector corresponding to 'row'. |
Definition at line 658 of file selectorsdialog.cpp.
References Inkscape::XML::Node::attributeList(), css, FONT_WEIGHT_NORMAL, key, sp_repr_css_attr_add_from_string(), sp_repr_css_attr_new(), sp_repr_css_attr_unref(), and sp_repr_css_write_string().
Referenced by SelectorsDialog().
|
private |
Definition at line 1090 of file selectorsdialog.cpp.
|
private |
This function deletes selector when '-' at the bottom is clicked.
Note: If deleting a class selector, class attributes are NOT changed.
Definition at line 1096 of file selectorsdialog.cpp.
Referenced by _showWidgets().
|
private |
Return the representation of the contents of a tree row in the dialog as a CSS string.
Definition at line 544 of file selectorsdialog.cpp.
|
private |
sel |
Definition at line 820 of file selectorsdialog.cpp.
|
private |
selector | a valid CSS selector string. |
Definition at line 841 of file selectorsdialog.cpp.
Referenced by _insertSyntacticElement().
|
staticprivate |
Definition at line 590 of file selectorsdialog.cpp.
References SPAttributeRelSVG::isSVGElement(), and Inkscape::Util::trim().
|
private |
Definition at line 375 of file selectorsdialog.cpp.
References _textNode, Inkscape::XML::Node::addObserver(), Inkscape::UI::Dialog::get_first_style_text_node(), m_root, m_styletextwatcher, and Inkscape::XML::Node::removeObserver().
Referenced by _readStyleElement().
|
private |
objs | list of objects to insert class |
class | class to insert Insert a class name into objects' 'class' attribute. |
Definition at line 855 of file selectorsdialog.cpp.
|
private |
objs | list of objects to insert class |
class | class to insert Insert a class name into objects' 'class' attribute. |
Definition at line 876 of file selectorsdialog.cpp.
References Inkscape::XML::Node::attribute(), SPObject::getRepr(), Inkscape::XML::Node::setAttribute(), and Inkscape::UI::Dialog::vector_contains().
|
private |
Populate a tree row with a representation of a CSS block -statement.
Reminder: a block -statement is something like
@media print { rect { fill: none; } ... } In particular, the block may contain further nested blocks.
block_at | The block -statement |
expand | Whether the tree row should be expanded |
where | Iterator to the tree row to populate |
Definition at line 446 of file selectorsdialog.cpp.
References Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_colExpand, Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_colObj, Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_colSelector, Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_colType, Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_fontWeight, _mColumns, Inkscape::CSS::BlockAtStatement::at_statement, Inkscape::CSS::BlockAtStatement::block_content, FONT_WEIGHT_NORMAL, and OTHER.
|
private |
Populate a tree row with a representation of a generic ("other") CSS statement.
This function is used for statements other than rule set statements or block -statements, for example for an @charset statement.
other | The CSS statement |
where | Iterator to the tree row to populate |
Definition at line 471 of file selectorsdialog.cpp.
References Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_colExpand, Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_colObj, Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_colSelector, Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_colType, Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_fontWeight, _mColumns, FONT_WEIGHT_NORMAL, and OTHER.
|
private |
Populate a tree row with a representation of a CSS rule statement.
Reminder: a rule statement is something like
.selector1, #selector2 { fill: red; stroke-width: 2pt; }
rule | The rule statement |
expand | Whether the tree row should be expanded |
where | Iterator to the tree row to populate |
Definition at line 406 of file selectorsdialog.cpp.
References Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_colExpand, Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_colObj, Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_colProperties, Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_colSelector, Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_colType, Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_fontWeight, _getObjVec(), _mColumns, _store, FONT_WEIGHT_NORMAL, OBJECT, Inkscape::CSS::RuleStatement::rules, SELECTOR, and Inkscape::CSS::RuleStatement::selectors.
|
private |
Definition at line 136 of file selectorsdialog.cpp.
References _readStyleElement(), and _selectRow().
|
private |
Definition at line 152 of file selectorsdialog.cpp.
References _readStyleElement(), _scrollock, and _selectRow().
|
private |
Definition at line 142 of file selectorsdialog.cpp.
References _readStyleElement(), _selectRow(), and _textNode.
|
private |
Fill the internal Gtk::TreeStore from the svg:style element.
Definition at line 484 of file selectorsdialog.cpp.
References Inkscape::UI::Dialog::SelectorsDialog::ModelColumns::_colExpand, _getStyleTextNode(), _mColumns, _scrollock, _store, _updating, Inkscape::CSS::SyntacticDecomposition::for_each(), and label.
Referenced by _nodeAdded(), _nodeChanged(), and _nodeRemoved().
|
private |
objs | list of objects to insert class |
class | class to insert Insert a class name into objects' 'class' attribute. |
Definition at line 905 of file selectorsdialog.cpp.
|
private |
objs | list of objects to insert class |
class | class to insert Insert a class name into objects' 'class' attribute. |
Definition at line 919 of file selectorsdialog.cpp.
References Inkscape::XML::Node::attribute(), SPObject::getRepr(), Inkscape::XML::Node::removeAttribute(), Inkscape::XML::Node::setAttribute(), and Inkscape::Util::trim().
|
private |
row | Remove the object corresponding to 'row' from the parent selector. |
Definition at line 757 of file selectorsdialog.cpp.
References parent, SPStyle::readFromObject(), SPObject::requestDisplayUpdate(), SPObject::style, and Inkscape::Util::trim().
Referenced by SelectorsDialog().
|
private |
Definition at line 536 of file selectorsdialog.cpp.
Referenced by SelectorsDialog().
|
private |
Definition at line 529 of file selectorsdialog.cpp.
Referenced by SelectorsDialog().
|
private |
This function selects the row in treeview corresponding to an object selected in the drawing.
If more than one row matches, the first is chosen.
Definition at line 1191 of file selectorsdialog.cpp.
References FONT_WEIGHT_BOLD, FONT_WEIGHT_NORMAL, Inkscape::Selection::includes(), and Inkscape::ObjectSet::isEmpty().
Referenced by _nodeAdded(), _nodeChanged(), _nodeRemoved(), and SelectorsDialog().
|
private |
Definition at line 291 of file selectorsdialog.cpp.
References _addSelector(), _button_box, _create, _del, _delSelector(), _paned, _scrolled_window_selectors, _selectors_box, _style_dialog, _styleButton(), _toggleDirection(), _treeView, _updating, _vadj, _vscroll(), Inkscape::UI::expand_widget, Inkscape::Preferences::get(), Inkscape::Preferences::getBool(), Inkscape::UI::pack_end(), Inkscape::UI::pack_start(), and Inkscape::UI::shrink.
Referenced by SelectorsDialog().
|
private |
btn | |
iconName | |
tooltip | Set the style of '+' and '-' buttons at the bottom of dialog. |
Definition at line 1265 of file selectorsdialog.cpp.
Referenced by _showWidgets().
|
private |
Definition at line 357 of file selectorsdialog.cpp.
References _paned, Inkscape::Preferences::get(), Inkscape::Preferences::setBool(), and Inkscape::Preferences::setInt().
Referenced by _showWidgets().
|
private |
Definition at line 281 of file selectorsdialog.cpp.
References _scrollock, _scrollpos, and _vadj.
Referenced by _showWidgets(), and SelectorsDialog().
|
private |
Update the content of the style element as selectors (or objects) are added/removed.
Definition at line 566 of file selectorsdialog.cpp.
References Inkscape::DocumentUndo::done(), and Inkscape::XML::Node::setContent().
|
finalvirtual |
Called when the desktop has certainly changed.
It may have changed to nullptr when destructing the dialog, so the override should expect nullptr too.
Reimplemented from Inkscape::UI::Dialog::DialogBase.
Definition at line 1153 of file selectorsdialog.cpp.
|
finalvirtual |
Reimplemented from Inkscape::UI::Dialog::DialogBase.
Definition at line 1170 of file selectorsdialog.cpp.
|
private |
Definition at line 648 of file selectorsdialog.cpp.
|
private |
|
private |
Definition at line 1158 of file selectorsdialog.cpp.
|
finalvirtual |
Reimplemented from Inkscape::UI::Dialog::DialogBase.
Definition at line 1180 of file selectorsdialog.cpp.
|
finalvirtual |
The update() method is essential to Gtk state management.
DialogBase implementations get updated whenever a new focus event happens if they are in a DialogWindow or if they are in the currently focused window.
DO NOT use update to keep SPDesktop, SPDocument or Selection states, use the virtual functions below.
Reimplemented from Inkscape::UI::Dialog::DialogBase.
Definition at line 1148 of file selectorsdialog.cpp.
|
private |
Definition at line 128 of file selectorsdialog.h.
Referenced by _showWidgets().
|
private |
Definition at line 133 of file selectorsdialog.h.
Referenced by _showWidgets().
|
private |
Definition at line 132 of file selectorsdialog.h.
Referenced by _showWidgets(), and SelectorsDialog().
|
private |
Definition at line 123 of file selectorsdialog.h.
|
private |
Definition at line 96 of file selectorsdialog.h.
Referenced by _insertSyntacticElement(), _insertSyntacticElement(), _insertSyntacticElement(), _readStyleElement(), Inkscape::UI::Dialog::SelectorsDialog::TreeStore::row_draggable_vfunc(), and SelectorsDialog().
|
private |
Definition at line 120 of file selectorsdialog.h.
|
private |
Definition at line 176 of file selectorsdialog.h.
|
private |
Definition at line 126 of file selectorsdialog.h.
Referenced by _showWidgets(), and _toggleDirection().
|
private |
Definition at line 130 of file selectorsdialog.h.
Referenced by _showWidgets().
|
private |
Definition at line 167 of file selectorsdialog.h.
Referenced by _nodeChanged(), _readStyleElement(), and _vscroll().
|
private |
Definition at line 166 of file selectorsdialog.h.
Referenced by _vscroll(), and SelectorsDialog().
|
private |
Definition at line 129 of file selectorsdialog.h.
Referenced by _showWidgets().
|
private |
Definition at line 121 of file selectorsdialog.h.
Referenced by _insertSyntacticElement(), _readStyleElement(), and SelectorsDialog().
|
private |
Definition at line 125 of file selectorsdialog.h.
Referenced by _showWidgets().
|
private |
Definition at line 170 of file selectorsdialog.h.
Referenced by _getStyleTextNode(), and _nodeRemoved().
|
private |
Definition at line 122 of file selectorsdialog.h.
Referenced by _showWidgets(), and SelectorsDialog().
|
private |
Definition at line 168 of file selectorsdialog.h.
Referenced by _readStyleElement(), _showWidgets(), and SelectorsDialog().
|
private |
Definition at line 127 of file selectorsdialog.h.
Referenced by _showWidgets(), _vscroll(), and SelectorsDialog().
|
private |
Definition at line 149 of file selectorsdialog.h.
Referenced by SelectorsDialog().
|
private |
Definition at line 169 of file selectorsdialog.h.
Referenced by _getStyleTextNode().
|
private |
Definition at line 150 of file selectorsdialog.h.
Referenced by _getStyleTextNode(), and SelectorsDialog().