use "mute" not cut in monitor section
[ardour.git] / gtk2_ardour / location_ui.cc
index 849ce9de221477419fe9ad5bf23b3a6f20c9b66a..004bf9e7658edda79b0d1262223b347367db3b80 100644 (file)
@@ -45,7 +45,7 @@ using namespace Gtkmm2ext;
 
 LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
        : SessionHandlePtr (0) /* explicitly set below */
-        , location(0) 
+        , location(0)
         , item_table (1, 6, false)
         , start_clock (X_("locationstart"), true, X_("LocationEditRowClock"), true, false)
         , end_clock (X_("locationend"), true, X_("LocationEditRowClock"), true, false)
@@ -83,6 +83,12 @@ LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
          composer_label.set_name ("LocationEditNumberLabel");
          composer_entry.set_name ("LocationEditNameEntry");
 
+        Gtk::Button* start_to_playhead_button = manage (new Button (_("Use PH")));
+        Gtk::Button* end_to_playhead_button = manage (new Button (_("Use PH")));
+
+        ARDOUR_UI::instance()->tooltips().set_tip (*start_to_playhead_button, _("Set value to playhead"));
+        ARDOUR_UI::instance()->tooltips().set_tip (*end_to_playhead_button, _("Set value to playhead"));
+
          isrc_label.set_text ("ISRC: ");
          isrc_label.set_size_request (30, -1);
          performer_label.set_text ("Performer: ");
@@ -121,19 +127,23 @@ LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
 
          start_hbox.pack_start (start_go_button, false, false);
          start_hbox.pack_start (start_clock, false, false);
+        start_hbox.pack_start (*start_to_playhead_button, false, false);
 
          /* this is always in this location, no matter what the location is */
 
          item_table.attach (start_hbox, 1, 2, 0, 1, FILL, FILL, 4, 0);
 
          start_go_button.signal_clicked().connect(sigc::bind (sigc::mem_fun (*this, &LocationEditRow::go_button_pressed), LocStart));
+        start_to_playhead_button->signal_clicked().connect (sigc::bind (sigc::mem_fun (*this, &LocationEditRow::to_playhead_button_pressed), LocStart));
          start_clock.ValueChanged.connect (sigc::bind (sigc::mem_fun (*this, &LocationEditRow::clock_changed), LocStart));
          start_clock.ChangeAborted.connect (sigc::bind (sigc::mem_fun (*this, &LocationEditRow::change_aborted), LocStart));
 
          end_hbox.pack_start (end_go_button, false, false);
          end_hbox.pack_start (end_clock, false, false);
+        end_hbox.pack_start (*end_to_playhead_button, false, false);
 
          end_go_button.signal_clicked().connect(sigc::bind (sigc::mem_fun (*this, &LocationEditRow::go_button_pressed), LocEnd));
+        end_to_playhead_button->signal_clicked().connect (sigc::bind (sigc::mem_fun (*this, &LocationEditRow::to_playhead_button_pressed), LocEnd));
          end_clock.ValueChanged.connect (sigc::bind (sigc::mem_fun (*this, &LocationEditRow::clock_changed), LocEnd));
          end_clock.ChangeAborted.connect (sigc::bind (sigc::mem_fun (*this, &LocationEditRow::change_aborted), LocEnd));
 
