Use transport_stopped() instead of speed check.
[ardour.git] / gtk2_ardour / editor.cc
index ae0ae9ea1cc2f2332758398c348791df4fdb0c09..b36833aff923a1fb4e31205cfac6cbf0b26b3c67 100644 (file)
@@ -179,7 +179,7 @@ static const gchar *_grid_type_strings[] = {
        N_("1/7 (8th septuplet)"),
        N_("1/14 (16th septuplet)"),
        N_("1/28 (32nd septuplet)"),
-       N_("Smpte"),
+       N_("Timecode"),
        N_("MinSec"),
        N_("Samples"),
        0
@@ -223,7 +223,12 @@ static const gchar *_rb_opt_strings[] = {
 };
 #endif
 
-#define COMBO_TRIANGLE_WIDTH 25 // ArdourButton _diameter (11) + 2 * arrow-padding (2*2) + 2 * text-padding (2*5)
+//Robin says: this should be odd to accomodate cairo drawing offset ( width/2 rounds up to pixel boundary )
+#ifdef __APPLE__
+#define COMBO_TRIANGLE_WIDTH 19 // ArdourButton _diameter (11) + 2 * arrow-padding (2*2) + 2 * text-padding (2*5)
+#else
+#define COMBO_TRIANGLE_WIDTH 11 // as-measured for win/linux.
+#endif
 
 Editor::Editor ()
        : PublicEditor (global_hpacker)
@@ -568,6 +573,7 @@ Editor::Editor ()
        _summary = new EditorSummary (this);
 
        selection->TimeChanged.connect (sigc::mem_fun(*this, &Editor::time_selection_changed));
+       selection->TracksChanged.connect (sigc::mem_fun(*this, &Editor::track_selection_changed));
 
        editor_regions_selection_changed_connection = selection->RegionsChanged.connect (sigc::mem_fun(*this, &Editor::region_selection_changed));
 
@@ -618,12 +624,19 @@ Editor::Editor ()
        time_bars_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
        time_bars_event_box.signal_button_release_event().connect (sigc::mem_fun(*this, &Editor::ruler_label_button_release));
 
+       ArdourWidgets::ArdourDropShadow *axis_view_shadow = manage (new (ArdourWidgets::ArdourDropShadow));
+       axis_view_shadow->set_size_request( 4, -1 );
+       axis_view_shadow->set_name("EditorWindow");
+       axis_view_shadow->show();
+
+       edit_packer.attach (*axis_view_shadow,     0, 1, 0, 2,    FILL,        FILL|EXPAND, 0, 0);
+
        /* labels for the time bars */
-       edit_packer.attach (time_bars_event_box,     0, 1, 0, 1,    FILL,        SHRINK, 0, 0);
+       edit_packer.attach (time_bars_event_box,     1, 2, 0, 1,    FILL,        SHRINK, 0, 0);
        /* track controls */
-       edit_packer.attach (controls_layout,         0, 1, 1, 2,    FILL,        FILL|EXPAND, 0, 0);
+       edit_packer.attach (controls_layout,         1, 2, 1, 2,    FILL,        FILL|EXPAND, 0, 0);
        /* canvas */
-       edit_packer.attach (*_track_canvas_viewport,  1, 2, 0, 2,    FILL|EXPAND, FILL|EXPAND, 0, 0);
+       edit_packer.attach (*_track_canvas_viewport,  2, 3, 0, 2,    FILL|EXPAND, FILL|EXPAND, 0, 0);
 
        bottom_hbox.set_border_width (2);
        bottom_hbox.set_spacing (3);
@@ -724,14 +737,14 @@ Editor::Editor ()
        }
        editor_summary_pane.set_divider (0, fract);
 
-       global_vpacker.set_spacing (2);
+       global_vpacker.set_spacing (0);
        global_vpacker.set_border_width (0);
 
        //the next three EventBoxes provide the ability for their child widgets to have a background color.  That is all.
 
        Gtk::EventBox* ebox = manage (new Gtk::EventBox);  //a themeable box
        ebox->set_name("EditorWindow");
