X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fwidget_timeslider.cpp;h=651cbe0ac879ea60f366922e1f50c386d94c6464;hb=b6c331ec41a1788c39606b9c398a25f801bacb4a;hp=d350d4a32c668a85f2c585b510ae7abfd518ad4b;hpb=700213b0555c6bba0fb82197cc18dd6322384762;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/widget_timeslider.cpp b/synfig-studio/trunk/src/gtkmm/widget_timeslider.cpp index d350d4a..651cbe0 100644 --- a/synfig-studio/trunk/src/gtkmm/widget_timeslider.cpp +++ b/synfig-studio/trunk/src/gtkmm/widget_timeslider.cpp @@ -6,6 +6,7 @@ ** ** \legal ** Copyright (c) 2004 Adrian Bentley +** Copyright (c) 2007 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -35,6 +36,8 @@ #include +#include "general.h" + #endif /* === U S I N G =========================================================== */ @@ -202,7 +205,7 @@ studio::render_time_point_to_window( points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y())); points.push_back(Gdk::Point(area.get_x()+area.get_width()/3,area.get_y())); points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()/3)); - points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()*2/3)); + points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()-area.get_height()/3)); points.push_back(Gdk::Point(area.get_x()+area.get_width()/3,area.get_y()+area.get_height())); points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height())); window->draw_polygon(gc,true,points); @@ -284,8 +287,8 @@ studio::render_time_point_to_window( points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y())); points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y())); points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()/2)); - points.push_back(Gdk::Point(area.get_x()+area.get_width()*3/4,area.get_y()+area.get_height()/2)); - points.push_back(Gdk::Point(area.get_x()+area.get_width()*3/4,area.get_y()+area.get_height())); + points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/4,area.get_y()+area.get_height()/2)); + points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/4,area.get_y()+area.get_height())); points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height())); window->draw_polygon(gc,true,points); gc->set_rgb_fg_color(black); @@ -295,10 +298,10 @@ studio::render_time_point_to_window( case INTERPOLATION_UNDEFINED: default: points.clear(); points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y())); - points.push_back(Gdk::Point(area.get_x()+area.get_width()*2/3,area.get_y())); + points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/3,area.get_y())); points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()/3)); - points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()*2/3)); - points.push_back(Gdk::Point(area.get_x()+area.get_width()*2/3,area.get_y()+area.get_height())); + points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()-area.get_height()/3)); + points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/3,area.get_y()+area.get_height())); points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height())); window->draw_polygon(gc,true,points); gc->set_rgb_fg_color(black); @@ -311,7 +314,7 @@ studio::render_time_point_to_window( /* === M E T H O D S ======================================================= */ /* === E N T R Y P O I N T ================================================= */ -double defaultfps = 0; +double defaultfps = 24; const int fullheight = 20; Widget_Timeslider::Widget_Timeslider() @@ -402,7 +405,7 @@ void Widget_Timeslider::refresh() } }*/ -bool Widget_Timeslider::redraw(bool doublebuffer) +bool Widget_Timeslider::redraw(bool /*doublebuffer*/) { Glib::RefPtr window = get_window(); @@ -494,7 +497,7 @@ bool Widget_Timeslider::redraw(bool doublebuffer) //search around this area to get the right one - //get first valid line and it's position in pixel space + //get first valid line and its position in pixel space double time = 0; double pixel = 0; @@ -502,7 +505,7 @@ bool Widget_Timeslider::redraw(bool doublebuffer) double subr = scale / subdiv; - //get it's position inside... + //get its position inside... time = ceil(start/subr)*subr - start; pixel = time*dpdt; @@ -704,7 +707,42 @@ bool Widget_Timeslider::on_scroll_event(GdkEventScroll* event) //for zooming return true; } + + case GDK_SCROLL_RIGHT: + case GDK_SCROLL_LEFT: + { + double t = adj_timescale->get_value(); + double start = adj_timescale->get_lower(); + double end = adj_timescale->get_upper(); + /* + FIXME: be more intelligent about how far to scroll + Perhaps it should be based on the tickmarks? + for e.g. 1/4 of a tick mark per scroll event + Obviously this would need post-rounding to 1/fps + */ + double adj = 1.0/fps; + + if( event->direction == GDK_SCROLL_RIGHT ) + t += adj; + else + t -= adj; + + if( t < start ){ + adj_timescale->set_lower(t); + adj_timescale->set_upper(t+end-start); + } else if( t > end ){ + adj_timescale->set_upper(t); + adj_timescale->set_lower(t-end+start); + } + if(adj_timescale) + { + adj_timescale->set_value(t); + adj_timescale->value_changed(); + } + return true; + } + default: { return false;