2007-04-26 16:54:31 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2005-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2005 Karsten Wiese <fzuuzf@googlemail.com>
|
|
|
|
* Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
|
|
|
|
* Copyright (C) 2008-2015 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2014-2015 Colin Fletcher <colin.m.fletcher@googlemail.com>
|
|
|
|
* Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org>
|
|
|
|
* Copyright (C) 2015-2017 Ben Loftis <ben@harrisonconsoles.com>
|
|
|
|
* Copyright (C) 2015-2017 Nick Mainsbridge <mainsbridge@gmail.com>
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2007-04-26 16:54:31 -04:00
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
#include <cstdio> // for snprintf, grrr
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-27 16:17:41 -05:00
|
|
|
#include <gtkmm/stock.h>
|
2011-12-20 21:33:38 -05:00
|
|
|
|
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "tempo_dialog.h"
|
2015-01-02 09:44:54 -05:00
|
|
|
#include "ui_config.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-05-12 13:03:42 -04:00
|
|
|
using namespace std;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Gtk;
|
2005-10-05 09:48:09 -04:00
|
|
|
using namespace Gtkmm2ext;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace ARDOUR;
|
2006-06-21 19:01:03 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
TempoDialog::TempoDialog (TempoMap& map, samplepos_t sample, const string&)
|
2011-12-20 11:29:44 -05:00
|
|
|
: ArdourDialog (_("New Tempo"))
|
2016-03-06 14:35:32 -05:00
|
|
|
, _map (&map)
|
|
|
|
, _section (0)
|
2011-12-20 11:29:44 -05:00
|
|
|
, bpm_adjustment (60.0, 1.0, 999.9, 0.1, 1.0)
|
|
|
|
, bpm_spinner (bpm_adjustment)
|
2017-03-06 11:59:42 -05:00
|
|
|
, end_bpm_adjustment (60.0, 1.0, 999.9, 0.1, 1.0)
|
|
|
|
, end_bpm_spinner (end_bpm_adjustment)
|
|
|
|
, _end_bpm_label (_("End Beats per Minute:"), ALIGN_LEFT, ALIGN_CENTER)
|
2017-01-05 15:50:57 -05:00
|
|
|
, when_bar_label (_("bar:"), ALIGN_RIGHT, ALIGN_CENTER)
|
|
|
|
, when_beat_label (_("beat:"), ALIGN_RIGHT, ALIGN_CENTER)
|
2017-03-06 11:59:42 -05:00
|
|
|
, pulse_selector_label (_("Pulse:"), ALIGN_LEFT, ALIGN_CENTER)
|
2014-02-10 16:14:59 -05:00
|
|
|
, tap_tempo_button (_("Tap tempo"))
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2017-09-18 12:39:17 -04:00
|
|
|
Tempo tempo (map.tempo_at_sample (sample));
|
|
|
|
Timecode::BBT_Time when (map.bbt_at_sample (sample));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2017-03-06 11:59:42 -05:00
|
|
|
init (when, tempo.note_types_per_minute(), tempo.end_note_types_per_minute(), tempo.note_type(), TempoSection::Constant, true, MusicTime);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2016-02-05 14:07:27 -05:00
|
|
|
TempoDialog::TempoDialog (TempoMap& map, TempoSection& section, const string&)
|
2012-07-17 09:11:15 -04:00
|
|
|
: ArdourDialog (_("Edit Tempo"))
|
2016-03-06 14:35:32 -05:00
|
|
|
, _map (&map)
|
|
|
|
, _section (§ion)
|
2011-12-20 11:29:44 -05:00
|
|
|
, bpm_adjustment (60.0, 1.0, 999.9, 0.1, 1.0)
|
|
|
|
, bpm_spinner (bpm_adjustment)
|
2017-03-06 11:59:42 -05:00
|
|
|
, end_bpm_adjustment (60.0, 1.0, 999.9, 0.1, 1.0)
|
|
|
|
, end_bpm_spinner (end_bpm_adjustment)
|
|
|
|
, _end_bpm_label (_("End Beats per Minute:"), ALIGN_LEFT, ALIGN_CENTER)
|
2017-01-05 15:50:57 -05:00
|
|
|
, when_bar_label (_("bar:"), ALIGN_RIGHT, ALIGN_CENTER)
|
|
|
|
, when_beat_label (_("beat:"), ALIGN_RIGHT, ALIGN_CENTER)
|
2017-03-06 11:59:42 -05:00
|
|
|
, pulse_selector_label (_("Pulse:"), ALIGN_LEFT, ALIGN_CENTER)
|
2014-02-10 16:14:59 -05:00
|
|
|
, tap_tempo_button (_("Tap tempo"))
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2017-09-18 12:39:17 -04:00
|
|
|
Timecode::BBT_Time when (map.bbt_at_sample (section.sample()));
|
2017-03-06 11:59:42 -05:00
|
|
|
init (when, section.note_types_per_minute(), section.end_note_types_per_minute(), section.note_type(), section.type()
|
2017-01-05 10:56:01 -05:00
|
|
|
, section.initial() || section.locked_to_meter(), section.position_lock_style());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-03-06 11:59:42 -05:00
|
|
|
TempoDialog::init (const Timecode::BBT_Time& when, double bpm, double end_bpm, double note_type, TempoSection::Type type, bool initial, PositionLockStyle style)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2011-12-20 11:29:44 -05:00
|
|
|
vector<string> strings;
|
|
|
|
NoteTypes::iterator x;
|
|
|
|
|
2007-02-02 15:55:16 -05:00
|
|
|
bpm_spinner.set_numeric (true);
|
2017-02-07 07:31:40 -05:00
|
|
|
bpm_spinner.set_digits (3);
|
2007-02-02 15:55:16 -05:00
|
|
|
bpm_spinner.set_wrap (true);
|
|
|
|
bpm_spinner.set_value (bpm);
|
2015-03-21 09:33:27 -04:00
|
|
|
bpm_spinner.set_alignment (1.0);
|
2007-02-02 15:55:16 -05:00
|
|
|
|
2017-03-06 11:59:42 -05:00
|
|
|
end_bpm_spinner.set_numeric (true);
|
|
|
|
end_bpm_spinner.set_digits (3);
|
|
|
|
end_bpm_spinner.set_wrap (true);
|
|
|
|
end_bpm_spinner.set_value (end_bpm);
|
|
|
|
end_bpm_spinner.set_alignment (1.0);
|
|
|
|
|
|
|
|
Gtkmm2ext::set_size_request_to_display_given_text (pulse_selector, _("one-hundred-twenty-eighth"), 3, 6);
|
|
|
|
|
2011-12-20 11:29:44 -05:00
|
|
|
note_types.insert (make_pair (_("whole"), 1.0));
|
|
|
|
strings.push_back (_("whole"));
|
|
|
|
note_types.insert (make_pair (_("second"), 2.0));
|
|
|
|
strings.push_back (_("second"));
|
|
|
|
note_types.insert (make_pair (_("third"), 3.0));
|
|
|
|
strings.push_back (_("third"));
|
|
|
|
note_types.insert (make_pair (_("quarter"), 4.0));
|
|
|
|
strings.push_back (_("quarter"));
|
|
|
|
note_types.insert (make_pair (_("eighth"), 8.0));
|
|
|
|
strings.push_back (_("eighth"));
|
2012-01-07 10:28:58 -05:00
|
|
|
note_types.insert (make_pair (_("sixteenth"), 16.0));
|
|
|
|
strings.push_back (_("sixteenth"));
|
2011-12-20 11:29:44 -05:00
|
|
|
note_types.insert (make_pair (_("thirty-second"), 32.0));
|
|
|
|
strings.push_back (_("thirty-second"));
|
|
|
|
note_types.insert (make_pair (_("sixty-fourth"), 64.0));
|
|
|
|
strings.push_back (_("sixty-fourth"));
|
|
|
|
note_types.insert (make_pair (_("one-hundred-twenty-eighth"), 128.0));
|
|
|
|
strings.push_back (_("one-hundred-twenty-eighth"));
|
|
|
|
|
|
|
|
set_popdown_strings (pulse_selector, strings);
|
|
|
|
|
|
|
|
for (x = note_types.begin(); x != note_types.end(); ++x) {
|
|
|
|
if (x->second == note_type) {
|
|
|
|
pulse_selector.set_active_text (x->first);
|
2011-12-20 11:56:07 -05:00
|
|
|
break;
|
2011-12-20 11:29:44 -05:00
|
|
|
}
|
2009-08-20 17:21:07 -04:00
|
|
|
}
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2011-12-20 11:29:44 -05:00
|
|
|
if (x == note_types.end()) {
|
|
|
|
pulse_selector.set_active_text (strings[3]); // "quarter"
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-12-19 12:41:45 -05:00
|
|
|
strings.clear();
|
|
|
|
|
2016-02-12 12:23:02 -05:00
|
|
|
tempo_types.insert (make_pair (_("ramped"), TempoSection::Ramp));
|
2015-12-19 12:41:45 -05:00
|
|
|
strings.push_back (_("ramped"));
|
2016-02-12 12:23:02 -05:00
|
|
|
tempo_types.insert (make_pair (_("constant"), TempoSection::Constant));
|
2015-12-19 12:41:45 -05:00
|
|
|
strings.push_back (_("constant"));
|
|
|
|
set_popdown_strings (tempo_type, strings);
|
2016-02-05 14:07:27 -05:00
|
|
|
TempoTypes::iterator tt;
|
|
|
|
for (tt = tempo_types.begin(); tt != tempo_types.end(); ++tt) {
|
|
|
|
if (tt->second == type) {
|
|
|
|
tempo_type.set_active_text (tt->first);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tt == tempo_types.end()) {
|
2016-02-27 12:59:34 -05:00
|
|
|
tempo_type.set_active_text (strings[1]); // "constant"
|
|
|
|
}
|
|
|
|
|
|
|
|
strings.clear();
|
|
|
|
|
2016-04-02 14:09:39 -04:00
|
|
|
lock_styles.insert (make_pair (_("music"), MusicTime));
|
2016-02-27 12:59:34 -05:00
|
|
|
strings.push_back (_("music"));
|
2016-04-02 14:09:39 -04:00
|
|
|
lock_styles.insert (make_pair (_("audio"), AudioTime));
|
2016-02-27 12:59:34 -05:00
|
|
|
strings.push_back (_("audio"));
|
|
|
|
set_popdown_strings (lock_style, strings);
|
|
|
|
LockStyles::iterator ls;
|
|
|
|
for (ls = lock_styles.begin(); ls != lock_styles.end(); ++ls) {
|
|
|
|
if (ls->second == style) {
|
|
|
|
lock_style.set_active_text (ls->first);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ls == lock_styles.end()) {
|
|
|
|
lock_style.set_active_text (strings[0]); // "music"
|
2016-02-05 14:07:27 -05:00
|
|
|
}
|
2015-12-19 12:41:45 -05:00
|
|
|
|
2011-12-20 21:33:38 -05:00
|
|
|
Table* table;
|
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
if (UIConfiguration::instance().get_allow_non_quarter_pulse()) {
|
2016-02-27 12:59:34 -05:00
|
|
|
table = manage (new Table (5, 7));
|
2011-12-20 21:33:38 -05:00
|
|
|
} else {
|
2016-02-27 12:59:34 -05:00
|
|
|
table = manage (new Table (5, 6));
|
2011-12-20 21:33:38 -05:00
|
|
|
}
|
|
|
|
|
2009-08-20 17:21:07 -04:00
|
|
|
table->set_spacings (6);
|
2011-12-20 11:29:44 -05:00
|
|
|
table->set_homogeneous (false);
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2017-03-06 11:59:42 -05:00
|
|
|
int row = 0;
|
2011-12-20 11:29:44 -05:00
|
|
|
|
2015-01-02 09:44:54 -05:00
|
|
|
if (UIConfiguration::instance().get_allow_non_quarter_pulse()) {
|
2017-03-06 11:59:42 -05:00
|
|
|
table->attach (pulse_selector_label, 0, 1, row, row + 1);
|
|
|
|
table->attach (pulse_selector, 1, 5, row, row + 1);
|
2016-12-28 11:44:19 -05:00
|
|
|
|
2017-03-06 11:59:42 -05:00
|
|
|
++row;
|
2011-12-20 21:33:38 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2017-03-06 11:59:42 -05:00
|
|
|
Label* bpm_label = manage (new Label(_("Start Beats per Minute:"), ALIGN_LEFT, ALIGN_CENTER));
|
2016-12-28 11:44:19 -05:00
|
|
|
table->attach (*bpm_label, 0, 1, row, row + 1);
|
|
|
|
table->attach (bpm_spinner, 1, 5, row, row + 1);
|
|
|
|
++row;
|
|
|
|
|
2017-03-06 11:59:42 -05:00
|
|
|
table->attach (_end_bpm_label, 0, 1, row, row + 1);
|
|
|
|
table->attach (end_bpm_spinner, 1, 5, row, row + 1);
|
|
|
|
++row;
|
|
|
|
|
|
|
|
Label* tempo_type_label = manage (new Label(_("Tempo Type:"), ALIGN_LEFT, ALIGN_CENTER));
|
|
|
|
table->attach (*tempo_type_label, 0, 1, row, row + 1);
|
|
|
|
table->attach (tempo_type, 1, 5, row, row + 1);
|
|
|
|
|
|
|
|
++row;
|
|
|
|
|
2014-12-08 13:11:13 -05:00
|
|
|
char buf[64];
|
2011-12-20 11:29:44 -05:00
|
|
|
|
2014-12-08 13:11:13 -05:00
|
|
|
snprintf (buf, sizeof (buf), "%" PRIu32, when.bars);
|
|
|
|
when_bar_entry.set_text (buf);
|
|
|
|
snprintf (buf, sizeof (buf), "%" PRIu32, when.beats);
|
|
|
|
when_beat_entry.set_text (buf);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2016-11-24 09:38:19 -05:00
|
|
|
if (!initial) {
|
2011-12-20 11:29:44 -05:00
|
|
|
when_bar_entry.set_width_chars(4);
|
|
|
|
when_beat_entry.set_width_chars (4);
|
2015-03-21 09:33:27 -04:00
|
|
|
when_bar_entry.set_alignment (1.0);
|
|
|
|
when_beat_entry.set_alignment (1.0);
|
2011-12-20 11:29:44 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
when_bar_label.set_name ("MetricLabel");
|
|
|
|
when_beat_label.set_name ("MetricLabel");
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-12-20 21:33:38 -05:00
|
|
|
table->attach (when_bar_label, 1, 2, row, row+1, Gtk::AttachOptions(0), Gtk::AttachOptions(0));
|
|
|
|
table->attach (when_bar_entry, 2, 3, row, row+1, Gtk::AttachOptions(0), Gtk::AttachOptions(0));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-12-20 21:33:38 -05:00
|
|
|
table->attach (when_beat_label, 3, 4, row, row+1, Gtk::AttachOptions(0), Gtk::AttachOptions(0));
|
|
|
|
table->attach (when_beat_entry, 4, 5, row, row+1, Gtk::AttachOptions(0), Gtk::AttachOptions(0));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-20 17:21:07 -04:00
|
|
|
Label* when_label = manage (new Label(_("Tempo begins at"), ALIGN_LEFT, ALIGN_CENTER));
|
2011-12-20 21:33:38 -05:00
|
|
|
table->attach (*when_label, 0, 1, row, row+1);
|
2016-04-04 13:56:38 -04:00
|
|
|
|
2016-04-04 14:15:55 -04:00
|
|
|
++row;
|
2016-04-04 13:56:38 -04:00
|
|
|
++row;
|
|
|
|
|
2017-03-06 11:59:42 -05:00
|
|
|
Label* lock_style_label = manage (new Label(_("Lock Style:"), ALIGN_LEFT, ALIGN_CENTER));
|
2016-04-04 13:56:38 -04:00
|
|
|
table->attach (*lock_style_label, 0, 1, row, row + 1);
|
2016-04-04 14:15:55 -04:00
|
|
|
table->attach (lock_style, 1, 5, row, row + 1);
|
2016-04-04 13:56:38 -04:00
|
|
|
|
2016-04-04 14:15:55 -04:00
|
|
|
--row;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2016-02-27 12:59:34 -05:00
|
|
|
get_vbox()->set_border_width (12);
|
|
|
|
get_vbox()->pack_end (*table);
|
|
|
|
|
2009-08-20 17:21:07 -04:00
|
|
|
table->show_all ();
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2005-12-08 13:53:43 -05:00
|
|
|
add_button (Stock::CANCEL, RESPONSE_CANCEL);
|
2006-04-24 20:51:30 -04:00
|
|
|
add_button (Stock::APPLY, RESPONSE_ACCEPT);
|
2014-12-07 07:54:05 -05:00
|
|
|
set_response_sensitive (RESPONSE_ACCEPT, true);
|
2006-04-24 20:51:30 -04:00
|
|
|
set_default_response (RESPONSE_ACCEPT);
|
2005-12-08 13:53:43 -05:00
|
|
|
|
2008-02-01 22:57:35 -05:00
|
|
|
bpm_spinner.show ();
|
2017-03-06 11:59:42 -05:00
|
|
|
end_bpm_spinner.show ();
|
2014-02-10 16:14:59 -05:00
|
|
|
tap_tempo_button.show ();
|
2017-01-05 15:50:57 -05:00
|
|
|
get_vbox()->set_spacing (6);
|
2014-02-10 16:14:59 -05:00
|
|
|
get_vbox()->pack_end (tap_tempo_button);
|
2017-05-04 10:12:26 -04:00
|
|
|
tap_tempo_button.can_focus ();
|
|
|
|
tap_tempo_button.grab_focus ();
|
2005-12-08 13:53:43 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
set_name ("MetricDialog");
|
2007-02-02 15:55:16 -05:00
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
bpm_spinner.signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &TempoDialog::response), RESPONSE_ACCEPT));
|
|
|
|
bpm_spinner.signal_button_press_event().connect (sigc::mem_fun (*this, &TempoDialog::bpm_button_press), false);
|
|
|
|
bpm_spinner.signal_button_release_event().connect (sigc::mem_fun (*this, &TempoDialog::bpm_button_release), false);
|
2010-05-02 19:14:43 -04:00
|
|
|
bpm_spinner.signal_changed().connect (sigc::mem_fun (*this, &TempoDialog::bpm_changed));
|
2017-03-06 11:59:42 -05:00
|
|
|
end_bpm_spinner.signal_changed().connect (sigc::mem_fun (*this, &TempoDialog::bpm_changed));
|
2009-12-11 18:29:48 -05:00
|
|
|
when_bar_entry.signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &TempoDialog::response), RESPONSE_ACCEPT));
|
|
|
|
when_bar_entry.signal_key_release_event().connect (sigc::mem_fun (*this, &TempoDialog::entry_key_release), false);
|
|
|
|
when_beat_entry.signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &TempoDialog::response), RESPONSE_ACCEPT));
|
|
|
|
when_beat_entry.signal_key_release_event().connect (sigc::mem_fun (*this, &TempoDialog::entry_key_release), false);
|
2011-12-20 11:29:44 -05:00
|
|
|
pulse_selector.signal_changed().connect (sigc::mem_fun (*this, &TempoDialog::pulse_change));
|
2015-12-20 13:42:38 -05:00
|
|
|
tempo_type.signal_changed().connect (sigc::mem_fun (*this, &TempoDialog::tempo_type_change));
|
2016-02-27 12:59:34 -05:00
|
|
|
lock_style.signal_changed().connect (sigc::mem_fun (*this, &TempoDialog::lock_style_change));
|
2015-03-09 15:19:16 -04:00
|
|
|
tap_tempo_button.signal_button_press_event().connect (sigc::mem_fun (*this, &TempoDialog::tap_tempo_button_press), false);
|
2017-05-04 10:12:26 -04:00
|
|
|
tap_tempo_button.signal_key_press_event().connect (sigc::mem_fun (*this, &TempoDialog::tap_tempo_key_press), false);
|
2015-03-19 15:44:20 -04:00
|
|
|
tap_tempo_button.signal_focus_out_event().connect (sigc::mem_fun (*this, &TempoDialog::tap_tempo_focus_out));
|
|
|
|
|
2017-03-06 11:59:42 -05:00
|
|
|
tempo_type_change();
|
|
|
|
|
2015-03-19 15:44:20 -04:00
|
|
|
tapped = false;
|
2006-04-24 20:51:30 -04:00
|
|
|
}
|
|
|
|
|
2014-12-07 07:54:05 -05:00
|
|
|
bool
|
|
|
|
TempoDialog::is_user_input_valid() const
|
|
|
|
{
|
|
|
|
return (when_beat_entry.get_text() != "")
|
|
|
|
&& (when_bar_entry.get_text() != "")
|
|
|
|
&& (when_bar_entry.get_text() != "0");
|
|
|
|
}
|
|
|
|
|
2010-05-02 19:14:43 -04:00
|
|
|
void
|
|
|
|
TempoDialog::bpm_changed ()
|
|
|
|
{
|
2014-12-07 07:54:05 -05:00
|
|
|
set_response_sensitive (RESPONSE_ACCEPT, is_user_input_valid());
|
2010-05-02 19:14:43 -04:00
|
|
|
}
|
|
|
|
|
2006-04-26 12:04:04 -04:00
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
TempoDialog::bpm_button_press (GdkEventButton*)
|
2006-04-26 12:04:04 -04:00
|
|
|
{
|
2007-02-02 15:55:16 -05:00
|
|
|
return false;
|
2006-04-26 12:04:04 -04:00
|
|
|
}
|
|
|
|
|
2006-04-24 20:51:30 -04:00
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
TempoDialog::bpm_button_release (GdkEventButton*)
|
2009-10-14 12:10:01 -04:00
|
|
|
{
|
2007-02-02 15:55:16 -05:00
|
|
|
/* the value has been modified, accept should work now */
|
|
|
|
|
2014-12-07 07:54:05 -05:00
|
|
|
set_response_sensitive (RESPONSE_ACCEPT, is_user_input_valid());
|
2006-04-24 20:51:30 -04:00
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2008-02-17 12:49:38 -05:00
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
TempoDialog::entry_key_release (GdkEventKey*)
|
2009-10-14 12:10:01 -04:00
|
|
|
{
|
2016-03-06 14:35:32 -05:00
|
|
|
Timecode::BBT_Time bbt;
|
|
|
|
get_bbt_time (bbt);
|
|
|
|
|
|
|
|
if (_section && is_user_input_valid()) {
|
2016-04-01 14:41:16 -04:00
|
|
|
set_response_sensitive (RESPONSE_ACCEPT, _map->can_solve_bbt (_section, bbt));
|
2016-03-06 14:35:32 -05:00
|
|
|
} else {
|
|
|
|
set_response_sensitive (RESPONSE_ACCEPT, is_user_input_valid());
|
|
|
|
}
|
|
|
|
|
2008-02-17 12:49:38 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
double
|
2005-09-25 14:42:24 -04:00
|
|
|
TempoDialog::get_bpm ()
|
|
|
|
{
|
2007-02-02 15:55:16 -05:00
|
|
|
return bpm_spinner.get_value ();
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2017-03-06 11:59:42 -05:00
|
|
|
double
|
|
|
|
TempoDialog::get_end_bpm ()
|
|
|
|
{
|
|
|
|
if (get_tempo_type() == TempoSection::Constant) {
|
|
|
|
return bpm_spinner.get_value ();
|
|
|
|
}
|
|
|
|
|
|
|
|
return end_bpm_spinner.get_value ();
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
bool
|
2010-12-14 13:13:37 -05:00
|
|
|
TempoDialog::get_bbt_time (Timecode::BBT_Time& requested)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (sscanf (when_bar_entry.get_text().c_str(), "%" PRIu32, &requested.bars) != 1) {
|
|
|
|
return false;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (sscanf (when_beat_entry.get_text().c_str(), "%" PRIu32, &requested.beats) != 1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-02-01 22:57:35 -05:00
|
|
|
requested.ticks = 0;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
double
|
|
|
|
TempoDialog::get_note_type ()
|
|
|
|
{
|
2011-12-20 11:29:44 -05:00
|
|
|
NoteTypes::iterator x = note_types.find (pulse_selector.get_active_text());
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-12-20 11:29:44 -05:00
|
|
|
if (x == note_types.end()) {
|
|
|
|
error << string_compose(_("incomprehensible pulse note type (%1)"), pulse_selector.get_active_text()) << endmsg;
|
|
|
|
return 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
|
|
|
|
2011-12-20 11:29:44 -05:00
|
|
|
return x->second;
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
|
|
|
|
2015-12-21 09:21:54 -05:00
|
|
|
TempoSection::Type
|
2015-12-19 12:41:45 -05:00
|
|
|
TempoDialog::get_tempo_type ()
|
|
|
|
{
|
|
|
|
TempoTypes::iterator x = tempo_types.find (tempo_type.get_active_text());
|
|
|
|
|
|
|
|
if (x == tempo_types.end()) {
|
2016-02-05 14:07:27 -05:00
|
|
|
error << string_compose(_("incomprehensible tempo type (%1)"), tempo_type.get_active_text()) << endmsg;
|
2016-02-12 12:23:02 -05:00
|
|
|
return TempoSection::Constant;
|
2015-12-19 12:41:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return x->second;
|
|
|
|
}
|
|
|
|
|
2016-02-27 12:59:34 -05:00
|
|
|
PositionLockStyle
|
|
|
|
TempoDialog::get_lock_style ()
|
|
|
|
{
|
|
|
|
LockStyles::iterator x = lock_styles.find (lock_style.get_active_text());
|
|
|
|
|
|
|
|
if (x == lock_styles.end()) {
|
|
|
|
error << string_compose(_("incomprehensible lock style (%1)"), lock_style.get_active_text()) << endmsg;
|
2016-04-02 14:09:39 -04:00
|
|
|
return MusicTime;
|
2016-02-27 12:59:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return x->second;
|
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
void
|
2011-12-20 11:29:44 -05:00
|
|
|
TempoDialog::pulse_change ()
|
2008-01-10 16:20:59 -05:00
|
|
|
{
|
2014-12-07 07:54:05 -05:00
|
|
|
set_response_sensitive (RESPONSE_ACCEPT, is_user_input_valid());
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
|
|
|
|
2015-12-20 13:42:38 -05:00
|
|
|
void
|
|
|
|
TempoDialog::tempo_type_change ()
|
|
|
|
{
|
2017-03-06 11:59:42 -05:00
|
|
|
if (get_tempo_type() == TempoSection::Constant) {
|
|
|
|
end_bpm_spinner.hide ();
|
|
|
|
_end_bpm_label.hide();
|
|
|
|
} else {
|
|
|
|
end_bpm_spinner.show ();
|
|
|
|
_end_bpm_label.show();
|
|
|
|
}
|
|
|
|
|
2015-12-20 13:42:38 -05:00
|
|
|
set_response_sensitive (RESPONSE_ACCEPT, is_user_input_valid());
|
|
|
|
}
|
|
|
|
|
2016-02-27 12:59:34 -05:00
|
|
|
void
|
|
|
|
TempoDialog::lock_style_change ()
|
|
|
|
{
|
|
|
|
set_response_sensitive (RESPONSE_ACCEPT, is_user_input_valid());
|
|
|
|
}
|
|
|
|
|
2015-03-09 15:19:16 -04:00
|
|
|
bool
|
2017-05-04 10:12:26 -04:00
|
|
|
TempoDialog::tap_tempo_key_press (GdkEventKey*)
|
|
|
|
{
|
|
|
|
tap_tempo ();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TempoDialog::tap_tempo_button_press (GdkEventButton* ev)
|
|
|
|
{
|
|
|
|
if (ev->type == GDK_2BUTTON_PRESS || ev->type == GDK_3BUTTON_PRESS) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (ev->button != 1) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
tap_tempo ();
|
|
|
|
return false; // grab focus
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TempoDialog::tap_tempo ()
|
2014-02-10 16:14:59 -05:00
|
|
|
{
|
2016-01-13 09:04:29 -05:00
|
|
|
double t;
|
2014-02-10 16:14:59 -05:00
|
|
|
|
2016-01-13 09:04:29 -05:00
|
|
|
// Linear least-squares regression
|
2015-03-19 15:44:20 -04:00
|
|
|
if (tapped) {
|
2016-01-13 09:04:29 -05:00
|
|
|
t = 1e-6 * (g_get_monotonic_time () - first_t); // Subtract first_t to avoid precision problems
|
|
|
|
|
|
|
|
double n = tap_count;
|
|
|
|
sum_y += t;
|
|
|
|
sum_x += n;
|
|
|
|
sum_xy += n * t;
|
|
|
|
sum_xx += n * n;
|
|
|
|
double T = (sum_xy/n - sum_x/n * sum_y/n) / (sum_xx/n - sum_x/n * sum_x/n);
|
|
|
|
|
|
|
|
if (t - last_t < T / 1.2 || t - last_t > T * 1.2) {
|
|
|
|
tapped = false;
|
2014-02-12 16:49:00 -05:00
|
|
|
} else {
|
2016-01-13 09:04:29 -05:00
|
|
|
bpm_spinner.set_value (60.0 / T);
|
2014-02-10 16:14:59 -05:00
|
|
|
}
|
2016-01-13 09:04:29 -05:00
|
|
|
}
|
|
|
|
if (!tapped) {
|
|
|
|
first_t = g_get_monotonic_time ();
|
|
|
|
t = 0.0;
|
|
|
|
sum_y = 0.0;
|
|
|
|
sum_x = 1.0;
|
|
|
|
sum_xy = 0.0;
|
|
|
|
sum_xx = 1.0;
|
|
|
|
tap_count = 1.0;
|
|
|
|
|
2015-03-19 15:44:20 -04:00
|
|
|
tapped = true;
|
2014-02-10 16:14:59 -05:00
|
|
|
}
|
2016-01-13 09:04:29 -05:00
|
|
|
tap_count++;
|
|
|
|
last_t = t;
|
2014-02-10 16:14:59 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2015-03-19 15:44:20 -04:00
|
|
|
bool
|
|
|
|
TempoDialog::tap_tempo_focus_out (GdkEventFocus* )
|
|
|
|
{
|
|
|
|
tapped = false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
MeterDialog::MeterDialog (TempoMap& map, samplepos_t sample, const string&)
|
2012-07-17 09:11:15 -04:00
|
|
|
: ArdourDialog (_("New Meter"))
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2017-09-18 12:39:17 -04:00
|
|
|
sample = map.round_to_bar(sample, RoundNearest).sample;
|
|
|
|
Timecode::BBT_Time when (map.bbt_at_sample (sample));
|
|
|
|
Meter meter (map.meter_at_sample (sample));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2016-12-18 12:15:46 -05:00
|
|
|
init (when, meter.divisions_per_bar(), meter.note_divisor(), false, MusicTime);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2016-02-05 14:07:27 -05:00
|
|
|
MeterDialog::MeterDialog (TempoMap& map, MeterSection& section, const string&)
|
2012-07-17 09:11:15 -04:00
|
|
|
: ArdourDialog (_("Edit Meter"))
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2017-09-18 12:39:17 -04:00
|
|
|
Timecode::BBT_Time when (map.bbt_at_sample (section.sample()));
|
2016-05-26 13:22:24 -04:00
|
|
|
|
2016-11-24 09:38:19 -05:00
|
|
|
init (when, section.divisions_per_bar(), section.note_divisor(), section.initial(), section.position_lock_style());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-11-24 09:38:19 -05:00
|
|
|
MeterDialog::init (const Timecode::BBT_Time& when, double bpb, double divisor, bool initial, PositionLockStyle style)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2011-12-20 11:29:44 -05:00
|
|
|
char buf[64];
|
2011-12-20 11:56:07 -05:00
|
|
|
vector<string> strings;
|
|
|
|
NoteTypes::iterator x;
|
2011-12-20 11:29:44 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
snprintf (buf, sizeof (buf), "%.2f", bpb);
|
|
|
|
bpb_entry.set_text (buf);
|
|
|
|
bpb_entry.select_region (0, -1);
|
2015-03-13 12:56:14 -04:00
|
|
|
bpb_entry.set_alignment (1.0);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2011-12-20 11:56:07 -05:00
|
|
|
note_types.insert (make_pair (_("whole"), 1.0));
|
|
|
|
strings.push_back (_("whole"));
|
|
|
|
note_types.insert (make_pair (_("second"), 2.0));
|
|
|
|
strings.push_back (_("second"));
|
|
|
|
note_types.insert (make_pair (_("third"), 3.0));
|
|
|
|
strings.push_back (_("third"));
|
|
|
|
note_types.insert (make_pair (_("quarter"), 4.0));
|
|
|
|
strings.push_back (_("quarter"));
|
|
|
|
note_types.insert (make_pair (_("eighth"), 8.0));
|
|
|
|
strings.push_back (_("eighth"));
|
2012-01-07 10:28:58 -05:00
|
|
|
note_types.insert (make_pair (_("sixteenth"), 16.0));
|
|
|
|
strings.push_back (_("sixteenth"));
|
2011-12-20 11:56:07 -05:00
|
|
|
note_types.insert (make_pair (_("thirty-second"), 32.0));
|
|
|
|
strings.push_back (_("thirty-second"));
|
|
|
|
note_types.insert (make_pair (_("sixty-fourth"), 64.0));
|
|
|
|
strings.push_back (_("sixty-fourth"));
|
|
|
|
note_types.insert (make_pair (_("one-hundred-twenty-eighth"), 128.0));
|
|
|
|
strings.push_back (_("one-hundred-twenty-eighth"));
|
|
|
|
|
|
|
|
set_popdown_strings (note_type, strings);
|
|
|
|
|
|
|
|
for (x = note_types.begin(); x != note_types.end(); ++x) {
|
|
|
|
if (x->second == divisor) {
|
|
|
|
note_type.set_active_text (x->first);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-12-20 11:56:07 -05:00
|
|
|
if (x == note_types.end()) {
|
|
|
|
note_type.set_active_text (strings[3]); // "quarter"
|
2009-08-20 17:21:07 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2016-02-27 12:59:34 -05:00
|
|
|
strings.clear();
|
|
|
|
|
2016-04-02 14:09:39 -04:00
|
|
|
lock_styles.insert (make_pair (_("music"), MusicTime));
|
2016-02-27 12:59:34 -05:00
|
|
|
strings.push_back (_("music"));
|
2016-04-02 14:09:39 -04:00
|
|
|
lock_styles.insert (make_pair (_("audio"), AudioTime));
|
2016-03-01 11:19:21 -05:00
|
|
|
strings.push_back (_("audio"));
|
2016-02-27 12:59:34 -05:00
|
|
|
set_popdown_strings (lock_style, strings);
|
|
|
|
LockStyles::iterator ls;
|
|
|
|
for (ls = lock_styles.begin(); ls != lock_styles.end(); ++ls) {
|
|
|
|
if (ls->second == style) {
|
|
|
|
lock_style.set_active_text (ls->first);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ls == lock_styles.end()) {
|
|
|
|
lock_style.set_active_text (strings[0]); // "music"
|
|
|
|
}
|
|
|
|
|
2017-01-05 15:50:57 -05:00
|
|
|
Label* note_label = manage (new Label (_("Note value:"), ALIGN_RIGHT, ALIGN_CENTER));
|
|
|
|
Label* lock_label = manage (new Label (_("Lock style:"), ALIGN_RIGHT, ALIGN_CENTER));
|
|
|
|
Label* bpb_label = manage (new Label (_("Beats per bar:"), ALIGN_RIGHT, ALIGN_CENTER));
|
2016-02-27 12:59:34 -05:00
|
|
|
Table* table = manage (new Table (3, 3));
|
2009-08-20 17:21:07 -04:00
|
|
|
table->set_spacings (6);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-08-20 17:21:07 -04:00
|
|
|
table->attach (*bpb_label, 0, 1, 0, 1, FILL|EXPAND, FILL|EXPAND);
|
|
|
|
table->attach (bpb_entry, 1, 2, 0, 1, FILL|EXPAND, FILL|EXPAND);
|
|
|
|
table->attach (*note_label, 0, 1, 1, 2, FILL|EXPAND, FILL|EXPAND);
|
2016-02-28 12:54:24 -05:00
|
|
|
table->attach (note_type, 1, 2, 1, 2, FILL|EXPAND, FILL|EXPAND);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2014-12-09 02:00:25 -05:00
|
|
|
snprintf (buf, sizeof (buf), "%" PRIu32, when.bars);
|
|
|
|
when_bar_entry.set_text (buf);
|
2015-03-21 09:33:27 -04:00
|
|
|
when_bar_entry.set_alignment (1.0);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2016-11-24 09:38:19 -05:00
|
|
|
if (!initial) {
|
2009-08-20 17:21:07 -04:00
|
|
|
Label* when_label = manage (new Label(_("Meter begins at bar:"), ALIGN_LEFT, ALIGN_CENTER));
|
2008-02-01 22:57:35 -05:00
|
|
|
|
2009-08-20 17:21:07 -04:00
|
|
|
table->attach (*when_label, 0, 1, 2, 3, FILL | EXPAND, FILL | EXPAND);
|
|
|
|
table->attach (when_bar_entry, 1, 2, 2, 3, FILL | EXPAND, FILL | EXPAND);
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2016-02-28 12:54:24 -05:00
|
|
|
table->attach (*lock_label, 0, 1, 3, 4, FILL|EXPAND, FILL|EXPAND);
|
|
|
|
table->attach (lock_style, 1, 2, 3, 4, FILL|EXPAND, SHRINK);
|
|
|
|
}
|
2016-02-27 12:59:34 -05:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
get_vbox()->set_border_width (12);
|
2009-08-20 17:21:07 -04:00
|
|
|
get_vbox()->pack_start (*table, false, false);
|
2008-02-01 22:57:35 -05:00
|
|
|
|
2005-11-27 16:17:41 -05:00
|
|
|
add_button (Stock::CANCEL, RESPONSE_CANCEL);
|
2006-04-24 20:51:30 -04:00
|
|
|
add_button (Stock::APPLY, RESPONSE_ACCEPT);
|
2014-12-07 07:54:05 -05:00
|
|
|
set_response_sensitive (RESPONSE_ACCEPT, true);
|
2006-04-24 20:51:30 -04:00
|
|
|
set_default_response (RESPONSE_ACCEPT);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-12-08 13:53:43 -05:00
|
|
|
get_vbox()->show_all ();
|
|
|
|
|
2005-11-27 16:17:41 -05:00
|
|
|
set_name ("MetricDialog");
|
2009-12-11 18:29:48 -05:00
|
|
|
bpb_entry.signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &MeterDialog::response), RESPONSE_ACCEPT));
|
|
|
|
bpb_entry.signal_key_press_event().connect (sigc::mem_fun (*this, &MeterDialog::entry_key_press), false);
|
|
|
|
bpb_entry.signal_key_release_event().connect (sigc::mem_fun (*this, &MeterDialog::entry_key_release));
|
|
|
|
when_bar_entry.signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &MeterDialog::response), RESPONSE_ACCEPT));
|
|
|
|
when_bar_entry.signal_key_press_event().connect (sigc::mem_fun (*this, &MeterDialog::entry_key_press), false);
|
|
|
|
when_bar_entry.signal_key_release_event().connect (sigc::mem_fun (*this, &MeterDialog::entry_key_release));
|
2011-12-20 11:56:07 -05:00
|
|
|
note_type.signal_changed().connect (sigc::mem_fun (*this, &MeterDialog::note_type_change));
|
2016-02-27 12:59:34 -05:00
|
|
|
lock_style.signal_changed().connect (sigc::mem_fun (*this, &MeterDialog::lock_style_change));
|
|
|
|
|
2006-04-24 20:51:30 -04:00
|
|
|
}
|
|
|
|
|
2014-12-07 07:54:05 -05:00
|
|
|
bool
|
|
|
|
MeterDialog::is_user_input_valid() const
|
|
|
|
{
|
|
|
|
return (when_bar_entry.get_text() != "")
|
|
|
|
&& (when_bar_entry.get_text() != "0")
|
|
|
|
&& (bpb_entry.get_text() != "");
|
|
|
|
}
|
|
|
|
|
2006-04-26 12:04:04 -04:00
|
|
|
bool
|
2008-02-17 12:49:38 -05:00
|
|
|
MeterDialog::entry_key_press (GdkEventKey* ev)
|
2006-04-26 12:04:04 -04:00
|
|
|
{
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
switch (ev->keyval) {
|
2008-02-01 22:57:35 -05:00
|
|
|
|
|
|
|
case GDK_0:
|
|
|
|
case GDK_1:
|
|
|
|
case GDK_2:
|
|
|
|
case GDK_3:
|
|
|
|
case GDK_4:
|
|
|
|
case GDK_5:
|
|
|
|
case GDK_6:
|
|
|
|
case GDK_7:
|
|
|
|
case GDK_8:
|
|
|
|
case GDK_9:
|
|
|
|
case GDK_KP_0:
|
|
|
|
case GDK_KP_1:
|
|
|
|
case GDK_KP_2:
|
|
|
|
case GDK_KP_3:
|
|
|
|
case GDK_KP_4:
|
|
|
|
case GDK_KP_5:
|
|
|
|
case GDK_KP_6:
|
|
|
|
case GDK_KP_7:
|
|
|
|
case GDK_KP_8:
|
|
|
|
case GDK_KP_9:
|
|
|
|
case GDK_period:
|
|
|
|
case GDK_comma:
|
|
|
|
case GDK_KP_Delete:
|
|
|
|
case GDK_KP_Enter:
|
|
|
|
case GDK_Delete:
|
|
|
|
case GDK_BackSpace:
|
|
|
|
case GDK_Escape:
|
|
|
|
case GDK_Return:
|
|
|
|
case GDK_Home:
|
|
|
|
case GDK_End:
|
|
|
|
case GDK_Left:
|
|
|
|
case GDK_Right:
|
|
|
|
case GDK_Num_Lock:
|
|
|
|
case GDK_Tab:
|
|
|
|
return FALSE;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2006-04-26 12:04:04 -04:00
|
|
|
}
|
|
|
|
|
2006-04-24 20:51:30 -04:00
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
MeterDialog::entry_key_release (GdkEventKey*)
|
2006-04-24 20:51:30 -04:00
|
|
|
{
|
2014-12-07 07:54:05 -05:00
|
|
|
set_response_sensitive (RESPONSE_ACCEPT, is_user_input_valid());
|
2006-04-24 20:51:30 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-12-20 11:56:07 -05:00
|
|
|
MeterDialog::note_type_change ()
|
2006-04-24 20:51:30 -04:00
|
|
|
{
|
2017-07-01 12:42:24 -04:00
|
|
|
set_response_sensitive (RESPONSE_ACCEPT, is_user_input_valid());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2016-02-27 12:59:34 -05:00
|
|
|
void
|
|
|
|
MeterDialog::lock_style_change ()
|
|
|
|
{
|
2017-07-01 12:42:24 -04:00
|
|
|
set_response_sensitive (RESPONSE_ACCEPT, is_user_input_valid());
|
2016-02-27 12:59:34 -05:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
double
|
|
|
|
MeterDialog::get_bpb ()
|
|
|
|
{
|
|
|
|
double bpb = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (sscanf (bpb_entry.get_text().c_str(), "%lf", &bpb) != 1) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bpb;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
double
|
|
|
|
MeterDialog::get_note_type ()
|
|
|
|
{
|
2011-12-20 11:56:07 -05:00
|
|
|
NoteTypes::iterator x = note_types.find (note_type.get_active_text());
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-12-20 11:56:07 -05:00
|
|
|
if (x == note_types.end()) {
|
|
|
|
error << string_compose(_("incomprehensible meter note type (%1)"), note_type.get_active_text()) << endmsg;
|
|
|
|
return 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2011-12-20 11:56:07 -05:00
|
|
|
return x->second;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2016-02-27 12:59:34 -05:00
|
|
|
PositionLockStyle
|
|
|
|
MeterDialog::get_lock_style ()
|
|
|
|
{
|
|
|
|
LockStyles::iterator x = lock_styles.find (lock_style.get_active_text());
|
|
|
|
|
|
|
|
if (x == lock_styles.end()) {
|
|
|
|
error << string_compose(_("incomprehensible meter lock style (%1)"), lock_style.get_active_text()) << endmsg;
|
2016-04-02 14:09:39 -04:00
|
|
|
return MusicTime;
|
2016-02-27 12:59:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return x->second;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
bool
|
2010-12-14 13:13:37 -05:00
|
|
|
MeterDialog::get_bbt_time (Timecode::BBT_Time& requested)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (sscanf (when_bar_entry.get_text().c_str(), "%" PRIu32, &requested.bars) != 1) {
|
|
|
|
return false;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-02-17 12:49:38 -05:00
|
|
|
requested.beats = 1;
|
2008-02-01 22:57:35 -05:00
|
|
|
requested.ticks = 0;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
return true;
|
|
|
|
}
|