Some cleanups to drawing of automation line control points. Drag all selected automation points if one selected point is dragged.

git-svn-id: svn://localhost/ardour2/branches/3.0@6437 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-01-03 00:08:58 +00:00
parent c88716665a
commit 0f79f67398
9 changed files with 67 additions and 91 deletions

View File

@ -9,10 +9,6 @@
<Option name="automation track outline" value="282828ff"/>
<Option name="cd marker bar" value="9496a3ff"/>
<Option name="clipped waveform" value="ff0000e5"/>
<Option name="control point fill" value="ffffff66"/>
<Option name="control point outline" value="ffffffaa"/>
<Option name="control point selected" value="00ff00ff"/>
<Option name="control point" value="ff0000ff"/>
<Option name="crossfade editor base" value="282d49ff"/>
<Option name="crossfade editor line shading" value="00a0d154"/>
<Option name="crossfade editor line" value="000000ff"/>
@ -22,9 +18,9 @@
<Option name="crossfade line" value="000000ff"/>
<Option name="edit point" value="0000ffff"/>
<Option name="entered automation line" value="dd6363ff"/>
<Option name="entered control point outline" value="ff0000ee"/>
<Option name="entered control point selected" value="ff3535ff"/>
<Option name="entered control point" value="ffffffaa"/>
<Option name="control point fill" value="ffffff66"/>
<Option name="control point outline" value="ff0000ee"/>
<Option name="control point selected" value="55ccccff"/>
<Option name="entered gain line" value="dd6363ff"/>
<Option name="entered marker" value="dd6363ff"/>
<Option name="frame handle" value="7c00ff96"/>

View File

