dbb33756bd786e9432e18ec7be93f8c416e1b492Jon A. Cruz/**
dbb33756bd786e9432e18ec7be93f8c416e1b492Jon A. Cruz * @file
dbb33756bd786e9432e18ec7be93f8c416e1b492Jon A. Cruz * Live Path Effect editing dialog - implementation.
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould */
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould/* Authors:
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm * Johan Engelen <j.b.c.engelen@utwente.nl>
23d859f2ce09c04ed802cb4912cc9c50f512f0a2bgk * Steren Giannini <steren.giannini@gmail.com>
23d859f2ce09c04ed802cb4912cc9c50f512f0a2bgk * Bastien Bouclet <bgkweb@gmail.com>
9dc68827cbd515262ecb8d5ae8547d9e82c72e00Jon A. Cruz * Abhishek Sharma
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm *
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould * Copyright (C) 2007 Authors
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm * Released under GNU GPL. Read the file 'COPYING' for more information.
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm */
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm#ifdef HAVE_CONFIG_H
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm# include <config.h>
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm#endif
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
1b3a8414f17dc95fc921d999ea715c99d10dd4aaAlex Valavanis#include "livepatheffect-editor.h"
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm#include <glibmm/i18n.h>
035e109c2dce9f6a9552f75d09b1573311d02546tweenk#include <gtkmm/stock.h>
035e109c2dce9f6a9552f75d09b1573311d02546tweenk#include <gtkmm/toolbar.h>
035e109c2dce9f6a9552f75d09b1573311d02546tweenk#include <vector>
035e109c2dce9f6a9552f75d09b1573311d02546tweenk
035e109c2dce9f6a9552f75d09b1573311d02546tweenk#include "desktop.h"
9ba77856a8823f85b53c0a861d220cd0347f2754Liam P. White
035e109c2dce9f6a9552f75d09b1573311d02546tweenk#include "document.h"
47badd0035ae8c9135c51444f3770b17ae504ddaAlex Valavanis#include "document-undo.h"
035e109c2dce9f6a9552f75d09b1573311d02546tweenk#include "gtkmm/widget.h"
12d084654ee6f91cc12b6218508ee5d3e37de2baLiam P. White#include "helper/action.h"
035e109c2dce9f6a9552f75d09b1573311d02546tweenk#include "inkscape.h"
035e109c2dce9f6a9552f75d09b1573311d02546tweenk#include "live_effects/effect.h"
035e109c2dce9f6a9552f75d09b1573311d02546tweenk#include "live_effects/lpeobject.h"
035e109c2dce9f6a9552f75d09b1573311d02546tweenk#include "live_effects/lpeobject-reference.h"
035e109c2dce9f6a9552f75d09b1573311d02546tweenk#include "path-chemistry.h"
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen#include "selection-chemistry.h"
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm#include "selection.h"
23d859f2ce09c04ed802cb4912cc9c50f512f0a2bgk#include "sp-item-group.h"
035e109c2dce9f6a9552f75d09b1573311d02546tweenk#include "sp-lpe-item.h"
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm#include "sp-path.h"
ae22ad7adc4a7a418e71f5dbab8c1f0f7f464562johanengelen#include "sp-rect.h"
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen#include "sp-use.h"
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen#include "sp-text.h"
035e109c2dce9f6a9552f75d09b1573311d02546tweenk#include "sp-shape.h"
035e109c2dce9f6a9552f75d09b1573311d02546tweenk#include "ui/icon-names.h"
035e109c2dce9f6a9552f75d09b1573311d02546tweenk#include "ui/widget/imagetoggler.h"
035e109c2dce9f6a9552f75d09b1573311d02546tweenk#include "verbs.h"
12d084654ee6f91cc12b6218508ee5d3e37de2baLiam P. White#include "widgets/icon.h"
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm#include "xml/node.h"
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith#include "livepatheffect-add.h"
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrmnamespace Inkscape {
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrmnamespace UI {
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrmnamespace Dialog {
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm/*####################
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm * Callback functions
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm */
738092bcf0d040b2431137e191dfd7cf3ce3afadJohan Engelenvoid lpeeditor_selection_changed (Inkscape::Selection * selection, gpointer data)
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm{
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm LivePathEffectEditor *lpeeditor = static_cast<LivePathEffectEditor *>(data);
738092bcf0d040b2431137e191dfd7cf3ce3afadJohan Engelen lpeeditor->lpe_list_locked = false;
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm lpeeditor->onSelectionChanged(selection);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm}
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
a95be1234ba4df33d6d074589edaa56f0d546069buliabyakstatic void lpeeditor_selection_modified (Inkscape::Selection * selection, guint /*flags*/, gpointer data)
a95be1234ba4df33d6d074589edaa56f0d546069buliabyak{
a95be1234ba4df33d6d074589edaa56f0d546069buliabyak LivePathEffectEditor *lpeeditor = static_cast<LivePathEffectEditor *>(data);
a95be1234ba4df33d6d074589edaa56f0d546069buliabyak lpeeditor->onSelectionChanged(selection);
a95be1234ba4df33d6d074589edaa56f0d546069buliabyak}
a95be1234ba4df33d6d074589edaa56f0d546069buliabyak
12d084654ee6f91cc12b6218508ee5d3e37de2baLiam P. Whitestatic void lpe_style_button(Gtk::Button& btn, char const* iconName)
12d084654ee6f91cc12b6218508ee5d3e37de2baLiam P. White{
12d084654ee6f91cc12b6218508ee5d3e37de2baLiam P. White GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName);
12d084654ee6f91cc12b6218508ee5d3e37de2baLiam P. White gtk_widget_show( child );
12d084654ee6f91cc12b6218508ee5d3e37de2baLiam P. White btn.add(*Gtk::manage(Glib::wrap(child)));
12d084654ee6f91cc12b6218508ee5d3e37de2baLiam P. White btn.set_relief(Gtk::RELIEF_NONE);
12d084654ee6f91cc12b6218508ee5d3e37de2baLiam P. White}
12d084654ee6f91cc12b6218508ee5d3e37de2baLiam P. White
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith/*
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm * LivePathEffectEditor
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith *
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith * TRANSLATORS: this dialog is accessible via menu Path - Path Effect Editor...
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith *
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm */
963f23115db07f460bdd862b957f8bd9dba88b9bgustav_b
852b4f6c7a572bc2ccbd96e80c4063a38f77153bjohanengelenLivePathEffectEditor::LivePathEffectEditor()
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould : UI::Widget::Panel("", "/dialogs/livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT),
d67024fee7c560721468212767fb6aa221d5b542John Smith deskTrack(),
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyak lpe_list_locked(false),
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm effectwidget(NULL),
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith status_label("", Gtk::ALIGN_CENTER),
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith effectcontrol_frame(""),
c67c19fc5d1f6d97cc795b5a53998434b431c641John Smith button_add(),
c67c19fc5d1f6d97cc795b5a53998434b431c641John Smith button_remove(),
c67c19fc5d1f6d97cc795b5a53998434b431c641John Smith button_up(),
c67c19fc5d1f6d97cc795b5a53998434b431c641John Smith button_down(),
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen current_desktop(NULL),
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen current_lpeitem(NULL)
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm{
963f23115db07f460bdd862b957f8bd9dba88b9bgustav_b Gtk::Box *contents = _getContents();
963f23115db07f460bdd862b957f8bd9dba88b9bgustav_b contents->set_spacing(4);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen //Add the TreeView, inside a ScrolledWindow, with the button underneath:
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen scrolled_window.add(effectlist_view);
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith scrolled_window.set_shadow_type(Gtk::SHADOW_IN);
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith scrolled_window.set_size_request(210, 70);
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm effectapplication_hbox.set_spacing(4);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm effectcontrol_vbox.set_spacing(4);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen effectlist_vbox.pack_start(scrolled_window, Gtk::PACK_EXPAND_WIDGET);
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith effectlist_vbox.pack_end(toolbar_hbox, Gtk::PACK_SHRINK);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm effectcontrol_frame.add(effectcontrol_vbox);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith button_add.set_tooltip_text(_("Add path effect"));
12d084654ee6f91cc12b6218508ee5d3e37de2baLiam P. White lpe_style_button(button_add, INKSCAPE_ICON("list-add"));
c67c19fc5d1f6d97cc795b5a53998434b431c641John Smith button_add.set_relief(Gtk::RELIEF_NONE);
c67c19fc5d1f6d97cc795b5a53998434b431c641John Smith
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith button_remove.set_tooltip_text(_("Delete current path effect"));
12d084654ee6f91cc12b6218508ee5d3e37de2baLiam P. White lpe_style_button(button_remove, INKSCAPE_ICON("list-remove"));
c67c19fc5d1f6d97cc795b5a53998434b431c641John Smith button_remove.set_relief(Gtk::RELIEF_NONE);
c67c19fc5d1f6d97cc795b5a53998434b431c641John Smith
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith button_up.set_tooltip_text(_("Raise the current path effect"));
12d084654ee6f91cc12b6218508ee5d3e37de2baLiam P. White lpe_style_button(button_up, INKSCAPE_ICON("go-up"));
c67c19fc5d1f6d97cc795b5a53998434b431c641John Smith button_up.set_relief(Gtk::RELIEF_NONE);
c67c19fc5d1f6d97cc795b5a53998434b431c641John Smith
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith button_down.set_tooltip_text(_("Lower the current path effect"));
12d084654ee6f91cc12b6218508ee5d3e37de2baLiam P. White lpe_style_button(button_down, INKSCAPE_ICON("go-down"));
c67c19fc5d1f6d97cc795b5a53998434b431c641John Smith button_down.set_relief(Gtk::RELIEF_NONE);
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith // Add toolbar items to toolbar
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith toolbar_hbox.set_layout (Gtk::BUTTONBOX_END);
8e7d13ca30e4b9671afc47f03dc11affd5507077Alex Valavanis
8e7d13ca30e4b9671afc47f03dc11affd5507077Alex Valavanis#if !WITH_GTKMM_3_0
8e7d13ca30e4b9671afc47f03dc11affd5507077Alex Valavanis // TODO: This has been removed from Gtkmm 3.0. Check that
8e7d13ca30e4b9671afc47f03dc11affd5507077Alex Valavanis // everything still looks OK!
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith toolbar_hbox.set_child_min_width( 16 );
8e7d13ca30e4b9671afc47f03dc11affd5507077Alex Valavanis#endif
8e7d13ca30e4b9671afc47f03dc11affd5507077Alex Valavanis
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith toolbar_hbox.add( button_add );
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith toolbar_hbox.set_child_secondary( button_add , true);
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith toolbar_hbox.add( button_remove );
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith toolbar_hbox.set_child_secondary( button_remove , true);
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith toolbar_hbox.add( button_up );
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith toolbar_hbox.add( button_down );
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen //Create the Tree model:
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen effectlist_store = Gtk::ListStore::create(columns);
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen effectlist_view.set_model(effectlist_store);
e018daf5696bee513e8574a6730e2ce79d2a3a23johanengelen effectlist_view.set_headers_visible(false);
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen // Handle tree selections
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen effectlist_selection = effectlist_view.get_selection();
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen effectlist_selection->signal_changed().connect( sigc::mem_fun(*this, &LivePathEffectEditor::on_effect_selection_changed) );
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
b3722066cc416b6582d9a9a3ffc8ba2e868e102cjohanengelen //Add the visibility icon column:
c42ca006cc2593efa9a0ea19f2680ea9d5792654Markus Engel Inkscape::UI::Widget::ImageToggler *eyeRenderer = Gtk::manage( new Inkscape::UI::Widget::ImageToggler(
11d3fae21261f21488c39b12b716385b5a91c847Johan Engelen INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-hidden")) );
b3722066cc416b6582d9a9a3ffc8ba2e868e102cjohanengelen int visibleColNum = effectlist_view.append_column("is_visible", *eyeRenderer) - 1;
607ec3f31779845d307f157ff34472da27b8bdbcjohanengelen eyeRenderer->signal_toggled().connect( sigc::mem_fun(*this, &LivePathEffectEditor::on_visibility_toggled) );
b3722066cc416b6582d9a9a3ffc8ba2e868e102cjohanengelen eyeRenderer->property_activatable() = true;
b3722066cc416b6582d9a9a3ffc8ba2e868e102cjohanengelen Gtk::TreeViewColumn* col = effectlist_view.get_column(visibleColNum);
b3722066cc416b6582d9a9a3ffc8ba2e868e102cjohanengelen if ( col ) {
b3722066cc416b6582d9a9a3ffc8ba2e868e102cjohanengelen col->add_attribute( eyeRenderer->property_active(), columns.col_visible );
b3722066cc416b6582d9a9a3ffc8ba2e868e102cjohanengelen }
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
b3722066cc416b6582d9a9a3ffc8ba2e868e102cjohanengelen //Add the effect name column:
b3722066cc416b6582d9a9a3ffc8ba2e868e102cjohanengelen effectlist_view.append_column("Effect", columns.col_name);
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith contents->pack_start(effectlist_vbox, true, true);
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith contents->pack_start(status_label, false, false);
b4998608f5fbde14c744b6ab8020664300e11f80jucablues contents->pack_start(effectcontrol_frame, false, false);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith effectcontrol_frame.hide();
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm // connect callback functions to buttons
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith button_add.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onAdd));
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm button_remove.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onRemove));
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen button_up.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onUp));
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen button_down.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onDown));
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
d67024fee7c560721468212767fb6aa221d5b542John Smith desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &LivePathEffectEditor::setDesktop) );
d67024fee7c560721468212767fb6aa221d5b542John Smith deskTrack.connect(GTK_WIDGET(gobj()));
d67024fee7c560721468212767fb6aa221d5b542John Smith
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm show_all_children();
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm}
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
852b4f6c7a572bc2ccbd96e80c4063a38f77153bjohanengelenLivePathEffectEditor::~LivePathEffectEditor()
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm{
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm if (effectwidget) {
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm effectcontrol_vbox.remove(*effectwidget);
c0cd5511d3b975ebe07d019c1f5528108725e438johanengelen delete effectwidget;
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm effectwidget = NULL;
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm if (current_desktop) {
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm selection_changed_connection.disconnect();
a95be1234ba4df33d6d074589edaa56f0d546069buliabyak selection_modified_connection.disconnect();
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm}
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrmvoid
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed GouldLivePathEffectEditor::showParams(LivePathEffect::Effect& effect)
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm{
c5526a2c3001be486990d816757dd5ac028b3c3fjohanengelen if (effectwidget) {
c5526a2c3001be486990d816757dd5ac028b3c3fjohanengelen effectcontrol_vbox.remove(*effectwidget);
c5526a2c3001be486990d816757dd5ac028b3c3fjohanengelen delete effectwidget;
c5526a2c3001be486990d816757dd5ac028b3c3fjohanengelen effectwidget = NULL;
c5526a2c3001be486990d816757dd5ac028b3c3fjohanengelen }
fdad0bc3aa765bdc61fe39e8c4da03f717525dccjohanengelen
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith effectcontrol_frame.set_label(effect.getName());
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith
5cf332777b4c27336d64c273ac63bce3ee27a53dAlex Valavanis effectwidget = effect.newWidget();
c5526a2c3001be486990d816757dd5ac028b3c3fjohanengelen if (effectwidget) {
c5526a2c3001be486990d816757dd5ac028b3c3fjohanengelen effectcontrol_vbox.pack_start(*effectwidget, true, true);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm }
c5526a2c3001be486990d816757dd5ac028b3c3fjohanengelen button_remove.show();
c5526a2c3001be486990d816757dd5ac028b3c3fjohanengelen
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith status_label.hide();
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith effectcontrol_frame.show();
c5526a2c3001be486990d816757dd5ac028b3c3fjohanengelen effectcontrol_vbox.show_all_children();
c5526a2c3001be486990d816757dd5ac028b3c3fjohanengelen // fixme: add resizing of dialog
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm}
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyakvoid
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyakLivePathEffectEditor::selectInList(LivePathEffect::Effect* effect)
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyak{
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyak Gtk::TreeNodeChildren chi = effectlist_view.get_model()->children();
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyak for (Gtk::TreeIter ci = chi.begin() ; ci != chi.end(); ci++) {
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould if (ci->get_value(columns.lperef)->lpeobject->get_lpe() == effect)
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyak effectlist_view.get_selection()->select(ci);
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyak }
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyak}
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyak
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyak
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrmvoid
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrmLivePathEffectEditor::showText(Glib::ustring const &str)
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm{
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm if (effectwidget) {
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm effectcontrol_vbox.remove(*effectwidget);
c0cd5511d3b975ebe07d019c1f5528108725e438johanengelen delete effectwidget;
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm effectwidget = NULL;
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith status_label.show();
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith status_label.set_label(str);
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith effectcontrol_frame.hide();
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm // fixme: do resizing of dialog ?
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm}
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrmvoid
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrmLivePathEffectEditor::set_sensitize_all(bool sensitive)
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm{
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith //combo_effecttype.set_sensitive(sensitive);
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith button_add.set_sensitive(sensitive);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm button_remove.set_sensitive(sensitive);
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen effectlist_view.set_sensitive(sensitive);
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen button_up.set_sensitive(sensitive);
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen button_down.set_sensitive(sensitive);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm}
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrmvoid
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrmLivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel)
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm{
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyak if (lpe_list_locked) {
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyak // this was triggered by selecting a row in the list, so skip reloading
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyak lpe_list_locked = false;
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyak return;
c730b7fa118ad88d7cc6047dcc78e7098cdf79caKrzysztof Kosiński }
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyak
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen effectlist_store->clear();
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen current_lpeitem = NULL;
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm if ( sel && !sel->isEmpty() ) {
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm SPItem *item = sel->singleItem();
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm if ( item ) {
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz if ( lpeitem ) {
852b4f6c7a572bc2ccbd96e80c4063a38f77153bjohanengelen effect_list_reload(lpeitem);
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen current_lpeitem = lpeitem;
852b4f6c7a572bc2ccbd96e80c4063a38f77153bjohanengelen
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm set_sensitize_all(true);
8261c3f0a43f2bbfa6f25edbae152278c40d9d97Johan B. C. Engelen if ( lpeitem->hasPathEffect() ) {
f4ce66b44581cea80a736cf20244c0539a7525daJohan B. C. Engelen Inkscape::LivePathEffect::Effect *lpe = lpeitem->getCurrentLPE();
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen if (lpe) {
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould showParams(*lpe);
c730b7fa118ad88d7cc6047dcc78e7098cdf79caKrzysztof Kosiński lpe_list_locked = true;
f0ed14f45951d21de3ff2c7c131f6aafa6e30c17buliabyak selectInList(lpe);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm } else {
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm showText(_("Unknown effect is applied"));
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm } else {
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith showText(_("Click button to add an effect"));
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm button_remove.set_sensitive(false);
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith button_up.set_sensitive(false);
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith button_down.set_sensitive(false);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm }
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz } else {
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz SPUse *use = dynamic_cast<SPUse *>(item);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz if ( use ) {
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz // test whether linked object is supported by the CLONE_ORIGINAL LPE
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz SPItem *orig = use->get_original();
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz if ( dynamic_cast<SPShape *>(orig) ||
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz dynamic_cast<SPText *>(orig) )
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz {
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz // Note that an SP_USE cannot have an LPE applied, so we only need to worry about the "add effect" case.
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz set_sensitize_all(true);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz showText(_("Click add button to convert clone"));
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz button_remove.set_sensitive(false);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz button_up.set_sensitive(false);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz button_down.set_sensitive(false);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz } else {
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz showText(_("Select a path or shape"));
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz set_sensitize_all(false);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz }
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen } else {
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen showText(_("Select a path or shape"));
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen set_sensitize_all(false);
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm } else {
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm showText(_("Only one item can be selected"));
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm set_sensitize_all(false);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm } else {
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith showText(_("Select a path or shape"));
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm set_sensitize_all(false);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm}
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
852b4f6c7a572bc2ccbd96e80c4063a38f77153bjohanengelen/*
852b4f6c7a572bc2ccbd96e80c4063a38f77153bjohanengelen * First clears the effectlist_store, then appends all effects from the effectlist.
852b4f6c7a572bc2ccbd96e80c4063a38f77153bjohanengelen */
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelenvoid
852b4f6c7a572bc2ccbd96e80c4063a38f77153bjohanengelenLivePathEffectEditor::effect_list_reload(SPLPEItem *lpeitem)
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen{
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen effectlist_store->clear();
852b4f6c7a572bc2ccbd96e80c4063a38f77153bjohanengelen
32143ea5edb30f496040c1f24538e38d9453fc06Johan B. C. Engelen PathEffectList effectlist = lpeitem->getEffectList();
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen PathEffectList::iterator it;
84d6d1f7365e49f2936df9df890ce49d2c000ce2Kris for( it = effectlist.begin() ; it!=effectlist.end(); ++it)
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen {
cd392fe863cb06ba22f2b54bdb96ef3a6ee6bc5bJohan Engelen if ( !(*it)->lpeobject ) {
cd392fe863cb06ba22f2b54bdb96ef3a6ee6bc5bJohan Engelen continue;
cd392fe863cb06ba22f2b54bdb96ef3a6ee6bc5bJohan Engelen }
cd392fe863cb06ba22f2b54bdb96ef3a6ee6bc5bJohan Engelen
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould if ((*it)->lpeobject->get_lpe()) {
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould Gtk::TreeModel::Row row = *(effectlist_store->append());
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould row[columns.col_name] = (*it)->lpeobject->get_lpe()->getName();
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould row[columns.lperef] = *it;
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould row[columns.col_visible] = (*it)->lpeobject->get_lpe()->isVisible();
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould } else {
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould Gtk::TreeModel::Row row = *(effectlist_store->append());
aea6c63514922bfc46ced140fa2877576aa21203johanengelen row[columns.col_name] = _("Unknown effect");
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould row[columns.lperef] = *it;
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould row[columns.col_visible] = false;
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould }
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen }
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen}
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
852b4f6c7a572bc2ccbd96e80c4063a38f77153bjohanengelenvoid
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrmLivePathEffectEditor::setDesktop(SPDesktop *desktop)
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm{
1e7c268648bcbae15fc13b8c94dee677b401d9b3gustav_b Panel::setDesktop(desktop);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm if ( desktop == current_desktop ) {
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm return;
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm if (current_desktop) {
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm selection_changed_connection.disconnect();
a95be1234ba4df33d6d074589edaa56f0d546069buliabyak selection_modified_connection.disconnect();
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
738092bcf0d040b2431137e191dfd7cf3ce3afadJohan Engelen lpe_list_locked = false;
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm current_desktop = desktop;
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm if (desktop) {
769a6887551cf7ff7bce4b48d3ac303cbea69507Liam P. White Inkscape::Selection *selection = desktop->getSelection();
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm selection_changed_connection = selection->connectChanged(
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm sigc::bind (sigc::ptr_fun(&lpeeditor_selection_changed), this ) );
a95be1234ba4df33d6d074589edaa56f0d546069buliabyak selection_modified_connection = selection->connectModified(
a95be1234ba4df33d6d074589edaa56f0d546069buliabyak sigc::bind (sigc::ptr_fun(&lpeeditor_selection_modified), this ) );
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm onSelectionChanged(selection);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm } else {
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm onSelectionChanged(NULL);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm}
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm/*########################################################################
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm# BUTTON CLICK HANDLERS (callbacks)
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm########################################################################*/
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm// TODO: factor out the effect applying code which can be called from anywhere. (selection-chemistry.cpp also needs it)
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrmvoid
0d00bc9f32167e81375a4be524572b27e2894ee4John SmithLivePathEffectEditor::onAdd()
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm{
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm Inkscape::Selection *sel = _getSelection();
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm if ( sel && !sel->isEmpty() ) {
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm SPItem *item = sel->singleItem();
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen if (item) {
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz if ( dynamic_cast<SPLPEItem *>(item) ) {
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen // show effectlist dialog
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen using Inkscape::UI::Dialog::LivePathEffectAdd;
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen LivePathEffectAdd::show(current_desktop);
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen if ( !LivePathEffectAdd::isApplied()) {
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen return;
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen SPDocument *doc = current_desktop->doc();
ae22ad7adc4a7a418e71f5dbab8c1f0f7f464562johanengelen
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen const Util::EnumData<LivePathEffect::EffectType>* data = LivePathEffectAdd::getActiveData();
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen if (!data) {
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen return;
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen }
3ae3dd4eb0191cc986a035c790b8b97e6c6e4ee4johanengelen
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen // If item is a SPRect, convert it to path first:
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz if ( dynamic_cast<SPRect *>(item) ) {
e25076a0c8caf01a05b34c96485471798f61b6cbEric Greveson sp_selected_path_to_curves(sel, current_desktop, false);
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen item = sel->singleItem(); // get new item
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen }
48c5a523ec28475a6f2b5e1f1a087e44d56f684fbuliabyak
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen LivePathEffect::Effect::createAndApply(data->key.c_str(), doc, item);
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen DocumentUndo::done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT,
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen _("Create and apply path effect"));
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen lpe_list_locked = false;
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen onSelectionChanged(sel);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz } else {
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz SPUse *use = dynamic_cast<SPUse *>(item);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz if ( use ) {
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz // item is a clone. do not show effectlist dialog.
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz // convert to path, apply CLONE_ORIGINAL LPE, link it to the cloned path
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz // test whether linked object is supported by the CLONE_ORIGINAL LPE
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz SPItem *orig = use->get_original();
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz if ( dynamic_cast<SPShape *>(orig) ||
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz dynamic_cast<SPText *>(orig) )
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz {
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz // select original
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz sel->set(orig);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz // delete clone but remember its id and transform
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz gchar *id = g_strdup(item->getRepr()->attribute("id"));
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz gchar *transform = g_strdup(item->getRepr()->attribute("transform"));
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz item->deleteObject(false);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz item = NULL;
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz // run sp_selection_clone_original_path_lpe
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz sp_selection_clone_original_path_lpe(current_desktop);
dd0ae0a28fda34d3805f7fe6deece97c4192910aJohan B. C. Engelen
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz SPItem *new_item = sel->singleItem();
dd0ae0a28fda34d3805f7fe6deece97c4192910aJohan B. C. Engelen // Check that the cloning was successful. We don't want to change the ID of the original referenced path!
dd0ae0a28fda34d3805f7fe6deece97c4192910aJohan B. C. Engelen if (new_item && (new_item != orig)) {
dd0ae0a28fda34d3805f7fe6deece97c4192910aJohan B. C. Engelen new_item->getRepr()->setAttribute("id", id);
dd0ae0a28fda34d3805f7fe6deece97c4192910aJohan B. C. Engelen new_item->getRepr()->setAttribute("transform", transform);
dd0ae0a28fda34d3805f7fe6deece97c4192910aJohan B. C. Engelen }
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz g_free(id);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz g_free(transform);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz /// \todo Add the LPE stack of the original path?
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz SPDocument *doc = current_desktop->doc();
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz DocumentUndo::done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT,
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz _("Create and apply Clone original path effect"));
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz lpe_list_locked = false;
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz onSelectionChanged(sel);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz }
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen }
edcba9f1706559e93aa06a7173daa6cd6516acb5Johan B. C. Engelen }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm}
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrmvoid
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrmLivePathEffectEditor::onRemove()
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm{
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm Inkscape::Selection *sel = _getSelection();
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm if ( sel && !sel->isEmpty() ) {
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm SPItem *item = sel->singleItem();
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz if ( lpeitem ) {
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz lpeitem->removeCurrentPathEffect(false);
852b4f6c7a572bc2ccbd96e80c4063a38f77153bjohanengelen
9ba77856a8823f85b53c0a861d220cd0347f2754Liam P. White DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
9dc68827cbd515262ecb8d5ae8547d9e82c72e00Jon A. Cruz _("Remove path effect") );
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz effect_list_reload(lpeitem);
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen }
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen }
0d00bc9f32167e81375a4be524572b27e2894ee4John Smith
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen}
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelenvoid LivePathEffectEditor::onUp()
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen{
852b4f6c7a572bc2ccbd96e80c4063a38f77153bjohanengelen Inkscape::Selection *sel = _getSelection();
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen if ( sel && !sel->isEmpty() ) {
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen SPItem *item = sel->singleItem();
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz if ( lpeitem ) {
32143ea5edb30f496040c1f24538e38d9453fc06Johan B. C. Engelen lpeitem->upCurrentPathEffect();
852b4f6c7a572bc2ccbd96e80c4063a38f77153bjohanengelen
9ba77856a8823f85b53c0a861d220cd0347f2754Liam P. White DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
9dc68827cbd515262ecb8d5ae8547d9e82c72e00Jon A. Cruz _("Move path effect up") );
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
32143ea5edb30f496040c1f24538e38d9453fc06Johan B. C. Engelen effect_list_reload(lpeitem);
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen }
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen }
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen}
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelenvoid LivePathEffectEditor::onDown()
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen{
852b4f6c7a572bc2ccbd96e80c4063a38f77153bjohanengelen Inkscape::Selection *sel = _getSelection();
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen if ( sel && !sel->isEmpty() ) {
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen SPItem *item = sel->singleItem();
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
f4d474ff2d58b3d32dacd5feed0c164e8df4936cJon A. Cruz if ( lpeitem ) {
32143ea5edb30f496040c1f24538e38d9453fc06Johan B. C. Engelen lpeitem->downCurrentPathEffect();
852b4f6c7a572bc2ccbd96e80c4063a38f77153bjohanengelen
9ba77856a8823f85b53c0a861d220cd0347f2754Liam P. White DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
9dc68827cbd515262ecb8d5ae8547d9e82c72e00Jon A. Cruz _("Move path effect down") );
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
32143ea5edb30f496040c1f24538e38d9453fc06Johan B. C. Engelen effect_list_reload(lpeitem);
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm }
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm}
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelenvoid LivePathEffectEditor::on_effect_selection_changed()
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen{
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen Glib::RefPtr<Gtk::TreeSelection> sel = effectlist_view.get_selection();
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen if (sel->count_selected_rows () == 0)
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen return;
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen Gtk::TreeModel::iterator it = sel->get_selected();
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen LivePathEffect::LPEObjectReference * lperef = (*it)[columns.lperef];
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen if (lperef && current_lpeitem) {
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould if (lperef->lpeobject->get_lpe()) {
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould lpe_list_locked = true; // prevent reload of the list which would lose selection
f4ce66b44581cea80a736cf20244c0539a7525daJohan B. C. Engelen current_lpeitem->setCurrentPathEffect(lperef);
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould showParams(*lperef->lpeobject->get_lpe());
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould }
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen }
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen}
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
607ec3f31779845d307f157ff34472da27b8bdbcjohanengelenvoid LivePathEffectEditor::on_visibility_toggled( Glib::ustring const& str )
607ec3f31779845d307f157ff34472da27b8bdbcjohanengelen{
607ec3f31779845d307f157ff34472da27b8bdbcjohanengelen Gtk::TreeModel::Children::iterator iter = effectlist_view.get_model()->get_iter(str);
607ec3f31779845d307f157ff34472da27b8bdbcjohanengelen Gtk::TreeModel::Row row = *iter;
607ec3f31779845d307f157ff34472da27b8bdbcjohanengelen
607ec3f31779845d307f157ff34472da27b8bdbcjohanengelen LivePathEffect::LPEObjectReference * lpeobjref = row[columns.lperef];
607ec3f31779845d307f157ff34472da27b8bdbcjohanengelen
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould if ( lpeobjref && lpeobjref->lpeobject->get_lpe() ) {
607ec3f31779845d307f157ff34472da27b8bdbcjohanengelen bool newValue = !row[columns.col_visible];
607ec3f31779845d307f157ff34472da27b8bdbcjohanengelen row[columns.col_visible] = newValue;
607ec3f31779845d307f157ff34472da27b8bdbcjohanengelen /* FIXME: this explicit writing to SVG is wrong. The lpe_item should have a method to disable/enable an effect within its stack.
607ec3f31779845d307f157ff34472da27b8bdbcjohanengelen * So one can call: lpe_item->setActive(lpeobjref->lpeobject); */
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould lpeobjref->lpeobject->get_lpe()->getRepr()->setAttribute("is_visible", newValue ? "true" : "false");
9ba77856a8823f85b53c0a861d220cd0347f2754Liam P. White DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
9dc68827cbd515262ecb8d5ae8547d9e82c72e00Jon A. Cruz newValue ? _("Activate path effect") : _("Deactivate path effect"));
607ec3f31779845d307f157ff34472da27b8bdbcjohanengelen }
607ec3f31779845d307f157ff34472da27b8bdbcjohanengelen}
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm} // namespace Dialog
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm} // namespace UI
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm} // namespace Inkscape
fd4b29a5cdef220804dfed85fec8acb5daceec5fpjrm
ba885512446fff2803585a4aaec34e7742841f05cilix/*
ba885512446fff2803585a4aaec34e7742841f05cilix Local Variables:
ba885512446fff2803585a4aaec34e7742841f05cilix mode:c++
ba885512446fff2803585a4aaec34e7742841f05cilix c-file-style:"stroustrup"
ba885512446fff2803585a4aaec34e7742841f05cilix c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
ba885512446fff2803585a4aaec34e7742841f05cilix indent-tabs-mode:nil
ba885512446fff2803585a4aaec34e7742841f05cilix fill-column:99
ba885512446fff2803585a4aaec34e7742841f05cilix End:
ba885512446fff2803585a4aaec34e7742841f05cilix*/
a4030d5ca449e7e384bc699cd249ee704faaeab0Chris Morgan// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :