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 "iconcontroller.h"
34 #include <gtkmm/button.h>
35 #include <synfig/paramdesc.h>
36 #include <synfigapp/action.h>
37 #include <synfigapp/instance.h>
40 #include <synfigapp/action_system.h>
42 #include <gtk/gtkversion.h>
48 /* === U S I N G =========================================================== */
52 using namespace synfig;
53 using namespace studio;
55 /* === M A C R O S ========================================================= */
57 /* === G L O B A L S ======================================================= */
59 /* === P R O C E D U R E S ================================================= */
61 /* === M E T H O D S ======================================================= */
63 static LayerTreeStore::Model& ModelHack()
65 static LayerTreeStore::Model* model(0);
66 if(!model)model=new LayerTreeStore::Model;
70 LayerTreeStore::LayerTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
71 Gtk::TreeStore (ModelHack()),
72 canvas_interface_ (canvas_interface_)
74 layer_icon=Gtk::Button().render_icon(Gtk::StockID("synfig-layer"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
76 // Connect Signals to Terminals
77 canvas_interface()->signal_layer_status_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_status_changed));
78 canvas_interface()->signal_layer_lowered().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_lowered));
79 canvas_interface()->signal_layer_raised().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_raised));
80 canvas_interface()->signal_layer_removed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_removed));
81 canvas_interface()->signal_layer_inserted().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_inserted));
82 canvas_interface()->signal_layer_moved().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_moved));
83 //canvas_interface()->signal_layer_param_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_param_changed));
84 canvas_interface()->signal_layer_new_description().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_new_description));
86 canvas_interface()->signal_time_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::refresh));
88 //canvas_interface()->signal_value_node_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_changed));
89 //canvas_interface()->signal_value_node_added().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_added));
90 //canvas_interface()->signal_value_node_deleted().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_deleted));
91 //canvas_interface()->signal_value_node_replaced().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_replaced));
93 set_default_sort_func(sigc::ptr_fun(index_sorter));
98 LayerTreeStore::~LayerTreeStore()
100 synfig::info("LayerTreeStore::~LayerTreeStore(): 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());
161 else if(column==model.z_depth.index())
163 synfig::Layer::Handle layer((*iter)[model.layer]);
167 Glib::Value<float> x;
168 g_value_init(x.gobj(),x.value_type());
170 x.set(layer->get_z_depth(canvas_interface()->get_time())*1.0001+layer->get_depth());
172 g_value_init(value.gobj(),x.value_type());
173 g_value_copy(x.gobj(),value.gobj());
175 else if(column==model.children_lock.index())
177 synfig::Layer::Handle layer((*iter)[model.layer]);
182 g_value_init(x.gobj(),x.value_type());
185 ValueBase v(layer->get_param("children_lock"));
186 if(v.same_type_as(bool()))
187 x.set(v.get(bool()));
189 g_value_init(value.gobj(),x.value_type());
190 g_value_copy(x.gobj(),value.gobj());
192 else if(column==model.label.index())
194 synfig::Layer::Handle layer((*iter)[model.layer]);
198 Glib::Value<Glib::ustring> x;
199 g_value_init(x.gobj(),x.value_type());
201 x.set(layer->get_non_empty_description());
203 g_value_init(value.gobj(),x.value_type());
204 //g_value_copy(x.gobj(),value.gobj());
207 else if(column==model.tooltip.index())
209 synfig::Layer::Handle layer((*iter)[model.layer]);
213 Glib::Value<Glib::ustring> x;
214 g_value_init(x.gobj(),x.value_type());
217 x.set(layer->get_local_name());
219 g_value_init(value.gobj(),x.value_type());
220 //g_value_copy(x.gobj(),value.gobj());
223 else if(column==model.canvas.index())
225 synfig::Layer::Handle layer((*iter)[model.layer]);
229 Glib::Value<Canvas::Handle> x;
230 g_value_init(x.gobj(),x.value_type());
233 x.set(layer->get_canvas());
235 g_value_init(value.gobj(),x.value_type());
236 //g_value_copy(x.gobj(),value.gobj());
239 else if(column==model.active.index())
241 synfig::Layer::Handle layer((*iter)[model.layer]);
246 g_value_init(x.gobj(),x.value_type());
248 x.set(layer->active());
250 g_value_init(value.gobj(),x.value_type());
251 g_value_copy(x.gobj(),value.gobj());
253 else if(column==model.icon.index())
255 synfig::Layer::Handle layer((*iter)[model.layer]);
258 Glib::Value<Glib::RefPtr<Gdk::Pixbuf> > x;
259 g_value_init(x.gobj(),x.value_type());
262 x.set(get_tree_pixbuf_layer(layer->get_name()));
264 g_value_init(value.gobj(),x.value_type());
265 g_value_copy(x.gobj(),value.gobj());
268 Gtk::TreeStore::get_value_vfunc(iter,column,value);
272 LayerTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
274 //if(!iterator_sane(row))
277 if(column>=get_n_columns_vfunc())
279 g_warning("LayerTreeStore::set_value_impl: Bad column (%d)",column);
283 if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
285 g_warning("LayerTreeStore::set_value_impl: Bad value type");
291 if(column==model.label.index())
293 Glib::Value<Glib::ustring> x;
294 g_value_init(x.gobj(),model.label.type());
295 g_value_copy(value.gobj(),x.gobj());
297 synfig::Layer::Handle layer((*iter)[model.layer]);
300 synfig::String new_desc(x.get());
302 if(new_desc==layer->get_local_name())
303 new_desc=synfig::String();
305 if(new_desc==layer->get_description())
308 synfigapp::Action::Handle action(synfigapp::Action::create("layer_set_desc"));
313 action->set_param("canvas",canvas_interface()->get_canvas());
314 action->set_param("canvas_interface",canvas_interface());
315 action->set_param("layer",layer);
316 action->set_param("new_description",synfig::String(x.get()));
318 canvas_interface()->get_instance()->perform_action(action);
321 else if(column==model.active.index())
323 synfig::Layer::Handle layer((*iter)[model.layer]);
328 g_value_init(x.gobj(),model.active.type());
329 g_value_copy(value.gobj(),x.gobj());
331 synfigapp::Action::Handle action(synfigapp::Action::create("layer_activate"));
336 action->set_param("canvas",canvas_interface()->get_canvas());
337 action->set_param("canvas_interface",canvas_interface());
338 action->set_param("layer",layer);
339 action->set_param("new_status",bool(x.get()));
341 canvas_interface()->get_instance()->perform_action(action);
345 Gtk::TreeStore::set_value_impl(iter,column, value);
348 catch(std::exception x)
358 LayerTreeStore::row_draggable_vfunc (const TreeModel::Path& /*path*/)const
360 //if(!get_iter(path)) return false;
361 // Gtk::TreeModel::Row row(*get_iter(path));
364 // return (bool)true;
368 LayerTreeStore::drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const
370 if(!const_cast<LayerTreeStore*>(this)->get_iter(path)) return false;
371 //synfig::info("Dragged data of type \"%s\"",selection_data.get_data_type());
372 //synfig::info("Dragged data of target \"%s\"",gdk_atom_name(selection_data->target));
373 //synfig::info("Dragged selection=\"%s\"",gdk_atom_name(selection_data->selection));
375 Gtk::TreeModel::Row row(*const_cast<LayerTreeStore*>(this)->get_iter(path));
379 Layer* layer(((Layer::Handle)row[model.layer]).get());
381 bool included(false);
383 //gtk_selection_data_set (selection_data, gdk_atom_intern("LAYER",false), 8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
385 std::vector<Layer*> layers;
386 // The following is a hack for multiple row DND
388 synfigapp::SelectionManager::LayerList bleh(get_canvas_interface()->get_selection_manager()->get_selected_layers());
391 selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
396 if(bleh.back().get()==layer)
398 layers.push_back(bleh.back().get());
403 layers.push_back(layer);
404 selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layers.front()), sizeof(void*)*layers.size());
412 LayerTreeStore::drag_data_delete_vfunc (const TreeModel::Path& /*path*/)
418 LayerTreeStore::row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const
420 //if(!const_cast<LayerTreeStore*>(this)->get_iter(dest)) return false;
422 //synfig::info("possible_drop -- data of type \"%s\"",selection_data.get_data_type());
423 //synfig::info("possible_drop -- data of target \"%s\"",gdk_atom_name(selection_data->target));
424 //synfig::info("possible_drop -- selection=\"%s\"",gdk_atom_name(selection_data->selection));
426 //Gtk::TreeModel::Row row(*get_iter(dest));
428 if(synfig::String(selection_data.get_data_type())=="LAYER" && (bool)true)
430 //Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
434 TreeModel::Path dest_parent(dest);
435 if(!dest_parent.up() || dest.get_depth()==1)
437 //row=(*get_iter(dest));
438 //dest_canvas=(Canvas::Handle)(row[model.canvas]);
441 else if((bool)const_cast<LayerTreeStore*>(this)->get_iter(dest_parent))
442 return (bool)(Canvas::Handle)(*const_cast<LayerTreeStore*>(this)->get_iter(dest_parent))[model.contained_canvas];
448 LayerTreeStore::drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)
451 //if(!dest_parent.up() || !get_iter(dest)) return false;
457 //synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
458 //synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
459 //synfig::info("Dropped selection=\"%s\"",gdk_atom_name(selection_data->selection));
460 synfigapp::Action::PassiveGrouper passive_grouper(canvas_interface()->get_instance().get(),_("Move Layers"));
462 // Save the selection data
463 synfigapp::SelectionManager::LayerList selected_layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
465 if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
467 Gtk::TreeModel::Row row;
468 Canvas::Handle dest_canvas;
470 int dest_layer_depth=dest.back();
472 TreeModel::Path dest_parent(dest);
473 if(!dest_parent.up() || !get_iter(dest_parent))
475 TreeModel::Path dest_(dest);
483 row=(*get_iter(dest_));
484 dest_canvas=(Canvas::Handle)(row[model.canvas]);
489 row=(*get_iter(dest_parent));
490 dest_canvas=row[model.contained_canvas];
495 Layer::Handle dest_layer(row[model.layer]);
497 if(synfig::String(selection_data.get_data_type())=="LAYER")for(unsigned int i=0;i<selection_data.get_length()/sizeof(void*);i++)
499 //synfig::info("dest_layer_depth=%d",dest_layer_depth);
501 Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
506 if(dest_canvas==src->get_canvas() && src->get_depth()<dest_layer_depth)
509 // In this case, we are just moving.
510 // if(dest_canvas==src->get_canvas())
512 //if(dest_canvas==src->get_canvas() && dest_layer_depth && dest_layer_depth>src->get_depth())
513 // dest_layer_depth--;
514 if(dest_canvas==src->get_canvas() && dest_layer_depth==src->get_depth())
517 synfigapp::Action::Handle action(synfigapp::Action::create("layer_move"));
518 action->set_param("canvas",dest_canvas);
519 action->set_param("canvas_interface",canvas_interface());
520 action->set_param("layer",src);
521 action->set_param("new_index",dest_layer_depth);
522 action->set_param("dest_canvas",dest_canvas);
523 if(canvas_interface()->get_instance()->perform_action(action))
527 passive_grouper.cancel();
532 /*else // In this case we need to remove and then add
535 synfigapp::Action::Handle action;
536 action=synfigapp::Action::create("layer_remove");
537 action->set_param("canvas",Canvas::Handle(src->get_canvas()));
538 if(!action->set_param("canvas_interface",App::get_instance(src->get_canvas())->find_canvas_interface(src->get_canvas())))
539 action->set_param("canvas_interface",canvas_interface());
540 action->set_param("layer",src);
541 if(!canvas_interface()->get_instance()->perform_action(action))
543 passive_grouper.cancel();
548 action=synfigapp::Action::create("layer_add");
549 action->set_param("canvas",dest_canvas);
550 action->set_param("canvas_interface",canvas_interface());
551 action->set_param("new",src);
552 if(!canvas_interface()->get_instance()->perform_action(action))
554 passive_grouper.cancel();
559 if(dest_layer_depth!=0)
561 action=synfigapp::Action::create("layer_move");
562 action->set_param("canvas",dest_canvas);
563 action->set_param("canvas_interface",canvas_interface());
564 action->set_param("layer",src);
565 action->set_param("new_index",dest_layer_depth);
566 if(!canvas_interface()->get_instance()->perform_action(action))
568 passive_grouper.cancel();
578 synfig::info("I supposedly moved %d layers",i);
580 // Reselect the previously selected layers
581 canvas_interface()->get_selection_manager()->set_selected_layers(selected_layer_list);
587 LayerTreeStore::rebuild()
589 //etl::clock timer;timer.reset();
591 //synfig::warning("---------rebuilding layer table---------");
592 // Save the selection data
593 synfigapp::SelectionManager::LayerList layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
595 // Clear out the current list
598 // Go ahead and and add all the layers
600 canvas_interface()->get_canvas()->rbegin(), canvas_interface()->get_canvas()->rend(),
601 sigc::mem_fun(*this, &studio::LayerTreeStore::on_layer_added)
604 // Reselect the previously selected layers
605 if(!layer_list.empty())
606 canvas_interface()->get_selection_manager()->set_selected_layers(layer_list);
608 //synfig::info("LayerTreeStore::rebuild() took %f seconds",float(timer()));
612 LayerTreeStore::refresh()
614 etl::clock timer;timer.reset();
616 Gtk::TreeModel::Children children_(children());
618 Gtk::TreeModel::Children::iterator iter;
620 if(!children_.empty())
621 for(iter = children_.begin(); iter && iter != children_.end(); ++iter)
623 Gtk::TreeRow row=*iter;
626 //synfig::info("LayerTreeStore::refresh() took %f seconds",float(timer()));
630 LayerTreeStore::refresh_row(Gtk::TreeModel::Row &row)
632 Layer::Handle layer=row[model.layer];
635 row[model.name] = layer->get_local_name();
636 if(layer->get_description().empty())
638 row[model.label] = layer->get_local_name();
639 row[model.tooltip] = Glib::ustring("Layer");
643 row[model.label] = layer->get_description();
644 row[model.tooltip] = layer->get_local_name();
649 if(layer->dynamic_param_list().count("z_depth"))
650 row[model.z_depth]=Time::begin();
651 // row_changed(get_path(row),row);
653 Gtk::TreeModel::Children children = row.children();
654 Gtk::TreeModel::Children::iterator iter;
656 if(!children.empty())
657 for(iter = children.begin(); iter && iter != children.end(); ++iter)
659 Gtk::TreeRow row=*iter;
666 LayerTreeStore::set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle)
668 //row[model.id] = handle->get_name();
669 //row[model.name] = handle->get_local_name();
670 /*if(handle->get_description().empty())
672 //row[model.label] = handle->get_local_name();
673 row[model.tooltip] = Glib::ustring("Layer");
677 //row[model.label] = handle->get_description();
678 row[model.tooltip] = handle->get_local_name();
681 //row[model.active] = handle->active();
682 row[model.layer] = handle;
683 //row[model.canvas] = handle->get_canvas();
684 //row[model.icon] = layer_icon;
686 synfig::Layer::ParamList paramlist=handle->get_param_list();
688 synfig::Layer::Vocab vocab=handle->get_param_vocab();
689 synfig::Layer::Vocab::iterator iter;
691 for(iter=vocab.begin();iter!=vocab.end();++iter)
693 if(iter->get_hidden())
695 if(handle->get_param(iter->get_name()).get_type()!=ValueBase::TYPE_CANVAS)
699 Canvas::Handle canvas;
700 canvas=handle->get_param(iter->get_name()).get(canvas);
704 Canvas::reverse_iterator iter;
705 row[model.contained_canvas]=canvas;
707 for(iter=canvas->rbegin();iter!=canvas->rend();++iter)
709 Gtk::TreeRow row_(*(prepend(row.children())));
710 set_row_layer(row_,*iter);
716 etl::handle<ValueNode> value_node;
717 if(handle.constant()->dynamic_param_list().count(iter->get_name()))
718 value_node=handle->dynamic_param_list()[iter->get_name()];
720 Gtk::TreeRow child_row = *(append(row.children()));
725 iter->get_local_name(),
726 paramlist[iter->get_name()],
735 LayerTreeStore::on_layer_added(synfig::Layer::Handle layer)
739 if(canvas_interface()->get_canvas()==layer->get_canvas())
745 Gtk::TreeModel::Children::iterator iter;
746 if(!find_canvas_row(layer->get_canvas(),iter))
751 row=*(prepend(iter->children()));
753 set_row_layer(row,layer);
757 LayerTreeStore::on_layer_removed(synfig::Layer::Handle handle)
759 Gtk::TreeModel::Children::iterator iter;
760 if(find_layer_row(handle,iter))
764 synfig::error("LayerTreeStore::on_layer_removed():Unable to find layer to be removed, forced to rebuild...");
770 LayerTreeStore::on_layer_inserted(synfig::Layer::Handle handle,int depth)
774 on_layer_added(handle);
778 Gtk::TreeModel::Children children_(children());
779 if(canvas_interface()->get_canvas()!=handle->get_canvas())
781 Gtk::TreeModel::Children::iterator iter;
782 if(!find_canvas_row(handle->get_canvas(),iter))
784 synfig::error("LayerTreeStore::on_layer_inserted():Unable to find canvas row, forced to rebuild...");
788 children_=iter->children();
791 Gtk::TreeModel::Children::iterator iter(children_.begin());
792 while(depth-- && iter)
795 if(!iter || iter==children_.end())
797 synfig::error("LayerTreeStore::on_layer_inserted():Unable to achieve desired depth, forced to rebuild...");
803 Gtk::TreeModel::Row row(*insert(iter));
804 set_row_layer(row,handle);
808 LayerTreeStore::on_layer_status_changed(synfig::Layer::Handle handle,bool /*x*/)
810 Gtk::TreeModel::Children::iterator iter;
811 if(find_layer_row(handle,iter))
812 (*iter)[model.layer]=handle;
815 synfig::warning("Couldn't find layer to be activated in layer list. Rebuilding index...");
821 LayerTreeStore::on_layer_lowered(synfig::Layer::Handle layer)
823 Gtk::TreeModel::Children::iterator iter, iter2;
824 if(find_layer_row(layer,iter))
826 // Save the selection data
827 //synfigapp::SelectionManager::LayerList layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
836 //Gtk::TreeModel::Row row(*iter);
837 Gtk::TreeModel::Row row2 = *iter2;
838 synfig::Layer::Handle layer2=row2[model.layer];
842 set_row_layer(row2,layer2);
850 LayerTreeStore::on_layer_raised(synfig::Layer::Handle layer)
852 Gtk::TreeModel::Children::iterator iter, iter2;
854 Gtk::TreeModel::Children children_(children());
856 if(find_layer_row_(layer, canvas_interface()->get_canvas(), children_, iter,iter2))
860 //Gtk::TreeModel::Row row = *iter;
861 Gtk::TreeModel::Row row2 = *iter2;
862 synfig::Layer::Handle layer2=row2[model.layer];
867 set_row_layer(row2,layer2);
877 LayerTreeStore::on_layer_moved(synfig::Layer::Handle layer,int depth, synfig::Canvas::Handle /*canvas*/)
879 on_layer_removed(layer);
880 on_layer_inserted(layer,depth);
884 LayerTreeStore::on_layer_param_changed(synfig::Layer::Handle handle,synfig::String param_name)
886 if(param_name=="z_depth")
888 Gtk::TreeModel::Children::iterator iter;
889 if(find_layer_row(handle,iter))
891 (*iter)[model.z_depth]=Time::begin();
896 Gtk::TreeModel::Children::iterator iter;
897 if(find_layer_row(handle,iter))
899 Gtk::TreeModel::Children children(iter->children());
901 for(iter = children.begin(); iter && iter != children.end(); ++iter)
903 if((Glib::ustring)(*iter)[model.param_name]==param_name)
905 Gtk::TreeRow row=*iter;
916 LayerTreeStore::on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc)
918 Gtk::TreeModel::Children::iterator iter;
919 if(find_layer_row(handle,iter))
921 Gtk::TreeRow row(*iter);
923 Layer::Handle layer(row[model.layer]);
927 //row[model.label]=layer->get_local_name();
928 row[model.tooltip]=Glib::ustring(_("Layer"));
931 //row[model.label]=layer->get_description();
932 row[model.tooltip]=layer->get_local_name();
941 LayerTreeStore::find_canvas_row_(synfig::Canvas::Handle canvas, synfig::Canvas::Handle parent, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter)
947 for(iter=layers.begin(); iter && iter != layers.end(); ++iter)
949 Gtk::TreeModel::Row row = *iter;
950 if(canvas==(synfig::Canvas::Handle)row[model.contained_canvas])
954 iter=children().end();
958 Gtk::TreeModel::Children::iterator iter2;
959 //Gtk::TreeModel::Children::iterator iter3;
961 for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
963 Gtk::TreeModel::Row row = *iter2;
966 if(row.children().empty())
969 Canvas::Handle sub_canvas((*row.children().begin())[model.canvas]);
973 if(find_canvas_row_(canvas,sub_canvas,iter2->children(),iter))
977 iter=children().end();
982 LayerTreeStore::find_canvas_row(synfig::Canvas::Handle canvas, Gtk::TreeModel::Children::iterator &iter)
984 return find_canvas_row_(canvas,canvas_interface()->get_canvas(),children(),iter);
989 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)
993 //if(layer->get_canvas()==canvas)
995 for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
997 Gtk::TreeModel::Row row = *iter;
998 if(layer==(synfig::Layer::Handle)row[model.layer])
1002 iter=children().end();
1006 Gtk::TreeModel::Children::iterator iter2;
1008 for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
1010 Gtk::TreeModel::Row row = *iter2;
1013 if(row.children().empty())
1016 Canvas::Handle canvas((*row.children().begin())[model.canvas]);
1020 if(find_layer_row_(layer,canvas,iter2->children(),iter,prev))
1024 iter=children().end();
1029 LayerTreeStore::find_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &iter)
1031 Gtk::TreeModel::Children::iterator prev;
1032 return find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev);
1036 LayerTreeStore::find_prev_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &prev)
1038 Gtk::TreeModel::Children::iterator iter;
1039 if(!find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev))
1041 if(iter==children().begin())