From 4527566217563bb524b60c23e925e4ff20aebccb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 11 Nov 2010 15:21:37 +0000 Subject: [PATCH] Visual tweaks to marker lines. git-svn-id: svn://localhost/ardour2/branches/3.0@8011 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.h | 1 + gtk2_ardour/editor_markers.cc | 9 ++++ gtk2_ardour/editor_rulers.cc | 5 +++ gtk2_ardour/marker.cc | 81 ++++++++++++++++------------------- gtk2_ardour/marker.h | 6 ++- 5 files changed, 55 insertions(+), 47 deletions(-) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 122391f032..98b7461292 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -600,6 +600,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void set_show_lines (bool); void set_selected (bool); void canvas_height_set (double); + void setup_lines (); void set_name (const std::string&); void set_position (framepos_t start, framepos_t end = 0); diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index e80551bd6b..00a71ed430 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -433,6 +433,15 @@ Editor::LocationMarkers::set_selected (bool s) } } +void +Editor::LocationMarkers::setup_lines () +{ + start->setup_line (); + if (end) { + end->setup_line (); + } +} + void Editor::mouse_add_new_marker (framepos_t where, bool is_cd, bool is_xrun) { diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc index f2ef742330..ff759f4b76 100644 --- a/gtk2_ardour/editor_rulers.cc +++ b/gtk2_ardour/editor_rulers.cc @@ -763,6 +763,11 @@ Editor::update_ruler_visibility () update_fixed_rulers(); redisplay_tempo (false); + + /* Changing ruler visibility means that any lines on markers might need updating */ + for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) { + i->second->setup_lines (); + } } void diff --git a/gtk2_ardour/marker.cc b/gtk2_ardour/marker.cc index 1752cbeae6..98be8a622a 100644 --- a/gtk2_ardour/marker.cc +++ b/gtk2_ardour/marker.cc @@ -53,6 +53,7 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, ArdourCanvas::Gro , _type (type) , _selected (false) , _shown (false) + , _line_shown (false) , _canvas_height (0) , _color (rgba) { @@ -101,29 +102,7 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, ArdourCanvas::Gro \ | 12,12 - - TransportStart: - - 0,0 - | \ - | \ - | \ - | \ - | \ - 0,13 --- 13,13 - - TransportEnd: - - /13,0 - / | - / | - / | - / | - / | - 0,13 ------ 13,13 - - - PunchIn: + PunchIn: 0,0 ------> 13,0 | / @@ -159,7 +138,7 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, ArdourCanvas::Gro points->push_back (Gnome::Art::Point (0.0, 5.0)); points->push_back (Gnome::Art::Point (0.0, 0.0)); - shift = 3; + _shift = 3; label_offset = 8.0; break; @@ -174,7 +153,7 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, ArdourCanvas::Gro points->push_back (Gnome::Art::Point (0.0, 5.0)); points->push_back (Gnome::Art::Point (3.0, 0.0)); - shift = 3; + _shift = 3; label_offset = 8.0; break; @@ -185,7 +164,7 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, ArdourCanvas::Gro points->push_back (Gnome::Art::Point (0.0, 13.0)); points->push_back (Gnome::Art::Point (0.0, 0.0)); - shift = 0; + _shift = 0; label_offset = 13.0; break; @@ -196,7 +175,7 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, ArdourCanvas::Gro points->push_back (Gnome::Art::Point (13.0, 13.0)); points->push_back (Gnome::Art::Point (6.5, 6.5)); - shift = 13; + _shift = 13; label_offset = 6.0; break; @@ -207,7 +186,7 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, ArdourCanvas::Gro points->push_back (Gnome::Art::Point (0.0, 13.0)); points->push_back (Gnome::Art::Point (0.0, 0.0)); - shift = 0; + _shift = 0; label_offset = 12.0; break; @@ -218,7 +197,7 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, ArdourCanvas::Gro points->push_back (Gnome::Art::Point (0.0, 13.0)); points->push_back (Gnome::Art::Point (13.0, 0.0)); - shift = 13; + _shift = 13; label_offset = 0.0; break; @@ -229,7 +208,7 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, ArdourCanvas::Gro points->push_back (Gnome::Art::Point (0.0, 13.0)); points->push_back (Gnome::Art::Point (0.0, 0.0)); - shift = 0; + _shift = 0; label_offset = 13.0; break; @@ -240,7 +219,7 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, ArdourCanvas::Gro points->push_back (Gnome::Art::Point (12.0, 12.0)); points->push_back (Gnome::Art::Point (0.0, 0.0)); - shift = 13; + _shift = 13; label_offset = 0.0; break; @@ -251,7 +230,7 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, ArdourCanvas::Gro /* adjust to properly locate the tip */ - unit_position -= shift; + unit_position -= _shift; group = new Group (parent, unit_position, 1.0); @@ -316,21 +295,21 @@ Marker::set_selected (bool s) void Marker::set_show_line (bool s) { - _shown = s; + _line_shown = s; setup_line (); } void Marker::setup_line () { - if (_selected || _shown) { + if (_shown && (_selected || _line_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; + + setup_line_x (); _line->signal_event().connect (sigc::bind (sigc::mem_fun (editor, &PublicEditor::canvas_marker_event), mark, this)); } @@ -343,8 +322,8 @@ Marker::setup_line () _line_parent->w2i (x, yo); } - _line->property_y1() = yo; - _line->property_y2() = yo + _canvas_height; + _line->property_y1() = yo + 10; + _line->property_y2() = yo + 10 + _canvas_height; _line->property_color_rgba() = _selected ? ARDOUR_UI::config()->canvasvar_EditPoint.get() : _color; _line->raise_to_top (); @@ -382,19 +361,25 @@ Marker::set_name (const string& new_name) } } +void +Marker::setup_line_x () +{ + if (_line) { + _line->property_x1() = unit_position + _shift - 0.5; + _line->property_x2() = unit_position + _shift - 0.5; + } +} + void Marker::set_position (framepos_t frame) { double new_unit_position = editor.frame_to_unit (frame); - new_unit_position -= shift; + new_unit_position -= _shift; group->move (new_unit_position - unit_position, 0.0); frame_position = frame; unit_position = new_unit_position; - if (_line) { - _line->property_x1() = unit_position + shift; - _line->property_x2() = unit_position + shift; - } + setup_line_x (); } void @@ -406,13 +391,19 @@ Marker::reposition () void Marker::show () { - group->show(); + _shown = true; + + group->show (); + setup_line (); } void Marker::hide () { - group->hide(); + _shown = false; + + group->hide (); + setup_line (); } void diff --git a/gtk2_ardour/marker.h b/gtk2_ardour/marker.h index e5885e6611..a6e48fc9c3 100644 --- a/gtk2_ardour/marker.h +++ b/gtk2_ardour/marker.h @@ -70,6 +70,7 @@ class Marker : public sigc::trackable void set_position (framepos_t); void set_name (const std::string&); void set_color_rgba (uint32_t rgba); + void setup_line (); framepos_t position() const { return frame_position; } @@ -97,16 +98,17 @@ class Marker : public sigc::trackable double unit_position; framepos_t frame_position; - unsigned char shift; /* should be double, but its always small and integral */ + double _shift; Type _type; int name_height; bool _selected; bool _shown; + bool _line_shown; double _canvas_height; uint32_t _color; void reposition (); - void setup_line (); + void setup_line_x (); }; class TempoMarker : public Marker -- 2.30.2