index f46a6bc95ccd5d5c9f93c9378c0bd997590b3704..567ee24dadf47ada4130dd7d0b7e0c0a7166dbb6 100644 (file)
#include <glibmm/i18n.h>
#include "livepatheffect-editor.h"
+#include "ui/widget/imagetoggler.h"
#include "verbs.h"
#include "selection.h"
#include "sp-shape.h"
LivePathEffectEditor::LivePathEffectEditor()
: UI::Widget::Panel("", "dialogs.livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT),
+ lpe_list_locked(false),
combo_effecttype(Inkscape::LivePathEffect::LPETypeConverter),
effectwidget(NULL),
explain_label("", Gtk::ALIGN_CENTER),
effectlist_store = Gtk::ListStore::create(columns);
effectlist_view.set_model(effectlist_store);
- effectlist_view.set_rules_hint();
effectlist_view.set_headers_visible(false);
// Handle tree selections
effectlist_selection = effectlist_view.get_selection();
effectlist_selection->signal_changed().connect( sigc::mem_fun(*this, &LivePathEffectEditor::on_effect_selection_changed) );
- //Add the TreeView's view columns:
- effectlist_view.append_column("Effect", columns.col_name);
+ //Add the visibility icon column:
+ Inkscape::UI::Widget::ImageToggler *eyeRenderer = manage( new Inkscape::UI::Widget::ImageToggler("visible", "hidden") );
+ int visibleColNum = effectlist_view.append_column("is_visible", *eyeRenderer) - 1;
+ eyeRenderer->signal_toggled().connect( sigc::mem_fun(*this, &LivePathEffectEditor::on_visibility_toggled) );
+ eyeRenderer->property_activatable() = true;
+ Gtk::TreeViewColumn* col = effectlist_view.get_column(visibleColNum);
+ if ( col ) {
+ col->add_attribute( eyeRenderer->property_active(), columns.col_visible );
+ }
+ //Add the effect name column:
+ effectlist_view.append_column("Effect", columns.col_name);
contents->pack_start(effectapplication_frame, false, false);
contents->pack_start(effectlist_frame, true, true);
// fixme: add resizing of dialog
}
+void
+LivePathEffectEditor::selectInList(LivePathEffect::Effect* effect)
+{
+ Gtk::TreeNodeChildren chi = effectlist_view.get_model()->children();
+ for (Gtk::TreeIter ci = chi.begin() ; ci != chi.end(); ci++) {
+ if (ci->get_value(columns.lperef)->lpeobject->lpe == effect)
+ effectlist_view.get_selection()->select(ci);
+ }
+}
+
+
void
LivePathEffectEditor::showText(Glib::ustring const &str)
{
void
LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel)
{
+ if (lpe_list_locked) {
+ // this was triggered by selecting a row in the list, so skip reloading
+ lpe_list_locked = false;
+ return;
+ }
+
effectlist_store->clear();
current_lpeitem = NULL;
Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(lpeitem);
if (lpe) {
showParams(lpe);
+ lpe_list_locked = true;
+ selectInList(lpe);
} else {
showText(_("Unknown effect is applied"));
}
Gtk::TreeModel::Row row = *(effectlist_store->append());
row[columns.col_name] = (*it)->lpeobject->lpe->getName();
row[columns.lperef] = *it;
+ row[columns.col_visible] = (*it)->lpeobject->lpe->isVisible();
}
}
LivePathEffect::LPEObjectReference * lperef = (*it)[columns.lperef];
if (lperef && current_lpeitem) {
+ lpe_list_locked = true; // prevent reload of the list which would lose selection
sp_lpe_item_set_current_path_effect(current_lpeitem, lperef);
showParams(lperef->lpeobject->lpe);
}
}
+void LivePathEffectEditor::on_visibility_toggled( Glib::ustring const& str )
+{
+ Gtk::TreeModel::Children::iterator iter = effectlist_view.get_model()->get_iter(str);
+ Gtk::TreeModel::Row row = *iter;
+
+ LivePathEffect::LPEObjectReference * lpeobjref = row[columns.lperef];
+
+ if ( lpeobjref ) {
+ bool newValue = !row[columns.col_visible];
+ row[columns.col_visible] = newValue;
+ /* FIXME: this explicit writing to SVG is wrong. The lpe_item should have a method to disable/enable an effect within its stack.
+ * So one can call: lpe_item->setActive(lpeobjref->lpeobject); */
+ lpeobjref->lpeobject->lpe->getRepr()->setAttribute("is_visible", newValue ? "true" : "false");
+ sp_document_done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+ newValue ? _("Activate path effect") : _("Deactivate path effect"));
+ }
+}
} // namespace Dialog
} // namespace UI