2 Copyright (C) 2000-2007 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 static const int triangle_size = 5;
29 null_label_callback (char* buf, unsigned int bufsize)
37 PannerBar::PannerBar (Gtk::Adjustment& adj, boost::shared_ptr<PBD::Controllable> c)
38 : BarController (adj, *c.get(), sigc::ptr_fun (null_label_callback))
40 set_style (BarController::Line);
43 PannerBar::~PannerBar ()
48 PannerBar::expose (GdkEventExpose* ev)
50 Glib::RefPtr<Gdk::Window> win (darea.get_window());
51 Glib::RefPtr<Gdk::GC> gc (get_style()->get_base_gc (get_state()));
53 BarController::expose (ev);
55 /* now draw triangles for left, right and center */
64 points[1].x = triangle_size;
68 points[2].y = triangle_size;
70 gdk_draw_polygon (win->gobj(), gc->gobj(), true, points, 3);
74 points[0].x = (darea.get_width()/2 - triangle_size);
77 points[1].x = (darea.get_width()/2 + triangle_size);
80 points[2].x = darea.get_width()/2;
81 points[2].y = triangle_size - 1;
83 gdk_draw_polygon (win->gobj(), gc->gobj(), true, points, 3);
87 points[0].x = (darea.get_width() - triangle_size);
90 points[1].x = darea.get_width();
93 points[2].x = darea.get_width();
94 points[2].y = triangle_size;
96 gdk_draw_polygon (win->gobj(), gc->gobj(), true, points, 3);
102 PannerBar::button_press (GdkEventButton* ev)
104 if (ev->button == 1 && ev->type == GDK_BUTTON_PRESS && ev->y < 10) {
105 if (ev->x < triangle_size) {
106 adjustment.set_value (adjustment.get_lower());
107 } else if (ev->x > (darea.get_width() - triangle_size)) {
108 adjustment.set_value (adjustment.get_upper());
109 } else if (ev->x > (darea.get_width()/2 - triangle_size) &&
110 ev->x < (darea.get_width()/2 + triangle_size)) {
111 adjustment.set_value (adjustment.get_lower() + ((adjustment.get_upper() - adjustment.get_lower()) / 2.0));
115 return BarController::button_press (ev);
119 PannerBar::button_release (GdkEventButton* ev)
121 return BarController::button_release (ev);