various fixes to MidiRegionView selection handling, key handling, drawing of ghost...
[ardour2.git] / gtk2_ardour / marker_view.cc
blob4bd842341bc76be7c0d8eaa8169617559ad105da
1 /*
2 Copyright (C) 2003 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 <gtkmm.h>
22 #include "imageframe_time_axis.h"
23 #include "imageframe_view.h"
24 #include "canvas-simplerect.h"
25 #include "public_editor.h"
26 #include "marker_view.h"
28 using namespace ARDOUR ;
30 PBD::Signal1<void,MarkerView*> MarkerView::CatchDeletion
32 //---------------------------------------------------------------------------------------//
33 // Constructor / Desctructor
35 /**
36 * Constructs a new MarkerView
38 * @param parent the parent canvas item
39 * @param tv the parent TimeAxisView of this item
40 * @param tavi the TimeAxisViewItem that this item is to be assciated (marking) with
41 * @param spu the current samples per unit
42 * @param base_color
43 * @param mark_type the marker type/name text, eg fade out, pan up etc.
44 * @param mark_id unique name/id of this item
45 * @param start the start time of this item
46 * @param duration the duration of this item
48 MarkerView::MarkerView(ArdourCanvas::Group *parent,
49 TimeAxisView* tv,
50 ImageFrameView* marked,
51 double spu,
52 Gdk::Color& basic_color,
53 std::string mark_type,
54 std::string mark_id,
55 framepos_t start,
56 framecnt_t duration)
57 : TimeAxisViewItem(mark_id, *parent,*tv,spu,basic_color,start,duration)
59 mark_type_text = mark_type ;
60 marked_item = marked ;
62 // set the canvas item text to the marker type, not the id
63 set_name_text(mark_type_text) ;
65 // hook up our canvas events
67 if (frame_handle_start) {
68 frame_handle_start->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_markerview_start_handle_event), frame_handle_start, this));
69 frame_handle_end->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_markerview_end_handle_event), frame_handle_end, this));
71 group->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_markerview_item_view_event), group, this));
73 set_position(start, this) ;
74 set_duration(duration, this) ;
77 /**
78 * Destructor
79 * Destroys this Marker Item and removes the association between itself and the item it is marking.
81 MarkerView::~MarkerView()
83 // remove the association our marked may still have to us
84 if(marked_item)
86 marked_item->remove_marker_view_item(this, this) ;
91 //---------------------------------------------------------------------------------------//
92 // Marker Type Methods
94 /**
95 * Sets the marker Type text of this this MarkerItem, eg fade_out, pan up etc.
97 * @param type_text the marker type text of this item
99 void
100 MarkerView::set_mark_type_text(std::string type_text)
102 mark_type_text = type_text ;
103 MarkTypeChanged(mark_type_text, this) ; /* EMIT_SIGNAL */
107 * Returns the marker Type of this this MarkerItem, eg fade_out, pan up etc.
109 * @return the marker type text of this item
111 std::string
112 MarkerView::get_mark_type_text() const
114 return(mark_type_text) ;
118 //---------------------------------------------------------------------------------------//
119 // Marked Item Methods
121 ImageFrameView*
122 MarkerView::set_marked_item(ImageFrameView* item)
124 ImageFrameView* temp = marked_item ;
125 marked_item = item ;
127 MarkedItemChanged(marked_item, this) ; /* EMIT_SIGNAL */
128 return(temp) ;
131 ImageFrameView*
132 MarkerView::get_marked_item()
134 return(marked_item) ;