2 Copyright (C) 2005 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 <libgnomecanvasmm/init.h>
21 #include <jack/types.h>
22 #include <gtkmm2ext/utils.h>
24 #include <ardour/audioregion.h>
25 #include <ardour/profile.h>
27 #include "ardour_ui.h"
30 #include "simplerect.h"
31 #include "simpleline.h"
32 #include "waveview_p.h"
33 #include "simplerect_p.h"
34 #include "simpleline_p.h"
35 #include "canvas_impl.h"
37 #include "rgb_macros.h"
39 #include "time_axis_view.h"
40 #include "audio_time_axis.h"
43 #include "imageframe.h"
44 #include "imageframe_p.h"
51 using namespace ARDOUR;
55 using namespace Gtkmm2ext;
56 using namespace Editing;
58 /* XXX this is a hack. it ought to be the maximum value of an nframes_t */
60 const double max_canvas_coordinate = (double) JACK_MAX_FRAMES;
65 GType gnome_canvas_simpleline_get_type(void);
66 GType gnome_canvas_simplerect_get_type(void);
67 GType gnome_canvas_waveview_get_type(void);
70 GType gnome_canvas_imageframe_get_type(void);
75 static void ardour_canvas_type_init()
77 // Map gtypes to gtkmm wrapper-creation functions:
79 Glib::wrap_register(gnome_canvas_simpleline_get_type(), &Gnome::Canvas::SimpleLine_Class::wrap_new);
80 Glib::wrap_register(gnome_canvas_simplerect_get_type(), &Gnome::Canvas::SimpleRect_Class::wrap_new);
81 Glib::wrap_register(gnome_canvas_waveview_get_type(), &Gnome::Canvas::WaveView_Class::wrap_new);
84 Glib::wrap_register(gnome_canvas_imageframe_get_type(), &Gnome::Canvas::ImageFrame_Class::wrap_new);
87 // Register the gtkmm gtypes:
89 (void) Gnome::Canvas::WaveView::get_type();
90 (void) Gnome::Canvas::SimpleLine::get_type();
91 (void) Gnome::Canvas::SimpleRect::get_type();
94 (void) Gnome::Canvas::ImageFrame::get_type();
99 Editor::initialize_canvas ()
101 ArdourCanvas::init ();
102 ardour_canvas_type_init ();
104 /* don't try to center the canvas */
106 track_canvas.set_center_scroll_region (false);
107 track_canvas.set_dither (Gdk::RGB_DITHER_NONE);
109 /* need to handle 4 specific types of events as catch-alls */
111 track_canvas.signal_scroll_event().connect (mem_fun (*this, &Editor::track_canvas_scroll_event));
112 track_canvas.signal_motion_notify_event().connect (mem_fun (*this, &Editor::track_canvas_motion_notify_event));
113 track_canvas.signal_button_press_event().connect (mem_fun (*this, &Editor::track_canvas_button_press_event));
114 track_canvas.signal_button_release_event().connect (mem_fun (*this, &Editor::track_canvas_button_release_event));
116 /* just scroll stuff for the timecanvas */
117 time_canvas.signal_scroll_event().connect (mem_fun (*this, &Editor::time_canvas_scroll_event));
119 track_canvas.set_name ("EditorMainCanvas");
120 track_canvas.add_events (Gdk::POINTER_MOTION_HINT_MASK|Gdk::SCROLL_MASK);
121 track_canvas.signal_leave_notify_event().connect (mem_fun(*this, &Editor::left_track_canvas));
122 track_canvas.set_flags (CAN_FOCUS);
124 /* set up drag-n-drop */
126 vector<TargetEntry> target_table;
128 // Drag-N-Drop from the region list can generate this target
129 target_table.push_back (TargetEntry ("regions"));
130 target_table.push_back (TargetEntry ("routes"));
132 target_table.push_back (TargetEntry ("text/plain"));
133 target_table.push_back (TargetEntry ("text/uri-list"));
134 target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
136 track_canvas.drag_dest_set (target_table);
137 track_canvas.signal_drag_data_received().connect (mem_fun(*this, &Editor::track_canvas_drag_data_received));
139 /* stuff for the verbose canvas cursor */
141 Pango::FontDescription* font = get_font_for_style (N_("VerboseCanvasCursor"));
143 verbose_canvas_cursor = new ArdourCanvas::Text (*track_canvas.root());
144 verbose_canvas_cursor->property_font_desc() = *font;
145 verbose_canvas_cursor->property_anchor() = ANCHOR_NW;
149 verbose_cursor_visible = false;
151 if (Profile->get_sae()) {
152 Image img (::get_icon (X_("saelogo")));
153 logo_item = new ArdourCanvas::Pixbuf (*track_canvas.root(), 0.0, 0.0, img.get_pixbuf());
154 // logo_item->property_height_in_pixels() = true;
155 // logo_item->property_width_in_pixels() = true;
156 // logo_item->property_height_set() = true;
157 // logo_item->property_width_set() = true;
161 /* a group to hold time (measure) lines */
163 time_line_group = new ArdourCanvas::Group (*track_canvas.root(), 0.0, 0.0);
164 tempo_lines = new TempoLines(track_canvas, time_line_group);
165 cursor_group = new ArdourCanvas::Group (*track_canvas.root(), 0.0, 0.0);
166 time_canvas.set_name ("EditorTimeCanvas");
167 time_canvas.add_events (Gdk::POINTER_MOTION_HINT_MASK);
168 time_canvas.set_flags (CAN_FOCUS);
169 time_canvas.set_center_scroll_region (false);
170 time_canvas.set_dither (Gdk::RGB_DITHER_NONE);
172 marker_time_line_group = new ArdourCanvas::Group (*time_canvas.root(), 0.0, 0.0);
173 marker_tempo_lines = new TempoLines(time_canvas, marker_time_line_group);
175 meter_group = new ArdourCanvas::Group (*time_canvas.root(), 0.0, 0.0);
176 tempo_group = new ArdourCanvas::Group (*time_canvas.root(), 0.0, timebar_height);
177 range_marker_group = new ArdourCanvas::Group (*time_canvas.root(), 0.0, timebar_height * 2.0);
178 transport_marker_group = new ArdourCanvas::Group (*time_canvas.root(), 0.0, timebar_height * 3.0);
179 marker_group = new ArdourCanvas::Group (*time_canvas.root(), 0.0, timebar_height * 4.0);
180 cd_marker_group = new ArdourCanvas::Group (*time_canvas.root(), 0.0, timebar_height * 5.0);
182 tempo_bar = new ArdourCanvas::SimpleRect (*tempo_group, 0.0, 0.0, max_canvas_coordinate, timebar_height-1.0);
183 tempo_bar->property_outline_what() = (0x1 | 0x8);
184 tempo_bar->property_outline_pixels() = 1;
186 meter_bar = new ArdourCanvas::SimpleRect (*meter_group, 0.0, 0.0, max_canvas_coordinate, timebar_height-1.0);
187 meter_bar->property_outline_what() = (0x1 | 0x8);
188 meter_bar->property_outline_pixels() = 1;
190 marker_bar = new ArdourCanvas::SimpleRect (*marker_group, 0.0, 0.0, max_canvas_coordinate, timebar_height-1.0);
191 marker_bar->property_outline_what() = (0x1 | 0x8);
192 marker_bar->property_outline_pixels() = 1;
194 cd_marker_bar = new ArdourCanvas::SimpleRect (*cd_marker_group, 0.0, 0.0, max_canvas_coordinate, timebar_height-1.0);
195 cd_marker_bar->property_outline_what() = (0x1 | 0x8);
196 cd_marker_bar->property_outline_pixels() = 1;
198 range_marker_bar = new ArdourCanvas::SimpleRect (*range_marker_group, 0.0, 0.0, max_canvas_coordinate, timebar_height-1.0);
199 range_marker_bar->property_outline_what() = (0x1 | 0x8);
200 range_marker_bar->property_outline_pixels() = 1;
202 transport_marker_bar = new ArdourCanvas::SimpleRect (*transport_marker_group, 0.0, 0.0, max_canvas_coordinate, timebar_height-1.0);
203 transport_marker_bar->property_outline_what() = (0x1 | 0x8);
204 transport_marker_bar->property_outline_pixels() = 1;
206 range_bar_drag_rect = new ArdourCanvas::SimpleRect (*range_marker_group, 0.0, 0.0, max_canvas_coordinate, timebar_height-1.0);
207 range_bar_drag_rect->property_outline_pixels() = 0;
208 range_bar_drag_rect->hide ();
210 transport_bar_drag_rect = new ArdourCanvas::SimpleRect (*transport_marker_group, 0.0, 0.0, max_canvas_coordinate, timebar_height-1.0);
211 transport_bar_drag_rect->property_outline_pixels() = 0;
212 transport_bar_drag_rect->hide ();
214 marker_drag_line_points.push_back(Gnome::Art::Point(0.0, 0.0));
215 marker_drag_line_points.push_back(Gnome::Art::Point(0.0, 0.0));
217 marker_drag_line = new ArdourCanvas::Line (*track_canvas.root());
218 marker_drag_line->property_width_pixels() = 1;
219 marker_drag_line->property_points() = marker_drag_line_points;
220 marker_drag_line->hide();
222 range_marker_drag_rect = new ArdourCanvas::SimpleRect (*track_canvas.root(), 0.0, 0.0, 0.0, 0.0);
223 range_marker_drag_rect->hide ();
225 transport_loop_range_rect = new ArdourCanvas::SimpleRect (*time_line_group, 0.0, 0.0, 0.0, 0.0);
226 transport_loop_range_rect->property_outline_pixels() = 1;
227 transport_loop_range_rect->hide();
229 transport_punch_range_rect = new ArdourCanvas::SimpleRect (*time_line_group, 0.0, 0.0, 0.0, 0.0);
230 transport_punch_range_rect->property_outline_pixels() = 0;
231 transport_punch_range_rect->hide();
233 transport_loop_range_rect->lower_to_bottom (); // loop on the bottom
235 transport_punchin_line = new ArdourCanvas::SimpleLine (*time_line_group);
236 transport_punchin_line->property_x1() = 0.0;
237 transport_punchin_line->property_y1() = 0.0;
238 transport_punchin_line->property_x2() = 0.0;
239 transport_punchin_line->property_y2() = 0.0;
240 transport_punchin_line->hide ();
242 transport_punchout_line = new ArdourCanvas::SimpleLine (*time_line_group);
243 transport_punchout_line->property_x1() = 0.0;
244 transport_punchout_line->property_y1() = 0.0;
245 transport_punchout_line->property_x2() = 0.0;
246 transport_punchout_line->property_y2() = 0.0;
247 transport_punchout_line->hide();
249 // used to show zoom mode active zooming
250 zoom_rect = new ArdourCanvas::SimpleRect (*track_canvas.root(), 0.0, 0.0, 0.0, 0.0);
251 zoom_rect->property_outline_pixels() = 1;
254 zoom_rect->signal_event().connect (bind (mem_fun (*this, &Editor::canvas_zoom_rect_event), (ArdourCanvas::Item*) 0));
256 // used as rubberband rect
257 rubberband_rect = new ArdourCanvas::SimpleRect (*track_canvas.root(), 0.0, 0.0, 0.0, 0.0);
258 rubberband_rect->property_outline_pixels() = 1;
259 rubberband_rect->hide();
261 tempo_bar->signal_event().connect (bind (mem_fun (*this, &Editor::canvas_tempo_bar_event), tempo_bar));
262 meter_bar->signal_event().connect (bind (mem_fun (*this, &Editor::canvas_meter_bar_event), meter_bar));
263 marker_bar->signal_event().connect (bind (mem_fun (*this, &Editor::canvas_marker_bar_event), marker_bar));
264 cd_marker_bar->signal_event().connect (bind (mem_fun (*this, &Editor::canvas_cd_marker_bar_event), cd_marker_bar));
265 range_marker_bar->signal_event().connect (bind (mem_fun (*this, &Editor::canvas_range_marker_bar_event), range_marker_bar));
266 transport_marker_bar->signal_event().connect (bind (mem_fun (*this, &Editor::canvas_transport_marker_bar_event), transport_marker_bar));
268 ZoomChanged.connect (bind (mem_fun(*this, &Editor::update_loop_range_view), false));
269 ZoomChanged.connect (bind (mem_fun(*this, &Editor::update_punch_range_view), false));
271 double time_height = timebar_height * 5;
272 double time_width = FLT_MAX/frames_per_unit;
273 time_canvas.set_scroll_region(0.0, 0.0, time_width, time_height);
275 playhead_cursor = new Cursor (*this, &Editor::canvas_playhead_cursor_event);
277 initial_ruler_update_required = true;
278 track_canvas.signal_size_allocate().connect (mem_fun(*this, &Editor::track_canvas_allocate));
281 logo_item->lower_to_bottom ();
284 ColorsChanged.connect (mem_fun (*this, &Editor::color_handler));
290 Editor::track_canvas_allocate (Gtk::Allocation alloc)
292 canvas_allocation = alloc;
294 if (!initial_ruler_update_required) {
295 if (!canvas_idle_queued) {
296 /* call this first so that we do stuff before any pending redraw */
297 Glib::signal_idle().connect (mem_fun (*this, &Editor::track_canvas_size_allocated), false);
298 canvas_idle_queued = true;
303 initial_ruler_update_required = false;
304 track_canvas_size_allocated ();
308 Editor::track_canvas_size_allocated ()
310 if (canvas_idle_queued) {
311 canvas_idle_queued = false;
314 canvas_width = canvas_allocation.get_width();
315 canvas_height = canvas_allocation.get_height();
317 full_canvas_height = canvas_height;
320 TrackViewList::iterator i;
323 for (i = track_views.begin(); i != track_views.end(); ++i) {
324 if ((*i)->control_parent) {
325 height += (*i)->effective_height;
329 full_canvas_height = height;
332 zoom_range_clock.set ((nframes_t) floor ((canvas_width * frames_per_unit)));
333 playhead_cursor->set_position (playhead_cursor->current_frame);
335 reset_hscrollbar_stepping ();
336 reset_scrolling_region ();
338 if (playhead_cursor) playhead_cursor->set_length (canvas_height);
340 double y1 = vertical_adjustment.get_value ();
342 for (MarkerSelection::iterator x = selection->markers.begin(); x != selection->markers.end(); ++x) {
343 (*x)->set_line_vpos (y1, canvas_height);
346 range_marker_drag_rect->property_y1() = 0.0;
347 range_marker_drag_rect->property_y2() = canvas_height;
348 transport_loop_range_rect->property_y1() = 0.0;
349 transport_loop_range_rect->property_y2() = canvas_height;
350 transport_punch_range_rect->property_y1() = 0.0;
351 transport_punch_range_rect->property_y2() = canvas_height;
352 transport_punchin_line->property_y1() = 0.0;
353 transport_punchin_line->property_y2() = canvas_height;
354 transport_punchout_line->property_y1() = 0.0;
355 transport_punchout_line->property_y2() = canvas_height;
357 update_fixed_rulers();
358 redisplay_tempo (true);
360 Resized (); /* EMIT_SIGNAL */
366 Editor::reset_scrolling_region (Gtk::Allocation* alloc)
368 TreeModel::Children rows = route_display_model->children();
369 TreeModel::Children::iterator i;
372 for (pos = 0, i = rows.begin(); i != rows.end(); ++i) {
373 TimeAxisView *tv = (*i)[route_display_columns.tv];
374 if (tv != 0 && !tv->hidden()) {
375 pos += tv->effective_height;
379 double last_canvas_unit = max ((last_canvas_frame / frames_per_unit), canvas_width);
381 track_canvas.set_scroll_region (0.0, 0.0, last_canvas_unit, pos);
383 // XXX what is the correct height value for the time canvas ? this overstates it
384 time_canvas.set_scroll_region ( 0.0, 0.0, last_canvas_unit, canvas_height);
386 range_marker_drag_rect->property_y2() = canvas_height;
387 transport_loop_range_rect->property_y2() = canvas_height;
388 transport_punch_range_rect->property_y2() = canvas_height;
389 transport_punchin_line->property_y2() = canvas_height;
390 transport_punchout_line->property_y2() = canvas_height;
392 update_punch_range_view (true);
394 controls_layout.queue_resize();
398 Editor::controls_layout_size_request (Requisition* req)
400 TreeModel::Children rows = route_display_model->children();
401 TreeModel::Children::iterator i;
404 for (pos = 0, i = rows.begin(); i != rows.end(); ++i) {
405 TimeAxisView *tv = (*i)[route_display_columns.tv];
407 pos += tv->effective_height;
411 RefPtr<Gdk::Screen> screen = get_screen();
414 screen = Gdk::Screen::get_default();
417 edit_controls_vbox.check_resize();
418 req->width = max (edit_controls_vbox.get_width(), controls_layout.get_width());
420 /* don't get too big. the fudge factors here are just guesses */
422 req->width = min (req->width, screen->get_width() - 300);
423 req->height = min ((gint) pos, (screen->get_height() - 400));
425 /* this one is important: it determines how big the layout thinks it really is, as
426 opposed to what it displays on the screen
429 controls_layout.set_size (edit_controls_vbox.get_width(), (gint) pos);
430 controls_layout.set_size_request(edit_controls_vbox.get_width(), -1);
431 zoom_box.set_size_request(edit_controls_vbox.get_width(), -1);
432 time_button_frame.set_size_request(edit_controls_vbox.get_width(), -1);
434 //cerr << "sizes = " << req->width << " " << edit_controls_vbox.get_width() << " " << controls_layout.get_width() << " " << zoom_box.get_width() << " " << time_button_frame.get_width() << endl;//DEBUG
438 Editor::track_canvas_map_handler (GdkEventAny* ev)
440 track_canvas.get_window()->set_cursor (*current_canvas_cursor);
445 Editor::time_canvas_map_handler (GdkEventAny* ev)
447 time_canvas.get_window()->set_cursor (*timebar_cursor);
452 Editor::track_canvas_drag_data_received (const RefPtr<Gdk::DragContext>& context,
454 const SelectionData& data,
455 guint info, guint time)
457 cerr << "drop on canvas, target = " << data.get_target() << endl;
459 if (data.get_target() == "regions") {
460 drop_regions (context, x, y, data, info, time);
462 else if(data.get_target() == "routes") {
463 drop_routes (context, x, y, data, info, time);
466 drop_paths (context, x, y, data, info, time);
471 Editor::drop_paths (const RefPtr<Gdk::DragContext>& context,
473 const SelectionData& data,
474 guint info, guint time)
477 RouteTimeAxisView* tv;
479 vector<ustring> paths;
484 if (convert_drop_to_paths (paths, context, x, y, data, info, time)) {
488 /* D-n-D coordinates are window-relative, so convert to "world" coordinates
494 track_canvas.window_to_world (x, y, wx, wy);
495 wx += horizontal_adjustment.get_value();
496 wy += vertical_adjustment.get_value();
498 ev.type = GDK_BUTTON_RELEASE;
502 frame = event_frame (&ev, 0, &cy);
506 if ((tvp = trackview_by_y_position (cy)) == 0) {
508 /* drop onto canvas background: create new tracks */
510 do_embed (paths, Editing::ImportDistinctFiles, ImportAsTrack, frame);
512 } else if ((tv = dynamic_cast<RouteTimeAxisView*>(tvp)) != 0) {
514 /* check that its an audio track, not a bus */
516 /* check that its an audio track, not a bus */
518 if (tv->get_diskstream()) {
519 /* select the track, then embed */
521 do_embed (paths, Editing::ImportDistinctFiles, ImportToTrack, frame);
526 context->drag_finish (true, false, time);
530 Editor::drop_regions (const RefPtr<Gdk::DragContext>& context,
532 const SelectionData& data,
533 guint info, guint time)
535 const SerializedObjectPointers<boost::shared_ptr<Region> >* sr =
536 reinterpret_cast<const SerializedObjectPointers<boost::shared_ptr<Region> > *> (data.get_data());
538 for (uint32_t i = 0; i < sr->cnt; ++i) {
540 boost::shared_ptr<Region> r = sr->data[i];
542 insert_region_list_drag (r, x, y);
545 context->drag_finish (true, false, time);
549 Editor::drop_routes (const Glib::RefPtr<Gdk::DragContext>& context,
551 const Gtk::SelectionData& data,
552 guint info, guint time) {
553 const SerializedObjectPointers<boost::shared_ptr<Route> >* sr =
554 reinterpret_cast<const SerializedObjectPointers<boost::shared_ptr<Route> > *> (data.get_data());
556 for (uint32_t i = 0; i < sr->cnt; ++i) {
557 boost::shared_ptr<Route> r = sr->data[i];
558 insert_route_list_drag (r, x, y);
561 context->drag_finish (true, false, time);
565 Editor::maybe_autoscroll (GdkEvent* event)
567 nframes_t rightmost_frame = leftmost_frame + current_page_frames();
568 nframes_t frame = drag_info.current_pointer_frame;
569 bool startit = false;
571 static int last_autoscroll_direction = 0;
573 if (frame > rightmost_frame) {
575 if (rightmost_frame < max_frames) {
576 autoscroll_direction = 1;
580 } else if (frame < leftmost_frame) {
582 if (leftmost_frame > 0) {
583 autoscroll_direction = -1;
589 if (drag_info.last_pointer_frame > drag_info.current_pointer_frame) {
590 autoscroll_direction = -1;
592 autoscroll_direction = 1;
597 if ((autoscroll_direction != last_autoscroll_direction) || (leftmost_frame < frame < rightmost_frame)) {
598 stop_canvas_autoscroll ();
601 if (startit && autoscroll_timeout_tag < 0) {
602 start_canvas_autoscroll (autoscroll_direction);
605 last_autoscroll_direction = autoscroll_direction;
609 Editor::_autoscroll_canvas (void *arg)
611 return ((Editor *) arg)->autoscroll_canvas ();
615 Editor::autoscroll_canvas ()
618 nframes_t limit = max_frames - current_page_frames();
620 nframes_t target_frame;
622 if (autoscroll_direction < 0) {
623 if (leftmost_frame < autoscroll_distance) {
626 new_frame = leftmost_frame - autoscroll_distance;
628 target_frame = drag_info.current_pointer_frame - autoscroll_distance;
630 if (leftmost_frame > limit - autoscroll_distance) {
633 new_frame = leftmost_frame + autoscroll_distance;
635 target_frame = drag_info.current_pointer_frame + autoscroll_distance;
638 /* now fake a motion event to get the object that is being dragged to move too */
640 ev.type = GDK_MOTION_NOTIFY;
641 ev.state &= Gdk::BUTTON1_MASK;
642 ev.x = frame_to_unit (target_frame);
643 ev.y = drag_info.current_pointer_y;
644 motion_handler (drag_info.item, (GdkEvent*) &ev, drag_info.item_type, true);
646 if (new_frame == 0 || new_frame == limit) {
653 if (autoscroll_cnt == 1) {
655 /* connect the timeout so that we get called repeatedly */
657 autoscroll_timeout_tag = g_idle_add ( _autoscroll_canvas, this);
662 if (new_frame != leftmost_frame) {
663 reset_x_origin (new_frame);
666 if (autoscroll_cnt == 50) { /* 0.5 seconds */
668 /* after about a while, speed up a bit by changing the timeout interval */
670 autoscroll_distance = (nframes_t) floor (current_page_frames()/30.0f);
672 } else if (autoscroll_cnt == 150) { /* 1.0 seconds */
674 autoscroll_distance = (nframes_t) floor (current_page_frames()/20.0f);
676 } else if (autoscroll_cnt == 300) { /* 1.5 seconds */
678 /* after about another while, speed up by increasing the shift per callback */
680 autoscroll_distance = (nframes_t) floor (current_page_frames()/10.0f);
688 Editor::start_canvas_autoscroll (int dir)
690 if (!session || autoscroll_active) {
694 stop_canvas_autoscroll ();
696 autoscroll_active = true;
697 autoscroll_direction = dir;
698 autoscroll_distance = (nframes_t) floor (current_page_frames()/50.0);
701 /* do it right now, which will start the repeated callbacks */
703 autoscroll_canvas ();
707 Editor::stop_canvas_autoscroll ()
709 if (autoscroll_timeout_tag >= 0) {
710 g_source_remove (autoscroll_timeout_tag);
711 autoscroll_timeout_tag = -1;
714 autoscroll_active = false;
718 Editor::left_track_canvas (GdkEventCrossing *ev)
720 set_entered_track (0);
721 set_entered_regionview (0);
726 Editor::tie_vertical_scrolling ()
728 double y1 = vertical_adjustment.get_value();
730 playhead_cursor->set_y_axis (y1);
732 range_marker_drag_rect->property_y1() = y1;
733 range_marker_drag_rect->property_y2() = y1 + canvas_height;
734 transport_loop_range_rect->property_y1() = y1;
735 transport_loop_range_rect->property_y2() = y1 + canvas_height;
736 transport_punch_range_rect->property_y1() = y1;
737 transport_punch_range_rect->property_y2() = y1 + canvas_height;
738 transport_punchin_line->property_y1() = y1;
739 transport_punchin_line->property_y2() = y1 + canvas_height;
740 transport_punchout_line->property_y1() = y1;
741 transport_punchout_line->property_y2() = y1 + canvas_height;
743 if (!selection->markers.empty()) {
744 for (MarkerSelection::iterator x = selection->markers.begin(); x != selection->markers.end(); ++x) {
745 (*x)->set_line_vpos (y1, canvas_height);
750 logo_item->property_y() = y1;
753 /* this will do an immediate redraw */
755 controls_layout.get_vadjustment()->set_value (y1);
759 Editor::canvas_horizontally_scrolled ()
761 nframes64_t time_origin = (nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
763 if (time_origin != leftmost_frame) {
764 canvas_scroll_to (time_origin);
769 Editor::canvas_scroll_to (nframes64_t time_origin)
771 leftmost_frame = time_origin;
772 nframes_t rightmost_frame = leftmost_frame + current_page_frames ();
774 if (rightmost_frame > last_canvas_frame) {
775 last_canvas_frame = rightmost_frame;
776 reset_scrolling_region ();
780 logo_item->property_x() = horizontal_adjustment.get_value ();
783 update_fixed_rulers ();
785 redisplay_tempo (!_dragging_hscrollbar);
789 Editor::color_handler()
791 playhead_cursor->canvas_item.property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_PlayHead.get();
792 verbose_canvas_cursor->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_VerboseCanvasCursor.get();
794 meter_bar->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MeterBar.get();
795 meter_bar->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerBarSeparator.get();
797 tempo_bar->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TempoBar.get();
798 tempo_bar->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerBarSeparator.get();
800 marker_bar->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerBar.get();
801 marker_bar->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerBarSeparator.get();
803 cd_marker_bar->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_CDMarkerBar.get();
804 cd_marker_bar->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerBarSeparator.get();
806 range_marker_bar->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_RangeMarkerBar.get();
807 range_marker_bar->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerBarSeparator.get();
809 transport_marker_bar->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportMarkerBar.get();
810 transport_marker_bar->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerBarSeparator.get();
812 range_bar_drag_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_RangeDragBarRect.get();
813 range_bar_drag_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_RangeDragBarRect.get();
815 transport_bar_drag_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportDragRect.get();
816 transport_bar_drag_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportDragRect.get();
818 marker_drag_line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerDragLine.get();
820 range_marker_drag_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_RangeDragRect.get();
821 range_marker_drag_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_RangeDragRect.get();
823 transport_loop_range_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportLoopRect.get();
824 transport_loop_range_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportLoopRect.get();
826 transport_punch_range_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportPunchRect.get();
827 transport_punch_range_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportPunchRect.get();
829 transport_punchin_line->property_color_rgba() = ARDOUR_UI::config()->canvasvar_PunchLine.get();
830 transport_punchout_line->property_color_rgba() = ARDOUR_UI::config()->canvasvar_PunchLine.get();
832 zoom_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ZoomRect.get();
833 zoom_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_ZoomRect.get();
835 rubberband_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_RubberBandRect.get();
836 rubberband_rect->property_fill_color_rgba() = (guint32) ARDOUR_UI::config()->canvasvar_RubberBandRect.get();
838 location_marker_color = ARDOUR_UI::config()->canvasvar_LocationMarker.get();
839 location_range_color = ARDOUR_UI::config()->canvasvar_LocationRange.get();
840 location_cd_marker_color = ARDOUR_UI::config()->canvasvar_LocationCDMarker.get();
841 location_loop_color = ARDOUR_UI::config()->canvasvar_LocationLoop.get();
842 location_punch_color = ARDOUR_UI::config()->canvasvar_LocationPunch.get();
844 refresh_location_display ();
845 redisplay_tempo (true);
848 session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks); // redraw metric markers