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