1 /* === S Y N F I G ========================================================= */
2 /*! \file layertreestore.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2008 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === H E A D E R S ======================================================= */
33 #include "layertreestore.h"
34 #include "iconcontroller.h"
35 #include <gtkmm/button.h>
36 #include <synfig/paramdesc.h>
37 #include <synfigapp/action.h>
38 #include <synfigapp/instance.h>
41 #include <synfigapp/action_system.h>
43 #include <gtk/gtkversion.h>
49 /* === U S I N G =========================================================== */
53 using namespace synfig;
54 using namespace studio;
56 /* === M A C R O S ========================================================= */
58 /* === G L O B A L S ======================================================= */
60 /* === P R O C E D U R E S ================================================= */
62 /* === M E T H O D S ======================================================= */
64 static LayerTreeStore::Model& ModelHack()
66 static LayerTreeStore::Model* model(0);
67 if(!model)model=new LayerTreeStore::Model;
71 LayerTreeStore::LayerTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
72 Gtk::TreeStore (ModelHack()),
73 canvas_interface_ (canvas_interface_)
75 layer_icon=Gtk::Button().render_icon(Gtk::StockID("synfig-layer"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
77 // Connect Signals to Terminals
78 canvas_interface()->signal_layer_status_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_status_changed));
79 canvas_interface()->signal_layer_lowered().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_lowered));
80 canvas_interface()->signal_layer_raised().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_raised));
81 canvas_interface()->signal_layer_removed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_removed));
82 canvas_interface()->signal_layer_inserted().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_inserted));
83 canvas_interface()->signal_layer_moved().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_moved));
84 //canvas_interface()->signal_layer_param_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_param_changed));
85 canvas_interface()->signal_layer_new_description().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_new_description));
87 canvas_interface()->signal_time_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::refresh));
89 //canvas_interface()->signal_value_node_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_changed));
90 //canvas_interface()->signal_value_node_added().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_added));
91 //canvas_interface()->signal_value_node_deleted().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_deleted));
92 //canvas_interface()->signal_value_node_replaced().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_replaced));
94 set_default_sort_func(sigc::ptr_fun(index_sorter));
99 LayerTreeStore::~LayerTreeStore()
101 if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
102 synfig::info("LayerTreeStore::~LayerTreeStore(): Deleted");
106 LayerTreeStore::z_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs)
110 float diff((float)(*rhs)[model.z_depth]-(float)(*lhs)[model.z_depth]);
120 LayerTreeStore::index_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs)
124 return ((int)(*rhs)[model.index]-(int)(*lhs)[model.index]);
128 LayerTreeStore::search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring& x,const TreeModel::iterator& iter)
132 Glib::ustring substr(x.uppercase());
133 Glib::ustring label((*iter)[model.label]);
134 label=label.uppercase();
136 return label.find(substr)==Glib::ustring::npos;
140 Glib::RefPtr<LayerTreeStore>
141 LayerTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
143 return Glib::RefPtr<LayerTreeStore>(new LayerTreeStore(canvas_interface_));
147 LayerTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
149 if(column==model.index.index())
151 synfig::Layer::Handle layer((*iter)[model.layer]);
156 g_value_init(x.gobj(),x.value_type());
158 x.set(layer->get_depth());
160 g_value_init(value.gobj(),x.value_type());
161 g_value_copy(x.gobj(),value.gobj());
163 else if(column==model.z_depth.index())
165 synfig::Layer::Handle layer((*iter)[model.layer]);
169 Glib::Value<float> x;
170 g_value_init(x.gobj(),x.value_type());
172 x.set(layer->get_z_depth(canvas_interface()->get_time())*1.0001+layer->get_depth());
174 g_value_init(value.gobj(),x.value_type());
175 g_value_copy(x.gobj(),value.gobj());
177 else if(column==model.children_lock.index())
179 synfig::Layer::Handle layer((*iter)[model.layer]);
184 g_value_init(x.gobj(),x.value_type());
187 ValueBase v(layer->get_param("children_lock"));
188 if(v.same_type_as(bool()))
189 x.set(v.get(bool()));
191 g_value_init(value.gobj(),x.value_type());
192 g_value_copy(x.gobj(),value.gobj());
194 else if(column==model.label.index())
196 synfig::Layer::Handle layer((*iter)[model.layer]);
200 Glib::Value<Glib::ustring> x;
201 g_value_init(x.gobj(),x.value_type());
203 x.set(layer->get_non_empty_description());
205 g_value_init(value.gobj(),x.value_type());
206 //g_value_copy(x.gobj(),value.gobj());
209 else if(column==model.tooltip.index())
211 synfig::Layer::Handle layer((*iter)[model.layer]);
215 Glib::Value<Glib::ustring> x;
216 g_value_init(x.gobj(),x.value_type());
219 x.set(layer->get_local_name());
221 g_value_init(value.gobj(),x.value_type());
222 //g_value_copy(x.gobj(),value.gobj());
225 else if(column==model.canvas.index())
227 synfig::Layer::Handle layer((*iter)[model.layer]);
231 Glib::Value<Canvas::Handle> x;
232 g_value_init(x.gobj(),x.value_type());
235 x.set(layer->get_canvas());
237 g_value_init(value.gobj(),x.value_type());
238 //g_value_copy(x.gobj(),value.gobj());
241 else if(column==model.active.index())
243 synfig::Layer::Handle layer((*iter)[model.layer]);
248 g_value_init(x.gobj(),x.value_type());
250 x.set(layer->active());
252 g_value_init(value.gobj(),x.value_type());
253 g_value_copy(x.gobj(),value.gobj());
255 else if(column==model.icon.index())
257 synfig::Layer::Handle layer((*iter)[model.layer]);
260 Glib::Value<Glib::RefPtr<Gdk::Pixbuf> > x;
261 g_value_init(x.gobj(),x.value_type());
264 x.set(get_tree_pixbuf_layer(layer->get_name()));
266 g_value_init(value.gobj(),x.value_type());
267 g_value_copy(x.gobj(),value.gobj());
270 Gtk::TreeStore::get_value_vfunc(iter,column,value);
274 LayerTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
276 //if(!iterator_sane(row))
279 if(column>=get_n_columns_vfunc())
281 g_warning("LayerTreeStore::set_value_impl: Bad column (%d)",column);
285 if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
287 g_warning("LayerTreeStore::set_value_impl: Bad value type");
293 if(column==model.label.index())
295 Glib::Value<Glib::ustring> x;
296 g_value_init(x.gobj(),model.label.type());
297 g_value_copy(value.gobj(),x.gobj());
299 synfig::Layer::Handle layer((*iter)[model.layer]);
302 synfig::String new_desc(x.get());
304 if(new_desc==layer->get_local_name())
305 new_desc=synfig::String();
307 if(new_desc==layer->get_description())
310 synfigapp::Action::Handle action(synfigapp::Action::create("layer_set_desc"));
315 action->set_param("canvas",canvas_interface()->get_canvas());
316 action->set_param("canvas_interface",canvas_interface());
317 action->set_param("layer",layer);
318 action->set_param("new_description",synfig::String(x.get()));
320 canvas_interface()->get_instance()->perform_action(action);
323 else if(column==model.active.index())
325 synfig::Layer::Handle layer((*iter)[model.layer]);
330 g_value_init(x.gobj(),model.active.type());
331 g_value_copy(value.gobj(),x.gobj());
333 synfigapp::Action::Handle action(synfigapp::Action::create("layer_activate"));
338 action->set_param("canvas",canvas_interface()->get_canvas());
339 action->set_param("canvas_interface",canvas_interface());
340 action->set_param("layer",layer);
341 action->set_param("new_status",bool(x.get()));
343 canvas_interface()->get_instance()->perform_action(action);
347 Gtk::TreeStore::set_value_impl(iter,column, value);
350 catch(std::exception x)
360 LayerTreeStore::row_draggable_vfunc (const TreeModel::Path& /*path*/)const
362 //if(!get_iter(path)) return false;
363 // Gtk::TreeModel::Row row(*get_iter(path));
366 // return (bool)true;
370 LayerTreeStore::drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const
372 if(!const_cast<LayerTreeStore*>(this)->get_iter(path)) return false;
373 //synfig::info("Dragged data of type \"%s\"",selection_data.get_data_type());
374 //synfig::info("Dragged data of target \"%s\"",gdk_atom_name(selection_data->target));
375 //synfig::info("Dragged selection=\"%s\"",gdk_atom_name(selection_data->selection));
377 Gtk::TreeModel::Row row(*const_cast<LayerTreeStore*>(this)->get_iter(path));
381 Layer* layer(((Layer::Handle)row[model.layer]).get());
383 bool included(false);
385 //gtk_selection_data_set (selection_data, gdk_atom_intern("LAYER",false), 8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
387 std::vector<Layer*> layers;
388 // The following is a hack for multiple row DND
390 synfigapp::SelectionManager::LayerList bleh(get_canvas_interface()->get_selection_manager()->get_selected_layers());
393 selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
398 if(bleh.back().get()==layer)
400 layers.push_back(bleh.back().get());
405 layers.push_back(layer);
406 selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layers.front()), sizeof(void*)*layers.size());
414 LayerTreeStore::drag_data_delete_vfunc (const TreeModel::Path& /*path*/)
420 LayerTreeStore::row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const
422 //if(!const_cast<LayerTreeStore*>(this)->get_iter(dest)) return false;
424 //synfig::info("possible_drop -- data of type \"%s\"",selection_data.get_data_type());
425 //synfig::info("possible_drop -- data of target \"%s\"",gdk_atom_name(selection_data->target));
426 //synfig::info("possible_drop -- selection=\"%s\"",gdk_atom_name(selection_data->selection));
428 //Gtk::TreeModel::Row row(*get_iter(dest));
430 if(synfig::String(selection_data.get_data_type())=="LAYER" && (bool)true)
432 //Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
436 TreeModel::Path dest_parent(dest);
437 if(!dest_parent.up() || dest.get_depth()==1)
439 //row=(*get_iter(dest));
440 //dest_canvas=(Canvas::Handle)(row[model.canvas]);
443 else if((bool)const_cast<LayerTreeStore*>(this)->get_iter(dest_parent))
444 return (bool)(Canvas::Handle)(*const_cast<LayerTreeStore*>(this)->get_iter(dest_parent))[model.contained_canvas];
450 LayerTreeStore::drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)
453 //if(!dest_parent.up() || !get_iter(dest)) return false;
459 //synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
460 //synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
461 //synfig::info("Dropped selection=\"%s\"",gdk_atom_name(selection_data->selection));
462 synfigapp::Action::PassiveGrouper passive_grouper(canvas_interface()->get_instance().get(),_("Move Layers"));
464 // Save the selection data
465 synfigapp::SelectionManager::LayerList selected_layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
467 if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
469 Gtk::TreeModel::Row row;
470 Canvas::Handle dest_canvas;
472 int dest_layer_depth=dest.back();
474 TreeModel::Path dest_parent(dest);
475 if(!dest_parent.up() || !get_iter(dest_parent))
477 TreeModel::Path dest_(dest);
485 row=(*get_iter(dest_));
486 dest_canvas=(Canvas::Handle)(row[model.canvas]);
491 row=(*get_iter(dest_parent));
492 dest_canvas=row[model.contained_canvas];
497 Layer::Handle dest_layer(row[model.layer]);
499 if(synfig::String(selection_data.get_data_type())=="LAYER")for(unsigned int i=0;i<selection_data.get_length()/sizeof(void*);i++)
501 //synfig::info("dest_layer_depth=%d",dest_layer_depth);
503 Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
508 if(dest_canvas==src->get_canvas() && src->get_depth()<dest_layer_depth)
511 // In this case, we are just moving.
512 // if(dest_canvas==src->get_canvas())
514 //if(dest_canvas==src->get_canvas() && dest_layer_depth && dest_layer_depth>src->get_depth())
515 // dest_layer_depth--;
516 if(dest_canvas==src->get_canvas() && dest_layer_depth==src->get_depth())
519 synfigapp::Action::Handle action(synfigapp::Action::create("layer_move"));
520 action->set_param("canvas",dest_canvas);
521 action->set_param("canvas_interface",canvas_interface());
522 action->set_param("layer",src);
523 action->set_param("new_index",dest_layer_depth);
524 action->set_param("dest_canvas",dest_canvas);
525 if(canvas_interface()->get_instance()->perform_action(action))
529 passive_grouper.cancel();
534 /*else // In this case we need to remove and then add
537 synfigapp::Action::Handle action;
538 action=synfigapp::Action::create("layer_remove");
539 action->set_param("canvas",Canvas::Handle(src->get_canvas()));
540 if(!action->set_param("canvas_interface",App::get_instance(src->get_canvas())->find_canvas_interface(src->get_canvas())))
541 action->set_param("canvas_interface",canvas_interface());
542 action->set_param("layer",src);
543 if(!canvas_interface()->get_instance()->perform_action(action))
545 passive_grouper.cancel();
550 action=synfigapp::Action::create("layer_add");
551 action->set_param("canvas",dest_canvas);
552 action->set_param("canvas_interface",canvas_interface());
553 action->set_param("new",src);
554 if(!canvas_interface()->get_instance()->perform_action(action))
556 passive_grouper.cancel();
561 if(dest_layer_depth!=0)
563 action=synfigapp::Action::create("layer_move");
564 action->set_param("canvas",dest_canvas);
565 action->set_param("canvas_interface",canvas_interface());
566 action->set_param("layer",src);
567 action->set_param("new_index",dest_layer_depth);
568 if(!canvas_interface()->get_instance()->perform_action(action))
570 passive_grouper.cancel();
580 synfig::info("I supposedly moved %d layers",i);
582 // Reselect the previously selected layers
583 canvas_interface()->get_selection_manager()->set_selected_layers(selected_layer_list);
589 LayerTreeStore::rebuild()
591 //etl::clock timer;timer.reset();
593 //synfig::warning("---------rebuilding layer table---------");
594 // Save the selection data
595 synfigapp::SelectionManager::LayerList layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
597 // Clear out the current list
600 // Go ahead and and add all the layers
602 canvas_interface()->get_canvas()->rbegin(), canvas_interface()->get_canvas()->rend(),
603 sigc::mem_fun(*this, &studio::LayerTreeStore::on_layer_added)
606 // Reselect the previously selected layers
607 if(!layer_list.empty())
608 canvas_interface()->get_selection_manager()->set_selected_layers(layer_list);
610 //synfig::info("LayerTreeStore::rebuild() took %f seconds",float(timer()));
614 LayerTreeStore::refresh()
616 etl::clock timer;timer.reset();
618 Gtk::TreeModel::Children children_(children());
620 Gtk::TreeModel::Children::iterator iter;
622 if(!children_.empty())
623 for(iter = children_.begin(); iter && iter != children_.end(); ++iter)
625 Gtk::TreeRow row=*iter;
628 //synfig::info("LayerTreeStore::refresh() took %f seconds",float(timer()));
632 LayerTreeStore::refresh_row(Gtk::TreeModel::Row &row)
634 Layer::Handle layer=row[model.layer];
637 row[model.name] = layer->get_local_name();
638 if(layer->get_description().empty())
640 row[model.label] = layer->get_local_name();
641 row[model.tooltip] = Glib::ustring("Layer");
645 row[model.label] = layer->get_description();
646 row[model.tooltip] = layer->get_local_name();
651 if(layer->dynamic_param_list().count("z_depth"))
652 row[model.z_depth]=Time::begin();
653 // row_changed(get_path(row),row);
655 Gtk::TreeModel::Children children = row.children();
656 Gtk::TreeModel::Children::iterator iter;
658 if(!children.empty())
659 for(iter = children.begin(); iter && iter != children.end(); ++iter)
661 Gtk::TreeRow row=*iter;
668 LayerTreeStore::set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle)
670 //row[model.id] = handle->get_name();
671 //row[model.name] = handle->get_local_name();
672 /*if(handle->get_description().empty())
674 //row[model.label] = handle->get_local_name();
675 row[model.tooltip] = Glib::ustring("Layer");
679 //row[model.label] = handle->get_description();
680 row[model.tooltip] = handle->get_local_name();
683 //row[model.active] = handle->active();
684 row[model.layer] = handle;
685 //row[model.canvas] = handle->get_canvas();
686 //row[model.icon] = layer_icon;
688 synfig::Layer::ParamList paramlist=handle->get_param_list();
690 synfig::Layer::Vocab vocab=handle->get_param_vocab();
691 synfig::Layer::Vocab::iterator iter;
693 for(iter=vocab.begin();iter!=vocab.end();++iter)
695 if(iter->get_hidden())
697 if(handle->get_param(iter->get_name()).get_type()!=ValueBase::TYPE_CANVAS)
701 Canvas::Handle canvas;
702 canvas=handle->get_param(iter->get_name()).get(canvas);
706 Canvas::reverse_iterator iter;
707 row[model.contained_canvas]=canvas;
709 for(iter=canvas->rbegin();iter!=canvas->rend();++iter)
711 Gtk::TreeRow row_(*(prepend(row.children())));
712 set_row_layer(row_,*iter);
718 etl::handle<ValueNode> value_node;
719 if(handle.constant()->dynamic_param_list().count(iter->get_name()))
720 value_node=handle->dynamic_param_list()[iter->get_name()];
722 Gtk::TreeRow child_row = *(append(row.children()));
727 iter->get_local_name(),
728 paramlist[iter->get_name()],
737 LayerTreeStore::on_layer_added(synfig::Layer::Handle layer)
741 if(canvas_interface()->get_canvas()==layer->get_canvas())
747 Gtk::TreeModel::Children::iterator iter;
748 if(!find_canvas_row(layer->get_canvas(),iter))
753 row=*(prepend(iter->children()));
755 set_row_layer(row,layer);
759 LayerTreeStore::on_layer_removed(synfig::Layer::Handle handle)
761 Gtk::TreeModel::Children::iterator iter;
762 if(find_layer_row(handle,iter))
766 synfig::error("LayerTreeStore::on_layer_removed():Unable to find layer to be removed, forced to rebuild...");
772 LayerTreeStore::on_layer_inserted(synfig::Layer::Handle handle,int depth)
776 on_layer_added(handle);
780 Gtk::TreeModel::Children children_(children());
781 if(canvas_interface()->get_canvas()!=handle->get_canvas())
783 Gtk::TreeModel::Children::iterator iter;
784 if(!find_canvas_row(handle->get_canvas(),iter))
786 synfig::error("LayerTreeStore::on_layer_inserted():Unable to find canvas row, forced to rebuild...");
790 children_=iter->children();
793 Gtk::TreeModel::Children::iterator iter(children_.begin());
794 while(depth-- && iter)
797 if(!iter || iter==children_.end())
799 synfig::error("LayerTreeStore::on_layer_inserted():Unable to achieve desired depth, forced to rebuild...");
805 Gtk::TreeModel::Row row(*insert(iter));
806 set_row_layer(row,handle);
810 LayerTreeStore::on_layer_status_changed(synfig::Layer::Handle handle,bool /*x*/)
812 Gtk::TreeModel::Children::iterator iter;
813 if(find_layer_row(handle,iter))
814 (*iter)[model.layer]=handle;
817 synfig::warning("Couldn't find layer to be activated in layer list. Rebuilding index...");
823 LayerTreeStore::on_layer_lowered(synfig::Layer::Handle layer)
825 Gtk::TreeModel::Children::iterator iter, iter2;
826 if(find_layer_row(layer,iter))
828 // Save the selection data
829 //synfigapp::SelectionManager::LayerList layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
838 //Gtk::TreeModel::Row row(*iter);
839 Gtk::TreeModel::Row row2 = *iter2;
840 synfig::Layer::Handle layer2=row2[model.layer];
844 set_row_layer(row2,layer2);
852 LayerTreeStore::on_layer_raised(synfig::Layer::Handle layer)
854 Gtk::TreeModel::Children::iterator iter, iter2;
856 Gtk::TreeModel::Children children_(children());
858 if(find_layer_row_(layer, canvas_interface()->get_canvas(), children_, iter,iter2))
862 //Gtk::TreeModel::Row row = *iter;
863 Gtk::TreeModel::Row row2 = *iter2;
864 synfig::Layer::Handle layer2=row2[model.layer];
869 set_row_layer(row2,layer2);
879 LayerTreeStore::on_layer_moved(synfig::Layer::Handle layer,int depth, synfig::Canvas::Handle /*canvas*/)
881 on_layer_removed(layer);
882 on_layer_inserted(layer,depth);
886 LayerTreeStore::on_layer_param_changed(synfig::Layer::Handle handle,synfig::String param_name)
888 if(param_name=="z_depth")
890 Gtk::TreeModel::Children::iterator iter;
891 if(find_layer_row(handle,iter))
893 (*iter)[model.z_depth]=Time::begin();
898 Gtk::TreeModel::Children::iterator iter;
899 if(find_layer_row(handle,iter))
901 Gtk::TreeModel::Children children(iter->children());
903 for(iter = children.begin(); iter && iter != children.end(); ++iter)
905 if((Glib::ustring)(*iter)[model.param_name]==param_name)
907 Gtk::TreeRow row=*iter;
918 LayerTreeStore::on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc)
920 Gtk::TreeModel::Children::iterator iter;
921 if(find_layer_row(handle,iter))
923 Gtk::TreeRow row(*iter);
925 Layer::Handle layer(row[model.layer]);
929 //row[model.label]=layer->get_local_name();
930 row[model.tooltip]=Glib::ustring(_("Layer"));
933 //row[model.label]=layer->get_description();
934 row[model.tooltip]=layer->get_local_name();
943 LayerTreeStore::find_canvas_row_(synfig::Canvas::Handle canvas, synfig::Canvas::Handle parent, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter)
949 for(iter=layers.begin(); iter && iter != layers.end(); ++iter)
951 Gtk::TreeModel::Row row = *iter;
952 if(canvas==(synfig::Canvas::Handle)row[model.contained_canvas])
956 iter=children().end();
960 Gtk::TreeModel::Children::iterator iter2;
961 //Gtk::TreeModel::Children::iterator iter3;
963 for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
965 Gtk::TreeModel::Row row = *iter2;
968 if(row.children().empty())
971 Canvas::Handle sub_canvas((*row.children().begin())[model.canvas]);
975 if(find_canvas_row_(canvas,sub_canvas,iter2->children(),iter))
979 iter=children().end();
984 LayerTreeStore::find_canvas_row(synfig::Canvas::Handle canvas, Gtk::TreeModel::Children::iterator &iter)
986 return find_canvas_row_(canvas,canvas_interface()->get_canvas(),children(),iter);
991 LayerTreeStore::find_layer_row_(const synfig::Layer::Handle &layer, synfig::Canvas::Handle /*canvas*/, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev)
995 //if(layer->get_canvas()==canvas)
997 for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
999 Gtk::TreeModel::Row row = *iter;
1000 if(layer==(synfig::Layer::Handle)row[model.layer])
1004 iter=children().end();
1008 Gtk::TreeModel::Children::iterator iter2;
1010 for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
1012 Gtk::TreeModel::Row row = *iter2;
1015 if(row.children().empty())
1018 Canvas::Handle canvas((*row.children().begin())[model.canvas]);
1022 if(find_layer_row_(layer,canvas,iter2->children(),iter,prev))
1026 iter=children().end();
1031 LayerTreeStore::find_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &iter)
1033 Gtk::TreeModel::Children::iterator prev;
1034 return find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev);
1038 LayerTreeStore::find_prev_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &prev)
1040 Gtk::TreeModel::Children::iterator iter;
1041 if(!find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev))
1043 if(iter==children().begin())