X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fregion_view.cc;h=d45164ee4279e1a17d344c30f9f2046d22996aa4;hb=9f4a00fa898845ba177955f115fa2f96d62a8643;hp=127ce79b8462636498e832e890e509a3f3ea2a2d;hpb=8c9749e42faf7808034ed8b7afce4a2fe6dc6f33;p=ardour.git diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index 127ce79b84..d45164ee42 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -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,11 +64,11 @@ static const int32_t sync_mark_width = 9; PBD::Signal1 RegionView::RegionViewGoingAway; -RegionView::RegionView (ArdourCanvas::Group* parent, +RegionView::RegionView (ArdourCanvas::Container* parent, TimeAxisView& tv, boost::shared_ptr 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, (automation ? TimeAxisViewItem::ShowFrame : @@ -127,11 +129,11 @@ RegionView::RegionView (const RegionView& other, boost::shared_ptr 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 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) @@ -152,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; @@ -163,8 +165,6 @@ 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)); @@ -520,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 () { @@ -527,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 () { @@ -638,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 @@ -694,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 */ @@ -729,12 +734,6 @@ RegionView::remove_ghost (GhostRegion* ghost) } } -uint32_t -RegionView::get_fill_color () -{ - return fill_color; -} - void RegionView::set_height (double h) {