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 if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
101 synfig::info("LayerTreeStore::~LayerTreeStore(): Deleted");
105 LayerTreeStore::z_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs)
109 float diff((float)(*rhs)[model.z_depth]-(float)(*lhs)[model.z_depth]);
119 LayerTreeStore::index_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs)
123 return ((int)(*rhs)[model.index]-(int)(*lhs)[model.index]);
127 LayerTreeStore::search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring& x,const TreeModel::iterator& iter)
131 Glib::ustring substr(x.uppercase());
132 Glib::ustring label((*iter)[model.label]);
133 label=label.uppercase();
135 return label.find(substr)==Glib::ustring::npos;
139 Glib::RefPtr<LayerTreeStore>
140 LayerTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
142 return Glib::RefPtr<LayerTreeStore>(new LayerTreeStore(canvas_interface_));
146 LayerTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
148 if(column==model.index.index())
150 synfig::Layer::Handle layer((*iter)[model.layer]);
155 g_value_init(x.gobj(),x.value_type());
157 x.set(layer->get_depth());
159 g_value_init(value.gobj(),x.value_type());
160 g_value_copy(x.gobj(),value.gobj());
162 else 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());
176 else if(column==model.children_lock.index())
178 synfig::Layer::Handle layer((*iter)[model.layer]);
183 g_value_init(x.gobj(),x.value_type());
186 ValueBase v(layer->get_param("children_lock"));
187 if(v.same_type_as(bool()))
188 x.set(v.get(bool()));
190 g_value_init(value.gobj(),x.value_type());
191 g_value_copy(x.gobj(),value.gobj());
193 else if(column==model.label.index())
195 synfig::Layer::Handle layer((*iter)[model.layer]);
199 Glib::Value<Glib::ustring> x;
200 g_value_init(x.gobj(),x.value_type());
202 x.set(layer->get_non_empty_description());
204 g_value_init(value.gobj(),x.value_type());
205 //g_value_copy(x.gobj(),value.gobj());
208 else if(column==model.tooltip.index())
210 synfig::Layer::Handle layer((*iter)[model.layer]);
214 Glib::Value<Glib::ustring> x;
215 g_value_init(x.gobj(),x.value_type());
218 x.set(layer->get_local_name());
220 g_value_init(value.gobj(),x.value_type());
221 //g_value_copy(x.gobj(),value.gobj());
224 else if(column==model.canvas.index())
226 synfig::Layer::Handle layer((*iter)[model.layer]);
230 Glib::Value<Canvas::Handle> x;
231 g_value_init(x.gobj(),x.value_type());
234 x.set(layer->get_canvas());
236 g_value_init(value.gobj(),x.value_type());
237 //g_value_copy(x.gobj(),value.gobj());
240 else if(column==model.active.index())
242 synfig::Layer::Handle layer((*iter)[model.layer]);
247 g_value_init(x.gobj(),x.value_type());
249 x.set(layer->active());
251 g_value_init(value.gobj(),x.value_type());
252 g_value_copy(x.gobj(),value.gobj());
254 else if(column==model.icon.index())
256 synfig::Layer::Handle layer((*iter)[model.layer]);
259 Glib::Value<Glib::RefPtr<Gdk::Pixbuf> > x;
260 g_value_init(x.gobj(),x.value_type());
263 x.set(get_tree_pixbuf_layer(layer->get_name()));
265 g_value_init(value.gobj(),x.value_type());
266 g_value_copy(x.gobj(),value.gobj());
269 Gtk::TreeStore::get_value_vfunc(iter,column,value);
273 LayerTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
275 //if(!iterator_sane(row))
278 if(column>=get_n_columns_vfunc())
280 g_warning("LayerTreeStore::set_value_impl: Bad column (%d)",column);
284 if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
286 g_warning("LayerTreeStore::set_value_impl: Bad value type");
292 if(column==model.label.index())
294 Glib::Value<Glib::ustring> x;
295 g_value_init(x.gobj(),model.label.type());
296 g_value_copy(value.gobj(),x.gobj());
298 synfig::Layer::Handle layer((*iter)[model.layer]);
301 synfig::String new_desc(x.get());
303 if(new_desc==layer->get_local_name())
304 new_desc=synfig::String();
306 if(new_desc==layer->get_description())
309 synfigapp::Action::Handle action(synfigapp::Action::create("layer_set_desc"));
314 action->set_param("canvas",canvas_interface()->get_canvas());
315 action->set_param("canvas_interface",canvas_interface());
316 action->set_param("layer",layer);
317 action->set_param("new_description",synfig::String(x.get()));
319 canvas_interface()->get_instance()->perform_action(action);
322 else if(column==model.active.index())
324 synfig::Layer::Handle layer((*iter)[model.layer]);
329 g_value_init(x.gobj(),model.active.type());
330 g_value_copy(value.gobj(),x.gobj());
332 synfigapp::Action::Handle action(synfigapp::Action::create("layer_activate"));
337 action->set_param("canvas",canvas_interface()->get_canvas());
338 action->set_param("canvas_interface",canvas_interface());
339 action->set_param("layer",layer);
340 action->set_param("new_status",bool(x.get()));
342 canvas_interface()->get_instance()->perform_action(action);
346 Gtk::TreeStore::set_value_impl(iter,column, value);
349 catch(std::exception x)
359 LayerTreeStore::row_draggable_vfunc (const TreeModel::Path& /*path*/)const
361 //if(!get_iter(path)) return false;
362 // Gtk::TreeModel::Row row(*get_iter(path));
365 // return (bool)true;
369 LayerTreeStore::drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const
371 if(!const_cast<LayerTreeStore*>(this)->get_iter(path)) return false;
372 //synfig::info("Dragged data of type \"%s\"",selection_data.get_data_type());
373 //synfig::info("Dragged data of target \"%s\"",gdk_atom_name(selection_data->target));
374 //synfig::info("Dragged selection=\"%s\"",gdk_atom_name(selection_data->selection));
376 Gtk::TreeModel::Row row(*const_cast<LayerTreeStore*>(this)->get_iter(path));
380 Layer* layer(((Layer::Handle)row[model.layer]).get());
382 bool included(false);
384 //gtk_selection_data_set (selection_data, gdk_atom_intern("LAYER",false), 8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
386 std::vector<Layer*> layers;
387 // The following is a hack for multiple row DND
389 synfigapp::SelectionManager::LayerList bleh(get_canvas_interface()->get_selection_manager()->get_selected_layers());
392 selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
397 if(bleh.back().get()==layer)
399 layers.push_back(bleh.back().get());
404 layers.push_back(layer);
405 selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layers.front()), sizeof(void*)*layers.size());
413 LayerTreeStore::drag_data_delete_vfunc (const TreeModel::Path& /*path*/)
419 LayerTreeStore::row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const
421 //if(!const_cast<LayerTreeStore*>(this)->get_iter(dest)) return false;
423 //synfig::info("possible_drop -- data of type \"%s\"",selection_data.get_data_type());
424 //synfig::info("possible_drop -- data of target \"%s\"",gdk_atom_name(selection_data->target));
425 //synfig::info("possible_drop -- selection=\"%s\"",gdk_atom_name(selection_data->selection));
427 //Gtk::TreeModel::Row row(*get_iter(dest));
429 if(synfig::String(selection_data.get_data_type())=="LAYER" && (bool)true)
431 //Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
435 TreeModel::Path dest_parent(dest);
436 if(!dest_parent.up() || dest.get_depth()==1)
438 //row=(*get_iter(dest));
439 //dest_canvas=(Canvas::Handle)(row[model.canvas]);
442 else if((bool)const_cast<LayerTreeStore*>(this)->get_iter(dest_parent))
443 return (bool)(Canvas::Handle)(*const_cast<LayerTreeStore*>(this)->get_iter(dest_parent))[model.contained_canvas];
449 LayerTreeStore::drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)
452 //if(!dest_parent.up() || !get_iter(dest)) return false;
458 //synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
459 //synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
460 //synfig::info("Dropped selection=\"%s\"",gdk_atom_name(selection_data->selection));
461 synfigapp::Action::PassiveGrouper passive_grouper(canvas_interface()->get_instance().get(),_("Move Layers"));
463 // Save the selection data
464 synfigapp::SelectionManager::LayerList selected_layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
466 if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
468 Gtk::TreeModel::Row row;
469 Canvas::Handle dest_canvas;
471 int dest_layer_depth=dest.back();
473 TreeModel::Path dest_parent(dest);
474 if(!dest_parent.up() || !get_iter(dest_parent))
476 TreeModel::Path dest_(dest);
484 row=(*get_iter(dest_));
485 dest_canvas=(Canvas::Handle)(row[model.canvas]);
490 row=(*get_iter(dest_parent));
491 dest_canvas=row[model.contained_canvas];
496 Layer::Handle dest_layer(row[model.layer]);
498 if(synfig::String(selection_data.get_data_type())=="LAYER")for(unsigned int i=0;i<selection_data.get_length()/sizeof(void*);i++)
500 //synfig::info("dest_layer_depth=%d",dest_layer_depth);
502 Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
507 if(dest_canvas==src->get_canvas() && src->get_depth()<dest_layer_depth)
510 // In this case, we are just moving.
511 // if(dest_canvas==src->get_canvas())
513 //if(dest_canvas==src->get_canvas() && dest_layer_depth && dest_layer_depth>src->get_depth())
514 // dest_layer_depth--;
515 if(dest_canvas==src->get_canvas() && dest_layer_depth==src->get_depth())
518 synfigapp::Action::Handle action(synfigapp::Action::create("layer_move"));
519 action->set_param("canvas",dest_canvas);
520 action->set_param("canvas_interface",canvas_interface());
521 action->set_param("layer",src);
522 action->set_param("new_index",dest_layer_depth);
523 action->set_param("dest_canvas",dest_canvas);
524 if(canvas_interface()->get_instance()->perform_action(action))
528 passive_grouper.cancel();
533 /*else // In this case we need to remove and then add
536 synfigapp::Action::Handle action;
537 action=synfigapp::Action::create("layer_remove");
538 action->set_param("canvas",Canvas::Handle(src->get_canvas()));
539 if(!action->set_param("canvas_interface",App::get_instance(src->get_canvas())->find_canvas_interface(src->get_canvas())))
540 action->set_param("canvas_interface",canvas_interface());
541 action->set_param("layer",src);
542 if(!canvas_interface()->get_instance()->perform_action(action))
544 passive_grouper.cancel();
549 action=synfigapp::Action::create("layer_add");
550 action->set_param("canvas",dest_canvas);
551 action->set_param("canvas_interface",canvas_interface());
552 action->set_param("new",src);
553 if(!canvas_interface()->get_instance()->perform_action(action))
555 passive_grouper.cancel();
560 if(dest_layer_depth!=0)
562 action=synfigapp::Action::create("layer_move");
563 action->set_param("canvas",dest_canvas);
564 action->set_param("canvas_interface",canvas_interface());
565 action->set_param("layer",src);
566 action->set_param("new_index",dest_layer_depth);
567 if(!canvas_interface()->get_instance()->perform_action(action))
569 passive_grouper.cancel();
579 synfig::info("I supposedly moved %d layers",i);
581 // Reselect the previously selected layers
582 canvas_interface()->get_selection_manager()->set_selected_layers(selected_layer_list);
588 LayerTreeStore::rebuild()
590 //etl::clock timer;timer.reset();
592 //synfig::warning("---------rebuilding layer table---------");
593 // Save the selection data
594 synfigapp::SelectionManager::LayerList layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
596 // Clear out the current list
599 // Go ahead and and add all the layers
601 canvas_interface()->get_canvas()->rbegin(), canvas_interface()->get_canvas()->rend(),
602 sigc::mem_fun(*this, &studio::LayerTreeStore::on_layer_added)
605 // Reselect the previously selected layers
606 if(!layer_list.empty())
607 canvas_interface()->get_selection_manager()->set_selected_layers(layer_list);
609 //synfig::info("LayerTreeStore::rebuild() took %f seconds",float(timer()));
613 LayerTreeStore::refresh()
615 etl::clock timer;timer.reset();
617 Gtk::TreeModel::Children children_(children());
619 Gtk::TreeModel::Children::iterator iter;
621 if(!children_.empty())
622 for(iter = children_.begin(); iter && iter != children_.end(); ++iter)
624 Gtk::TreeRow row=*iter;
627 //synfig::info("LayerTreeStore::refresh() took %f seconds",float(timer()));
631 LayerTreeStore::refresh_row(Gtk::TreeModel::Row &row)
633 Layer::Handle layer=row[model.layer];
636 row[model.name] = layer->get_local_name();
637 if(layer->get_description().empty())
639 row[model.label] = layer->get_local_name();
640 row[model.tooltip] = Glib::ustring("Layer");
644 row[model.label] = layer->get_description();
645 row[model.tooltip] = layer->get_local_name();
650 if(layer->dynamic_param_list().count("z_depth"))
651 row[model.z_depth]=Time::begin();
652 // row_changed(get_path(row),row);
654 Gtk::TreeModel::Children children = row.children();
655 Gtk::TreeModel::Children::iterator iter;
657 if(!children.empty())
658 for(iter = children.begin(); iter && iter != children.end(); ++iter)
660 Gtk::TreeRow row=*iter;
667 LayerTreeStore::set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle)
669 //row[model.id] = handle->get_name();
670 //row[model.name] = handle->get_local_name();
671 /*if(handle->get_description().empty())
673 //row[model.label] = handle->get_local_name();
674 row[model.tooltip] = Glib::ustring("Layer");
678 //row[model.label] = handle->get_description();
679 row[model.tooltip] = handle->get_local_name();
682 //row[model.active] = handle->active();
683 row[model.layer] = handle;
684 //row[model.canvas] = handle->get_canvas();
685 //row[model.icon] = layer_icon;
687 synfig::Layer::ParamList paramlist=handle->get_param_list();
689 synfig::Layer::Vocab vocab=handle->get_param_vocab();
690 synfig::Layer::Vocab::iterator iter;
692 for(iter=vocab.begin();iter!=vocab.end();++iter)
694 if(iter->get_hidden())
696 if(handle->get_param(iter->get_name()).get_type()!=ValueBase::TYPE_CANVAS)
700 Canvas::Handle canvas;
701 canvas=handle->get_param(iter->get_name()).get(canvas);
705 Canvas::reverse_iterator iter;
706 row[model.contained_canvas]=canvas;
708 for(iter=canvas->rbegin();iter!=canvas->rend();++iter)
710 Gtk::TreeRow row_(*(prepend(row.children())));
711 set_row_layer(row_,*iter);
717 etl::handle<ValueNode> value_node;
718 if(handle.constant()->dynamic_param_list().count(iter->get_name()))
719 value_node=handle->dynamic_param_list()[iter->get_name()];
721 Gtk::TreeRow child_row = *(append(row.children()));
726 iter->get_local_name(),
727 paramlist[iter->get_name()],
736 LayerTreeStore::on_layer_added(synfig::Layer::Handle layer)
740 if(canvas_interface()->get_canvas()==layer->get_canvas())
746 Gtk::TreeModel::Children::iterator iter;
747 if(!find_canvas_row(layer->get_canvas(),iter))
752 row=*(prepend(iter->children()));
754 set_row_layer(row,layer);
758 LayerTreeStore::on_layer_removed(synfig::Layer::Handle handle)
760 Gtk::TreeModel::Children::iterator iter;
761 if(find_layer_row(handle,iter))
765 synfig::error("LayerTreeStore::on_layer_removed():Unable to find layer to be removed, forced to rebuild...");
771 LayerTreeStore::on_layer_inserted(synfig::Layer::Handle handle,int depth)
775 on_layer_added(handle);
779 Gtk::TreeModel::Children children_(children());
780 if(canvas_interface()->get_canvas()!=handle->get_canvas())
782 Gtk::TreeModel::Children::iterator iter;
783 if(!find_canvas_row(handle->get_canvas(),iter))
785 synfig::error("LayerTreeStore::on_layer_inserted():Unable to find canvas row, forced to rebuild...");
789 children_=iter->children();
792 Gtk::TreeModel::Children::iterator iter(children_.begin());
793 while(depth-- && iter)
796 if(!iter || iter==children_.end())
798 synfig::error("LayerTreeStore::on_layer_inserted():Unable to achieve desired depth, forced to rebuild...");
804 Gtk::TreeModel::Row row(*insert(iter));
805 set_row_layer(row,handle);
809 LayerTreeStore::on_layer_status_changed(synfig::Layer::Handle handle,bool /*x*/)
811 Gtk::TreeModel::Children::iterator iter;
812 if(find_layer_row(handle,iter))
813 (*iter)[model.layer]=handle;
816 synfig::warning("Couldn't find layer to be activated in layer list. Rebuilding index...");
822 LayerTreeStore::on_layer_lowered(synfig::Layer::Handle layer)
824 Gtk::TreeModel::Children::iterator iter, iter2;
825 if(find_layer_row(layer,iter))
827 // Save the selection data
828 //synfigapp::SelectionManager::LayerList layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
837 //Gtk::TreeModel::Row row(*iter);
838 Gtk::TreeModel::Row row2 = *iter2;
839 synfig::Layer::Handle layer2=row2[model.layer];
843 set_row_layer(row2,layer2);
851 LayerTreeStore::on_layer_raised(synfig::Layer::Handle layer)
853 Gtk::TreeModel::Children::iterator iter, iter2;
855 Gtk::TreeModel::Children children_(children());
857 if(find_layer_row_(layer, canvas_interface()->get_canvas(), children_, iter,iter2))
861 //Gtk::TreeModel::Row row = *iter;
862 Gtk::TreeModel::Row row2 = *iter2;
863 synfig::Layer::Handle layer2=row2[model.layer];
868 set_row_layer(row2,layer2);
878 LayerTreeStore::on_layer_moved(synfig::Layer::Handle layer,int depth, synfig::Canvas::Handle /*canvas*/)
880 on_layer_removed(layer);
881 on_layer_inserted(layer,depth);
885 LayerTreeStore::on_layer_param_changed(synfig::Layer::Handle handle,synfig::String param_name)
887 if(param_name=="z_depth")
889 Gtk::TreeModel::Children::iterator iter;
890 if(find_layer_row(handle,iter))
892 (*iter)[model.z_depth]=Time::begin();
897 Gtk::TreeModel::Children::iterator iter;
898 if(find_layer_row(handle,iter))
900 Gtk::TreeModel::Children children(iter->children());
902 for(iter = children.begin(); iter && iter != children.end(); ++iter)
904 if((Glib::ustring)(*iter)[model.param_name]==param_name)
906 Gtk::TreeRow row=*iter;
917 LayerTreeStore::on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc)
919 Gtk::TreeModel::Children::iterator iter;
920 if(find_layer_row(handle,iter))
922 Gtk::TreeRow row(*iter);
924 Layer::Handle layer(row[model.layer]);
928 //row[model.label]=layer->get_local_name();
929 row[model.tooltip]=Glib::ustring(_("Layer"));
932 //row[model.label]=layer->get_description();
933 row[model.tooltip]=layer->get_local_name();
942 LayerTreeStore::find_canvas_row_(synfig::Canvas::Handle canvas, synfig::Canvas::Handle parent, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter)
948 for(iter=layers.begin(); iter && iter != layers.end(); ++iter)
950 Gtk::TreeModel::Row row = *iter;
951 if(canvas==(synfig::Canvas::Handle)row[model.contained_canvas])
955 iter=children().end();
959 Gtk::TreeModel::Children::iterator iter2;
960 //Gtk::TreeModel::Children::iterator iter3;
962 for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
964 Gtk::TreeModel::Row row = *iter2;
967 if(row.children().empty())
970 Canvas::Handle sub_canvas((*row.children().begin())[model.canvas]);
974 if(find_canvas_row_(canvas,sub_canvas,iter2->children(),iter))
978 iter=children().end();
983 LayerTreeStore::find_canvas_row(synfig::Canvas::Handle canvas, Gtk::TreeModel::Children::iterator &iter)
985 return find_canvas_row_(canvas,canvas_interface()->get_canvas(),children(),iter);
990 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)
994 //if(layer->get_canvas()==canvas)
996 for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
998 Gtk::TreeModel::Row row = *iter;
999 if(layer==(synfig::Layer::Handle)row[model.layer])
1003 iter=children().end();
1007 Gtk::TreeModel::Children::iterator iter2;
1009 for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
1011 Gtk::TreeModel::Row row = *iter2;
1014 if(row.children().empty())
1017 Canvas::Handle canvas((*row.children().begin())[model.canvas]);
1021 if(find_layer_row_(layer,canvas,iter2->children(),iter,prev))
1025 iter=children().end();
1030 LayerTreeStore::find_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &iter)
1032 Gtk::TreeModel::Children::iterator prev;
1033 return find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev);
1037 LayerTreeStore::find_prev_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &prev)
1039 Gtk::TreeModel::Children::iterator iter;
1040 if(!find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev))
1042 if(iter==children().begin())