From fcfbd65268cbba8b1fd1cebc32654a43ba051d1a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 11 Nov 2010 13:36:38 +0000 Subject: Further fixes for #3529. Show marker lines the same colour as their marker; adjust height of lines. git-svn-id: svn://localhost/ardour2/branches/3.0@8009 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.h | 6 +- gtk2_ardour/editor_canvas.cc | 2 +- gtk2_ardour/editor_drag.cc | 22 ++++++-- gtk2_ardour/editor_markers.cc | 99 +++++++++++++++----------------- gtk2_ardour/editor_tempodisplay.cc | 4 +- gtk2_ardour/marker.cc | 113 ++++++++++++++++++++++--------------- gtk2_ardour/marker.h | 27 +++++---- 7 files changed, 152 insertions(+), 121 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index ae4161245c..122391f032 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -597,9 +597,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void hide (); void show (); - void hide_lines (); - void show_lines (ArdourCanvas::Group *, double); - void set_lines_vpos (double, double); + void set_show_lines (bool); + void set_selected (bool); + void canvas_height_set (double); void set_name (const std::string&); void set_position (framepos_t start, framepos_t end = 0); diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index 33efcbdc5a..28c0708f62 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -342,7 +342,7 @@ Editor::track_canvas_size_allocated () } for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) { - i->second->set_lines_vpos (0, _canvas_height); + i->second->canvas_height_set (_canvas_height); } vertical_adjustment.set_page_size (_canvas_height); diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 45d67605b4..71dda34d63 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -1756,8 +1756,15 @@ MeterMarkerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) // The actual copying is not done before we reach the finish callback. char name[64]; snprintf (name, sizeof(name), "%g/%g", _marker->meter().beats_per_bar(), _marker->meter().note_divisor ()); - MeterMarker* new_marker = new MeterMarker(*_editor, *_editor->meter_group, ARDOUR_UI::config()->canvasvar_MeterMarker.get(), name, - *new MeterSection (_marker->meter())); + + MeterMarker* new_marker = new MeterMarker ( + *_editor, + *_editor->meter_group, + *_editor->cursor_group, + ARDOUR_UI::config()->canvasvar_MeterMarker.get(), + name, + *new MeterSection (_marker->meter()) + ); _item = &new_marker->the_item (); _marker = new_marker; @@ -1850,8 +1857,15 @@ TempoMarkerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) // The actual copying is not done before we reach the finish callback. char name[64]; snprintf (name, sizeof (name), "%.2f", _marker->tempo().beats_per_minute()); - TempoMarker* new_marker = new TempoMarker(*_editor, *_editor->tempo_group, ARDOUR_UI::config()->canvasvar_TempoMarker.get(), name, - *new TempoSection (_marker->tempo())); + + TempoMarker* new_marker = new TempoMarker ( + *_editor, + *_editor->tempo_group, + *_editor->cursor_group, + ARDOUR_UI::config()->canvasvar_TempoMarker.get(), + name, + *new TempoSection (_marker->tempo()) + ); _item = &new_marker->the_item (); _marker = new_marker; diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 0eab51260f..e80551bd6b 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -80,44 +80,44 @@ Editor::add_new_location (Location *location) if (location->is_mark()) { if (location->is_cd_marker() && ruler_cd_marker_action->get_active()) { - lam->start = new Marker (*this, *cd_marker_group, color, location->name(), Marker::Mark, location->start()); + lam->start = new Marker (*this, *cd_marker_group, *cursor_group, color, location->name(), Marker::Mark, location->start()); } else { - lam->start = new Marker (*this, *marker_group, color, location->name(), Marker::Mark, location->start()); + lam->start = new Marker (*this, *marker_group, *cursor_group, color, location->name(), Marker::Mark, location->start()); } lam->end = 0; } else if (location->is_auto_loop()) { // transport marker - lam->start = new Marker (*this, *transport_marker_group, color, + lam->start = new Marker (*this, *transport_marker_group, *cursor_group, color, location->name(), Marker::LoopStart, location->start()); - lam->end = new Marker (*this, *transport_marker_group, color, + lam->end = new Marker (*this, *transport_marker_group, *cursor_group, color, location->name(), Marker::LoopEnd, location->end()); } else if (location->is_auto_punch()) { // transport marker - lam->start = new Marker (*this, *transport_marker_group, color, + lam->start = new Marker (*this, *transport_marker_group, *cursor_group, color, location->name(), Marker::PunchIn, location->start()); - lam->end = new Marker (*this, *transport_marker_group, color, + lam->end = new Marker (*this, *transport_marker_group, *cursor_group, color, location->name(), Marker::PunchOut, location->end()); } else if (location->is_session_range()) { // session range - lam->start = new Marker (*this, *marker_group, color, _("start"), Marker::Start, location->start()); - lam->end = new Marker (*this, *marker_group, color, _("end"), Marker::End, location->end()); + lam->start = new Marker (*this, *marker_group, *cursor_group, color, _("start"), Marker::Start, location->start()); + lam->end = new Marker (*this, *marker_group, *cursor_group, color, _("end"), Marker::End, location->end()); } else { // range marker if (location->is_cd_marker() && ruler_cd_marker_action->get_active()) { - lam->start = new Marker (*this, *cd_marker_group, color, + lam->start = new Marker (*this, *cd_marker_group, *cursor_group, color, location->name(), Marker::Start, location->start()); - lam->end = new Marker (*this, *cd_marker_group, color, + lam->end = new Marker (*this, *cd_marker_group, *cursor_group, color, location->name(), Marker::End, location->end()); } else { - lam->start = new Marker (*this, *range_marker_group, color, + lam->start = new Marker (*this, *range_marker_group, *cursor_group, color, location->name(), Marker::Start, location->start()); - lam->end = new Marker (*this, *range_marker_group, color, + lam->end = new Marker (*this, *range_marker_group, *cursor_group, color, location->name(), Marker::End, location->end()); } } @@ -146,11 +146,8 @@ Editor::add_new_location (Location *location) select_new_marker = false; } - if (_show_marker_lines) { - lam->show_lines (cursor_group, _canvas_height); - } else { - lam->hide_lines (); - } + lam->canvas_height_set (_canvas_height); + lam->set_show_lines (_show_marker_lines); } void @@ -377,32 +374,11 @@ Editor::LocationMarkers::show() } void -Editor::LocationMarkers::show_lines (ArdourCanvas::Group* g, double h) -{ - /* add_line may be required, and it calls show_line even if it isn't */ - - start->add_line (g, 0, h); - - if (end) { - end->add_line (g, 0, h); - } -} - -void -Editor::LocationMarkers::hide_lines () +Editor::LocationMarkers::canvas_height_set (double h) { - start->hide_line (); + start->canvas_height_set (h); if (end) { - end->hide_line (); - } -} - -void -Editor::LocationMarkers::set_lines_vpos (double y, double h) -{ - start->set_line_vpos (y, h); - if (end) { - end->set_line_vpos (y, h); + end->canvas_height_set (h); } } @@ -425,14 +401,36 @@ Editor::LocationMarkers::set_position (framepos_t startf, framepos_t endf) { start->set_position (startf); - if (end) { end->set_position (endf); } + if (end) { + end->set_position (endf); + } } void Editor::LocationMarkers::set_color_rgba (uint32_t rgba) { start->set_color_rgba (rgba); - if (end) { end->set_color_rgba (rgba); } + if (end) { + end->set_color_rgba (rgba); + } +} + +void +Editor::LocationMarkers::set_show_lines (bool s) +{ + start->set_show_line (s); + if (end) { + end->set_show_line (s); + } +} + +void +Editor::LocationMarkers::set_selected (bool s) +{ + start->set_selected (s); + if (end) { + end->set_selected (s); + } } void @@ -1243,15 +1241,12 @@ Editor::marker_selection_changed () return; } - if (!_show_marker_lines) { - for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) { - i->second->hide_lines (); - } + for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) { + i->second->set_selected (false); } for (MarkerSelection::iterator x = selection->markers.begin(); x != selection->markers.end(); ++x) { - (*x)->add_line (cursor_group, 0, _canvas_height); - (*x)->show_line (); + (*x)->set_selected (true); } } @@ -1318,10 +1313,6 @@ Editor::toggle_marker_lines () _show_marker_lines = !_show_marker_lines; for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) { - if (_show_marker_lines) { - i->second->show_lines (cursor_group, _canvas_height); - } else { - i->second->hide_lines (); - } + i->second->set_show_lines (_show_marker_lines); } } diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc index ac6c572af4..98186a8e77 100644 --- a/gtk2_ardour/editor_tempodisplay.cc +++ b/gtk2_ardour/editor_tempodisplay.cc @@ -81,11 +81,11 @@ Editor::draw_metric_marks (const Metrics& metrics) if ((ms = dynamic_cast(*i)) != 0) { snprintf (buf, sizeof(buf), "%g/%g", ms->beats_per_bar(), ms->note_divisor ()); - metric_marks.push_back (new MeterMarker (*this, *meter_group, ARDOUR_UI::config()->canvasvar_MeterMarker.get(), buf, + metric_marks.push_back (new MeterMarker (*this, *meter_group, *cursor_group, ARDOUR_UI::config()->canvasvar_MeterMarker.get(), buf, *(const_cast(ms)))); } else if ((ts = dynamic_cast(*i)) != 0) { snprintf (buf, sizeof (buf), "%.2f", ts->beats_per_minute()); - metric_marks.push_back (new TempoMarker (*this, *tempo_group, ARDOUR_UI::config()->canvasvar_TempoMarker.get(), buf, + metric_marks.push_back (new TempoMarker (*this, *tempo_group, *cursor_group, ARDOUR_UI::config()->canvasvar_TempoMarker.get(), buf, *(const_cast(ts)))); } diff --git a/gtk2_ardour/marker.cc b/gtk2_ardour/marker.cc index e42dc3308e..1752cbeae6 100644 --- a/gtk2_ardour/marker.cc +++ b/gtk2_ardour/marker.cc @@ -43,10 +43,18 @@ using namespace Gtkmm2ext; PBD::Signal1 Marker::CatchDeletion; -Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, const string& annotation, +Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, ArdourCanvas::Group& line_parent, guint32 rgba, const string& annotation, Type type, nframes_t frame, bool handle_events) - : editor (ed), _parent(&parent), _type(type) + : editor (ed) + , _parent (&parent) + , _line_parent (&line_parent) + , _line (0) + , _type (type) + , _selected (false) + , _shown (false) + , _canvas_height (0) + , _color (rgba) { double label_offset = 0; @@ -249,8 +257,7 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, con mark = new Polygon (*group); mark->property_points() = *points; - mark->property_fill_color_rgba() = rgba; - mark->property_outline_color_rgba() = rgba; + set_color_rgba (rgba); mark->property_width_pixels() = 1; /* setup name pixbuf sizes */ @@ -278,8 +285,6 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, con group->signal_event().connect (sigc::bind (sigc::mem_fun (editor, &PublicEditor::canvas_marker_event), mark, this)); } - line = 0; - } @@ -292,8 +297,7 @@ Marker::~Marker () delete mark; delete points; - delete line; - line = 0; + delete _line; } void Marker::reparent(ArdourCanvas::Group & parent) @@ -302,49 +306,62 @@ void Marker::reparent(ArdourCanvas::Group & parent) _parent = &parent; } - void -Marker::set_line_vpos (double pos, double height) +Marker::set_selected (bool s) { - if (line) { - line->property_y1() = pos; - line->property_y2() = pos + height; - } + _selected = s; + setup_line (); } void -Marker::add_line (ArdourCanvas::Group* group, double y_origin, double initial_height) +Marker::set_show_line (bool s) { - if (!line) { - - line = new ArdourCanvas::SimpleLine (*group); - line->property_color_rgba() = ARDOUR_UI::config()->canvasvar_EditPoint.get(); - line->property_x1() = unit_position + shift; - line->property_y1() = y_origin; - line->property_x2() = unit_position + shift; - line->property_y2() = y_origin + initial_height; - - line->signal_event().connect (sigc::bind (sigc::mem_fun (editor, &PublicEditor::canvas_marker_event), mark, this)); - } - - show_line (); + _shown = s; + setup_line (); } void -Marker::show_line () +Marker::setup_line () { - if (line) { - line->raise_to_top(); - line->show (); + if (_selected || _shown) { + + if (_line == 0) { + + _line = new ArdourCanvas::SimpleLine (*_line_parent); + _line->property_color_rgba() = ARDOUR_UI::config()->canvasvar_EditPoint.get(); + _line->property_x1() = unit_position + shift; + _line->property_x2() = unit_position + shift; + + _line->signal_event().connect (sigc::bind (sigc::mem_fun (editor, &PublicEditor::canvas_marker_event), mark, this)); + } + + double yo = 0; + if (!_selected) { + /* work out where to start the line from so that it extends only as far as the mark */ + double x = 0; + _parent->i2w (x, yo); + _line_parent->w2i (x, yo); + } + + _line->property_y1() = yo; + _line->property_y2() = yo + _canvas_height; + + _line->property_color_rgba() = _selected ? ARDOUR_UI::config()->canvasvar_EditPoint.get() : _color; + _line->raise_to_top (); + _line->show (); + + } else { + if (_line) { + _line->hide (); + } } } void -Marker::hide_line () +Marker::canvas_height_set (double h) { - if (line) { - line->hide (); - } + _canvas_height = h; + setup_line (); } ArdourCanvas::Item& @@ -374,9 +391,9 @@ Marker::set_position (framepos_t frame) frame_position = frame; unit_position = new_unit_position; - if (line) { - line->property_x1() = unit_position + shift; - line->property_x2() = unit_position + shift; + if (_line) { + _line->property_x1() = unit_position + shift; + _line->property_x2() = unit_position + shift; } } @@ -399,17 +416,21 @@ Marker::hide () } void -Marker::set_color_rgba (uint32_t color) +Marker::set_color_rgba (uint32_t c) { - mark->property_fill_color_rgba() = color; - mark->property_outline_color_rgba() = color; + _color = c; + mark->property_fill_color_rgba() = _color; + mark->property_outline_color_rgba() = _color; + if (_line && !_selected) { + _line->property_color_rgba() = _color; + } } /***********************************************************************/ -TempoMarker::TempoMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text, +TempoMarker::TempoMarker (PublicEditor& editor, ArdourCanvas::Group& parent, ArdourCanvas::Group& line_parent, guint32 rgba, const string& text, ARDOUR::TempoSection& temp) - : Marker (editor, parent, rgba, text, Tempo, 0, false), + : Marker (editor, parent, line_parent, rgba, text, Tempo, 0, false), _tempo (temp) { set_position (_tempo.frame()); @@ -422,9 +443,9 @@ TempoMarker::~TempoMarker () /***********************************************************************/ -MeterMarker::MeterMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text, +MeterMarker::MeterMarker (PublicEditor& editor, ArdourCanvas::Group& parent, ArdourCanvas::Group& line_parent, guint32 rgba, const string& text, ARDOUR::MeterSection& m) - : Marker (editor, parent, rgba, text, Meter, 0, false), + : Marker (editor, parent, line_parent, rgba, text, Meter, 0, false), _meter (m) { set_position (_meter.frame()); diff --git a/gtk2_ardour/marker.h b/gtk2_ardour/marker.h index 623e624f9d..e5885e6611 100644 --- a/gtk2_ardour/marker.h +++ b/gtk2_ardour/marker.h @@ -54,7 +54,7 @@ class Marker : public sigc::trackable }; - Marker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const std::string& text, Type, + Marker (PublicEditor& editor, ArdourCanvas::Group &, ArdourCanvas::Group &, guint32 rgba, const std::string& text, Type, nframes_t frame = 0, bool handle_events = true); virtual ~Marker (); @@ -63,10 +63,9 @@ class Marker : public sigc::trackable ArdourCanvas::Item& the_item() const; - void add_line (ArdourCanvas::Group*, double y_origin, double initial_height); - void show_line (); - void hide_line (); - void set_line_vpos (double y_origin, double height); + void set_selected (bool); + void set_show_line (bool); + void canvas_height_set (double); void set_position (framepos_t); void set_name (const std::string&); @@ -87,27 +86,33 @@ class Marker : public sigc::trackable Pango::FontDescription* name_font; - ArdourCanvas::Group * _parent; + ArdourCanvas::Group* _parent; + ArdourCanvas::Group* _line_parent; ArdourCanvas::Group *group; ArdourCanvas::Polygon *mark; ArdourCanvas::Pixbuf *name_pixbuf; ArdourCanvas::Points *points; - ArdourCanvas::SimpleLine *line; + ArdourCanvas::SimpleLine* _line; ArdourCanvas::Points *line_points; double unit_position; - framepos_t frame_position; + framepos_t frame_position; unsigned char shift; /* should be double, but its always small and integral */ - Type _type; + Type _type; int name_height; + bool _selected; + bool _shown; + double _canvas_height; + uint32_t _color; void reposition (); + void setup_line (); }; class TempoMarker : public Marker { public: - TempoMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const std::string& text, ARDOUR::TempoSection&); + TempoMarker (PublicEditor& editor, ArdourCanvas::Group &, ArdourCanvas::Group &, guint32 rgba, const std::string& text, ARDOUR::TempoSection&); ~TempoMarker (); ARDOUR::TempoSection& tempo() const { return _tempo; } @@ -119,7 +124,7 @@ class TempoMarker : public Marker class MeterMarker : public Marker { public: - MeterMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const std::string& text, ARDOUR::MeterSection&); + MeterMarker (PublicEditor& editor, ArdourCanvas::Group &, ArdourCanvas::Group &, guint32 rgba, const std::string& text, ARDOUR::MeterSection&); ~MeterMarker (); ARDOUR::MeterSection& meter() const { return _meter; } -- cgit v1.2.3