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
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "layertreestore.h"
33 #include "iconcontroler.h"
34 #include <gtkmm/button.h>
35 #include <synfig/paramdesc.h>
36 #include <synfigapp/action.h>
37 #include <synfigapp/instance.h>
40 #include "iconcontroler.h"
41 #include <synfigapp/action_system.h>
43 #include <gtk/gtkversion.h>
47 /* === U S I N G =========================================================== */
51 using namespace synfig;
52 using namespace studio;
54 /* === M A C R O S ========================================================= */
56 /* === G L O B A L S ======================================================= */
58 /* === P R O C E D U R E S ================================================= */
60 /* === M E T H O D S ======================================================= */
62 static LayerTreeStore::Model& ModelHack()
64 static LayerTreeStore::Model* model(0);
65 if(!model)model=new LayerTreeStore::Model;
69 LayerTreeStore::LayerTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
70 Gtk::TreeStore (ModelHack()),
71 canvas_interface_ (canvas_interface_)
73 layer_icon=Gtk::Button().render_icon(Gtk::StockID("synfig-layer"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
75 // Connect Signals to Terminals
76 canvas_interface()->signal_layer_status_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_status_changed));
77 canvas_interface()->signal_layer_lowered().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_lowered));
78 canvas_interface()->signal_layer_raised().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_raised));
79 canvas_interface()->signal_layer_removed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_removed));
80 canvas_interface()->signal_layer_inserted().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_inserted));
81 canvas_interface()->signal_layer_moved().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_moved));
82 //canvas_interface()->signal_layer_param_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_param_changed));
83 canvas_interface()->signal_layer_new_description().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_new_description));
85 canvas_interface()->signal_time_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::refresh));
87 //canvas_interface()->signal_value_node_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_changed));
88 //canvas_interface()->signal_value_node_added().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_added));
89 //canvas_interface()->signal_value_node_deleted().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_deleted));
90 //canvas_interface()->signal_value_node_replaced().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_replaced));
92 set_default_sort_func(sigc::ptr_fun(index_sorter));
97 LayerTreeStore::~LayerTreeStore()
99 synfig::info("LayerTreeStore::~LayerTreeStore()q: Deleted");
104 LayerTreeStore::z_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs)
108 float diff((float)(*rhs)[model.z_depth]-(float)(*lhs)[model.z_depth]);
118 LayerTreeStore::index_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs)
122 return ((int)(*rhs)[model.index]-(int)(*lhs)[model.index]);
126 LayerTreeStore::search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring& x,const TreeModel::iterator& iter)
130 Glib::ustring substr(x.uppercase());
131 Glib::ustring label((*iter)[model.label]);
132 label=label.uppercase();
134 return label.find(substr)==Glib::ustring::npos;
138 Glib::RefPtr<LayerTreeStore>
139 LayerTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
141 return Glib::RefPtr<LayerTreeStore>(new LayerTreeStore(canvas_interface_));
145 LayerTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
147 if(column==model.index.index())
149 synfig::Layer::Handle layer((*iter)[model.layer]);
154 g_value_init(x.gobj(),x.value_type());
156 x.set(layer->get_depth());
158 g_value_init(value.gobj(),x.value_type());
159 g_value_copy(x.gobj(),value.gobj());
162 if(column==model.z_depth.index())
164 synfig::Layer::Handle layer((*iter)[model.layer]);
168 Glib::Value<float> x;
169 g_value_init(x.gobj(),x.value_type());
171 x.set(layer->get_z_depth(canvas_interface()->get_time())*1.0001+layer->get_depth());
173 g_value_init(value.gobj(),x.value_type());
174 g_value_copy(x.gobj(),value.gobj());
177 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_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());
195 if(column==model.label.index())
197 synfig::Layer::Handle layer((*iter)[model.layer]);
201 Glib::Value<Glib::ustring> x;
202 g_value_init(x.gobj(),x.value_type());
205 if(!layer->get_description().empty())
206 x.set(layer->get_description());
208 x.set(layer->get_local_name());
210 g_value_init(value.gobj(),x.value_type());
211 //g_value_copy(x.gobj(),value.gobj());
215 if(column==model.tooltip.index())
217 synfig::Layer::Handle layer((*iter)[model.layer]);
221 Glib::Value<Glib::ustring> x;
222 g_value_init(x.gobj(),x.value_type());
225 x.set(layer->get_local_name());
227 g_value_init(value.gobj(),x.value_type());
228 //g_value_copy(x.gobj(),value.gobj());
232 if(column==model.canvas.index())
234 synfig::Layer::Handle layer((*iter)[model.layer]);
238 Glib::Value<Canvas::Handle> x;
239 g_value_init(x.gobj(),x.value_type());
242 x.set(layer->get_canvas());
244 g_value_init(value.gobj(),x.value_type());
245 //g_value_copy(x.gobj(),value.gobj());
249 if(column==model.active.index())
251 synfig::Layer::Handle layer((*iter)[model.layer]);
256 g_value_init(x.gobj(),x.value_type());
258 x.set(layer->active());
260 g_value_init(value.gobj(),x.value_type());
261 g_value_copy(x.gobj(),value.gobj());
264 if(column==model.icon.index())
266 synfig::Layer::Handle layer((*iter)[model.layer]);
269 Glib::Value<Glib::RefPtr<Gdk::Pixbuf> > x;
270 g_value_init(x.gobj(),x.value_type());
273 x.set(get_tree_pixbuf_layer(layer->get_name()));
275 g_value_init(value.gobj(),x.value_type());
276 g_value_copy(x.gobj(),value.gobj());
279 Gtk::TreeStore::get_value_vfunc(iter,column,value);
283 LayerTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
285 //if(!iterator_sane(row))
288 if(column>=get_n_columns_vfunc())
290 g_warning("LayerTreeStore::set_value_impl: Bad column (%d)",column);
294 if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
296 g_warning("LayerTreeStore::set_value_impl: Bad value type");
302 if(column==model.label.index())
304 Glib::Value<Glib::ustring> x;
305 g_value_init(x.gobj(),model.label.type());
306 g_value_copy(value.gobj(),x.gobj());
308 synfig::Layer::Handle layer((*iter)[model.layer]);
311 synfig::String new_desc(x.get());
313 if(new_desc==layer->get_local_name())
314 new_desc=synfig::String();
316 if(new_desc==layer->get_description())
319 synfigapp::Action::Handle action(synfigapp::Action::create("layer_set_desc"));
324 action->set_param("canvas",canvas_interface()->get_canvas());
325 action->set_param("canvas_interface",canvas_interface());
326 action->set_param("layer",layer);
327 action->set_param("new_description",synfig::String(x.get()));
329 canvas_interface()->get_instance()->perform_action(action);
333 if(column==model.active.index())
335 synfig::Layer::Handle layer((*iter)[model.layer]);
340 g_value_init(x.gobj(),model.active.type());
341 g_value_copy(value.gobj(),x.gobj());
343 synfigapp::Action::Handle action(synfigapp::Action::create("layer_activate"));
348 action->set_param("canvas",canvas_interface()->get_canvas());
349 action->set_param("canvas_interface",canvas_interface());
350 action->set_param("layer",layer);
351 action->set_param("new_status",bool(x.get()));
353 canvas_interface()->get_instance()->perform_action(action);
357 Gtk::TreeStore::set_value_impl(iter,column, value);
360 catch(std::exception x)
370 LayerTreeStore::row_draggable_vfunc (const TreeModel::Path& path)const
372 //if(!get_iter(path)) return false;
373 // Gtk::TreeModel::Row row(*get_iter(path));
376 // return (bool)true;
380 LayerTreeStore::drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const
382 if(!const_cast<LayerTreeStore*>(this)->get_iter(path)) return false;
383 //synfig::info("Dragged data of type \"%s\"",selection_data.get_data_type());
384 //synfig::info("Dragged data of target \"%s\"",gdk_atom_name(selection_data->target));
385 //synfig::info("Dragged selection=\"%s\"",gdk_atom_name(selection_data->selection));
387 Gtk::TreeModel::Row row(*const_cast<LayerTreeStore*>(this)->get_iter(path));
391 Layer* layer(((Layer::Handle)row[model.layer]).get());
393 bool included(false);
395 //gtk_selection_data_set (selection_data, gdk_atom_intern("LAYER",false), 8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
397 std::vector<Layer*> layers;
398 // The following is a hack for multiple row DND
400 synfigapp::SelectionManager::LayerList bleh(get_canvas_interface()->get_selection_manager()->get_selected_layers());
403 selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
408 if(bleh.back().get()==layer)
410 layers.push_back(bleh.back().get());
415 layers.push_back(layer);
416 selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layers.front()), sizeof(void*)*layers.size());
424 LayerTreeStore::drag_data_delete_vfunc (const TreeModel::Path& path)
430 LayerTreeStore::row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const
432 //if(!const_cast<LayerTreeStore*>(this)->get_iter(dest)) return false;
434 //synfig::info("possible_drop -- data of type \"%s\"",selection_data.get_data_type());
435 //synfig::info("possible_drop -- data of target \"%s\"",gdk_atom_name(selection_data->target));
436 //synfig::info("possible_drop -- selection=\"%s\"",gdk_atom_name(selection_data->selection));
438 //Gtk::TreeModel::Row row(*get_iter(dest));
440 if(synfig::String(selection_data.get_data_type())=="LAYER" && (bool)true)
442 //Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
446 TreeModel::Path dest_parent(dest);
447 if(!dest_parent.up() || dest.get_depth()==1)
449 //row=(*get_iter(dest));
450 //dest_canvas=(Canvas::Handle)(row[model.canvas]);
455 if((bool)const_cast<LayerTreeStore*>(this)->get_iter(dest_parent))
456 return (bool)(Canvas::Handle)(*const_cast<LayerTreeStore*>(this)->get_iter(dest_parent))[model.contained_canvas];
465 LayerTreeStore::drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)
468 //if(!dest_parent.up() || !get_iter(dest)) return false;
474 //synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
475 //synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
476 //synfig::info("Dropped selection=\"%s\"",gdk_atom_name(selection_data->selection));
477 synfigapp::Action::PassiveGrouper passive_grouper(canvas_interface()->get_instance().get(),_("Move Layers"));
479 // Save the selection data
480 synfigapp::SelectionManager::LayerList selected_layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
482 if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
484 Gtk::TreeModel::Row row;
485 Canvas::Handle dest_canvas;
487 int dest_layer_depth=dest.back();
489 TreeModel::Path dest_parent(dest);
490 if(!dest_parent.up() || !get_iter(dest_parent))
492 TreeModel::Path dest_(dest);
500 row=(*get_iter(dest_));
501 dest_canvas=(Canvas::Handle)(row[model.canvas]);
506 row=(*get_iter(dest_parent));
507 dest_canvas=row[model.contained_canvas];
512 Layer::Handle dest_layer(row[model.layer]);
514 if(synfig::String(selection_data.get_data_type())=="LAYER")for(unsigned int i=0;i<selection_data.get_length()/sizeof(void*);i++)
516 //synfig::info("dest_layer_depth=%d",dest_layer_depth);
518 Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
523 if(dest_canvas==src->get_canvas() && src->get_depth()<dest_layer_depth)
528 // In this case, we are just moving.
529 // if(dest_canvas==src->get_canvas())
531 //if(dest_canvas==src->get_canvas() && dest_layer_depth && dest_layer_depth>src->get_depth())
532 // dest_layer_depth--;
533 if(dest_canvas==src->get_canvas() && dest_layer_depth==src->get_depth())
536 synfigapp::Action::Handle action(synfigapp::Action::create("layer_move"));
537 action->set_param("canvas",dest_canvas);
538 action->set_param("canvas_interface",canvas_interface());
539 action->set_param("layer",src);
540 action->set_param("new_index",dest_layer_depth);
541 action->set_param("dest_canvas",dest_canvas);
542 if(canvas_interface()->get_instance()->perform_action(action))
550 passive_grouper.cancel();
555 /*else // In this case we need to remove and then add
558 synfigapp::Action::Handle action;
559 action=synfigapp::Action::create("layer_remove");
560 action->set_param("canvas",Canvas::Handle(src->get_canvas()));
561 if(!action->set_param("canvas_interface",App::get_instance(src->get_canvas())->find_canvas_interface(src->get_canvas())))
562 action->set_param("canvas_interface",canvas_interface());
563 action->set_param("layer",src);
564 if(!canvas_interface()->get_instance()->perform_action(action))
566 passive_grouper.cancel();
571 action=synfigapp::Action::create("layer_add");
572 action->set_param("canvas",dest_canvas);
573 action->set_param("canvas_interface",canvas_interface());
574 action->set_param("new",src);
575 if(!canvas_interface()->get_instance()->perform_action(action))
577 passive_grouper.cancel();
582 if(dest_layer_depth!=0)
584 action=synfigapp::Action::create("layer_move");
585 action->set_param("canvas",dest_canvas);
586 action->set_param("canvas_interface",canvas_interface());
587 action->set_param("layer",src);
588 action->set_param("new_index",dest_layer_depth);
589 if(!canvas_interface()->get_instance()->perform_action(action))
591 passive_grouper.cancel();
601 synfig::info("I suposidly moved %d layers",i);
603 // Reselect the previously selected layers
604 canvas_interface()->get_selection_manager()->set_selected_layers(selected_layer_list);
616 LayerTreeStore::rebuild()
618 //etl::clock timer;timer.reset();
620 //synfig::warning("---------rebuilding layer table---------");
621 // Save the selection data
622 synfigapp::SelectionManager::LayerList layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
624 // Clear out the current list
627 // Go ahead and and add all the layers
629 canvas_interface()->get_canvas()->rbegin(), canvas_interface()->get_canvas()->rend(),
630 sigc::mem_fun(*this, &studio::LayerTreeStore::on_layer_added)
633 // Reselect the previously selected layers
634 if(!layer_list.empty())
635 canvas_interface()->get_selection_manager()->set_selected_layers(layer_list);
637 //synfig::info("LayerTreeStore::rebuild() took %f seconds",float(timer()));
641 LayerTreeStore::refresh()
643 etl::clock timer;timer.reset();
645 Gtk::TreeModel::Children children_(children());
647 Gtk::TreeModel::Children::iterator iter;
649 if(!children_.empty())
650 for(iter = children_.begin(); iter && iter != children_.end(); ++iter)
652 Gtk::TreeRow row=*iter;
655 //synfig::info("LayerTreeStore::refresh() took %f seconds",float(timer()));
659 LayerTreeStore::refresh_row(Gtk::TreeModel::Row &row)
661 Layer::Handle layer=row[model.layer];
664 row[model.name] = layer->get_local_name();
665 if(layer->get_description().empty())
667 row[model.label] = layer->get_local_name();
668 row[model.tooltip] = Glib::ustring("Layer");
672 row[model.label] = layer->get_description();
673 row[model.tooltip] = layer->get_local_name();
678 if(layer->dynamic_param_list().count("z_depth"))
679 row[model.z_depth]=Time::begin();
680 // row_changed(get_path(row),row);
682 Gtk::TreeModel::Children children = row.children();
683 Gtk::TreeModel::Children::iterator iter;
685 if(!children.empty())
686 for(iter = children.begin(); iter && iter != children.end(); ++iter)
688 Gtk::TreeRow row=*iter;
695 LayerTreeStore::set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle)
697 //row[model.id] = handle->get_name();
698 //row[model.name] = handle->get_local_name();
699 /*if(handle->get_description().empty())
701 //row[model.label] = handle->get_local_name();
702 row[model.tooltip] = Glib::ustring("Layer");
706 //row[model.label] = handle->get_description();
707 row[model.tooltip] = handle->get_local_name();
710 //row[model.active] = handle->active();
711 row[model.layer] = handle;
712 //row[model.canvas] = handle->get_canvas();
713 //row[model.icon] = layer_icon;
715 synfig::Layer::ParamList paramlist=handle->get_param_list();
717 synfig::Layer::Vocab vocab=handle->get_param_vocab();
718 synfig::Layer::Vocab::iterator iter;
720 for(iter=vocab.begin();iter!=vocab.end();++iter)
722 if(iter->get_hidden())
724 if(handle->get_param(iter->get_name()).get_type()!=ValueBase::TYPE_CANVAS)
728 Canvas::Handle canvas;
729 canvas=handle->get_param(iter->get_name()).get(canvas);
733 Canvas::reverse_iterator iter;
734 row[model.contained_canvas]=canvas;
736 for(iter=canvas->rbegin();iter!=canvas->rend();++iter)
738 Gtk::TreeRow row_(*(prepend(row.children())));
739 set_row_layer(row_,*iter);
746 etl::handle<ValueNode> value_node;
747 if(handle.constant()->dynamic_param_list().count(iter->get_name()))
748 value_node=handle->dynamic_param_list()[iter->get_name()];
750 Gtk::TreeRow child_row = *(append(row.children()));
755 iter->get_local_name(),
756 paramlist[iter->get_name()],
765 LayerTreeStore::on_layer_added(synfig::Layer::Handle layer)
769 if(canvas_interface()->get_canvas()==layer->get_canvas())
775 Gtk::TreeModel::Children::iterator iter;
776 if(!find_canvas_row(layer->get_canvas(),iter))
781 row=*(prepend(iter->children()));
783 set_row_layer(row,layer);
787 LayerTreeStore::on_layer_removed(synfig::Layer::Handle handle)
789 Gtk::TreeModel::Children::iterator iter;
790 if(find_layer_row(handle,iter))
794 synfig::error("LayerTreeStore::on_layer_removed():Unable to find layer to be removed, forced to rebuild...");
800 LayerTreeStore::on_layer_inserted(synfig::Layer::Handle handle,int depth)
804 on_layer_added(handle);
809 Gtk::TreeModel::Children children_(children());
810 if(canvas_interface()->get_canvas()!=handle->get_canvas())
812 Gtk::TreeModel::Children::iterator iter;
813 if(!find_canvas_row(handle->get_canvas(),iter))
815 synfig::error("LayerTreeStore::on_layer_inserted():Unable to find canvas row, forced to rebuild...");
819 children_=iter->children();
822 Gtk::TreeModel::Children::iterator iter(children_.begin());
823 while(depth-- && iter)
826 if(!iter || iter==children_.end())
828 synfig::error("LayerTreeStore::on_layer_inserted():Unable to achieve desired depth, forced to rebuild...");
834 Gtk::TreeModel::Row row(*insert(iter));
835 set_row_layer(row,handle);
840 LayerTreeStore::on_layer_status_changed(synfig::Layer::Handle handle,bool x)
842 Gtk::TreeModel::Children::iterator iter;
843 if(find_layer_row(handle,iter))
844 (*iter)[model.layer]=handle;
847 synfig::warning("Couldn't find layer to be activated in layer list. Rebuilding index...");
853 LayerTreeStore::on_layer_lowered(synfig::Layer::Handle layer)
855 Gtk::TreeModel::Children::iterator iter, iter2;
856 if(find_layer_row(layer,iter))
858 // Save the selection data
859 //synfigapp::SelectionManager::LayerList layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
868 //Gtk::TreeModel::Row row(*iter);
869 Gtk::TreeModel::Row row2 = *iter2;
870 synfig::Layer::Handle layer2=row2[model.layer];
874 set_row_layer(row2,layer2);
882 LayerTreeStore::on_layer_raised(synfig::Layer::Handle layer)
884 Gtk::TreeModel::Children::iterator iter, iter2;
886 Gtk::TreeModel::Children children_(children());
888 if(find_layer_row_(layer, canvas_interface()->get_canvas(), children_, iter,iter2))
892 //Gtk::TreeModel::Row row = *iter;
893 Gtk::TreeModel::Row row2 = *iter2;
894 synfig::Layer::Handle layer2=row2[model.layer];
899 set_row_layer(row2,layer2);
909 LayerTreeStore::on_layer_moved(synfig::Layer::Handle layer,int depth, synfig::Canvas::Handle canvas)
911 on_layer_removed(layer);
912 on_layer_inserted(layer,depth);
916 LayerTreeStore::on_layer_param_changed(synfig::Layer::Handle handle,synfig::String param_name)
918 if(param_name=="z_depth")
920 Gtk::TreeModel::Children::iterator iter;
921 if(find_layer_row(handle,iter))
923 (*iter)[model.z_depth]=Time::begin();
929 Gtk::TreeModel::Children::iterator iter;
930 if(find_layer_row(handle,iter))
933 Gtk::TreeModel::Children children(iter->children());
935 for(iter = children.begin(); iter && iter != children.end(); ++iter)
937 if((Glib::ustring)(*iter)[model.param_name]==param_name)
940 Gtk::TreeRow row=*iter;
952 LayerTreeStore::on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc)
954 Gtk::TreeModel::Children::iterator iter;
955 if(find_layer_row(handle,iter))
957 Gtk::TreeRow row(*iter);
959 Layer::Handle layer(row[model.layer]);
963 //row[model.label]=layer->get_local_name();
964 row[model.tooltip]=Glib::ustring(_("Layer"));
967 //row[model.label]=layer->get_description();
968 row[model.tooltip]=layer->get_local_name();
977 LayerTreeStore::find_canvas_row_(synfig::Canvas::Handle canvas, synfig::Canvas::Handle parent, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter)
983 for(iter=layers.begin(); iter && iter != layers.end(); ++iter)
985 Gtk::TreeModel::Row row = *iter;
986 if(canvas==(synfig::Canvas::Handle)row[model.contained_canvas])
990 iter=children().end();
994 Gtk::TreeModel::Children::iterator iter2;
995 //Gtk::TreeModel::Children::iterator iter3;
997 for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
999 Gtk::TreeModel::Row row = *iter2;
1002 if(row.children().empty())
1005 Canvas::Handle sub_canvas((*row.children().begin())[model.canvas]);
1009 if(find_canvas_row_(canvas,sub_canvas,iter2->children(),iter))
1013 iter=children().end();
1018 LayerTreeStore::find_canvas_row(synfig::Canvas::Handle canvas, Gtk::TreeModel::Children::iterator &iter)
1020 return find_canvas_row_(canvas,canvas_interface()->get_canvas(),children(),iter);
1025 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)
1029 //if(layer->get_canvas()==canvas)
1031 for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
1033 Gtk::TreeModel::Row row = *iter;
1034 if(layer==(synfig::Layer::Handle)row[model.layer])
1038 iter=children().end();
1043 Gtk::TreeModel::Children::iterator iter2;
1045 for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
1047 Gtk::TreeModel::Row row = *iter2;
1050 if(row.children().empty())
1053 Canvas::Handle canvas((*row.children().begin())[model.canvas]);
1057 if(find_layer_row_(layer,canvas,iter2->children(),iter,prev))
1061 iter=children().end();
1066 LayerTreeStore::find_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &iter)
1068 Gtk::TreeModel::Children::iterator prev;
1069 return find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev);
1073 LayerTreeStore::find_prev_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &prev)
1075 Gtk::TreeModel::Children::iterator iter;
1076 if(!find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev))
1078 if(iter==children().begin())