@ -592,7 +592,6 @@ AutomationLine::determine_visible_control_points (ALPoints& points)
}
set_selected_points (trackview.editor().get_selection().points);
}
string
@ -672,7 +671,9 @@ AutomationLine::invalidate_point (ALPoints& p, uint32_t index)
p[index].y = DBL_MAX;
}
/** Start dragging a single point.
/** Start dragging a single point, possibly adding others if the supplied point is selected and there
* are other selected points.
*
* @param cp Point to drag.
* @param x Initial x position (frames).
* @param fraction Initial y position (as a fraction of the track height, where 0 is the bottom and 1 the top)
@ -685,6 +686,15 @@ AutomationLine::start_drag_single (ControlPoint* cp, nframes_t x, float fraction
_drag_points.clear ();
_drag_points.push_back (cp);
if (cp->selected ()) {
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
if (*i != cp && (*i)->selected()) {
_drag_points.push_back (*i);
}
}
}
start_drag_common (x, fraction);
}
@ -1034,7 +1044,7 @@ AutomationLine::set_selected_points (PointSelection& points)
double bot;
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
(*i)->set_selected(false);
(*i)->set_selected(false);
}
if (points.empty()) {
@ -1071,51 +1081,17 @@ AutomationLine::set_selected_points (PointSelection& points)
}
out:
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
(*i)->show_color (false, !points_visible);
}
set_colors ();
}
void AutomationLine::set_colors()
void AutomationLine::set_colors ()
{
set_line_color (ARDOUR_UI::config()->canvasvar_AutomationLine.get());
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
(*i)->show_color (false, !points_visible);
(*i)->set_color ();
}
}
void
AutomationLine::show_selection ()
{
TimeSelection& time (trackview.editor().get_selection().time);
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
(*i)->set_selected(false);
for (list<AudioRange>::iterator r = time.begin(); r != time.end(); ++r) {
double rstart, rend;
rstart = trackview.editor().frame_to_unit ((*r).start);
rend = trackview.editor().frame_to_unit ((*r).end);
if ((*i)->get_x() >= rstart && (*i)->get_x() <= rend) {
(*i)->set_selected(true);
break;
}
}
(*i)->show_color (false, !points_visible);
}
}
void
AutomationLine::hide_selection ()
{
// show_selection ();
}
void
AutomationLine::list_changed ()
{
@ -1201,9 +1177,10 @@ AutomationLine::show_all_control_points ()
points_visible = true;
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
(*i)->show_color((_interpolation != AutomationList::Discrete), false);
(*i)->show ();
(*i)->set_visible (true);
if (!(*i)->visible()) {
(*i)->show ();
(*i)->set_visible (true);
}
}
}

View File

@ -104,9 +104,6 @@ class AutomationLine : public sigc::trackable, public PBD::StatefulDestructible
ArdourCanvas::Item& parent_group() const { return _parent_group; }
ArdourCanvas::Item& grab_item() const { return *line; }
void show_selection();
void hide_selection ();
std::string get_verbose_cursor_string (double) const;
std::string fraction_to_string (double) const;
double string_to_fraction (std::string const &) const;

View File

@ -816,8 +816,9 @@ AutomationTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectabl
void
AutomationTimeAxisView::set_selected_points (PointSelection& points)
{
if (_line)
if (_line) {
_line->set_selected_points (points);
}
}
void

View File

@ -20,7 +20,6 @@ enum {
PROP_FILL_COLOR_RGBA,
PROP_OUTLINE_COLOR_RGBA,
PROP_DRAW
};
static void gnome_canvas_simplerect_class_init (GnomeCanvasSimpleRectClass *class);
@ -255,7 +254,6 @@ gnome_canvas_simplerect_bounds (GnomeCanvasItem *item, double *x1, double *y1, d
*y1 = simplerect->y1;
*x2 = simplerect->x2 + 1;
*y2 = simplerect->y2 + 1;
}
@ -456,7 +454,23 @@ gnome_canvas_simplerect_set_property (GObject *object,
break;
}
simplerect->full_draw_on_update = update;
if (!simplerect->full_draw_on_update) {
/* XXX: not sure about this;
*
* I changed the next line to be conditional, rather than always
* being executed. Without the condition, the following bug occurs:
*
* caller sets a property (e.g. outline colour); this sets update = TRUE and hence full_draw_on_update = TRUE
* update is requested (and it is intended, I suppose, that during this update, full_draw_on_update is noted)
* ... update does not occur before ...
* caller sets the same property again to the same value; this sets update = FALSE and hence full_draw_on_update = FALSE
* update now occurs, but full_draw_on_update is FALSE, so the full redraw does not happen,
* which results in graphical glitches.
*
* (Carl, 2/1/2010)
*/
simplerect->full_draw_on_update = update;
}
if (update || bounds_changed) {
gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(object));

View File

