widget_timeslider_->set_global_fps(canvas_view->get_canvas()->rend_desc().get_frame_rate());
widget_kf_list_->set_time_adjustment(&canvas_view->time_adjustment());
- widget_kf_list_->set_fps(canvas_view->get_canvas()->rend_desc().get_frame_rate());
- widget_kf_list_->set_kf_list(&canvas_view->get_canvas()->keyframe_list());
+ widget_kf_list_->set_canvas_interface(canvas_view->canvas_interface());
vscrollbar_->set_adjustment(*tree_view->get_vadjustment());
hscrollbar_->set_adjustment(canvas_view->time_window_adjustment());
using namespace synfig;
using namespace studio;
+
/* === M A C R O S ========================================================= */
/* === G L O B A L S ======================================================= */
Widget_Keyframe_List::set_kf_list(synfig::KeyframeList* x)
{
kf_list_=x;
- if(kf_list_->size())
- set_selected_keyframe(selected_none);
+ set_selected_keyframe(selected_none);
+ selected_=false;
+ dragging_=false;
}
void
Widget_Keyframe_List::set_selected_keyframe(const synfig::Keyframe &x)
{
selected_kf=x;
+ selected_=true;
dragging_kf_time=selected_kf.get_time();
//signal_keyframe_selected_(selected_kf);
+ dragging_=false;
queue_draw();
}
bool
Widget_Keyframe_List::perform_move_kf()
{
- return false;
+ if(!selected_)
+ return false;
+ if(dragging_kf_time == selected_kf.get_time())
+ return false;
+ synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSet"));
+ if(!action)
+ return false;
+ selected_kf.set_time(dragging_kf_time);
+ action->set_param("canvas",canvas_interface_->get_canvas());
+ action->set_param("canvas_interface",canvas_interface_);
+ action->set_param("keyframe",selected_kf);
+ //synfig::info("DELTA: %s", (dragging_kf_time-selected_kf.get_time()).get_string().c_str());
+ try
+ {
+ canvas_interface_->get_instance()->perform_action(action);
+ }
+ catch(...)
+ {
+ return false;
+ }
+ queue_draw();
+ return true;
}
bool
)
{
set_selected_keyframe(selected_none);
+ selected_=false;
synfig::info("Selected keyframe set to none");
synfig::info("Distance to prev %s", (t-prev_t).get_string().c_str());
synfig::info("Distance to next %s", (next_t-t).get_string().c_str());
set_selected_keyframe(*(kf_list_->find_prev(t)));
synfig::info("Selected keyframe set to previous");
queue_draw();
+ selected_=true;
return true;
}
else
set_selected_keyframe(*(kf_list_->find_next(t)));
synfig::info("Selected keyframe set to next");
queue_draw();
+ selected_=true;
return true;
}
{
t = floor(t*fps + 0.5)/fps;
}
- bool stat=perform_move_kf();
+ bool stat=false;
+ if(dragging_)
+ stat=perform_move_kf();
dragging_=false;
synfig::info("Dropping keyframe time at: %s", t.get_string().c_str());
+ synfig::info("perform move result: %i", stat);
return stat;
}
default:
queue_draw();
}
}
+
+void
+Widget_Keyframe_List::set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h)
+{
+ canvas_interface_=h;
+ if (canvas_interface_)
+ {
+ set_fps(canvas_interface_->get_canvas()->rend_desc().get_frame_rate());
+ set_kf_list(&canvas_interface_->get_canvas()->keyframe_list());
+ }
+}
+
+
#include <gtkmm/adjustment.h>
#include <synfig/keyframe.h>
#include <sigc++/connection.h>
+#include <synfigapp/canvasinterface.h>
/* === M A C R O S ========================================================= */
class Widget_Keyframe_List : public Gtk::DrawingArea
{
+ //! The canvas interface being watched
+ etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
+
//! Time adjustment window
Gtk::Adjustment adj_default;
Gtk::Adjustment *adj_timescale;
//!Holds the selected keyframe of the keyframe list
synfig::Keyframe selected_kf;
synfig::Keyframe selected_none;
+ bool selected_;
//!The time of the selected keyframe
synfig::Time selected_kf_time;
//! Set the fps
void set_fps(float x);
+ //! Set the canvas interface
+ void set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h);
+
//! Performs the keyframe movement. Returns true if it was sucessful
bool perform_move_kf();
}; // END of namespace studio
+
/* === E N D =============================================================== */
#endif