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.

Conflicts:
	gtk2_ardour/time_axis_view_item.cc
This commit is contained in:
Paul Davis 2014-06-13 10:56:46 -04:00
parent 3bde595378
commit c5d29d59b5
6 changed files with 57 additions and 63 deletions

View file

@ -743,7 +743,6 @@ RegionMotionDrag::motion (GdkEvent* event, bool first_move)
if (first_move) { if (first_move) {
rv->drag_start (); rv->drag_start ();
rv->set_opacity_for_drag (true);
/* reparent the regionview into a group above all /* reparent the regionview into a group above all
* others * others
@ -938,10 +937,6 @@ RegionMoveDrag::motion (GdkEvent* event, bool first_move)
void void
RegionMotionDrag::finished (GdkEvent *, bool) RegionMotionDrag::finished (GdkEvent *, bool)
{ {
for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
i->view->set_opacity_for_drag (false);
}
for (vector<TimeAxisView*>::iterator i = _time_axis_views.begin(); i != _time_axis_views.end(); ++i) { for (vector<TimeAxisView*>::iterator i = _time_axis_views.begin(); i != _time_axis_views.end(); ++i) {
if (!(*i)->view()) { if (!(*i)->view()) {
continue; continue;
@ -1200,7 +1195,7 @@ RegionMoveDrag::finished_no_copy (
visible. visible.
*/ */
rv->hide_region_editor(); rv->hide_region_editor();
rv->set_opacity_for_drag (false);
remove_region_from_playlist (rv->region(), i->initial_playlist, modified_playlists); remove_region_from_playlist (rv->region(), i->initial_playlist, modified_playlists);
@ -1435,7 +1430,6 @@ RegionMotionDrag::aborted (bool)
rv->get_canvas_group()->reparent (rtv->view()->canvas_item()); rv->get_canvas_group()->reparent (rtv->view()->canvas_item());
rv->get_canvas_group()->set_y_position (0); rv->get_canvas_group()->set_y_position (0);
rv->drag_end (); rv->drag_end ();
rv->set_opacity_for_drag (false);
rv->move (-_total_x_delta, 0); rv->move (-_total_x_delta, 0);
rv->set_height (rtv->view()->child_height ()); rv->set_height (rtv->view()->child_height ());
} }
@ -2070,7 +2064,6 @@ VideoTimeLineDrag::motion (GdkEvent* event, bool first_move)
DEBUG_TRACE (DEBUG::Drags, string_compose("SHIFT REGION at %1 by %2\n", i->initial_position, dt)); DEBUG_TRACE (DEBUG::Drags, string_compose("SHIFT REGION at %1 by %2\n", i->initial_position, dt));
if (first_move) { if (first_move) {
rv->drag_start (); rv->drag_start ();
rv->set_opacity_for_drag (true);
rv->region()->clear_changes (); rv->region()->clear_changes ();
rv->region()->suspend_property_changes(); rv->region()->suspend_property_changes();
} }
@ -2118,7 +2111,6 @@ VideoTimeLineDrag::finished (GdkEvent * /*event*/, bool movement_occurred)
for (list<AVDraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) { for (list<AVDraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
i->view->drag_end(); i->view->drag_end();
i->view->set_opacity_for_drag (false);
i->view->region()->resume_property_changes (); i->view->region()->resume_property_changes ();
_editor->session()->add_command (new StatefulDiffCommand (i->view->region())); _editor->session()->add_command (new StatefulDiffCommand (i->view->region()));
@ -2254,7 +2246,6 @@ TrimDrag::motion (GdkEvent* event, bool first_move)
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) { for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
RegionView* rv = i->view; RegionView* rv = i->view;
rv->set_opacity_for_drag (false);
rv->enable_display (false); rv->enable_display (false);
rv->region()->playlist()->clear_owned_changes (); rv->region()->playlist()->clear_owned_changes ();
@ -2437,7 +2428,6 @@ TrimDrag::finished (GdkEvent* event, bool movement_occurred)
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) { for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
i->view->thaw_after_trim (); i->view->thaw_after_trim ();
i->view->enable_display (true); i->view->enable_display (true);
i->view->set_opacity_for_drag (true);
/* Trimming one region may affect others on the playlist, so we need /* Trimming one region may affect others on the playlist, so we need
to get undo Commands from the whole playlist rather than just the to get undo Commands from the whole playlist rather than just the

View file

@ -519,6 +519,18 @@ RegionView::set_duration (framecnt_t frames, void *src)
return true; 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 void
RegionView::set_colors () RegionView::set_colors ()
{ {
@ -534,14 +546,6 @@ RegionView::set_colors ()
void void
RegionView::set_frame_color () RegionView::set_frame_color ()
{ {
if (!frame) {
return;
}
if (!_region->opaque()) {
fill_opacity = 60;
}
TimeAxisViewItem::set_frame_color (); TimeAxisViewItem::set_frame_color ();
} }

View file

@ -154,6 +154,8 @@ class RegionView : public TimeAxisViewItem
virtual void set_frame_color (); virtual void set_frame_color ();
virtual void reset_width_dependent_items (double pixel_width); virtual void reset_width_dependent_items (double pixel_width);
uint32_t fill_opacity () const;
virtual void color_handler () {} virtual void color_handler () {}
boost::shared_ptr<ARDOUR::Region> _region; boost::shared_ptr<ARDOUR::Region> _region;

View file

@ -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)); group->Event.connect (sigc::mem_fun (*this, &TimeAxisViewItem::canvas_group_event));
fill_color = base_color; fill_color = base_color;
pre_drag_fill_color = base_color;
samples_per_pixel = fpp; samples_per_pixel = fpp;
frame_position = start; frame_position = start;
item_duration = duration; item_duration = duration;
@ -280,7 +279,6 @@ TimeAxisViewItem::init (ArdourCanvas::Group* parent, double fpp, uint32_t base_c
} }
set_color (base_color); set_color (base_color);
set_opacity_for_drag (false);
set_duration (item_duration, this); set_duration (item_duration, this);
set_position (start, this); set_position (start, this);
@ -666,11 +664,7 @@ TimeAxisViewItem::get_name_highlight()
void void
TimeAxisViewItem::set_colors() TimeAxisViewItem::set_colors()
{ {
/* we cannot be dragging this item when changing colors, set_frame_color ();
so reuse set_opacity_for_drag()
*/
set_opacity_for_drag (false);
set_frame_color();
if (name_highlight) { if (name_highlight) {
name_highlight->set_fill_color (fill_color); name_highlight->set_fill_color (fill_color);
@ -705,19 +699,39 @@ TimeAxisViewItem::set_name_text_color ()
name_text->set_color (contrasting_text_color (f)); 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 uint32_t
TimeAxisViewItem::get_fill_color () const TimeAxisViewItem::get_fill_color () const
{ {
uint32_t f; uint32_t f;
uint32_t o; uint32_t o;
o = fill_opacity ();
if (_selected) { if (_selected) {
f = ARDOUR_UI::config()->get_canvasvar_SelectedFrameBase(); f = ARDOUR_UI::config()->get_canvasvar_SelectedFrameBase();
if (fill_opacity != 0) { if (o == 0) {
o = fill_opacity;
} else {
/* some condition of this item has set fill opacity to /* some condition of this item has set fill opacity to
* zero, but it has been selected, so use a mid-way * zero, but it has been selected, so use a mid-way
* alpha value to make it reasonably visible. * alpha value to make it reasonably visible.
@ -732,23 +746,10 @@ TimeAxisViewItem::get_fill_color () const
} else { } else {
if ((!Config->get_show_name_highlight() || high_enough_for_name) && !ARDOUR_UI::config()->get_color_regions_using_track_color()) { 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(); f = ARDOUR_UI::config()->get_canvasvar_FrameBase();
/* use the opacity as set for the FrameBase color */
o = UINT_RGBA_A (f);
} else { } else {
f = fill_color; f = fill_color;
o = 0xff; // Valeriy changed this from '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); return UINT_RGBA_CHANGE_A (f, o);
@ -786,22 +787,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 void
TimeAxisViewItem::set_frame_gradient () TimeAxisViewItem::set_frame_gradient ()
{ {
@ -1018,3 +1003,17 @@ TimeAxisViewItem::parameter_changed (string p)
set_frame_gradient (); set_frame_gradient ();
} }
} }
void
TimeAxisViewItem::drag_start ()
{
_dragging = true;
set_frame_color ();
}
void
TimeAxisViewItem::drag_end ()
{
_dragging = false;
set_frame_color ();
}

View file

@ -74,7 +74,6 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList
void set_y (double); void set_y (double);
void set_color (uint32_t); void set_color (uint32_t);
void set_name_text_color (); void set_name_text_color ();
void set_opacity_for_drag (bool drag_starting);
uint32_t get_fill_color () const; uint32_t get_fill_color () const;
@ -86,8 +85,8 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList
double get_samples_per_pixel () const; double get_samples_per_pixel () const;
virtual void drag_start() { _dragging = true; } virtual void drag_start();
virtual void drag_end() { _dragging = false; } virtual void drag_end();
bool dragging() const { return _dragging; } bool dragging() const { return _dragging; }
virtual void raise () { return; } virtual void raise () { return; }
@ -230,9 +229,9 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList
/** true if a small vestigial rect should be shown when the item gets very narrow */ /** true if a small vestigial rect should be shown when the item gets very narrow */
bool show_vestigial; bool show_vestigial;
uint32_t fill_opacity;
uint32_t fill_color; uint32_t fill_color;
uint32_t pre_drag_fill_color;
virtual uint32_t fill_opacity() const;
uint32_t last_item_width; uint32_t last_item_width;
int name_text_width; int name_text_width;