Prepare for re-use of TimeInfoBox w/o punch-clock
authorRobin Gareus <robin@gareus.org>
Tue, 20 Dec 2016 02:10:05 +0000 (03:10 +0100)
committerRobin Gareus <robin@gareus.org>
Tue, 20 Dec 2016 02:59:15 +0000 (03:59 +0100)
gtk2_ardour/editor.cc
gtk2_ardour/time_info_box.cc
gtk2_ardour/time_info_box.h

index 78f4e2b405c5230665c9a84d070348548bf12bf4..bcbc5ec81b73eff75bcead341006ad72b937d1e9 100644 (file)
@@ -644,7 +644,7 @@ Editor::Editor ()
        _regions = new EditorRegions (this);
        _snapshots = new EditorSnapshots (this);
        _locations = new EditorLocations (this);
-       _time_info_box = new TimeInfoBox ();
+       _time_info_box = new TimeInfoBox (true);
 
        /* these are static location signals */
 
index f8118cbf648d842bdf2ce01bcd6d4d6a2b47c144..ceda41e90c16246f325788dcb103c81098e772eb 100644 (file)
@@ -43,10 +43,13 @@ using namespace ARDOUR;
 using std::min;
 using std::max;
 
-TimeInfoBox::TimeInfoBox ()
-       : table (3, 4)
+TimeInfoBox::TimeInfoBox (bool with_punch)
+       : table (3, 3)
+       , punch_start (0)
+       , punch_end (0)
        , syncing_selection (false)
        , syncing_punch (false)
+       , with_punch_clock (with_punch)
 {
        set_name (X_("TimeInfoBox"));
 
@@ -54,11 +57,7 @@ TimeInfoBox::TimeInfoBox ()
        selection_end = new AudioClock ("selection-end", false, "selection", false, false, false, false);
        selection_length = new AudioClock ("selection-length", false, "selection", false, false, true, false);
 
-       punch_start = new AudioClock ("punch-start", false, "punch", false, false, false, false);
-       punch_end = new AudioClock ("punch-end", false, "punch", false, false, false, false);
-
        selection_title.set_text (_("Selection"));
-       punch_title.set_text (_("Punch"));
 
        set_homogeneous (false);
        set_spacing (0);
@@ -74,7 +73,9 @@ TimeInfoBox::TimeInfoBox ()
        Gtk::Label* l;
 
        selection_title.set_name ("TimeInfoSelectionTitle");
-       table.attach (selection_title, 1, 2, 0, 1);
+       if (with_punch_clock) {
+               table.attach (selection_title, 1, 2, 0, 1);
+       }
        l = manage (new Label);
        l->set_text (_("Start"));
        l->set_alignment (1.0, 0.5);
@@ -96,10 +97,16 @@ TimeInfoBox::TimeInfoBox ()
        table.attach (*l, 0, 1, 3, 4, FILL);
        table.attach (*selection_length, 1, 2, 3, 4);
 
-       punch_title.set_name ("TimeInfoSelectionTitle");
-       table.attach (punch_title, 2, 3, 0, 1);
-       table.attach (*punch_start, 2, 3, 1, 2);
-       table.attach (*punch_end, 2, 3, 2, 3);
+       if (with_punch_clock) {
+               punch_start = new AudioClock ("punch-start", false, "punch", false, false, false, false);
+               punch_end = new AudioClock ("punch-end", false, "punch", false, false, false, false);
+               punch_title.set_text (_("Punch"));
+
+               punch_title.set_name ("TimeInfoSelectionTitle");
+               table.attach (punch_title, 2, 3, 0, 1);
+               table.attach (*punch_start, 2, 3, 1, 2);
+               table.attach (*punch_end, 2, 3, 2, 3);
+       }
 
        show_all ();
 
@@ -107,14 +114,16 @@ TimeInfoBox::TimeInfoBox ()
        selection_end->mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::sync_selection_mode), selection_end));
        selection_length->mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::sync_selection_mode), selection_length));
 
-       punch_start->mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::sync_punch_mode), punch_start));
-       punch_end->mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::sync_punch_mode), punch_end));
-
        selection_start->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), selection_start), true);
        selection_end->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), selection_end), true);
 
-       punch_start->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), punch_start), true);
-       punch_end->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), punch_end), true);
+       if (with_punch_clock) {
+               punch_start->mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::sync_punch_mode), punch_start));
+               punch_end->mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::sync_punch_mode), punch_end));
+
+               punch_start->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), punch_start), true);
+               punch_end->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), punch_end), true);
+       }
 
        Editor::instance().get_selection().TimeChanged.connect (sigc::mem_fun (*this, &TimeInfoBox::selection_changed));
        Editor::instance().get_selection().RegionsChanged.connect (sigc::mem_fun (*this, &TimeInfoBox::selection_changed));
