livepatheffect-editor.cpp revision c0cd5511d3b975ebe07d019c1f5528108725e438
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * \brief LivePathEffect dialog
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Johan Engelen <j.b.c.engelen@utwente.nl>
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Copyright (C) 2007 Author
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Released under GNU GPL. Read the file 'COPYING' for more information.
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen/*####################
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Callback functions
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenstatic void lpeeditor_selection_changed (Inkscape::Selection * selection, gpointer data)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen LivePathEffectEditor *lpeeditor = static_cast<LivePathEffectEditor *>(data);
8001ba81cb851b38d86650a2fef5817facffb763johanengelenstatic void lpeeditor_selection_modified( Inkscape::Selection *selection, guint /*flags*/, gpointer data )
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen/*#######################
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * LivePathEffectEditor
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen : UI::Widget::Panel("", "dialogs.livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT),
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen combo_effecttype(Inkscape::LivePathEffect::LPETypeConverter),
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen button_apply(_("_Apply"), _("Apply chosen effect to selection")),
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen button_remove(_("_Remove"), _("Remove effect from selection")),
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectapplication_frame(_("Apply new effect")),
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectapplication_hbox.pack_start(combo_effecttype, true, true);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectapplication_hbox.pack_start(button_apply, true, true);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectapplication_frame.add(effectapplication_hbox);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectcontrol_vbox.pack_start(explain_label, true, true);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectcontrol_vbox.pack_end(button_remove, true, true);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen contents->pack_start(effectapplication_frame, true, true);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen contents->pack_start(effectcontrol_frame, true, true);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen // connect callback functions to buttons
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen button_apply.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onApply));
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen button_remove.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onRemove));
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenLivePathEffectEditor::showParams(LivePathEffect::Effect* effect)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen explain_label.set_markup("<b>" + effect->getName() + "</b>");
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectcontrol_vbox.pack_start(*effectwidget, true, true);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen // fixme: do resizing of dialog
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenLivePathEffectEditor::showText(Glib::ustring const &str)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen // fixme: do resizing of dialog ?
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenLivePathEffectEditor::set_sensitize_all(bool sensitive)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenLivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen LivePathEffectObject *lpeobj = sp_shape_get_livepatheffectobject(shape);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenLivePathEffectEditor::setDesktop(SPDesktop *desktop)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen Inkscape::Selection *selection = sp_desktop_selection(desktop);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen selection_changed_connection = selection->connectChanged(
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen sigc::bind (sigc::ptr_fun(&lpeeditor_selection_changed), this ) );
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen selection_modified_connection = selection->connectModified(
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen sigc::bind (sigc::ptr_fun(&lpeeditor_selection_modified), this ) );
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen/*########################################################################
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen# BUTTON CLICK HANDLERS (callbacks)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen########################################################################*/
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen// TODO: factor out the effect applying code which can be called from anywhere. (selection-chemistry.cpp also needs it)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen const Util::EnumData<LivePathEffect::EffectType>* data = combo_effecttype.get_active_data();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if (!data) return;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:path-effect");
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen repr->setAttribute("effect", data->key.c_str() );
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen SP_OBJECT_REPR(SP_DOCUMENT_DEFS(doc))->addChild(repr, NULL); // adds to <defs> and assigns the 'id' attribute
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen sp_shape_set_path_effect(SP_SHAPE(item), href);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen // make sure there is an original-d for paths!!!
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen Inkscape::XML::Node *pathrepr = SP_OBJECT_REPR(item);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if ( ! pathrepr->attribute("inkscape:original-d") ) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen pathrepr->setAttribute("inkscape:original-d", pathrepr->attribute("d"));
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen LivePathEffectObject *lpeobj = sp_shape_get_livepatheffectobject(SP_SHAPE(item));
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen sp_document_done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT,
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen _("Create and apply path effect"));
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen _("Remove path effect") );
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen} // namespace Dialog
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen} // namespace UI
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen} // namespace Inkscape