diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2008-05-30 20:36:13 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2008-05-30 20:36:13 +0000 |
| commit | 8e8734dc15e614586f9b4963b69671ce16d5c137 (patch) | |
| tree | 036c4af16f6f673757e6e2c580a8ec5c4f3518de /src/ui | |
| parent | remove warnings (diff) | |
| download | inkscape-8e8734dc15e614586f9b4963b69671ce16d5c137.tar.gz inkscape-8e8734dc15e614586f9b4963b69671ce16d5c137.zip | |
LPE STACKING!
(many thanks to the french students who made this.)
(bzr r5766)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/clipboard.cpp | 9 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-editor.cpp | 163 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-editor.h | 50 |
3 files changed, 204 insertions, 18 deletions
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index fff6e3b09..2d38f5ccd 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -61,6 +61,7 @@ #include "sp-textpath.h" #include "sp-rect.h" #include "live_effects/lpeobject.h" +#include "live_effects/lpeobject-reference.h" #include "live_effects/parameter/path.h" #include "svg/svg.h" // for sp_svg_transform_write, used in _copySelection #include "svg/css-ostringstream.h" // used in _parseColor @@ -560,10 +561,14 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) } } // For lpe items, copy liveeffect if applicable + // TODO: copy the whole effect stack. now it only copies current selected effect if (SP_IS_LPE_ITEM(item)) { SPLPEItem *lpeitem = SP_LPE_ITEM (item); if (sp_lpe_item_has_path_effect(lpeitem)) { - _copyNode(SP_OBJECT_REPR(SP_OBJECT(sp_lpe_item_get_livepatheffectobject(lpeitem))), _doc, _defs); + Inkscape::LivePathEffect::LPEObjectReference* lperef = sp_lpe_item_get_current_lpereference(lpeitem); + if (lperef && lperef->lpeobject) { + _copyNode(SP_OBJECT_REPR(SP_OBJECT(lperef->lpeobject)), _doc, _defs); + } } } // For 3D boxes, copy perspectives @@ -900,7 +905,7 @@ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effect) if (!obj) return; // if the effect is not used by anyone, we might as well take it LivePathEffectObject *lpeobj = LIVEPATHEFFECT(obj)->fork_private_if_necessary(1); - sp_lpe_item_set_path_effect(lpeitem, lpeobj); + sp_lpe_item_add_path_effect(lpeitem, lpeobj); } } diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 43cdb726c..c92d015f5 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -23,6 +23,7 @@ #include "sp-item-group.h" #include "sp-path.h" #include "sp-rect.h" +#include "sp-lpe-item.h" #include "path-chemistry.h" #include "live_effects/effect.h" #include "live_effects/lpeobject.h" @@ -34,6 +35,10 @@ #include "document-private.h" #include "xml/node.h" #include "xml/document.h" +#include <gtkmm/stock.h> +#include <gtkmm/toolbar.h> + +#include "live_effects/lpeobject-reference.h" namespace Inkscape { class Application; @@ -59,38 +64,88 @@ static void lpeeditor_selection_changed (Inkscape::Selection * selection, gpoint LivePathEffectEditor::LivePathEffectEditor() : UI::Widget::Panel("", "dialogs.livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT), combo_effecttype(Inkscape::LivePathEffect::LPETypeConverter), - button_apply(_("_Apply"), _("Apply chosen effect to selection")), - button_remove(_("_Remove"), _("Remove effect from selection")), effectwidget(NULL), explain_label("", Gtk::ALIGN_CENTER), effectapplication_frame(_("Apply new effect")), effectcontrol_frame(_("Current effect")), - current_desktop(NULL) + effectlist_frame(_("Effect list")), + button_up(Gtk::Stock::GO_UP), + button_down(Gtk::Stock::GO_DOWN), + button_apply(Gtk::Stock::ADD), + button_remove(Gtk::Stock::REMOVE), + current_desktop(NULL), + current_lpeitem(NULL) { Gtk::Box *contents = _getContents(); contents->set_spacing(4); + //Add the TreeView, inside a ScrolledWindow, with the button underneath: + scrolled_window.add(effectlist_view); + //Only show the scrollbars when they are necessary: + scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + effectapplication_hbox.set_spacing(4); effectcontrol_vbox.set_spacing(4); + effectlist_vbox.set_spacing(4); effectapplication_hbox.pack_start(combo_effecttype, true, true); effectapplication_hbox.pack_start(button_apply, true, true); effectapplication_frame.add(effectapplication_hbox); + effectlist_vbox.pack_start(scrolled_window, Gtk::PACK_EXPAND_WIDGET); + effectlist_vbox.pack_end(toolbar, Gtk::PACK_SHRINK); + // effectlist_vbox.pack_end(button_hbox, Gtk::PACK_SHRINK); + effectlist_frame.add(effectlist_vbox); + effectcontrol_vbox.pack_start(explain_label, true, true); - effectcontrol_vbox.pack_end(button_remove, true, true); effectcontrol_frame.add(effectcontrol_vbox); + // button_hbox.pack_start(button_up, true, true); + // button_hbox.pack_start(button_down, true, true); + // button_hbox.pack_end(button_remove, true, true); + toolbar.set_toolbar_style(Gtk::TOOLBAR_ICONS); + // Add toolbar items to toolbar + toolbar.append(button_up); + toolbar.append(button_down); + toolbar.append(button_remove); + + + // Add toolbar + //add_toolbar(toolbar); + toolbar.show_all(); //Show the toolbar and all its child widgets. + + + //Create the Tree model: + effectlist_store = Gtk::ListStore::create(columns); + effectlist_view.set_model(effectlist_store); + + effectlist_view.set_rules_hint(); + effectlist_view.set_headers_clickable(true); + effectlist_view.set_headers_visible(true); + + // Handle tree selections + effectlist_selection = effectlist_view.get_selection(); + effectlist_selection->signal_changed().connect( sigc::mem_fun(*this, &LivePathEffectEditor::on_effect_selection_changed) ); + + effectlist_view.set_headers_visible(false); + //Add the TreeView's view columns: + effectlist_view.append_column("Effect", columns.col_name); + + contents->pack_start(effectapplication_frame, false, false); + contents->pack_start(effectlist_frame, true, true); contents->pack_start(effectcontrol_frame, false, false); // connect callback functions to buttons button_apply.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onApply)); button_remove.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onRemove)); + button_up.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onUp)); + button_down.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onDown)); + show_all_children(); - button_remove.hide(); + //button_remove.hide(); } LivePathEffectEditor::~LivePathEffectEditor() @@ -136,7 +191,7 @@ LivePathEffectEditor::showText(Glib::ustring const &str) } explain_label.set_label(str); - button_remove.hide(); + //button_remove.hide(); // fixme: do resizing of dialog ? } @@ -147,21 +202,33 @@ LivePathEffectEditor::set_sensitize_all(bool sensitive) combo_effecttype.set_sensitive(sensitive); button_apply.set_sensitive(sensitive); button_remove.set_sensitive(sensitive); + effectlist_view.set_sensitive(sensitive); + button_up.set_sensitive(sensitive); + button_down.set_sensitive(sensitive); } + void LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) { + effectlist_store->clear(); + current_lpeitem = NULL; + if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); if ( item ) { if ( SP_IS_LPE_ITEM(item) ) { SPLPEItem *lpeitem = SP_LPE_ITEM(item); - LivePathEffectObject *lpeobj = sp_lpe_item_get_livepatheffectobject(lpeitem); + + effect_list_update(lpeitem); + + current_lpeitem = lpeitem; + set_sensitize_all(true); - if (lpeobj) { - if (lpeobj->lpe) { - showParams(lpeobj->lpe); + if ( sp_lpe_item_has_path_effect(lpeitem) ) { + Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(lpeitem); + if (lpe) { + showParams(lpe); } else { showText(_("Unknown effect is applied")); } @@ -185,6 +252,22 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) } } +void +LivePathEffectEditor::effect_list_update(SPLPEItem *lpeitem) +{ + effectlist_store->clear(); + + PathEffectList effectlist = sp_lpe_item_get_effect_list(lpeitem); + PathEffectList::iterator it; + for( it = effectlist.begin() ; it!=effectlist.end(); it++ ) + { + Gtk::TreeModel::Row row = *(effectlist_store->append()); + row[columns.col_name] = (*it)->lpeobject->lpe->getName(); + row[columns.lperef] = *it; + } +} + + void LivePathEffectEditor::setDesktop(SPDesktop *desktop) { @@ -247,7 +330,7 @@ LivePathEffectEditor::onApply() Inkscape::GC::release(repr); gchar *href = g_strdup_printf("#%s", repr_id); - sp_lpe_item_set_path_effect(SP_LPE_ITEM(item), href, true); + sp_lpe_item_add_path_effect(SP_LPE_ITEM(item), href, true); g_free(href); sp_document_done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT, @@ -265,15 +348,67 @@ LivePathEffectEditor::onRemove() if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); if ( item && SP_IS_LPE_ITEM(item) ) { - sp_lpe_item_remove_path_effect(SP_LPE_ITEM(item), false); - showText(_("No effect applied")); - button_remove.set_sensitive(false); + sp_lpe_item_remove_current_path_effect(SP_LPE_ITEM(item), false); + + sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + _("Remove path effect") ); + + effect_list_update(SP_LPE_ITEM(item)); + } + } +} + +void LivePathEffectEditor::onUp() +{ + Inkscape::Selection *sel = _getSelection(); + if ( sel && !sel->isEmpty() ) { + SPItem *item = sel->singleItem(); + if ( item && SP_IS_LPE_ITEM(item) ) { + + sp_lpe_item_up_current_path_effect(SP_LPE_ITEM(item)); + + sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + _("Remove path effect") ); + + effect_list_update(SP_LPE_ITEM(item)); + } + } + +} + +void LivePathEffectEditor::onDown() +{ + Inkscape::Selection *sel = _getSelection(); + if ( sel && !sel->isEmpty() ) { + SPItem *item = sel->singleItem(); + if ( item && SP_IS_LPE_ITEM(item) ) { + + sp_lpe_item_down_current_path_effect(SP_LPE_ITEM(item)); + sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Remove path effect") ); + + effect_list_update(SP_LPE_ITEM(item)); } } } +void LivePathEffectEditor::on_effect_selection_changed() +{ + Glib::RefPtr<Gtk::TreeSelection> sel = effectlist_view.get_selection(); + if (sel->count_selected_rows () == 0) + return; + + Gtk::TreeModel::iterator it = sel->get_selected(); + LivePathEffect::LPEObjectReference * lperef = (*it)[columns.lperef]; + + if (lperef && current_lpeitem) { + sp_lpe_item_set_current_path_effect(current_lpeitem, lperef); + showParams(lperef->lpeobject->lpe); + } +} + + } // namespace Dialog } // namespace UI } // namespace Inkscape diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h index dc96fc313..e2c7da322 100644 --- a/src/ui/dialog/livepatheffect-editor.h +++ b/src/ui/dialog/livepatheffect-editor.h @@ -21,6 +21,13 @@ #include <gtkmm/tooltips.h> #include "ui/widget/combo-enums.h" #include "live_effects/effect.h" +#include "live_effects/lpeobject-reference.h" +#include <gtkmm/liststore.h> +#include <gtkmm/treeview.h> +#include <gtkmm/scrolledwindow.h> +#include <gtkmm/buttonbox.h> +#include <gtkmm/toolbar.h> + class SPDesktop; @@ -37,6 +44,7 @@ public: static LivePathEffectEditor &getInstance() { return *new LivePathEffectEditor(); } void onSelectionChanged(Inkscape::Selection *sel); + virtual void on_effect_selection_changed(); void setDesktop(SPDesktop *desktop); private: @@ -47,22 +55,60 @@ private: void showParams(LivePathEffect::Effect* effect); void showText(Glib::ustring const &str); + // void add_entry(const char* name ); + void effect_list_update(SPLPEItem *lpeitem); + // callback methods for buttons on grids page. void onApply(); void onRemove(); + void onUp(); + void onDown(); + + class ModelColumns : public Gtk::TreeModel::ColumnRecord + { + public: + ModelColumns() + { + add(col_name); + add(lperef); + } + + Gtk::TreeModelColumn<Glib::ustring> col_name; + Gtk::TreeModelColumn<LivePathEffect::LPEObjectReference *> lperef; + }; + Inkscape::UI::Widget::ComboBoxEnum<LivePathEffect::EffectType> combo_effecttype; - Inkscape::UI::Widget::Button button_apply; - Inkscape::UI::Widget::Button button_remove; + Gtk::Widget * effectwidget; Gtk::Label explain_label; Gtk::Frame effectapplication_frame; Gtk::Frame effectcontrol_frame; + Gtk::Frame effectlist_frame; Gtk::HBox effectapplication_hbox; Gtk::VBox effectcontrol_vbox; + Gtk::VBox effectlist_vbox; Gtk::Tooltips tooltips; + ModelColumns columns; + Gtk::ScrolledWindow scrolled_window; + Gtk::TreeView effectlist_view; + Glib::RefPtr<Gtk::ListStore> effectlist_store; + Glib::RefPtr<Gtk::TreeSelection> effectlist_selection; + + Gtk::Toolbar toolbar; + Gtk::ToolButton button_up; + Gtk::ToolButton button_down; + Gtk::Button button_apply; + Gtk::ToolButton button_remove; + /*Gtk::HButtonBox button_hbox; + Gtk::Button button_up; + Gtk::Button button_down; + Gtk::Button button_apply; + Gtk::Button button_remove;*/ SPDesktop * current_desktop; + + SPLPEItem * current_lpeitem; LivePathEffectEditor(LivePathEffectEditor const &d); LivePathEffectEditor& operator=(LivePathEffectEditor const &d); |
