only the last step-edited note remains selected after each note addition; waf install...
[ardour.git] / gtk2_ardour / time_axis_view_item.cc
index 416a1741dcb4d8cfe01906fe9204cf6158264dcc..164e4d2420eabd11551e1f68eb76f2caa061e134 100644 (file)
@@ -49,7 +49,6 @@ using namespace PBD;
 using namespace ARDOUR;
 
 Pango::FontDescription* TimeAxisViewItem::NAME_FONT = 0;
-bool TimeAxisViewItem::have_name_font = false;
 const double TimeAxisViewItem::NAME_X_OFFSET = 15.0;
 const double TimeAxisViewItem::GRAB_HANDLE_LENGTH = 6;
 
@@ -58,6 +57,28 @@ double TimeAxisViewItem::NAME_Y_OFFSET;
 double TimeAxisViewItem::NAME_HIGHLIGHT_SIZE;
 double TimeAxisViewItem::NAME_HIGHLIGHT_THRESH;
 
+void
+TimeAxisViewItem::set_constant_heights ()
+{
+        NAME_FONT = get_font_for_style (X_("TimeAxisViewItemName"));
+        
+        Gtk::Window win;
+        Gtk::Label foo;
+        win.add (foo);
+        
+        Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout (X_("Hg")); /* ascender + descender */
+        int width = 0;
+        int height = 0;
+        
+        layout->set_font_description (*NAME_FONT);
+        Gtkmm2ext::get_ink_pixel_size (layout, width, height);
+        
+        NAME_HEIGHT = height;
+        NAME_Y_OFFSET = height + 3;
+        NAME_HIGHLIGHT_SIZE = height + 2;
+        NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 3;
+}
+
 /**
  * Construct a new TimeAxisViewItem.
  *
@@ -76,31 +97,6 @@ TimeAxisViewItem::TimeAxisViewItem(const string & it_name, ArdourCanvas::Group&
        , _height (1.0)
        , _recregion (recording)
 {
-       if (!have_name_font) {
-
-               /* first constructed item sets up font info */
-
-               NAME_FONT = get_font_for_style (N_("TimeAxisViewItemName"));
-
-               Gtk::Window win;
-               Gtk::Label foo;
-               win.add (foo);
-
-               Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout (X_("Hg")); /* ascender + descender */
-               int width = 0;
-               int height = 0;
-
-               layout->set_font_description (*NAME_FONT);
-               Gtkmm2ext::get_ink_pixel_size (layout, width, height);
-
-               NAME_HEIGHT = height;
-               NAME_Y_OFFSET = height + 3;
-               NAME_HIGHLIGHT_SIZE = height + 2;
-               NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 3;
-
-               have_name_font = true;
-       }
-
        group = new ArdourCanvas::Group (parent);
 
        init (it_name, spu, base_color, start, duration, vis, true, true);
@@ -135,8 +131,7 @@ TimeAxisViewItem::TimeAxisViewItem (const TimeAxisViewItem& other)
 
 void
 TimeAxisViewItem::init (
-       const string& it_name, double spu, Gdk::Color const & base_color, nframes64_t start, nframes64_t duration, Visibility vis, bool wide, bool high
-       )
+       const string& it_name, double spu, Gdk::Color const & base_color, nframes64_t start, nframes64_t duration, Visibility vis, bool wide, bool high)
 {
        item_name = it_name;
        samples_per_unit = spu;
@@ -168,38 +163,31 @@ TimeAxisViewItem::init (
 
        if (visibility & ShowFrame) {
                frame = new ArdourCanvas::SimpleRect (*group, 0.0, 1.0, trackview.editor().frame_to_pixel(duration), trackview.current_height());
+               
                frame->property_outline_pixels() = 1;
                frame->property_outline_what() = 0xF;
-               frame->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeAxisFrame.get();
-
-               /* by default draw all 4 edges */
-
-               uint32_t outline_what = 0x1|0x2|0x4|0x8;
-
-               if (visibility & HideFrameLeft) {
-                       outline_what &= ~(0x1);
-               }
-
-               if (visibility & HideFrameRight) {
-                       outline_what &= ~(0x2);
+               
+               if(_recregion){
+                       frame->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_RecordingRect.get();
                }
-
-               if (visibility & HideFrameTB) {
-                       outline_what &= ~(0x4 | 0x8);
+               else {
+                       frame->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeAxisFrame.get();
                }
-
-               frame->property_outline_what() = outline_what;
+               
+               frame->property_outline_what() = 0x1|0x2|0x4|0x8;
 
        } else {
                frame = 0;
        }
 
        if (visibility & ShowNameHighlight) {
+               
                if (visibility & FullWidthNameHighlight) {
                        name_highlight = new ArdourCanvas::SimpleRect (*group, 0.0, trackview.editor().frame_to_pixel(item_duration), trackview.current_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE, trackview.current_height() - 1);
                } else {
                        name_highlight = new ArdourCanvas::SimpleRect (*group, 1.0, trackview.editor().frame_to_pixel(item_duration) - 1, trackview.current_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE, trackview.current_height() - 1);
                }
+               
                name_highlight->set_data ("timeaxisviewitem", this);
 
        } else {
@@ -216,11 +204,14 @@ TimeAxisViewItem::init (
        }
 
        /* create our grab handles used for trimming/duration etc */
-       frame_handle_start = new ArdourCanvas::SimpleRect (*group, 0.0, TimeAxisViewItem::GRAB_HANDLE_LENGTH, 5.0, trackview.current_height());
-       frame_handle_start->property_outline_what() = 0x0;
-
-       frame_handle_end = new ArdourCanvas::SimpleRect (*group, 0.0, TimeAxisViewItem::GRAB_HANDLE_LENGTH, 5.0, trackview.current_height());
-       frame_handle_end->property_outline_what() = 0x0;
+       if (!_recregion) {
+               frame_handle_start = new ArdourCanvas::SimpleRect (*group, 0.0, TimeAxisViewItem::GRAB_HANDLE_LENGTH, 5.0, trackview.current_height());
+               frame_handle_start->property_outline_what() = 0x0;
+               frame_handle_end = new ArdourCanvas::SimpleRect (*group, 0.0, TimeAxisViewItem::GRAB_HANDLE_LENGTH, 5.0, trackview.current_height());
+               frame_handle_end->property_outline_what() = 0x0;
+       } else {
+               frame_handle_start = frame_handle_end = 0;
+       }
 
        set_color (base_color);
 
@@ -539,8 +530,10 @@ TimeAxisViewItem::set_height (double height)
 
        if (frame) {
                frame->property_y2() = height - 1;
-               frame_handle_start->property_y2() = height - 1;
-               frame_handle_end->property_y2() = height - 1;
+               if (frame_handle_start) {
+                       frame_handle_start->property_y2() = height - 1;
+                       frame_handle_end->property_y2() = height - 1;
+               }
        }
 
        vestigial_frame->property_y2() = height - 1;
@@ -761,7 +754,9 @@ TimeAxisViewItem::reset_width_dependent_items (double pixel_width)
                        frame_handle_end->hide();
                }
 
-       } if (pixel_width < 2.0) {
+       }
+
+       if (pixel_width < 2.0) {
 
                if (show_vestigial) {
                        vestigial_frame->show();