initial (incomplete) framework for DiskIOPoint manipulation
[ardour.git] / gtk2_ardour / quantize_dialog.cc
index 05c8d1e940e392af9b5dfba273a28e5afe3db77d..dd7bd1affc22b272955947c1e89d73f094db49b4 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;
@@ -55,6 +55,13 @@ static const gchar *_grid_strings[] = {
        0
 };
 
+static const int _grid_beats[] = {
+       0,
+       128, 64, 32, 28, 24, 20, 16, 14,
+       12, 10, 8, 7, 6, 5, 4, 3, 2, 1,
+       0
+};
+
 std::vector<std::string> QuantizeDialog::grid_strings;
 
 QuantizeDialog::QuantizeDialog (PublicEditor& e)
@@ -112,7 +119,7 @@ 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 (_("Quantize"), RESPONSE_OK);
@@ -131,13 +138,13 @@ QuantizeDialog::start_grid_size () const
 double
 QuantizeDialog::end_grid_size () const
 {
-       return grid_size_to_musical_time (start_grid_combo.get_active_text ());
+       return grid_size_to_musical_time (end_grid_combo.get_active_text ());
 }
 
 double
 QuantizeDialog::grid_size_to_musical_time (const string& txt) const
 {
-       if (txt == "main grid") {
+       if (txt == _("main grid")) {
                bool success;
 
                Evoral::Beats b = editor.get_grid_type_as_beats (success, 0);
@@ -147,18 +154,17 @@ QuantizeDialog::grid_size_to_musical_time (const string& txt) const
                return b.to_double();
        }
 
-       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;
-                       }
+       double divisor = 1.0;
+       for (size_t i = 1; i < grid_strings.size(); ++i) {
+               if (txt == grid_strings[i]) {
+                       assert (_grid_beats[i] != 0);
+                       divisor = 1.0 / _grid_beats[i];
+                       break;
                }
        }
 
-       return 1.0;
+       return divisor;
 }
 
 float