1 /* === S I N F G =========================================================== */
2 /*! \file keyframeactionmanager.cpp
3 ** \brief Template File
5 ** $Id: keyframeactionmanager.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
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.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include "keyframeactionmanager.h"
32 #include "keyframetree.h"
33 #include <sinfgapp/action_param.h>
38 /* === U S I N G =========================================================== */
42 using namespace sinfg;
43 using namespace studio;
45 static const guint no_prev_popup((guint)-1);
47 /* === M A C R O S ========================================================= */
49 //#define ONE_ACTION_GROUP 1
51 /* === G L O B A L S ======================================================= */
53 /* === P R O C E D U R E S ================================================= */
55 /* === M E T H O D S ======================================================= */
57 KeyframeActionManager::KeyframeActionManager():
58 action_group_(Gtk::ActionGroup::create()),
59 popup_id_(no_prev_popup),
64 KeyframeActionManager::~KeyframeActionManager()
69 KeyframeActionManager::set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x)
73 #ifdef ONE_ACTION_GROUP
74 if(ui_manager_) get_ui_manager()->remove_action_group(action_group_);
76 if(ui_manager_) get_ui_manager()->insert_action_group(action_group_);
83 KeyframeActionManager::set_keyframe_tree(KeyframeTree* x)
85 selection_changed_connection.disconnect();
89 selection_changed_connection=keyframe_tree_->get_selection()->signal_changed().connect(
90 sigc::mem_fun(*this,&KeyframeActionManager::queue_refresh)
96 KeyframeActionManager::set_canvas_interface(const etl::handle<sinfgapp::CanvasInterface> &x)
98 time_changed_connection.disconnect();
100 if(canvas_interface_)
102 canvas_interface_->signal_time_changed().connect(
103 sigc::mem_fun(*this,&KeyframeActionManager::queue_refresh)
109 KeyframeActionManager::clear()
113 // Clear out old stuff
114 if(popup_id_!=no_prev_popup)
116 get_ui_manager()->remove_ui(popup_id_);
117 popup_id_=no_prev_popup;
118 #ifdef ONE_ACTION_GROUP
119 while(!action_group_->get_actions().empty())action_group_->remove(*action_group_->get_actions().begin());
121 get_ui_manager()->remove_action_group(action_group_);
122 action_group_=Gtk::ActionGroup::create();
129 KeyframeActionManager::queue_refresh()
134 //queue_refresh_connection.disconnect();
135 queue_refresh_connection=Glib::signal_idle().connect(
137 sigc::mem_fun(*this,&KeyframeActionManager::refresh),
146 KeyframeActionManager::on_keyframe_properties()
148 signal_show_keyframe_properties_();
152 KeyframeActionManager::on_add_keyframe()
154 sinfgapp::Action::Handle action(sinfgapp::Action::create("keyframe_add"));
159 action->set_param("canvas",canvas_interface_->get_canvas());
160 action->set_param("canvas_interface",canvas_interface_);
161 action->set_param("keyframe",Keyframe(canvas_interface_->get_time()));
163 canvas_interface_->get_instance()->perform_action(action);
167 KeyframeActionManager::refresh()
169 KeyframeTreeStore::Model model;
174 //queue_refresh_connection.disconnect();
180 // Make sure we are ready
181 if(!ui_manager_ || !keyframe_tree_ || !canvas_interface_)
183 sinfg::error("KeyframeActionManager::refresh(): Not ready!");
190 sinfgapp::Action::ParamList param_list;
191 param_list.add("time",get_canvas_interface()->get_time());
192 param_list.add("canvas",get_canvas_interface()->get_canvas());
193 param_list.add("canvas_interface",get_canvas_interface());
194 if(keyframe_tree_->get_selection()->count_selected_rows()==1)
196 Keyframe keyframe((*keyframe_tree_->get_selection()->get_selected())[model.keyframe]);
197 param_list.add("keyframe",keyframe);
200 handle<studio::Instance>::cast_static(
201 get_canvas_interface()->get_instance()
202 )->add_actions_to_group(
206 sinfgapp::Action::CATEGORY_KEYFRAME
209 if(action_group_->get_action("action-keyframe_add"))
211 action_group_->remove(action_group_->get_action("action-keyframe_add"));
214 action_group_->add(Gtk::Action::create(
215 "action-keyframe_add",
216 Gtk::StockID("gtk-add"),
217 _("Add new Keyframe"),_("Add new Keyframe")
219 sigc::mem_fun(*this,&KeyframeActionManager::on_add_keyframe)
224 canvas_interface_->get_canvas()->keyframe_list().find(canvas_interface_->get_time());
225 action_group_->get_action("action-keyframe_add")->set_sensitive(false);
226 if(action_group_->get_action("action-keyframe_duplicate"))
227 action_group_->get_action("action-keyframe_duplicate")->set_sensitive(false);
234 Glib::RefPtr<Gtk::Action> action(Gtk::Action::create("keyframe-properties", Gtk::StockID("gtk-properties"), _("Keyframe Properties")));
235 action_group_->add(action,sigc::mem_fun(*this,&KeyframeActionManager::on_keyframe_properties));
236 if(keyframe_tree_->get_selection()->count_selected_rows()==0)
237 action->set_sensitive(false);
240 ui_info="<ui><menubar action='menu-main'><menu action='menu-keyframe'>"+ui_info+"</menu></menubar></ui>";
241 popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
242 #ifdef ONE_ACTION_GROUP
244 get_ui_manager()->insert_action_group(action_group_);