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