X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor.cc;h=ecf3870c7ffe43ddb34ef7155f754f3499f85151;hb=082c4570a1efbf59794a79820a96dd88de23c73b;hp=518ef7217a2933ede038639747015e010a453303;hpb=6f4a92f740b2fd75794489ce58f9348f8adf6bf4;p=ardour.git diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 518ef7217a..ecf3870c7f 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -97,15 +98,6 @@ const double Editor::timebar_height = 15.0; #include "editor_xpms" -static const int32_t slide_index = 0; -static const int32_t splice_index = 1; - -static const gchar *edit_mode_strings[] = { - N_("Slide Edit"), - N_("Splice Edit"), - 0 -}; - static const gchar *snap_type_strings[] = { N_("None"), N_("CD Frames"), @@ -140,8 +132,8 @@ static const gchar *zoom_focus_strings[] = { N_("Focus Left"), N_("Focus Right"), N_("Focus Center"), - N_("Focus Play"), - N_("Focus Edit"), + N_("Focus Playhead"), + N_("Focus Edit Cursor"), 0 }; @@ -245,7 +237,6 @@ Editor::Editor (AudioEngine& eng) latest_regionview = 0; last_update_frame = 0; drag_info.item = 0; - last_audition_region = 0; current_mixer_strip = 0; current_bbt_points = 0; @@ -257,6 +248,7 @@ Editor::Editor (AudioEngine& eng) bbt_beat_subdivision = 4; canvas_width = 0; canvas_height = 0; + autoscroll_active = false; autoscroll_timeout_tag = -1; interthread_progress_window = 0; @@ -271,7 +263,6 @@ Editor::Editor (AudioEngine& eng) first_action_message = 0; export_dialog = 0; show_gain_after_trim = false; - no_zoom_repos_update = false; ignore_route_list_reorder = false; no_route_list_redisplay = false; verbose_cursor_on = true; @@ -284,7 +275,6 @@ Editor::Editor (AudioEngine& eng) _xfade_visibility = true; editor_ruler_menu = 0; no_ruler_shown_update = false; - edit_hscroll_dragging = false; edit_group_list_menu = 0; route_list_menu = 0; region_list_menu = 0; @@ -645,7 +635,7 @@ Editor::Editor (AudioEngine& eng) edit_pane.pack1 (edit_packer, true, true); edit_pane.pack2 (the_notebook, false, true); - edit_pane.signal_size_allocate().connect_notify (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast (&edit_pane))); + edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast (&edit_pane))); top_hbox.pack_start (toolbar_frame, true, true); @@ -702,6 +692,9 @@ Editor::Editor (AudioEngine& eng) ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false)); ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true)); ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll)); + + Config->ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed)); + constructed = true; instant_save (); } @@ -803,19 +796,19 @@ Editor::tie_vertical_scrolling () void Editor::set_frames_per_unit (double fpu) { - jack_nframes_t frames; + nframes_t frames; if (fpu == frames_per_unit) { return; } - if (fpu < 1.0) { - fpu = 1.0; + if (fpu < 2.0) { + fpu = 2.0; } // convert fpu to frame count - frames = (jack_nframes_t) floor (fpu * canvas_width); + frames = (nframes_t) floor (fpu * canvas_width); /* don't allow zooms that fit more than the maximum number of frames into an 800 pixel wide space. @@ -825,22 +818,16 @@ Editor::set_frames_per_unit (double fpu) return; } + if (fpu == frames_per_unit) { + return; + } + frames_per_unit = fpu; if (frames != zoom_range_clock.current_duration()) { zoom_range_clock.set (frames); } - /* only update these if we not about to call reposition_x_origin, - which will do the same updates. - */ - - if (!no_zoom_repos_update) { - horizontal_adjustment.set_value (leftmost_frame/frames_per_unit); - update_fixed_rulers (); - tempo_map_changed (Change (0)); - } - if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) { if (!selection->tracks.empty()) { for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { @@ -880,12 +867,12 @@ Editor::instant_save () } void -Editor::reposition_x_origin (jack_nframes_t frame) +Editor::reposition_x_origin (nframes_t frame) { if (frame != leftmost_frame) { leftmost_frame = frame; - jack_nframes_t rightmost_frame = leftmost_frame + current_page_frames (); + nframes_t rightmost_frame = leftmost_frame + current_page_frames (); if (rightmost_frame > last_canvas_frame) { last_canvas_frame = rightmost_frame; @@ -893,6 +880,9 @@ Editor::reposition_x_origin (jack_nframes_t frame) } horizontal_adjustment.set_value (frame/frames_per_unit); + } else { + update_fixed_rulers(); + tempo_map_changed (Change (0)); } } @@ -908,7 +898,7 @@ Editor::edit_cursor_clock_changed() void Editor::zoom_adjustment_changed () { - if (session == 0 || no_zoom_repos_update) { + if (session == 0) { return; } @@ -916,10 +906,10 @@ Editor::zoom_adjustment_changed () if (fpu < 1.0) { fpu = 1.0; - zoom_range_clock.set ((jack_nframes_t) floor (fpu * canvas_width)); + zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width)); } else if (fpu > session->current_end_frame() / canvas_width) { fpu = session->current_end_frame() / canvas_width; - zoom_range_clock.set ((jack_nframes_t) floor (fpu * canvas_width)); + zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width)); } temporal_zoom (fpu); @@ -935,14 +925,14 @@ Editor::control_scroll (float fraction) } double step = fraction * current_page_frames(); - jack_nframes_t target; + nframes_t target; - if ((fraction < 0.0f) && (session->transport_frame() < (jack_nframes_t) fabs(step))) { + if ((fraction < 0.0f) && (session->transport_frame() < (nframes_t) fabs(step))) { target = 0; } else if ((fraction > 0.0f) && (max_frames - session->transport_frame() < step)) { target = (max_frames - (current_page_frames()*2)); // allow room for slop in where the PH is on the screen } else { - target = (session->transport_frame() + (jack_nframes_t) floor ((fraction * current_page_frames()))); + target = (session->transport_frame() + (nframes_t) floor ((fraction * current_page_frames()))); } /* move visuals, we'll catch up with it later */ @@ -966,7 +956,7 @@ Editor::control_scroll (float fraction) } bool -Editor::deferred_control_scroll (jack_nframes_t target) +Editor::deferred_control_scroll (nframes_t target) { session->request_locate (target); return false; @@ -975,40 +965,28 @@ Editor::deferred_control_scroll (jack_nframes_t target) void Editor::canvas_horizontally_scrolled () { - leftmost_frame = (jack_nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit); + leftmost_frame = (nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit); update_fixed_rulers (); - - if (!edit_hscroll_dragging) { - tempo_map_changed (Change (0)); - } else { - update_tempo_based_rulers(); - } + tempo_map_changed (Change (0)); + } void -Editor::reposition_and_zoom (jack_nframes_t frame, double nfpu) +Editor::reposition_and_zoom (nframes_t frame, double nfpu) { if (!repos_zoom_queued) { - Glib::signal_idle().connect (bind (mem_fun(*this, &Editor::deferred_reposition_and_zoom), frame, nfpu)); repos_zoom_queued = true; + Glib::signal_idle().connect (bind (mem_fun(*this, &Editor::deferred_reposition_and_zoom), frame, nfpu)); } } gint -Editor::deferred_reposition_and_zoom (jack_nframes_t frame, double nfpu) +Editor::deferred_reposition_and_zoom (nframes_t frame, double nfpu) { - /* if we need to force an update to the hscroller stuff, - don't set no_zoom_repos_update. - */ - no_zoom_repos_update = (frame != leftmost_frame); - set_frames_per_unit (nfpu); - if (no_zoom_repos_update) { - reposition_x_origin (frame); - } - no_zoom_repos_update = false; + reposition_x_origin (frame); repos_zoom_queued = false; return FALSE; @@ -1021,35 +999,6 @@ Editor::on_realize () Realized (); } -void -Editor::queue_session_control_changed (Session::ControlType t) -{ - Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &Editor::session_control_changed), t)); -} - -void -Editor::session_control_changed (Session::ControlType t) -{ - // right now we're only tracking some state here - - switch (t) { - case Session::AutoLoop: - update_loop_range_view (true); - break; - case Session::PunchIn: - case Session::PunchOut: - update_punch_range_view (true); - break; - - case Session::LayeringModel: - update_layering_model (); - break; - - default: - break; - } -} - void Editor::start_scrolling () { @@ -1061,11 +1010,10 @@ void Editor::stop_scrolling () { scroll_connection.disconnect (); - slower_update_connection.disconnect (); } void -Editor::map_position_change (jack_nframes_t frame) +Editor::map_position_change (nframes_t frame) { ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame)); @@ -1078,7 +1026,7 @@ Editor::map_position_change (jack_nframes_t frame) } void -Editor::center_screen (jack_nframes_t frame) +Editor::center_screen (nframes_t frame) { double page = canvas_width * frames_per_unit; @@ -1091,12 +1039,12 @@ Editor::center_screen (jack_nframes_t frame) } void -Editor::center_screen_internal (jack_nframes_t frame, float page) +Editor::center_screen_internal (nframes_t frame, float page) { page /= 2; if (frame > page) { - frame -= (jack_nframes_t) page; + frame -= (nframes_t) page; } else { frame = 0; } @@ -1109,7 +1057,7 @@ Editor::handle_new_duration () { ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration)); - jack_nframes_t new_end = session->get_maximum_extent() + (jack_nframes_t) floorf (current_page_frames() * 0.10f); + nframes_t new_end = session->get_maximum_extent() + (nframes_t) floorf (current_page_frames() * 0.10f); if (new_end > last_canvas_frame) { last_canvas_frame = new_end; @@ -1167,7 +1115,7 @@ Editor::connect_to_session (Session *t) update_title (); - session->going_away.connect (mem_fun(*this, &Editor::session_going_away)); + session->GoingAway.connect (mem_fun(*this, &Editor::session_going_away)); /* These signals can all be emitted by a non-GUI thread. Therefore the handlers for them must not attempt to directly interact with the GUI, @@ -1190,7 +1138,6 @@ Editor::connect_to_session (Session *t) session_connections.push_back (session->RegionHiddenChange.connect (mem_fun(*this, &Editor::region_hidden))); session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte))); - session_connections.push_back (session->SMPTETypeChanged.connect (mem_fun(*this, &Editor::update_just_smpte))); session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed))); @@ -1206,16 +1153,6 @@ Editor::connect_to_session (Session *t) analysis_window->set_session (session); #endif - switch (session->get_edit_mode()) { - case Splice: - edit_mode_selector.set_active_text (edit_mode_strings[splice_index]); - break; - - case Slide: - edit_mode_selector.set_active_text (edit_mode_strings[slide_index]); - break; - } - Location* loc = session->locations()->auto_loop_location(); if (loc == 0) { loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden)); @@ -1244,10 +1181,8 @@ Editor::connect_to_session (Session *t) loc->set_name (_("Punch")); } - update_loop_range_view (true); - update_punch_range_view (true); + Config->map_parameters (mem_fun (*this, &Editor::parameter_changed)); - session->ControlChanged.connect (mem_fun(*this, &Editor::queue_session_control_changed)); session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved)); refresh_location_display (); @@ -1257,32 +1192,6 @@ Editor::connect_to_session (Session *t) session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s)); session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed)); - bool yn; - RefPtr act; - - act = ActionManager::get_action (X_("Editor"), X_("toggle-xfades-active")); - if (act) { - RefPtr tact = RefPtr::cast_dynamic(act); - /* do it twice to force the change */ - yn = session->get_crossfades_active(); - tact->set_active (!yn); - tact->set_active (yn); - } - - act = ActionManager::get_action (X_("Editor"), X_("toggle-auto-xfades")); - if (act) { - RefPtr tact = RefPtr::cast_dynamic(act); - /* do it twice to force the change */ - yn = Config->get_auto_xfade (); - tact->set_active (!yn); - tact->set_active (yn); - } - - /* xfade visibility state set from editor::set_state() */ - - update_crossfade_model (); - update_layering_model (); - handle_new_duration (); redisplay_regions (); @@ -1305,7 +1214,8 @@ Editor::connect_to_session (Session *t) horizontal_adjustment.set_value (0); restore_ruler_visibility (); - tempo_map_changed (Change (0)); + //tempo_map_changed (Change (0)); + session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks); edit_cursor->set_position (0); playhead_cursor->set_position (0); @@ -1338,6 +1248,10 @@ Editor::connect_to_session (Session *t) no_route_list_redisplay = false; redisplay_route_list (); } + + /* register for undo history */ + + session->register_with_memento_command_factory(_id, this); } void @@ -1394,13 +1308,14 @@ Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* i } MenuList& items (fade_context_menu.items()); + AudioRegion& ar (*arv->audio_region().get()); // FIXME items.clear (); switch (item_type) { case FadeInItem: case FadeInHandleItem: - if (arv->audio_region().fade_in_active()) { + if (arv->audio_region()->fade_in_active()) { items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), false))); } else { items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), true))); @@ -1408,16 +1323,16 @@ Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* i items.push_back (SeparatorElem()); - items.push_back (MenuElem (_("Linear"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_in_shape), AudioRegion::Linear))); - items.push_back (MenuElem (_("Slowest"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_in_shape), AudioRegion::LogB))); - items.push_back (MenuElem (_("Slow"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_in_shape), AudioRegion::Fast))); - items.push_back (MenuElem (_("Fast"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_in_shape), AudioRegion::LogA))); - items.push_back (MenuElem (_("Fastest"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_in_shape), AudioRegion::Slow))); + items.push_back (MenuElem (_("Linear"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::Linear))); + items.push_back (MenuElem (_("Slowest"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::LogB))); + items.push_back (MenuElem (_("Slow"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::Fast))); + items.push_back (MenuElem (_("Fast"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::LogA))); + items.push_back (MenuElem (_("Fastest"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::Slow))); break; case FadeOutItem: case FadeOutHandleItem: - if (arv->audio_region().fade_out_active()) { + if (arv->audio_region()->fade_out_active()) { items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), false))); } else { items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), true))); @@ -1425,11 +1340,11 @@ Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* i items.push_back (SeparatorElem()); - items.push_back (MenuElem (_("Linear"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_out_shape), AudioRegion::Linear))); - items.push_back (MenuElem (_("Slowest"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_out_shape), AudioRegion::Fast))); - items.push_back (MenuElem (_("Slow"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_out_shape), AudioRegion::LogB))); - items.push_back (MenuElem (_("Fast"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_out_shape), AudioRegion::LogA))); - items.push_back (MenuElem (_("Fastest"), bind (mem_fun (arv->audio_region(), &AudioRegion::set_fade_out_shape), AudioRegion::Slow))); + items.push_back (MenuElem (_("Linear"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::Linear))); + items.push_back (MenuElem (_("Slowest"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::Fast))); + items.push_back (MenuElem (_("Slow"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::LogB))); + items.push_back (MenuElem (_("Fast"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::LogA))); + items.push_back (MenuElem (_("Fastest"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::Slow))); break; default: @@ -1443,10 +1358,10 @@ Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* i } void -Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, jack_nframes_t frame) +Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes_t frame) { using namespace Menu_Helpers; - Menu* (Editor::*build_menu_function)(jack_nframes_t); + Menu* (Editor::*build_menu_function)(nframes_t); Menu *menu; switch (item_type) { @@ -1496,7 +1411,7 @@ Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, case RegionViewNameHighlight: if (!with_selection) { if (region_edit_menu_split_item) { - if (clicked_regionview && clicked_regionview->region().covers (edit_cursor->current_frame)) { + if (clicked_regionview && clicked_regionview->region()->covers (edit_cursor->current_frame)) { ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, true); } else { ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, false); @@ -1558,7 +1473,7 @@ Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, } Menu* -Editor::build_track_context_menu (jack_nframes_t ignored) +Editor::build_track_context_menu (nframes_t ignored) { using namespace Menu_Helpers; @@ -1570,7 +1485,7 @@ Editor::build_track_context_menu (jack_nframes_t ignored) } Menu* -Editor::build_track_bus_context_menu (jack_nframes_t ignored) +Editor::build_track_bus_context_menu (nframes_t ignored) { using namespace Menu_Helpers; @@ -1582,7 +1497,7 @@ Editor::build_track_bus_context_menu (jack_nframes_t ignored) } Menu* -Editor::build_track_region_context_menu (jack_nframes_t frame) +Editor::build_track_region_context_menu (nframes_t frame) { using namespace Menu_Helpers; MenuList& edit_items = track_region_context_menu.items(); @@ -1591,11 +1506,11 @@ Editor::build_track_region_context_menu (jack_nframes_t frame) AudioTimeAxisView* atv = dynamic_cast (clicked_trackview); if (atv) { - Diskstream* ds; + boost::shared_ptr ds; Playlist* pl; if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) { - Playlist::RegionList* regions = pl->regions_at ((jack_nframes_t) floor ( (double)frame * ds->speed())); + Playlist::RegionList* regions = pl->regions_at ((nframes_t) floor ( (double)frame * ds->speed())); for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) { add_region_context_items (atv->audio_view(), (*i), edit_items); } @@ -1609,7 +1524,7 @@ Editor::build_track_region_context_menu (jack_nframes_t frame) } Menu* -Editor::build_track_crossfade_context_menu (jack_nframes_t frame) +Editor::build_track_crossfade_context_menu (nframes_t frame) { using namespace Menu_Helpers; MenuList& edit_items = track_crossfade_context_menu.items(); @@ -1618,7 +1533,7 @@ Editor::build_track_crossfade_context_menu (jack_nframes_t frame) AudioTimeAxisView* atv = dynamic_cast (clicked_trackview); if (atv) { - Diskstream* ds; + boost::shared_ptr ds; Playlist* pl; AudioPlaylist* apl; @@ -1689,7 +1604,7 @@ Editor::analyze_range_selection() Menu* -Editor::build_track_selection_context_menu (jack_nframes_t ignored) +Editor::build_track_selection_context_menu (nframes_t ignored) { using namespace Menu_Helpers; MenuList& edit_items = track_selection_context_menu.items(); @@ -1731,9 +1646,9 @@ Editor::add_crossfade_context_items (AudioStreamView* view, Crossfade* xfade, Me } if (many) { - str = xfade->out().name(); + str = xfade->out()->name(); str += "->"; - str += xfade->in().name(); + str += xfade->in()->name(); } else { str = _("Crossfade"); } @@ -1759,17 +1674,17 @@ Editor::xfade_edit_right_region () } void -Editor::add_region_context_items (AudioStreamView* sv, Region* region, Menu_Helpers::MenuList& edit_items) +Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr region, Menu_Helpers::MenuList& edit_items) { using namespace Menu_Helpers; Menu *region_menu = manage (new Menu); MenuList& items = region_menu->items(); region_menu->set_name ("ArdourContextMenu"); - AudioRegion* ar = 0; + boost::shared_ptr ar; if (region) { - ar = dynamic_cast (region); + ar = boost::dynamic_pointer_cast (region); } /* when this particular menu pops up, make the relevant region @@ -2118,6 +2033,9 @@ Editor::set_state (const XMLNode& node) int x, y, xoff, yoff; Gdk::Geometry g; + if ((prop = node.property ("id")) != 0) { + _id = prop->value (); + } if ((geometry = find_named_node (node, "geometry")) == 0) { @@ -2239,6 +2157,7 @@ Editor::set_state (const XMLNode& node) } } + return 0; } @@ -2248,6 +2167,9 @@ Editor::get_state () XMLNode* node = new XMLNode ("Editor"); char buf[32]; + _id.print (buf, sizeof (buf)); + node->add_property ("id", buf); + if (is_realized()) { Glib::RefPtr win = get_window(); @@ -2257,7 +2179,7 @@ Editor::get_state () win->get_size(width, height); XMLNode* geometry = new XMLNode ("geometry"); - char buf[32]; + snprintf(buf, sizeof(buf), "%d", width); geometry->add_property("x_size", string(buf)); snprintf(buf, sizeof(buf), "%d", height); @@ -2327,7 +2249,7 @@ Editor::trackview_by_y_position (double y) } void -Editor::snap_to (jack_nframes_t& start, int32_t direction, bool for_mark) +Editor::snap_to (nframes_t& start, int32_t direction, bool for_mark) { Location* before = 0; Location* after = 0; @@ -2336,10 +2258,10 @@ Editor::snap_to (jack_nframes_t& start, int32_t direction, bool for_mark) return; } - const jack_nframes_t one_second = session->frame_rate(); - const jack_nframes_t one_minute = session->frame_rate() * 60; + const nframes_t one_second = session->frame_rate(); + const nframes_t one_minute = session->frame_rate() * 60; - jack_nframes_t presnap = start; + nframes_t presnap = start; switch (snap_type) { case SnapToFrame: @@ -2347,16 +2269,16 @@ Editor::snap_to (jack_nframes_t& start, int32_t direction, bool for_mark) case SnapToCDFrame: if (direction) { - start = (jack_nframes_t) ceil ((double) start / (one_second / 75)) * (one_second / 75); + start = (nframes_t) ceil ((double) start / (one_second / 75)) * (one_second / 75); } else { - start = (jack_nframes_t) floor ((double) start / (one_second / 75)) * (one_second / 75); + start = (nframes_t) floor ((double) start / (one_second / 75)) * (one_second / 75); } break; case SnapToSMPTEFrame: if (direction) { - start = (jack_nframes_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame()); + start = (nframes_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame()); } else { - start = (jack_nframes_t) (floor ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame()); + start = (nframes_t) (floor ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame()); } break; @@ -2368,9 +2290,9 @@ Editor::snap_to (jack_nframes_t& start, int32_t direction, bool for_mark) start -= session->smpte_offset (); } if (direction > 0) { - start = (jack_nframes_t) ceil ((double) start / one_second) * one_second; + start = (nframes_t) ceil ((double) start / one_second) * one_second; } else { - start = (jack_nframes_t) floor ((double) start / one_second) * one_second; + start = (nframes_t) floor ((double) start / one_second) * one_second; } if (session->smpte_offset_negative()) @@ -2389,9 +2311,9 @@ Editor::snap_to (jack_nframes_t& start, int32_t direction, bool for_mark) start -= session->smpte_offset (); } if (direction) { - start = (jack_nframes_t) ceil ((double) start / one_minute) * one_minute; + start = (nframes_t) ceil ((double) start / one_minute) * one_minute; } else { - start = (jack_nframes_t) floor ((double) start / one_minute) * one_minute; + start = (nframes_t) floor ((double) start / one_minute) * one_minute; } if (session->smpte_offset_negative()) { @@ -2403,17 +2325,17 @@ Editor::snap_to (jack_nframes_t& start, int32_t direction, bool for_mark) case SnapToSeconds: if (direction) { - start = (jack_nframes_t) ceil ((double) start / one_second) * one_second; + start = (nframes_t) ceil ((double) start / one_second) * one_second; } else { - start = (jack_nframes_t) floor ((double) start / one_second) * one_second; + start = (nframes_t) floor ((double) start / one_second) * one_second; } break; case SnapToMinutes: if (direction) { - start = (jack_nframes_t) ceil ((double) start / one_minute) * one_minute; + start = (nframes_t) ceil ((double) start / one_minute) * one_minute; } else { - start = (jack_nframes_t) floor ((double) start / one_minute) * one_minute; + start = (nframes_t) floor ((double) start / one_minute) * one_minute; } break; @@ -2494,7 +2416,7 @@ Editor::snap_to (jack_nframes_t& start, int32_t direction, bool for_mark) case SnapToRegionSync: case SnapToRegionBoundary: if (!region_boundary_cache.empty()) { - vector::iterator i; + vector::iterator i; if (direction > 0) { i = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start); @@ -2579,9 +2501,13 @@ Editor::setup_toolbar () mouse_mode_button_box.pack_start(mouse_audition_button, true, true); mouse_mode_button_box.set_homogeneous(true); + vector edit_mode_strings; + edit_mode_strings.push_back (edit_mode_to_string (Splice)); + edit_mode_strings.push_back (edit_mode_to_string (Slide)); + edit_mode_selector.set_name ("EditModeSelector"); - Gtkmm2ext::set_size_request_to_display_given_text (edit_mode_selector, "Splice Edit", 2+FUDGE, 10); - set_popdown_strings (edit_mode_selector, internationalize (edit_mode_strings)); + Gtkmm2ext::set_size_request_to_display_given_text (edit_mode_selector, longest (edit_mode_strings).c_str(), 2+FUDGE, 10); + set_popdown_strings (edit_mode_selector, edit_mode_strings); edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done)); mode_box->pack_start(edit_mode_selector); @@ -2878,8 +2804,8 @@ void Editor::begin_reversible_command (string name) { if (session) { - UndoAction ua = get_memento(); - session->begin_reversible_command (name, &ua); + before = &get_state(); + session->begin_reversible_command (name); } } @@ -2887,8 +2813,7 @@ void Editor::commit_reversible_command () { if (session) { - UndoAction ua = get_memento(); - session->commit_reversible_command (&ua); + session->commit_reversible_command (new MementoCommand(*this, before, &get_state())); } } @@ -2940,7 +2865,7 @@ Editor::set_selected_control_point_from_click (bool press, Selection::Operation /* select this point and any others that it represents */ double y1, y2; - jack_nframes_t x1, x2; + nframes_t x1, x2; x1 = pixel_to_frame (clicked_control_point->get_x() - 10); x2 = pixel_to_frame (clicked_control_point->get_x() + 10); @@ -3011,12 +2936,12 @@ Editor::mapover_audio_tracks (slot sl) void Editor::mapped_set_selected_regionview_from_click (RouteTimeAxisView& tv, uint32_t ignored, - RegionView* basis, vector* all_equivs) + RegionView* basis, vector* all_equivs) { Playlist* pl; - vector results; + vector > results; RegionView* marv; - Diskstream* ds; + boost::shared_ptr ds; if ((ds = tv.get_diskstream()) == 0) { /* bus */ @@ -3033,8 +2958,8 @@ Editor::mapped_set_selected_regionview_from_click (RouteTimeAxisView& tv, uint32 pl->get_equivalent_regions (basis->region(), results); } - for (vector::iterator ir = results.begin(); ir != results.end(); ++ir) { - if ((marv = tv.view()->find_view (**ir)) != 0) { + for (vector >::iterator ir = results.begin(); ir != results.end(); ++ir) { + if ((marv = tv.view()->find_view (*ir)) != 0) { all_equivs->push_back (marv); } } @@ -3123,8 +3048,8 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, } else if (op == Selection::Extend) { list results; - jack_nframes_t last_frame; - jack_nframes_t first_frame; + nframes_t last_frame; + nframes_t first_frame; /* 1. find the last selected regionview in the track that was clicked in */ @@ -3134,55 +3059,55 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) { if (&(*x)->get_time_axis_view() == &clicked_regionview->get_time_axis_view()) { - if ((*x)->region().last_frame() > last_frame) { - last_frame = (*x)->region().last_frame(); + if ((*x)->region()->last_frame() > last_frame) { + last_frame = (*x)->region()->last_frame(); } - if ((*x)->region().first_frame() < first_frame) { - first_frame = (*x)->region().first_frame(); + if ((*x)->region()->first_frame() < first_frame) { + first_frame = (*x)->region()->first_frame(); } } } /* 2. figure out the boundaries for our search for new objects */ - switch (clicked_regionview->region().coverage (first_frame, last_frame)) { + switch (clicked_regionview->region()->coverage (first_frame, last_frame)) { case OverlapNone: cerr << "no overlap, first = " << first_frame << " last = " << last_frame << " region = " - << clicked_regionview->region().first_frame() << " .. " << clicked_regionview->region().last_frame() << endl; + << clicked_regionview->region()->first_frame() << " .. " << clicked_regionview->region()->last_frame() << endl; - if (last_frame < clicked_regionview->region().first_frame()) { + if (last_frame < clicked_regionview->region()->first_frame()) { first_frame = last_frame; - last_frame = clicked_regionview->region().last_frame(); + last_frame = clicked_regionview->region()->last_frame(); } else { last_frame = first_frame; - first_frame = clicked_regionview->region().first_frame(); + first_frame = clicked_regionview->region()->first_frame(); } break; case OverlapExternal: cerr << "external overlap, first = " << first_frame << " last = " << last_frame << " region = " - << clicked_regionview->region().first_frame() << " .. " << clicked_regionview->region().last_frame() << endl; + << clicked_regionview->region()->first_frame() << " .. " << clicked_regionview->region()->last_frame() << endl; - if (last_frame < clicked_regionview->region().first_frame()) { + if (last_frame < clicked_regionview->region()->first_frame()) { first_frame = last_frame; - last_frame = clicked_regionview->region().last_frame(); + last_frame = clicked_regionview->region()->last_frame(); } else { last_frame = first_frame; - first_frame = clicked_regionview->region().first_frame(); + first_frame = clicked_regionview->region()->first_frame(); } break; case OverlapInternal: cerr << "internal overlap, first = " << first_frame << " last = " << last_frame << " region = " - << clicked_regionview->region().first_frame() << " .. " << clicked_regionview->region().last_frame() << endl; + << clicked_regionview->region()->first_frame() << " .. " << clicked_regionview->region()->last_frame() << endl; - if (last_frame < clicked_regionview->region().first_frame()) { + if (last_frame < clicked_regionview->region()->first_frame()) { first_frame = last_frame; - last_frame = clicked_regionview->region().last_frame(); + last_frame = clicked_regionview->region()->last_frame(); } else { last_frame = first_frame; - first_frame = clicked_regionview->region().first_frame(); + first_frame = clicked_regionview->region()->first_frame(); } break; @@ -3229,7 +3154,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, } void -Editor::set_selected_regionview_from_region_list (Region& region, Selection::Operation op) +Editor::set_selected_regionview_from_region_list (boost::shared_ptr region, Selection::Operation op) { vector all_equivalent_regions; @@ -3240,9 +3165,9 @@ Editor::set_selected_regionview_from_region_list (Region& region, Selection::Ope if ((tatv = dynamic_cast (*i)) != 0) { Playlist* pl; - vector results; + vector > results; RegionView* marv; - Diskstream* ds; + boost::shared_ptr ds; if ((ds = tatv->get_diskstream()) == 0) { /* bus */ @@ -3253,8 +3178,8 @@ Editor::set_selected_regionview_from_region_list (Region& region, Selection::Ope pl->get_region_list_equivalent_regions (region, results); } - for (vector::iterator ir = results.begin(); ir != results.end(); ++ir) { - if ((marv = tatv->view()->find_view (**ir)) != 0) { + for (vector >::iterator ir = results.begin(); ir != results.end(); ++ir) { + if ((marv = tatv->view()->find_view (*ir)) != 0) { all_equivalent_regions.push_back (marv); } } @@ -3281,17 +3206,17 @@ Editor::set_selected_regionview_from_region_list (Region& region, Selection::Ope } bool -Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, Region* r) +Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, boost::shared_ptr r) { RegionView* rv; - Region* ar; + boost::shared_ptr ar; - if ((ar = dynamic_cast (r)) == 0) { - return TRUE; + if ((ar = boost::dynamic_pointer_cast (r)) == 0) { + return true; } - if ((rv = sv->find_view (*ar)) == 0) { - return TRUE; + if ((rv = sv->find_view (ar)) == 0) { + return true; } /* don't reset the selection if its something other than @@ -3299,7 +3224,7 @@ Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, */ if (selection->regions.size() > 1) { - return TRUE; + return true; } begin_reversible_command (_("set selected regions")); @@ -3308,7 +3233,7 @@ Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, commit_reversible_command () ; - return TRUE; + return true; } void @@ -3520,7 +3445,7 @@ Editor::edit_mode_selection_done () mode = Slide; } - session->set_edit_mode (mode); + Config->set_edit_mode (mode); } void @@ -3750,10 +3675,12 @@ Editor::get_valid_views (TimeAxisView* track, RouteGroup* group) void Editor::set_zoom_focus (ZoomFocus f) { + vector txt = internationalize (zoom_focus_strings); + zoom_focus_selector.set_active_text (txt[(int)f]); + if (zoom_focus != f) { zoom_focus = f; - vector txt = internationalize (zoom_focus_strings); - zoom_focus_selector.set_active_text (txt[(int)f]); + ZoomFocusChanged (); /* EMIT_SIGNAL */ instant_save (); @@ -3900,10 +3827,10 @@ Editor::playlist_selector () const return *_playlist_selector; } -jack_nframes_t -Editor::get_nudge_distance (jack_nframes_t pos, jack_nframes_t& next) +nframes_t +Editor::get_nudge_distance (nframes_t pos, nframes_t& next) { - jack_nframes_t ret; + nframes_t ret; ret = nudge_clock.current_duration (pos); next = ret + 1; /* XXXX fix me */ @@ -3953,10 +3880,10 @@ Editor::playlist_deletion_dialog (Playlist* pl) } bool -Editor::audio_region_selection_covers (jack_nframes_t where) +Editor::audio_region_selection_covers (nframes_t where) { for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) { - if ((*a)->region().covers (where)) { + if ((*a)->region()->covers (where)) { return true; } } @@ -4091,6 +4018,7 @@ Editor::restore_editing_space () { mouse_mode_tearoff->set_visible (true); tools_tearoff->set_visible (true); + edit_pane.set_position (pre_maximal_pane_position); unfullscreen(); @@ -4144,51 +4072,3 @@ Editor::on_key_press_event (GdkEventKey* ev) return key_press_focus_accelerator_handler (*this, ev); } -void -Editor::update_layering_model () -{ - RefPtr act; - - switch (session->get_layer_model()) { - case Session::LaterHigher: - act = ActionManager::get_action (X_("Editor"), X_("LayerLaterHigher")); - break; - case Session::MoveAddHigher: - act = ActionManager::get_action (X_("Editor"), X_("LayerMoveAddHigher")); - break; - case Session::AddHigher: - act = ActionManager::get_action (X_("Editor"), X_("LayerAddHigher")); - break; - } - - if (act) { - RefPtr ract = RefPtr::cast_dynamic(act); - if (ract && !ract->get_active()) { - ract->set_active (true); - } - } -} - - -void -Editor::update_crossfade_model () -{ - RefPtr act; - - switch (session->get_xfade_model()) { - case FullCrossfade: - act = ActionManager::get_action (X_("Editor"), X_("CrossfadesFull")); - break; - case ShortCrossfade: - act = ActionManager::get_action (X_("Editor"), X_("CrossfadesShort")); - break; - } - - if (act) { - RefPtr ract = RefPtr::cast_dynamic(act); - if (ract && !ract->get_active()) { - ract->set_active (true); - } - } -} -