2007-04-26 16:54:31 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2000-2007 Paul Davis
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2006-12-20 16:03:11 -05:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "panner.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2006-12-30 01:37:00 -05:00
|
|
|
static const int triangle_size = 5;
|
2006-12-20 16:03:11 -05:00
|
|
|
|
|
|
|
static void
|
|
|
|
null_label_callback (char* buf, unsigned int bufsize)
|
|
|
|
{
|
|
|
|
/* no label */
|
|
|
|
|
|
|
|
buf[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-29 00:02:58 -04:00
|
|
|
PannerBar::PannerBar (Gtk::Adjustment& adj, boost::shared_ptr<PBD::Controllable> c)
|
2008-09-10 11:03:30 -04:00
|
|
|
: BarController (adj, c, sigc::ptr_fun (null_label_callback))
|
2006-12-20 16:03:11 -05:00
|
|
|
{
|
2006-12-20 19:28:08 -05:00
|
|
|
set_style (BarController::Line);
|
2006-12-20 16:03:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
PannerBar::~PannerBar ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PannerBar::expose (GdkEventExpose* ev)
|
|
|
|
{
|
|
|
|
Glib::RefPtr<Gdk::Window> win (darea.get_window());
|
|
|
|
Glib::RefPtr<Gdk::GC> gc (get_style()->get_base_gc (get_state()));
|
|
|
|
|
|
|
|
BarController::expose (ev);
|
|
|
|
|
|
|
|
/* now draw triangles for left, right and center */
|
|
|
|
|
|
|
|
GdkPoint points[3];
|
|
|
|
|
2006-12-20 21:52:27 -05:00
|
|
|
// left
|
2006-12-20 16:03:11 -05:00
|
|
|
|
|
|
|
points[0].x = 0;
|
|
|
|
points[0].y = 0;
|
|
|
|
|
|
|
|
points[1].x = triangle_size;
|
|
|
|
points[1].y = 0;
|
|
|
|
|
|
|
|
points[2].x = 0;
|
|
|
|
points[2].y = triangle_size;
|
|
|
|
|
|
|
|
gdk_draw_polygon (win->gobj(), gc->gobj(), true, points, 3);
|
|
|
|
|
2006-12-20 21:52:27 -05:00
|
|
|
// center
|
|
|
|
|
2006-12-21 20:48:20 -05:00
|
|
|
points[0].x = (darea.get_width()/2 - triangle_size);
|
2006-12-20 16:03:11 -05:00
|
|
|
points[0].y = 0;
|
|
|
|
|
2007-04-11 09:07:51 -04:00
|
|
|
points[1].x = (darea.get_width()/2 + triangle_size);
|
2006-12-20 16:03:11 -05:00
|
|
|
points[1].y = 0;
|
|
|
|
|
2007-04-11 09:07:51 -04:00
|
|
|
points[2].x = darea.get_width()/2;
|
2006-12-21 15:13:37 -05:00
|
|
|
points[2].y = triangle_size - 1;
|
2006-12-20 16:03:11 -05:00
|
|
|
|
2006-12-20 21:52:27 -05:00
|
|
|
gdk_draw_polygon (win->gobj(), gc->gobj(), true, points, 3);
|
|
|
|
|
|
|
|
// right
|
2006-12-20 16:03:11 -05:00
|
|
|
|
2007-04-11 09:07:51 -04:00
|
|
|
points[0].x = (darea.get_width() - triangle_size);
|
2006-12-20 16:03:11 -05:00
|
|
|
points[0].y = 0;
|
|
|
|
|
2007-04-11 09:07:51 -04:00
|
|
|
points[1].x = darea.get_width();
|
2006-12-20 16:03:11 -05:00
|
|
|
points[1].y = 0;
|
|
|
|
|
2007-04-11 09:07:51 -04:00
|
|
|
points[2].x = darea.get_width();
|
2006-12-20 16:03:11 -05:00
|
|
|
points[2].y = triangle_size;
|
|
|
|
|
|
|
|
gdk_draw_polygon (win->gobj(), gc->gobj(), true, points, 3);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PannerBar::button_press (GdkEventButton* ev)
|
|
|
|
{
|
|
|
|
if (ev->button == 1 && ev->type == GDK_BUTTON_PRESS && ev->y < 10) {
|
|
|
|
if (ev->x < triangle_size) {
|
2006-12-21 23:20:07 -05:00
|
|
|
adjustment.set_value (adjustment.get_lower());
|
2006-12-20 16:03:11 -05:00
|
|
|
} else if (ev->x > (darea.get_width() - triangle_size)) {
|
2006-12-21 23:20:07 -05:00
|
|
|
adjustment.set_value (adjustment.get_upper());
|
2006-12-20 16:03:11 -05:00
|
|
|
} else if (ev->x > (darea.get_width()/2 - triangle_size) &&
|
|
|
|
ev->x < (darea.get_width()/2 + triangle_size)) {
|
2006-12-21 23:20:07 -05:00
|
|
|
adjustment.set_value (adjustment.get_lower() + ((adjustment.get_upper() - adjustment.get_lower()) / 2.0));
|
2006-12-20 16:03:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return BarController::button_press (ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PannerBar::button_release (GdkEventButton* ev)
|
|
|
|
{
|
|
|
|
return BarController::button_release (ev);
|
|
|
|
}
|
2006-12-20 21:52:27 -05:00
|
|
|
|