@ -6,10 +6,6 @@ CANVAS_VARIABLE(canvasvar_AutomationLine, "automation line")
CANVAS_VARIABLE(canvasvar_AutomationTrackFill, "automation track fill")
CANVAS_VARIABLE(canvasvar_AutomationTrackOutline, "automation track outline")
CANVAS_VARIABLE(canvasvar_CDMarkerBar, "cd marker bar")
CANVAS_VARIABLE(canvasvar_ControlPoint, "control point")
CANVAS_VARIABLE(canvasvar_ControlPointFill, "control point fill")
CANVAS_VARIABLE(canvasvar_ControlPointOutline, "control point outline")
CANVAS_VARIABLE(canvasvar_ControlPointSelected, "control point selected")
CANVAS_VARIABLE(canvasvar_CrossfadeEditorBase, "crossfade editor base")
CANVAS_VARIABLE(canvasvar_CrossfadeEditorLine, "crossfade editor line")
CANVAS_VARIABLE(canvasvar_CrossfadeEditorLineShading, "crossfade editor line shading")
@ -20,9 +16,9 @@ CANVAS_VARIABLE(canvasvar_SelectedCrossfadeEditorWaveFill, "selected crossfade e
CANVAS_VARIABLE(canvasvar_CrossfadeLine, "crossfade line")
CANVAS_VARIABLE(canvasvar_EditPoint, "edit point")
CANVAS_VARIABLE(canvasvar_EnteredAutomationLine, "entered automation line")
CANVAS_VARIABLE(canvasvar_EnteredControlPoint, "entered control point")
CANVAS_VARIABLE(canvasvar_EnteredControlPointOutline, "entered control point outline")
CANVAS_VARIABLE(canvasvar_EnteredControlPointSelected, "entered control point selected")
CANVAS_VARIABLE(canvasvar_ControlPointFill, "control point fill")
CANVAS_VARIABLE(canvasvar_ControlPointOutline, "control point outline")
CANVAS_VARIABLE(canvasvar_ControlPointSelected, "control point selected")
CANVAS_VARIABLE(canvasvar_EnteredGainLine, "entered gain line")
CANVAS_VARIABLE(canvasvar_EnteredMarker, "entered marker")
CANVAS_VARIABLE(canvasvar_FrameHandle, "frame handle")

View File

@ -45,7 +45,7 @@ ControlPoint::ControlPoint (AutomationLine& al)
_item = new Canvas::SimpleRect (_line.canvas_group());
_item->property_draw() = true;
_item->property_fill() = false;
_item->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ControlPointFill.get();
_item->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ControlPointFill.get();
_item->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_ControlPointOutline.get();
_item->property_outline_pixels() = 1;
_item->set_data ("control_point", this);
@ -111,6 +111,12 @@ ControlPoint::set_visible (bool yn)
_item->property_draw() = (gboolean) yn;
}
bool
ControlPoint::visible () const
{
return _item->property_draw ();
}
void
ControlPoint::reset (double x, double y, AutomationList::iterator mi, uint32_t vi, ShapeType shape)
{
@ -120,31 +126,14 @@ ControlPoint::reset (double x, double y, AutomationList::iterator mi, uint32_t v
}
void
ControlPoint::show_color (bool entered, bool hide_too)
ControlPoint::set_color ()
{
uint32_t color = 0;
if (entered) {
if (_selected) {
color = ARDOUR_UI::config()->canvasvar_EnteredControlPointSelected.get();
set_visible(true);
} else {
color = ARDOUR_UI::config()->canvasvar_EnteredControlPointOutline.get();
if (hide_too) {
set_visible(false);
}
}
if (_selected) {
color = ARDOUR_UI::config()->canvasvar_ControlPointSelected.get();
} else {
if (_selected) {
color = ARDOUR_UI::config()->canvasvar_ControlPointSelected.get();
set_visible(true);
} else {
color = ARDOUR_UI::config()->canvasvar_ControlPointOutline.get();
if (hide_too) {
set_visible(false);
}
}
color = ARDOUR_UI::config()->canvasvar_ControlPointOutline.get();
}
_item->property_outline_color_rgba() = color;
@ -190,3 +179,8 @@ ControlPoint::move_to (double x, double y, ShapeType shape)
_shape = shape;
}
void
ControlPoint::i2w (double& x, double& y) const
{
_item->i2w (x, y);
}

View File

@ -62,10 +62,11 @@ class ControlPoint
void hide ();
void show ();
void show_color (bool entered, bool hide_too);
void set_color ();
void set_size (double);
void set_visible (bool);
bool visible () const;
bool can_slide() const { return _can_slide; }
void set_can_slide(bool yn) { _can_slide = yn; }
@ -74,11 +75,12 @@ class ControlPoint
uint32_t view_index() const { return _view_index; }
void set_view_index(uint32_t i) { _view_index = i; }
void i2w (double &, double &) const;
ARDOUR::AutomationList::iterator model() const { return _model; }
AutomationLine& line() const { return _line; }
ArdourCanvas::Item* item() const { return _item; }
protected:
private:
ArdourCanvas::SimpleRect* _item;
AutomationLine& _line;
@ -90,7 +92,6 @@ class ControlPoint
virtual bool event_handler (GdkEvent*);
private:
double _x;
double _y;
double _size;

View File

@ -1441,7 +1441,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_
double at_x, at_y;
at_x = cp->get_x();
at_y = cp->get_y ();
cp->item()->i2w (at_x, at_y);
cp->i2w (at_x, at_y);
at_x += 10.0;
at_y += 10.0;