just use show() and hide() to manage control point visibility in automation lines

No need for the wierd old set_visible()/property_draw() stuff that was a hangover from gnomecanvas.
This commit is contained in:
Paul Davis 2013-12-31 11:55:30 -05:00
parent e7059e5a16
commit 87c29025de
4 changed files with 12 additions and 20 deletions

View File

@ -148,16 +148,19 @@ AutomationLine::show ()
if (_visible & ControlPoints) {
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
(*i)->set_visible (true);
(*i)->show ();
}
} else if (_visible & SelectedControlPoints) {
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
(*i)->set_visible ((*i)->get_selected());
if ((*i)->get_selected()) {
(*i)->show ();
} else {
(*i)->hide ();
}
}
} else {
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
(*i)->set_visible (false);
(*i)->hide ();
}
}
}
@ -1215,9 +1218,8 @@ AutomationLine::add_visible_control_point (uint32_t view_index, uint32_t pi, dou
if (_visible & ControlPoints) {
control_points[view_index]->show ();
control_points[view_index]->set_visible (true);
} else {
control_points[view_index]->set_visible (false);
control_points[view_index]->hide ();
}
}

View File

@ -44,7 +44,6 @@ ControlPoint::ControlPoint (AutomationLine& al)
_size = 4.0;
_item = new ArdourCanvas::Rectangle (&_line.canvas_group());
_item->property_draw() = true;
_item->set_fill (false);
_item->set_fill_color (ARDOUR_UI::config()->get_canvasvar_ControlPointFill());
_item->set_outline_color (ARDOUR_UI::config()->get_canvasvar_ControlPointOutline());
@ -52,7 +51,6 @@ ControlPoint::ControlPoint (AutomationLine& al)
_item->Event.connect (sigc::mem_fun (this, &ControlPoint::event_handler));
hide ();
set_visible (false);
}
ControlPoint::ControlPoint (const ControlPoint& other, bool /*dummy_arg_to_force_special_copy_constructor*/)
@ -77,7 +75,6 @@ ControlPoint::ControlPoint (const ControlPoint& other, bool /*dummy_arg_to_force
/* NOTE: no event handling in copied ControlPoints */
hide ();
set_visible (false);
}
ControlPoint::~ControlPoint ()
@ -105,16 +102,10 @@ ControlPoint::show()
_item->show();
}
void
ControlPoint::set_visible (bool yn)
{
_item->property_draw() = (gboolean) yn;
}
bool
ControlPoint::visible () const
{
return _item->property_draw ();
return _item->visible ();
}
void

View File

@ -60,15 +60,14 @@ class ControlPoint : public Selectable
void hide ();
void show ();
void set_color ();
bool visible () const;
double size () const {
return _size;
}
void set_size (double);
void set_visible (bool);
bool visible () const;
void set_color ();
bool can_slide() const { return _can_slide; }
void set_can_slide(bool yn) { _can_slide = yn; }

View File

@ -1833,7 +1833,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_
case ControlPointItem:
if (mouse_mode == MouseGain || mouse_mode == MouseObject) {
cp = static_cast<ControlPoint*>(item->get_data ("control_point"));
cp->set_visible (true);
cp->show ();
double at_x, at_y;
at_x = cp->get_x();
@ -2055,7 +2055,7 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent*, ItemType item_type)
cp = reinterpret_cast<ControlPoint*>(item->get_data ("control_point"));
if (cp->line().the_list()->interpolation() != AutomationList::Discrete) {
if (cp->line().npoints() > 1 && !cp->get_selected()) {
cp->set_visible (false);
cp->hide ();
}
}