add mixbus profile which removes the tearoffs
[ardour.git] / gtk2_ardour / region_view.cc
index 530d046f5ae8d823cb1471b62a01dc099ec71380..d45164ee4279e1a17d344c30f9f2046d22996aa4 100644 (file)
@@ -33,6 +33,7 @@
 #include "canvas/pixbuf.h"
 #include "canvas/text.h"
 #include "canvas/line.h"
+#include "canvas/utils.h"
 
 #include "ardour_ui.h"
 #include "global_signals.h"
@@ -53,6 +54,7 @@
 
 using namespace std;
 using namespace ARDOUR;
+using namespace ARDOUR_UI_UTILS;
 using namespace PBD;
 using namespace Editing;
 using namespace Gtk;
@@ -62,15 +64,16 @@ static const int32_t sync_mark_width = 9;
 
 PBD::Signal1<void,RegionView*> RegionView::RegionViewGoingAway;
 
-RegionView::RegionView (ArdourCanvas::Group*              parent,
+RegionView::RegionView (ArdourCanvas::Container*              parent,
                         TimeAxisView&                     tv,
                         boost::shared_ptr<ARDOUR::Region> r,
                         double                            spu,
-                        Gdk::Color const &                basic_color,
+                        uint32_t                          basic_color,
                        bool                              automation)
        : TimeAxisViewItem (r->name(), *parent, tv, spu, basic_color, r->position(), r->length(), false, automation,
-                           TimeAxisViewItem::Visibility (TimeAxisViewItem::ShowNameText|
-                                                         TimeAxisViewItem::ShowNameHighlight| TimeAxisViewItem::ShowFrame))
+                           (automation ? TimeAxisViewItem::ShowFrame :
+                            TimeAxisViewItem::Visibility (TimeAxisViewItem::ShowNameText|
+                                                          TimeAxisViewItem::ShowNameHighlight| TimeAxisViewItem::ShowFrame)))
        , _region (r)
        , sync_mark(0)
        , sync_line(0)
@@ -126,11 +129,11 @@ RegionView::RegionView (const RegionView& other, boost::shared_ptr<Region> other
        GhostRegion::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RegionView::remove_ghost, this, _1), gui_context());
 }
 
-RegionView::RegionView (ArdourCanvas::Group*         parent,
+RegionView::RegionView (ArdourCanvas::Container*         parent,
                         TimeAxisView&                tv,
                         boost::shared_ptr<ARDOUR::Region> r,
                         double                       spu,
-                        Gdk::Color const &           basic_color,
+                        uint32_t                     basic_color,
                        bool                         recording,
                         TimeAxisViewItem::Visibility visibility)
        : TimeAxisViewItem (r->name(), *parent, tv, spu, basic_color, r->position(), r->length(), recording, false, visibility)
@@ -151,7 +154,7 @@ RegionView::RegionView (ArdourCanvas::Group*         parent,
 }
 
 void
-RegionView::init (Gdk::Color const & basic_color, bool wfd)
+RegionView::init (bool wfd)
 {
        editor        = 0;
        valid         = true;
@@ -162,25 +165,23 @@ RegionView::init (Gdk::Color const & basic_color, bool wfd)
        sync_mark     = 0;
        sync_line     = 0;
 
-       compute_colors (basic_color);
-
        if (name_highlight) {
                name_highlight->set_data ("regionview", this);
                name_highlight->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_region_view_name_highlight_event), name_highlight, this));
-
-               if (frame_handle_start) {
-                       frame_handle_start->set_data ("regionview", this);
-                       frame_handle_start->set_data ("isleft", (void*) 1);
-                       frame_handle_start->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_frame_handle_event), frame_handle_start, this));
-                       frame_handle_start->raise_to_top();
-               }
-
-               if (frame_handle_end) {
-                       frame_handle_end->set_data ("regionview", this);
-                       frame_handle_end->set_data ("isleft", (void*) 0);
-                       frame_handle_end->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_frame_handle_event), frame_handle_end, this));
-                       frame_handle_end->raise_to_top();
-               }
+       }
+       
+       if (frame_handle_start) {
+               frame_handle_start->set_data ("regionview", this);
+               frame_handle_start->set_data ("isleft", (void*) 1);
+               frame_handle_start->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_frame_handle_event), frame_handle_start, this));
+               frame_handle_start->raise_to_top();
+       }
+       
+       if (frame_handle_end) {
+               frame_handle_end->set_data ("regionview", this);
+               frame_handle_end->set_data ("isleft", (void*) 0);
+               frame_handle_end->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_frame_handle_event), frame_handle_end, this));
+               frame_handle_end->raise_to_top();
        }
 
        if (name_text) {
@@ -519,6 +520,18 @@ RegionView::set_duration (framecnt_t frames, void *src)
        return true;
 }
 
