2011-06-03 22:18:47 +00:00
|
|
|
/*
|
|
|
|
|
Copyright (C) 2011 Paul Davis
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2011-06-08 13:44:18 +00:00
|
|
|
#include <algorithm>
|
2011-06-03 22:18:47 +00:00
|
|
|
#include "pbd/compose.h"
|
|
|
|
|
|
|
|
|
|
#include "gtkmm2ext/cairocell.h"
|
|
|
|
|
#include "gtkmm2ext/gui_thread.h"
|
|
|
|
|
#include "gtkmm2ext/utils.h"
|
2011-06-08 19:48:57 +00:00
|
|
|
#include "gtkmm2ext/stateful_button.h"
|
|
|
|
|
#include "gtkmm2ext/actions.h"
|
2011-06-03 22:18:47 +00:00
|
|
|
|
|
|
|
|
#include "ardour/location.h"
|
2014-04-18 04:21:54 -05:00
|
|
|
#include "ardour/profile.h"
|
2011-06-03 22:18:47 +00:00
|
|
|
#include "ardour/session.h"
|
|
|
|
|
|
|
|
|
|
#include "audio_clock.h"
|
2014-08-12 23:21:11 +03:00
|
|
|
#include "time_info_box.h"
|
2011-06-03 22:18:47 +00:00
|
|
|
#include "editor.h"
|
2012-04-22 14:03:07 +00:00
|
|
|
#include "control_point.h"
|
|
|
|
|
#include "automation_line.h"
|
2011-06-03 22:18:47 +00:00
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
|
|
using namespace Gtk;
|
|
|
|
|
using namespace ARDOUR;
|
2011-06-08 13:44:18 +00:00
|
|
|
using std::min;
|
|
|
|
|
using std::max;
|
2011-06-03 22:18:47 +00:00
|
|
|
|
|
|
|
|
TimeInfoBox::TimeInfoBox ()
|
2014-08-12 23:21:11 +03:00
|
|
|
: Gtk::VBox ()
|
|
|
|
|
, WavesUI ("time_info_box.xml", *this)
|
2011-06-07 17:40:05 +00:00
|
|
|
, syncing_selection (false)
|
|
|
|
|
, syncing_punch (false)
|
2014-08-12 23:21:11 +03:00
|
|
|
, selection_start ("selection-start", false, "selection", false, false, false, false)
|
|
|
|
|
, selection_end ("selection-end", false, "selection", false, false, false, false)
|
|
|
|
|
, selection_length ("selection-length", false, "selection", false, false, true, false)
|
|
|
|
|
, punch_start ("punch-start", false, "punch", false, false, false, false)
|
|
|
|
|
, punch_end ("punch-end", false, "punch", false, false, false, false)
|
2011-06-03 22:18:47 +00:00
|
|
|
{
|
2014-08-12 23:21:11 +03:00
|
|
|
set_attributes (*this, *xml_tree ()->root (), XMLNodeMap ());
|
|
|
|
|
get_box ("selection_start_home").pack_start (selection_start, false, false);
|
|
|
|
|
get_box ("selection_end_home").pack_start (selection_end, false, false);
|
|
|
|
|
get_box ("selection_length_home").pack_start (selection_length, false, false);
|
|
|
|
|
get_box ("punch_start_home").pack_start (punch_start, false, false);
|
|
|
|
|
get_box ("punch_end_home").pack_start (punch_end, false, false);
|
|
|
|
|
|
|
|
|
|
selection_start.set_draw_background (false);
|
|
|
|
|
selection_start.set_visible_window (false);
|
|
|
|
|
selection_end.set_draw_background (false);
|
|
|
|
|
selection_end.set_visible_window (false);
|
|
|
|
|
selection_length.set_draw_background (false);
|
|
|
|
|
selection_length.set_visible_window (false);
|
|
|
|
|
punch_start.set_draw_background (false);
|
|
|
|
|
punch_end.set_draw_background (false);
|
|
|
|
|
|
|
|
|
|
//left.set_homogeneous (false);
|
|
|
|
|
//left.set_spacings (0);
|
|
|
|
|
//left.set_border_width (2);
|
|
|
|
|
//left.set_col_spacings (2);
|
|
|
|
|
|
|
|
|
|
//right.set_homogeneous (false);
|
|
|
|
|
//right.set_spacings (0);
|
|
|
|
|
//right.set_border_width (2);
|
|
|
|
|
//right.set_col_spacings (2);
|
|
|
|
|
|
|
|
|
|
//left.attach (*selection_start, 1, 2, 1, 2);
|
|
|
|
|
|
|
|
|
|
//left.attach (*l, 0, 1, 2, 3, FILL);
|
|
|
|
|
//left.attach (*selection_end, 1, 2, 2, 3);
|
|
|
|
|
|
|
|
|
|
//left.attach (*l, 0, 1, 3, 4, FILL);
|
|
|
|
|
//left.attach (*selection_length, 1, 2, 3, 4);
|
|
|
|
|
|
|
|
|
|
//punch_in_button.set_name ("punch button");
|
|
|
|
|
//punch_out_button.set_name ("punch button");
|
|
|
|
|
//punch_in_button.set_text (_("In"));
|
|
|
|
|
//punch_out_button.set_text (_("Out"));
|
|
|
|
|
|
|
|
|
|
//Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "TogglePunchIn");
|
|
|
|
|
//punch_in_button.set_related_action (act);
|
|
|
|
|
//act = ActionManager::get_action ("Transport", "TogglePunchOut");
|
|
|
|
|
//punch_out_button.set_related_action (act);
|
|
|
|
|
|
|
|
|
|
//Gtkmm2ext::UI::instance()->set_tip (punch_in_button, _("Start recording at auto-punch start"));
|
|
|
|
|
//Gtkmm2ext::UI::instance()->set_tip (punch_out_button, _("Stop recording at auto-punch end"));
|
|
|
|
|
|
|
|
|
|
//right.attach (punch_in_button, 2, 3, 1, 2, FILL, SHRINK);
|
|
|
|
|
//right.attach (*punch_start, 3, 4, 1, 2);
|
|
|
|
|
//right.attach (punch_out_button, 2, 3, 2, 3, FILL, SHRINK);
|
|
|
|
|
//right.attach (*punch_end, 3, 4, 2, 3);
|
2011-06-08 19:48:57 +00:00
|
|
|
|
2011-06-03 22:18:47 +00:00
|
|
|
show_all ();
|
|
|
|
|
|
2014-08-12 23:21:11 +03:00
|
|
|
selection_start.mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::sync_selection_mode), &selection_start));
|
|
|
|
|
selection_end.mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::sync_selection_mode), &selection_end));
|
|
|
|
|
selection_length.mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::sync_selection_mode), &selection_length));
|
2011-06-07 17:40:05 +00:00
|
|
|
|
2014-08-12 23:21:11 +03:00
|
|
|
punch_start.mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::sync_punch_mode), &punch_start));
|
|
|
|
|
punch_end.mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::sync_punch_mode), &punch_end));
|
2011-06-07 17:40:05 +00:00
|
|
|
|
2014-08-12 23:21:11 +03:00
|
|
|
selection_start.signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), &selection_start), true);
|
|
|
|
|
selection_end.signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), &selection_end), true);
|
2011-06-07 18:20:22 +00:00
|
|
|
|
2014-08-12 23:21:11 +03:00
|
|
|
punch_start.signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), &punch_start), true);
|
|
|
|
|
punch_end.signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), &punch_end), true);
|
2011-06-07 18:20:22 +00:00
|
|
|
|
2011-06-03 22:18:47 +00:00
|
|
|
Editor::instance().get_selection().TimeChanged.connect (sigc::mem_fun (*this, &TimeInfoBox::selection_changed));
|
2011-06-07 23:07:08 +00:00
|
|
|
Editor::instance().get_selection().RegionsChanged.connect (sigc::mem_fun (*this, &TimeInfoBox::selection_changed));
|
|
|
|
|
|
2012-04-25 12:58:19 +00:00
|
|
|
Editor::instance().MouseModeChanged.connect (editor_connections, invalidator(*this), boost::bind (&TimeInfoBox::track_mouse_mode, this), gui_context());
|
2011-06-03 22:18:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TimeInfoBox::~TimeInfoBox ()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-07 23:07:08 +00:00
|
|
|
void
|
|
|
|
|
TimeInfoBox::track_mouse_mode ()
|
|
|
|
|
{
|
|
|
|
|
selection_changed ();
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-07 18:20:22 +00:00
|
|
|
bool
|
|
|
|
|
TimeInfoBox::clock_button_release_event (GdkEventButton* ev, AudioClock* src)
|
|
|
|
|
{
|
|
|
|
|
if (!_session) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ev->button == 1) {
|
2011-11-20 16:38:51 +00:00
|
|
|
if (!src->off()) {
|
|
|
|
|
_session->request_locate (src->current_time ());
|
|
|
|
|
}
|
2011-06-07 18:20:22 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-07 17:40:05 +00:00
|
|
|
void
|
|
|
|
|
TimeInfoBox::sync_selection_mode (AudioClock* src)
|
|
|
|
|
{
|
|
|
|
|
if (!syncing_selection) {
|
|
|
|
|
syncing_selection = true;
|
2014-08-12 23:21:11 +03:00
|
|
|
selection_start.set_mode (src->mode());
|
|
|
|
|
selection_end.set_mode (src->mode());
|
|
|
|
|
selection_length.set_mode (src->mode());
|
2011-06-07 17:40:05 +00:00
|
|
|
syncing_selection = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
TimeInfoBox::sync_punch_mode (AudioClock* src)
|
|
|
|
|
{
|
|
|
|
|
if (!syncing_punch) {
|
|
|
|
|
syncing_punch = true;
|
2014-08-12 23:21:11 +03:00
|
|
|
punch_start.set_mode (src->mode());
|
|
|
|
|
punch_end.set_mode (src->mode());
|
2011-06-07 17:40:05 +00:00
|
|
|
syncing_punch = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-06-03 22:18:47 +00:00
|
|
|
void
|
|
|
|
|
TimeInfoBox::set_session (Session* s)
|
|
|
|
|
{
|
|
|
|
|
SessionHandlePtr::set_session (s);
|
|
|
|
|
|
2014-08-12 23:21:11 +03:00
|
|
|
selection_start.set_session (s);
|
|
|
|
|
selection_end.set_session (s);
|
|
|
|
|
selection_length.set_session (s);
|
2011-06-03 22:18:47 +00:00
|
|
|
|
2014-08-12 23:21:11 +03:00
|
|
|
punch_start.set_session (s);
|
|
|
|
|
punch_end.set_session (s);
|
2011-06-03 22:18:47 +00:00
|
|
|
|
|
|
|
|
if (s) {
|
|
|
|
|
Location* punch = s->locations()->auto_punch_location ();
|
|
|
|
|
|
|
|
|
|
if (punch) {
|
|
|
|
|
watch_punch (punch);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-08 17:27:26 +00:00
|
|
|
punch_changed (punch);
|
|
|
|
|
|
2011-06-03 22:18:47 +00:00
|
|
|
_session->auto_punch_location_changed.connect (_session_connections, MISSING_INVALIDATOR,
|
|
|
|
|
boost::bind (&TimeInfoBox::punch_location_changed, this, _1), gui_context());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
TimeInfoBox::selection_changed ()
|
|
|
|
|
{
|
2011-06-07 23:07:08 +00:00
|
|
|
framepos_t s, e;
|
2011-06-08 13:22:40 +00:00
|
|
|
Selection& selection (Editor::instance().get_selection());
|
2011-06-07 23:07:08 +00:00
|
|
|
|
|
|
|
|
switch (Editor::instance().current_mouse_mode()) {
|
2011-06-08 13:44:18 +00:00
|
|
|
|
2011-06-07 23:07:08 +00:00
|
|
|
case Editing::MouseObject:
|
2011-06-08 13:44:18 +00:00
|
|
|
if (Editor::instance().internal_editing()) {
|
|
|
|
|
/* displaying MIDI note selection is tricky */
|
|
|
|
|
|
2014-08-12 23:21:11 +03:00
|
|
|
selection_start.set_off (true);
|
|
|
|
|
selection_end.set_off (true);
|
|
|
|
|
selection_length.set_off (true);
|
2011-06-08 13:44:18 +00:00
|
|
|
|
2011-06-08 13:22:40 +00:00
|
|
|
} else {
|
2011-06-08 13:44:18 +00:00
|
|
|
if (selection.regions.empty()) {
|
|
|
|
|
if (selection.points.empty()) {
|
2012-01-27 19:05:03 +00:00
|
|
|
Glib::RefPtr<Action> act = ActionManager::get_action ("MouseMode", "set-mouse-mode-object-range");
|
|
|
|
|
Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
|
|
|
|
|
|
|
|
|
|
if (tact && tact->get_active() && !selection.time.empty()) {
|
|
|
|
|
/* show selected range */
|
2014-08-12 23:21:11 +03:00
|
|
|
selection_start.set_off (false);
|
|
|
|
|
selection_end.set_off (false);
|
|
|
|
|
selection_length.set_off (false);
|
|
|
|
|
selection_start.set (selection.time.start());
|
|
|
|
|
selection_end.set (selection.time.end_frame());
|
|
|
|
|
selection_length.set (selection.time.length());
|
2012-01-27 19:05:03 +00:00
|
|
|
} else {
|
2014-08-12 23:21:11 +03:00
|
|
|
selection_start.set_off (true);
|
|
|
|
|
selection_end.set_off (true);
|
|
|
|
|
selection_length.set_off (true);
|
2012-01-27 19:05:03 +00:00
|
|
|
}
|
2011-06-08 13:44:18 +00:00
|
|
|
} else {
|
|
|
|
|
s = max_framepos;
|
|
|
|
|
e = 0;
|
|
|
|
|
for (PointSelection::iterator i = selection.points.begin(); i != selection.points.end(); ++i) {
|
2012-04-22 14:03:07 +00:00
|
|
|
framepos_t const p = (*i)->line().session_position ((*i)->model ());
|
|
|
|
|
s = min (s, p);
|
|
|
|
|
e = max (e, p);
|
2011-06-08 13:44:18 +00:00
|
|
|
}
|
2014-08-12 23:21:11 +03:00
|
|
|
selection_start.set_off (false);
|
|
|
|
|
selection_end.set_off (false);
|
|
|
|
|
selection_length.set_off (false);
|
|
|
|
|
selection_start.set (s);
|
|
|
|
|
selection_end.set (e);
|
|
|
|
|
selection_length.set (e - s + 1);
|
2011-06-08 13:44:18 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
s = selection.regions.start();
|
|
|
|
|
e = selection.regions.end_frame();
|
2014-08-12 23:21:11 +03:00
|
|
|
selection_start.set_off (false);
|
|
|
|
|
selection_end.set_off (false);
|
|
|
|
|
selection_length.set_off (false);
|
|
|
|
|
selection_start.set (s);
|
|
|
|
|
selection_end.set (e);
|
|
|
|
|
selection_length.set (e - s + 1);
|
2011-06-08 13:44:18 +00:00
|
|
|
}
|
2011-06-08 13:22:40 +00:00
|
|
|
}
|
2011-06-07 23:07:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Editing::MouseRange:
|
2011-06-08 13:22:40 +00:00
|
|
|
if (selection.time.empty()) {
|
2012-01-27 19:05:03 +00:00
|
|
|
Glib::RefPtr<Action> act = ActionManager::get_action ("MouseMode", "set-mouse-mode-object-range");
|
|
|
|
|
Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
|
|
|
|
|
|
|
|
|
|
if (tact && tact->get_active() && !selection.regions.empty()) {
|
|
|
|
|
/* show selected regions */
|
|
|
|
|
s = selection.regions.start();
|
|
|
|
|
e = selection.regions.end_frame();
|
2014-08-12 23:21:11 +03:00
|
|
|
selection_start.set_off (false);
|
|
|
|
|
selection_end.set_off (false);
|
|
|
|
|
selection_length.set_off (false);
|
|
|
|
|
selection_start.set (s);
|
|
|
|
|
selection_end.set (e);
|
|
|
|
|
selection_length.set (e - s + 1);
|
2012-01-27 19:05:03 +00:00
|
|
|
} else {
|
2014-08-12 23:21:11 +03:00
|
|
|
selection_start.set_off (true);
|
|
|
|
|
selection_end.set_off (true);
|
|
|
|
|
selection_length.set_off (true);
|
2012-01-27 19:05:03 +00:00
|
|
|
}
|
2011-06-08 13:22:40 +00:00
|
|
|
} else {
|
2014-08-12 23:21:11 +03:00
|
|
|
selection_start.set_off (false);
|
|
|
|
|
selection_end.set_off (false);
|
|
|
|
|
selection_length.set_off (false);
|
|
|
|
|
selection_start.set (selection.time.start());
|
|
|
|
|
selection_end.set (selection.time.end_frame());
|
|
|
|
|
selection_length.set (selection.time.length());
|
2011-06-08 13:22:40 +00:00
|
|
|
}
|
2011-06-07 23:07:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2014-08-12 23:21:11 +03:00
|
|
|
selection_start.set_off (true);
|
|
|
|
|
selection_end.set_off (true);
|
|
|
|
|
selection_length.set_off (true);
|
2011-06-07 23:07:08 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2011-06-03 22:18:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
TimeInfoBox::punch_location_changed (Location* loc)
|
|
|
|
|
{
|
|
|
|
|
if (loc) {
|
|
|
|
|
watch_punch (loc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
TimeInfoBox::watch_punch (Location* punch)
|
|
|
|
|
{
|
|
|
|
|
punch_connections.drop_connections ();
|
|
|
|
|
|
|
|
|
|
punch->start_changed.connect (punch_connections, MISSING_INVALIDATOR, boost::bind (&TimeInfoBox::punch_changed, this, _1), gui_context());
|
|
|
|
|
punch->end_changed.connect (punch_connections, MISSING_INVALIDATOR, boost::bind (&TimeInfoBox::punch_changed, this, _1), gui_context());
|
|
|
|
|
|
|
|
|
|
punch_changed (punch);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
TimeInfoBox::punch_changed (Location* loc)
|
|
|
|
|
{
|
|
|
|
|
if (!loc) {
|
2014-08-12 23:21:11 +03:00
|
|
|
punch_start.set_off (true);
|
|
|
|
|
punch_end.set_off (true);
|
2011-06-03 22:18:47 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-12 23:21:11 +03:00
|
|
|
punch_start.set_off (false);
|
|
|
|
|
punch_end.set_off (false);
|
2011-06-08 17:27:26 +00:00
|
|
|
|
2014-08-12 23:21:11 +03:00
|
|
|
punch_start.set (loc->start());
|
|
|
|
|
punch_end.set (loc->end());
|
2011-06-03 22:18:47 +00:00
|
|
|
}
|
|
|
|
|
|