From: Carlos Lopez Date: Fri, 17 Jul 2009 18:56:26 +0000 (+0200) Subject: Added code to fix the shown of the keyfrmae list widget. It is not fully working... X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=dd3f7a1496c6ac179f17ca1d940cc4310333891e;p=synfig.git Added code to fix the shown of the keyfrmae list widget. It is not fully working at the moment. --- diff --git a/synfig-studio/trunk/src/gtkmm/dock_timetrack.cpp b/synfig-studio/trunk/src/gtkmm/dock_timetrack.cpp index f8a8feb..7f0c253 100644 --- a/synfig-studio/trunk/src/gtkmm/dock_timetrack.cpp +++ b/synfig-studio/trunk/src/gtkmm/dock_timetrack.cpp @@ -505,7 +505,7 @@ Dock_Timetrack::changed_canvas_view_vfunc(etl::loose_handle canvas_v 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_kf_list(&canvas_view->get_canvas()->keyframe_list()); 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 e0669c4..835f814 100644 --- a/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.cpp +++ b/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.cpp @@ -60,7 +60,8 @@ Widget_Keyframe_List::Widget_Keyframe_List(): editable_(true), adj_default(0,0,2,1/24,10/24), adj_timescale(0), - fps(24) + fps(24), + kf_list_(&default_kf_list_) { set_size_request(-1,64); //!This signal is called when the widget need to be redrawn @@ -80,6 +81,7 @@ Widget_Keyframe_List::~Widget_Keyframe_List() bool Widget_Keyframe_List::redraw(GdkEventExpose */*bleh*/) { + if (kf_list_->empty()) return false; const int h(get_height()); const int w(get_width()); @@ -98,13 +100,13 @@ Widget_Keyframe_List::redraw(GdkEventExpose */*bleh*/) } //! draw a background - gc->set_rgb_fg_color(Gdk::Color("#7f7f7f")); - get_window()->draw_rectangle(gc, false, 0, 0, w, h); + gc->set_rgb_fg_color(Gdk::Color("#FF0000")); + get_window()->draw_rectangle(gc, true, 0, 0, w, h); //!Loop all the keyframes synfig::KeyframeList::iterator iter,selected_iter; bool show_selected(false); - for(iter=kf_list_.begin();iter!=kf_list_.end();iter++) + for(iter=kf_list_->begin();iter!=kf_list_->end();iter++) { //!do not draw keyframes out of the widget boundaries if (iter->get_time()>top || iter->get_time()size()) + set_selected_keyframe(*kf_list_->find_next(synfig::Time::zero())); } void @@ -174,13 +176,21 @@ Widget_Keyframe_List::on_event(GdkEvent *event) if(pos>1.0f)pos=1.0f; //! The time where the event x is synfig::Time t((float)(pos*(top-bottom))); - //! here the guts of the event + + //Do not respond mouse events if the list is empty + if(!kf_list_->size()) + { + synfig::info("Keyframe list empty"); + return true; + } + + //! here the guts of the event switch(event->type) { case GDK_MOTION_NOTIFY: if(editable_) { - if(!kf_list_.size()) return true; + // stick to integer frames. if(fps) { @@ -195,10 +205,12 @@ Widget_Keyframe_List::on_event(GdkEvent *event) changed_=false; if(event->button.button==1) { + synfig::info("Looking keyframe at %s", t.get_string().c_str()); + synfig::info("Total amount of keyframes %i", kf_list_->size()); if(editable_) { synfig::KeyframeList::iterator selected; - selected = kf_list_.find_next(t); + selected = kf_list_->find_next(t); set_selected_keyframe(*selected); queue_draw(); return true; diff --git a/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.h b/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.h index 2acef1c..8796beb 100644 --- a/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.h +++ b/synfig-studio/trunk/src/gtkmm/widget_keyframe_list.h @@ -49,7 +49,8 @@ class Widget_Keyframe_List : public Gtk::DrawingArea Gtk::Adjustment *adj_timescale; //!The list of keyframes to be drawn on the widget and moved with mouse - synfig::KeyframeList kf_list_; + synfig::KeyframeList default_kf_list_; + mutable synfig::KeyframeList* kf_list_; //! The frames per second of the canvas float fps; @@ -85,10 +86,10 @@ public: ~Widget_Keyframe_List(); //!Loads a new keyframe list on the widget. - void set_kf_list(const synfig::KeyframeList& x); + void set_kf_list(synfig::KeyframeList* x); //!Member for private data. - const synfig::KeyframeList& get_kf_list()const { return kf_list_; } + synfig::KeyframeList* get_kf_list()const { return kf_list_; } //!Member for private data void set_editable(bool x=true) { editable_=x; }