PBD::Signal<...>::connect() is already thread safe, so drop intermediate proxy/call_s...
[ardour.git] / gtk2_ardour / quantize_dialog.cc
index 88d1f5496937c106236da7c69ed772c1894e0ce3..dab1b6adeceffb361090bd1c591db262de78b6d0 100644 (file)
@@ -25,7 +25,7 @@
 #include "quantize_dialog.h"
 #include "public_editor.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace Gtk;
@@ -37,8 +37,17 @@ static const gchar *_grid_strings[] = {
        N_("Beats/128"),
        N_("Beats/64"),
        N_("Beats/32"),
+       N_("Beats/28"),
+       N_("Beats/24"),
+       N_("Beats/20"),
        N_("Beats/16"),
+       N_("Beats/14"),
+       N_("Beats/12"),
+       N_("Beats/10"),
        N_("Beats/8"),
+       N_("Beats/7"),
+       N_("Beats/6"),
+       N_("Beats/5"),
        N_("Beats/4"),
        N_("Beats/3"),
        N_("Beats/2"),
@@ -46,27 +55,18 @@ static const gchar *_grid_strings[] = {
        0
 };
 
-static const gchar *_type_strings[] = {
-       N_("Grid"),
-       N_("Legato"),
-       N_("Groove"),
-       0
-};
-
 std::vector<std::string> QuantizeDialog::grid_strings;
-std::vector<std::string> QuantizeDialog::type_strings;
 
 QuantizeDialog::QuantizeDialog (PublicEditor& e)
        : ArdourDialog (_("Quantize"), false, false)
        , editor (e)
-       , type_label (_("Quantize Type"))
        , strength_adjustment (100.0, 0.0, 100.0, 1.0, 10.0)
        , strength_spinner (strength_adjustment)
        , strength_label (_("Strength"))
        , swing_adjustment (100.0, -130.0, 130.0, 1.0, 10.0)
        , swing_spinner (swing_adjustment)
        , swing_button (_("Swing"))
-       , threshold_adjustment (0.0, -1920.0, 1920.0, 1.0, 10.0) // XXX MAGIC TICK NUMBER FIX ME
+       , threshold_adjustment (0.0, -Timecode::BBT_Time::ticks_per_beat, Timecode::BBT_Time::ticks_per_beat, 1.0, 10.0)
        , threshold_spinner (threshold_adjustment)
        , threshold_label (_("Threshold (ticks)"))
        , snap_start_button (_("Snap note start"))
@@ -74,7 +74,6 @@ QuantizeDialog::QuantizeDialog (PublicEditor& e)
 {
        if (grid_strings.empty()) {
                grid_strings =  I18N (_grid_strings);
-               type_strings =  I18N (_type_strings);
        }
 
        set_popdown_strings (start_grid_combo, grid_strings);
@@ -82,20 +81,12 @@ QuantizeDialog::QuantizeDialog (PublicEditor& e)
        set_popdown_strings (end_grid_combo, grid_strings);
        end_grid_combo.set_active_text (grid_strings.front());
 
-       set_popdown_strings (type_combo, type_strings);
-       type_combo.set_active_text (type_strings.front());
-
        Table* table = manage (new Table (6, 2));
        table->set_spacings (12);
        table->set_border_width (12);
 
        int r = 0;
 
-       type_label.set_alignment (0, 0.5);
-       table->attach (type_label, 0, 1, r, r + 1);
-       table->attach (type_combo, 1, 2, r, r + 1);
-       ++r;
-
        table->attach (snap_start_button, 0, 1, r, r + 1);
        table->attach (start_grid_combo, 1, 2, r, r + 1);
        ++r;
@@ -121,10 +112,10 @@ QuantizeDialog::QuantizeDialog (PublicEditor& e)
        snap_end_button.set_active (false);
 
        get_vbox()->pack_start (*table);
-       show_all ();
+       get_vbox()->show_all ();
 
        add_button (Stock::CANCEL, RESPONSE_CANCEL);
-       add_button (Stock::OK, RESPONSE_OK);
+       add_button (_("Quantize"), RESPONSE_OK);
 }
 
 QuantizeDialog::~QuantizeDialog()
@@ -149,33 +140,24 @@ QuantizeDialog::grid_size_to_musical_time (const string& txt) const
        if (txt == "main grid") {
                bool success;
 
-               Evoral::MusicalTime b = editor.get_grid_type_as_beats (success, 0);
+               Evoral::Beats b = editor.get_grid_type_as_beats (success, 0);
                if (!success) {
                        return 1.0;
                }
-               return (double) b;
+               return b.to_double();
        }
 
-       if (txt == _("Beats/128")) {
-               return 1.0/128.0;
-       } else if (txt == _("Beats/64")) {
-               return 1.0/64.0;
-       } else if (txt == _("Beats/32")) {
-               return 1.0/32.0;
-       } else if (txt == _("Beats/16")) {
-               return 1.0/16.0;
-       } if (txt == _("Beats/8")) {
-               return 1.0/8.0;
-       } else if (txt == _("Beats/4")) {
-               return 1.0/4.0;
-       } else if (txt == _("Beats/3")) {
-               return 1.0/3.0;
-       } else if (txt == _("Beats/2")) {
-               return 1.0/2.0;
-       } else if (txt == _("Beats")) {
-               return 1.0;
+       string::size_type slash;
+
+       if ((slash = txt.find ('/')) != string::npos) {
+               if (slash < txt.length() - 1) {
+                       double divisor = PBD::atof (txt.substr (slash+1));
+                       if (divisor != 0.0) {
+                               return 1.0/divisor;
+                       }
+               }
        }
-        
+
        return 1.0;
 }