diff options
-rw-r--r-- | gtk2_ardour/ardour_ui.cc | 15 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/audio_clock.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/audio_clock.h | 14 | ||||
-rw-r--r-- | gtk2_ardour/editor.cc | 7 | ||||
-rw-r--r-- | gtk2_ardour/editor.h | 150 | ||||
-rw-r--r-- | gtk2_ardour/editor_markers.cc | 15 | ||||
-rw-r--r-- | gtk2_ardour/editor_rulers.cc | 4 | ||||
-rw-r--r-- | gtk2_ardour/main_clock.cc | 77 | ||||
-rw-r--r-- | gtk2_ardour/main_clock.h | 15 | ||||
-rw-r--r-- | gtk2_ardour/public_editor.h | 7 | ||||
-rw-r--r-- | gtk2_ardour/tempo_dialog.cc | 31 | ||||
-rw-r--r-- | gtk2_ardour/tempo_dialog.h | 4 | ||||
-rw-r--r-- | libs/ardour/ardour/tempo.h | 1 | ||||
-rw-r--r-- | libs/ardour/tempo.cc | 27 | ||||
-rw-r--r-- | libs/backends/wavesaudio/waves_audiobackend.midi.cc | 4 |
16 files changed, 257 insertions, 118 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 4939c78735..ac1a0370b0 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -184,8 +184,8 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir) , ui_config (new UIConfiguration) , gui_object_state (new GUIObjectState) - , primary_clock (new MainClock (X_("primary"), false, X_("transport"), true, true, true, false, true)) - , secondary_clock (new MainClock (X_("secondary"), false, X_("secondary"), true, true, false, false, true)) + , primary_clock (new MainClock (X_("primary"), X_("transport"), true )) + , secondary_clock (new MainClock (X_("secondary"), X_("secondary"), false)) /* big clock */ @@ -2354,7 +2354,7 @@ ARDOUR_UI::update_clocks () if (!_session) return; if (editor && !editor->dragging_playhead()) { - Clock (_session->audible_frame(), false, editor->get_preferred_edit_position()); /* EMIT_SIGNAL */ + Clock (_session->audible_frame(), false, editor->get_preferred_edit_position (true)); /* EMIT_SIGNAL */ } } @@ -4080,7 +4080,10 @@ ARDOUR_UI::keyboard_settings () const void ARDOUR_UI::create_xrun_marker (framepos_t where) { - editor->mouse_add_new_marker (where, false, true); + if (_session) { + Location *location = new Location (*_session, where, where, _("xrun"), Location::IsMark); + _session->locations()->add (location); + } } void @@ -4402,13 +4405,13 @@ void ARDOUR_UI::update_transport_clocks (framepos_t pos) { if (ui_config->get_primary_clock_delta_edit_cursor()) { - primary_clock->set (pos, false, editor->get_preferred_edit_position()); + primary_clock->set (pos, false, editor->get_preferred_edit_position (true)); } else { primary_clock->set (pos); } if (ui_config->get_secondary_clock_delta_edit_cursor()) { - secondary_clock->set (pos, false, editor->get_preferred_edit_position()); + secondary_clock->set (pos, false, editor->get_preferred_edit_position (true)); } else { secondary_clock->set (pos); } diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 6cce503511..c078422ef3 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -186,7 +186,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr static ARDOUR_UI *instance () { return theArdourUI; } static UIConfiguration *config () { return theArdourUI->ui_config; } - PublicEditor& the_editor(){return *editor;} + PublicEditor& the_editor() { return *editor;} Mixer_UI* the_mixer() { return mixer; } void new_midi_tracer_window (); diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index a90946f3ba..2a84abc66a 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -334,7 +334,7 @@ AudioClock::render (cairo_t* cr, cairo_rectangle_t*) if (mode_based_info_ratio != 1.0) { - double left_rect_width = round (((get_width() - separator_height) * mode_based_info_ratio) + 0.5); + double left_rect_width = get_left_rect_width(); if (_need_bg) { if (corner_radius) { diff --git a/gtk2_ardour/audio_clock.h b/gtk2_ardour/audio_clock.h index 5ab75c261f..10a24cd3ac 100644 --- a/gtk2_ardour/audio_clock.h +++ b/gtk2_ardour/audio_clock.h @@ -98,10 +98,22 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr protected: void render (cairo_t*, cairo_rectangle_t*); + bool get_is_duration () const { return is_duration; } ; virtual void build_ops_menu (); Gtk::Menu *ops_menu; + bool on_button_press_event (GdkEventButton *ev); + bool on_button_release_event(GdkEventButton *ev); + bool is_lower_layout_click(int y) const { + return y > upper_height + separator_height; + } + bool is_right_layout_click(int x) const { + return x > x_leading_padding + get_left_rect_width() + separator_height; + } + double get_left_rect_width() const { + return round (((get_width() - separator_height) * mode_based_info_ratio) + 0.5); + } private: Mode _mode; std::string _name; @@ -187,8 +199,6 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr bool on_key_press_event (GdkEventKey *); bool on_key_release_event (GdkEventKey *); bool on_scroll_event (GdkEventScroll *ev); - bool on_button_press_event (GdkEventButton *ev); - bool on_button_release_event(GdkEventButton *ev); void on_style_changed (const Glib::RefPtr<Gtk::Style>&); void on_size_request (Gtk::Requisition* req); bool on_motion_notify_event (GdkEventMotion *ev); diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 8ea9dd2f9a..09d70e40d6 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -4661,9 +4661,9 @@ Editor::get_preferred_edit_position (bool ignore_playhead, bool from_context_men framepos_t where = 0; EditPoint ep = _edit_point; - if(Profile->get_mixbus()) + if (Profile->get_mixbus()) if (ep == EditAtSelectedMarker) - ep=EditAtPlayhead; + ep = EditAtPlayhead; if (from_outside_canvas && (ep == EditAtMouse)) { ep = EditAtPlayhead; @@ -4687,8 +4687,9 @@ Editor::get_preferred_edit_position (bool ignore_playhead, bool from_context_men /* XXX not right but what can we do ? */ return 0; } - } else + } else { where = _session->audible_frame(); + } DEBUG_TRACE (DEBUG::CutNPaste, string_compose ("GPEP: use playhead @ %1\n", where)); break; diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 7cfc6ff9ff..9f37f9d1f2 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -288,9 +288,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void set_zoom_focus (Editing::ZoomFocus); Editing::ZoomFocus get_zoom_focus () const { return zoom_focus; } framecnt_t get_current_zoom () const { return samples_per_pixel; } - void cycle_zoom_focus (); + void cycle_zoom_focus (); void temporal_zoom_step (bool coarser); - void ensure_time_axis_view_is_visible (TimeAxisView const & tav, bool at_top); + void ensure_time_axis_view_is_visible (TimeAxisView const & tav, bool at_top); void tav_zoom_step (bool coarser); void tav_zoom_smooth (bool coarser, bool force_all); @@ -365,8 +365,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void scroll_tracks_down_line (); void scroll_tracks_up_line (); - bool scroll_up_one_track (bool skip_child_views = false); - bool scroll_down_one_track (bool skip_child_views = false); + + bool scroll_up_one_track (bool skip_child_views = false); + bool scroll_down_one_track (bool skip_child_views = false); void prepare_for_cleanup (); void finish_cleanup (); @@ -421,7 +422,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD framepos_t& pos, boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>()); - void get_regions_corresponding_to (boost::shared_ptr<ARDOUR::Region> region, std::vector<RegionView*>& regions, bool src_comparison); + void get_regions_corresponding_to (boost::shared_ptr<ARDOUR::Region> region, std::vector<RegionView*>& regions, bool src_comparison); void get_regionviews_by_id (PBD::ID const id, RegionSelection & regions) const; void get_per_region_note_selection (std::list<std::pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > >&) const; @@ -461,8 +462,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD return _drags; } - void maybe_autoscroll (bool, bool, bool); - bool autoscroll_active() const; + void maybe_autoscroll (bool, bool, bool); + bool autoscroll_active() const; Gdk::Cursor* get_canvas_cursor () const; @@ -521,11 +522,16 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void metric_get_minsec (std::vector<ArdourCanvas::Ruler::Mark>&, gdouble, gdouble, gint); /* editing operations that need to be public */ - void mouse_add_new_marker (framepos_t where, bool is_cd=false, bool is_xrun=false); + void mouse_add_new_marker (framepos_t where, bool is_cd=false); void split_regions_at (framepos_t, RegionSelection&); void split_region_at_points (boost::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret, bool select_new = false); RegionSelection get_regions_from_selection_and_mouse (framepos_t); + void mouse_add_new_tempo_event (framepos_t where); + void mouse_add_new_meter_event (framepos_t where); + void edit_tempo_section (ARDOUR::TempoSection*); + void edit_meter_section (ARDOUR::MeterSection*); + protected: void map_transport_state (); void map_position_change (framepos_t); @@ -572,7 +578,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void cancel_visual_state_op (uint32_t n); framepos_t leftmost_frame; - framecnt_t samples_per_pixel; + framecnt_t samples_per_pixel; Editing::ZoomFocus zoom_focus; void set_samples_per_pixel (framecnt_t); @@ -841,11 +847,11 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD */ ArdourCanvas::Container* _drag_motion_group; - /* a rect that sits at the bottom of all tracks to act as a drag-no-drop/clickable + /* a rect that sits at the bottom of all tracks to act as a drag-no-drop/clickable * target area. */ - ArdourCanvas::Rectangle* _canvas_drop_zone; - bool canvas_drop_zone_event (GdkEvent* event); + ArdourCanvas::Rectangle* _canvas_drop_zone; + bool canvas_drop_zone_event (GdkEvent* event); enum RulerType { ruler_metric_timecode = 0, @@ -882,7 +888,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void update_just_timecode (); void compute_fixed_ruler_scale (); //calculates the RulerScale of the fixed rulers void update_fixed_rulers (); - void update_tempo_based_rulers (ARDOUR::TempoMap::BBTPointList::const_iterator& begin, + void update_tempo_based_rulers (ARDOUR::TempoMap::BBTPointList::const_iterator& begin, ARDOUR::TempoMap::BBTPointList::const_iterator& end); void popup_ruler_menu (framepos_t where = 0, ItemType type = RegionItem); void update_ruler_visibility (); @@ -946,7 +952,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD gint bbt_nmarks; uint32_t bbt_bar_helper_on; uint32_t bbt_accent_modulo; - void compute_bbt_ruler_scale (framepos_t lower, framepos_t upper, + void compute_bbt_ruler_scale (framepos_t lower, framepos_t upper, ARDOUR::TempoMap::BBTPointList::const_iterator current_bbt_points_begin, ARDOUR::TempoMap::BBTPointList::const_iterator current_bbt_points_end); @@ -1044,9 +1050,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD /** the adjustment that controls the overall editor vertical scroll position */ Gtk::Adjustment vertical_adjustment; - Gtk::Adjustment horizontal_adjustment; + Gtk::Adjustment horizontal_adjustment; - Gtk::Adjustment unused_adjustment; // yes, really; Gtk::Layout constructor requires refs + Gtk::Adjustment unused_adjustment; // yes, really; Gtk::Layout constructor requires refs Gtk::Layout controls_layout; bool control_layout_scroll (GdkEventScroll* ev); void reset_controls_layout_width (); @@ -1122,7 +1128,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD static int _idle_visual_changer (void *arg); int idle_visual_changer (); - void visual_changer (const VisualChange&); + void visual_changer (const VisualChange&); void ensure_visual_change_idle_handler (); /* track views */ @@ -1170,9 +1176,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void register_actions (); void register_region_actions (); - void load_bindings (); - Gtkmm2ext::ActionMap editor_action_map; - Gtkmm2ext::Bindings key_bindings; + void load_bindings (); + Gtkmm2ext::ActionMap editor_action_map; + Gtkmm2ext::Bindings key_bindings; /* CUT/COPY/PASTE */ @@ -1366,7 +1372,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD boost::shared_ptr<ARDOUR::AudioTrack> get_nth_selected_audio_track (int nth) const; boost::shared_ptr<ARDOUR::MidiTrack> get_nth_selected_midi_track (int nth) const; - void toggle_midi_input_active (bool flip_others); + void toggle_midi_input_active (bool flip_others); ARDOUR::InterThreadInfo* current_interthread_info; @@ -1609,21 +1615,17 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD ArdourCanvas::Container* time_line_group; void hide_measures (); - void draw_measures (ARDOUR::TempoMap::BBTPointList::const_iterator& begin, + void draw_measures (ARDOUR::TempoMap::BBTPointList::const_iterator& begin, ARDOUR::TempoMap::BBTPointList::const_iterator& end); void new_tempo_section (); - void mouse_add_new_tempo_event (framepos_t where); - void mouse_add_new_meter_event (framepos_t where); void remove_tempo_marker (ArdourCanvas::Item*); void remove_meter_marker (ArdourCanvas::Item*); gint real_remove_tempo_marker (ARDOUR::TempoSection*); gint real_remove_meter_marker (ARDOUR::MeterSection*); - void edit_tempo_section (ARDOUR::TempoSection*); - void edit_meter_section (ARDOUR::MeterSection*); void edit_tempo_marker (TempoMarker&); void edit_meter_marker (MeterMarker&); void edit_control_point (ArdourCanvas::Item*); @@ -1675,7 +1677,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void remove_metric_marks (); void draw_metric_marks (const ARDOUR::Metrics& metrics); - void compute_current_bbt_points (framepos_t left, framepos_t right, + void compute_current_bbt_points (framepos_t left, framepos_t right, ARDOUR::TempoMap::BBTPointList::const_iterator& begin, ARDOUR::TempoMap::BBTPointList::const_iterator& end); @@ -1700,11 +1702,11 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD ArdourDropdown visible_tracks_selector; ArdourDropdown zoom_preset_selector; - int32_t _visible_track_count; - void build_track_count_menu (); - void set_visible_track_count (int32_t); - - void set_zoom_preset(int64_t); + int32_t _visible_track_count; + void build_track_count_menu (); + void set_visible_track_count (int32_t); + + void set_zoom_preset(int64_t); Gtk::VBox toolbar_clock_vbox; Gtk::VBox toolbar_selection_clock_vbox; @@ -1796,7 +1798,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD SelectionMemento* _selection_memento; void time_selection_changed (); - void update_time_selection_display (); + void update_time_selection_display (); void track_selection_changed (); void region_selection_changed (); sigc::connection editor_regions_selection_changed_connection; @@ -1869,15 +1871,15 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD /* autoscrolling */ - sigc::connection autoscroll_connection; - bool autoscroll_horizontal_allowed; - bool autoscroll_vertical_allowed; - uint32_t autoscroll_cnt; - Gtk::Widget* autoscroll_widget; - ArdourCanvas::Rect autoscroll_boundary; + sigc::connection autoscroll_connection; + bool autoscroll_horizontal_allowed; + bool autoscroll_vertical_allowed; + uint32_t autoscroll_cnt; + Gtk::Widget* autoscroll_widget; + ArdourCanvas::Rect autoscroll_boundary; bool autoscroll_canvas (); - void start_canvas_autoscroll (bool allow_horiz, bool allow_vert, const ArdourCanvas::Rect& boundary); + void start_canvas_autoscroll (bool allow_horiz, bool allow_vert, const ArdourCanvas::Rect& boundary); void stop_canvas_autoscroll (); /* trimming */ @@ -1900,45 +1902,45 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD /* Drag-n-Drop */ int convert_drop_to_paths ( - std::vector<std::string>& paths, - const Glib::RefPtr<Gdk::DragContext>& context, - gint x, - gint y, - const Gtk::SelectionData& data, - guint info, - guint time); + std::vector<std::string>& paths, + const Glib::RefPtr<Gdk::DragContext>& context, + gint x, + gint y, + const Gtk::SelectionData& data, + guint info, + guint time); void track_canvas_drag_data_received ( - const Glib::RefPtr<Gdk::DragContext>& context, - gint x, - gint y, - const Gtk::SelectionData& data, - guint info, - guint time); + const Glib::RefPtr<Gdk::DragContext>& context, + gint x, + gint y, + const Gtk::SelectionData& data, + guint info, + guint time); void drop_paths ( - const Glib::RefPtr<Gdk::DragContext>& context, - gint x, - gint y, - const Gtk::SelectionData& data, - guint info, - guint time); + const Glib::RefPtr<Gdk::DragContext>& context, + gint x, + gint y, + const Gtk::SelectionData& data, + guint info, + guint time); void drop_regions ( - const Glib::RefPtr<Gdk::DragContext>& context, - gint x, - gint y, - const Gtk::SelectionData& data, - guint info, - guint time); + const Glib::RefPtr<Gdk::DragContext>& context, + gint x, + gint y, + const Gtk::SelectionData& data, + guint info, + guint time); void drop_routes ( - const Glib::RefPtr<Gdk::DragContext>& context, - gint x, - gint y, - const Gtk::SelectionData& data, - guint info, - guint time); + const Glib::RefPtr<Gdk::DragContext>& context, + gint x, + gint y, + const Gtk::SelectionData& data, + guint info, + guint time); /* audio export */ @@ -1979,12 +1981,12 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void duplicate_range (bool with_dialog); - /** computes the timeline frame (sample) of an event whose coordinates + /** computes the timeline frame (sample) of an event whose coordinates * are in canvas units (pixels, scroll offset included). */ framepos_t canvas_event_sample (GdkEvent const *, double* px = 0, double* py = 0) const; - /** computes the timeline frame (sample) of an event whose coordinates + /** computes the timeline frame (sample) of an event whose coordinates * are in window units (pixels, no scroll offset). */ framepos_t window_event_sample (GdkEvent const *, double* px = 0, double* py = 0) const; @@ -2205,7 +2207,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD bool _following_mixer_selection; int time_fx (ARDOUR::RegionList&, float val, bool pitching); - void note_edit_done (int, EditNoteDialog*); + void note_edit_done (int, EditNoteDialog*); void toggle_sound_midi_notes (); /** Flag for a bit of a hack wrt control point selection; see set_selected_control_point_from_click */ diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 78f806310e..392b3bb6c1 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -636,21 +636,14 @@ Editor::LocationMarkers::setup_lines () } void -Editor::mouse_add_new_marker (framepos_t where, bool is_cd, bool is_xrun) +Editor::mouse_add_new_marker (framepos_t where, bool is_cd) { - string markername, markerprefix; + string markername; int flags = (is_cd ? Location::IsCDMarker|Location::IsMark : Location::IsMark); - if (is_xrun) { - markerprefix = "xrun"; - flags = Location::IsMark; - } else { - markerprefix = "mark"; - } - if (_session) { - _session->locations()->next_available_name(markername, markerprefix); - if (!is_xrun && !choose_new_marker_name(markername)) { + _session->locations()->next_available_name(markername, _("mark")); + if (!choose_new_marker_name(markername)) { return; } Location *location = new Location (*_session, where, where, markername, (Location::Flags) flags); diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc index 0fc49f522b..4a86aa6fad 100644 --- a/gtk2_ardour/editor_rulers.cc +++ b/gtk2_ardour/editor_rulers.cc @@ -208,7 +208,7 @@ Editor::popup_ruler_menu (framepos_t where, ItemType t) switch (t) { case MarkerBarItem: - ruler_items.push_back (MenuElem (_("New location marker"), sigc::bind ( sigc::mem_fun(*this, &Editor::mouse_add_new_marker), where, false, false))); + ruler_items.push_back (MenuElem (_("New location marker"), sigc::bind ( sigc::mem_fun(*this, &Editor::mouse_add_new_marker), where, false))); ruler_items.push_back (MenuElem (_("Clear all locations"), sigc::mem_fun(*this, &Editor::clear_markers))); ruler_items.push_back (MenuElem (_("Unhide locations"), sigc::mem_fun(*this, &Editor::unhide_markers))); ruler_items.push_back (SeparatorElem ()); @@ -227,7 +227,7 @@ Editor::popup_ruler_menu (framepos_t where, ItemType t) case CdMarkerBarItem: // TODO - ruler_items.push_back (MenuElem (_("New CD track marker"), sigc::bind ( sigc::mem_fun(*this, &Editor::mouse_add_new_marker), where, true, false))); + ruler_items.push_back (MenuElem (_("New CD track marker"), sigc::bind ( sigc::mem_fun(*this, &Editor::mouse_add_new_marker), where, true))); break; diff --git a/gtk2_ardour/main_clock.cc b/gtk2_ardour/main_clock.cc index 80dece04aa..26d780ea8a 100644 --- a/gtk2_ardour/main_clock.cc +++ b/gtk2_ardour/main_clock.cc @@ -19,22 +19,20 @@ #include "ardour_ui.h" #include "main_clock.h" +#include "public_editor.h" #include "i18n.h" +#include "ardour/tempo.h" + using namespace Gtk; MainClock::MainClock ( const std::string& clock_name, - bool is_transient, const std::string& widget_name, - bool editable, - bool follows_playhead, - bool primary, - bool duration, - bool with_info + bool primary ) - : AudioClock (clock_name, is_transient, widget_name, editable, follows_playhead, duration, with_info) + : AudioClock (clock_name, false, widget_name, true, true, false, true) , _primary (primary) { @@ -62,6 +60,23 @@ MainClock::build_ops_menu () c->set_active (true); } } + + ops_items.push_back (SeparatorElem()); + ops_items.push_back (MenuElem (_("Edit Tempo"), sigc::mem_fun(*this, &MainClock::edit_current_tempo))); + ops_items.push_back (MenuElem (_("Edit Meter"), sigc::mem_fun(*this, &MainClock::edit_current_meter))); + ops_items.push_back (MenuElem (_("Insert Tempo Change"), sigc::mem_fun(*this, &MainClock::insert_new_tempo))); + ops_items.push_back (MenuElem (_("Insert Meter Change"), sigc::mem_fun(*this, &MainClock::insert_new_meter))); +} + +framepos_t +MainClock::absolute_time () const +{ + if (get_is_duration ()) { + // delta to edit cursor + return current_time () + PublicEditor::instance().get_preferred_edit_position (true); + } else { + return current_time (); + } } void @@ -73,3 +88,51 @@ MainClock::display_delta_to_edit_cursor () ARDOUR_UI::config()->set_secondary_clock_delta_edit_cursor (!ARDOUR_UI::config()->get_secondary_clock_delta_edit_cursor ()); } } + +void +MainClock::edit_current_tempo () +{ + ARDOUR::TempoSection ts = PublicEditor::instance().session()->tempo_map().tempo_section_at (absolute_time()); + PublicEditor::instance().edit_tempo_section (&ts); +} + +void +MainClock::edit_current_meter () +{ + ARDOUR::MeterSection ms = PublicEditor::instance().session()->tempo_map().meter_section_at (absolute_time()); + PublicEditor::instance().edit_meter_section (&ms); +} + +void +MainClock::insert_new_tempo () +{ + PublicEditor::instance().mouse_add_new_tempo_event (absolute_time ()); +} + +void +MainClock::insert_new_meter () +{ + PublicEditor::instance().mouse_add_new_meter_event (absolute_time ()); +} + +bool +MainClock::on_button_press_event (GdkEventButton *ev) +{ + if (ev->button == 1) { + if (mode() == BBT) { + if (is_lower_layout_click(ev->y)) { + if (is_right_layout_click(ev->x)) { + // meter on the right + edit_current_meter(); + } else { + // tempo on the left + edit_current_tempo(); + } + return true; + } + } + } + + return AudioClock::on_button_press_event (ev); +} + diff --git a/gtk2_ardour/main_clock.h b/gtk2_ardour/main_clock.h index 959a3f9440..696b7e21e6 100644 --- a/gtk2_ardour/main_clock.h +++ b/gtk2_ardour/main_clock.h @@ -19,15 +19,26 @@ #include "audio_clock.h" -/** A simple subclass of AudioClock that adds the `display delta to edit cursor' option to its context menu */ +/** A simple subclass of AudioClock that adds a few things to its context menu: + * `display delta to edit cursor' and edit/change tempo/meter + */ class MainClock : public AudioClock { public: - MainClock (const std::string &, bool, const std::string &, bool, bool, bool primary, bool duration = false, bool with_info = false); + MainClock (const std::string& clock_name, const std::string& widget_name, bool primary); private: + // Editor *_editor; + void build_ops_menu (); void display_delta_to_edit_cursor (); + void edit_current_tempo (); + void edit_current_meter (); + void insert_new_tempo (); + void insert_new_meter (); + framepos_t absolute_time () const; bool _primary; + + bool on_button_press_event (GdkEventButton *ev); }; diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index 1ee068f141..69471ef152 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -286,7 +286,7 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi virtual void toggle_meter_updating() = 0; virtual void split_regions_at (framepos_t, RegionSelection&) = 0; virtual void split_region_at_points (boost::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret, bool select_new = false) = 0; - virtual void mouse_add_new_marker (framepos_t where, bool is_cd=false, bool is_xrun=false) = 0; + virtual void mouse_add_new_marker (framepos_t where, bool is_cd=false) = 0; virtual void foreach_time_axis_view (sigc::slot<void,TimeAxisView&>) = 0; virtual void add_to_idle_resize (TimeAxisView*, int32_t) = 0; virtual framecnt_t get_nudge_distance (framepos_t pos, framecnt_t& next) = 0; @@ -419,6 +419,11 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi virtual void get_regionviews_by_id (PBD::ID const id, RegionSelection & regions) const = 0; virtual void get_per_region_note_selection (std::list<std::pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > >&) const = 0; + virtual void mouse_add_new_tempo_event (framepos_t where) = 0; + virtual void mouse_add_new_meter_event (framepos_t where) = 0; + virtual void edit_tempo_section (ARDOUR::TempoSection*) = 0; + virtual void edit_meter_section (ARDOUR::MeterSection*) = 0; + /// Singleton instance, set up by Editor::Editor() static PublicEditor* _instance; diff --git a/gtk2_ardour/tempo_dialog.cc b/gtk2_ardour/tempo_dialog.cc index a16d224354..d430f22523 100644 --- a/gtk2_ardour/tempo_dialog.cc +++ b/gtk2_ardour/tempo_dialog.cc @@ -181,7 +181,10 @@ TempoDialog::init (const Timecode::BBT_Time& when, double bpm, double note_type, when_beat_entry.signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &TempoDialog::response), RESPONSE_ACCEPT)); when_beat_entry.signal_key_release_event().connect (sigc::mem_fun (*this, &TempoDialog::entry_key_release), false); pulse_selector.signal_changed().connect (sigc::mem_fun (*this, &TempoDialog::pulse_change)); - tap_tempo_button.signal_clicked().connect (sigc::mem_fun (*this, &TempoDialog::tap_tempo)); + tap_tempo_button.signal_button_press_event().connect (sigc::mem_fun (*this, &TempoDialog::tap_tempo_button_press), false); + tap_tempo_button.signal_focus_out_event().connect (sigc::mem_fun (*this, &TempoDialog::tap_tempo_focus_out)); + + tapped = false; } bool @@ -261,37 +264,51 @@ TempoDialog::pulse_change () set_response_sensitive (RESPONSE_ACCEPT, is_user_input_valid()); } -void -TempoDialog::tap_tempo () +bool +TempoDialog::tap_tempo_button_press (GdkEventButton *ev) { gint64 now; now = g_get_monotonic_time (); // microseconds - if (last_tap > 0) { + if (tapped) { double interval, bpm; static const double decay = 0.5; interval = (now - last_tap) * 1.0e-6; if (interval <= 6.0) { - // >= 10 bpm, say + // <= 6 seconds (say): >= 10 bpm if (average_interval > 0) { + if (average_interval > interval / 1.2 && average_interval < interval * 1.2) { average_interval = interval * decay + average_interval * (1.0-decay); + } else { + average_interval = 0; + } } else { average_interval = interval; } - bpm = 60.0 / average_interval; - bpm_spinner.set_value (bpm); + if (average_interval > 0) { + bpm = 60.0 / average_interval; + bpm_spinner.set_value (bpm); + } } else { average_interval = 0; } } else { average_interval = 0; + tapped = true; } last_tap = now; } +bool +TempoDialog::tap_tempo_focus_out (GdkEventFocus* ) +{ + tapped = false; + return false; +} + MeterDialog::MeterDialog (TempoMap& map, framepos_t frame, const string&) : ArdourDialog (_("New Meter")) { diff --git a/gtk2_ardour/tempo_dialog.h b/gtk2_ardour/tempo_dialog.h index da924ac859..eda4e61f1a 100644 --- a/gtk2_ardour/tempo_dialog.h +++ b/gtk2_ardour/tempo_dialog.h @@ -53,11 +53,13 @@ private: bool bpm_button_release (GdkEventButton* ); bool entry_key_release (GdkEventKey* ); void pulse_change (); - void tap_tempo (); + bool tap_tempo_button_press (GdkEventButton* ); + bool tap_tempo_focus_out (GdkEventFocus* ); typedef std::map<std::string,float> NoteTypes; NoteTypes note_types; + bool tapped; // whether the tap-tempo button has been clicked gint64 last_tap; double average_interval; diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h index 6e6818bf19..9e6a0c17bd 100644 --- a/libs/ardour/ardour/tempo.h +++ b/libs/ardour/ardour/tempo.h @@ -287,6 +287,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible const Meter& meter_at (framepos_t) const; const TempoSection& tempo_section_at (framepos_t) const; + const MeterSection& meter_section_at (framepos_t) const; void add_tempo (const Tempo&, Timecode::BBT_Time where); void add_meter (const Meter&, Timecode::BBT_Time where); diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index 521b91147d..c5f7272b7e 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -1620,6 +1620,33 @@ TempoMap::tempo_at (framepos_t frame) const return m.tempo(); } +const MeterSection& +TempoMap::meter_section_at (framepos_t frame) const +{ + Glib::Threads::RWLock::ReaderLock lm (lock); + Metrics::const_iterator i; + MeterSection* prev = 0; + + for (i = metrics.begin(); i != metrics.end(); ++i) { + MeterSection* t; + + if ((t = dynamic_cast<MeterSection*> (*i)) != 0) { + + if ((*i)->frame() > frame) { + break; + } + + prev = t; + } + } + + if (prev == 0) { + fatal << endmsg; + abort(); /*NOTREACHED*/ + } + + return *prev; +} const Meter& TempoMap::meter_at (framepos_t frame) const diff --git a/libs/backends/wavesaudio/waves_audiobackend.midi.cc b/libs/backends/wavesaudio/waves_audiobackend.midi.cc index 296f3564f9..47efd2d860 100644 --- a/libs/backends/wavesaudio/waves_audiobackend.midi.cc +++ b/libs/backends/wavesaudio/waves_audiobackend.midi.cc @@ -31,7 +31,11 @@ const std::vector<std::string> WavesAudioBackend::__available_midi_options = boo #elif PLATFORM_WINDOWS +<<<<<<< HEAD const std::vector<std::string> WavesAudioBackend::__available_midi_options = boost::assign::list_of ("System MIDI (MME)") ("None"); +======= +const std::vector<std::string> WavesAudioBackend::__available_midi_options = boost::assign::list_of ("Multimedia Extensions") ("None"); +>>>>>>> remotes/origin/tempo-marker-from-clock #endif |