From 8fbf2c3f5288bf6aa864edbdbf8711443e71fd47 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 7 Apr 2023 15:59:55 -0600 Subject: [PATCH] add enum and member var for controlling what kind of tempo editing we are doing note: this was much harder than it ought to be --- gtk2_ardour/editing.cc | 10 ++++++++++ gtk2_ardour/editing.h | 13 +++++++++++++ gtk2_ardour/editing_convert.h | 1 + gtk2_ardour/editing_syms.h | 3 +++ gtk2_ardour/editor.cc | 1 + gtk2_ardour/editor.h | 5 +++++ gtk2_ardour/editor_tempodisplay.cc | 6 ++++++ gtk2_ardour/enums.cc | 5 +++++ gtk2_ardour/ui_config.cc | 1 + gtk2_ardour/ui_config.h | 1 + gtk2_ardour/ui_config_vars.h | 1 + 11 files changed, 47 insertions(+) diff --git a/gtk2_ardour/editing.cc b/gtk2_ardour/editing.cc index d6d97bc059..e23ee17fda 100644 --- a/gtk2_ardour/editing.cc +++ b/gtk2_ardour/editing.cc @@ -163,5 +163,15 @@ const char *importmodestrs[] = { #undef IMPORTMODE #define IMPORTMODE(a) /*empty*/ +//TEMPOEDITBEHAVIOR +#undef TEMPOEDITBEHAVIOR +#define TEMPOEDITBEHAVIOR(s) N_(#s), +const char *tempoeditbehaviorstrs[] = { + #include "editing_syms.h" + 0 +}; +#undef TEMPOEDITBEHAVIOR +#define TEMPOEDITBEHAVIOR(a) /*empty*/ + } // namespace Editing diff --git a/gtk2_ardour/editing.h b/gtk2_ardour/editing.h index 4e270dc6b7..7ccabca99e 100644 --- a/gtk2_ardour/editing.h +++ b/gtk2_ardour/editing.h @@ -41,6 +41,7 @@ #define WAVEFORMSCALE(a) /*empty*/ #define WAVEFORMSHAPE(a) /*empty*/ #define INSERTTIMEOPT(a) /*empty*/ +#define TEMPOEDITBEHAVIOR(a) /*empty*/ namespace Editing { @@ -197,6 +198,18 @@ enum InsertTimeOption { #undef INSERTTIMEOPT #define INSERTTIMEOPT(a) /*empty*/ +#undef TEMPOEDITBEHAVIOR +#define TEMPOEDITBEHAVIOR(a) a, +enum TempoEditBehavior { + #include "editing_syms.h" +}; + +extern const char *tempoeditbehaviorstrs[]; +inline const char* enum2str(TempoEditBehavior m) {return tempoeditbehaviorstrs[m];} +TempoEditBehavior str2tempoeditbehavior(const std::string &); + +#undef TEMPOEDITBEHAVIOR +#define TEMPOEDITBEHAVIOR(a) /*empty*/ ///////////////////// // These don't need their state saved. yet... diff --git a/gtk2_ardour/editing_convert.h b/gtk2_ardour/editing_convert.h index 5ed05d4dfb..7fc3862659 100644 --- a/gtk2_ardour/editing_convert.h +++ b/gtk2_ardour/editing_convert.h @@ -32,6 +32,7 @@ DEFINE_ENUM_CONVERT(Editing::SnapMode) DEFINE_ENUM_CONVERT(Editing::EditPoint) DEFINE_ENUM_CONVERT(Editing::RegionListSortType) DEFINE_ENUM_CONVERT(Editing::MouseMode) +DEFINE_ENUM_CONVERT(Editing::TempoEditBehavior) } // namespace PBD diff --git a/gtk2_ardour/editing_syms.h b/gtk2_ardour/editing_syms.h index 4f3f9afd25..fb076d28b7 100644 --- a/gtk2_ardour/editing_syms.h +++ b/gtk2_ardour/editing_syms.h @@ -107,3 +107,6 @@ EDITPOINT(EditAtMouse) INSERTTIMEOPT(LeaveIntersected) INSERTTIMEOPT(MoveIntersected) INSERTTIMEOPT(SplitIntersected) + +TEMPOEDITBEHAVIOR(TempoMapping) +TEMPOEDITBEHAVIOR(TempoChanging) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index d301875bd2..0a8da3abc3 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -470,6 +470,7 @@ Editor::Editor () , _stepping_axis_view (0) , quantize_dialog (0) , _main_menu_disabler (0) + , _tempo_edit_behavior (UIConfiguration::instance().get_default_tempo_edit_behavior()) { /* we are a singleton */ diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 3cca23c558..8a01b0f5c5 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -620,6 +620,9 @@ public: void remove_region_marker (ARDOUR::CueMarker&); void make_region_markers_global (bool as_cd_markers); + Editing::TempoEditBehavior tempo_edit_behavior() const { return _tempo_edit_behavior; } + void set_tempo_edit_behavior (Editing::TempoEditBehavior teb); + protected: void map_transport_state (); void map_position_change (samplepos_t); @@ -2525,6 +2528,8 @@ private: void choose_mapping_drag (ArdourCanvas::Item*, GdkEvent*); + Editing::TempoEditBehavior _tempo_edit_behavior; + template Temporal::TimeDomain drag_time_domain (T* thing_with_time_domain) { return thing_with_time_domain ? thing_with_time_domain->time_domain() : Temporal::AudioTime; diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc index c719eb4177..6f1938175a 100644 --- a/gtk2_ardour/editor_tempodisplay.cc +++ b/gtk2_ardour/editor_tempodisplay.cc @@ -894,3 +894,9 @@ Editor::mid_tempo_per_region_update (RegionView* rv) { rv->tempo_map_changed (); } + +void +Editor::set_tempo_edit_behavior (TempoEditBehavior teb) +{ + _tempo_edit_behavior = teb; +} diff --git a/gtk2_ardour/enums.cc b/gtk2_ardour/enums.cc index 3a606d5cb7..f2e2b4bdfc 100644 --- a/gtk2_ardour/enums.cc +++ b/gtk2_ardour/enums.cc @@ -60,6 +60,7 @@ setup_gtk_ardour_enums () StartupFSM::DialogID startup_dialog; Gtk::ResponseType dialog_response; AddRouteDialog::TypeWanted type_wanted; + TempoEditBehavior tempo_edit_behavior; #define REGISTER(e) enum_writer.register_distinct (typeid(e).name(), i, s); i.clear(); s.clear() #define REGISTER_BITS(e) enum_writer.register_bits (typeid(e).name(), i, s); i.clear(); s.clear() @@ -227,4 +228,8 @@ setup_gtk_ardour_enums () REGISTER_CLASS_ENUM (AddRouteDialog, VCAMaster); REGISTER_CLASS_ENUM (AddRouteDialog, FoldbackBus); REGISTER (type_wanted); + + REGISTER_ENUM (TempoMapping); + REGISTER_ENUM (TempoChanging); + REGISTER (tempo_edit_behavior); } diff --git a/gtk2_ardour/ui_config.cc b/gtk2_ardour/ui_config.cc index 4eb13e8cd4..a8ea99fd3e 100644 --- a/gtk2_ardour/ui_config.cc +++ b/gtk2_ardour/ui_config.cc @@ -53,6 +53,7 @@ #include "canvas/text.h" +#include "editing_convert.h" #include "ui_config.h" #include "pbd/i18n.h" diff --git a/gtk2_ardour/ui_config.h b/gtk2_ardour/ui_config.h index 61256698a2..cdac0aabc0 100644 --- a/gtk2_ardour/ui_config.h +++ b/gtk2_ardour/ui_config.h @@ -43,6 +43,7 @@ #include "gtkmm2ext/colors.h" #include "widgets/ui_config.h" +#include "editing.h" #include "utils.h" class UIConfiguration : public ArdourWidgets::UIConfigurationBase diff --git a/gtk2_ardour/ui_config_vars.h b/gtk2_ardour/ui_config_vars.h index 75b0a0c5b3..e34411f549 100644 --- a/gtk2_ardour/ui_config_vars.h +++ b/gtk2_ardour/ui_config_vars.h @@ -146,6 +146,7 @@ UI_CONFIG_VARIABLE (int, default_upper_midi_note, "default-upper-midi-note", 71) UI_CONFIG_VARIABLE (bool, ask_before_closing_last_window, "ask-before-closing-last-window", true) UI_CONFIG_VARIABLE (std::string, freesound_dir, "freesound-dir", "") UI_CONFIG_VARIABLE (int, max_note_height, "max-note-height", 20) +UI_CONFIG_VARIABLE (Editing::TempoEditBehavior, default_tempo_edit_behavior, "default-tempo-edit-behavior", Editing::TempoMapping) /* these are visibility-type selections in the New Track dialog that we should make persistent for the user's choices */ UI_CONFIG_VARIABLE (bool, show_on_cue_page, "show-on-cue-page", true)