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