-       ebox->add (toolbar_hbox);
+       ebox->add (ebox_hpacker);
 
        Gtk::EventBox* epane_box = manage (new EventBoxExt);  //a themeable box
        epane_box->set_name("EditorWindow");
@@ -741,6 +754,13 @@ Editor::Editor ()
        epane_box2->set_name("EditorWindow");
        epane_box2->add (global_vpacker);
 
+       ArdourWidgets::ArdourDropShadow *toolbar_shadow = manage (new (ArdourWidgets::ArdourDropShadow));
+       toolbar_shadow->set_size_request( -1, 4 );
+       toolbar_shadow->set_mode(ArdourWidgets::ArdourDropShadow::DropShadowBoth);
+       toolbar_shadow->set_name("EditorWindow");
+       toolbar_shadow->show(); 
+
+       global_vpacker.pack_start (*toolbar_shadow, false, false);
        global_vpacker.pack_start (*ebox, false, false);
        global_vpacker.pack_start (*epane_box, true, true);
        global_hpacker.pack_start (*epane_box2, true, true);
@@ -749,6 +769,8 @@ Editor::Editor ()
         */
 
        global_hpacker.show ();
+       ebox_hpacker.show();
+       ebox->show();
 
        /* register actions now so that set_state() can find them and set toggles/checks etc */
 
