From 50fea864dbbba2a6be3ddf3346afce5d1778902e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 13 Jun 2014 10:56:46 -0400 Subject: rationalize and coordinate handle of region (time axis view item) opacity. There are still some bugs with this because of the waveview image cache - fixes coming soon. --- gtk2_ardour/time_axis_view_item.cc | 77 +++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 39 deletions(-) (limited to 'gtk2_ardour/time_axis_view_item.cc') diff --git a/gtk2_ardour/time_axis_view_item.cc b/gtk2_ardour/time_axis_view_item.cc index b6ae21668a..e3b302f975 100644 --- a/gtk2_ardour/time_axis_view_item.cc +++ b/gtk2_ardour/time_axis_view_item.cc @@ -167,7 +167,6 @@ TimeAxisViewItem::init (ArdourCanvas::Group* parent, double fpp, uint32_t base_c group->Event.connect (sigc::mem_fun (*this, &TimeAxisViewItem::canvas_group_event)); fill_color = base_color; - pre_drag_fill_color = base_color; samples_per_pixel = fpp; frame_position = start; item_duration = duration; @@ -280,7 +279,6 @@ TimeAxisViewItem::init (ArdourCanvas::Group* parent, double fpp, uint32_t base_c } set_color (base_color); - set_opacity_for_drag (false); set_duration (item_duration, this); set_position (start, this); @@ -666,11 +664,7 @@ TimeAxisViewItem::get_name_highlight() void TimeAxisViewItem::set_colors() { - /* we cannot be dragging this item when changing colors, - so reuse set_opacity_for_drag() - */ - set_opacity_for_drag (false); - set_frame_color(); + set_frame_color (); if (name_highlight) { name_highlight->set_fill_color (fill_color); @@ -705,19 +699,39 @@ TimeAxisViewItem::set_name_text_color () name_text->set_color (contrasting_text_color (f)); } +uint32_t +TimeAxisViewItem::fill_opacity () const +{ + if (!rect_visible) { + /* if the frame/rect is marked as invisible, then the + * fill should be transparent. simplest: set + + * alpha/opacity to zero. + */ + return 0; + } + + if (_dragging) { + return 130; + } + + uint32_t col = ARDOUR_UI::config()->get_canvasvar_FrameBase(); + return UINT_RGBA_A (col); +} + uint32_t TimeAxisViewItem::get_fill_color () const { uint32_t f; uint32_t o; + o = fill_opacity (); + if (_selected) { f = ARDOUR_UI::config()->get_canvasvar_SelectedFrameBase(); - if (fill_opacity != 0) { - o = fill_opacity; - } else { + if (o == 0) { /* some condition of this item has set fill opacity to * zero, but it has been selected, so use a mid-way * alpha value to make it reasonably visible. @@ -732,23 +746,10 @@ TimeAxisViewItem::get_fill_color () const } else { if ((!Config->get_show_name_highlight() || high_enough_for_name) && !ARDOUR_UI::config()->get_color_regions_using_track_color()) { f = ARDOUR_UI::config()->get_canvasvar_FrameBase(); - /* use the opacity as set for the FrameBase color */ - o = UINT_RGBA_A (f); } else { f = fill_color; - o = fill_opacity; } } - - /* tweak opacity */ - - if (!rect_visible) { - /* if the frame/rect is marked as invisible, then the - * fill should be transparent. simplest: set - * alpha/opacity to zero. - */ - o = 0; - } } return UINT_RGBA_CHANGE_A (f, o); @@ -785,22 +786,6 @@ TimeAxisViewItem::set_frame_color() } } -void -TimeAxisViewItem::set_opacity_for_drag (bool drag_starting) -{ - if (drag_starting) { - fill_opacity = 130; - } else { - /* use the alpha/opacity value from the basic color, no matter whether - we use the color of our time axis or not. - */ - - uint32_t col = ARDOUR_UI::config()->get_canvasvar_FrameBase(); - fill_opacity = UINT_RGBA_A (col); - } - set_frame_color (); -} - void TimeAxisViewItem::set_frame_gradient () { @@ -1017,3 +1002,17 @@ TimeAxisViewItem::parameter_changed (string p) set_frame_gradient (); } } + +void +TimeAxisViewItem::drag_start () +{ + _dragging = true; + set_frame_color (); +} + +void +TimeAxisViewItem::drag_end () +{ + _dragging = false; + set_frame_color (); +} -- cgit v1.2.3