+uint32_t
+RegionView::fill_opacity () const
+{
+       if (!_region->opaque()) {
+               return 60;
+       }
+       
+       uint32_t normal_tavi_opacity = TimeAxisViewItem::fill_opacity ();
+
+       return normal_tavi_opacity;
+}
+
 void
 RegionView::set_colors ()
 {
@@ -526,35 +539,17 @@ RegionView::set_colors ()
 
        if (sync_mark) {
                /* XXX: make these colours themable */
-               sync_mark->set_fill_color (RGBA_TO_UINT (0, 255, 0, 255));
-               sync_line->set_outline_color (RGBA_TO_UINT (0, 255, 0, 255));
+               sync_mark->set_fill_color (ArdourCanvas::rgba_to_color (0, 1.0, 0, 1.0));
+               sync_line->set_outline_color (ArdourCanvas::rgba_to_color (0, 1.0, 0, 1.0));
        }
 }
 
 void
 RegionView::set_frame_color ()
 {
-       if (_region->opaque()) {
-               fill_opacity = 130;
-       } else {
-               fill_opacity = 60;
-       }
-
        TimeAxisViewItem::set_frame_color ();
 }
 
-void
-RegionView::fake_set_opaque (bool yn)
-{
-       if (yn) {
-               fill_opacity = 130;
-       } else {
-               fill_opacity = 60;
-       }
-
-       set_frame_color ();
-}
-
 void
 RegionView::show_region_editor ()
 {
@@ -637,11 +632,11 @@ RegionView::region_sync_changed ()
 
                sync_mark = new ArdourCanvas::Polygon (group);
                CANVAS_DEBUG_NAME (sync_mark, string_compose ("sync mark for %1", get_item_name()));
-               sync_mark->set_fill_color (RGBA_TO_UINT(0,255,0,255));    // FIXME make a themeable colour
+               sync_mark->set_fill_color (ArdourCanvas::rgba_to_color (0, 1.0, 0, 1.0));    // FIXME make a themeable colour
 
                sync_line = new ArdourCanvas::Line (group);
                CANVAS_DEBUG_NAME (sync_line, string_compose ("sync mark for %1", get_item_name()));
-               sync_line->set_outline_color (RGBA_TO_UINT(0,255,0,255)); // FIXME make a themeable colour
+               sync_line->set_outline_color (ArdourCanvas::rgba_to_color (0, 1.0, 0, 1.0)); // FIXME make a themeable colour
        }
 
        /* this has to handle both a genuine change of position, a change of samples_per_pixel
@@ -693,7 +688,18 @@ RegionView::move (double x_delta, double y_delta)
                return;
        }
 
-       get_canvas_group()->move (ArdourCanvas::Duple (x_delta, y_delta));
+       /* items will not prevent Item::move() moving
+        * them to a negative x-axis coordinate, which
+        * is legal, but we don't want that here.
+        */
+
+       ArdourCanvas::Item *item = get_canvas_group ();
+       
+       if (item->position().x + x_delta < 0) {
+               x_delta = -item->position().x; /* move it to zero */
+       }
+
+       item->move (ArdourCanvas::Duple (x_delta, y_delta));
 
        /* note: ghosts never leave their tracks so y_delta for them is always zero */
 
@@ -728,12 +734,6 @@ RegionView::remove_ghost (GhostRegion* ghost)
        }
 }
 
-uint32_t
-RegionView::get_fill_color ()
-{
-       return fill_color;
-}
-
 void
 RegionView::set_height (double h)
 {