the return of VST support
[ardour.git] / gtk2_ardour / editor_tempodisplay.cc
index 0533792dd9a41873b85a08b131b40b1600965a14..5f998ada9fa5a0602c39cb874a790d9b8e5ffb60 100644 (file)
@@ -24,7 +24,7 @@
 #include <string>
 #include <climits>
 
-#include <libgnomecanvasmm/libgnomecanvasmm.h>
+#include <libgnomecanvasmm.h>
 
 #include <pbd/error.h>
 
@@ -34,6 +34,7 @@
 #include <ardour/session.h>
 #include <ardour/tempo.h>
 #include <gtkmm2ext/doi.h>
+#include <gtkmm2ext/utils.h>
 
 #include "editor.h"
 #include "marker.h"
 #include "tempo_dialog.h"
 #include "rgb_macros.h"
 #include "gui_thread.h"
+#include "color.h"
 
 #include "i18n.h"
 
 using namespace std;
 using namespace sigc;
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
+using namespace Gtkmm2ext;
 using namespace Editing;
 
 void
@@ -133,7 +137,6 @@ Editor::get_time_line ()
 
        if (free_measure_lines.empty()) {
                line = new ArdourCanvas::SimpleLine (*time_line_group);
-               // cerr << "measure line @ " << line << endl;
                used_measure_lines.push_back (line);
        } else {
                line = free_measure_lines.front();
@@ -180,7 +183,7 @@ Editor::draw_measures ()
                        break;
 
                case TempoMap::Beat:
-                       xpos = p.frame / (gdouble) frames_per_unit;
+                       xpos = frame_to_unit (p.frame);
                        if (last_beat < xpos) {
                                beat_spacing = xpos - last_beat;
                        }
@@ -188,6 +191,9 @@ Editor::draw_measures ()
                }
        }
 
+       double x1, x2, y1, y2;
+       track_canvas.get_scroll_region (x1, y1, x2, y2);
+
        for (i = all_bbt_points->begin(); i != all_bbt_points->end(); ++i) {
 
                TempoMap::BBTPoint& p = (*i);
@@ -197,8 +203,8 @@ Editor::draw_measures ()
                        break;
 
                case TempoMap::Beat:
-                       xpos = p.frame / (gdouble) frames_per_unit;
-
+                       xpos = frame_to_unit (p.frame);
+                       
                        if (p.beat == 1) {
                                color = color_map[cMeasureLineBeat];
                        } else {
@@ -212,12 +218,12 @@ Editor::draw_measures ()
                                        break;
                                }
                        }
-
+                       
                        if (cnt == 0 || xpos - last_xpos > 4.0) {
                                line = get_time_line ();
                                line->property_x1() = xpos;
                                line->property_x2() = xpos;
-                               line->property_y2() = canvas_height;
+                               line->property_y2() = y2;
                                line->property_color_rgba() = color;
                                line->raise_to_top();
                                line->show();
@@ -247,9 +253,7 @@ Editor::mouse_add_new_tempo_event (jack_nframes_t frame)
        TempoDialog tempo_dialog (map, frame, _("add"));
        
        tempo_dialog.set_position (Gtk::WIN_POS_MOUSE);
-       // GTK2FIX
-       // tempo_dialog.realize ();
-       // tempo_dialog.get_window()->set_decorations (Gdk::WMDecoration (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH));
+       tempo_dialog.signal_realize().connect (bind (sigc::ptr_fun (set_decoration), &tempo_dialog, Gdk::WMDecoration (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH)));
 
        ensure_float (tempo_dialog);
 
@@ -289,9 +293,7 @@ Editor::mouse_add_new_meter_event (jack_nframes_t frame)
        MeterDialog meter_dialog (map, frame, _("add"));
 
        meter_dialog.set_position (Gtk::WIN_POS_MOUSE);
-       // GTK2FIX
-       // meter_dialog.realize ();
-       // meter_dialog.get_window()->set_decorations (Gdk::WMDecoration (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH));
+       meter_dialog.signal_realize().connect (bind (sigc::ptr_fun (set_decoration), &meter_dialog, Gdk::WMDecoration (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH)));
 
        ensure_float (meter_dialog);
        
@@ -346,9 +348,6 @@ Editor::edit_meter_section (MeterSection* section)
        MeterDialog meter_dialog (*section, _("done"));
 
        meter_dialog.set_position (Gtk::WIN_POS_MOUSE);
-       // GTK2FIX
-       // meter_dialog.realize ();
-       // meter_dialog.get_window()->set_decorations (Gdk::WMDecoration (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH));
 
        ensure_float (meter_dialog);
 
@@ -377,9 +376,6 @@ Editor::edit_tempo_section (TempoSection* section)
        TempoDialog tempo_dialog (*section, _("done"));
 
        tempo_dialog.set_position (Gtk::WIN_POS_MOUSE);
-       // GTK2FIX
-       // tempo_dialog.realize ();
-       // tempo_dialog.get_window()->set_decorations (Gdk::WMDecoration (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH));
 
        ensure_float (tempo_dialog);