Add glue / lock buttons to the location window.
authorCarl Hetherington <carl@carlh.net>
Mon, 9 Aug 2010 18:22:10 +0000 (18:22 +0000)
committerCarl Hetherington <carl@carlh.net>
Mon, 9 Aug 2010 18:22:10 +0000 (18:22 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7577 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/location_ui.cc
gtk2_ardour/location_ui.h
libs/ardour/ardour/location.h
libs/ardour/location.cc

index fb30450a54e5baa7e635640c5720d26662062955..ac7b227e5bfaabfc52c812c3d98d875f18f6285d 100644 (file)
@@ -51,6 +51,8 @@ LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
          length_clock (X_("locationlength"), true, X_("LocationEditRowClock"), true, false, true),
          cd_check_button (_("CD")),
          hide_check_button (_("Hide")),
+         lock_check_button (_("Lock")),
+         glue_check_button (_("Glue")),
          scms_check_button (_("SCMS")),
          preemph_check_button (_("Pre-Emphasis"))
 
@@ -68,6 +70,8 @@ LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
        end_go_button.set_name ("LocationEditGoButton");
        cd_check_button.set_name ("LocationEditCdButton");
        hide_check_button.set_name ("LocationEditHideButton");
+       lock_check_button.set_name ("LocationEditLockButton");
+       glue_check_button.set_name ("LocationEditGlueButton");
        remove_button.set_name ("LocationEditRemoveButton");
        isrc_label.set_name ("LocationEditNumberLabel");
        isrc_entry.set_name ("LocationEditNameEntry");
@@ -137,6 +141,8 @@ LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
 
        cd_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::cd_toggled));
        hide_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::hide_toggled));
+       lock_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::lock_toggled));
+       glue_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::glue_toggled));
 
        remove_button.signal_clicked().connect(sigc::mem_fun(*this, &LocationEditRow::remove_button_pressed));
 
@@ -191,8 +197,12 @@ LocationEditRow::set_location (Location *loc)
 
        if (!hide_check_button.get_parent()) {
                item_table.attach (hide_check_button, 5, 6, 0, 1, FILL, Gtk::FILL, 4, 0);
+               item_table.attach (lock_check_button, 6, 7, 0, 1, FILL, Gtk::FILL, 4, 0);
+               item_table.attach (glue_check_button, 7, 8, 0, 1, FILL, Gtk::FILL, 4, 0);
        }
        hide_check_button.set_active (location->is_hidden());
+       lock_check_button.set_active (location->locked());
+       glue_check_button.set_active (location->position_lock_style() == MusicTime);
 
        if (location->is_auto_loop() || location-> is_auto_punch()) {
                // use label instead of entry
@@ -222,7 +232,7 @@ LocationEditRow::set_location (Location *loc)
                        item_table.attach (cd_check_button, 4, 5, 0, 1, FILL, FILL, 4, 0);
                }
                if (!remove_button.get_parent()) {
-                       item_table.attach (remove_button, 6, 7, 0, 1, FILL, FILL, 4, 0);
+                       item_table.attach (remove_button, 8, 9, 0, 1, FILL, FILL, 4, 0);
                }
 
                if (location->is_session_range()) {
@@ -239,6 +249,8 @@ LocationEditRow::set_location (Location *loc)
                }
 
                hide_check_button.show();
+               lock_check_button.show();
+               glue_check_button.show();
        }
 
        start_clock.set (location->start(), true);
@@ -286,6 +298,8 @@ LocationEditRow::set_location (Location *loc)
        location->name_changed.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::name_changed, this, _1), gui_context());
        location->changed.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::location_changed, this, _1), gui_context());
        location->FlagsChanged.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::flags_changed, this, _1, _2), gui_context());
+       location->LockChanged.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::lock_changed, this, _1), gui_context());
+       location->PositionLockStyleChanged.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::position_lock_style_changed, this, _1), gui_context());
 }
 
 void
@@ -444,11 +458,41 @@ LocationEditRow::cd_toggled ()
 void
 LocationEditRow::hide_toggled ()
 {
-       if (i_am_the_modifier || !location) return;
+       if (i_am_the_modifier || !location) {
+               return;
+       }
 
        location->set_hidden (hide_check_button.get_active(), this);
 }
 
