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(): Deleted");
103 LayerTreeStore::z_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs)
107 float diff((float)(*rhs)[model.z_depth]-(float)(*lhs)[model.z_depth]);
117 LayerTreeStore::index_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs)
121 return ((int)(*rhs)[model.index]-(int)(*lhs)[model.index]);
125 LayerTreeStore::search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring& x,const TreeModel::iterator& iter)
129 Glib::ustring substr(x.uppercase());
130 Glib::ustring label((*iter)[model.label]);
131 label=label.uppercase();
133 return label.find(substr)==Glib::ustring::npos;
137 Glib::RefPtr<LayerTreeStore>
138 LayerTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
140 return Glib::RefPtr<LayerTreeStore>(new LayerTreeStore(canvas_interface_));
144 LayerTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
146 if(column==model.index.index())
148 synfig::Layer::Handle layer((*iter)[model.layer]);
153 g_value_init(x.gobj(),x.value_type());
155 x.set(layer->get_depth());
157 g_value_init(value.gobj(),x.value_type());
158 g_value_copy(x.gobj(),value.gobj());
160 else if(column==model.z_depth.index())
162 synfig::Layer::Handle layer((*iter)[model.layer]);
166 Glib::Value<float> x;
167 g_value_init(x.gobj(),x.value_type());
169 x.set(layer->get_z_depth(canvas_interface()->get_time())*1.0001+layer->get_depth());
171 g_value_init(value.gobj(),x.value_type());
172 g_value_copy(x.gobj(),value.gobj());
174 else if(column==model.children_lock.index())
176 synfig::Layer::Handle layer((*iter)[model.layer]);
181 g_value_init(x.gobj(),x.value_type());
184 ValueBase v(layer->get_param("children_lock"));
185 if(v.same_type_as(bool()))
186 x.set(v.get(bool()));
188 g_value_init(value.gobj(),x.value_type());
189 g_value_copy(x.gobj(),value.gobj());
191 else if(column==model.label.index())
193 synfig::Layer::Handle layer((*iter)[model.layer]);
197 Glib::Value<Glib::ustring> x;
198 g_value_init(x.gobj(),x.value_type());
201 if(!layer->get_description().empty())
202 x.set(layer->get_description());
204 x.set(layer->get_local_name());
206 g_value_init(value.gobj(),x.value_type());
207 //g_value_copy(x.gobj(),value.gobj());
210 else if(column==model.tooltip.index())
212 synfig::Layer::Handle layer((*iter)[model.layer]);
216 Glib::Value<Glib::ustring> x;
217 g_value_init(x.gobj(),x.value_type());
220 x.set(layer->get_local_name());
222 g_value_init(value.gobj(),x.value_type());
223 //g_value_copy(x.gobj(),value.gobj());
226 else if(column==model.canvas.index())
228 synfig::Layer::Handle layer((*iter)[model.layer]);
232 Glib::Value<Canvas::Handle> x;
233 g_value_init(x.gobj(),x.value_type());
236 x.set(layer->get_canvas());
238 g_value_init(value.gobj(),x.value_type());
239 //g_value_copy(x.gobj(),value.gobj());
242 else if(column==model.active.index())
244 synfig::Layer::Handle layer((*iter)[model.layer]);
249 g_value_init(x.gobj(),x.value_type());
251 x.set(layer->active());
253 g_value_init(value.gobj(),x.value_type());
254 g_value_copy(x.gobj(),value.gobj());
256 else if(column==model.icon.index())
258 synfig::Layer::Handle layer((*iter)[model.layer]);
261 Glib::Value<Glib::RefPtr<Gdk::Pixbuf> > x;
262 g_value_init(x.gobj(),x.value_type());
265 x.set(get_tree_pixbuf_layer(layer->get_name()));
267 g_value_init(value.gobj(),x.value_type());
268 g_value_copy(x.gobj(),value.gobj());
271 Gtk::TreeStore::get_value_vfunc(iter,column,value);
275 LayerTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
277 //if(!iterator_sane(row))
280 if(column>=get_n_columns_vfunc())
282 g_warning("LayerTreeStore::set_value_impl: Bad column (%d)",column);
286 if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
288 g_warning("LayerTreeStore::set_value_impl: Bad value type");
294 if(column==model.label.index())
296 Glib::Value<Glib::ustring> x;
297 g_value_init(x.gobj(),model.label.type());
298 g_value_copy(value.gobj(),x.gobj());
300 synfig::Layer::Handle layer((*iter)[model.layer]);
303 synfig::String new_desc(x.get());
305 if(new_desc==layer->get_local_name())
306 new_desc=synfig::String();
308 if(new_desc==layer->get_description())
311 synfigapp::Action::Handle action(synfigapp::Action::create("layer_set_desc"));
316 action->set_param("canvas",canvas_interface()->get_canvas());
317 action->set_param("canvas_interface",canvas_interface());
318 action->set_param("layer",layer);
319 action->set_param("new_description",synfig::String(x.get()));
321 canvas_interface()->get_instance()->perform_action(action);
324 else if(column==model.active.index())
326 synfig::Layer::Handle layer((*iter)[model.layer]);
331 g_value_init(x.gobj(),model.active.type());
332 g_value_copy(value.gobj(),x.gobj());
334 synfigapp::Action::Handle action(synfigapp::Action::create("layer_activate"));
339 action->set_param("canvas",canvas_interface()->get_canvas());
340 action->set_param("canvas_interface",canvas_interface());
341 action->set_param("layer",layer);
342 action->set_param("new_status",bool(x.get()));
344 canvas_interface()->get_instance()->perform_action(action);
348 Gtk::TreeStore::set_value_impl(iter,column, value);
351 catch(std::exception x)
361 LayerTreeStore::row_draggable_vfunc (const TreeModel::Path& /*path*/)const
363 //if(!get_iter(path)) return false;
364 // Gtk::TreeModel::Row row(*get_iter(path));
367 // return (bool)true;
371 LayerTreeStore::drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const
373 if(!const_cast<LayerTreeStore*>(this)->get_iter(path)) return false;
374 //synfig::info("Dragged data of type \"%s\"",selection_data.get_data_type());
375 //synfig::info("Dragged data of target \"%s\"",gdk_atom_name(selection_data->target));
376 //synfig::info("Dragged selection=\"%s\"",gdk_atom_name(selection_data->selection));
378 Gtk::TreeModel::Row row(*const_cast<LayerTreeStore*>(this)->get_iter(path));
382 Layer* layer(((Layer::Handle)row[model.layer]).get());
384 bool included(false);
386 //gtk_selection_data_set (selection_data, gdk_atom_intern("LAYER",false), 8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
388 std::vector<Layer*> layers;
389 // The following is a hack for multiple row DND
391 synfigapp::SelectionManager::LayerList bleh(get_canvas_interface()->get_selection_manager()->get_selected_layers());
394 selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
399 if(bleh.back().get()==layer)
401 layers.push_back(bleh.back().get());
406 layers.push_back(layer);
407 selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layers.front()), sizeof(void*)*layers.size());
415 LayerTreeStore::drag_data_delete_vfunc (const TreeModel::Path& /*path*/)
421 LayerTreeStore::row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const
423 //if(!const_cast<LayerTreeStore*>(this)->get_iter(dest)) return false;
425 //synfig::info("possible_drop -- data of type \"%s\"",selection_data.get_data_type());
426 //synfig::info("possible_drop -- data of target \"%s\"",gdk_atom_name(selection_data->target));
427 //synfig::info("possible_drop -- selection=\"%s\"",gdk_atom_name(selection_data->selection));
429 //Gtk::TreeModel::Row row(*get_iter(dest));
431 if(synfig::String(selection_data.get_data_type())=="LAYER" && (bool)true)
433 //Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
437 TreeModel::Path dest_parent(dest);
438 if(!dest_parent.up() || dest.get_depth()==1)
440 //row=(*get_iter(dest));
441 //dest_canvas=(Canvas::Handle)(row[model.canvas]);
444 else if((bool)const_cast<LayerTreeStore*>(this)->get_iter(dest_parent))
445 return (bool)(Canvas::Handle)(*const_cast<LayerTreeStore*>(this)->get_iter(dest_parent))[model.contained_canvas];
451 LayerTreeStore::drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)
454 //if(!dest_parent.up() || !get_iter(dest)) return false;
460 //synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
461 //synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
462 //synfig::info("Dropped selection=\"%s\"",gdk_atom_name(selection_data->selection));
463 synfigapp::Action::PassiveGrouper passive_grouper(canvas_interface()->get_instance().get(),_("Move Layers"));
465 // Save the selection data
466 synfigapp::SelectionManager::LayerList selected_layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
468 if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
470 Gtk::TreeModel::Row row;
471 Canvas::Handle dest_canvas;
473 int dest_layer_depth=dest.back();
475 TreeModel::Path dest_parent(dest);
476 if(!dest_parent.up() || !get_iter(dest_parent))
478 TreeModel::Path dest_(dest);
486 row=(*get_iter(dest_));
487 dest_canvas=(Canvas::Handle)(row[model.canvas]);
492 row=(*get_iter(dest_parent));
493 dest_canvas=row[model.contained_canvas];
498 Layer::Handle dest_layer(row[model.layer]);
500 if(synfig::String(selection_data.get_data_type())=="LAYER")for(unsigned int i=0;i<selection_data.get_length()/sizeof(void*);i++)
502 //synfig::info("dest_layer_depth=%d",dest_layer_depth);
504 Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
509 if(dest_canvas==src->get_canvas() && src->get_depth()<dest_layer_depth)
512 // In this case, we are just moving.
513 // if(dest_canvas==src->get_canvas())
515 //if(dest_canvas==src->get_canvas() && dest_layer_depth && dest_layer_depth>src->get_depth())
516 // dest_layer_depth--;
517 if(dest_canvas==src->get_canvas() && dest_layer_depth==src->get_depth())
520 synfigapp::Action::Handle action(synfigapp::Action::create("layer_move"));
521 action->set_param("canvas",dest_canvas);
522 action->set_param("canvas_interface",canvas_interface());
523 action->set_param("layer",src);
524 action->set_param("new_index",dest_layer_depth);
525 action->set_param("dest_canvas",dest_canvas);
526 if(canvas_interface()->get_instance()->perform_action(action))
530 passive_grouper.cancel();
535 /*else // In this case we need to remove and then add
538 synfigapp::Action::Handle action;
539 action=synfigapp::Action::create("layer_remove");
540 action->set_param("canvas",Canvas::Handle(src->get_canvas()));
541 if(!action->set_param("canvas_interface",App::get_instance(src->get_canvas())->find_canvas_interface(src->get_canvas())))
542 action->set_param("canvas_interface",canvas_interface());
543 action->set_param("layer",src);
544 if(!canvas_interface()->get_instance()->perform_action(action))
546 passive_grouper.cancel();
551 action=synfigapp::Action::create("layer_add");
552 action->set_param("canvas",dest_canvas);
553 action->set_param("canvas_interface",canvas_interface());
554 action->set_param("new",src);
555 if(!canvas_interface()->get_instance()->perform_action(action))
557 passive_grouper.cancel();
562 if(dest_layer_depth!=0)
564 action=synfigapp::Action::create("layer_move");
565 action->set_param("canvas",dest_canvas);
566 action->set_param("canvas_interface",canvas_interface());
567 action->set_param("layer",src);
568 action->set_param("new_index",dest_layer_depth);
569 if(!canvas_interface()->get_instance()->perform_action(action))
571 passive_grouper.cancel();
581 synfig::info("I suposidly moved %d layers",i);
583 // Reselect the previously selected layers
584 canvas_interface()->get_selection_manager()->set_selected_layers(selected_layer_list);
590 LayerTreeStore::rebuild()
592 //etl::clock timer;timer.reset();
594 //synfig::warning("---------rebuilding layer table---------");
595 // Save the selection data
596 synfigapp::SelectionManager::LayerList layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
598 // Clear out the current list
601 // Go ahead and and add all the layers
603 canvas_interface()->get_canvas()->rbegin(), canvas_interface()->get_canvas()->rend(),
604 sigc::mem_fun(*this, &studio::LayerTreeStore::on_layer_added)
607 // Reselect the previously selected layers
608 if(!layer_list.empty())
609 canvas_interface()->get_selection_manager()->set_selected_layers(layer_list);
611 //synfig::info("LayerTreeStore::rebuild() took %f seconds",float(timer()));
615 LayerTreeStore::refresh()
617 etl::clock timer;timer.reset();
619 Gtk::TreeModel::Children children_(children());
621 Gtk::TreeModel::Children::iterator iter;
623 if(!children_.empty())
624 for(iter = children_.begin(); iter && iter != children_.end(); ++iter)
626 Gtk::TreeRow row=*iter;
629 //synfig::info("LayerTreeStore::refresh() took %f seconds",float(timer()));
633 LayerTreeStore::refresh_row(Gtk::TreeModel::Row &row)
635 Layer::Handle layer=row[model.layer];
638 row[model.name] = layer->get_local_name();
639 if(layer->get_description().empty())
641 row[model.label] = layer->get_local_name();
642 row[model.tooltip] = Glib::ustring("Layer");
646 row[model.label] = layer->get_description();
647 row[model.tooltip] = layer->get_local_name();
652 if(layer->dynamic_param_list().count("z_depth"))
653 row[model.z_depth]=Time::begin();
654 // row_changed(get_path(row),row);
656 Gtk::TreeModel::Children children = row.children();
657 Gtk::TreeModel::Children::iterator iter;
659 if(!children.empty())
660 for(iter = children.begin(); iter && iter != children.end(); ++iter)
662 Gtk::TreeRow row=*iter;
669 LayerTreeStore::set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle)
671 //row[model.id] = handle->get_name();
672 //row[model.name] = handle->get_local_name();
673 /*if(handle->get_description().empty())
675 //row[model.label] = handle->get_local_name();
676 row[model.tooltip] = Glib::ustring("Layer");
680 //row[model.label] = handle->get_description();
681 row[model.tooltip] = handle->get_local_name();
684 //row[model.active] = handle->active();
685 row[model.layer] = handle;
686 //row[model.canvas] = handle->get_canvas();
687 //row[model.icon] = layer_icon;
689 synfig::Layer::ParamList paramlist=handle->get_param_list();
691 synfig::Layer::Vocab vocab=handle->get_param_vocab();
692 synfig::Layer::Vocab::iterator iter;
694 for(iter=vocab.begin();iter!=vocab.end();++iter)
696 if(iter->get_hidden())
698 if(handle->get_param(iter->get_name()).get_type()!=ValueBase::TYPE_CANVAS)
702 Canvas::Handle canvas;
703 canvas=handle->get_param(iter->get_name()).get(canvas);
707 Canvas::reverse_iterator iter;
708 row[model.contained_canvas]=canvas;
710 for(iter=canvas->rbegin();iter!=canvas->rend();++iter)
712 Gtk::TreeRow row_(*(prepend(row.children())));
713 set_row_layer(row_,*iter);
719 etl::handle<ValueNode> value_node;
720 if(handle.constant()->dynamic_param_list().count(iter->get_name()))
721 value_node=handle->dynamic_param_list()[iter->get_name()];
723 Gtk::TreeRow child_row = *(append(row.children()));
728 iter->get_local_name(),
729 paramlist[iter->get_name()],
738 LayerTreeStore::on_layer_added(synfig::Layer::Handle layer)
742 if(canvas_interface()->get_canvas()==layer->get_canvas())
748 Gtk::TreeModel::Children::iterator iter;
749 if(!find_canvas_row(layer->get_canvas(),iter))
754 row=*(prepend(iter->children()));
756 set_row_layer(row,layer);
760 LayerTreeStore::on_layer_removed(synfig::Layer::Handle handle)
762 Gtk::TreeModel::Children::iterator iter;
763 if(find_layer_row(handle,iter))
767 synfig::error("LayerTreeStore::on_layer_removed():Unable to find layer to be removed, forced to rebuild...");
773 LayerTreeStore::on_layer_inserted(synfig::Layer::Handle handle,int depth)
777 on_layer_added(handle);
781 Gtk::TreeModel::Children children_(children());
782 if(canvas_interface()->get_canvas()!=handle->get_canvas())
784 Gtk::TreeModel::Children::iterator iter;
785 if(!find_canvas_row(handle->get_canvas(),iter))
787 synfig::error("LayerTreeStore::on_layer_inserted():Unable to find canvas row, forced to rebuild...");
791 children_=iter->children();
794 Gtk::TreeModel::Children::iterator iter(children_.begin());
795 while(depth-- && iter)
798 if(!iter || iter==children_.end())
800 synfig::error("LayerTreeStore::on_layer_inserted():Unable to achieve desired depth, forced to rebuild...");
806 Gtk::TreeModel::Row row(*insert(iter));
807 set_row_layer(row,handle);
811 LayerTreeStore::on_layer_status_changed(synfig::Layer::Handle handle,bool /*x*/)
813 Gtk::TreeModel::Children::iterator iter;
814 if(find_layer_row(handle,iter))
815 (*iter)[model.layer]=handle;
818 synfig::warning("Couldn't find layer to be activated in layer list. Rebuilding index...");
824 LayerTreeStore::on_layer_lowered(synfig::Layer::Handle layer)
826 Gtk::TreeModel::Children::iterator iter, iter2;
827 if(find_layer_row(layer,iter))
829 // Save the selection data
830 //synfigapp::SelectionManager::LayerList layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
839 //Gtk::TreeModel::Row row(*iter);
840 Gtk::TreeModel::Row row2 = *iter2;
841 synfig::Layer::Handle layer2=row2[model.layer];
845 set_row_layer(row2,layer2);
853 LayerTreeStore::on_layer_raised(synfig::Layer::Handle layer)
855 Gtk::TreeModel::Children::iterator iter, iter2;
857 Gtk::TreeModel::Children children_(children());
859 if(find_layer_row_(layer, canvas_interface()->get_canvas(), children_, iter,iter2))
863 //Gtk::TreeModel::Row row = *iter;
864 Gtk::TreeModel::Row row2 = *iter2;
865 synfig::Layer::Handle layer2=row2[model.layer];
870 set_row_layer(row2,layer2);
880 LayerTreeStore::on_layer_moved(synfig::Layer::Handle layer,int depth, synfig::Canvas::Handle /*canvas*/)
882 on_layer_removed(layer);
883 on_layer_inserted(layer,depth);
887 LayerTreeStore::on_layer_param_changed(synfig::Layer::Handle handle,synfig::String param_name)
889 if(param_name=="z_depth")
891 Gtk::TreeModel::Children::iterator iter;
892 if(find_layer_row(handle,iter))
894 (*iter)[model.z_depth]=Time::begin();
900 Gtk::TreeModel::Children::iterator iter;
901 if(find_layer_row(handle,iter))
904 Gtk::TreeModel::Children children(iter->children());
906 for(iter = children.begin(); iter && iter != children.end(); ++iter)
908 if((Glib::ustring)(*iter)[model.param_name]==param_name)
911 Gtk::TreeRow row=*iter;
923 LayerTreeStore::on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc)
925 Gtk::TreeModel::Children::iterator iter;
926 if(find_layer_row(handle,iter))
928 Gtk::TreeRow row(*iter);
930 Layer::Handle layer(row[model.layer]);
934 //row[model.label]=layer->get_local_name();
935 row[model.tooltip]=Glib::ustring(_("Layer"));
938 //row[model.label]=layer->get_description();
939 row[model.tooltip]=layer->get_local_name();
948 LayerTreeStore::find_canvas_row_(synfig::Canvas::Handle canvas, synfig::Canvas::Handle parent, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter)
954 for(iter=layers.begin(); iter && iter != layers.end(); ++iter)
956 Gtk::TreeModel::Row row = *iter;
957 if(canvas==(synfig::Canvas::Handle)row[model.contained_canvas])
961 iter=children().end();
965 Gtk::TreeModel::Children::iterator iter2;
966 //Gtk::TreeModel::Children::iterator iter3;
968 for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
970 Gtk::TreeModel::Row row = *iter2;
973 if(row.children().empty())
976 Canvas::Handle sub_canvas((*row.children().begin())[model.canvas]);
980 if(find_canvas_row_(canvas,sub_canvas,iter2->children(),iter))
984 iter=children().end();
989 LayerTreeStore::find_canvas_row(synfig::Canvas::Handle canvas, Gtk::TreeModel::Children::iterator &iter)
991 return find_canvas_row_(canvas,canvas_interface()->get_canvas(),children(),iter);
996 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)
1000 //if(layer->get_canvas()==canvas)
1002 for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
1004 Gtk::TreeModel::Row row = *iter;
1005 if(layer==(synfig::Layer::Handle)row[model.layer])
1009 iter=children().end();
1014 Gtk::TreeModel::Children::iterator iter2;
1016 for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
1018 Gtk::TreeModel::Row row = *iter2;
1021 if(row.children().empty())
1024 Canvas::Handle canvas((*row.children().begin())[model.canvas]);
1028 if(find_layer_row_(layer,canvas,iter2->children(),iter,prev))
1032 iter=children().end();
1037 LayerTreeStore::find_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &iter)
1039 Gtk::TreeModel::Children::iterator prev;
1040 return find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev);
1044 LayerTreeStore::find_prev_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &prev)
1046 Gtk::TreeModel::Children::iterator iter;
1047 if(!find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev))
1049 if(iter==children().begin())