@@ -2709,9 +2731,11 @@ check_best_snap ( samplepos_t presnap, samplepos_t &test, samplepos_t &dist, sam
 samplepos_t
 Editor::snap_to_grid (vector<ArdourCanvas::Ruler::Mark> marks, samplepos_t presnap, RoundMode direction)
 {
+       if  (marks.empty() ) return presnap;
+
        samplepos_t before;
        samplepos_t after;
-       samplepos_t test;
+       samplepos_t test = presnap;
 
        before = after = max_samplepos;
 
@@ -2734,7 +2758,7 @@ Editor::snap_to_grid (vector<ArdourCanvas::Ruler::Mark> marks, samplepos_t presn
        }
 
        if (before == max_samplepos && after == max_samplepos) {
-               /* No smpte to snap to, so just don't snap */
+               /* No grid to snap to, so just don't snap */
                return presnap;
        } else if (before == max_samplepos) {
                test = after;
@@ -2927,11 +2951,11 @@ Editor::setup_toolbar ()
 
        if (!ARDOUR::Profile->get_mixbus()) {
                mouse_mode_hbox->pack_start (mouse_cut_button, false, false);
+               mouse_mode_hbox->pack_start (mouse_audition_button, false, false);
        }
 
        if (!ARDOUR::Profile->get_trx()) {
                mouse_mode_hbox->pack_start (mouse_timefx_button, false, false);
-               mouse_mode_hbox->pack_start (mouse_audition_button, false, false);
                mouse_mode_hbox->pack_start (mouse_draw_button, false, false);
                mouse_mode_hbox->pack_start (mouse_content_button, false, false);
        }
@@ -2947,6 +2971,9 @@ Editor::setup_toolbar ()
 
        if (!ARDOUR::Profile->get_trx()) {
                mode_box->pack_start (edit_mode_selector, false, false);
+               mode_box->pack_start (*(manage (new ArdourVSpacer ())), false, false, 3);
+               mode_box->pack_start (edit_point_selector, false, false);
+               mode_box->pack_start (*(manage (new ArdourVSpacer ())), false, false, 3);
        }
 
        mode_box->pack_start (*mouse_mode_box, false, false);
@@ -3034,13 +3061,6 @@ Editor::setup_toolbar ()
        snap_box.pack_start (snap_mode_button, false, false);
        snap_box.pack_start (grid_type_selector, false, false);
 
-       /* Edit Point*/
-       HBox *ep_box = manage (new HBox);
-       ep_box->set_spacing (2);
-       ep_box->set_border_width (2);
-
-       ep_box->pack_start (edit_point_selector, false, false);
-
        /* Nudge */
 
        HBox *nudge_box = manage (new HBox);
@@ -3060,17 +3080,25 @@ Editor::setup_toolbar ()
        toolbar_hbox.set_spacing (2);
        toolbar_hbox.set_border_width (2);
 
-       toolbar_hbox.pack_start (*mode_box, false, false);
+       ArdourWidgets::ArdourDropShadow *tool_shadow = manage (new (ArdourWidgets::ArdourDropShadow));
+       tool_shadow->set_size_request( 4, -1 );
+       tool_shadow->show();
 
-       if (!ARDOUR::Profile->get_trx()) {
+       ebox_hpacker.pack_start (*tool_shadow, false, false);
+       ebox_hpacker.pack_start(ebox_vpacker, true, true);
 
-               toolbar_hbox.pack_start (*(manage (new ArdourVSpacer ())), false, false, 3);
+       Gtk::EventBox* spacer = manage (new Gtk::EventBox);  //extra space under the mouse toolbar, for aesthetics
+       spacer->set_name("EditorWindow");
+       spacer->set_size_request(-1,4);
+       spacer->show();
 
-               toolbar_hbox.pack_start (_zoom_box, false, false);
+       ebox_vpacker.pack_start(toolbar_hbox, false, false);
+       ebox_vpacker.pack_start(*spacer, false, false);
+       ebox_vpacker.show();
 
-               toolbar_hbox.pack_start (*(manage (new ArdourVSpacer ())), false, false, 3);
+       toolbar_hbox.pack_start (*mode_box, false, false);
 
-               toolbar_hbox.pack_start (_track_box, false, false);
+       if (!ARDOUR::Profile->get_trx()) {
 
                toolbar_hbox.pack_start (*(manage (new ArdourVSpacer ())), false, false, 3);
 
@@ -3078,11 +3106,16 @@ Editor::setup_toolbar ()
 
                toolbar_hbox.pack_start (*(manage (new ArdourVSpacer ())), false, false, 3);
 
-               toolbar_hbox.pack_start (*ep_box, false, false);
+               toolbar_hbox.pack_start (*nudge_box, false, false);
 
-               toolbar_hbox.pack_start (*(manage (new ArdourVSpacer ())), false, false, 3);
+               //zoom tools on right ege
+
+               toolbar_hbox.pack_end (_zoom_box, false, false, 2);
+
+               toolbar_hbox.pack_end (*(manage (new ArdourVSpacer ())), false, false, 3);
+
+               toolbar_hbox.pack_end (_track_box, false, false);
 
-               toolbar_hbox.pack_start (*nudge_box, false, false);
        }
 
        toolbar_hbox.show_all ();
@@ -3166,7 +3199,7 @@ Editor::build_grid_type_menu ()
        grid_type_selector.AddMenuElem (MenuElem ( grid_type_strings[(int)GridTypeMinSec], sigc::bind (sigc::mem_fun(*this, &Editor::grid_type_selection_done), (GridType) GridTypeMinSec)));
        grid_type_selector.AddMenuElem (MenuElem ( grid_type_strings[(int)GridTypeSamples], sigc::bind (sigc::mem_fun(*this, &Editor::grid_type_selection_done), (GridType) GridTypeSamples)));
 
-       set_size_request_to_display_given_text (grid_type_selector, "No Grid", COMBO_TRIANGLE_WIDTH, 2);
+       set_size_request_to_display_given_text (grid_type_selector, _("Long Grid"), COMBO_TRIANGLE_WIDTH, 2);  //problem: some of the rarely-used grid names are very long.  Just do something arbitary, translators: rename this if needed
 }
 
 void
@@ -5726,6 +5759,11 @@ Editor::super_rapid_screen_update ()
                _last_update_time = 0;
        }
 
+       if (_session->transport_stopped()) {
+               //we are stopped.  don't interpolate the playhead position; just set it
+               _last_update_time = 0;
+       }
+
        if (_last_update_time > 0) {
                /* interpolate and smoothen playhead position */
                const double ds =  (now - _last_update_time) * _session->transport_speed() * _session->nominal_sample_rate () * 1e-6;