+void
+LocationEditRow::lock_toggled ()
+{
+       if (i_am_the_modifier || !location) {
+               return;
+       }
+
+       if (location->locked()) {
+               location->unlock ();
+       } else {
+               location->lock ();
+       }
+}
+
+void
+LocationEditRow::glue_toggled ()
+{
+       if (i_am_the_modifier || !location) {
+               return;
+       }
+
+       if (location->position_lock_style() == AudioTime) {
+               location->set_position_lock_style (MusicTime);
+       } else {
+               location->set_position_lock_style (AudioTime);
+       }
+}
+
 void
 LocationEditRow::remove_button_pressed ()
 {
@@ -564,14 +608,43 @@ LocationEditRow::location_changed (ARDOUR::Location *loc)
 void
 LocationEditRow::flags_changed (ARDOUR::Location *loc, void *src)
 {
-       ENSURE_GUI_THREAD (*this, &LocationEditRow::flags_changed, loc, src)
-
-       if (!location) return;
+       if (!location) {
+               return;
+       }
 
        i_am_the_modifier++;
 
        cd_check_button.set_active (location->is_cd_marker());
        hide_check_button.set_active (location->is_hidden());
+       glue_check_button.set_active (location->position_lock_style() == MusicTime);
+
+       i_am_the_modifier--;
+}
+
+void
+LocationEditRow::lock_changed (ARDOUR::Location *loc)
+{
+       if (!location) {
+               return;
+       }
+
+       i_am_the_modifier++;
+
+       lock_check_button.set_active (location->locked());
+
+       i_am_the_modifier--;
+}
+
+void
+LocationEditRow::position_lock_style_changed (ARDOUR::Location* loc)
+{
+       if (!location) {
+               return;
+       }
+
+       i_am_the_modifier++;
+
+       glue_check_button.set_active (location->position_lock_style() == MusicTime);
 
        i_am_the_modifier--;
 }
index c3f07cc84d980c6298bf414b22be420e7e920328..b2b7174d8f9a9ea26ca9454bbd5ff9db3f1a1d6e 100644 (file)
@@ -86,6 +86,8 @@ class LocationEditRow  : public Gtk::HBox, public ARDOUR::SessionHandlePtr
        AudioClock    length_clock;
        Gtk::CheckButton cd_check_button;
        Gtk::CheckButton hide_check_button;
+       Gtk::CheckButton lock_check_button;
+       Gtk::CheckButton glue_check_button;
 
        Gtk::Button   remove_button;
 
@@ -117,6 +119,8 @@ class LocationEditRow  : public Gtk::HBox, public ARDOUR::SessionHandlePtr
 
        void cd_toggled ();
        void hide_toggled ();
+       void lock_toggled ();
+       void glue_toggled ();
        void remove_button_pressed ();
 
        void scms_toggled ();
@@ -127,6 +131,8 @@ class LocationEditRow  : public Gtk::HBox, public ARDOUR::SessionHandlePtr
        void name_changed (ARDOUR::Location *);
        void location_changed (ARDOUR::Location *);
        void flags_changed (ARDOUR::Location *, void *src);
+       void lock_changed (ARDOUR::Location *);
+       void position_lock_style_changed (ARDOUR::Location *);
 
        PBD::ScopedConnectionList connections;
 };
index cafcf3849431a4ce73292ff1c313a62bd37bb7ed..429fac177cae710bfbf054c85889c8d9e2e0c050 100644 (file)
@@ -58,8 +58,8 @@ class Location : public SessionHandleRef, public PBD::StatefulDestructible
        Location* operator= (const Location& other);
 
        bool locked() const { return _locked; }
-       void lock() { _locked = true; changed (this); }
-       void unlock() { _locked = false; changed (this); }
+       void lock() { _locked = true; LockChanged (this); }
+       void unlock() { _locked = false; LockChanged (this); }
 
        nframes64_t start() const  { return _start; }
        nframes64_t end() const { return _end; }
@@ -95,10 +95,11 @@ class Location : public SessionHandleRef, public PBD::StatefulDestructible
        PBD::Signal1<void,Location*> end_changed;
        PBD::Signal1<void,Location*> start_changed;
 
+       PBD::Signal1<void,Location*> LockChanged;
        PBD::Signal2<void,Location*,void*> FlagsChanged;
+       PBD::Signal1<void,Location*> PositionLockStyleChanged;
 
-       /* this is sent only when both start&end change at the same time */
-
+       /* this is sent only when both start and end change at the same time */
        PBD::Signal1<void,Location*> changed;
 
        /* CD Track / CD-Text info */
index 5828c57f65149fc96418831147fdf0d4007a2c80..ea267db25ede84ba0fe3f47b1b6d7a2e49f35fff 100644 (file)
@@ -464,6 +464,8 @@ Location::set_position_lock_style (PositionLockStyle ps)
        _position_lock_style = ps;
 
        recompute_bbt_from_frames ();
+
+       PositionLockStyleChanged (this); /* EMIT SIGNAL */
 }
 
 void