ardour
editor_cursors.cc
Go to the documentation of this file.
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 "canvas/canvas.h"
24 #include "canvas/debug.h"
25 #include "canvas/scroll_group.h"
26 
27 #include "editor_cursors.h"
28 #include "editor.h"
29 
30 using namespace ARDOUR;
31 using namespace PBD;
32 using namespace Gtk;
33 
34 EditorCursor::EditorCursor (Editor& ed, bool (Editor::*callbck)(GdkEvent*,ArdourCanvas::Item*))
35  : _editor (ed)
36  , _track_canvas_item (new ArdourCanvas::Arrow (_editor.get_cursor_scroll_group()))
37 {
38  CANVAS_DEBUG_NAME (_track_canvas_item, "track canvas editor cursor");
39 
40  _track_canvas_item->set_show_head (0, true);
41  _track_canvas_item->set_head_height (0, 9);
42  _track_canvas_item->set_head_width (0, 16);
43  _track_canvas_item->set_head_outward (0, false);
44  _track_canvas_item->set_show_head (1, false); // head only
45  _track_canvas_item->set_data ("cursor", this);
46 
47  _track_canvas_item->Event.connect (sigc::bind (sigc::mem_fun (ed, callbck), _track_canvas_item));
48 
49  _track_canvas_item->set_y1 (ArdourCanvas::COORD_MAX);
50 
51  _track_canvas_item->set_x (0);
52 
53  _current_frame = 1; /* force redraw at 0 */
54 }
55 
57  : _editor (ed)
58  , _track_canvas_item (new ArdourCanvas::Arrow (_editor.get_hscroll_group()))
59 {
60  CANVAS_DEBUG_NAME (_track_canvas_item, "track canvas cursor");
61 
62  _track_canvas_item->set_show_head (0, false);
63  _track_canvas_item->set_show_head (1, false);
64  _track_canvas_item->set_y1 (ArdourCanvas::COORD_MAX);
65  _track_canvas_item->set_ignore_events (true);
66 
67  _track_canvas_item->set_x (0);
68 
69  _current_frame = 1; /* force redraw at 0 */
70 }
71 
73 {
74  delete _track_canvas_item;
75 }
76 
77 void
79 {
80  if (_current_frame != frame) { PositionChanged (frame); }
81 
82  double const new_pos = _editor.sample_to_pixel_unrounded (frame);
83 
84  if (rint(new_pos) != rint(_track_canvas_item->x ())) {
85  _track_canvas_item->set_x (new_pos);
86  }
87 
88  _current_frame = frame;
89 }
90 
91 void
93 {
94  _track_canvas_item->show ();
95 }
96 
97 void
99 {
100  _track_canvas_item->hide ();
101 }
102 
103 void
104 EditorCursor::set_color (ArdourCanvas::Color color)
105 {
106  _track_canvas_item->set_color (color);
107 }
108 
109 void
111 {
112  _track_canvas_item->set_ignore_events (!yn);
113 }
Definition: ardour_ui.h:130
framepos_t _current_frame
EditorCursor(Editor &, bool(Editor::*)(GdkEvent *, ArdourCanvas::Item *))
double sample_to_pixel_unrounded(framepos_t sample) const
Definition: editor.h:238
PBD::Signal1< void, framepos_t > PositionChanged
void set_position(framepos_t)
Editor & _editor
ArdourCanvas::Arrow * _track_canvas_item
Definition: amp.h:29
void set_sensitive(bool)
int64_t framepos_t
Definition: types.h:66
Definition: editor.h:134
Definition: debug.h:30
void set_color(ArdourCanvas::Color)
LIBARDOUR_API PBD::PropertyDescriptor< bool > color
Definition: route_group.cc:50