1 /* === S Y N F I G ========================================================= */
2 /*! \file dock_keyframes.cpp
3 ** \brief Template File
5 ** $Id: dock_keyframes.cpp,v 1.3 2005/01/13 20:23:01 darco Exp $
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
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.
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.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "dock_keyframes.h"
35 #include <gtkmm/scrolledwindow.h>
38 #include <sigc++/signal.h>
39 #include <sigc++/hide.h>
40 #include <sigc++/slot.h>
41 #include "keyframetreestore.h"
42 #include "keyframetree.h"
43 #include "canvasview.h"
44 #include "keyframeactionmanager.h"
48 /* === U S I N G =========================================================== */
52 using namespace synfig;
53 using namespace studio;
55 /* === M A C R O S ========================================================= */
57 /* === G L O B A L S ======================================================= */
59 /* === P R O C E D U R E S ================================================= */
61 /* === M E T H O D S ======================================================= */
63 Dock_Keyframes::Dock_Keyframes():
64 Dock_CanvasSpecific("keyframes",_("Keyframes"),Gtk::StockID("synfig-keyframes")),
65 action_group(Gtk::ActionGroup::create()),
66 keyframe_action_manager(new KeyframeActionManager)
68 keyframe_action_manager->set_ui_manager(App::ui_manager());
69 keyframe_action_manager->signal_show_keyframe_properties().connect(
70 sigc::mem_fun(*this,&Dock_Keyframes::show_keyframe_properties)
73 Gtk::StockID("gtk-add"),
74 _("Inserts a Keyframe at the current time")
75 )->signal_clicked().connect(
78 &Dock_Keyframes::add_keyframe_pressed
83 Gtk::StockID("synfig-duplicate"),
84 _("Duplicates the selected keyframe at the current time")
85 )->signal_clicked().connect(
88 &Dock_Keyframes::duplicate_keyframe_pressed
93 Gtk::StockID("gtk-delete"),
94 _("Deletes the selected Keyframe")
95 )->signal_clicked().connect(
98 &Dock_Keyframes::delete_keyframe_pressed
102 Glib::ustring ui_info =
104 " <toolbar action='toolbar-keyframe'>"
105 " <toolitem action='action-keyframe_add' />"
106 " <toolitem action='action-keyframe_duplicate' />"
107 " <toolitem action='action-keyframe_remove' />"
108 " <toolitem action='keyframe-properties' />"
113 App::ui_manager()->add_ui_from_string(ui_info);
115 set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-keyframe")));
118 Dock_Keyframes::~Dock_Keyframes()
123 Dock_Keyframes::show_keyframe_properties()
125 if(get_canvas_view())
126 get_canvas_view()->show_keyframe_dialog();
131 Dock_Keyframes::add_keyframe_pressed()
133 if(get_canvas_view())
134 get_canvas_view()->on_keyframe_add_pressed();
138 Dock_Keyframes::duplicate_keyframe_pressed()
140 if(get_canvas_view())
141 get_canvas_view()->on_keyframe_duplicate_pressed();
145 Dock_Keyframes::delete_keyframe_pressed()
147 if(get_canvas_view())
148 get_canvas_view()->on_keyframe_remove_pressed();
153 Dock_Keyframes::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
155 Glib::RefPtr<KeyframeTreeStore> keyframe_tree_store;
156 keyframe_tree_store=KeyframeTreeStore::create(canvas_view->canvas_interface());
158 KeyframeTree* keyframe_tree(new KeyframeTree());
159 keyframe_tree->set_model(keyframe_tree_store);
160 keyframe_tree->set_editable(true);
162 canvas_view->set_tree_model(get_name(),keyframe_tree_store);
163 canvas_view->set_ext_widget(get_name(),keyframe_tree);
167 Dock_Keyframes::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
171 Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
176 keyframe_action_manager->set_keyframe_tree(dynamic_cast<KeyframeTree*>(canvas_view->get_ext_widget(get_name())));
177 keyframe_action_manager->set_canvas_interface(canvas_view->canvas_interface());
178 keyframe_action_manager->refresh();
184 keyframe_action_manager->set_keyframe_tree(0);
185 keyframe_action_manager->set_canvas_interface(0);
186 keyframe_action_manager->refresh();