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());
}
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)));
_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;
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);
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;
+}