#include "pbd/enumwriter.h"
#include "pbd/memento_command.h"
#include "pbd/unknown_type.h"
-#include "pbd/stacktrace.h"
+#include "pbd/unwind.h"
#include <glibmm/miscutils.h>
#include <gtkmm/image.h>
#include "canvas-noevent-text.h"
#include "canvas_impl.h"
#include "crossfade_edit.h"
-#include "crossfade_view.h"
#include "debug.h"
#include "editing.h"
#include "editor.h"
N_("Timecode Minutes"),
N_("Seconds"),
N_("Minutes"),
+ N_("Beats/128"),
+ N_("Beats/64"),
N_("Beats/32"),
N_("Beats/28"),
N_("Beats/24"),
clicked_regionview = 0;
clicked_axisview = 0;
clicked_routeview = 0;
- clicked_crossfadeview = 0;
clicked_control_point = 0;
last_update_frame = 0;
pre_press_cursor = 0;
have_pending_keyboard_selection = false;
_follow_playhead = true;
_stationary_playhead = false;
- _xfade_visibility = true;
editor_ruler_menu = 0;
no_ruler_shown_update = false;
marker_menu = 0;
layering_order_editor = 0;
no_save_visual = false;
resize_idle_id = -1;
+ within_track_canvas = false;
scrubbing_direction = 0;
ControlProtocol::ZoomToSession.connect (*this, invalidator (*this), boost::bind (&Editor::temporal_zoom_session, this), gui_context());
ControlProtocol::ZoomIn.connect (*this, invalidator (*this), boost::bind (&Editor::temporal_zoom_step, this, false), gui_context());
ControlProtocol::ZoomOut.connect (*this, invalidator (*this), boost::bind (&Editor::temporal_zoom_step, this, true), gui_context());
+ ControlProtocol::Undo.connect (*this, invalidator (*this), boost::bind (&Editor::undo, this, true), gui_context());
+ ControlProtocol::Redo.connect (*this, invalidator (*this), boost::bind (&Editor::redo, this, true), gui_context());
ControlProtocol::ScrollTimeline.connect (*this, invalidator (*this), ui_bind (&Editor::control_scroll, this, _1), gui_context());
- ControlProtocol::SelectByRID.connect (*this, invalidator (*this), ui_bind (&Editor::control_select, this, _1), gui_context());
+ ControlProtocol::GotoView.connect (*this, invalidator (*this), ui_bind (&Editor::control_view, this, _1), gui_context());
+ ControlProtocol::CloseDialog.connect (*this, invalidator (*this), Keyboard::close_current_dialog, gui_context());
+ ControlProtocol::VerticalZoomInAll.connect (*this, invalidator (*this), ui_bind (&Editor::control_vertical_zoom_in_all, this), gui_context());
+ ControlProtocol::VerticalZoomOutAll.connect (*this, invalidator (*this), ui_bind (&Editor::control_vertical_zoom_out_all, this), gui_context());
+ ControlProtocol::VerticalZoomInSelected.connect (*this, invalidator (*this), ui_bind (&Editor::control_vertical_zoom_in_selected, this), gui_context());
+ ControlProtocol::VerticalZoomOutSelected.connect (*this, invalidator (*this), ui_bind (&Editor::control_vertical_zoom_out_selected, this), gui_context());
+
+ ControlProtocol::AddRouteToSelection.connect (*this, invalidator (*this), ui_bind (&Editor::control_select, this, _1, Selection::Add), gui_context());
+ ControlProtocol::RemoveRouteFromSelection.connect (*this, invalidator (*this), ui_bind (&Editor::control_select, this, _1, Selection::Toggle), gui_context());
+ ControlProtocol::SetRouteSelection.connect (*this, invalidator (*this), ui_bind (&Editor::control_select, this, _1, Selection::Set), gui_context());
+ ControlProtocol::ClearRouteSelection.connect (*this, invalidator (*this), ui_bind (&Editor::control_unselect, this), gui_context());
+
BasicUI::AccessAction.connect (*this, invalidator (*this), ui_bind (&Editor::access_action, this, _1, _2), gui_context());
/* problematic: has to return a value and thus cannot be x-thread */
}
void
-Editor::control_select (uint32_t rid)
+Editor::control_vertical_zoom_in_all ()
+{
+ tav_zoom_smooth (false, true);
+}
+
+void
+Editor::control_vertical_zoom_out_all ()
+{
+ tav_zoom_smooth (true, true);
+}
+
+void
+Editor::control_vertical_zoom_in_selected ()
+{
+ tav_zoom_smooth (false, false);
+}
+
+void
+Editor::control_vertical_zoom_out_selected ()
+{
+ tav_zoom_smooth (true, false);
+}
+
+void
+Editor::control_view (uint32_t view)
+{
+ goto_visual_state (view);
+}
+
+void
+Editor::control_unselect ()
+{
+ selection->clear_tracks ();
+}
+
+void
+Editor::control_select (uint32_t rid, Selection::Operation op)
{
/* handles the (static) signal from the ControlProtocol class that
* requests setting the selected track to a given RID
TimeAxisView* tav = axis_view_from_route (r);
if (tav) {
- selection->set (tav);
+ switch (op) {
+ case Selection::Add:
+ selection->add (tav);
+ break;
+ case Selection::Toggle:
+ selection->toggle (tav);
+ break;
+ case Selection::Extend:
+ break;
+ case Selection::Set:
+ selection->set (tav);
+ break;
+ }
} else {
selection->clear_tracks ();
}
_session->locations()->StateChanged.connect (_session_connections, invalidator (*this), ui_bind (&Editor::refresh_location_display, this), gui_context());
_session->history().Changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::history_changed, this), gui_context());
- if (Profile->get_sae()) {
- Timecode::BBT_Time bbt;
- bbt.bars = 0;
- bbt.beats = 0;
- bbt.ticks = 120;
- framepos_t pos = _session->tempo_map().bbt_duration_at (0, bbt, 1);
- nudge_clock->set_mode(AudioClock::BBT);
- nudge_clock->set (pos, true);
-
- } else {
- nudge_clock->set_mode (AudioClock::Timecode);
- nudge_clock->set (_session->frame_rate() * 5, true);
- }
-
playhead_cursor->canvas_item.show ();
boost::function<void (string)> pc (boost::bind (&Editor::parameter_changed, this, _1));
}
break;
- case CrossfadeViewItem:
- build_menu_function = &Editor::build_track_crossfade_context_menu;
- break;
-
case StreamItem:
if (clicked_routeview->track()) {
build_menu_function = &Editor::build_track_context_menu;
case SelectionItem:
break;
- case CrossfadeViewItem:
- break;
-
case StreamItem:
break;
region_edit_menu_split_item = 0;
region_edit_menu_split_multichannel_item = 0;
- /* we might try to use items that are currently attached to a crossfade menu,
- so clear that, too.
- */
- track_crossfade_context_menu.items().clear ();
-
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (clicked_axisview);
if (rtv) {
return &track_region_context_menu;
}
-Menu*
-Editor::build_track_crossfade_context_menu ()
-{
- using namespace Menu_Helpers;
- MenuList& edit_items = track_crossfade_context_menu.items();
- edit_items.clear ();
-
- /* we might try to use items that are currently attached to a crossfade menu,
- so clear that, too.
- */
- track_region_context_menu.items().clear ();
-
- AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_axisview);
-
- if (atv) {
- boost::shared_ptr<Track> tr;
- boost::shared_ptr<Playlist> pl;
- boost::shared_ptr<AudioPlaylist> apl;
-
- if ((tr = atv->track()) && ((pl = tr->playlist()) != 0) && ((apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl)) != 0)) {
-
- AudioPlaylist::Crossfades xfades;
- framepos_t where;
- bool ignored;
-
- /* The xfade menu is a bit of a special case, as we always use the mouse position
- to decide whether or not to display it (rather than the edit point). No particularly
- strong reasons for this, other than it is a bit surprising to right-click on a xfade
- and not get a menu.
- */
- mouse_frame (where, ignored);
- apl->crossfades_at (where, xfades);
-
- bool const many = xfades.size() > 1;
-
- for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
- add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
- }
-
- add_region_context_items (edit_items, tr);
- }
- }
-
- add_dstream_context_items (edit_items);
-
- return &track_crossfade_context_menu;
-}
-
void
Editor::analyze_region_selection ()
{
return &track_selection_context_menu;
}
-/** Add context menu items relevant to crossfades.
- * @param edit_items List to add the items to.
- */
-void
-Editor::add_crossfade_context_items (AudioStreamView* view, boost::shared_ptr<Crossfade> xfade, Menu_Helpers::MenuList& edit_items, bool many)
-{
- using namespace Menu_Helpers;
- Menu *xfade_menu = manage (new Menu);
- MenuList& items = xfade_menu->items();
- xfade_menu->set_name ("ArdourContextMenu");
- string str;
-
- if (xfade->active()) {
- str = _("Mute");
- } else {
- str = _("Unmute");
- }
-
- items.push_back (
- MenuElem (str, sigc::bind (sigc::mem_fun (*this, &Editor::toggle_xfade_active), &view->trackview(), boost::weak_ptr<Crossfade> (xfade)))
- );
-
- items.push_back (
- MenuElem (_("Edit..."), sigc::bind (sigc::mem_fun (*this, &Editor::edit_xfade), boost::weak_ptr<Crossfade> (xfade)))
- );
-
- if (xfade->can_follow_overlap()) {
-
- if (xfade->following_overlap()) {
- str = _("Convert to Short");
- } else {
- str = _("Convert to Full");
- }
-
- items.push_back (
- MenuElem (str, sigc::bind (sigc::mem_fun (*this, &Editor::toggle_xfade_length), &view->trackview(), xfade))
- );
- }
-
- if (many) {
- str = xfade->out()->name();
- str += "->";
- str += xfade->in()->name();
- } else {
- str = _("Crossfade");
- }
-
- edit_items.push_back (MenuElem (str, *xfade_menu));
- edit_items.push_back (SeparatorElem());
-}
-
-void
-Editor::xfade_edit_left_region ()
-{
- if (clicked_crossfadeview) {
- clicked_crossfadeview->left_view.show_region_editor ();
- }
-}
-
-void
-Editor::xfade_edit_right_region ()
-{
- if (clicked_crossfadeview) {
- clicked_crossfadeview->right_view.show_region_editor ();
- }
-}
-
void
Editor::add_region_context_items (Menu_Helpers::MenuList& edit_items, boost::shared_ptr<Track> track)
{
instant_save ();
switch (_snap_type) {
+ case SnapToBeatDiv128:
+ case SnapToBeatDiv64:
case SnapToBeatDiv32:
case SnapToBeatDiv28:
case SnapToBeatDiv24:
_regions->reset_sort_type ((RegionListSortType) string_2_enum (prop->value(), st), true);
}
- if ((prop = node.property ("xfades-visible"))) {
- bool yn = string_is_affirmative (prop->value());
- _xfade_visibility = !yn;
- // set_xfade_visibility (yn);
- }
-
if ((prop = node.property ("show-editor-mixer"))) {
Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
}
}
+ if ((prop = node.property ("nudge-clock-value"))) {
+ framepos_t f;
+ sscanf (prop->value().c_str(), "%" PRId64, &f);
+ nudge_clock->set (f);
+ } else {
+ nudge_clock->set_mode (AudioClock::Timecode);
+ nudge_clock->set (_session->frame_rate() * 5, true);
+ }
+
return 0;
}
node->add_property ("maximised", _maximised ? "yes" : "no");
node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
node->add_property ("stationary-playhead", _stationary_playhead ? "yes" : "no");
- node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
node->add_property ("region-list-sort-type", enum_2_string (_regions->sort_type ()));
node->add_property ("mouse-mode", enum2str(mouse_mode));
node->add_property ("internal-edit", _internal_editing ? "yes" : "no");
node->add_child_nocopy (selection->get_state ());
node->add_child_nocopy (_regions->get_state ());
+ snprintf (buf, sizeof (buf), "%" PRId64, nudge_clock->current_duration());
+ node->add_property ("nudge-clock-value", buf);
+
return *node;
}
start = _session->tempo_map().round_to_beat (start, direction);
break;
+ case SnapToBeatDiv128:
+ start = _session->tempo_map().round_to_beat_subdivision (start, 128, direction);
+ break;
+ case SnapToBeatDiv64:
+ start = _session->tempo_map().round_to_beat_subdivision (start, 64, direction);
+ break;
case SnapToBeatDiv32:
start = _session->tempo_map().round_to_beat_subdivision (start, 32, direction);
break;
/* make them just a bit bigger */
mouse_move_button.set_size_request (-1, 25);
- smart_mode_joiner = manage (new ButtonJoiner ("mouse mode button", mouse_move_button, mouse_select_button));
+ smart_mode_joiner = manage (new ButtonJoiner ("mouse mode button", mouse_move_button, mouse_select_button, true));
smart_mode_joiner->set_related_action (smart_mode_action);
- mouse_move_button.set_elements (ArdourButton::Element (ArdourButton::Body|ArdourButton::Text));
- mouse_select_button.set_elements (ArdourButton::Element (ArdourButton::Body|ArdourButton::Text));
-
- mouse_move_button.set_rounded_corner_mask (0x1); // upper left only
- mouse_select_button.set_rounded_corner_mask (0x2); // upper right only
-
mouse_mode_hbox2->set_spacing (2);
mouse_mode_box->set_spacing (2);
if ((*i).substr (0,7) == "file://") {
- string p = *i;
- PBD::url_decode (p);
+ string const p = PBD::url_decode (*i);
// scan forward past three slashes
string::size_type slashcnt = 0;
string::size_type n = 0;
- string::iterator x = p.begin();
+ string::const_iterator x = p.begin();
while (slashcnt < 3 && x != p.end()) {
if ((*x) == '/') {
/* UNDO/REDO */
-Editor::State::State (PublicEditor const * e)
-{
- selection = new Selection (e);
-}
-
-Editor::State::~State ()
-{
- delete selection;
-}
-
void
Editor::begin_reversible_command (string name)
{
snaptype = SnapToBeatDiv28;
} else if (choice == _("Beats/32")) {
snaptype = SnapToBeatDiv32;
+ } else if (choice == _("Beats/64")) {
+ snaptype = SnapToBeatDiv64;
+ } else if (choice == _("Beats/128")) {
+ snaptype = SnapToBeatDiv128;
} else if (choice == _("Beats")) {
snaptype = SnapToBeat;
} else if (choice == _("Bars")) {
}
}
-void
-Editor::toggle_xfade_active (RouteTimeAxisView* tv, boost::weak_ptr<Crossfade> wxfade)
-{
- boost::shared_ptr<Crossfade> xfade (wxfade.lock());
- if (!xfade) {
- return;
- }
-
- vector<boost::shared_ptr<Crossfade> > all = get_equivalent_crossfades (*tv, xfade, ARDOUR::Properties::edit.property_id);
-
- _session->begin_reversible_command (_("Change crossfade active state"));
-
- for (vector<boost::shared_ptr<Crossfade> >::iterator i = all.begin(); i != all.end(); ++i) {
- (*i)->clear_changes ();
- (*i)->set_active (!(*i)->active());
- _session->add_command (new StatefulDiffCommand (*i));
- }
-
- _session->commit_reversible_command ();
-}
-
-void
-Editor::toggle_xfade_length (RouteTimeAxisView* tv, boost::weak_ptr<Crossfade> wxfade)
-{
- boost::shared_ptr<Crossfade> xfade (wxfade.lock());
- if (!xfade) {
- return;
- }
-
- vector<boost::shared_ptr<Crossfade> > all = get_equivalent_crossfades (*tv, xfade, ARDOUR::Properties::edit.property_id);
-
- /* This can't be a StatefulDiffCommand as the fade shapes are not
- managed by the Stateful properties system.
- */
- _session->begin_reversible_command (_("Change crossfade length"));
-
- for (vector<boost::shared_ptr<Crossfade> >::iterator i = all.begin(); i != all.end(); ++i) {
- XMLNode& before = (*i)->get_state ();
- (*i)->set_follow_overlap (!(*i)->following_overlap());
- XMLNode& after = (*i)->get_state ();
-
- _session->add_command (new MementoCommand<Crossfade> (*i->get(), &before, &after));
- }
-
- _session->commit_reversible_command ();
-}
-
-void
-Editor::edit_xfade (boost::weak_ptr<Crossfade> wxfade)
-{
- boost::shared_ptr<Crossfade> xfade (wxfade.lock());
-
- if (!xfade) {
- return;
- }
-
- CrossfadeEditor cew (_session, xfade, xfade->fade_in().get_min_y(), 1.0);
-
- ensure_float (cew);
-
- switch (cew.run ()) {
- case RESPONSE_ACCEPT:
- break;
- default:
- return;
- }
-
- cew.apply ();
- PropertyChange all_crossfade_properties;
- all_crossfade_properties.add (ARDOUR::Properties::active);
- all_crossfade_properties.add (ARDOUR::Properties::follow_overlap);
- xfade->PropertyChanged (all_crossfade_properties);
-}
-
PlaylistSelector&
Editor::playlist_selector () const
{
return 1.0;
break;
+ case SnapToBeatDiv128:
+ return 1.0/128.0;
+ break;
+ case SnapToBeatDiv64:
+ return 1.0/64.0;
+ break;
case SnapToBeatDiv32:
return 1.0/32.0;
break;
}
}
-Editor::VisualState::VisualState ()
- : gui_state (new GUIObjectState)
+Editor::VisualState::VisualState (bool with_tracks)
+ : gui_state (with_tracks ? new GUIObjectState : 0)
{
}
Editor::VisualState*
Editor::current_visual_state (bool with_tracks)
{
- VisualState* vs = new VisualState;
+ VisualState* vs = new VisualState (with_tracks);
vs->y_position = vertical_adjustment.get_value();
vs->frames_per_unit = frames_per_unit;
vs->leftmost_frame = leftmost_frame;
vs->zoom_focus = zoom_focus;
if (with_tracks) {
- *(vs->gui_state) = *ARDOUR_UI::instance()->gui_object_state;
+ *vs->gui_state = *ARDOUR_UI::instance()->gui_object_state;
}
return vs;
return;
}
- redo_visual_stack.push_back (current_visual_state());
-
VisualState* vs = undo_visual_stack.back();
undo_visual_stack.pop_back();
+
+
+ redo_visual_stack.push_back (current_visual_state (vs ? vs->gui_state != 0 : false));
+
use_visual_state (*vs);
}
return;
}
- undo_visual_stack.push_back (current_visual_state());
-
VisualState* vs = redo_visual_stack.back();
redo_visual_stack.pop_back();
+
+ undo_visual_stack.push_back (current_visual_state (vs ? vs->gui_state != 0 : false));
+
use_visual_state (*vs);
}
void
Editor::use_visual_state (VisualState& vs)
{
- no_save_visual = true;
+ PBD::Unwinder<bool> nsv (no_save_visual, true);
_routes->suspend_redisplay ();
set_zoom_focus (vs.zoom_focus);
reposition_and_zoom (vs.leftmost_frame, vs.frames_per_unit);
- *ARDOUR_UI::instance()->gui_object_state = *vs.gui_state;
-
- for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
- (*i)->reset_visual_state ();
+ if (vs.gui_state) {
+ *ARDOUR_UI::instance()->gui_object_state = *vs.gui_state;
+
+ for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
+ (*i)->reset_visual_state ();
+ }
}
_routes->update_visibility ();
_routes->resume_redisplay ();
-
- no_save_visual = false;
}
void
zoom_range_clock->set (frames);
}
- if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
+ bool const showing_time_selection =
+ mouse_mode == MouseRange ||
+ (mouse_mode == MouseObject && _join_object_range_state != JOIN_OBJECT_RANGE_NONE);
+
+ if (showing_time_selection && selection->time.start () != selection->time.end_frame ()) {
for (TrackViewList::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
(*i)->reshow_selection (selection->time);
}
double const last_time_origin = horizontal_position ();
- if (p & VisualChange::TimeOrigin) {
- /* This is a bit of a hack, but set_frames_per_unit
- below will (if called) end up with the
- CrossfadeViews looking at Editor::leftmost_frame,
- and if we're changing origin and zoom in the same
- operation it will be the wrong value unless we
- update it here.
- */
-
- leftmost_frame = pending_visual_change.time_origin;
- assert (leftmost_frame >= 0);
- }
-
if (p & VisualChange::ZoomLevel) {
set_frames_per_unit (pending_visual_change.frames_per_unit);
clicked_regionview = 0;
clicked_axisview = 0;
clicked_routeview = 0;
- clicked_crossfadeview = 0;
entered_regionview = 0;
entered_track = 0;
last_update_frame = 0;
_fade_out_images[FadeSlow] = new Gtk::Image (get_icon_path (X_("crossfade-out-long-cut")));
}
-
/** @return Gtk::manage()d menu item for a given action from `editor_actions' */
Gtk::MenuItem&
Editor::action_menu_item (std::string const & name)