From e0396836d3738f9b6d2182f310795fc6fe9d8857 Mon Sep 17 00:00:00 2001 From: kamalpreetgrewal Date: Mon, 18 Jul 2016 00:14:29 +0530 Subject: Add CSS panel with editing support (no changes reflected yet) (bzr r14949.1.52) --- src/ui/dialog/cssdialog.cpp | 83 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/ui/dialog/cssdialog.cpp (limited to 'src/ui/dialog/cssdialog.cpp') diff --git a/src/ui/dialog/cssdialog.cpp b/src/ui/dialog/cssdialog.cpp new file mode 100644 index 000000000..b0123482b --- /dev/null +++ b/src/ui/dialog/cssdialog.cpp @@ -0,0 +1,83 @@ +/** @file + * @brief A dialog for CSS selectors + */ +/* Authors: + * Kamalpreet Kaur Grewal + * + * Copyright (C) Kamalpreet Kaur Grewal 2016 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "cssdialog.h" +#include "ui/widget/addtoicon.h" +#include "widgets/icon.h" +#include "verbs.h" +#include "sp-object.h" +#include "selection.h" +#include "xml/attribute-record.h" + +namespace Inkscape { +namespace UI { +namespace Dialog { + +CssDialog::CssDialog(): + UI::Widget::Panel("", "/dialogs/css", SP_VERB_DIALOG_CSS), + _desktop(0) +{ + set_size_request(50, 50); + _mainBox.pack_start(_scrolledWindow, Gtk::PACK_EXPAND_WIDGET); + _treeView.set_headers_visible(false); + _scrolledWindow.add(_treeView); + _scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + + _store = Gtk::ListStore::create(_cssColumns); + _treeView.set_model(_store); + + Inkscape::UI::Widget::AddToIcon * addRenderer = manage( + new Inkscape::UI::Widget::AddToIcon() ); + addRenderer->property_active() = false; + + int addCol = _treeView.append_column("Unset Property", *addRenderer) - 1; + Gtk::TreeViewColumn *col = _treeView.get_column(addCol); + if ( col ) { + col->add_attribute( addRenderer->property_active(), _cssColumns._colUnsetProp); + } + _textRenderer = Gtk::manage(new Gtk::CellRendererText()); + _textRenderer->property_editable() = true; + + int nameColNum = _treeView.append_column("Property", *_textRenderer) - 1; + _propCol = _treeView.get_column(nameColNum); + + _getContents()->pack_start(_mainBox, Gtk::PACK_EXPAND_WIDGET); + + _targetDesktop = getDesktop(); + setDesktop(_targetDesktop); + + _textRenderer->signal_edited().connect(sigc::mem_fun(*this, &CssDialog:: + _handleEdited)); +} + +CssDialog::~CssDialog() +{ + setDesktop(NULL); +} + +void CssDialog::setDesktop( SPDesktop* desktop ) +{ + _desktop = desktop; +} + +void CssDialog::_handleEdited(const Glib::ustring& path, const Glib::ustring& new_text) +{ + Gtk::TreeModel::iterator iter = _treeView.get_model()->get_iter(path); + if (iter) { + Gtk::TreeModel::Row row = *iter; + row[_cssColumns._propertyLabel] = new_text; + editedProp = new_text; + } +} + +} // namespace Dialog +} // namespace UI +} // namespace Inkscape -- cgit v1.2.3 From 96b7038386f56aa59a9d0935989469105234d2fe Mon Sep 17 00:00:00 2001 From: kamalpreetgrewal Date: Tue, 19 Jul 2016 14:39:24 +0530 Subject: Update XML & hence drawing when properties are edited in CSS panel (bzr r14949.1.54) --- src/ui/dialog/cssdialog.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src/ui/dialog/cssdialog.cpp') diff --git a/src/ui/dialog/cssdialog.cpp b/src/ui/dialog/cssdialog.cpp index b0123482b..e12716d6e 100644 --- a/src/ui/dialog/cssdialog.cpp +++ b/src/ui/dialog/cssdialog.cpp @@ -21,6 +21,11 @@ namespace Inkscape { namespace UI { namespace Dialog { +/** + * Constructor + * A treeview whose each row corresponds to a CSS property of selector selected. + * TODO: Further, buttons to add and delete properties will be added. + */ CssDialog::CssDialog(): UI::Widget::Panel("", "/dialogs/css", SP_VERB_DIALOG_CSS), _desktop(0) @@ -53,9 +58,6 @@ CssDialog::CssDialog(): _targetDesktop = getDesktop(); setDesktop(_targetDesktop); - - _textRenderer->signal_edited().connect(sigc::mem_fun(*this, &CssDialog:: - _handleEdited)); } CssDialog::~CssDialog() @@ -68,16 +70,6 @@ void CssDialog::setDesktop( SPDesktop* desktop ) _desktop = desktop; } -void CssDialog::_handleEdited(const Glib::ustring& path, const Glib::ustring& new_text) -{ - Gtk::TreeModel::iterator iter = _treeView.get_model()->get_iter(path); - if (iter) { - Gtk::TreeModel::Row row = *iter; - row[_cssColumns._propertyLabel] = new_text; - editedProp = new_text; - } -} - } // namespace Dialog } // namespace UI } // namespace Inkscape -- cgit v1.2.3 From be3b537680814fd07a0a5776724028f09f78a023 Mon Sep 17 00:00:00 2001 From: kamalpreetgrewal Date: Wed, 20 Jul 2016 12:51:39 +0530 Subject: Separate CSS dialog from Style Dialog visually (bzr r14949.1.56) --- src/ui/dialog/cssdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/dialog/cssdialog.cpp') diff --git a/src/ui/dialog/cssdialog.cpp b/src/ui/dialog/cssdialog.cpp index e12716d6e..9007faafc 100644 --- a/src/ui/dialog/cssdialog.cpp +++ b/src/ui/dialog/cssdialog.cpp @@ -30,7 +30,7 @@ CssDialog::CssDialog(): UI::Widget::Panel("", "/dialogs/css", SP_VERB_DIALOG_CSS), _desktop(0) { - set_size_request(50, 50); + set_size_request(20, 15); _mainBox.pack_start(_scrolledWindow, Gtk::PACK_EXPAND_WIDGET); _treeView.set_headers_visible(false); _scrolledWindow.add(_treeView); -- cgit v1.2.3 From 39c55178f470bf12c6a7fc51d5d17b65b319faf2 Mon Sep 17 00:00:00 2001 From: kamalpreetgrewal Date: Tue, 26 Jul 2016 21:45:08 +0530 Subject: Add functionality to add and delete CSS property in CSS panel (bzr r14949.1.61) --- src/ui/dialog/cssdialog.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/ui/dialog/cssdialog.cpp') diff --git a/src/ui/dialog/cssdialog.cpp b/src/ui/dialog/cssdialog.cpp index 9007faafc..cd2f74d15 100644 --- a/src/ui/dialog/cssdialog.cpp +++ b/src/ui/dialog/cssdialog.cpp @@ -21,6 +21,23 @@ namespace Inkscape { namespace UI { namespace Dialog { +/** + * @brief CssDialog::_styleButton + * @param btn + * @param iconName + * @param tooltip + * This function sets the style of '+'button at the bottom of dialog. + */ +void CssDialog::_styleButton(Gtk::Button& btn, char const* iconName, + char const* tooltip) +{ + GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName); + gtk_widget_show(child); + btn.add(*manage(Glib::wrap(child))); + btn.set_relief(Gtk::RELIEF_NONE); + btn.set_tooltip_text (tooltip); +} + /** * Constructor * A treeview whose each row corresponds to a CSS property of selector selected. @@ -54,10 +71,18 @@ CssDialog::CssDialog(): int nameColNum = _treeView.append_column("Property", *_textRenderer) - 1; _propCol = _treeView.get_column(nameColNum); + create = manage(new Gtk::Button()); + _styleButton(*create, "list-add", "Add a new property"); + + _mainBox.pack_end(_buttonBox, Gtk::PACK_SHRINK); + _buttonBox.pack_start(*create, Gtk::PACK_SHRINK); + _getContents()->pack_start(_mainBox, Gtk::PACK_EXPAND_WIDGET); _targetDesktop = getDesktop(); setDesktop(_targetDesktop); + + create->signal_clicked().connect(sigc::mem_fun(*this, &CssDialog::_addProperty)); } CssDialog::~CssDialog() @@ -70,6 +95,18 @@ void CssDialog::setDesktop( SPDesktop* desktop ) _desktop = desktop; } +/** + * @brief CssDialog::_addProperty + * This function is a slot to signal_clicked for '+' button at the bottom of CSS + * panel. A new row is added, double clicking which text for new property can be + * added. _newProperty is set to true in which case the value is appended. + */ +void CssDialog::_addProperty() +{ + _propRow = *(_store->append()); + _newProperty = true; +} + } // namespace Dialog } // namespace UI } // namespace Inkscape -- cgit v1.2.3 From bb2023c0d4971e15f12394b85dc52b8ae49225eb Mon Sep 17 00:00:00 2001 From: kamalpreetgrewal Date: Sat, 20 Aug 2016 12:39:45 +0530 Subject: Add some more comments to improve code understanding (bzr r14949.1.75) --- src/ui/dialog/cssdialog.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src/ui/dialog/cssdialog.cpp') diff --git a/src/ui/dialog/cssdialog.cpp b/src/ui/dialog/cssdialog.cpp index cd2f74d15..fa266b012 100644 --- a/src/ui/dialog/cssdialog.cpp +++ b/src/ui/dialog/cssdialog.cpp @@ -35,13 +35,17 @@ void CssDialog::_styleButton(Gtk::Button& btn, char const* iconName, gtk_widget_show(child); btn.add(*manage(Glib::wrap(child))); btn.set_relief(Gtk::RELIEF_NONE); - btn.set_tooltip_text (tooltip); + btn.set_tooltip_text(tooltip); } /** * Constructor * A treeview whose each row corresponds to a CSS property of selector selected. - * TODO: Further, buttons to add and delete properties will be added. + * New CSS property can be added by clicking '+' at bottom of the CSS pane. '-' + * in front of the CSS property row can be clicked to delete the CSS property. + * Besides clicking on an already selected property row makes the property editable + * and clicking 'Enter' updates the property with changes reflected in the + * drawing. */ CssDialog::CssDialog(): UI::Widget::Panel("", "/dialogs/css", SP_VERB_DIALOG_CSS), @@ -56,14 +60,14 @@ CssDialog::CssDialog(): _store = Gtk::ListStore::create(_cssColumns); _treeView.set_model(_store); - Inkscape::UI::Widget::AddToIcon * addRenderer = manage( - new Inkscape::UI::Widget::AddToIcon() ); + Inkscape::UI::Widget::AddToIcon * addRenderer = manage(new Inkscape::UI:: + Widget::AddToIcon()); addRenderer->property_active() = false; int addCol = _treeView.append_column("Unset Property", *addRenderer) - 1; Gtk::TreeViewColumn *col = _treeView.get_column(addCol); - if ( col ) { - col->add_attribute( addRenderer->property_active(), _cssColumns._colUnsetProp); + if (col) { + col->add_attribute(addRenderer->property_active(), _cssColumns._colUnsetProp); } _textRenderer = Gtk::manage(new Gtk::CellRendererText()); _textRenderer->property_editable() = true; @@ -71,7 +75,7 @@ CssDialog::CssDialog(): int nameColNum = _treeView.append_column("Property", *_textRenderer) - 1; _propCol = _treeView.get_column(nameColNum); - create = manage(new Gtk::Button()); + Gtk::Button* create = manage(new Gtk::Button()); _styleButton(*create, "list-add", "Add a new property"); _mainBox.pack_end(_buttonBox, Gtk::PACK_SHRINK); @@ -85,12 +89,21 @@ CssDialog::CssDialog(): create->signal_clicked().connect(sigc::mem_fun(*this, &CssDialog::_addProperty)); } +/** + * @brief CssDialog::~CssDialog + * Class destructor + */ CssDialog::~CssDialog() { setDesktop(NULL); } -void CssDialog::setDesktop( SPDesktop* desktop ) +/** + * @brief CssDialog::setDesktop + * @param desktop + * This function sets the 'desktop' for the CSS pane. + */ +void CssDialog::setDesktop(SPDesktop* desktop) { _desktop = desktop; } -- cgit v1.2.3 From db37e627f21d79c6968f681725c7a4dd8de21081 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 14 Feb 2017 16:39:13 +0100 Subject: Rewrite and cleanup of style dialog. Still WIP. Missing undo and document tracking. (bzr r15520) --- src/ui/dialog/cssdialog.cpp | 53 +++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 23 deletions(-) (limited to 'src/ui/dialog/cssdialog.cpp') diff --git a/src/ui/dialog/cssdialog.cpp b/src/ui/dialog/cssdialog.cpp index fa266b012..d0ae822bd 100644 --- a/src/ui/dialog/cssdialog.cpp +++ b/src/ui/dialog/cssdialog.cpp @@ -3,8 +3,10 @@ */ /* Authors: * Kamalpreet Kaur Grewal + * Tavmjong Bah * * Copyright (C) Kamalpreet Kaur Grewal 2016 + * Copyright (C) Tavmjong Bah 2017 * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -21,23 +23,6 @@ namespace Inkscape { namespace UI { namespace Dialog { -/** - * @brief CssDialog::_styleButton - * @param btn - * @param iconName - * @param tooltip - * This function sets the style of '+'button at the bottom of dialog. - */ -void CssDialog::_styleButton(Gtk::Button& btn, char const* iconName, - char const* tooltip) -{ - GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName); - gtk_widget_show(child); - btn.add(*manage(Glib::wrap(child))); - btn.set_relief(Gtk::RELIEF_NONE); - btn.set_tooltip_text(tooltip); -} - /** * Constructor * A treeview whose each row corresponds to a CSS property of selector selected. @@ -60,8 +45,7 @@ CssDialog::CssDialog(): _store = Gtk::ListStore::create(_cssColumns); _treeView.set_model(_store); - Inkscape::UI::Widget::AddToIcon * addRenderer = manage(new Inkscape::UI:: - Widget::AddToIcon()); + Inkscape::UI::Widget::AddToIcon * addRenderer = manage(new Inkscape::UI::Widget::AddToIcon()); addRenderer->property_active() = false; int addCol = _treeView.append_column("Unset Property", *addRenderer) - 1; @@ -74,6 +58,10 @@ CssDialog::CssDialog(): int nameColNum = _treeView.append_column("Property", *_textRenderer) - 1; _propCol = _treeView.get_column(nameColNum); + if (_propCol) { + _propCol->add_attribute(_textRenderer->property_text(), + _cssColumns._propertyLabel); + } Gtk::Button* create = manage(new Gtk::Button()); _styleButton(*create, "list-add", "Add a new property"); @@ -83,12 +71,12 @@ CssDialog::CssDialog(): _getContents()->pack_start(_mainBox, Gtk::PACK_EXPAND_WIDGET); - _targetDesktop = getDesktop(); - setDesktop(_targetDesktop); + setDesktop(getDesktop()); create->signal_clicked().connect(sigc::mem_fun(*this, &CssDialog::_addProperty)); } + /** * @brief CssDialog::~CssDialog * Class destructor @@ -98,6 +86,7 @@ CssDialog::~CssDialog() setDesktop(NULL); } + /** * @brief CssDialog::setDesktop * @param desktop @@ -108,16 +97,34 @@ void CssDialog::setDesktop(SPDesktop* desktop) _desktop = desktop; } + +/** + * @brief CssDialog::_styleButton + * @param btn + * @param iconName + * @param tooltip + * This function sets the style of '+'button at the bottom of dialog. + */ +void CssDialog::_styleButton(Gtk::Button& btn, char const* iconName, + char const* tooltip) +{ + GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName); + gtk_widget_show(child); + btn.add(*manage(Glib::wrap(child))); + btn.set_relief(Gtk::RELIEF_NONE); + btn.set_tooltip_text(tooltip); +} + + /** * @brief CssDialog::_addProperty * This function is a slot to signal_clicked for '+' button at the bottom of CSS * panel. A new row is added, double clicking which text for new property can be - * added. _newProperty is set to true in which case the value is appended. + * added. */ void CssDialog::_addProperty() { _propRow = *(_store->append()); - _newProperty = true; } } // namespace Dialog -- cgit v1.2.3 From f352e76fcf5cc4d12d456cff756135008ad5fe06 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sun, 19 Feb 2017 10:00:27 +0100 Subject: Implement selector reordering via drag and drop. A few other tweeks. (bzr r15533) --- src/ui/dialog/cssdialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ui/dialog/cssdialog.cpp') diff --git a/src/ui/dialog/cssdialog.cpp b/src/ui/dialog/cssdialog.cpp index d0ae822bd..a5736513f 100644 --- a/src/ui/dialog/cssdialog.cpp +++ b/src/ui/dialog/cssdialog.cpp @@ -38,7 +38,7 @@ CssDialog::CssDialog(): { set_size_request(20, 15); _mainBox.pack_start(_scrolledWindow, Gtk::PACK_EXPAND_WIDGET); - _treeView.set_headers_visible(false); + _treeView.set_headers_visible(true); _scrolledWindow.add(_treeView); _scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); @@ -48,7 +48,7 @@ CssDialog::CssDialog(): Inkscape::UI::Widget::AddToIcon * addRenderer = manage(new Inkscape::UI::Widget::AddToIcon()); addRenderer->property_active() = false; - int addCol = _treeView.append_column("Unset Property", *addRenderer) - 1; + int addCol = _treeView.append_column("", *addRenderer) - 1; Gtk::TreeViewColumn *col = _treeView.get_column(addCol); if (col) { col->add_attribute(addRenderer->property_active(), _cssColumns._colUnsetProp); @@ -56,7 +56,7 @@ CssDialog::CssDialog(): _textRenderer = Gtk::manage(new Gtk::CellRendererText()); _textRenderer->property_editable() = true; - int nameColNum = _treeView.append_column("Property", *_textRenderer) - 1; + int nameColNum = _treeView.append_column("CSS Property", *_textRenderer) - 1; _propCol = _treeView.get_column(nameColNum); if (_propCol) { _propCol->add_attribute(_textRenderer->property_text(), -- cgit v1.2.3 From 0833ffbc6047245b873bb26bd30f27144edb7de0 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 24 Feb 2017 13:10:42 +0100 Subject: Display both style sheet and style attribute property values in CSS pane. (bzr r15545) --- src/ui/dialog/cssdialog.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'src/ui/dialog/cssdialog.cpp') diff --git a/src/ui/dialog/cssdialog.cpp b/src/ui/dialog/cssdialog.cpp index a5736513f..85c804b75 100644 --- a/src/ui/dialog/cssdialog.cpp +++ b/src/ui/dialog/cssdialog.cpp @@ -53,27 +53,41 @@ CssDialog::CssDialog(): if (col) { col->add_attribute(addRenderer->property_active(), _cssColumns._colUnsetProp); } - _textRenderer = Gtk::manage(new Gtk::CellRendererText()); - _textRenderer->property_editable() = true; - int nameColNum = _treeView.append_column("CSS Property", *_textRenderer) - 1; + _propRenderer = Gtk::manage(new Gtk::CellRendererText()); + _propRenderer->property_editable() = true; + int nameColNum = _treeView.append_column("CSS Property", *_propRenderer) - 1; _propCol = _treeView.get_column(nameColNum); if (_propCol) { - _propCol->add_attribute(_textRenderer->property_text(), - _cssColumns._propertyLabel); + _propCol->add_attribute(_propRenderer->property_text(), _cssColumns._propertyLabel); } - Gtk::Button* create = manage(new Gtk::Button()); - _styleButton(*create, "list-add", "Add a new property"); + _sheetRenderer = Gtk::manage(new Gtk::CellRendererText()); + _sheetRenderer->property_editable() = true; + int sheetColNum = _treeView.append_column("Style Sheet", *_sheetRenderer) - 1; + _sheetCol = _treeView.get_column(sheetColNum); + if (_sheetCol) { + _sheetCol->add_attribute(_sheetRenderer->property_text(), _cssColumns._styleSheetVal); + } + + _attrRenderer = Gtk::manage(new Gtk::CellRendererText()); + _attrRenderer->property_editable() = false; + int attrColNum = _treeView.append_column("Style Attribute", *_attrRenderer) - 1; + _attrCol = _treeView.get_column(attrColNum); + if (_attrCol) { + _attrCol->add_attribute(_attrRenderer->property_text(), _cssColumns._styleAttrVal); + } + + _styleButton(_buttonAddProperty, "list-add", "Add a new property"); _mainBox.pack_end(_buttonBox, Gtk::PACK_SHRINK); - _buttonBox.pack_start(*create, Gtk::PACK_SHRINK); + _buttonBox.pack_start(_buttonAddProperty, Gtk::PACK_SHRINK); _getContents()->pack_start(_mainBox, Gtk::PACK_EXPAND_WIDGET); setDesktop(getDesktop()); - create->signal_clicked().connect(sigc::mem_fun(*this, &CssDialog::_addProperty)); + _buttonAddProperty.signal_clicked().connect(sigc::mem_fun(*this, &CssDialog::_addProperty)); } -- cgit v1.2.3