**
** \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
#include <cmath>
+#include "general.h"
+
#endif
/* === U S I N G =========================================================== */
static Gdk::Color
color_darken(Gdk::Color x, float amount)
{
- x.set_rgb_p(
- x.get_red_p()*amount,
- x.get_green_p()*amount,
- x.get_blue_p()*amount
- );
+ double red = x.get_red_p() * amount;
+ double green = x.get_green_p() * amount;
+ double blue = x.get_blue_p() * amount;
+
+ x.set_rgb_p( red > 1 ? 1 : red,
+ green > 1 ? 1 : green,
+ blue > 1 ? 1 : blue);
+
return x;
}
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);
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);
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);
/* === 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()
}
}*/
-bool Widget_Timeslider::redraw(bool doublebuffer)
+bool Widget_Timeslider::redraw(bool /*doublebuffer*/)
{
Glib::RefPtr<Gdk::Window> window = get_window();
//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;
double subr = scale / subdiv;
- //get it's position inside...
+ //get its position inside...
time = ceil(start/subr)*subr - start;
pixel = time*dpdt;
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;