@@ -198,6 +207,9 @@ TimeInfoBox::sync_selection_mode (AudioClock* src)
 void
 TimeInfoBox::sync_punch_mode (AudioClock* src)
 {
+       if (!with_punch_clock) {
+               return;
+       }
        if (!syncing_punch) {
                syncing_punch = true;
                punch_start->set_mode (src->mode());
@@ -216,6 +228,10 @@ TimeInfoBox::set_session (Session* s)
        selection_end->set_session (s);
        selection_length->set_session (s);
 
+       if (!with_punch_clock) {
+               return;
+       }
+
        punch_start->set_session (s);
        punch_end->set_session (s);
 
@@ -229,7 +245,7 @@ TimeInfoBox::set_session (Session* s)
                punch_changed (punch);
 
                _session->auto_punch_location_changed.connect (_session_connections, MISSING_INVALIDATOR,
-                                                              boost::bind (&TimeInfoBox::punch_location_changed, this, _1), gui_context());
+                               boost::bind (&TimeInfoBox::punch_location_changed, this, _1), gui_context());
        }
 }
 
@@ -335,7 +351,7 @@ TimeInfoBox::selection_changed ()
 void
 TimeInfoBox::punch_location_changed (Location* loc)
 {
-       if (loc) {
+       if (loc && with_punch_clock) {
                watch_punch (loc);
        }
 }
@@ -343,6 +359,7 @@ TimeInfoBox::punch_location_changed (Location* loc)
 void
 TimeInfoBox::watch_punch (Location* punch)
 {
+       assert (with_punch_clock);
        punch_connections.drop_connections ();
 
        punch->start_changed.connect (punch_connections, MISSING_INVALIDATOR, boost::bind (&TimeInfoBox::punch_changed, this, _1), gui_context());
@@ -354,6 +371,7 @@ TimeInfoBox::watch_punch (Location* punch)
 void
 TimeInfoBox::punch_changed (Location* loc)
 {
+       assert (with_punch_clock);
        if (!loc) {
                punch_start->set_off (true);
                punch_end->set_off (true);
@@ -366,4 +384,3 @@ TimeInfoBox::punch_changed (Location* loc)
        punch_start->set (loc->start());
        punch_end->set (loc->end());
 }
-
index 984a14a1c0d28bb788a0d7ae21cc0b33fcc3b323..83f58e7eb58ab093ef90a917f72c820df7549ed2 100644 (file)
@@ -42,43 +42,43 @@ class AudioClock;
 
 class TimeInfoBox : public CairoHPacker, public ARDOUR::SessionHandlePtr
 {
-  public:
-    TimeInfoBox ();
-    ~TimeInfoBox ();
+public:
+       TimeInfoBox (bool with_punch);
+       ~TimeInfoBox ();
 
-    void set_session (ARDOUR::Session*);
+       void set_session (ARDOUR::Session*);
 
-  private:
-    Gtk::Table table;
+private:
+       Gtk::Table table;
 
-    AudioClock* selection_start;
-    AudioClock* selection_end;
-    AudioClock* selection_length;
+       AudioClock* selection_start;
+       AudioClock* selection_end;
+       AudioClock* selection_length;
 
-    AudioClock* punch_start;
-    AudioClock* punch_end;
+       AudioClock* punch_start;
+       AudioClock* punch_end;
 
-    Gtk::Label selection_title;
-    Gtk::Label punch_title;
-    bool syncing_selection;
-    bool syncing_punch;
+       Gtk::Label selection_title;
+       Gtk::Label punch_title;
+       bool syncing_selection;
+       bool syncing_punch;
+       bool with_punch_clock;
 
-    void punch_changed (ARDOUR::Location*);
-    void punch_location_changed (ARDOUR::Location*);
-    void watch_punch (ARDOUR::Location*);
-    PBD::ScopedConnectionList punch_connections;
-    PBD::ScopedConnectionList editor_connections;
-    PBD::ScopedConnectionList region_property_connections;
+       void punch_changed (ARDOUR::Location*);
+       void punch_location_changed (ARDOUR::Location*);
+       void watch_punch (ARDOUR::Location*);
+       PBD::ScopedConnectionList punch_connections;
+       PBD::ScopedConnectionList editor_connections;
+       PBD::ScopedConnectionList region_property_connections;
 
-    void selection_changed ();
+       void selection_changed ();
 
-    void sync_selection_mode (AudioClock*);
-    void sync_punch_mode (AudioClock*);
+       void sync_selection_mode (AudioClock*);
+       void sync_punch_mode (AudioClock*);
 
-    bool clock_button_release_event (GdkEventButton* ev, AudioClock* src);
-    void track_mouse_mode ();
-    void region_property_change (boost::shared_ptr<ARDOUR::Region> r, const PBD::PropertyChange& what_changed);
+       bool clock_button_release_event (GdkEventButton* ev, AudioClock* src);
+       void track_mouse_mode ();
+       void region_property_change (boost::shared_ptr<ARDOUR::Region> r, const PBD::PropertyChange& what_changed);
 };
 
-
 #endif /* __time_info_box_h__ */