@@ -187,7 +197,7 @@ LocationEditRow::set_session (Session *sess)
 {
        SessionHandlePtr::set_session (sess);
 
-       if (!_session) { 
+       if (!_session) {
                return;
        }
 
@@ -333,7 +343,7 @@ void
 LocationEditRow::name_entry_changed ()
 {
        ENSURE_GUI_THREAD (*this, &LocationEditRow::name_entry_changed)
-       
+
        if (i_am_the_modifier || !location) {
                return;
        }
@@ -406,6 +416,25 @@ LocationEditRow::go_button_pressed (LocationPart part)
        }
 }
 
+void
+LocationEditRow::to_playhead_button_pressed (LocationPart part)
+{
+       if (!location) {
+               return;
+       }
+
+       switch (part) {
+       case LocStart:
+               location->set_start (_session->transport_frame ());
+               break;
+       case LocEnd:
+               location->set_end (_session->transport_frame ());
+               break;
+       default:
+               break;
+       }
+}
+
 void
 LocationEditRow::clock_changed (LocationPart part)
 {
@@ -564,7 +593,7 @@ LocationEditRow::preemph_toggled ()
 }
 
 void
-LocationEditRow::end_changed (ARDOUR::Location *loc)
+LocationEditRow::end_changed (ARDOUR::Location *)
 {
        ENSURE_GUI_THREAD (*this, &LocationEditRow::end_changed, loc)
 
@@ -719,12 +748,12 @@ LocationUI::LocationUI ()
 
        loop_punch_box.pack_start (loop_edit_row, false, false);
        loop_punch_box.pack_start (punch_edit_row, false, false);
-       
+
        table->attach (loop_punch_box, 1, 2, table_row, table_row + 1);
        ++table_row;
 
        vbox->pack_start (*table, false, false);
-       
+
        table = manage (new Table (3, 2));
        table->set_spacings (4);
        table->set_col_spacing (0, 32);
@@ -732,7 +761,7 @@ LocationUI::LocationUI ()
 
        table->attach (*manage (new Label ("")), 0, 2, table_row, table_row + 1, Gtk::SHRINK, Gtk::SHRINK);
        ++table_row;
-       
+
        l = manage (new Label (_("<b>Markers (Including CD Index)</b>")));
        l->set_alignment (0, 0.5);
        l->set_use_markup (true);
@@ -767,7 +796,7 @@ LocationUI::LocationUI ()
 
        table->attach (*manage (new Label ("")), 0, 2, table_row, table_row + 1, Gtk::SHRINK, Gtk::SHRINK);
        ++table_row;
-       
+
        l = manage (new Label (_("<b>Ranges (Including CD Track Ranges)</b>")));
        l->set_alignment (0, 0.5);
        l->set_use_markup (true);
@@ -803,7 +832,7 @@ LocationUI::LocationUI ()
 
        add_location_button.signal_clicked().connect (sigc::mem_fun(*this, &LocationUI::add_new_location));
        add_range_button.signal_clicked().connect (sigc::mem_fun(*this, &LocationUI::add_new_range));
-       
+
        show_all ();
 }
 
@@ -812,7 +841,7 @@ LocationUI::~LocationUI()
         delete _clock_group;
 }
 
-gint 
+gint
 LocationUI::do_location_remove (ARDOUR::Location *loc)
 {
        /* this is handled internally by Locations, but there's
@@ -834,7 +863,7 @@ LocationUI::do_location_remove (ARDOUR::Location *loc)
        return FALSE;
 }
 
-void 
+void
 LocationUI::location_remove_requested (ARDOUR::Location *loc)
 {
        // must do this to prevent problems when destroying
@@ -844,7 +873,7 @@ LocationUI::location_remove_requested (ARDOUR::Location *loc)
 }
 
 
-void 
+void
 LocationUI::location_redraw_ranges ()
 {
        range_rows.hide();
@@ -892,7 +921,7 @@ LocationUI::location_added (Location* location)
                        }
 
                        ++i;
-                       
+
                        if (j != children.end()) {
                                ++j;
                        }
@@ -943,7 +972,7 @@ LocationUI::map_locations (Locations::LocationList& locations)
                if (location->is_mark()) {
                        LocationEditRow* erow = manage (new LocationEditRow (_session, location, mark_n));
 
-                        erow->set_clock_group (*_clock_group);
+                       erow->set_clock_group (*_clock_group);
                        erow->remove_requested.connect (sigc::mem_fun(*this, &LocationUI::location_remove_requested));
                        erow->redraw_ranges.connect (sigc::mem_fun(*this, &LocationUI::location_redraw_ranges));
 
@@ -1023,7 +1052,9 @@ LocationUI::refresh_location_list ()
        using namespace Box_Helpers;
 
        // this is just too expensive to do when window is not shown
-       if (!is_visible()) return;
+       if (!is_mapped()) {
+               return;
+       }
 
        BoxList & loc_children = location_rows.children();
        BoxList & range_children = range_rows.children();
@@ -1034,7 +1065,6 @@ LocationUI::refresh_location_list ()
        if (_session) {
                _session->locations()->apply (*this, &LocationUI::map_locations);
        }
-
 }
 
 void
@@ -1103,11 +1133,11 @@ LocationUIWindow::~LocationUIWindow()
 {
 }
 
-void 
-LocationUIWindow::on_show()
+void
+LocationUIWindow::on_map ()
 {
+       ArdourDialog::on_map ();
        _ui.refresh_location_list();
-       ArdourDialog::on_show();
 }
 
 bool