Remove unused code.
[ardour.git] / gtk2_ardour / time_info_box.cc
index 750ce9cea7dd656c791da943fe9c419cce475895..515d49f72b6faf18c73c9e040c666c8940f0d348 100644 (file)
@@ -23,6 +23,8 @@
 #include "gtkmm2ext/cairocell.h"
 #include "gtkmm2ext/gui_thread.h"
 #include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/stateful_button.h"
+#include "gtkmm2ext/actions.h"
 
 #include "ardour/location.h"
 #include "ardour/session.h"
@@ -39,83 +41,88 @@ using std::min;
 using std::max;
 
 TimeInfoBox::TimeInfoBox ()
-       : Table (4, 4)
+       : left (2, 4)
+       , right (2, 4)
        , syncing_selection (false)
        , syncing_punch (false)
 {
-       selection_start = new AudioClock ("selection-start", false, "SelectionClockDisplay", false, false, false, false);
-       selection_end = new AudioClock ("selection-end", false, "SelectionClockDisplay", false, false, false, false);
-       selection_length = new AudioClock ("selection-length", false, "SelectionClockDisplay", false, false, true, false);
+       selection_start = new AudioClock ("selection-start", false, "selection", false, false, false, false);
+       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, "PunchClockDisplay", false, false, false, false);
-       punch_end = new AudioClock ("punch-end", false, "PunchClockDisplay", false, false, false, 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);
 
-       CairoEditableText& ss (selection_start->main_display());
-       ss.set_corner_radius (0);
-
-       CairoEditableText& se (selection_end->main_display());
-       se.set_corner_radius (0);
-
-       CairoEditableText& sl (selection_length->main_display());
-       sl.set_corner_radius (0);
-
-       CairoEditableText& ps (punch_start->main_display());
-       ps.set_corner_radius (0);
-
-       CairoEditableText& pe (punch_end->main_display());
-       pe.set_corner_radius (0);
+       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_spacings (0);
+       set_spacing (6);
        set_border_width (2);
-       set_col_spacings (2);
 
-       /* a bit more spacing between the two "sides" */
-       set_col_spacing (1, 10);
+       pack_start (left, true, true);
+       pack_start (right, true, true);
+
+       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);
 
        Gtk::Label* l;
 
        selection_title.set_name ("TimeInfoSelectionTitle");
-       attach (selection_title, 0, 2, 0, 1);
+       left.attach (selection_title, 0, 2, 0, 1);
        l = manage (new Label);
        l->set_text (_("Start"));
        l->set_alignment (1.0, 0.5);
        l->set_name (X_("TimeInfoSelectionLabel"));
-        attach (*l, 0, 1, 1, 2, FILL);
-        attach (*selection_start, 1, 2, 1, 2);
+        left.attach (*l, 0, 1, 1, 2, FILL);
+        left.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"));
-        attach (*l, 0, 1, 2, 3, FILL);
-        attach (*selection_end, 1, 2, 2, 3);
+        left.attach (*l, 0, 1, 2, 3, FILL);
+        left.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"));
-        attach (*l, 0, 1, 3, 4, FILL);
-        attach (*selection_length, 1, 2, 3, 4);
+        left.attach (*l, 0, 1, 3, 4, FILL);
+        left.attach (*selection_length, 1, 2, 3, 4);
 
-       punch_title.set_name ("TimeInfoSelectionTitle");
-       attach (punch_title, 2, 4, 0, 1);
-       l = manage (new Label);
-       l->set_alignment (1.0, 0.5);
-       l->set_text (_("In"));
-       l->set_name (X_("TimeInfoPunchLabel"));
-        attach (*l, 2, 3, 1, 2, FILL);
-        attach (*punch_start, 3, 4, 1, 2);
+       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"));
 
-       l = manage (new Label);
-       l->set_alignment (1.0, 0.5);
-       l->set_text (_("Out"));
-       l->set_name (X_("TimeInfoPunchLabel"));
-        attach (*l, 2, 3, 2, 3, FILL);
-        attach (*punch_end, 3, 4, 2, 3);
+       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, 2, 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);
 
         show_all ();
 
@@ -162,7 +169,9 @@ TimeInfoBox::clock_button_release_event (GdkEventButton* ev, AudioClock* src)
        }
 
        if (ev->button == 1) {
-               _session->request_locate (src->current_time ());
+               if (!src->off()) {
+                       _session->request_locate (src->current_time ());
+               }
                return true;
        }
 
@@ -326,31 +335,3 @@ TimeInfoBox::punch_changed (Location* loc)
        punch_end->set (loc->end());
 }      
 
-bool
-TimeInfoBox::on_expose_event (GdkEventExpose* ev)
-{
-       {
-               int x, y;
-               Gtk::Widget* window_parent;
-               Glib::RefPtr<Gdk::Window> win = Gtkmm2ext::window_to_draw_on (*this, &window_parent);
-
-               if (win) {
-               
-                       Cairo::RefPtr<Cairo::Context> context = win->create_cairo_context();
-
-#if 0                  
-                       translate_coordinates (*window_parent, ev->area.x, ev->area.y, x, y);
-                       context->rectangle (x, y, ev->area.width, ev->area.height);
-                       context->clip ();
-#endif
-                       translate_coordinates (*window_parent, 0, 0, x, y);
-                       context->set_source_rgba (0.149, 0.149, 0.149, 1.0);
-                       Gtkmm2ext::rounded_rectangle (context, x, y, get_allocation().get_width(), get_allocation().get_height(), 5);
-                       context->fill ();
-               }
-       }
-
-       Table::on_expose_event (ev);
-
-       return false;
-}