Shut up.
[ardour.git] / gtk2_ardour / time_axis_view_item.cc
index f4316efd879ec785692a84661a3bf6f18f9635d3..1e75a7845ea5f1d6d4c60a76844c052dc36b1754 100644 (file)
 
 */
 
-#include <pbd/error.h>
-#include <pbd/stacktrace.h>
+#include "pbd/error.h"
+#include "pbd/stacktrace.h"
 
-#include <ardour/types.h>
-#include <ardour/ardour.h>
+#include "ardour/types.h"
+#include "ardour/ardour.h"
 
 #include <gtkmm2ext/utils.h>
 
@@ -70,9 +70,9 @@ double TimeAxisViewItem::NAME_HIGHLIGHT_THRESH;
  * @param duration the duration of this item
  */
 TimeAxisViewItem::TimeAxisViewItem(const string & it_name, ArdourCanvas::Group& parent, TimeAxisView& tv, double spu, Gdk::Color& base_color, 
-                                  nframes_t start, nframes_t duration,
+                                  nframes_t start, nframes_t duration, bool recording,
                                   Visibility vis)
-       : trackview (tv)
+       : trackview (tv), _recregion(recording)
 {
        if (!have_name_font) {
 
@@ -105,7 +105,8 @@ TimeAxisViewItem::TimeAxisViewItem(const string & it_name, ArdourCanvas::Group&
 }
 
 TimeAxisViewItem::TimeAxisViewItem (const TimeAxisViewItem& other)
-       : trackview (other.trackview)
+       : sigc::trackable(other)
+       , trackview (other.trackview)
 {
 
        Gdk::Color c;
@@ -135,7 +136,7 @@ TimeAxisViewItem::init (const string& it_name, double spu, Gdk::Color& base_colo
        frame_position = start ;
        item_duration = duration ;
        name_connected = false;
-       // why? fill_opacity = 60;
+       fill_opacity = 60;
        position_locked = false ;
        max_item_duration = ARDOUR::max_frames;
        min_item_duration = 0 ;
@@ -150,8 +151,8 @@ TimeAxisViewItem::init (const string& it_name, double spu, Gdk::Color& base_colo
        vestigial_frame = new ArdourCanvas::SimpleRect (*group);
        vestigial_frame->property_x1() = (double) 0.0;
        vestigial_frame->property_y1() = (double) 1.0;
-       vestigial_frame->property_x2() = 2.0;
-       vestigial_frame->property_y2() = (double) trackview.height;
+       vestigial_frame->property_x2() = (double) 2.0;
+       vestigial_frame->property_y2() = (double) trackview.current_height();
        vestigial_frame->property_outline_what() = 0xF;
        vestigial_frame->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_VestigialFrame.get();
        vestigial_frame->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_VestigialFrame.get();
@@ -161,11 +162,11 @@ TimeAxisViewItem::init (const string& it_name, double spu, Gdk::Color& base_colo
                frame = new ArdourCanvas::SimpleRect (*group);
                frame->property_x1() = (double) 0.0;
                frame->property_y1() = (double) 1.0;
-               frame->property_x2() = (double) trackview.editor.frame_to_pixel(duration);
-               frame->property_y2() = (double) trackview.height;
+               frame->property_x2() = (double) trackview.editor().frame_to_pixel(duration);
+               frame->property_y2() = (double) trackview.current_height();
+               frame->property_outline_pixels() = 1;
                frame->property_outline_what() = 0xF;
                frame->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeAxisFrame.get();
-               frame->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeAxisFrame.get();
 
                /* by default draw all 4 edges */
 
@@ -193,15 +194,13 @@ TimeAxisViewItem::init (const string& it_name, double spu, Gdk::Color& base_colo
                name_highlight = new ArdourCanvas::SimpleRect (*group);
                if (visibility & FullWidthNameHighlight) {
                        name_highlight->property_x1() = (double) 0.0;
-                       name_highlight->property_x2() = (double) (trackview.editor.frame_to_pixel(item_duration));
+                       name_highlight->property_x2() = (double) (trackview.editor().frame_to_pixel(item_duration));
                } else {
                        name_highlight->property_x1() = (double) 1.0;
-                       name_highlight->property_x2() = (double) (trackview.editor.frame_to_pixel(item_duration)) - 1;
+                       name_highlight->property_x2() = (double) (trackview.editor().frame_to_pixel(item_duration)) - 1;
                }
-               name_highlight->property_y1() = (double) (trackview.height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE);
-               name_highlight->property_y2() = (double) (trackview.height - 1);
-               name_highlight->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_NameHighlightFill.get();
-               name_highlight->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_NameHighlightOutline.get();
+               name_highlight->property_y1() = (double) (trackview.current_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE);
+               name_highlight->property_y2() = (double) (trackview.current_height() - 1);
 
                name_highlight->set_data ("timeaxisviewitem", this);
 
@@ -212,10 +211,10 @@ TimeAxisViewItem::init (const string& it_name, double spu, Gdk::Color& base_colo
        if (visibility & ShowNameText) {
                name_text = new ArdourCanvas::Text (*group);
                name_text->property_x() = (double) TimeAxisViewItem::NAME_X_OFFSET;
-               /* trackview.height is the bottom of the trackview. subtract 1 to get back to the bottom of the highlight,
+               /* trackview.current_height() is the bottom of the trackview. subtract 1 to get back to the bottom of the highlight,
                   then NAME_Y_OFFSET to position the text in the vertical center of the highlight
                */
-               name_text->property_y() = (double) trackview.height - 1.0 - TimeAxisViewItem::NAME_Y_OFFSET;
+               name_text->property_y() = (double) trackview.current_height() - 1.0 - TimeAxisViewItem::NAME_Y_OFFSET;
                name_text->property_font_desc() = *NAME_FONT;
                name_text->property_anchor() = Gtk::ANCHOR_NW;
 
@@ -234,15 +233,13 @@ TimeAxisViewItem::init (const string& it_name, double spu, Gdk::Color& base_colo
                frame_handle_start->property_y1() = (double) 1.0;
                frame_handle_start->property_y2() = (double) TimeAxisViewItem::GRAB_HANDLE_LENGTH+1;
                frame_handle_start->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_FrameHandle.get();
-               frame_handle_start->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_FrameHandle.get();
-               
+
                frame_handle_end = new ArdourCanvas::SimpleRect (*group);
-               frame_handle_end->property_x1() = (double) (trackview.editor.frame_to_pixel(get_duration())) - (TimeAxisViewItem::GRAB_HANDLE_LENGTH);
-               frame_handle_end->property_x2() = (double) trackview.editor.frame_to_pixel(get_duration());
+               frame_handle_end->property_x1() = (double) (trackview.editor().frame_to_pixel(get_duration())) - (TimeAxisViewItem::GRAB_HANDLE_LENGTH);
+               frame_handle_end->property_x2() = (double) trackview.editor().frame_to_pixel(get_duration());
                frame_handle_end->property_y1() = (double) 1;
                frame_handle_end->property_y2() = (double) TimeAxisViewItem::GRAB_HANDLE_LENGTH + 1;
                frame_handle_end->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_FrameHandle.get();
-               frame_handle_end->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_FrameHandle.get();
 
        } else {
                frame_handle_start = 0;
@@ -343,7 +340,7 @@ TimeAxisViewItem::set_duration (nframes_t dur, void* src)
 
        item_duration = dur;
        
-       reset_width_dependent_items (trackview.editor.frame_to_pixel (dur));
+       reset_width_dependent_items (trackview.editor().frame_to_pixel (dur));
        
        DurationChanged (dur, src) ; /* EMIT_SIGNAL */
        return true;
@@ -571,16 +568,15 @@ TimeAxisViewItem::set_name_text(const ustring& new_name)
 }
 
 /**
- * Set the y position and height of this item.
+ * Set the height of this item
  *
- * @param y the new y position
  * @param h the new height
  */            
 void
-TimeAxisViewItem::set_y_position_and_height (double y, double h)
+TimeAxisViewItem::set_height (double height)
 {
        if (name_highlight) {
-               if (h < NAME_HIGHLIGHT_THRESH) {
+               if (height < NAME_HIGHLIGHT_THRESH) {
                        name_highlight->hide();
                        if (name_text) {
                                name_text->hide();
@@ -592,20 +588,20 @@ TimeAxisViewItem::set_y_position_and_height (double y, double h)
                        }
                }
 
-               if (h > NAME_HIGHLIGHT_SIZE) {
-                       name_highlight->property_y1() = (double) y + h + 1 - NAME_HIGHLIGHT_SIZE;
-                       name_highlight->property_y2() = (double) y + h;
+               if (height > NAME_HIGHLIGHT_SIZE) {
+                       name_highlight->property_y1() = (double) height+1 - NAME_HIGHLIGHT_SIZE;
+                       name_highlight->property_y2() = (double) height;
                }
                else {
                        /* it gets hidden now anyway */
-                       name_highlight->property_y1() = (double) y;
-                       name_highlight->property_y2() = (double) y + h;
+                       name_highlight->property_y1() = (double) 1.0;
+                       name_highlight->property_y2() = (double) height;
                }
        }
 
        if (name_text) {
-               name_text->property_y() = y + h + 1 - NAME_Y_OFFSET;
-               if (h < NAME_HIGHLIGHT_THRESH) {
+               name_text->property_y() = height+1 - NAME_Y_OFFSET;
+               if (height < NAME_HIGHLIGHT_THRESH) {
                        name_text->property_fill_color_rgba() =  fill_color;
                }
                else {
@@ -614,12 +610,10 @@ TimeAxisViewItem::set_y_position_and_height (double y, double h)
        }
 
        if (frame) {
-               frame->property_y1() = y;
-               frame->property_y2() = y + h + 1;
+               frame->property_y2() = height+1;
        }
 
-       vestigial_frame->property_y1() = y;
-       vestigial_frame->property_y2() = y + h + 1;
+       vestigial_frame->property_y2() = height+1;
 }
 
 /**
@@ -644,7 +638,7 @@ TimeAxisViewItem::get_canvas_frame()
 /**
  * 
  */
-ArdourCanvas::Item*
+ArdourCanvas::Group*
 TimeAxisViewItem::get_canvas_group()
 {
        return (group) ;
@@ -804,8 +798,13 @@ TimeAxisViewItem::set_frame_color()
                        UINT_TO_RGBA(ARDOUR_UI::config()->canvasvar_SelectedFrameBase.get(), &r, &g, &b, &a);
                        frame->property_fill_color_rgba() = RGBA_TO_UINT(r, g, b, a);
                } else {
-                       UINT_TO_RGBA(ARDOUR_UI::config()->canvasvar_FrameBase.get(), &r, &g, &b, &a);
-                       frame->property_fill_color_rgba() = RGBA_TO_UINT(r, g, b, a);
+                       if (_recregion) {
+                               UINT_TO_RGBA(ARDOUR_UI::config()->canvasvar_RecordingRect.get(), &r, &g, &b, &a);
+                               frame->property_fill_color_rgba() = RGBA_TO_UINT(r, g, b, a);
+                       } else {
+                               UINT_TO_RGBA(ARDOUR_UI::config()->canvasvar_FrameBase.get(), &r, &g, &b, &a);
+                               frame->property_fill_color_rgba() = RGBA_TO_UINT(r, g, b, fill_opacity ? fill_opacity : a);
+                       }
                }
        }
 }
@@ -1049,3 +1048,15 @@ TimeAxisViewItem::idle_remove_this_item(TimeAxisViewItem* item, void* src)
        item = 0;
        return false;
 }
+
+void
+TimeAxisViewItem::set_y (double y)
+{
+       double const old = group->property_y ();
+       if (y != old) {
+               group->move (0, y - old);
+       }
+}
+
+
+