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 nframes64_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();
100 Editor::initialize_canvas ()
102 if (getenv ("ARDOUR_NON_AA_CANVAS")) {
103 track_canvas = new ArdourCanvas::Canvas ();
105 track_canvas = new ArdourCanvas::CanvasAA ();
108 ArdourCanvas::init ();
109 ardour_canvas_type_init ();
111 /* don't try to center the canvas */
113 track_canvas->set_center_scroll_region (false);
114 track_canvas->set_dither (Gdk::RGB_DITHER_NONE);
116 Glib::RefPtr<Gdk::Screen> screen = get_screen();
119 screen = Gdk::Screen::get_default();
121 physical_screen_width = screen->get_width ();
122 physical_screen_height = screen->get_height ();
124 /* stuff for the verbose canvas cursor */
126 Pango::FontDescription* font = get_font_for_style (N_("VerboseCanvasCursor"));
128 verbose_canvas_cursor = new ArdourCanvas::Text (*track_canvas->root());
129 verbose_canvas_cursor->property_font_desc() = *font;
130 verbose_canvas_cursor->property_anchor() = ANCHOR_NW;
134 verbose_cursor_visible = false;
136 if (Profile->get_sae()) {
137 Image img (::get_icon (X_("saelogo")));
138 logo_item = new ArdourCanvas::Pixbuf (*track_canvas->root(), 0.0, 0.0, img.get_pixbuf());
139 // logo_item->property_height_in_pixels() = true;
140 // logo_item->property_width_in_pixels() = true;
141 // logo_item->property_height_set() = true;
142 // logo_item->property_width_set() = true;
146 _master_group = new ArdourCanvas::Group (*track_canvas->root(), 0.0, 0.0);
148 transport_loop_range_rect = new ArdourCanvas::SimpleRect (*_master_group, 0.0, 0.0, 0.0, 0.0);
149 transport_loop_range_rect->property_outline_pixels() = 1;
150 transport_loop_range_rect->hide();
152 transport_punch_range_rect = new ArdourCanvas::SimpleRect (*_master_group, 0.0, 0.0, 0.0, 0.0);
153 transport_punch_range_rect->property_outline_pixels() = 0;
154 transport_punch_range_rect->hide();
156 /* a group to hold time (measure) lines */
157 time_line_group = new ArdourCanvas::Group (*_master_group, 0.0, 0.0);
159 range_marker_drag_rect = new ArdourCanvas::SimpleRect (*time_line_group, 0.0, 0.0, 0.0, 0.0);
160 range_marker_drag_rect->hide ();
162 _trackview_group = new ArdourCanvas::Group (*_master_group, 0.0, 0.0);
163 _region_motion_group = new ArdourCanvas::Group (*_trackview_group, 0.0, 0.0);
167 meter_bar_group = new ArdourCanvas::Group (*track_canvas->root());
168 meter_bar = new ArdourCanvas::SimpleRect (*meter_bar_group, 0.0, 0.0, physical_screen_width, timebar_height-1.0);
169 meter_bar->property_outline_what() = (0x1 | 0x8);
170 meter_bar->property_outline_pixels() = 1;
172 tempo_bar_group = new ArdourCanvas::Group (*track_canvas->root());
173 tempo_bar = new ArdourCanvas::SimpleRect (*tempo_bar_group, 0.0, 0.0, physical_screen_width, (timebar_height-1.0));
174 tempo_bar->property_outline_what() = (0x1 | 0x8);
175 tempo_bar->property_outline_pixels() = 1;
177 range_marker_bar_group = new ArdourCanvas::Group (*track_canvas->root());
178 range_marker_bar = new ArdourCanvas::SimpleRect (*range_marker_bar_group, 0.0, 0.0, physical_screen_width, (timebar_height-1.0));
179 range_marker_bar->property_outline_what() = (0x1 | 0x8);
180 range_marker_bar->property_outline_pixels() = 1;
182 transport_marker_bar_group = new ArdourCanvas::Group (*track_canvas->root());
183 transport_marker_bar = new ArdourCanvas::SimpleRect (*transport_marker_bar_group, 0.0, 0.0, physical_screen_width, (timebar_height-1.0));
184 transport_marker_bar->property_outline_what() = (0x1 | 0x8);
185 transport_marker_bar->property_outline_pixels() = 1;
187 marker_bar_group = new ArdourCanvas::Group (*track_canvas->root());
188 marker_bar = new ArdourCanvas::SimpleRect (*marker_bar_group, 0.0, 0.0, physical_screen_width, (timebar_height-1.0));
189 marker_bar->property_outline_what() = (0x1 | 0x8);
190 marker_bar->property_outline_pixels() = 1;
192 cd_marker_bar_group = new ArdourCanvas::Group (*track_canvas->root());
193 cd_marker_bar = new ArdourCanvas::SimpleRect (*cd_marker_bar_group, 0.0, 0.0, physical_screen_width, (timebar_height-1.0));
194 cd_marker_bar->property_outline_what() = (0x1 | 0x8);
195 cd_marker_bar->property_outline_pixels() = 1;
197 timebar_group = new ArdourCanvas::Group (*track_canvas->root());
198 cursor_group = new ArdourCanvas::Group (*track_canvas->root(), 0.0, 0.0);
200 meter_group = new ArdourCanvas::Group (*timebar_group, 0.0, timebar_height * 5.0);
201 tempo_group = new ArdourCanvas::Group (*timebar_group, 0.0, timebar_height * 4.0);
202 range_marker_group = new ArdourCanvas::Group (*timebar_group, 0.0, timebar_height * 3.0);
203 transport_marker_group = new ArdourCanvas::Group (*timebar_group, 0.0, timebar_height * 2.0);
204 marker_group = new ArdourCanvas::Group (*timebar_group, 0.0, timebar_height);
205 cd_marker_group = new ArdourCanvas::Group (*timebar_group, 0.0, 0.0);
207 marker_drag_line_points.push_back(Gnome::Art::Point(0.0, 0.0));
208 marker_drag_line_points.push_back(Gnome::Art::Point(0.0, 1.0));
210 marker_drag_line = new ArdourCanvas::Line (*timebar_group);
211 marker_drag_line->property_width_pixels() = 1;
212 marker_drag_line->property_points() = marker_drag_line_points;
213 marker_drag_line->hide();
215 cd_marker_bar_drag_rect = new ArdourCanvas::SimpleRect (*cd_marker_group, 0.0, 0.0, 100, timebar_height);
216 cd_marker_bar_drag_rect->property_outline_pixels() = 0;
217 cd_marker_bar_drag_rect->hide ();
219 range_bar_drag_rect = new ArdourCanvas::SimpleRect (*range_marker_group, 0.0, 0.0, 100, timebar_height);
220 range_bar_drag_rect->property_outline_pixels() = 0;
221 range_bar_drag_rect->hide ();
223 transport_bar_drag_rect = new ArdourCanvas::SimpleRect (*transport_marker_group, 0.0, 0.0, 100, timebar_height);
224 transport_bar_drag_rect->property_outline_pixels() = 0;
225 transport_bar_drag_rect->hide ();
227 transport_punchin_line = new ArdourCanvas::SimpleLine (*_master_group);
228 transport_punchin_line->property_x1() = 0.0;
229 transport_punchin_line->property_y1() = 0.0;
230 transport_punchin_line->property_x2() = 0.0;
231 transport_punchin_line->property_y2() = 0.0;
232 transport_punchin_line->hide ();
234 transport_punchout_line = new ArdourCanvas::SimpleLine (*_master_group);
235 transport_punchout_line->property_x1() = 0.0;
236 transport_punchout_line->property_y1() = 0.0;
237 transport_punchout_line->property_x2() = 0.0;
238 transport_punchout_line->property_y2() = 0.0;
239 transport_punchout_line->hide();
241 // used to show zoom mode active zooming
242 zoom_rect = new ArdourCanvas::SimpleRect (*_master_group, 0.0, 0.0, 0.0, 0.0);
243 zoom_rect->property_outline_pixels() = 1;
246 zoom_rect->signal_event().connect (bind (mem_fun (*this, &Editor::canvas_zoom_rect_event), (ArdourCanvas::Item*) 0));
248 // used as rubberband rect
249 rubberband_rect = new ArdourCanvas::SimpleRect (*_trackview_group, 0.0, 0.0, 0.0, 0.0);
251 rubberband_rect->property_outline_pixels() = 1;
252 rubberband_rect->hide();
254 tempo_bar->signal_event().connect (bind (mem_fun (*this, &Editor::canvas_tempo_bar_event), tempo_bar));
255 meter_bar->signal_event().connect (bind (mem_fun (*this, &Editor::canvas_meter_bar_event), meter_bar));
256 marker_bar->signal_event().connect (bind (mem_fun (*this, &Editor::canvas_marker_bar_event), marker_bar));
257 cd_marker_bar->signal_event().connect (bind (mem_fun (*this, &Editor::canvas_cd_marker_bar_event), cd_marker_bar));
258 range_marker_bar->signal_event().connect (bind (mem_fun (*this, &Editor::canvas_range_marker_bar_event), range_marker_bar));
259 transport_marker_bar->signal_event().connect (bind (mem_fun (*this, &Editor::canvas_transport_marker_bar_event), transport_marker_bar));
261 playhead_cursor = new Cursor (*this, &Editor::canvas_playhead_cursor_event);
264 logo_item->lower_to_bottom ();
267 /* need to handle 4 specific types of events as catch-alls */
269 track_canvas->signal_scroll_event().connect (mem_fun (*this, &Editor::track_canvas_scroll_event));
270 track_canvas->signal_motion_notify_event().connect (mem_fun (*this, &Editor::track_canvas_motion_notify_event));
271 track_canvas->signal_button_press_event().connect (mem_fun (*this, &Editor::track_canvas_button_press_event));
272 track_canvas->signal_button_release_event().connect (mem_fun (*this, &Editor::track_canvas_button_release_event));
274 track_canvas->set_name ("EditorMainCanvas");
275 track_canvas->add_events (Gdk::POINTER_MOTION_HINT_MASK|Gdk::SCROLL_MASK);
276 track_canvas->signal_leave_notify_event().connect (mem_fun(*this, &Editor::left_track_canvas));
277 track_canvas->signal_enter_notify_event().connect (mem_fun(*this, &Editor::entered_track_canvas));
278 track_canvas->set_flags (CAN_FOCUS);
280 /* set up drag-n-drop */
282 vector<TargetEntry> target_table;
284 // Drag-N-Drop from the region list can generate this target
285 target_table.push_back (TargetEntry ("regions"));
286 target_table.push_back (TargetEntry ("routes"));
288 target_table.push_back (TargetEntry ("text/plain"));
289 target_table.push_back (TargetEntry ("text/uri-list"));
290 target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
292 track_canvas->drag_dest_set (target_table);
293 track_canvas->signal_drag_data_received().connect (mem_fun(*this, &Editor::track_canvas_drag_data_received));
295 track_canvas->signal_size_allocate().connect (mem_fun(*this, &Editor::track_canvas_allocate));
297 ColorsChanged.connect (mem_fun (*this, &Editor::color_handler));
303 Editor::track_canvas_allocate (Gtk::Allocation alloc)
305 canvas_allocation = alloc;
306 track_canvas_size_allocated ();
310 Editor::track_canvas_size_allocated ()
312 bool height_changed = canvas_height != canvas_allocation.get_height();
314 canvas_width = canvas_allocation.get_width();
315 canvas_height = canvas_allocation.get_height();
318 TrackViewList::iterator i;
321 for (i = track_views.begin(); i != track_views.end(); ++i) {
322 if ((*i)->control_parent) {
323 height += (*i)->effective_height;
325 (*i)->clip_to_viewport ();
328 full_canvas_height = height + canvas_timebars_vsize;
333 if (height_changed) {
334 if (playhead_cursor) {
335 playhead_cursor->set_length (canvas_height);
338 vertical_adjustment.set_page_size (canvas_height);
340 for (MarkerSelection::iterator x = selection->markers.begin(); x != selection->markers.end(); ++x) {
341 (*x)->set_line_vpos (0, canvas_height);
344 // marker_drag_line_points.back().set_y(canvas_height);
345 range_marker_drag_rect->property_y2() = canvas_height;
346 transport_loop_range_rect->property_y2() = canvas_height;
347 transport_punch_range_rect->property_y2() = canvas_height;
348 transport_punchin_line->property_y2() = canvas_height;
349 transport_punchout_line->property_y2() = canvas_height;
351 horizontal_adjustment.set_upper (session->current_end_frame()/frames_per_unit);
352 horizontal_adjustment.set_page_size (current_page_frames()/frames_per_unit);
353 reset_hscrollbar_stepping ();
354 update_fixed_rulers();
355 redisplay_tempo (false);
357 last_trackview_group_vertical_offset = get_trackview_group_vertical_offset ();
358 if ((vertical_adjustment.get_value() + canvas_height) >= vertical_adjustment.get_upper()) {
360 We're increasing the size of the canvas while the bottom is visible.
361 We scroll down to keep in step with the controls layout.
363 vertical_adjustment.set_value (full_canvas_height - canvas_height + 1);
366 Resized (); /* EMIT_SIGNAL */
372 Editor::controls_layout_size_request (Requisition* req)
374 TreeModel::Children rows = route_display_model->children();
375 TreeModel::Children::iterator i;
377 bool changed = false;
379 for (pos = 0, i = rows.begin(); i != rows.end(); ++i) {
380 TimeAxisView *tv = (*i)[route_display_columns.tv];
382 pos += tv->effective_height;
383 tv->clip_to_viewport ();
387 RefPtr<Gdk::Screen> screen = get_screen();
390 screen = Gdk::Screen::get_default();
392 gint height = min ( (gint) pos, (gint) (physical_screen_height - 600));
393 gint width = max (edit_controls_vbox.get_width(), controls_layout.get_width());
395 /* don't get too big. the fudge factors here are just guesses */
397 width = min (width, (gint) (physical_screen_width - 300));
399 if ((req->width != width) || (req->height != height)) {
401 controls_layout_size_request_connection.disconnect ();
404 if (req->width != width) {
405 gint vbox_width = edit_controls_vbox.get_width();
408 /* this one is important: it determines how big the layout thinks it really is, as
409 opposed to what it displays on the screen
411 controls_layout.property_width () = vbox_width;
412 controls_layout.property_width_request () = vbox_width;
414 time_button_event_box.property_width_request () = vbox_width;
415 zoom_box.property_width_request () = vbox_width;
418 if (req->height != height) {
419 req->height = height;
420 controls_layout.property_height () = (guint) floor (pos);
424 controls_layout_size_request_connection = controls_layout.signal_size_request().connect (mem_fun (*this, &Editor::controls_layout_size_request));
429 Editor::track_canvas_map_handler (GdkEventAny* ev)
431 track_canvas->get_window()->set_cursor (*current_canvas_cursor);
436 Editor::track_canvas_drag_data_received (const RefPtr<Gdk::DragContext>& context,
438 const SelectionData& data,
439 guint info, guint time)
441 cerr << "drop on canvas, target = " << data.get_target() << endl;
443 if (data.get_target() == "regions") {
444 drop_regions (context, x, y, data, info, time);
446 else if(data.get_target() == "routes") {
447 drop_routes (context, x, y, data, info, time);
450 drop_paths (context, x, y, data, info, time);
455 Editor::drop_paths (const RefPtr<Gdk::DragContext>& context,
457 const SelectionData& data,
458 guint info, guint time)
461 RouteTimeAxisView* tv;
463 vector<ustring> paths;
468 if (convert_drop_to_paths (paths, context, x, y, data, info, time)) {
472 /* D-n-D coordinates are window-relative, so convert to "world" coordinates
478 track_canvas->window_to_world (x, y, wx, wy);
479 //wx += horizontal_adjustment.get_value();
480 //wy += vertical_adjustment.get_value();
482 ev.type = GDK_BUTTON_RELEASE;
486 frame = event_frame (&ev, 0, &cy);
490 if ((tvp = trackview_by_y_position (cy)) == 0) {
492 /* drop onto canvas background: create new tracks */
496 if (Profile->get_sae() || Config->get_only_copy_imported_files()) {
497 do_import (paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack, SrcBest, frame);
499 do_embed (paths, Editing::ImportDistinctFiles, ImportAsTrack, frame);
502 } else if ((tv = dynamic_cast<RouteTimeAxisView*>(tvp)) != 0) {
504 /* check that its an audio track, not a bus */
506 /* check that its an audio track, not a bus */
508 if (tv->get_diskstream()) {
509 /* select the track, then embed */
512 if (Profile->get_sae() || Config->get_only_copy_imported_files()) {
513 do_import (paths, Editing::ImportDistinctFiles, Editing::ImportToTrack, SrcBest, frame);
515 do_embed (paths, Editing::ImportDistinctFiles, ImportToTrack, frame);
521 context->drag_finish (true, false, time);
525 Editor::drop_regions (const RefPtr<Gdk::DragContext>& context,
527 const SelectionData& data,
528 guint info, guint time)
530 const SerializedObjectPointers<boost::shared_ptr<Region> >* sr =
531 reinterpret_cast<const SerializedObjectPointers<boost::shared_ptr<Region> > *> (data.get_data());
533 for (uint32_t i = 0; i < sr->cnt; ++i) {
535 boost::shared_ptr<Region> r = sr->data[i];
537 insert_region_list_drag (r, x, y);
540 context->drag_finish (true, false, time);
544 Editor::drop_routes (const Glib::RefPtr<Gdk::DragContext>& context,
546 const Gtk::SelectionData& data,
547 guint info, guint time) {
548 const SerializedObjectPointers<boost::shared_ptr<Route> >* sr =
549 reinterpret_cast<const SerializedObjectPointers<boost::shared_ptr<Route> > *> (data.get_data());
551 for (uint32_t i = 0; i < sr->cnt; ++i) {
552 boost::shared_ptr<Route> r = sr->data[i];
553 insert_route_list_drag (r, x, y);
556 context->drag_finish (true, false, time);
560 Editor::maybe_autoscroll (GdkEventMotion* event)
563 nframes64_t rightmost_frame = leftmost_frame + current_page_frames();
564 nframes64_t frame = drag_info.current_pointer_frame;
565 bool startit = false;
569 if (event->y < canvas_timebars_vsize) {
572 } else if (event->y > canvas_height) {
577 if (frame > rightmost_frame) {
579 if (rightmost_frame < max_frames) {
584 } else if (frame < leftmost_frame) {
585 if (leftmost_frame > 0) {
592 if (!allow_vertical_scroll) {
596 if ((autoscroll_x != last_autoscroll_x) || (autoscroll_y != last_autoscroll_y) || (autoscroll_x == 0 && autoscroll_y == 0)) {
597 stop_canvas_autoscroll ();
600 if (startit && autoscroll_timeout_tag < 0) {
601 start_canvas_autoscroll (autoscroll_x, autoscroll_y);
604 last_autoscroll_x = autoscroll_x;
605 last_autoscroll_y = autoscroll_y;
609 Editor::maybe_autoscroll_horizontally (GdkEventMotion* event)
611 nframes64_t rightmost_frame = leftmost_frame + current_page_frames();
612 nframes64_t frame = drag_info.current_pointer_frame;
613 bool startit = false;
618 if (frame > rightmost_frame) {
620 if (rightmost_frame < max_frames) {
625 } else if (frame < leftmost_frame) {
626 if (leftmost_frame > 0) {
633 if ((autoscroll_x != last_autoscroll_x) || (autoscroll_y != last_autoscroll_y) || (autoscroll_x == 0 && autoscroll_y == 0)) {
634 stop_canvas_autoscroll ();
637 if (startit && autoscroll_timeout_tag < 0) {
638 start_canvas_autoscroll (autoscroll_x, autoscroll_y);
641 last_autoscroll_x = autoscroll_x;
642 last_autoscroll_y = autoscroll_y;
646 Editor::_autoscroll_canvas (void *arg)
648 return ((Editor *) arg)->autoscroll_canvas ();
652 Editor::autoscroll_canvas ()
654 nframes64_t new_frame;
655 nframes64_t limit = max_frames - current_page_frames();
660 if (autoscroll_x > 0) {
661 autoscroll_x_distance = (unit_to_frame (drag_info.current_pointer_x) - (leftmost_frame + current_page_frames())) / 3;
662 } else if (autoscroll_x < 0) {
663 autoscroll_x_distance = (leftmost_frame - unit_to_frame (drag_info.current_pointer_x)) / 3;
667 if (autoscroll_y > 0) {
668 autoscroll_y_distance = (drag_info.current_pointer_y - (get_trackview_group_vertical_offset() + canvas_height)) / 3;
669 } else if (autoscroll_y < 0) {
671 autoscroll_y_distance = (vertical_adjustment.get_value () - drag_info.current_pointer_y) / 3;
674 if (autoscroll_x < 0) {
675 if (leftmost_frame < autoscroll_x_distance) {
678 new_frame = leftmost_frame - autoscroll_x_distance;
680 } else if (autoscroll_x > 0) {
681 if (leftmost_frame > limit - autoscroll_x_distance) {
684 new_frame = leftmost_frame + autoscroll_x_distance;
687 new_frame = leftmost_frame;
690 double vertical_pos = vertical_adjustment.get_value();
692 if (autoscroll_y < 0) {
694 if (vertical_pos < autoscroll_y_distance) {
697 new_pixel = vertical_pos - autoscroll_y_distance;
700 target_pixel = drag_info.current_pointer_y - autoscroll_y_distance;
701 target_pixel = max (target_pixel, 0.0);
703 } else if (autoscroll_y > 0) {
705 double top_of_bottom_of_canvas = full_canvas_height - canvas_height;
707 if (vertical_pos > full_canvas_height - autoscroll_y_distance) {
708 new_pixel = full_canvas_height;
710 new_pixel = vertical_pos + autoscroll_y_distance;
713 new_pixel = min (top_of_bottom_of_canvas, new_pixel);
715 target_pixel = drag_info.current_pointer_y + autoscroll_y_distance;
717 /* don't move to the full canvas height because the item will be invisible
718 (its top edge will line up with the bottom of the visible canvas.
721 target_pixel = min (target_pixel, full_canvas_height - 10);
724 target_pixel = drag_info.current_pointer_y;
725 new_pixel = vertical_pos;
728 if ((new_frame == 0 || new_frame == limit) && (new_pixel == 0 || new_pixel == DBL_MAX)) {
733 if (new_frame != leftmost_frame) {
734 reset_x_origin (new_frame);
739 Glib::RefPtr<Gdk::Window> canvas_window = const_cast<Editor*>(this)->track_canvas->get_window();
741 Gdk::ModifierType mask;
742 canvas_window->get_pointer (x, y, mask);
743 ev.type = GDK_MOTION_NOTIFY;
744 ev.state &= Gdk::BUTTON1_MASK;
748 motion_handler (drag_info.item, (GdkEvent*) &ev, drag_info.item_type, true);
750 vertical_adjustment.set_value (new_pixel);
754 if (autoscroll_cnt == 1) {
756 /* connect the timeout so that we get called repeatedly */
758 autoscroll_timeout_tag = g_idle_add ( _autoscroll_canvas, this);
767 Editor::start_canvas_autoscroll (int dx, int dy)
769 if (!session || autoscroll_active) {
773 stop_canvas_autoscroll ();
775 autoscroll_active = true;
778 autoscroll_x_distance = (nframes64_t) floor (current_page_frames()/50.0);
779 autoscroll_y_distance = fabs (dy * 5); /* pixels */
782 /* do it right now, which will start the repeated callbacks */
784 autoscroll_canvas ();
788 Editor::stop_canvas_autoscroll ()
791 if (autoscroll_timeout_tag >= 0) {
792 g_source_remove (autoscroll_timeout_tag);
793 autoscroll_timeout_tag = -1;
796 autoscroll_active = false;
800 Editor::left_track_canvas (GdkEventCrossing *ev)
802 set_entered_track (0);
803 set_entered_regionview (0);
804 reset_canvas_action_sensitivity (false);
809 Editor::entered_track_canvas (GdkEventCrossing *ev)
811 reset_canvas_action_sensitivity (true);
816 Editor::tie_vertical_scrolling ()
818 scroll_canvas_vertically ();
820 /* this will do an immediate redraw */
822 controls_layout.get_vadjustment()->set_value (vertical_adjustment.get_value());
826 Editor::scroll_canvas_horizontally ()
828 nframes64_t time_origin = (nframes64_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
830 if (time_origin != leftmost_frame) {
831 canvas_scroll_to (time_origin);
834 /* horizontal scrolling only */
835 double x1, x2, y1, y2, x_delta;
837 _master_group->get_bounds(x1, y1, x2, y2);
838 x_delta = x1 + horizontal_adjustment.get_value();
840 _master_group->move (-x_delta, 0);
841 timebar_group->move (-x_delta, 0);
842 cursor_group->move (-x_delta, 0);
843 update_fixed_rulers ();
844 redisplay_tempo (true);
848 Editor::scroll_canvas_vertically ()
850 /* vertical scrolling only */
853 y_delta = last_trackview_group_vertical_offset - get_trackview_group_vertical_offset ();
855 _trackview_group->move (0, y_delta);
857 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
858 (*i)->clip_to_viewport ();
860 last_trackview_group_vertical_offset = get_trackview_group_vertical_offset ();
861 /* required to keep the controls_layout in lock step with the canvas group */
862 track_canvas->update_now ();
866 Editor::canvas_horizontally_scrolled ()
868 nframes64_t time_origin = (nframes64_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
870 if (time_origin != leftmost_frame) {
871 canvas_scroll_to (time_origin);
873 redisplay_tempo (true);
877 Editor::canvas_scroll_to (nframes64_t time_origin)
879 leftmost_frame = time_origin;
880 nframes64_t rightmost_frame = leftmost_frame + current_page_frames ();
882 if (rightmost_frame > last_canvas_frame) {
883 last_canvas_frame = rightmost_frame;
884 //reset_scrolling_region ();
889 Editor::color_handler()
891 playhead_cursor->canvas_item.property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_PlayHead.get();
892 verbose_canvas_cursor->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_VerboseCanvasCursor.get();
894 meter_bar->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MeterBar.get();
895 meter_bar->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerBarSeparator.get();
897 tempo_bar->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TempoBar.get();
898 tempo_bar->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerBarSeparator.get();
900 marker_bar->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerBar.get();
901 marker_bar->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerBarSeparator.get();
903 cd_marker_bar->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_CDMarkerBar.get();
904 cd_marker_bar->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerBarSeparator.get();
906 range_marker_bar->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_RangeMarkerBar.get();
907 range_marker_bar->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerBarSeparator.get();
909 transport_marker_bar->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportMarkerBar.get();
910 transport_marker_bar->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerBarSeparator.get();
912 cd_marker_bar_drag_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_RangeDragBarRect.get();
913 cd_marker_bar_drag_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_RangeDragBarRect.get();
915 range_bar_drag_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_RangeDragBarRect.get();
916 range_bar_drag_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_RangeDragBarRect.get();
918 transport_bar_drag_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportDragRect.get();
919 transport_bar_drag_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportDragRect.get();
921 marker_drag_line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerDragLine.get();
923 range_marker_drag_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_RangeDragRect.get();
924 range_marker_drag_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_RangeDragRect.get();
926 transport_loop_range_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportLoopRect.get();
927 transport_loop_range_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportLoopRect.get();
929 transport_punch_range_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportPunchRect.get();
930 transport_punch_range_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportPunchRect.get();
932 transport_punchin_line->property_color_rgba() = ARDOUR_UI::config()->canvasvar_PunchLine.get();
933 transport_punchout_line->property_color_rgba() = ARDOUR_UI::config()->canvasvar_PunchLine.get();
935 zoom_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ZoomRect.get();
936 zoom_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_ZoomRect.get();
938 rubberband_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_RubberBandRect.get();
939 rubberband_rect->property_fill_color_rgba() = (guint32) ARDOUR_UI::config()->canvasvar_RubberBandRect.get();
941 location_marker_color = ARDOUR_UI::config()->canvasvar_LocationMarker.get();
942 location_range_color = ARDOUR_UI::config()->canvasvar_LocationRange.get();
943 location_cd_marker_color = ARDOUR_UI::config()->canvasvar_LocationCDMarker.get();
944 location_loop_color = ARDOUR_UI::config()->canvasvar_LocationLoop.get();
945 location_punch_color = ARDOUR_UI::config()->canvasvar_LocationPunch.get();
947 refresh_location_display ();
949 redisplay_tempo (true);
952 session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks); // redraw metric markers
957 Editor::flush_canvas ()
960 track_canvas->update_now ();
961 // gdk_window_process_updates (GTK_LAYOUT(track_canvas->gobj())->bin_window, true);