1 /* === S Y N F I G ========================================================= */
2 /*! \file dock_keyframes.cpp
3 ** \brief Template File
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"
50 /* === U S I N G =========================================================== */
54 using namespace synfig;
55 using namespace studio;
57 /* === M A C R O S ========================================================= */
59 /* === G L O B A L S ======================================================= */
61 /* === P R O C E D U R E S ================================================= */
63 /* === M E T H O D S ======================================================= */
65 Dock_Keyframes::Dock_Keyframes():
66 Dock_CanvasSpecific("keyframes",_("Keyframes"),Gtk::StockID("synfig-keyframes")),
67 action_group(Gtk::ActionGroup::create("action_group_dock_keyframes")),
68 keyframe_action_manager(new KeyframeActionManager)
70 keyframe_action_manager->set_ui_manager(App::ui_manager());
71 keyframe_action_manager->signal_show_keyframe_properties().connect(
72 sigc::mem_fun(*this,&Dock_Keyframes::show_keyframe_properties)
75 Gtk::StockID("gtk-add"),
76 _("Inserts a Keyframe at the current time")
77 )->signal_clicked().connect(
80 &Dock_Keyframes::add_keyframe_pressed
85 Gtk::StockID("synfig-duplicate"),
86 _("Duplicates the selected keyframe at the current time")
87 )->signal_clicked().connect(
90 &Dock_Keyframes::duplicate_keyframe_pressed
95 Gtk::StockID("gtk-delete"),
96 _("Deletes the selected Keyframe")
97 )->signal_clicked().connect(
100 &Dock_Keyframes::delete_keyframe_pressed
104 Glib::ustring ui_info =
106 " <toolbar action='toolbar-keyframe'>"
107 " <toolitem action='action-KeyframeAdd' />"
108 " <toolitem action='action-KeyframeDuplicate' />"
109 " <toolitem action='action-KeyframeRemove' />"
110 " <toolitem action='keyframe-properties' />"
115 App::ui_manager()->add_ui_from_string(ui_info);
117 set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-keyframe")));
120 Dock_Keyframes::~Dock_Keyframes()
125 Dock_Keyframes::show_keyframe_properties()
127 if(get_canvas_view())
128 get_canvas_view()->show_keyframe_dialog();
133 Dock_Keyframes::add_keyframe_pressed()
135 if(get_canvas_view())
136 get_canvas_view()->on_keyframe_add_pressed();
140 Dock_Keyframes::duplicate_keyframe_pressed()
142 if(get_canvas_view())
143 get_canvas_view()->on_keyframe_duplicate_pressed();
147 Dock_Keyframes::delete_keyframe_pressed()
149 if(get_canvas_view())
150 get_canvas_view()->on_keyframe_remove_pressed();
155 Dock_Keyframes::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
157 Glib::RefPtr<KeyframeTreeStore> keyframe_tree_store;
158 keyframe_tree_store=KeyframeTreeStore::create(canvas_view->canvas_interface());
160 KeyframeTree* keyframe_tree(new KeyframeTree());
161 keyframe_tree->set_model(keyframe_tree_store);
162 keyframe_tree->set_editable(true);
164 canvas_view->set_tree_model(get_name(),keyframe_tree_store);
165 canvas_view->set_ext_widget(get_name(),keyframe_tree);
169 Dock_Keyframes::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
173 Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
178 keyframe_action_manager->set_keyframe_tree(dynamic_cast<KeyframeTree*>(canvas_view->get_ext_widget(get_name())));
179 keyframe_action_manager->set_canvas_interface(canvas_view->canvas_interface());
180 keyframe_action_manager->refresh();
186 keyframe_action_manager->set_keyframe_tree(0);
187 keyframe_action_manager->set_canvas_interface(0);
188 keyframe_action_manager->refresh();