my log
[synfig.git] / synfig-studio / trunk / src / gtkmm / dock_canvasspecific.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file dock_canvasspecific.cpp
3 **      \brief Template File
4 **
5 **      $Id: dock_canvasspecific.cpp,v 1.3 2005/01/13 20:23:01 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002 Robert B. Quattlebaum Jr.
9 **
10 **      This software and associated documentation
11 **      are CONFIDENTIAL and PROPRIETARY property of
12 **      the above-mentioned copyright holder.
13 **
14 **      You may not copy, print, publish, or in any
15 **      other way distribute this software without
16 **      a prior written agreement with
17 **      the copyright holder.
18 **      \endlegal
19 */
20 /* ========================================================================= */
21
22 /* === H E A D E R S ======================================================= */
23
24 #ifdef USING_PCH
25 #       include "pch.h"
26 #else
27 #ifdef HAVE_CONFIG_H
28 #       include <config.h>
29 #endif
30
31 #include "app.h"
32 #include "dock_canvasspecific.h"
33
34 #include <gtkmm/scrolledwindow.h>
35 #include <cassert>
36 #include "instance.h"
37 #include <sigc++/signal.h>
38 #include <sigc++/adaptors/hide.h>
39 //#include <sigc++/hide.h>
40 #include <sigc++/slot.h>
41 #include "metadatatreestore.h"
42 #include "canvasview.h"
43 #include <ETL/clock>
44
45 #endif
46
47 /* === U S I N G =========================================================== */
48
49 using namespace std;
50 using namespace etl;
51 using namespace synfig;
52 using namespace studio;
53
54 /* === M A C R O S ========================================================= */
55
56 /* === G L O B A L S ======================================================= */
57
58 /* === P R O C E D U R E S ================================================= */
59
60 /* === M E T H O D S ======================================================= */
61
62 Dock_CanvasSpecific::Dock_CanvasSpecific(const synfig::String& name,const synfig::String& local_name,Gtk::StockID stock_id_):
63         Dockable(name,local_name,stock_id_)
64 {
65         App::signal_instance_created().connect(sigc::mem_fun(*this,&Dock_CanvasSpecific::init_instance));
66 }
67
68 Dock_CanvasSpecific::~Dock_CanvasSpecific()
69 {
70 }
71
72 etl::loose_handle<studio::CanvasView>
73 Dock_CanvasSpecific::get_canvas_view()
74 {
75         return App::get_selected_canvas_view();
76 }
77
78 etl::loose_handle<synfigapp::CanvasInterface>
79 Dock_CanvasSpecific::get_canvas_interface()
80 {
81         if(get_canvas_view())
82                 return get_canvas_view()->canvas_interface();
83         return 0;
84 }
85
86 void
87 Dock_CanvasSpecific::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
88 {
89 }
90
91 void
92 Dock_CanvasSpecific::init_instance_vfunc(etl::loose_handle<Instance> instance)
93 {
94 }
95
96 void
97 Dock_CanvasSpecific::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
98 {
99 }
100
101 void
102 Dock_CanvasSpecific::init_instance(etl::handle<Instance> instance)
103 {
104         etl::clock timer;timer.reset();
105         instance->signal_canvas_view_created().connect(sigc::mem_fun(*this,&Dock_CanvasSpecific::init_canvas_view));
106         init_instance_vfunc(instance);
107         synfig::info("%s init_instance() took %f seconds",get_local_name().c_str(),float(timer()));
108 }
109
110 void
111 Dock_CanvasSpecific::delete_instance(etl::handle<Instance> instance)
112 {
113         changed_canvas_view_vfunc(0);
114 }
115
116 void
117 Dock_CanvasSpecific::init_canvas_view(CanvasView* canvas_view)
118 {
119         /*
120         canvas_view->signal_focus_in_event().connect(
121                 sigc::hide(
122                         sigc::bind_return(
123                                 sigc::mem_fun(
124                                         *this,
125                                         &Dock_CanvasSpecific::canvas_view_changed
126                                 ),
127                                 false
128                         )
129                 )       
130         );
131         */
132         synfig::info("%s init_canvas_view() Starting init...",get_local_name().c_str());
133         etl::clock timer;timer.reset();
134         App::signal_canvas_view_focus().connect(
135                 sigc::hide(
136                         sigc::mem_fun(
137                                 *this,
138                                 &Dock_CanvasSpecific::canvas_view_changed
139                         )
140                 )
141         );
142         init_canvas_view_vfunc(canvas_view);
143         synfig::info("%s init_canvas_view() took %f seconds",get_local_name().c_str(),float(timer()));
144 }
145
146 void
147 Dock_CanvasSpecific::canvas_view_changed()
148 {
149         etl::loose_handle<CanvasView> canvas_view(App::get_selected_canvas_view());
150 /*      if(canvas_view)
151         {
152                 canvas_delete_connection.disconnect();
153                 canvas_delete_connection=canvas_view->signal_deleted().connect(
154                         sigc::bind(
155                                 sigc::mem_fun(
156                                         *this,
157                                         &Dock_CanvasSpecific::changed_canvas_view
158                                 ),
159                                 etl::loose_handle<CanvasView>(0)
160                         )
161                 );
162         }
163 */
164         
165 #ifdef _DEBUG
166         synfig::info("%s canvas_view_changed: start",get_local_name().c_str());
167 #endif
168         changed_canvas_view_vfunc(canvas_view);
169 #ifdef _DEBUG
170         synfig::info("%s canvas_view_changed: end",get_local_name().c_str());
171 #endif
172 }