new hellenic translation, plus new names in about dialog
[ardour.git] / gtk2_ardour / editor_cursors.cc
1 /*
2     Copyright (C) 2000 Paul Davis 
3
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.
8
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.
13
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.
17
18 */
19
20 #include <cstdlib>
21 #include <cmath>
22
23 #include <libgnomecanvas/libgnomecanvas.h>
24
25 #include "utils.h"
26 #include "editor.h"
27
28 using namespace sigc;
29 using namespace ARDOUR;
30 using namespace PBD;
31 using namespace Gtk;
32
33 Editor::Cursor::Cursor (Editor& ed, bool (Editor::*callbck)(GdkEvent*,ArdourCanvas::Item*))
34         : editor (ed),
35           canvas_item (*editor.cursor_group),
36           length(1.0)
37 {
38         
39         /* "randomly" initialize coords */
40         
41         points.push_back(Gnome::Art::Point(-9383839.0, 0.0));
42         points.push_back(Gnome::Art::Point(1.0, 0.0));
43
44         canvas_item.property_points() = points;
45         canvas_item.property_width_pixels() = 1;
46         canvas_item.property_first_arrowhead() = TRUE;
47         canvas_item.property_last_arrowhead() = TRUE;
48         canvas_item.property_arrow_shape_a() = 11.0;
49         canvas_item.property_arrow_shape_b() = 0.0;
50         canvas_item.property_arrow_shape_c() = 9.0;
51
52         canvas_item.set_data ("cursor", this);
53         canvas_item.signal_event().connect (bind (mem_fun (ed, callbck), &canvas_item));
54
55         current_frame = 1; /* force redraw at 0 */
56 }
57
58 Editor::Cursor::~Cursor ()
59
60 {
61 }
62
63 void
64 Editor::Cursor::set_position (nframes_t frame)
65 {
66         double new_pos =  editor.frame_to_unit (frame);
67
68         if (editor.session == 0) {
69                 canvas_item.hide();
70         } else {
71                 canvas_item.show();
72         }
73
74         current_frame = frame;
75
76         if (new_pos != points.front().get_x()) {
77
78                 points.front().set_x (new_pos);
79                 points.back().set_x (new_pos);
80
81                 canvas_item.property_points() = points;
82
83                 ArdourCanvas::Points p = canvas_item.property_points();
84         }
85
86         canvas_item.raise_to_top();
87 }
88
89 void
90 Editor::Cursor::set_length (double units)
91 {
92         length = units; 
93         points.back().set_y (points.front().get_y() + length);
94         canvas_item.property_points() = points;
95 }
96
97 void 
98 Editor::Cursor::set_y_axis (double position)
99 {
100         points.front().set_y (position);
101         points.back().set_y (position + length);
102         canvas_item.property_points() = points;
103 }