Fix yet another oversight for the windows icon file update
[ardour.git] / gtk2_ardour / time_info_box.cc
index a26ec50932c2f04e8d2d4e4824e2f243be7c2f7f..ceda41e90c16246f325788dcb103c81098e772eb 100644 (file)
 #include "control_point.h"
 #include "automation_line.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace Gtk;
 using namespace ARDOUR;
 using std::min;
 using std::max;
 
-TimeInfoBox::TimeInfoBox ()
-       : left (2, 4)
-       , right (2, 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"));
 
@@ -55,96 +57,73 @@ 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_start->set_draw_background (false);
-       selection_end->set_draw_background (false);
-       selection_length->set_draw_background (false);
-       punch_start->set_draw_background (false);
-       punch_end->set_draw_background (false);
-
        selection_title.set_text (_("Selection"));
-       punch_title.set_text (_("Punch"));
 
        set_homogeneous (false);
        set_spacing (0);
        set_border_width (2);
 
-       pack_start (left, true, true);
-       if (!ARDOUR::Profile->get_trx()) {
-               pack_start (right, true, true);
-       }
+       pack_start (table, false, false);
 
-       left.set_homogeneous (false);
-       left.set_spacings (0);
-       left.set_border_width (2);
-       left.set_col_spacings (2);
-
-       right.set_homogeneous (false);
-       right.set_spacings (0);
-       right.set_border_width (2);
-       right.set_col_spacings (2);
+       table.set_homogeneous (false);
+       table.set_spacings (0);
+       table.set_border_width (2);
+       table.set_col_spacings (2);
 
        Gtk::Label* l;
 
        selection_title.set_name ("TimeInfoSelectionTitle");
-       left.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);
        l->set_name (X_("TimeInfoSelectionLabel"));
-        left.attach (*l, 0, 1, 1, 2, FILL);
-        left.attach (*selection_start, 1, 2, 1, 2);
+       table.attach (*l, 0, 1, 1, 2, FILL);
+       table.attach (*selection_start, 1, 2, 1, 2);
 
        l = manage (new Label);
        l->set_text (_("End"));
        l->set_alignment (1.0, 0.5);
        l->set_name (X_("TimeInfoSelectionLabel"));
-        left.attach (*l, 0, 1, 2, 3, FILL);
-        left.attach (*selection_end, 1, 2, 2, 3);
+       table.attach (*l, 0, 1, 2, 3, FILL);
+       table.attach (*selection_end, 1, 2, 2, 3);
 
        l = manage (new Label);
        l->set_text (_("Length"));
        l->set_alignment (1.0, 0.5);
        l->set_name (X_("TimeInfoSelectionLabel"));
-        left.attach (*l, 0, 1, 3, 4, FILL);
-        left.attach (*selection_length, 1, 2, 3, 4);
-
-       punch_in_button.set_name ("punch button");
-       punch_out_button.set_name ("punch button");
-       punch_in_button.set_text (_("In"));
-       punch_out_button.set_text (_("Out"));
-
-       Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "TogglePunchIn");
-       punch_in_button.set_related_action (act);
-       act = ActionManager::get_action ("Transport", "TogglePunchOut");
-       punch_out_button.set_related_action (act);
-
-       Gtkmm2ext::UI::instance()->set_tip (punch_in_button, _("Start recording at auto-punch start"));
-       Gtkmm2ext::UI::instance()->set_tip (punch_out_button, _("Stop recording at auto-punch end"));
-
-       punch_title.set_name ("TimeInfoSelectionTitle");
-       right.attach (punch_title, 3, 4, 0, 1);
-        right.attach (punch_in_button, 2, 3, 1, 2, FILL, SHRINK);
-        right.attach (*punch_start, 3, 4, 1, 2);
-        right.attach (punch_out_button, 2, 3, 2, 3, FILL, SHRINK);
-        right.attach (*punch_end, 3, 4, 2, 3);
+       table.attach (*l, 0, 1, 3, 4, FILL);
+       table.attach (*selection_length, 1, 2, 3, 4);
+
+       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 ();
+       show_all ();
 
        selection_start->mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::sync_selection_mode), selection_start));
        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));
@@ -155,12 +134,12 @@ TimeInfoBox::TimeInfoBox ()
 
 TimeInfoBox::~TimeInfoBox ()
 {
-        delete selection_length;
-        delete selection_end;
-        delete selection_start;
+       delete selection_length;
+       delete selection_end;
+       delete selection_start;
 
-        delete punch_start;
-        delete punch_end;
+       delete punch_start;
+       delete punch_end;
 }
 
 void
@@ -193,7 +172,7 @@ TimeInfoBox::region_property_change (boost::shared_ptr<ARDOUR::Region> /* r */,
         * RegionView (not Region itself).
         */
 
-       selection_changed ();
+       //selection_changed ();
 }
 
 bool
@@ -228,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());
@@ -246,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);
 
@@ -259,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());
        }
 }
 
@@ -365,7 +351,7 @@ TimeInfoBox::selection_changed ()
 void
 TimeInfoBox::punch_location_changed (Location* loc)
 {
-       if (loc) {
+       if (loc && with_punch_clock) {
                watch_punch (loc);
        }
 }
@@ -373,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());
@@ -384,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);
@@ -396,4 +384,3 @@ TimeInfoBox::punch_changed (Location* loc)
        punch_start->set (loc->start());
        punch_end->set (loc->end());
 }
-