don't cache width & height for CairoWidget; provide option for all CairoWidgets to...
[ardour.git] / gtk2_ardour / time_info_box.cc
index fe6fe23bc364b35b04ff29ec2ab09676d0676ec6..3befc890aea27901c78aebaafecf4133c8e9b11a 100644 (file)
@@ -45,30 +45,19 @@ TimeInfoBox::TimeInfoBox ()
        , right (2, 4)
        , syncing_selection (false)
        , syncing_punch (false)
-       , punch_in_button (_("In"))
-       , punch_out_button (_("Out"))
 {
-       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"));
@@ -90,7 +79,6 @@ TimeInfoBox::TimeInfoBox ()
        right.set_border_width (2);
        right.set_col_spacings (2);
 
-
        Gtk::Label* l;
 
        selection_title.set_name ("TimeInfoSelectionTitle");
@@ -116,37 +104,25 @@ TimeInfoBox::TimeInfoBox ()
         left.attach (*l, 0, 1, 3, 4, FILL);
         left.attach (*selection_length, 1, 2, 3, 4);
 
-       punch_title.set_name ("TimeInfoSelectionTitle");
-       right.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"));
-        right.attach (*l, 2, 3, 1, 2, FILL);
-        right.attach (*punch_start, 3, 4, 1, 2);
-
-       l = manage (new Label);
-       l->set_alignment (1.0, 0.5);
-       l->set_text (_("Out"));
-       l->set_name (X_("TimeInfoPunchLabel"));
-        right.attach (*l, 2, 3, 2, 3, FILL);
-        right.attach (*punch_end, 3, 4, 2, 3);
+       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"));
 
-       punch_in_button.set_name ("TimeInfoPunchButton");
-       punch_out_button.set_name ("TimeInfoPunchButton");
-       punch_button_box.set_homogeneous (true);
-       punch_button_box.set_spacing (6);
-       punch_button_box.set_border_width (2);
-       punch_button_box.pack_start (punch_in_button, true, true);
-       punch_button_box.pack_start (punch_out_button, true, true);
-
-       ActionManager::get_action ("Transport", "TogglePunchIn")->connect_proxy (punch_in_button);
-       ActionManager::get_action ("Transport", "TogglePunchOut")->connect_proxy (punch_out_button);
+       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"));
 
-       right.attach (punch_button_box, 2, 4, 3, 4, FILL, FILL);
+       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 ();
 
@@ -167,6 +143,14 @@ TimeInfoBox::TimeInfoBox ()
        Editor::instance().get_selection().RegionsChanged.connect (sigc::mem_fun (*this, &TimeInfoBox::selection_changed));
 
        Editor::instance().MouseModeChanged.connect (editor_connections, invalidator(*this), ui_bind (&TimeInfoBox::track_mouse_mode, this), gui_context());
+
+       Gdk::Color bg;
+
+       bg.set_red (lrint (0.149 * 65535));
+       bg.set_green (lrint (0.149 * 65535));
+       bg.set_blue (lrint (0.149 * 65535));
+
+       CairoWidget::provide_background_for_cairo_widget (*this, bg);
 }
 
 TimeInfoBox::~TimeInfoBox ()
@@ -376,7 +360,7 @@ TimeInfoBox::on_expose_event (GdkEventExpose* ev)
 #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);
+                       Gtkmm2ext::rounded_rectangle (context, x, y, get_allocation().get_width(), get_allocation().get_height(), 9);
                        context->fill ();
                }
        }