Zoom session when the mouse pointer is moved up and down during a playhead drag.
[ardour2.git] / gtk2_ardour / editor_cursors.cc
blobccacda210f01484f5342e381e7248e34aeb0e423
1 /*
2 Copyright (C) 2000 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.
20 #include <cstdlib>
21 #include <cmath>
23 #include <libgnomecanvas/libgnomecanvas.h>
25 #include "utils.h"
26 #include "editor_cursors.h"
27 #include "editor.h"
29 using namespace ARDOUR;
30 using namespace PBD;
31 using namespace Gtk;
33 EditorCursor::EditorCursor (Editor& ed, bool (Editor::*callbck)(GdkEvent*,ArdourCanvas::Item*))
34 : editor (ed),
35 canvas_item (*editor.cursor_group),
36 length(1.0)
38 points.push_back(Gnome::Art::Point(-1.0, 0.0)); // first x-coord needs to be a non-normal value
39 points.push_back(Gnome::Art::Point(1.0, 1.0));
41 canvas_item.property_points() = points;
42 canvas_item.property_width_pixels() = 1;
43 canvas_item.property_first_arrowhead() = TRUE;
44 canvas_item.property_last_arrowhead() = TRUE;
45 canvas_item.property_arrow_shape_a() = 11.0;
46 canvas_item.property_arrow_shape_b() = 0.0;
47 canvas_item.property_arrow_shape_c() = 9.0;
49 canvas_item.set_data ("cursor", this);
50 canvas_item.signal_event().connect (sigc::bind (sigc::mem_fun (ed, callbck), &canvas_item));
51 current_frame = 1; /* force redraw at 0 */
54 EditorCursor::~EditorCursor ()
59 void
60 EditorCursor::set_position (framepos_t frame)
62 PositionChanged (frame);
64 double new_pos = editor.frame_to_unit (frame);
66 if (new_pos != points.front().get_x()) {
68 points.front().set_x (new_pos);
69 points.back().set_x (new_pos);
71 canvas_item.property_points() = points;
73 current_frame = frame;
76 void
77 EditorCursor::set_length (double units)
79 length = units;
80 points.back().set_y (points.front().get_y() + length);
81 canvas_item.property_points() = points;
84 void
85 EditorCursor::set_y_axis (double position)
87 points.front().set_y (position);
88 points.back().set_y (position + length);
89 canvas_item.property_points() = points;