Fix some FTBFS issues when compiling with GCC 4.3
[synfig.git] / synfig-studio / trunk / src / gtkmm / layertree.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file layertree.cpp
3 **      \brief Template File
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
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.
14 **
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.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === H E A D E R S ======================================================= */
24
25 #ifdef USING_PCH
26 #       include "pch.h"
27 #else
28 #ifdef HAVE_CONFIG_H
29 #       include <config.h>
30 #endif
31
32 #include "layertree.h"
33 #include "layerparamtreestore.h"
34 #include "cellrenderer_value.h"
35 #include "cellrenderer_timetrack.h"
36 #include <synfigapp/action.h>
37 #include <synfigapp/instance.h>
38 #include <gtkmm/scrolledwindow.h>
39 #include <gtkmm/paned.h>
40 #include "app.h"
41 #include "instance.h"
42 #include <gtkmm/treemodelsort.h>
43
44 #include "general.h"
45
46 #endif
47
48 /* === U S I N G =========================================================== */
49
50 using namespace std;
51 using namespace etl;
52 using namespace synfig;
53 using namespace studio;
54
55 /* === M A C R O S ========================================================= */
56
57 #ifndef SMALL_BUTTON
58 #define SMALL_BUTTON(button,stockid,tooltip)    \
59         button = manage(new class Gtk::Button());       \
60         icon=manage(new Gtk::Image(Gtk::StockID(stockid),iconsize));    \
61         button->add(*icon);     \
62         tooltips_.set_tip(*button,tooltip);     \
63         icon->set_padding(0,0);\
64         icon->show();   \
65         button->set_relief(Gtk::RELIEF_NONE); \
66         button->show()
67 #endif
68
69 #ifndef NORMAL_BUTTON
70 #define NORMAL_BUTTON(button,stockid,tooltip)   \
71         button = manage(new class Gtk::Button());       \
72         icon=manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::ICON_SIZE_BUTTON));       \
73         button->add(*icon);     \
74         tooltips_.set_tip(*button,tooltip);     \
75         icon->set_padding(0,0);\
76         icon->show();   \
77         /*button->set_relief(Gtk::RELIEF_NONE);*/ \
78         button->show()
79 #endif
80
81 #define NEW_SMALL_BUTTON(x,y,z) Gtk::Button *SMALL_BUTTON(x,y,z)
82
83 #define NOT_IMPLEMENTED_SLOT sigc::mem_fun(*reinterpret_cast<studio::CanvasViewUIInterface*>(get_ui_interface().get()),&studio::CanvasViewUIInterface::not_implemented)
84
85 /* === G L O B A L S ======================================================= */
86
87 /* === P R O C E D U R E S ================================================= */
88
89 /* === M E T H O D S ======================================================= */
90
91 LayerTree::LayerTree():
92         layer_amount_adjustment_(1,0,1,0.01,0.01,0)
93 {
94         param_tree_view_=new Gtk::TreeView;
95         layer_tree_view_=new Gtk::TreeView;
96
97         //Gtk::HPaned* hpaned(manage(new Gtk::HPaned()));
98         //hpaned->show();
99         //attach(*hpaned, 0, 3, 0, 1, Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL, 0, 0);
100         //attach(*create_layer_tree(), 0, 3, 0, 1, Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL, 0, 0);
101
102         create_layer_tree();
103         create_param_tree();
104
105         //hpaned->pack1(*create_layer_tree(),false,false);
106         //hpaned->pack2(*create_param_tree(),true,false);
107         //hpaned->set_position(200);
108         hbox=manage(new Gtk::HBox());
109
110         attach(*hbox, 0, 1, 1, 2, Gtk::FILL|Gtk::SHRINK, Gtk::SHRINK, 0, 0);
111         attach(blend_method_widget, 2, 3, 1, 2,Gtk::SHRINK, Gtk::SHRINK, 0, 0);
112
113         layer_amount_hscale=manage(new Gtk::HScale(layer_amount_adjustment_));
114         layer_amount_hscale->set_digits(2);
115         layer_amount_hscale->set_value_pos(Gtk::POS_LEFT);
116         layer_amount_hscale->set_sensitive(false);
117         layer_amount_hscale->set_update_policy( Gtk::UPDATE_DISCONTINUOUS);
118         attach(*layer_amount_hscale, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 1, 1);
119         layer_amount_adjustment_.signal_value_changed().connect(sigc::mem_fun(*this, &studio::LayerTree::on_amount_value_changed));
120
121         Gtk::Image *icon;
122         //Gtk::IconSize iconsize(Gtk::IconSize::from_name("synfig-small_icon"));
123         Gtk::IconSize iconsize(Gtk::ICON_SIZE_SMALL_TOOLBAR);
124
125         SMALL_BUTTON(button_raise,"gtk-go-up","Raise");
126         SMALL_BUTTON(button_lower,"gtk-go-down","Lower");
127         SMALL_BUTTON(button_duplicate,"synfig-duplicate","Duplicate");
128         SMALL_BUTTON(button_delete,"gtk-delete","Delete");
129
130         hbox->pack_start(*button_raise,Gtk::PACK_SHRINK);
131         hbox->pack_start(*button_lower,Gtk::PACK_SHRINK);
132         hbox->pack_start(*button_duplicate,Gtk::PACK_SHRINK);
133         hbox->pack_start(*button_delete,Gtk::PACK_SHRINK);
134
135         button_raise->signal_clicked().connect(sigc::mem_fun(*this, &studio::LayerTree::on_raise_pressed));
136         button_lower->signal_clicked().connect(sigc::mem_fun(*this, &studio::LayerTree::on_lower_pressed));
137         button_duplicate->signal_clicked().connect(sigc::mem_fun(*this, &studio::LayerTree::on_duplicate_pressed));
138         button_delete->signal_clicked().connect(sigc::mem_fun(*this, &studio::LayerTree::on_delete_pressed));
139
140         button_raise->set_sensitive(false);
141         button_lower->set_sensitive(false);
142         button_duplicate->set_sensitive(false);
143         button_delete->set_sensitive(false);
144
145         get_selection()->signal_changed().connect(sigc::mem_fun(*this, &studio::LayerTree::on_selection_changed));
146
147         get_layer_tree_view().set_reorderable(true);
148         get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
149         //get_param_tree_view().get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
150         get_layer_tree_view().show();
151         get_param_tree_view().show();
152
153         hbox->show();
154         layer_amount_hscale->show();
155         blend_method_widget.show();
156
157         tooltips_.enable();
158         disable_amount_changed_signal=false;
159
160         blend_method_widget.set_param_desc(ParamDesc(Color::BlendMethod(),"blend_method"));
161
162         blend_method_widget.set_value((int)Color::BLEND_COMPOSITE);
163         blend_method_widget.set_size_request(150,-1);
164         blend_method_widget.set_sensitive(false);
165         blend_method_widget.signal_activate().connect(sigc::mem_fun(*this, &studio::LayerTree::on_blend_method_changed));
166 }
167
168 LayerTree::~LayerTree()
169 {
170         synfig::info("LayerTree::~LayerTree(): Deleted");
171 }
172
173 Gtk::Widget*
174 LayerTree::create_layer_tree()
175 {
176         const LayerTreeStore::Model model;
177
178         {       // --- O N / O F F ----------------------------------------------------
179                 //int index;
180                 //index=get_layer_tree_view().append_column_editable(_(" "),layer_model.active);
181                 //Gtk::TreeView::Column* column = get_layer_tree_view().get_column(index-1);
182
183                 Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_(" ")) );
184
185                 // Set up the icon cell-renderer
186                 Gtk::CellRendererToggle* cellrenderer = Gtk::manage( new Gtk::CellRendererToggle() );
187                 cellrenderer->signal_toggled().connect(sigc::mem_fun(*this, &studio::LayerTree::on_layer_toggle));
188
189                 column->pack_start(*cellrenderer,false);
190                 column->add_attribute(cellrenderer->property_active(), layer_model.active);
191                 get_layer_tree_view().append_column(*column);
192         }
193
194         {       // --- I C O N --------------------------------------------------------
195                 int index;
196                 index=get_layer_tree_view().append_column(_("Z"),layer_model.icon);
197                 Gtk::TreeView::Column* column = get_layer_tree_view().get_column(index-1);
198                 get_layer_tree_view().set_expander_column(*column);
199
200                 column->set_sort_column_id(layer_model.z_depth);
201                 //column->set_reorderable();
202                 //column->set_resizable();
203                 //column->set_clickable();
204
205                 //Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
206                 //column->pack_start(*icon_cellrenderer,false);
207                 //column->add_attribute(icon_cellrenderer->property_pixbuf(), layer_model.icon);
208         }
209         //get_layer_tree_view().append_column(_("Z"),layer_model.z_depth);
210         {       // --- N A M E --------------------------------------------------------
211                 Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Layer")) );
212
213                 // Set up the icon cell-renderer
214                 Gtk::CellRendererText* cellrenderer = Gtk::manage( new Gtk::CellRendererText() );
215                 cellrenderer->signal_edited().connect(sigc::mem_fun(*this, &studio::LayerTree::on_layer_renamed));
216                 cellrenderer->property_editable()=true;
217
218                 column->pack_start(*cellrenderer,false);
219                 column->add_attribute(cellrenderer->property_text(), layer_model.label);
220                 get_layer_tree_view().append_column(*column);
221
222                 //              int index;
223 //              index=get_layer_tree_view().append_column_editable(_("Layer"),layer_model.label);
224                 //Gtk::TreeView::Column* column = get_layer_tree_view().get_column(index-1);
225
226                 //column->set_sort_column_id(layer_model.index);
227
228                 //get_layer_tree_view().set_expander_column(*column);
229                 //column->set_reorderable();
230                 //column->set_resizable();
231                 //column->set_clickable(false);
232
233                 //Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
234                 //column->pack_start(*icon_cellrenderer,false);
235                 //column->add_attribute(icon_cellrenderer->property_pixbuf(), layer_model.icon);
236         }
237         {       // --- Z D E P T H ----------------------------------------------------
238                 int index;
239                 index=get_layer_tree_view().append_column(_("Z"),layer_model.z_depth);
240                 column_z_depth=get_layer_tree_view().get_column(index-1);
241
242                 column_z_depth->set_reorderable();
243                 column_z_depth->set_resizable();
244                 column_z_depth->set_clickable();
245
246                 column_z_depth->set_sort_column_id(layer_model.z_depth);
247         }
248
249         get_layer_tree_view().set_enable_search(true);
250         get_layer_tree_view().set_search_column(layer_model.label);
251         get_layer_tree_view().set_search_equal_func(sigc::ptr_fun(&studio::LayerTreeStore::search_func));
252
253         std::list<Gtk::TargetEntry> listTargets;
254         listTargets.push_back( Gtk::TargetEntry("LAYER") );
255         get_layer_tree_view().drag_dest_set(listTargets);
256
257         // This makes things easier to read.
258         get_layer_tree_view().set_rules_hint();
259
260         // Make us more sensitive to several events
261         //get_layer_tree_view().add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK|Gdk::POINTER_MOTION_MASK);
262
263         get_layer_tree_view().signal_event().connect(sigc::mem_fun(*this, &studio::LayerTree::on_layer_tree_event));
264         get_layer_tree_view().show();
265
266         Gtk::ScrolledWindow *scroll = manage(new class Gtk::ScrolledWindow());
267         scroll->set_flags(Gtk::CAN_FOCUS);
268         scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
269         //scroll->add(get_layer_tree_view());
270         scroll->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
271         scroll->show();
272
273         return scroll;
274 }
275
276 Gtk::Widget*
277 LayerTree::create_param_tree()
278 {
279         Pango::AttrList attr_list;
280         {
281                 Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*8));
282                 pango_size.set_start_index(0);
283                 pango_size.set_end_index(64);
284                 attr_list.change(pango_size);
285         }
286
287         Gtk::IconSize icon_size(Gtk::ICON_SIZE_SMALL_TOOLBAR);
288
289         {       // --- N A M E --------------------------------------------------------
290                 Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Name")) );
291
292                 // Set up the icon cell-renderer
293                 Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
294                 column->pack_start(*icon_cellrenderer,false);
295                 column->add_attribute(icon_cellrenderer->property_pixbuf(), param_model.icon);
296
297                 // Pack the label into the column
298                 //column->pack_start(layer_model.label,true);
299                 Gtk::CellRendererText* text_cellrenderer = Gtk::manage( new Gtk::CellRendererText() );
300                 column->pack_start(*text_cellrenderer,false);
301                 column->add_attribute(text_cellrenderer->property_text(), param_model.label);
302                 text_cellrenderer->property_attributes()=attr_list;
303
304                 text_cellrenderer->property_foreground()=Glib::ustring("#7f7f7f");
305                 column->add_attribute(text_cellrenderer->property_foreground_set(),param_model.is_inconsistent);
306
307                 // Pack the label into the column
308                 //column->pack_start(param_model.label,true);
309
310                 // Set up the value-node icon cell-renderer to be on the far right
311                 Gtk::CellRendererPixbuf* valuenode_icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
312                 column->pack_end(*valuenode_icon_cellrenderer,false);
313                 valuenode_icon_cellrenderer->property_pixbuf()=Gtk::Button().render_icon(Gtk::StockID("synfig-value_node"),icon_size);
314                 column->add_attribute(valuenode_icon_cellrenderer->property_visible(), param_model.is_shared);
315
316                 // Finish setting up the column
317                 column->set_reorderable();
318                 column->set_resizable();
319                 column->set_clickable();
320
321                 get_param_tree_view().append_column(*column);
322         }
323         {       // --- V A L U E  -----------------------------------------------------
324                 Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Value")) );
325
326                 // Set up the value cell-renderer
327                 cellrenderer_value=LayerParamTreeStore::add_cell_renderer_value(column);
328                 cellrenderer_value->signal_edited().connect(sigc::mem_fun(*this, &studio::LayerTree::on_edited_value));
329                 cellrenderer_value->property_value()=synfig::ValueBase();
330                 column->add_attribute(cellrenderer_value->property_param_desc(), param_model.param_desc);
331                 column->add_attribute(cellrenderer_value->property_inconsistent(),param_model.is_inconsistent);
332                 //cellrenderer_value->property_canvas()=canvas_interface->get_canvas(); // Is this line necessary?
333                 cellrenderer_value->property_attributes()=attr_list;
334
335                 // Finish setting up the column
336                 get_param_tree_view().append_column(*column);
337                 column->set_sizing(Gtk::TREE_VIEW_COLUMN_AUTOSIZE);
338                 column->set_clickable();
339                 column->set_min_width(120);
340                 column->set_reorderable();
341                 column->set_resizable();
342         }
343         {       // --- T Y P E --------------------------------------------------------
344                 Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Type")) );
345                 Gtk::CellRendererText* text_cellrenderer = Gtk::manage( new Gtk::CellRendererText() );
346                 column->pack_start(*text_cellrenderer,false);
347                 column->add_attribute(text_cellrenderer->property_text(), param_model.type);
348                 text_cellrenderer->property_attributes()=attr_list;
349                 get_param_tree_view().append_column(*column);
350                 column->set_reorderable();
351                 column->set_resizable();
352                 column->set_clickable();
353                 column->set_sort_column_id(param_model.type);
354         }
355         /*{     // --- T I M E   T R A C K --------------------------------------------
356                 Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Time Track")) );
357                 column_time_track=column;
358
359                 // Set up the value-node cell-renderer
360                 cellrenderer_time_track=LayerParamTreeStore::add_cell_renderer_value_node(column);
361                 cellrenderer_time_track->property_mode()=Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
362                 cellrenderer_time_track->signal_waypoint_clicked().connect(sigc::mem_fun(*this, &studio::LayerTree::on_waypoint_clicked) );
363                 cellrenderer_time_track->signal_waypoint_changed().connect(sigc::mem_fun(*this, &studio::LayerTree::on_waypoint_changed) );
364                 column->add_attribute(cellrenderer_time_track->property_value_desc(), param_model.value_desc);
365                 column->add_attribute(cellrenderer_time_track->property_canvas(), param_model.canvas);
366                 //column->add_attribute(cellrenderer_time_track->property_visible(), model.is_value_node);
367
368                 //column->pack_start(*cellrenderer_time_track);
369
370                 // Finish setting up the column
371                 column->set_reorderable();
372                 column->set_resizable();
373                 column->set_min_width(200);
374                 //get_param_tree_view().append_column(*column);
375         }*/
376
377         // This makes things easier to read.
378         get_param_tree_view().set_rules_hint();
379
380         // Make us more sensitive to several events
381         get_param_tree_view().add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK|Gdk::POINTER_MOTION_MASK);
382
383         get_param_tree_view().signal_event().connect(sigc::mem_fun(*this, &studio::LayerTree::on_param_tree_event));
384         get_param_tree_view().show();
385
386         Gtk::ScrolledWindow *scroll = manage(new class Gtk::ScrolledWindow());
387         scroll->set_flags(Gtk::CAN_FOCUS);
388         scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
389         //scroll->add(get_param_tree_view());
390         scroll->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
391         scroll->show();
392
393         //column_time_track->set_visible(false);
394
395         return scroll;
396 }
397
398 void
399 LayerTree::on_waypoint_changed( synfig::Waypoint waypoint , synfig::ValueNode::Handle value_node)
400 {
401         synfigapp::Action::ParamList param_list;
402         param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
403         param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
404         param_list.add("value_node",value_node);
405         param_list.add("waypoint",waypoint);
406 //      param_list.add("time",canvas_interface()->get_time());
407
408         etl::handle<studio::Instance>::cast_static(layer_tree_store_->canvas_interface()->get_instance())->process_action("waypoint_set_smart", param_list);
409 }
410
411 void
412 LayerTree::select_layer(synfig::Layer::Handle layer)
413 {
414         Gtk::TreeModel::Children::iterator iter;
415         if(layer_tree_store_->find_layer_row(layer,iter))
416         {
417                 if(sorted_layer_tree_store_)
418                         iter=sorted_layer_tree_store_->convert_child_iter_to_iter(iter);
419
420                 Gtk::TreePath path(iter);
421                 for(int i=path.get_depth();i;i--)
422                 {
423                         int j;
424                         path=Gtk::TreePath(iter);
425                         for(j=i;j;j--)
426                                 path.up();
427                         get_layer_tree_view().expand_row(path,false);
428                 }
429                 get_layer_tree_view().scroll_to_row(Gtk::TreePath(iter));
430                 get_layer_tree_view().get_selection()->select(iter);
431         }
432 }
433
434 void
435 LayerTree::select_all_children(Gtk::TreeModel::Children::iterator iter)
436 {
437         get_layer_tree_view().get_selection()->select(iter);
438         if((bool)(*iter)[layer_model.children_lock])
439                 return;
440         get_layer_tree_view().expand_row(layer_tree_store_->get_path(iter),false);
441         Gtk::TreeModel::Children children(iter->children());
442         for(iter=children.begin();iter!=children.end();++iter)
443                 select_all_children(iter);
444 }
445
446 void
447 LayerTree::select_all_children_layers(synfig::Layer::Handle layer)
448 {
449         Gtk::TreeModel::Children::iterator iter;
450         if(layer_tree_store_->find_layer_row(layer,iter))
451                 select_all_children(iter);
452 }
453
454 void
455 LayerTree::select_layers(const LayerList &layer_list)
456 {
457         LayerList::const_iterator iter;
458         for(iter = layer_list.begin(); iter != layer_list.end(); ++iter)
459                 select_layer(*iter);
460 }
461
462 static inline void __layer_grabber(const Gtk::TreeModel::iterator& iter, LayerTree::LayerList* ret)
463 {
464         const LayerTreeStore::Model layer_tree_model;
465         ret->push_back((Layer::Handle)(*iter)[layer_tree_model.layer]);
466 }
467
468 LayerTree::LayerList
469 LayerTree::get_selected_layers()const
470 {
471         Glib::RefPtr<Gtk::TreeSelection> selection=const_cast<Gtk::TreeView&>(get_layer_tree_view()).get_selection();
472
473         if(!selection)
474                 return LayerList();
475
476         LayerList ret;
477
478         selection->selected_foreach_iter(
479                 sigc::bind(
480                         sigc::ptr_fun(
481                                 &__layer_grabber
482                         ),
483                         &ret
484                 )
485         );
486
487         return ret;
488 }
489
490 synfig::Layer::Handle
491 LayerTree::get_selected_layer()const
492 {
493         LayerList layers(get_selected_layers());
494
495         if(layers.empty())
496                 return 0;
497
498         return *layers.begin();
499 }
500
501 void
502 LayerTree::clear_selected_layers()
503 {
504         get_layer_tree_view().get_selection()->unselect_all();
505 }
506
507 void
508 LayerTree::set_show_timetrack(bool x)
509 {
510         //column_time_track->set_visible(x);
511 //      column_time_track->set_visible(false);
512         column_z_depth->set_visible(x);
513 }
514
515 void
516 LayerTree::set_model(Glib::RefPtr<LayerTreeStore> layer_tree_store)
517 {
518         layer_tree_store_=layer_tree_store;
519
520         if(false)
521         {
522                 sorted_layer_tree_store_=Gtk::TreeModelSort::create(layer_tree_store);
523
524                 sorted_layer_tree_store_->set_default_sort_func(sigc::ptr_fun(&studio::LayerTreeStore::z_sorter));
525
526                 //sorted_store->set_sort_func(model.time.index(),sigc::mem_fun(&studio::KeyframeTreeStore::time_sorter));
527                 //sorted_store->set_sort_column_id(model.time.index(), Gtk::SORT_ASCENDING);
528
529                 get_layer_tree_view().set_model(sorted_layer_tree_store_);
530         }
531         else
532                 get_layer_tree_view().set_model(layer_tree_store_);
533
534         layer_tree_store_->canvas_interface()->signal_dirty_preview().connect(sigc::mem_fun(*this,&studio::LayerTree::on_dirty_preview));
535
536         //layer_tree_store_->canvas_interface()->signal_dirty_preview().connect(sigc::mem_fun(*this,&studio::LayerTree::on_dirty_preview));
537
538         layer_tree_store_->canvas_interface()->signal_time_changed().connect(
539                 sigc::mem_fun(
540                         &get_param_tree_view(),
541                         &Gtk::Widget::queue_draw
542                 )
543         );
544         if(!param_tree_store_)
545         {
546                 param_tree_store_=LayerParamTreeStore::create(layer_tree_store_->canvas_interface(), this);
547                 get_param_tree_view().set_model(param_tree_store_);
548         }
549
550 /*      if(cellrenderer_time_track && layer_tree_store_ && layer_tree_store_->canvas_interface())
551         {
552                 cellrenderer_time_track->set_canvas_interface(layer_tree_store_->canvas_interface());
553         }
554 */
555 }
556
557 void
558 LayerTree::set_time_adjustment(Gtk::Adjustment &adjustment)
559 {
560         //cellrenderer_time_track->set_adjustment(adjustment);
561         adjustment.signal_value_changed().connect(sigc::mem_fun(get_param_tree_view(),&Gtk::TreeView::queue_draw));
562         adjustment.signal_changed().connect(sigc::mem_fun(get_param_tree_view(),&Gtk::TreeView::queue_draw));
563 }
564
565 void
566 LayerTree::on_dirty_preview()
567 {
568 /*
569         if(quick_layer && !disable_amount_changed_signal)
570         {
571                 layer_amount_hscale->set_sensitive(true);
572                 disable_amount_changed_signal=true;
573                 layer_amount_adjustment_.set_value(quick_layer->get_param("amount").get(Real()));
574                 disable_amount_changed_signal=false;
575                 if(quick_layer->get_param("blend_method").is_valid())
576                 {
577                         blend_method_widget.set_sensitive(true);
578                         disable_amount_changed_signal=true;
579                         blend_method_widget.set_value(quick_layer->get_param("blend_method"));
580                         disable_amount_changed_signal=false;
581                 }
582         }
583 */
584 }
585
586 void
587 LayerTree::on_selection_changed()
588 {
589         synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
590
591         Gtk::TreeIter iter;
592         if(last_top_selected_layer && !layer_tree_store_->find_layer_row(last_top_selected_layer,iter))
593         {
594                 if(layer_list.empty())
595                 {
596                         last_top_selected_layer=0;
597                         layer_tree_view_->get_selection()->select(last_top_selected_path);
598                         return;
599                 }
600         }
601
602         {
603                 if(!layer_list.empty())
604                 {
605                         last_top_selected_layer=layer_list.front();
606                         last_top_selected_path=*layer_tree_view_->get_selection()->get_selected_rows().begin();
607                 }
608                 else
609                 {
610                         last_top_selected_layer=0;
611                 }
612         }
613
614         if(layer_list.empty())
615         {
616                 button_raise->set_sensitive(false);
617                 button_lower->set_sensitive(false);
618                 button_duplicate->set_sensitive(false);
619                 button_delete->set_sensitive(false);
620                 layer_amount_hscale->set_sensitive(false);
621                 blend_method_widget.set_sensitive(false);
622                 return;
623         }
624
625         button_raise->set_sensitive(true);
626         button_lower->set_sensitive(true);
627         button_duplicate->set_sensitive(true);
628         button_delete->set_sensitive(true);
629
630         if(layer_list.size()==1 && (*layer_list.begin())->get_param("amount").is_valid()&& (*layer_list.begin())->get_param("amount").same_type_as(Real()))
631         {
632                 quick_layer=*layer_list.begin();
633         }
634         else
635                 quick_layer=0;
636
637         if(quick_layer)
638         {
639                 layer_amount_hscale->set_sensitive(true);
640                 disable_amount_changed_signal=true;
641                 layer_amount_adjustment_.set_value(quick_layer->get_param("amount").get(Real()));
642                 disable_amount_changed_signal=false;
643                 if(quick_layer->get_param("blend_method").is_valid())
644                 {
645                         blend_method_widget.set_sensitive(true);
646                         disable_amount_changed_signal=true;
647                         blend_method_widget.set_value(quick_layer->get_param("blend_method"));
648                         disable_amount_changed_signal=false;
649                 }
650                 else
651                         blend_method_widget.set_sensitive(false);
652         }
653         else
654         {
655                 layer_amount_hscale->set_sensitive(false);
656                 blend_method_widget.set_sensitive(false);
657         }
658 }
659
660 void
661 LayerTree::on_blend_method_changed()
662 {
663         if(disable_amount_changed_signal)
664                 return;
665         if(!quick_layer)
666                 return;
667
668         if(quick_layer->get_param("blend_method").is_valid())
669         {
670                 disable_amount_changed_signal=true;
671                 signal_edited_value()(synfigapp::ValueDesc(quick_layer,"blend_method"),blend_method_widget.get_value());
672                 disable_amount_changed_signal=false;
673         }
674 }
675
676 void
677 LayerTree::on_amount_value_changed()
678 {
679         if(disable_amount_changed_signal)
680                 return;
681         if(!quick_layer)
682                 return;
683
684         disable_amount_changed_signal=true;
685         signal_edited_value()(synfigapp::ValueDesc(quick_layer,"amount"),synfig::ValueBase(layer_amount_adjustment_.get_value()));
686         disable_amount_changed_signal=false;
687 }
688
689 void
690 LayerTree::on_edited_value(const Glib::ustring&path_string,synfig::ValueBase value)
691 {
692         Gtk::TreePath path(path_string);
693
694         const Gtk::TreeRow row = *(get_param_tree_view().get_model()->get_iter(path));
695         if(!row)
696                 return;
697         row[param_model.value]=value;
698         //signal_edited_value()(row[param_model.value_desc],value);
699 }
700
701 void
702 LayerTree::on_layer_renamed(const Glib::ustring&path_string,const Glib::ustring& value)
703 {
704         Gtk::TreePath path(path_string);
705
706         const Gtk::TreeRow row = *(get_layer_tree_view().get_model()->get_iter(path));
707         if(!row)
708                 return;
709         row[layer_model.label]=value;
710 }
711
712 void
713 LayerTree::on_layer_toggle(const Glib::ustring& path_string)
714 {
715         Gtk::TreePath path(path_string);
716
717         const Gtk::TreeRow row = *(get_layer_tree_view().get_model()->get_iter(path));
718         bool active=static_cast<bool>(row[layer_model.active]);
719         row[layer_model.active]=!active;
720 }
721
722 void
723 LayerTree::on_waypoint_clicked(const Glib::ustring &path_string, synfig::Waypoint waypoint,int button)
724 {
725         Gtk::TreePath path(path_string);
726
727         const Gtk::TreeRow row = *(get_param_tree_view().get_model()->get_iter(path));
728         if(!row)
729                 return;
730
731         signal_waypoint_clicked()(static_cast<synfigapp::ValueDesc>(row[param_model.value_desc]),waypoint,button);
732 }
733
734 bool
735 LayerTree::on_layer_tree_event(GdkEvent *event)
736 {
737     switch(event->type)
738     {
739         case GDK_BUTTON_PRESS:
740                 {
741                         Gtk::TreeModel::Path path;
742                         Gtk::TreeViewColumn *column;
743                         int cell_x, cell_y;
744                         if(!get_layer_tree_view().get_path_at_pos(
745                                 int(event->button.x),int(event->button.y),      // x, y
746                                 path, // TreeModel::Path&
747                                 column, //TreeViewColumn*&
748                                 cell_x,cell_y //int&cell_x,int&cell_y
749                                 )
750                         ) break;
751                         const Gtk::TreeRow row = *(get_layer_tree_view().get_model()->get_iter(path));
752
753                         //if(column->get_first_cell_renderer()==cellrenderer_time_track)
754                         //      return signal_layer_user_click()(event->button.button,row,COLUMNID_TIME_TRACK);
755                         //else
756                                 if(column->get_first_cell_renderer()==cellrenderer_value)
757                                 return signal_layer_user_click()(event->button.button,row,COLUMNID_VALUE);
758                         else
759                                 return signal_layer_user_click()(event->button.button,row,COLUMNID_NAME);
760
761                 }
762                 break;
763
764         case GDK_MOTION_NOTIFY:
765                 {
766                         Gtk::TreeModel::Path path;
767                         Gtk::TreeViewColumn *column;
768                         int cell_x, cell_y;
769                         if(!get_layer_tree_view().get_path_at_pos(
770                                 (int)event->button.x,(int)event->button.y,      // x, y
771                                 path, // TreeModel::Path&
772                                 column, //TreeViewColumn*&
773                                 cell_x,cell_y //int&cell_x,int&cell_y
774                                 )
775                         ) break;
776
777                         if(!get_layer_tree_view().get_model()->get_iter(path))
778                                 break;
779
780                         Gtk::TreeRow row = *(get_layer_tree_view().get_model()->get_iter(path));
781
782                         /*
783                         if(cellrenderer_time_track==column->get_first_cell_renderer())
784                         {
785                                 // Movement on TimeLine
786                                 return true;
787                         }
788                         else
789                                 */
790                         if(last_tooltip_path.get_depth()<=0 || path!=last_tooltip_path)
791                         {
792                                 tooltips_.unset_tip(*this);
793                                 Glib::ustring tooltips_string(row[layer_model.tooltip]);
794                                 last_tooltip_path=path;
795                                 if(!tooltips_string.empty())
796                                 {
797                                         tooltips_.set_tip(*this,tooltips_string);
798                                         tooltips_.force_window();
799                                 }
800                         }
801                 }
802                 break;
803         case GDK_BUTTON_RELEASE:
804                 break;
805         default:
806                 break;
807         }
808         return false;
809 }
810
811 bool
812 LayerTree::on_param_tree_event(GdkEvent *event)
813 {
814     switch(event->type)
815     {
816         case GDK_BUTTON_PRESS:
817                 {
818                         Gtk::TreeModel::Path path;
819                         Gtk::TreeViewColumn *column;
820                         int cell_x, cell_y;
821                         if(!get_param_tree_view().get_path_at_pos(
822                                 int(event->button.x),int(event->button.y),      // x, y
823                                 path, // TreeModel::Path&
824                                 column, //TreeViewColumn*&
825                                 cell_x,cell_y //int&cell_x,int&cell_y
826                                 )
827                         ) break;
828                         const Gtk::TreeRow row = *(get_param_tree_view().get_model()->get_iter(path));
829
830 /*                      if(column && column->get_first_cell_renderer()==cellrenderer_time_track)
831                         {
832                                 Gdk::Rectangle rect;
833                                 get_param_tree_view().get_cell_area(path,*column,rect);
834                                 cellrenderer_time_track->property_value_desc()=row[param_model.value_desc];
835                                 cellrenderer_time_track->property_canvas()=row[param_model.canvas];
836                                 cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
837                                 get_param_tree_view().queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
838                                 return true;
839                                 //return signal_param_user_click()(event->button.button,row,COLUMNID_TIME_TRACK);
840                         }
841                         else
842 */                      {
843                                 if(event->button.button==3)
844                                 {
845                                         LayerList layer_list(get_selected_layers());
846                                         if(layer_list.size()<=1)
847                                         {
848                                                 synfigapp::ValueDesc value_desc(row[param_model.value_desc]);
849                                                 Gtk::Menu* menu(manage(new Gtk::Menu()));
850                                                 menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu));
851                                                 App::get_instance(param_tree_store_->canvas_interface()->get_canvas())->make_param_menu(menu,param_tree_store_->canvas_interface()->get_canvas(),value_desc,0.5f);
852                                                 menu->popup(event->button.button,gtk_get_current_event_time());
853                                                 return true;
854                                         }
855                                         Gtk::Menu* menu(manage(new Gtk::Menu()));
856                                         menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu));
857                                         std::list<synfigapp::ValueDesc> value_desc_list;
858                                         ParamDesc param_desc(row[param_model.param_desc]);
859                                         for(;!layer_list.empty();layer_list.pop_back())
860                                                 value_desc_list.push_back(synfigapp::ValueDesc(layer_list.back(),param_desc.get_name()));
861                                         App::get_instance(param_tree_store_->canvas_interface()->get_canvas())->make_param_menu(menu,param_tree_store_->canvas_interface()->get_canvas(),value_desc_list);
862                                         menu->popup(event->button.button,gtk_get_current_event_time());
863                                         return true;
864                                 }
865                                 else
866                                 {
867                                         if(column->get_first_cell_renderer()==cellrenderer_value)
868                                                 return signal_param_user_click()(event->button.button,row,COLUMNID_VALUE);
869                                         else
870                                                 return signal_param_user_click()(event->button.button,row,COLUMNID_NAME);
871                                 }
872                         }
873                 }
874                 break;
875
876         case GDK_MOTION_NOTIFY:
877                 {
878                         Gtk::TreeModel::Path path;
879                         Gtk::TreeViewColumn *column;
880                         int cell_x, cell_y;
881                         if(!get_param_tree_view().get_path_at_pos(
882                                 (int)event->motion.x,(int)event->motion.y,      // x, y
883                                 path, // TreeModel::Path&
884                                 column, //TreeViewColumn*&
885                                 cell_x,cell_y //int&cell_x,int&cell_y
886                                 )
887                         ) break;
888
889                         if(!get_param_tree_view().get_model()->get_iter(path))
890                                 break;
891
892                         Gtk::TreeRow row = *(get_param_tree_view().get_model()->get_iter(path));
893
894 /*                      if((event->motion.state&GDK_BUTTON1_MASK ||event->motion.state&GDK_BUTTON3_MASK) && column && cellrenderer_time_track==column->get_first_cell_renderer())
895                         {
896                                 Gdk::Rectangle rect;
897                                 get_param_tree_view().get_cell_area(path,*column,rect);
898                                 cellrenderer_time_track->property_value_desc()=row[param_model.value_desc];
899                                 cellrenderer_time_track->property_canvas()=row[param_model.canvas];
900                                 cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
901                                 get_param_tree_view().queue_draw();
902                                 //get_param_tree_view().queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
903                                 return true;
904                         }
905                         else
906 */                      if(last_tooltip_path.get_depth()<=0 || path!=last_tooltip_path)
907                         {
908                                 tooltips_.unset_tip(*this);
909                                 Glib::ustring tooltips_string(row[layer_model.tooltip]);
910                                 last_tooltip_path=path;
911                                 if(!tooltips_string.empty())
912                                 {
913                                         tooltips_.set_tip(*this,tooltips_string);
914                                         tooltips_.force_window();
915                                 }
916                         }
917                 }
918                 break;
919         case GDK_BUTTON_RELEASE:
920                 {
921                         Gtk::TreeModel::Path path;
922                         Gtk::TreeViewColumn *column;
923                         int cell_x, cell_y;
924                         if(!get_param_tree_view().get_path_at_pos(
925                                 (int)event->button.x,(int)event->button.y,      // x, y
926                                 path, // TreeModel::Path&
927                                 column, //TreeViewColumn*&
928                                 cell_x,cell_y //int&cell_x,int&cell_y
929                                 )
930                         ) break;
931
932                         if(!get_param_tree_view().get_model()->get_iter(path))
933                                 break;
934
935                         Gtk::TreeRow row = *(get_param_tree_view().get_model()->get_iter(path));
936
937 /*                      if(column && cellrenderer_time_track==column->get_first_cell_renderer())
938                         {
939                                 Gdk::Rectangle rect;
940                                 get_param_tree_view().get_cell_area(path,*column,rect);
941                                 cellrenderer_time_track->property_value_desc()=row[param_model.value_desc];
942                                 cellrenderer_time_track->property_canvas()=row[param_model.canvas];
943                                 cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
944                                 get_param_tree_view().queue_draw();
945                                 get_param_tree_view().queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
946                                 return true;
947
948                         }
949 */
950                 }
951                 break;
952         default:
953                 break;
954         }
955         return false;
956 }
957
958 void
959 LayerTree::on_raise_pressed()
960 {
961         synfigapp::Action::ParamList param_list;
962         param_list.add("time",layer_tree_store_->canvas_interface()->get_time());
963         param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
964         param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
965
966         {
967                 synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
968                 synfigapp::SelectionManager::LayerList::iterator iter;
969
970                 for(iter=layer_list.begin();iter!=layer_list.end();++iter)
971                         param_list.add("layer",Layer::Handle(*iter));
972         }
973         synfigapp::Action::Handle action(synfigapp::Action::create("layer_raise"));
974         action->set_param_list(param_list);
975         layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
976 }
977
978 void
979 LayerTree::on_lower_pressed()
980 {
981         synfigapp::Action::ParamList param_list;
982         param_list.add("time",layer_tree_store_->canvas_interface()->get_time());
983         param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
984         param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
985
986         {
987                 synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
988                 synfigapp::SelectionManager::LayerList::iterator iter;
989
990                 for(iter=layer_list.begin();iter!=layer_list.end();++iter)
991                         param_list.add("layer",Layer::Handle(*iter));
992         }
993
994         synfigapp::Action::Handle action(synfigapp::Action::create("layer_lower"));
995         action->set_param_list(param_list);
996         layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
997 }
998
999 void
1000 LayerTree::on_duplicate_pressed()
1001 {
1002         synfigapp::Action::ParamList param_list;
1003         param_list.add("time",layer_tree_store_->canvas_interface()->get_time());
1004         param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
1005         param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
1006
1007         {
1008                 synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
1009                 synfigapp::SelectionManager::LayerList::iterator iter;
1010
1011                 for(iter=layer_list.begin();iter!=layer_list.end();++iter)
1012                         param_list.add("layer",Layer::Handle(*iter));
1013         }
1014
1015         synfigapp::Action::Handle action(synfigapp::Action::create("layer_duplicate"));
1016         action->set_param_list(param_list);
1017         layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
1018 }
1019
1020 void
1021 LayerTree::on_delete_pressed()
1022 {
1023         synfigapp::Action::ParamList param_list;
1024         param_list.add("time",layer_tree_store_->canvas_interface()->get_time());
1025         param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
1026         param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
1027
1028         {
1029                 synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
1030                 synfigapp::SelectionManager::LayerList::iterator iter;
1031
1032                 for(iter=layer_list.begin();iter!=layer_list.end();++iter)
1033                         param_list.add("layer",Layer::Handle(*iter));
1034         }
1035
1036         synfigapp::Action::Handle action(synfigapp::Action::create("layer_remove"));
1037         action->set_param_list(param_list);
1038         layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
1039 }
1040
1041 /*
1042 void
1043 LayerTree::on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&context, Gtk::SelectionData& selection_data, guint info, guint time)
1044 {
1045         synfig::info("Dragged data of type \"%s\"",selection_data.get_data_type());
1046         synfig::info("Dragged data of target \"%s\"",gdk_atom_name(selection_data->target));
1047         synfig::info("Dragged selection=\"%s\"",gdk_atom_name(selection_data->selection));
1048
1049         Gtk::TreeModel::Path path;
1050         Gtk::TreeViewColumn *column;
1051         int cell_x, cell_y;
1052         if(get_selection()
1053         Gtk::TreeRow row = *(get_selection()->get_selected());
1054
1055         if(synfig::String(gdk_atom_name(selection_data->target))=="LAYER" && (bool)row[model.is_layer])
1056         {
1057                 Layer* layer(((Layer::Handle)row[model.layer]).get());
1058                 assert(layer);
1059                 selection_data.set(8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
1060                 return;
1061         }
1062 }
1063
1064 void
1065 LayerTree::on_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, Gtk::SelectionData& selection_data, guint info, guint time)
1066 {
1067         synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
1068         synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
1069         synfig::info("Dropped selection=\"%s\"",gdk_atom_name(selection_data->selection));
1070         synfig::info("Dropped x=%d, y=%d",x,y);
1071         bool success=false;
1072         bool dropped_on_specific_row=false;
1073
1074         Gtk::TreeModel::Path path;
1075         Gtk::TreeViewColumn *column;
1076         int cell_x, cell_y;
1077         if(!get_path_at_pos(
1078                 x,y,    // x, y
1079                 path, // TreeModel::Path&
1080                 column, //TreeViewColumn*&
1081                 cell_x,cell_y //int&cell_x,int&cell_y
1082                 )
1083         )
1084         {
1085                 dropped_on_specific_row=false;
1086         }
1087         else
1088                 dropped_on_specific_row=true;
1089
1090         Gtk::TreeRow row = *(get_model()->get_iter(path));
1091
1092         if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
1093         {
1094                 if(synfig::String(selection_data.get_data_type())=="LAYER")do
1095                 {
1096                         Layer::Handle src(*reinterpret_cast<Layer**>(selection_data.get_data()));
1097                         assert(src);
1098
1099                         Canvas::Handle dest_canvas;
1100                         Layer::Handle dest_layer;
1101
1102                         if(dropped_on_specific_row)
1103                         {
1104                                 dest_canvas=(Canvas::Handle)(row[model.canvas]);
1105                                 dest_layer=(Layer::Handle)(row[model.layer]);
1106                                 assert(dest_canvas);
1107                         }
1108                         else
1109                                 dest_canvas=layer_tree_store_->canvas_interface()->get_canvas();
1110
1111                         // In this case, we are just moving.
1112                         if(dest_canvas==src->get_canvas())
1113                         {
1114                                 if(!dest_layer || dest_layer==src)
1115                                         break;
1116
1117                                 synfigapp::Action::Handle action(synfigapp::Action::create("layer_move"));
1118                                 action->set_param("canvas",dest_canvas);
1119                                 action->set_param("canvas_interface",layer_tree_store_->canvas_interface());
1120                                 action->set_param("layer",src);
1121                                 action->set_param("new_index",dest_canvas->get_depth(dest_layer));
1122                                 if(layer_tree_store_->canvas_interface()->get_instance()->perform_action(action))
1123                                         success=true;
1124                                 else
1125                                         success=false;
1126                                 break;
1127                         }
1128                 }while(0);
1129         }
1130
1131         // Finish the drag
1132         context->drag_finish(success, false, time);
1133 }
1134 */
1135
1136 /*bool
1137 LayerTree::on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context,int x, int    y, guint    time)
1138 {
1139         return get_layer_tree_view().on_drag_motion(context,x,y,time);
1140 }
1141
1142 void
1143 LayerTree::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, Gtk::SelectionData& selection_data, guint info, guint time)
1144 {
1145         get_layer_tree_view().on_drag_data_received(context,x,y,selection_data,info,time);
1146 */
1147 /*
1148         if(context->gobj()->source_window==context->gobj()->dest_window)
1149         {
1150                 Gtk::TreeView::on_drag_data_received(context,x,y,selection_data,info,time);
1151                 return;
1152         }
1153
1154         Gtk::TreeModel::Path path;
1155         Gtk::TreeViewColumn *column;
1156         int cell_x, cell_y;
1157         if(!get_path_at_pos(
1158                 x,y,    // x, y
1159                 path, // TreeModel::Path&
1160                 column, //TreeViewColumn*&
1161                 cell_x,cell_y //int&cell_x,int&cell_y
1162                 )
1163         )
1164         {
1165                 context->drag_finish(false, false, time);
1166         }
1167
1168         if(layer_tree_store_->row_drop_possible(path,selection_data))
1169         {
1170                 if(layer_tree_store_->drag_data_received(path,selection_data))
1171                         context->drag_finish(true, false, time);
1172         }
1173         context->drag_finish(false, false, time);
1174 }
1175 */