#include "gtkmm2ext/cell_renderer_pixbuf_toggle.h"
#include "ardour/audio_track.h"
-#include "ardour/audioplaylist.h"
+#include "ardour/audioengine.h"
#include "ardour/audioregion.h"
#include "ardour/location.h"
-#include "ardour/midi_region.h"
-#include "ardour/plugin_manager.h"
#include "ardour/profile.h"
#include "ardour/route_group.h"
-#include "ardour/session_directory.h"
-#include "ardour/session_route.h"
-#include "ardour/session_state_utils.h"
+#include "ardour/session_playlists.h"
#include "ardour/tempo.h"
#include "ardour/utils.h"
-#include "ardour/session_playlists.h"
-#include "ardour/audioengine.h"
#include "control_protocol/control_protocol.h"
cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
}
-#ifdef GTKOSX
static void
pane_size_watcher (Paned* pane)
{
/* if the handle of a pane vanishes into (at least) the tabs of a notebook,
- it is no longer accessible. so stop that. this doesn't happen on X11,
- just the quartz backend.
+ it is:
+
+ X: hard to access
+ Quartz: impossible to access
+
+ so stop that by preventing it from ever getting too narrow. 35
+ pixels is basically a rough guess at the tab width.
ugh.
*/
- int max_width_of_lhs = GTK_WIDGET(pane->gobj())->allocation.width - 25;
+ int max_width_of_lhs = GTK_WIDGET(pane->gobj())->allocation.width - 35;
gint pos = pane->get_position ();
pane->set_position (max_width_of_lhs);
}
}
-#endif
Editor::Editor ()
: _join_object_range_state (JOIN_OBJECT_RANGE_NONE)
, _region_selection_change_updates_region_list (true)
, _following_mixer_selection (false)
+ , _control_point_toggled_on_press (false)
+ , _stepping_axis_view (0)
{
constructed = false;
editor_summary_pane.signal_size_allocate().connect (sigc::bind (sigc::mem_fun (*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&editor_summary_pane)));
- /* XXX: editor_summary_pane might need similar special OS X treatment to the edit_pane */
+ /* XXX: editor_summary_pane might need similar to the edit_pane */
edit_pane.signal_size_allocate().connect (sigc::bind (sigc::mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
-#ifdef GTKOSX
+
Glib::PropertyProxy<int> proxy = edit_pane.property_position();
proxy.signal_changed().connect (bind (sigc::ptr_fun (pane_size_watcher), static_cast<Paned*> (&edit_pane)));
-#endif
+
top_hbox.pack_start (toolbar_frame);
HBox *hbox = manage (new HBox);
signal_configure_event().connect (sigc::mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
signal_delete_event().connect (sigc::mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
+ Gtkmm2ext::Keyboard::the_keyboard().ShiftReleased.connect (sigc::mem_fun (*this, &Editor::shift_key_released));
+
/* allow external control surfaces/protocols to do various things */
ControlProtocol::ZoomToSession.connect (*this, invalidator (*this), boost::bind (&Editor::temporal_zoom_session, this), gui_context());
XMLNode* node = find_named_node (*settings, X_("Buttons"));
if (!node) {
- cerr << "new empty Button node\n";
node = new XMLNode (X_("Buttons"));
}
}
double fpu = zoom_range_clock->current_duration() / _canvas_width;
-
- if (fpu < 1.0) {
- fpu = 1.0;
- zoom_range_clock->set ((framepos_t) floor (fpu * _canvas_width));
- } else if (fpu > _session->current_end_frame() / _canvas_width) {
- fpu = _session->current_end_frame() / _canvas_width;
+ bool clamped = clamp_frames_per_unit (fpu);
+
+ if (clamped) {
zoom_range_clock->set ((framepos_t) floor (fpu * _canvas_width));
}
_session->StepEditStatusChange.connect (_session_connections, invalidator (*this), boost::bind (&Editor::step_edit_status_change, this, _1), gui_context());
_session->TransportStateChange.connect (_session_connections, invalidator (*this), boost::bind (&Editor::map_transport_state, this), gui_context());
_session->PositionChanged.connect (_session_connections, invalidator (*this), boost::bind (&Editor::map_position_change, this, _1), gui_context());
- _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Editor::handle_new_route, this, _1), gui_context());
+ _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Editor::add_routes, this, _1), gui_context());
_session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Editor::update_title, this), gui_context());
_session->tempo_map().PropertyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Editor::tempo_map_changed, this, _1), gui_context());
_session->Located.connect (_session_connections, invalidator (*this), boost::bind (&Editor::located, this), gui_context());
/** Pop up a context menu for when the user clicks on a start crossfade */
void
-Editor::popup_xfade_in_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
+Editor::popup_xfade_in_context_menu (int button, int32_t time, ArdourCanvas::Item* /*item*/, ItemType /*item_type*/)
{
using namespace Menu_Helpers;
/** Pop up a context menu for when the user clicks on an end crossfade */
void
-Editor::popup_xfade_out_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
+Editor::popup_xfade_out_context_menu (int button, int32_t time, ArdourCanvas::Item* /*item*/, ItemType /*item_type*/)
{
using namespace Menu_Helpers;
edit_items.push_back (SeparatorElem());
edit_items.push_back (MenuElem (_("Crop Region to Range"), sigc::mem_fun(*this, &Editor::crop_region_to_selection)));
edit_items.push_back (MenuElem (_("Fill Range with Region"), sigc::mem_fun(*this, &Editor::region_fill_selection)));
- edit_items.push_back (MenuElem (_("Duplicate Range"), sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_dialog), false)));
+ edit_items.push_back (MenuElem (_("Duplicate Range"), sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_range), false)));
edit_items.push_back (SeparatorElem());
edit_items.push_back (MenuElem (_("Consolidate Range"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), true, false)));
nudge_menu->set_name ("ArdourContextMenu");
edit_items.push_back (SeparatorElem());
- nudge_items.push_back (MenuElem (_("Nudge Entire Track Forward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), false, true))));
- nudge_items.push_back (MenuElem (_("Nudge Track After Edit Point Forward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), true, true))));
- nudge_items.push_back (MenuElem (_("Nudge Entire Track Backward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), false, false))));
- nudge_items.push_back (MenuElem (_("Nudge Track After Edit Point Backward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), true, false))));
+ nudge_items.push_back (MenuElem (_("Nudge Entire Track Later"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), false, true))));
+ nudge_items.push_back (MenuElem (_("Nudge Track After Edit Point Later"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), true, true))));
+ nudge_items.push_back (MenuElem (_("Nudge Entire Track Earlier"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), false, false))));
+ nudge_items.push_back (MenuElem (_("Nudge Track After Edit Point Earlier"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), true, false))));
edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
}
nudge_menu->set_name ("ArdourContextMenu");
edit_items.push_back (SeparatorElem());
- nudge_items.push_back (MenuElem (_("Nudge Entire Track Forward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), false, true))));
- nudge_items.push_back (MenuElem (_("Nudge Track After Edit Point Forward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), true, true))));
- nudge_items.push_back (MenuElem (_("Nudge Entire Track Backward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), false, false))));
- nudge_items.push_back (MenuElem (_("Nudge Track After Edit Point Backward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), true, false))));
+ nudge_items.push_back (MenuElem (_("Nudge Entire Track Later"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), false, true))));
+ nudge_items.push_back (MenuElem (_("Nudge Track After Edit Point Later"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), true, true))));
+ nudge_items.push_back (MenuElem (_("Nudge Entire Track Earlier"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), false, false))));
+ nudge_items.push_back (MenuElem (_("Nudge Track After Edit Point Earlier"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), true, false))));
edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
}
_session->locations()->marks_either_side (start, before, after);
- if (before == max_framepos) {
+ if (before == max_framepos && after == max_framepos) {
+ /* No marks to snap to, so just don't snap */
+ return;
+ } else if (before == max_framepos) {
start = after;
} else if (after == max_framepos) {
start = before;
ARDOUR_UI::instance()->set_tip (smart_mode_joiner, _("Smart Mode (Select/Move Objects + Ranges)"));
ARDOUR_UI::instance()->set_tip (internal_edit_button, _("Edit Region Contents (e.g. notes)"));
ARDOUR_UI::instance()->set_tip (*_group_tabs, _("Groups: click to (de)activate\nContext-click for other operations"));
- ARDOUR_UI::instance()->set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
- ARDOUR_UI::instance()->set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
+ ARDOUR_UI::instance()->set_tip (nudge_forward_button, _("Nudge Region/Selection Later"));
+ ARDOUR_UI::instance()->set_tip (nudge_backward_button, _("Nudge Region/Selection Earlier"));
ARDOUR_UI::instance()->set_tip (zoom_in_button, _("Zoom In"));
ARDOUR_UI::instance()->set_tip (zoom_out_button, _("Zoom Out"));
ARDOUR_UI::instance()->set_tip (zoom_out_full_button, _("Zoom to Session"));
const char* q;
p = (const char *) malloc (txt.length() + 1);
- txt.copy ((char *) p, txt.length(), 0);
- ((char*)p)[txt.length()] = '\0';
+ txt.copy (const_cast<char *> (p), txt.length(), 0);
+ const_cast<char*>(p)[txt.length()] = '\0';
while (p)
{
}
void
-Editor::duplicate_dialog (bool with_dialog)
+Editor::duplicate_range (bool with_dialog)
{
float times = 1.0f;
_snapshots->redisplay ();
}
+void
+Editor::update_tearoff_visibility()
+{
+ bool visible = Config->get_keep_tearoffs();
+ _mouse_mode_tearoff->set_visible (visible);
+ _tools_tearoff->set_visible (visible);
+ _zoom_tearoff->set_visible (visible);
+}
+
void
Editor::maximise_editing_space ()
{
fullscreen ();
- if (!Config->get_keep_tearoffs()) {
- /* these calls will leave each tearoff visible *if* it is torn off,
- but invisible otherwise.
- */
- _mouse_mode_tearoff->set_visible (false);
- _tools_tearoff->set_visible (false);
- _zoom_tearoff->set_visible (false);
- }
-
_maximised = true;
}
unfullscreen();
- if (!Config->get_keep_tearoffs()) {
- _mouse_mode_tearoff->set_visible (true);
- _tools_tearoff->set_visible (true);
- _zoom_tearoff->set_visible (true);
- }
-
_maximised = false;
}
void
Editor::reset_x_origin (framepos_t frame)
{
- queue_visual_change (frame);
+ pending_visual_change.add (VisualChange::TimeOrigin);
+ pending_visual_change.time_origin = frame;
+ ensure_visual_change_idle_handler ();
}
void
Editor::reset_y_origin (double y)
{
- queue_visual_change_y (y);
+ pending_visual_change.add (VisualChange::YOrigin);
+ pending_visual_change.y_origin = y;
+ ensure_visual_change_idle_handler ();
}
void
Editor::reset_zoom (double fpu)
{
- queue_visual_change (fpu);
+ clamp_frames_per_unit (fpu);
+
+ if (fpu == frames_per_unit) {
+ return;
+ }
+
+ pending_visual_change.add (VisualChange::ZoomLevel);
+ pending_visual_change.frames_per_unit = fpu;
+ ensure_visual_change_idle_handler ();
}
void
_routes->resume_redisplay ();
}
+/** This is the core function that controls the zoom level of the canvas. It is called
+ * whenever one or more calls are made to reset_zoom(). It executes in an idle handler.
+ * @param fpu New frames per unit; should already have been clamped so that it is sensible.
+ */
void
Editor::set_frames_per_unit (double fpu)
{
- /* this is the core function that controls the zoom level of the canvas. it is called
- whenever one or more calls are made to reset_zoom(). it executes in an idle handler.
- */
-
- if (fpu == frames_per_unit) {
- return;
- }
-
- if (fpu < 2.0) {
- fpu = 2.0;
- }
-
-
- /* don't allow zooms that fit more than the maximum number
- of frames into an 800 pixel wide space.
- */
-
- if (max_framepos / fpu < 800.0) {
- return;
- }
-
- if (tempo_lines)
+ if (tempo_lines) {
tempo_lines->tempo_map_changed();
+ }
frames_per_unit = fpu;
- post_zoom ();
-}
-void
-Editor::post_zoom ()
-{
- // convert fpu to frame count
+ /* convert fpu to frame count */
framepos_t frames = (framepos_t) floor (frames_per_unit * _canvas_width);
instant_save ();
}
-void
-Editor::queue_visual_change (framepos_t where)
-{
- pending_visual_change.add (VisualChange::TimeOrigin);
- pending_visual_change.time_origin = where;
- ensure_visual_change_idle_handler ();
-}
-
-void
-Editor::queue_visual_change (double fpu)
-{
- pending_visual_change.add (VisualChange::ZoomLevel);
- pending_visual_change.frames_per_unit = fpu;
-
- ensure_visual_change_idle_handler ();
-}
-
-void
-Editor::queue_visual_change_y (double y)
-{
- pending_visual_change.add (VisualChange::YOrigin);
- pending_visual_change.y_origin = y;
-
- ensure_visual_change_idle_handler ();
-}
-
void
Editor::ensure_visual_change_idle_handler ()
{
int
Editor::idle_visual_changer ()
{
+ /* set_horizontal_position() below (and maybe other calls) call
+ gtk_main_iteration(), so it's possible that a signal will be handled
+ half-way through this method. If this signal wants an
+ idle_visual_changer we must schedule another one after this one, so
+ mark the idle_handler_id as -1 here to allow that. Also make a note
+ that we are doing the visual change, so that changes in response to
+ super-rapid-screen-update can be dropped if we are still processing
+ the last one.
+ */
+ pending_visual_change.idle_handler_id = -1;
+ pending_visual_change.being_handled = true;
+
VisualChange::Type p = pending_visual_change.pending;
pending_visual_change.pending = (VisualChange::Type) 0;
_summary->set_overlays_dirty ();
- pending_visual_change.idle_handler_id = -1;
+ pending_visual_change.being_handled = false;
return 0; /* this is always a one-shot call */
}
Location* tpl;
if ((tpl = transport_punch_location()) == 0) {
- Location* loc = new Location (*_session, start, end, _("Loop"), Location::IsAutoPunch);
+ Location* loc = new Location (*_session, start, end, _("Punch"), Location::IsAutoPunch);
XMLNode &before = _session->locations()->get_state();
_session->locations()->add (loc, true);
_session->set_auto_loop_location (loc);
* the edit point is `mouse' and the mouse is over an unselected
* region. In this case, start with just that region.
*
- * Then, make an initial track list of the tracks that these
- * regions are on, and if the edit point is not `mouse', add the
- * selected tracks.
+ * Then, add equivalent regions in active edit groups to the region list.
*
- * Look at this track list and add any other tracks that are on the
- * same active edit-enabled route group as one of the initial tracks.
+ * Then, search the list of selected tracks to find any selected tracks which
+ * do not contain regions already in the region list. If there are no selected
+ * tracks and 'No Selection = All Tracks' is active, search all tracks rather
+ * than just the selected.
*
- * Finally take the initial region list and add any regions that are
- * under the edit point on one of the tracks on the track list to get
- * the returned region list.
+ * Add any regions that are under the edit point on these tracks to get the
+ * returned region list.
*
* The rationale here is that the mouse edit point is special in that
* its position describes both a time and a track; the other edit
tracks = selection->tracks;
}
- /* Add any other tracks that have regions that are in the same
+ /* Add any other regions that are in the same
edit-activated route group as one of our regions.
*/
- for (RegionSelection::iterator i = regions.begin (); i != regions.end(); ++i) {
+ regions = get_equivalent_regions (regions, ARDOUR::Properties::edit.property_id);
+ framepos_t const where = get_preferred_edit_position ();
- RouteGroup* g = (*i)->get_time_axis_view().route_group ();
-
- if (g && g->is_active() && g->is_edit()) {
- tracks.add (axis_views_from_routes (g->route_list()));
- }
+ if (_route_groups->all_group_active_button().get_active() && tracks.empty()) {
+ /* tracks is empty (no track selected), and 'No Selection = All Tracks'
+ * is enabled, so consider all tracks
+ */
+ tracks = track_views;
}
if (!tracks.empty()) {
- /* now find regions that are at the edit position on those tracks */
- framepos_t const where = get_preferred_edit_position ();
- get_regions_at (regions, where, tracks);
+ /* now search the selected tracks for tracks which don't
+ already contain regions to be acted upon, and get regions at
+ the edit point on those tracks too.
+ */
+ TrackViewList tracks_without_relevant_regions;
+
+ for (TrackViewList::iterator t = tracks.begin (); t != tracks.end (); ++t) {
+ if (!regions.involves (**t)) {
+ /* there are no equivalent regions on this track */
+ tracks_without_relevant_regions.push_back (*t);
+ }
+ }
+
+ if (!tracks_without_relevant_regions.empty()) {
+ /* there are some selected tracks with neither selected
+ * regions or their equivalents: act upon all regions in
+ * those tracks
+ */
+ get_regions_at (regions, where, tracks_without_relevant_regions);
+ }
}
return regions;
return t;
}
-
void
-Editor::handle_new_route (RouteList& routes)
+Editor::add_routes (RouteList& routes)
{
ENSURE_GUI_THREAD (*this, &Editor::handle_new_route, routes)
if (!_stationary_playhead) {
- if (!_dragging_playhead && _follow_playhead && _session->requested_return_frame() < 0) {
+ if (!_dragging_playhead && _follow_playhead && _session->requested_return_frame() < 0 && !pending_visual_change.being_handled) {
+ /* We only do this if we aren't already
+ handling a visual change (ie if
+ pending_visual_change.being_handled is
+ false) so that these requests don't stack
+ up there are too many of them to handle in
+ time.
+ */
reset_x_origin_to_follow_playhead ();
}
_control_point_context_menu.popup (event->button.button, event->button.time);
}
+void
+Editor::shift_key_released ()
+{
+ _stepping_axis_view = 0;
+}