Improve the logic for when to use the tile renderer. At lower resolutions we can...
[synfig.git] / synfig-studio / trunk / src / gtkmm / widget_timeslider.cpp
index a171c11..651cbe0 100644 (file)
@@ -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 <cmath>
 
+#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);
@@ -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;