Module: synfig Branch: genete_master Commit: b5c3d66d7714b6a2b6a10eb968206c6a46b0f026 URL: http://synfig.git.sourceforge.net/git/gitweb.cgi?p=synfig;a=commit;h=b5c3d66d7714b6a2b6a10eb968206c6a46b0f026
Author: Carlos Lopez <car...@pcnuevo.(none)> Date: Sat Jul 18 12:44:52 2009 +0200 Now the widget is fully working. Need a place to be stored and better size. --- synfig-studio/trunk/src/gtkmm/dock_timetrack.cpp | 3 +- .../trunk/src/gtkmm/widget_keyframe_list.cpp | 52 ++++++++++++++++++-- .../trunk/src/gtkmm/widget_keyframe_list.h | 9 +++ 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/synfig-studio/trunk/src/gtkmm/dock_timetrack.cpp b/synfig-studio/trunk/src/gtkmm/dock_timetrack.cpp index 7f0c253..c13bb71 100644 --- a/synfig-studio/trunk/src/gtkmm/dock_timetrack.cpp +++ b/synfig-studio/trunk/src/gtkmm/dock_timetrack.cpp @@ -504,8 +504,7 @@ Dock_Timetrack::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_v 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()); diff --git a/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.cpp b/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.cpp index dba098d..9ab98ba 100644 --- a/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.cpp +++ b/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.cpp @@ -48,6 +48,7 @@ using namespace etl; using namespace synfig; using namespace studio; + /* === M A C R O S ========================================================= */ /* === G L O B A L S ======================================================= */ @@ -165,23 +166,47 @@ void 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 @@ -243,6 +268,7 @@ Widget_Keyframe_List::on_event(GdkEvent *event) ) { 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()); @@ -254,6 +280,7 @@ Widget_Keyframe_List::on_event(GdkEvent *event) set_selected_keyframe(*(kf_list_->find_prev(t))); synfig::info("Selected keyframe set to previous"); queue_draw(); + selected_=true; return true; } else @@ -261,6 +288,7 @@ Widget_Keyframe_List::on_event(GdkEvent *event) set_selected_keyframe(*(kf_list_->find_next(t))); synfig::info("Selected keyframe set to next"); queue_draw(); + selected_=true; return true; } @@ -280,9 +308,12 @@ Widget_Keyframe_List::on_event(GdkEvent *event) { 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: @@ -320,3 +351,16 @@ Widget_Keyframe_List::set_fps(float d) 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()); + } +} + + diff --git a/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.h b/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.h index b42127d..4280a69 100644 --- a/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.h +++ b/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.h @@ -32,6 +32,7 @@ #include <gtkmm/adjustment.h> #include <synfig/keyframe.h> #include <sigc++/connection.h> +#include <synfigapp/canvasinterface.h> /* === M A C R O S ========================================================= */ @@ -44,6 +45,9 @@ namespace studio { 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; @@ -70,6 +74,7 @@ class Widget_Keyframe_List : public Gtk::DrawingArea //!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; @@ -114,6 +119,9 @@ public: //! 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(); @@ -129,6 +137,7 @@ public: }; // END of namespace studio + /* === E N D =============================================================== */ #endif ------------------------------------------------------------------------------ _______________________________________________ Synfig-devl mailing list Synfig-devl@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/synfig-devl