mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
Implement clock delta modes
* use new config variable * update GUI to select delta-modes * delegate delta-calculation to MainClock * save offset to calculate absolute-time
This commit is contained in:
parent
1be2790cac
commit
15150c57c1
10 changed files with 128 additions and 58 deletions
|
|
@ -202,7 +202,7 @@ using namespace Editing;
|
|||
|
||||
ARDOUR_UI *ARDOUR_UI::theArdourUI = 0;
|
||||
|
||||
sigc::signal<void, samplepos_t, bool, samplepos_t> ARDOUR_UI::Clock;
|
||||
sigc::signal<void, samplepos_t> ARDOUR_UI::Clock;
|
||||
sigc::signal<void> ARDOUR_UI::CloseAllDialogs;
|
||||
|
||||
static bool
|
||||
|
|
@ -2704,7 +2704,7 @@ ARDOUR_UI::update_clocks ()
|
|||
if (!_session) return;
|
||||
|
||||
if (editor && !editor->dragging_playhead()) {
|
||||
Clock (_session->audible_sample(), false, editor->get_preferred_edit_position (EDIT_IGNORE_PHEAD)); /* EMIT_SIGNAL */
|
||||
Clock (_session->audible_sample()); /* EMIT_SIGNAL */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5286,16 +5286,34 @@ ARDOUR_UI::use_config ()
|
|||
void
|
||||
ARDOUR_UI::update_transport_clocks (samplepos_t pos)
|
||||
{
|
||||
if (UIConfiguration::instance().get_primary_clock_delta_edit_cursor()) {
|
||||
primary_clock->set (pos, false, editor->get_preferred_edit_position (EDIT_IGNORE_PHEAD));
|
||||
} else {
|
||||
switch (UIConfiguration::instance().get_primary_clock_delta_mode()) {
|
||||
case NoDelta:
|
||||
primary_clock->set (pos);
|
||||
break;
|
||||
case DeltaEditPoint:
|
||||
primary_clock->set (pos, false, editor->get_preferred_edit_position (EDIT_IGNORE_PHEAD));
|
||||
break;
|
||||
case DeltaOriginMarker:
|
||||
{
|
||||
Location* loc = _session->locations()->clock_origin_location ();
|
||||
primary_clock->set (pos, false, loc ? loc->start() : 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (UIConfiguration::instance().get_secondary_clock_delta_edit_cursor()) {
|
||||
secondary_clock->set (pos, false, editor->get_preferred_edit_position (EDIT_IGNORE_PHEAD));
|
||||
} else {
|
||||
switch (UIConfiguration::instance().get_secondary_clock_delta_mode()) {
|
||||
case NoDelta:
|
||||
secondary_clock->set (pos);
|
||||
break;
|
||||
case DeltaEditPoint:
|
||||
secondary_clock->set (pos, false, editor->get_preferred_edit_position (EDIT_IGNORE_PHEAD));
|
||||
break;
|
||||
case DeltaOriginMarker:
|
||||
{
|
||||
Location* loc = _session->locations()->clock_origin_location ();
|
||||
secondary_clock->set (pos, false, loc ? loc->start() : 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (big_clock_window) {
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ public:
|
|||
*
|
||||
* (either RapidScreenUpdate || SuperRapidScreenUpdate - user-config)
|
||||
*/
|
||||
static sigc::signal<void, samplepos_t, bool, samplepos_t> Clock;
|
||||
static sigc::signal<void, samplepos_t> Clock;
|
||||
|
||||
static void close_all_dialogs () { CloseAllDialogs(); }
|
||||
static sigc::signal<void> CloseAllDialogs;
|
||||
|
|
|
|||
|
|
@ -334,8 +334,8 @@ ARDOUR_UI::setup_transport ()
|
|||
monitor_disk_button.set_related_action (act);
|
||||
|
||||
/* connect signals */
|
||||
ARDOUR_UI::Clock.connect (sigc::mem_fun (primary_clock, &AudioClock::set));
|
||||
ARDOUR_UI::Clock.connect (sigc::mem_fun (secondary_clock, &AudioClock::set));
|
||||
ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (primary_clock, &MainClock::set), false, 0));
|
||||
ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (secondary_clock, &MainClock::set), false, 0));
|
||||
|
||||
primary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
|
||||
secondary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));
|
||||
|
|
|
|||
|
|
@ -442,8 +442,8 @@ ARDOUR_UI::parameter_changed (std::string p)
|
|||
|
||||
} else if (p == "show-track-meters") {
|
||||
if (editor) editor->toggle_meter_updating();
|
||||
} else if (p == "primary-clock-delta-edit-cursor") {
|
||||
if (UIConfiguration::instance().get_primary_clock_delta_edit_cursor()) {
|
||||
} else if (p == "primary-clock-delta-mode") {
|
||||
if (UIConfiguration::instance().get_primary_clock_delta_mode() != NoDelta) {
|
||||
primary_clock->set_is_duration (true);
|
||||
primary_clock->set_editable (false);
|
||||
primary_clock->set_widget_name ("transport delta");
|
||||
|
|
@ -452,8 +452,8 @@ ARDOUR_UI::parameter_changed (std::string p)
|
|||
primary_clock->set_editable (true);
|
||||
primary_clock->set_widget_name ("transport");
|
||||
}
|
||||
} else if (p == "secondary-clock-delta-edit-cursor") {
|
||||
if (UIConfiguration::instance().get_secondary_clock_delta_edit_cursor()) {
|
||||
} else if (p == "secondary-clock-delta-mode") {
|
||||
if (UIConfiguration::instance().get_secondary_clock_delta_mode() != NoDelta) {
|
||||
secondary_clock->set_is_duration (true);
|
||||
secondary_clock->set_editable (false);
|
||||
secondary_clock->set_widget_name ("secondary delta");
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string&
|
|||
|
||||
_mode = BBT; /* lie to force mode switch */
|
||||
set_mode (Timecode);
|
||||
set (last_when, true);
|
||||
AudioClock::set (last_when, true);
|
||||
|
||||
if (!is_transient) {
|
||||
clocks.push_back (this);
|
||||
|
|
@ -187,7 +187,7 @@ AudioClock::set_font (Pango::FontDescription font)
|
|||
tmp->get_pixel_size (em_width, ignore_height);
|
||||
|
||||
/* force redraw of markup with new font-size */
|
||||
set (last_when, true);
|
||||
AudioClock::set (last_when, true);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -554,7 +554,7 @@ AudioClock::end_edit (bool modify)
|
|||
break;
|
||||
}
|
||||
|
||||
set (pos, true);
|
||||
AudioClock::set (pos, true);
|
||||
_layout->set_attributes (normal_attributes);
|
||||
ValueChanged(); /* EMIT_SIGNAL */
|
||||
}
|
||||
|
|
@ -781,14 +781,14 @@ AudioClock::end_edit_relative (bool add)
|
|||
|
||||
if (samples != 0) {
|
||||
if (add) {
|
||||
set (current_time() + samples, true);
|
||||
AudioClock::set (current_time() + samples, true);
|
||||
} else {
|
||||
samplepos_t c = current_time();
|
||||
|
||||
if (c > samples || _negative_allowed) {
|
||||
set (c - samples, true);
|
||||
AudioClock::set (c - samples, true);
|
||||
} else {
|
||||
set (0, true);
|
||||
AudioClock::set (0, true);
|
||||
}
|
||||
}
|
||||
ValueChanged (); /* EMIT SIGNAL */
|
||||
|
|
@ -802,7 +802,7 @@ AudioClock::end_edit_relative (bool add)
|
|||
void
|
||||
AudioClock::session_property_changed (const PropertyChange&)
|
||||
{
|
||||
set (last_when, true);
|
||||
AudioClock::set (last_when, true);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -814,7 +814,7 @@ AudioClock::session_configuration_changed (std::string p)
|
|||
}
|
||||
|
||||
if (p == "sync-source" || p == "external-sync") {
|
||||
set (current_time(), true);
|
||||
AudioClock::set (current_time(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -831,7 +831,7 @@ AudioClock::session_configuration_changed (std::string p)
|
|||
} else {
|
||||
current = current_time ();
|
||||
}
|
||||
set (current, true);
|
||||
AudioClock::set (current, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -845,6 +845,7 @@ AudioClock::set (samplepos_t when, bool force, samplecnt_t offset)
|
|||
return;
|
||||
}
|
||||
|
||||
_offset = offset;
|
||||
if (is_duration) {
|
||||
when = when - offset;
|
||||
}
|
||||
|
|
@ -1312,7 +1313,7 @@ AudioClock::set_session (Session *s)
|
|||
}
|
||||
}
|
||||
|
||||
set (last_when, true);
|
||||
AudioClock::set (last_when, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1744,7 +1745,7 @@ AudioClock::on_scroll_event (GdkEventScroll *ev)
|
|||
if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
|
||||
samples *= 10;
|
||||
}
|
||||
set (current_time() + samples, true);
|
||||
AudioClock::set (current_time() + samples, true);
|
||||
ValueChanged (); /* EMIT_SIGNAL */
|
||||
}
|
||||
break;
|
||||
|
|
@ -1757,9 +1758,9 @@ AudioClock::on_scroll_event (GdkEventScroll *ev)
|
|||
}
|
||||
|
||||
if (!_negative_allowed && (double)current_time() - (double)samples < 0.0) {
|
||||
set (0, true);
|
||||
AudioClock::set (0, true);
|
||||
} else {
|
||||
set (current_time() - samples, true);
|
||||
AudioClock::set (current_time() - samples, true);
|
||||
}
|
||||
|
||||
ValueChanged (); /* EMIT_SIGNAL */
|
||||
|
|
@ -1809,9 +1810,9 @@ AudioClock::on_motion_notify_event (GdkEventMotion *ev)
|
|||
samples = get_sample_step (drag_field, pos, dir);
|
||||
|
||||
if (samples != 0 && samples * drag_accum < current_time()) {
|
||||
set ((samplepos_t) floor (pos - drag_accum * samples), false); // minus because up is negative in GTK
|
||||
AudioClock::set ((samplepos_t) floor (pos - drag_accum * samples), false); // minus because up is negative in GTK
|
||||
} else {
|
||||
set (0 , false);
|
||||
AudioClock::set (0 , false);
|
||||
}
|
||||
|
||||
drag_accum= 0;
|
||||
|
|
@ -2154,7 +2155,7 @@ AudioClock::set_from_playhead ()
|
|||
return;
|
||||
}
|
||||
|
||||
set (_session->transport_sample());
|
||||
AudioClock::set (_session->transport_sample());
|
||||
ValueChanged ();
|
||||
}
|
||||
|
||||
|
|
@ -2237,7 +2238,7 @@ AudioClock::set_mode (Mode m, bool noemit)
|
|||
break;
|
||||
}
|
||||
|
||||
set (last_when, true);
|
||||
AudioClock::set (last_when, true);
|
||||
|
||||
if (!is_transient && !noemit) {
|
||||
ModeChanged (); /* EMIT SIGNAL (the static one)*/
|
||||
|
|
@ -2279,7 +2280,7 @@ AudioClock::set_is_duration (bool yn)
|
|||
}
|
||||
|
||||
is_duration = yn;
|
||||
set (last_when, true);
|
||||
AudioClock::set (last_when, true);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -2295,7 +2296,7 @@ AudioClock::set_off (bool yn)
|
|||
* change
|
||||
*/
|
||||
|
||||
set (last_when, true);
|
||||
AudioClock::set (last_when, true);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
|
|||
|
||||
void focus ();
|
||||
|
||||
void set (samplepos_t, bool force = false, ARDOUR::samplecnt_t offset = 0);
|
||||
virtual void set (samplepos_t, bool force = false, ARDOUR::samplecnt_t offset = 0);
|
||||
void set_from_playhead ();
|
||||
void locate ();
|
||||
void set_mode (Mode, bool noemit = false);
|
||||
|
|
@ -105,7 +105,8 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
|
|||
|
||||
protected:
|
||||
void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
|
||||
bool get_is_duration () const { return is_duration; } ;
|
||||
bool get_is_duration () const { return is_duration; }
|
||||
ARDOUR::samplecnt_t offset () const { return _offset; }
|
||||
|
||||
virtual void build_ops_menu ();
|
||||
Gtk::Menu *ops_menu;
|
||||
|
|
@ -133,6 +134,8 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
|
|||
|
||||
samplepos_t _limit_pos;
|
||||
|
||||
ARDOUR::samplecnt_t _offset;
|
||||
|
||||
Glib::RefPtr<Pango::Layout> _layout;
|
||||
|
||||
bool _with_info;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ BigClockWindow::BigClockWindow (AudioClock& c)
|
|||
: ArdourWindow (_("Big Clock"))
|
||||
, clock (c)
|
||||
{
|
||||
ARDOUR_UI::Clock.connect (sigc::mem_fun (clock, &AudioClock::set));
|
||||
ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (clock, &AudioClock::set), false, 0));
|
||||
|
||||
clock.set_corner_radius (0.0);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "pbd/unwind.h"
|
||||
#include "ardour/tempo.h"
|
||||
|
||||
#include "actions.h"
|
||||
|
|
@ -27,6 +28,7 @@
|
|||
#include "pbd/i18n.h"
|
||||
|
||||
using namespace Gtk;
|
||||
using namespace ARDOUR;
|
||||
|
||||
MainClock::MainClock (
|
||||
const std::string& clock_name,
|
||||
|
|
@ -35,6 +37,7 @@ MainClock::MainClock (
|
|||
)
|
||||
: AudioClock (clock_name, false, widget_name, true, true, false, true)
|
||||
, _primary (primary)
|
||||
, _suspend_delta_mode_signal (false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -55,21 +58,33 @@ MainClock::build_ops_menu ()
|
|||
|
||||
MenuList& ops_items = ops_menu->items();
|
||||
ops_items.push_back (SeparatorElem ());
|
||||
ops_items.push_back (CheckMenuElem (_("Display delta to edit cursor"), sigc::mem_fun (*this, &MainClock::display_delta_to_edit_cursor)));
|
||||
Gtk::CheckMenuItem* c = dynamic_cast<Gtk::CheckMenuItem *> (&ops_items.back());
|
||||
RadioMenuItem::Group group;
|
||||
PBD::Unwinder<bool> uw (_suspend_delta_mode_signal, true);
|
||||
ClockDeltaMode mode;
|
||||
if (_primary) {
|
||||
if (UIConfiguration::instance().get_primary_clock_delta_edit_cursor ()) {
|
||||
UIConfiguration::instance().set_primary_clock_delta_edit_cursor (false);
|
||||
c->set_active (true);
|
||||
}
|
||||
mode = UIConfiguration::instance().get_primary_clock_delta_mode ();
|
||||
} else {
|
||||
if (UIConfiguration::instance().get_secondary_clock_delta_edit_cursor ()) {
|
||||
UIConfiguration::instance().set_secondary_clock_delta_edit_cursor (false);
|
||||
c->set_active (true);
|
||||
mode = UIConfiguration::instance().get_secondary_clock_delta_mode ();
|
||||
}
|
||||
|
||||
ops_items.push_back (RadioMenuElem (group, _("Display absolute time"), sigc::bind (sigc::mem_fun (*this, &MainClock::set_display_delta_mode), NoDelta)));
|
||||
if (mode == NoDelta) {
|
||||
RadioMenuItem* i = dynamic_cast<RadioMenuItem *> (&ops_items.back ());
|
||||
i->set_active (true);
|
||||
}
|
||||
ops_items.push_back (RadioMenuElem (group, _("Display delta to edit cursor"), sigc::bind (sigc::mem_fun (*this, &MainClock::set_display_delta_mode), DeltaEditPoint)));
|
||||
if (mode == DeltaEditPoint) {
|
||||
RadioMenuItem* i = dynamic_cast<RadioMenuItem *> (&ops_items.back ());
|
||||
i->set_active (true);
|
||||
}
|
||||
ops_items.push_back (RadioMenuElem (group, _("Display delta to origin marker"), sigc::bind (sigc::mem_fun (*this, &MainClock::set_display_delta_mode), DeltaOriginMarker)));
|
||||
if (mode == DeltaOriginMarker) {
|
||||
RadioMenuItem* i = dynamic_cast<RadioMenuItem *> (&ops_items.back ());
|
||||
i->set_active (true);
|
||||
}
|
||||
|
||||
ops_items.push_back (SeparatorElem());
|
||||
|
||||
ops_items.push_back (MenuElem (_("Edit Tempo"), sigc::mem_fun(*this, &MainClock::edit_current_tempo)));
|
||||
ops_items.push_back (MenuElem (_("Edit Meter"), sigc::mem_fun(*this, &MainClock::edit_current_meter)));
|
||||
ops_items.push_back (MenuElem (_("Insert Tempo Change"), sigc::mem_fun(*this, &MainClock::insert_new_tempo)));
|
||||
|
|
@ -80,20 +95,51 @@ samplepos_t
|
|||
MainClock::absolute_time () const
|
||||
{
|
||||
if (get_is_duration ()) {
|
||||
// delta to edit cursor
|
||||
return current_time () + PublicEditor::instance().get_preferred_edit_position (Editing::EDIT_IGNORE_PHEAD);
|
||||
return current_time () + offset ();
|
||||
} else {
|
||||
return current_time ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MainClock::display_delta_to_edit_cursor ()
|
||||
MainClock::set (samplepos_t when, bool force, ARDOUR::samplecnt_t /*offset*/)
|
||||
{
|
||||
ClockDeltaMode mode;
|
||||
if (_primary) {
|
||||
UIConfiguration::instance().set_primary_clock_delta_edit_cursor (!UIConfiguration::instance().get_primary_clock_delta_edit_cursor ());
|
||||
mode = UIConfiguration::instance().get_primary_clock_delta_mode ();
|
||||
} else {
|
||||
UIConfiguration::instance().set_secondary_clock_delta_edit_cursor (!UIConfiguration::instance().get_secondary_clock_delta_edit_cursor ());
|
||||
mode = UIConfiguration::instance().get_secondary_clock_delta_mode ();
|
||||
}
|
||||
if (!PublicEditor::instance().session()) {
|
||||
mode = NoDelta;
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case NoDelta:
|
||||
AudioClock::set (when, force, 0);
|
||||
break;
|
||||
case DeltaEditPoint:
|
||||
AudioClock::set (when, force, PublicEditor::instance().get_preferred_edit_position (Editing::EDIT_IGNORE_PHEAD));
|
||||
break;
|
||||
case DeltaOriginMarker:
|
||||
{
|
||||
Location* loc = PublicEditor::instance().session()->locations()->clock_origin_location ();
|
||||
AudioClock::set (when, force, loc ? loc->start() : 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MainClock::set_display_delta_mode (ClockDeltaMode m)
|
||||
{
|
||||
if (_suspend_delta_mode_signal) {
|
||||
return;
|
||||
}
|
||||
if (_primary) {
|
||||
UIConfiguration::instance().set_primary_clock_delta_mode (m);
|
||||
} else {
|
||||
UIConfiguration::instance().set_secondary_clock_delta_mode (m);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,18 +31,20 @@ public:
|
|||
MainClock (const std::string& clock_name, const std::string& widget_name, bool primary);
|
||||
samplepos_t absolute_time () const;
|
||||
void set_session (ARDOUR::Session *s);
|
||||
void set (samplepos_t, bool force = false, ARDOUR::samplecnt_t offset = 0);
|
||||
|
||||
private:
|
||||
|
||||
// Editor *_editor;
|
||||
|
||||
void build_ops_menu ();
|
||||
void display_delta_to_edit_cursor ();
|
||||
void set_display_delta_mode (ARDOUR::ClockDeltaMode);
|
||||
void edit_current_tempo ();
|
||||
void edit_current_meter ();
|
||||
void insert_new_tempo ();
|
||||
void insert_new_meter ();
|
||||
bool _primary;
|
||||
bool _suspend_delta_mode_signal;
|
||||
};
|
||||
|
||||
#endif // __gtk_ardour_main_clock_h__
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ UI_CONFIG_VARIABLE (std::string, mixer_strip_visibility, "mixer-element-visibili
|
|||
UI_CONFIG_VARIABLE (bool, allow_non_quarter_pulse, "allow-non-quarter-pulse", false)
|
||||
UI_CONFIG_VARIABLE (bool, show_region_gain, "show-region-gain", false)
|
||||
UI_CONFIG_VARIABLE (bool, show_name_highlight, "show-name-highlight", false)
|
||||
UI_CONFIG_VARIABLE (bool, primary_clock_delta_edit_cursor, "primary-clock-delta-edit-cursor", false)
|
||||
UI_CONFIG_VARIABLE (bool, secondary_clock_delta_edit_cursor, "secondary-clock-delta-edit-cursor", false)
|
||||
UI_CONFIG_VARIABLE (ARDOUR::ClockDeltaMode, primary_clock_delta_mode, "primary-clock-delta-mode", NoDelta)
|
||||
UI_CONFIG_VARIABLE (ARDOUR::ClockDeltaMode, secondary_clock_delta_mode, "secondary-clock-delta-mode", NoDelta)
|
||||
UI_CONFIG_VARIABLE (uint64_t, clock_display_limit, "clock-display-limit", 2592000) /* seconds; default 30days (720h), 0 = unlimited */
|
||||
UI_CONFIG_VARIABLE (bool, show_track_meters, "show-track-meters", true)
|
||||
UI_CONFIG_VARIABLE (bool, editor_stereo_only_meters, "editor-stereo-only-meters", false)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue