2 Copyright (C) 2000-2003 Paul Davis
3 Written by Colin Law, CMT, Glasgow
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "imageframe_view.h"
23 #include "imageframe_time_axis.h"
24 #include "imageframe_time_axis_view.h"
25 #include "imageframe_time_axis_group.h"
26 #include "marker_time_axis_view.h"
27 #include "marker_time_axis.h"
28 #include "marker_view.h"
31 #include "canvas_impl.h"
33 #include <gtkmm2ext/gtk_ui.h>
34 #include <pbd/error.h>
36 #include <sys/types.h>
37 #include <sys/socket.h>
38 #include <netinet/in.h>
40 #include <arpa/inet.h>
42 #include "imageframe_socket_handler.h"
43 #include "ardour_image_compositor_socket.h"
44 #include "public_editor.h"
48 /* <CMT Additions file="editor.cc"> */
51 Editor::add_imageframe_time_axis(const string & track_name, void* src)
53 // check for duplicate name
54 if(get_named_time_axis(track_name))
56 warning << "Repeated time axis name" << std::endl ;
60 Gtkmm2ext::UI::instance()->call_slot(bind(mem_fun(*this, &Editor::handle_new_imageframe_time_axis_view),track_name, src)) ;
65 Editor::connect_to_image_compositor()
67 if(image_socket_listener == 0)
69 image_socket_listener = ImageFrameSocketHandler::create_instance(*this) ;
72 if(image_socket_listener->is_connected() == true)
77 // XXX should really put this somewhere safe
78 const char * host_ip = "127.0.0.1" ;
80 bool retcode = image_socket_listener->connect(host_ip, ardourvis::DEFAULT_PORT) ;
84 // XXX need to get some return status here
85 warning << "Image Compositor Connection attempt failed" << std::endl ;
89 // add the socket to the gui loop, and keep the retuned tag value of the input
90 gint tag = gdk_input_add(image_socket_listener->get_socket_descriptor(), GDK_INPUT_READ,ImageFrameSocketHandler::image_socket_callback,image_socket_listener) ;
91 image_socket_listener->set_gdk_input_tag(tag) ;
95 Editor::scroll_timeaxis_to_imageframe_item(const TimeAxisViewItem* item)
98 //jack_nframes_t offset = static_cast<jack_nframes_t>(frames_per_unit * (edit_hscroll_slider_width/2)) ;
99 jack_nframes_t offset = 0;
101 jack_nframes_t x_pos = 0 ;
102 if(item->get_position() < offset)
108 x_pos = item->get_position() - offset + (item->get_duration() / 2) ;
111 reposition_x_origin(x_pos) ;
115 Editor::add_imageframe_marker_time_axis(const string & track_name, TimeAxisView* marked_track, void* src)
117 // Can we only bind 2 data Items?
118 // @todo we really want to bind the src attribute too, for the moment tracks can only be added remotely,
119 // so this is not too much of an issue, however will need to be looked at again
120 Gtkmm2ext::UI::instance()->call_slot(sigc::bind(mem_fun(*this, &Editor::handle_new_imageframe_marker_time_axis_view),track_name, marked_track)) ;
124 Editor::popup_imageframe_edit_menu(int button, int32_t time, ArdourCanvas::Item* ifv, bool with_item)
126 ImageFrameTimeAxis* ifta = dynamic_cast<ImageFrameTimeAxis*>(clicked_trackview) ;
130 ImageFrameTimeAxisGroup* iftag = ifta->get_view()->get_selected_imageframe_group() ;
134 ImageFrameView* selected_ifv = ifta->get_view()->get_selected_imageframe_view() ;
135 ifta->popup_imageframe_edit_menu(button, time, selected_ifv, with_item) ;
141 Editor::popup_marker_time_axis_edit_menu(int button, int32_t time, ArdourCanvas::Item* ifv, bool with_item)
143 MarkerTimeAxis* mta = dynamic_cast<MarkerTimeAxis*>(clicked_trackview) ;
147 MarkerView* selected_mv = mta->get_view()->get_selected_time_axis_item() ;
150 mta->popup_marker_time_axis_edit_menu(button,time, selected_mv, with_item) ;
156 Editor::get_named_time_axis(const string & name)
158 TimeAxisView* tav = 0 ;
160 for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i)
162 if (((TimeAxisView*)*i)->name() == name)
164 tav = ((TimeAxisView*)*i) ;
171 /* </CMT Additions file="editor.cc"> */
178 /* <CMT Additions file="editor_canvas_events.cc"> */
180 Editor::canvas_imageframe_item_view_event (GdkEvent *event, ArdourCanvas::Item* item, ImageFrameView *ifv)
183 ImageFrameTimeAxisGroup* iftag = 0 ;
187 case GDK_BUTTON_PRESS:
188 case GDK_2BUTTON_PRESS:
189 case GDK_3BUTTON_PRESS:
190 clicked_trackview = &ifv->get_time_axis_view();
191 iftag = ifv->get_time_axis_group() ;
192 dynamic_cast<ImageFrameTimeAxis*>(clicked_trackview)->get_view()->set_selected_imageframe_view(iftag, ifv);
193 ret = button_press_handler (item, event, ImageFrameItem) ;
195 case GDK_BUTTON_RELEASE:
196 ret = button_release_handler (item, event, ImageFrameItem) ;
198 case GDK_MOTION_NOTIFY:
199 ret = motion_handler (item, event, ImageFrameItem) ;
208 Editor::canvas_imageframe_start_handle_event (GdkEvent *event, ArdourCanvas::Item* item, ImageFrameView *ifv)
211 ImageFrameTimeAxisGroup* iftag = 0 ;
215 case GDK_BUTTON_PRESS:
216 case GDK_2BUTTON_PRESS:
217 case GDK_3BUTTON_PRESS:
218 clicked_trackview = &ifv->get_time_axis_view() ;
219 iftag = ifv->get_time_axis_group() ;
220 dynamic_cast<ImageFrameTimeAxis*>(clicked_trackview)->get_view()->set_selected_imageframe_view(iftag, ifv);
222 ret = button_press_handler (item, event, ImageFrameHandleStartItem) ;
224 case GDK_BUTTON_RELEASE:
225 ret = button_release_handler (item, event, ImageFrameHandleStartItem) ;
227 case GDK_MOTION_NOTIFY:
228 ret = motion_handler (item, event, ImageFrameHandleStartItem) ;
230 case GDK_ENTER_NOTIFY:
231 ret = enter_handler (item, event, ImageFrameHandleStartItem) ;
233 case GDK_LEAVE_NOTIFY:
234 ret = leave_handler (item, event, ImageFrameHandleStartItem) ;
243 Editor::canvas_imageframe_end_handle_event (GdkEvent *event, ArdourCanvas::Item* item, ImageFrameView *ifv)
246 ImageFrameTimeAxisGroup* iftag = 0 ;
250 case GDK_BUTTON_PRESS:
251 case GDK_2BUTTON_PRESS:
252 case GDK_3BUTTON_PRESS:
253 clicked_trackview = &ifv->get_time_axis_view() ;
254 iftag = ifv->get_time_axis_group() ;
255 dynamic_cast<ImageFrameTimeAxis*>(clicked_trackview)->get_view()->set_selected_imageframe_view(iftag, ifv);
257 ret = button_press_handler (item, event, ImageFrameHandleEndItem) ;
259 case GDK_BUTTON_RELEASE:
260 ret = button_release_handler (item, event, ImageFrameHandleEndItem) ;
262 case GDK_MOTION_NOTIFY:
263 ret = motion_handler (item, event, ImageFrameHandleEndItem) ;
265 case GDK_ENTER_NOTIFY:
266 ret = enter_handler (item, event, ImageFrameHandleEndItem) ;
268 case GDK_LEAVE_NOTIFY:
269 ret = leave_handler (item, event, ImageFrameHandleEndItem);
278 Editor::canvas_imageframe_view_event (GdkEvent* event, ArdourCanvas::Item* item, ImageFrameTimeAxis* ifta)
283 case GDK_BUTTON_PRESS:
284 case GDK_2BUTTON_PRESS:
285 case GDK_3BUTTON_PRESS:
286 clicked_trackview = ifta ;
287 ret = button_press_handler (item, event, ImageFrameTimeAxisItem) ;
289 case GDK_BUTTON_RELEASE:
290 ret = button_release_handler (item, event, ImageFrameTimeAxisItem) ;
292 case GDK_MOTION_NOTIFY:
301 Editor::canvas_marker_time_axis_view_event (GdkEvent* event, ArdourCanvas::Item* item, MarkerTimeAxis* mta)
306 case GDK_BUTTON_PRESS:
307 case GDK_2BUTTON_PRESS:
308 case GDK_3BUTTON_PRESS:
309 clicked_trackview = mta ;
310 ret = button_press_handler(item, event, MarkerTimeAxisItem) ;
312 case GDK_BUTTON_RELEASE:
313 ret = button_release_handler(item, event, MarkerTimeAxisItem) ;
315 case GDK_MOTION_NOTIFY:
324 Editor::canvas_markerview_item_view_event (GdkEvent* event, ArdourCanvas::Item* item, MarkerView* mta)
329 case GDK_BUTTON_PRESS:
330 case GDK_2BUTTON_PRESS:
331 case GDK_3BUTTON_PRESS:
332 clicked_trackview = &mta->get_time_axis_view() ;
333 dynamic_cast<MarkerTimeAxis*>(clicked_trackview)->get_view()->set_selected_time_axis_item(mta);
334 ret = button_press_handler(item, event, MarkerViewItem) ;
336 case GDK_BUTTON_RELEASE:
337 ret = button_release_handler(item, event, MarkerViewItem) ;
339 case GDK_MOTION_NOTIFY:
340 ret = motion_handler(item, event, MarkerViewItem) ;
349 Editor::canvas_markerview_start_handle_event (GdkEvent* event, ArdourCanvas::Item* item, MarkerView* mta)
354 case GDK_BUTTON_PRESS:
355 case GDK_2BUTTON_PRESS:
356 case GDK_3BUTTON_PRESS:
357 clicked_trackview = &mta->get_time_axis_view() ;
358 dynamic_cast<MarkerTimeAxis*>(clicked_trackview)->get_view()->set_selected_time_axis_item(mta) ;
359 ret = button_press_handler(item, event, MarkerViewHandleStartItem) ;
361 case GDK_BUTTON_RELEASE:
362 ret = button_release_handler(item, event, MarkerViewHandleStartItem) ;
364 case GDK_MOTION_NOTIFY:
365 ret = motion_handler(item, event, MarkerViewHandleStartItem) ;
367 case GDK_ENTER_NOTIFY:
368 ret = enter_handler(item, event, MarkerViewHandleStartItem) ;
370 case GDK_LEAVE_NOTIFY:
371 ret = leave_handler(item, event, MarkerViewHandleStartItem) ;
380 Editor::canvas_markerview_end_handle_event (GdkEvent* event, ArdourCanvas::Item* item, MarkerView* mta)
385 case GDK_BUTTON_PRESS:
386 case GDK_2BUTTON_PRESS:
387 case GDK_3BUTTON_PRESS:
388 clicked_trackview = &mta->get_time_axis_view() ;
389 dynamic_cast<MarkerTimeAxis*>(clicked_trackview)->get_view()->set_selected_time_axis_item(mta) ;
390 ret = button_press_handler(item, event, MarkerViewHandleEndItem) ;
392 case GDK_BUTTON_RELEASE:
393 ret = button_release_handler(item, event, MarkerViewHandleEndItem) ;
395 case GDK_MOTION_NOTIFY:
396 ret = motion_handler(item, event, MarkerViewHandleEndItem) ;
398 case GDK_ENTER_NOTIFY:
399 ret = enter_handler(item, event, MarkerViewHandleEndItem) ;
401 case GDK_LEAVE_NOTIFY:
402 ret = leave_handler(item, event, MarkerViewHandleEndItem) ;
411 /* </CMT Additions file="editor_canvas_events.cc"> */
415 ---------------------------------------------------------------------------------------------------
416 ---------------------------------------------------------------------------------------------------
417 ---------------------------------------------------------------------------------------------------
422 /* <CMT Additions file="editor_mouse.cc"> */
425 Editor::start_imageframe_grab(ArdourCanvas::Item* item, GdkEvent* event)
427 ImageFrameView* ifv = ((ImageFrameTimeAxis*)clicked_trackview)->get_view()->get_selected_imageframe_view() ;
428 drag_info.copy = false ;
429 drag_info.item = item ;
430 drag_info.data = ifv ;
431 drag_info.motion_callback = &Editor::imageframe_drag_motion_callback;
432 drag_info.finished_callback = &Editor::timeaxis_item_drag_finished_callback;
433 drag_info.last_frame_position = ifv->get_position() ;
435 drag_info.last_trackview = &ifv->get_time_axis_view() ;
437 /* this is subtle. raising the regionview itself won't help,
438 because raise_to_top() just puts the item on the top of
439 its parent's stack. so, we need to put the trackview canvas_display group
440 on the top, since its parent is the whole canvas.
442 however, this hides the measure bars within that particular trackview,
443 so move them to the top afterwards.
446 drag_info.item->raise_to_top();
447 drag_info.last_trackview->canvas_display->raise_to_top();
448 //time_line_group->raise_to_top();
449 cursor_group->raise_to_top ();
453 drag_info.pointer_frame_offset = pixel_to_frame(drag_info.grab_x) - drag_info.last_frame_position;
458 Editor::start_markerview_grab(ArdourCanvas::Item* item, GdkEvent* event)
460 MarkerView* mv = ((MarkerTimeAxis*)clicked_trackview)->get_view()->get_selected_time_axis_item() ;
461 drag_info.copy = false ;
462 drag_info.item = item ;
463 drag_info.data = mv ;
464 drag_info.motion_callback = &Editor::markerview_drag_motion_callback;
465 drag_info.finished_callback = &Editor::timeaxis_item_drag_finished_callback;
466 drag_info.last_frame_position = mv->get_position() ;
468 drag_info.last_trackview = &mv->get_time_axis_view() ;
470 /* this is subtle. raising the regionview itself won't help,
471 because raise_to_top() just puts the item on the top of
472 its parent's stack. so, we need to put the trackview canvas_display group
473 on the top, since its parent is the whole canvas.
475 however, this hides the measure bars within that particular trackview,
476 so move them to the top afterwards.
479 drag_info.item->raise_to_top();
480 drag_info.last_trackview->canvas_display->raise_to_top();
481 //time_line_group->raise_to_top();
482 cursor_group->raise_to_top ();
486 drag_info.pointer_frame_offset = pixel_to_frame(drag_info.grab_x) - drag_info.last_frame_position ;
491 Editor::markerview_drag_motion_callback(ArdourCanvas::Item*, GdkEvent* event)
495 MarkerView* mv = reinterpret_cast<MarkerView*>(drag_info.data) ;
496 jack_nframes_t pending_region_position ;
497 jack_nframes_t pointer_frame ;
499 pointer_frame = event_frame(event, &cx, &cy) ;
501 snap_to(pointer_frame) ;
503 if (pointer_frame > (jack_nframes_t) drag_info.pointer_frame_offset)
505 pending_region_position = pointer_frame - drag_info.pointer_frame_offset ;
506 snap_to(pending_region_position) ;
508 // we dont allow marker items to extend beyond, or in front of the marked items so
509 // cap the value to the marked items position and duration
510 if((pending_region_position + mv->get_duration()) >= ((mv->get_marked_item()->get_position()) + (mv->get_marked_item()->get_duration())))
512 pending_region_position = (mv->get_marked_item()->get_position() + mv->get_marked_item()->get_duration()) - (mv->get_duration()) ;
514 else if(pending_region_position <= mv->get_marked_item()->get_position())
516 pending_region_position = mv->get_marked_item()->get_position() ;
521 pending_region_position = mv->get_marked_item()->get_position() ;
524 drag_info.last_frame_position = pending_region_position ;
526 // we treat this as a special case, usually we want to send the identitiy of the caller
527 // but in this case, that would trigger our socket handler to handle the event, sending
528 // notification to the image compositor. This would be fine, except that we have not
529 // finished the drag, we therefore do not want to sent notification until we have
530 // completed the drag, only then do we want the image compositor notofied.
531 // We therefore set the caller identity to the special case of 0
532 mv->set_position(pending_region_position, 0) ;
534 show_verbose_time_cursor(pending_region_position) ;
538 Editor::imageframe_drag_motion_callback(ArdourCanvas::Item*, GdkEvent* event)
542 ImageFrameView* ifv = reinterpret_cast<ImageFrameView*>(drag_info.data) ;
544 jack_nframes_t pending_region_position;
545 jack_nframes_t pointer_frame;
547 pointer_frame = event_frame(event, &cx, &cy) ;
549 snap_to(pointer_frame) ;
551 if (pointer_frame > (jack_nframes_t) drag_info.pointer_frame_offset)
553 pending_region_position = pointer_frame - drag_info.pointer_frame_offset ;
554 snap_to(pending_region_position) ;
558 pending_region_position = 0 ;
561 drag_info.grab_x = cx;
562 //drag_info.last_frame_position = pending_region_position ;
563 drag_info.current_pointer_frame = pending_region_position ;
565 // we treat this as a special case, usually we want to send the identitiy of the caller
566 // but in this case, that would trigger our socket handler to handle the event, sending
567 // notification to the image compositor. This would be fine, except that we have not
568 // finished the drag, we therefore do not want to sent notification until we have
569 // completed the drag, only then do we want the image compositor notofied.
570 // We therefore set the caller identity to the special case of 0
571 ifv->set_position(pending_region_position, 0) ;
573 show_verbose_time_cursor(pending_region_position) ;
577 Editor::timeaxis_item_drag_finished_callback(ArdourCanvas::Item*, GdkEvent* event)
579 jack_nframes_t where ;
580 TimeAxisViewItem* tavi = reinterpret_cast<TimeAxisViewItem*>(drag_info.data) ;
582 bool item_x_movement = (drag_info.last_frame_position != tavi->get_position()) ;
584 hide_verbose_canvas_cursor() ;
586 /* no x or y movement either means the regionview hasn't been moved, or has been moved
587 but is back in it's original position/trackview.*/
589 if(!item_x_movement && event && event->type == GDK_BUTTON_RELEASE)
591 /* No motion: either set the current region, or align the clicked region
592 with the current one.
599 /* base the new region position on the current position of the regionview.*/
600 where = drag_info.current_pointer_frame ;
602 // final call to set position after the motion to tell interested parties of the new position
603 tavi->set_position(where, this) ;
607 //where = tavi->get_position() ;
615 Editor::imageframe_start_handle_op(ArdourCanvas::Item* item, GdkEvent* event)
617 // get the selected item from the parent time axis
618 ImageFrameTimeAxis* ifta = dynamic_cast<ImageFrameTimeAxis*>(clicked_trackview) ;
621 ImageFrameView* ifv = ifta->get_view()->get_selected_imageframe_view() ;
624 fatal << _("programming error: no ImageFrameView selected") << endmsg;
629 drag_info.item = ifv->get_canvas_frame() ;
630 drag_info.data = ifv;
631 drag_info.grab_x = event->motion.x;
632 drag_info.cumulative_x_drag = 0;
633 drag_info.motion_callback = &Editor::imageframe_start_handle_trim_motion ;
634 drag_info.finished_callback = &Editor::imageframe_start_handle_end_trim ;
638 show_verbose_time_cursor(ifv->get_position(), 10) ;
643 Editor::imageframe_end_handle_op(ArdourCanvas::Item* item, GdkEvent* event)
645 // get the selected item from the parent time axis
646 ImageFrameTimeAxis* ifta = dynamic_cast<ImageFrameTimeAxis*>(clicked_trackview) ;
650 ImageFrameView* ifv = ifta->get_view()->get_selected_imageframe_view() ;
654 fatal << _("programming error: no ImageFrameView selected") << endmsg ;
659 drag_info.item = ifv->get_canvas_frame() ;
660 drag_info.data = ifv ;
661 drag_info.grab_x = event->motion.x ;
662 drag_info.cumulative_x_drag = 0 ;
663 drag_info.motion_callback = &Editor::imageframe_end_handle_trim_motion ;
664 drag_info.finished_callback = &Editor::imageframe_end_handle_end_trim ;
666 start_grab(event, trimmer_cursor) ;
668 show_verbose_time_cursor(ifv->get_position() + ifv->get_duration(), 10) ;
673 Editor::imageframe_start_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event)
675 ImageFrameView* ifv = reinterpret_cast<ImageFrameView*> (drag_info.data) ;
677 jack_nframes_t start = 0 ;
678 jack_nframes_t end = 0 ;
679 jack_nframes_t pointer_frame = event_frame(event) ;
681 // chekc th eposition of the item is not locked
682 if(!ifv->get_position_locked()) {
683 snap_to(pointer_frame) ;
685 if(pointer_frame != drag_info.last_pointer_frame) {
686 start = ifv->get_position() ;
687 end = ifv->get_position() + ifv->get_duration() ;
689 if (pointer_frame > end) {
692 start = pointer_frame ;
695 // are we getting bigger or smaller?
696 jack_nframes_t new_dur_val = end - start ;
698 // start handle, so a smaller pointer frame increases our component size
699 if(pointer_frame <= drag_info.grab_frame)
701 if(ifv->get_max_duration_active() && (new_dur_val > ifv->get_max_duration()))
703 new_dur_val = ifv->get_max_duration() ;
704 start = end - new_dur_val ;
708 // current values are ok
713 if(ifv->get_min_duration_active() && (new_dur_val < ifv->get_min_duration()))
715 new_dur_val = ifv->get_min_duration() ;
716 start = end - new_dur_val ;
720 // current values are ok
724 drag_info.last_pointer_frame = pointer_frame ;
726 /* re-calculatethe duration and position of the imageframeview */
727 drag_info.cumulative_x_drag = new_dur_val ;
729 // we treat this as a special case, usually we want to send the identitiy of the caller
730 // but in this case, that would trigger our socket handler to handle the event, sending
731 // notification to the image compositor. This would be fine, except that we have not
732 // finished the drag, we therefore do not want to sent notification until we have
733 // completed the drag, only then do we want the image compositor notofied.
734 // We therefore set the caller identity to the special case of 0
735 ifv->set_duration(new_dur_val, 0) ;
736 ifv->set_position(start, 0) ;
740 show_verbose_time_cursor(start, 10) ;
744 Editor::imageframe_start_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event)
746 ImageFrameView* ifv = reinterpret_cast<ImageFrameView *> (drag_info.data) ;
748 if (drag_info.cumulative_x_drag == 0)
754 jack_nframes_t temp = ifv->get_position() + ifv->get_duration() ;
756 ifv->set_position((jack_nframes_t) (temp - drag_info.cumulative_x_drag), this) ;
757 ifv->set_duration((jack_nframes_t) drag_info.cumulative_x_drag, this) ;
762 Editor::imageframe_end_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event)
764 ImageFrameView* ifv = reinterpret_cast<ImageFrameView *> (drag_info.data) ;
766 jack_nframes_t start = 0 ;
767 jack_nframes_t end = 0 ;
768 jack_nframes_t pointer_frame = event_frame(event) ;
769 jack_nframes_t new_dur_val = 0 ;
771 snap_to(pointer_frame) ;
773 if (pointer_frame != drag_info.last_pointer_frame)
775 start = ifv->get_position() ;
776 end = ifv->get_position() + ifv->get_duration() ;
777 if (pointer_frame < start)
783 end = pointer_frame ;
786 new_dur_val = end - start ;
788 // are we getting bigger or smaller?
789 if(pointer_frame >= drag_info.last_pointer_frame)
791 if(ifv->get_max_duration_active() && (new_dur_val > ifv->get_max_duration()))
793 new_dur_val = ifv->get_max_duration() ;
798 if(ifv->get_min_duration_active() && (new_dur_val < ifv->get_min_duration()))
800 new_dur_val = ifv->get_min_duration() ;
804 drag_info.last_pointer_frame = pointer_frame ;
805 drag_info.cumulative_x_drag = new_dur_val ;
807 // we treat this as a special case, usually we want to send the identitiy of the caller
808 // but in this case, that would trigger our socket handler to handle the event, sending
809 // notification to the image compositor. This would be fine, except that we have not
810 // finished the drag, we therefore do not want to sent notification until we have
811 // completed the drag, only then do we want the image compositor notofied.
812 // We therefore set the caller identity to the special case of 0
813 ifv->set_duration(new_dur_val, 0) ;
816 show_verbose_time_cursor(new_dur_val, 10) ;
821 Editor::imageframe_end_handle_end_trim (ArdourCanvas::Item* item, GdkEvent* event)
823 ImageFrameView* ifv = reinterpret_cast<ImageFrameView *> (drag_info.data) ;
825 if (drag_info.cumulative_x_drag == 0)
831 jack_nframes_t new_duration = (jack_nframes_t)drag_info.cumulative_x_drag ;
832 if((new_duration <= ifv->get_max_duration()) && (new_duration >= ifv->get_min_duration()))
834 ifv->set_duration(new_duration, this) ;
841 Editor::markerview_item_start_handle_op(ArdourCanvas::Item* item, GdkEvent* event)
843 MarkerView* mv = reinterpret_cast<MarkerTimeAxis*>(clicked_trackview)->get_view()->get_selected_time_axis_item() ;
847 fatal << _("programming error: no MarkerView selected") << endmsg ;
852 drag_info.item = mv->get_canvas_frame() ;
854 drag_info.grab_x = event->motion.x;
856 drag_info.cumulative_x_drag = 0 ;
857 drag_info.motion_callback = &Editor::markerview_start_handle_trim_motion ;
858 drag_info.finished_callback = &Editor::markerview_start_handle_end_trim ;
860 start_grab(event, trimmer_cursor) ;
864 Editor::markerview_item_end_handle_op(ArdourCanvas::Item* item, GdkEvent* event)
866 MarkerView* mv = reinterpret_cast<MarkerTimeAxis*>(clicked_trackview)->get_view()->get_selected_time_axis_item() ;
869 fatal << _("programming error: no MarkerView selected") << endmsg ;
874 drag_info.item = mv->get_canvas_frame() ;
875 drag_info.data = mv ;
876 drag_info.grab_x = event->motion.x ;
877 drag_info.cumulative_x_drag = 0 ;
879 drag_info.motion_callback = &Editor::markerview_end_handle_trim_motion ;
880 drag_info.finished_callback = &Editor::markerview_end_handle_end_trim ;
882 start_grab(event, trimmer_cursor) ;
887 Editor::markerview_start_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event)
889 MarkerView* mv = reinterpret_cast<MarkerView*> (drag_info.data) ;
891 jack_nframes_t start = 0 ;
892 jack_nframes_t end = 0 ;
893 jack_nframes_t pointer_frame = event_frame(event) ;
895 // chekc th eposition of the item is not locked
896 if(!mv->get_position_locked())
898 snap_to(pointer_frame) ;
899 if(pointer_frame != drag_info.last_pointer_frame)
901 start = mv->get_position() ;
902 end = mv->get_position() + mv->get_duration() ;
904 if (pointer_frame > end)
910 start = pointer_frame ;
913 // are we getting bigger or smaller?
914 jack_nframes_t new_dur_val = end - start ;
916 if(pointer_frame <= drag_info.grab_frame)
918 if(mv->get_max_duration_active() && (new_dur_val > mv->get_max_duration()))
920 new_dur_val = mv->get_max_duration() ;
921 start = end - new_dur_val ;
925 // current values are ok
930 if(mv->get_min_duration_active() && (new_dur_val < mv->get_min_duration()))
932 new_dur_val = mv->get_min_duration() ;
933 start = end - new_dur_val ;
937 // current values are ok
941 drag_info.last_pointer_frame = pointer_frame ;
943 /* re-calculatethe duration and position of the imageframeview */
944 drag_info.cumulative_x_drag = new_dur_val ;
946 // we treat this as a special case, usually we want to send the identitiy of the caller
947 // but in this case, that would trigger our socket handler to handle the event, sending
948 // notification to the image compositor. This would be fine, except that we have not
949 // finished the drag, we therefore do not want to sent notification until we have
950 // completed the drag, only then do we want the image compositor notofied.
951 // We therefore set the caller identity to the special case of 0
952 mv->set_duration(new_dur_val, 0) ;
953 mv->set_position(start, 0) ;
957 show_verbose_time_cursor(start, 10) ;
961 Editor::markerview_start_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event)
963 MarkerView* mv = reinterpret_cast<MarkerView*> (drag_info.data) ;
965 if (drag_info.cumulative_x_drag == 0)
971 jack_nframes_t temp = mv->get_position() + mv->get_duration() ;
973 mv->set_position((jack_nframes_t) (temp - drag_info.cumulative_x_drag), this) ;
974 mv->set_duration((jack_nframes_t) drag_info.cumulative_x_drag, this) ;
979 Editor::markerview_end_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event)
981 MarkerView* mv = reinterpret_cast<MarkerView*> (drag_info.data) ;
983 jack_nframes_t start = 0 ;
984 jack_nframes_t end = 0 ;
985 jack_nframes_t pointer_frame = event_frame(event) ;
986 jack_nframes_t new_dur_val = 0 ;
988 snap_to(pointer_frame) ;
990 if (pointer_frame != drag_info.last_pointer_frame)
992 start = mv->get_position() ;
993 end = mv->get_position() + mv->get_duration() ;
995 if(pointer_frame < start)
1001 end = pointer_frame ;
1004 new_dur_val = end - start ;
1006 // are we getting bigger or smaller?
1007 if(pointer_frame >= drag_info.last_pointer_frame)
1009 // we cant extend beyond the item we are marking
1010 ImageFrameView* marked_item = mv->get_marked_item() ;
1011 jack_nframes_t marked_end = marked_item->get_position() + marked_item->get_duration() ;
1013 if(mv->get_max_duration_active() && (new_dur_val > mv->get_max_duration()))
1015 if((start + mv->get_max_duration()) > marked_end)
1017 new_dur_val = marked_end - start ;
1021 new_dur_val = mv->get_max_duration() ;
1024 else if(end > marked_end)
1026 new_dur_val = marked_end - start ;
1031 if(mv->get_min_duration_active() && (new_dur_val < mv->get_min_duration()))
1033 new_dur_val = mv->get_min_duration() ;
1038 drag_info.last_pointer_frame = pointer_frame ;
1039 drag_info.cumulative_x_drag = new_dur_val ;
1041 // we treat this as a special case, usually we want to send the identitiy of the caller
1042 // but in this case, that would trigger our socket handler to handle the event, sending
1043 // notification to the image compositor. This would be fine, except that we have not
1044 // finished the drag, we therefore do not want to sent notification until we have
1045 // completed the drag, only then do we want the image compositor notofied.
1046 // We therefore set the caller identity to the special case of 0
1047 mv->set_duration(new_dur_val, 0) ;
1050 show_verbose_time_cursor(new_dur_val, 10) ;
1055 Editor::markerview_end_handle_end_trim (ArdourCanvas::Item* item, GdkEvent* event)
1057 MarkerView* mv = reinterpret_cast<MarkerView*> (drag_info.data) ;
1059 if (drag_info.cumulative_x_drag == 0)
1065 jack_nframes_t new_duration = (jack_nframes_t)drag_info.cumulative_x_drag ;
1066 mv->set_duration(new_duration, this) ;
1071 /* </CMT Additions file="editor_mouse.cc"> */
1079 /* <CMT Additions file="editor_route_list.cc"> */
1082 Editor::handle_new_imageframe_time_axis_view(const string & track_name, void* src)
1084 ImageFrameTimeAxis* iftav ;
1085 iftav = new ImageFrameTimeAxis(track_name, *this, *session, track_canvas) ;
1086 iftav->set_time_axis_name(track_name, this) ;
1087 track_views.push_back(iftav) ;
1089 TreeModel::Row row = *(route_display_model->append());
1091 row[route_display_columns.text] = iftav->name();
1092 row[route_display_columns.tv] = iftav;
1093 route_list_display.get_selection()->select (row);
1095 iftav->GoingAway.connect(bind(mem_fun(*this, &Editor::remove_route), (TimeAxisView*)iftav)) ;
1096 iftav->gui_changed.connect(mem_fun(*this, &Editor::handle_gui_changes)) ;
1100 Editor::handle_new_imageframe_marker_time_axis_view(const string & track_name, TimeAxisView* marked_track)
1102 MarkerTimeAxis* mta = new MarkerTimeAxis (*this, *this->current_session(), track_canvas, track_name, marked_track) ;
1103 ((ImageFrameTimeAxis*)marked_track)->add_marker_time_axis(mta, this) ;
1104 track_views.push_back(mta) ;
1106 TreeModel::Row row = *(route_display_model->append());
1108 row[route_display_columns.text] = mta->name();
1109 row[route_display_columns.tv] = mta;
1110 route_list_display.get_selection()->select (row);
1112 mta->GoingAway.connect(bind(mem_fun(*this, &Editor::remove_route), (TimeAxisView*)mta)) ;
1116 /* </CMT Additions file="editor_route_list.cc"> */