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.
23 #include <pbd/error.h>
25 #include <gtkmm/menu.h>
27 #include <gtkmm2ext/utils.h>
29 #include <ardour/session.h>
30 #include <ardour/utils.h>
32 #include "ardour_ui.h"
33 #include "public_editor.h"
34 #include "imageframe_time_axis.h"
35 #include "selection.h"
36 #include "imageframe_time_axis_view.h"
37 #include "marker_time_axis_view.h"
38 #include "imageframe_view.h"
39 #include "marker_time_axis.h"
40 #include "canvas_impl.h"
44 using namespace ARDOUR;
49 //---------------------------------------------------------------------------------------//
50 // Constructor / Desctructor
53 * Constructs a new MarkerTimeAxis
55 * @param ed the PublicEditor
56 * @param sess the current session
57 * @param canvas the parent canvas item
58 * @param name the name/id of this time axis
59 * @param tav the associated track view that this MarkerTimeAxis is marking up
61 MarkerTimeAxis::MarkerTimeAxis (PublicEditor& ed, ARDOUR::Session& sess, Canvas& canvas, const string & name, TimeAxisView* tav)
63 VisualTimeAxis(name, ed, sess, canvas)
65 /* the TimeAxisView these markers are associated with */
66 marked_time_axis = tav ;
68 _color = unique_random_color() ;
69 time_axis_name = name ;
71 selection_group = new Group (*canvas_display);
72 selection_group->hide();
74 // intialize our data items
79 /* create our new marker time axis strip view */
80 view = new MarkerTimeAxisView(*this) ;
82 // set the initial time axis text label
85 // set the initial height of this time axis
91 * Responsible for destroying any marker items upon this time axis
93 MarkerTimeAxis::~MarkerTimeAxis()
95 GoingAway() ; /* EMIT_SIGNAL */
97 // destroy the view helper
98 // this handles removing and destroying individual marker items
107 //---------------------------------------------------------------------------------------//
111 * Sets the height of this TrackView to one of the defined TrackHeights
113 * @param h the TrackHeight value to set
116 MarkerTimeAxis::set_height (TrackHeight h)
118 VisualTimeAxis::set_height(h) ;
120 // tell out view helper of the change too
123 view->set_height((double) height) ;
126 // tell those interested that we have had our height changed
127 gui_changed("track_height",(void*)0) ; /* EMIT_SIGNAL */
131 * Sets the number of samples per unit that are used.
132 * This is used to determine the sizes of items upon this time axis
134 * @param spu the number of samples per unit
137 MarkerTimeAxis::set_samples_per_unit(double spu)
139 TimeAxisView::set_samples_per_unit (editor.get_current_zoom());
142 view->set_samples_per_unit(spu) ;
147 * Show the popup edit menu
149 * @param button the mouse button pressed
150 * @param time when to show the popup
151 * @param clicked_mv the MarkerView that the event ocured upon, or 0 if none
152 * @param with_item true if an item has been selected upon the time axis, used to set context menu
155 MarkerTimeAxis::popup_marker_time_axis_edit_menu(int button, int32_t time, MarkerView* clicked_mv, bool with_item)
159 build_marker_menu() ;
164 marker_item_menu->set_sensitive(true) ;
168 marker_item_menu->set_sensitive(false) ;
171 marker_menu->popup(button,time) ;
176 * convenience method to select a new track color and apply it to the view and view items
180 MarkerTimeAxis::select_track_color()
182 if(VisualTimeAxis::choose_time_axis_color())
186 view->apply_color(_color) ;
192 * Handles the building of the popup menu
195 MarkerTimeAxis::build_display_menu()
197 using namespace Menu_Helpers;
199 /* get the size menu ready */
203 TimeAxisView::build_display_menu();
205 /* now fill it with our stuff */
206 MenuList& items = display_menu->items();
208 items.push_back(MenuElem (_("Rename"), mem_fun(*this, &VisualTimeAxis::start_time_axis_rename)));
210 items.push_back(SeparatorElem()) ;
211 items.push_back(MenuElem (_("Height"), *size_menu));
212 items.push_back(MenuElem (_("Color"), mem_fun(*this, &MarkerTimeAxis::select_track_color)));
213 items.push_back(SeparatorElem()) ;
215 items.push_back(MenuElem (_("Remove"), bind(mem_fun(*this, &MarkerTimeAxis::remove_this_time_axis), (void*)this)));
219 * handles the building of the MarkerView sub menu
222 MarkerTimeAxis::build_marker_menu()
224 using namespace Menu_Helpers;
227 marker_menu = manage(new Menu) ;
228 marker_menu->set_name ("ArdourContextMenu");
229 MenuList& items = marker_menu->items();
231 marker_item_menu = manage(new Menu) ;
232 marker_item_menu->set_name ("ArdourContextMenu");
233 MenuList& marker_sub_items = marker_item_menu->items() ;
236 Menu* duration_menu = manage(new Menu) ;
237 duration_menu->set_name ("ArdourContextMenu");
238 MenuList& duration_items = duration_menu->items() ;
242 duration_items.push_back(MenuElem (_("1 seconds"), bind (mem_fun (view, &MarkerTimeAxisView::set_marker_duration_sec), 1.0))) ;
243 duration_items.push_back(MenuElem (_("1.5 seconds"), bind (mem_fun (view, &MarkerTimeAxisView::set_marker_duration_sec), 1.5))) ;
244 duration_items.push_back(MenuElem (_("2 seconds"), bind (mem_fun (view, &MarkerTimeAxisView::set_marker_duration_sec), 2.0))) ;
245 duration_items.push_back(MenuElem (_("2.5 seconds"), bind (mem_fun (view, &MarkerTimeAxisView::set_marker_duration_sec), 2.5))) ;
246 duration_items.push_back(MenuElem (_("3 seconds"), bind (mem_fun (view, &MarkerTimeAxisView::set_marker_duration_sec), 3.0))) ;
248 //duration_items.push_back(SeparatorElem()) ;
249 //duration_items.push_back(MenuElem (_("custom"), mem_fun(*this, &ImageFrameTimeAxis::set_marker_duration_custom))) ;
251 marker_sub_items.push_back(MenuElem(_("Duration (sec)"), *duration_menu)) ;
253 marker_sub_items.push_back(SeparatorElem()) ;
254 marker_sub_items.push_back(MenuElem (_("Remove Marker"), bind(mem_fun(view, &MarkerTimeAxisView::remove_selected_marker_view),(void*)this))) ;
256 items.push_back(MenuElem(_("Marker"), *marker_item_menu)) ;
257 items.push_back(MenuElem (_("Rename Track"), mem_fun(*this,&MarkerTimeAxis::start_time_axis_rename))) ;
259 marker_menu->show_all() ;
265 * Returns the view helper of this TimeAxis
267 * @return the view helper of this TimeAxis
270 MarkerTimeAxis::get_view()
276 * Returns the TimeAxisView that this markerTimeAxis is marking up
278 * @return the TimeAXisView that this MarkerTimeAxis is marking
281 MarkerTimeAxis::get_marked_time_axis()
283 return(marked_time_axis) ;