Visual tweaks to marker lines.
authorCarl Hetherington <carl@carlh.net>
Thu, 11 Nov 2010 15:21:37 +0000 (15:21 +0000)
committerCarl Hetherington <carl@carlh.net>
Thu, 11 Nov 2010 15:21:37 +0000 (15:21 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@8011 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.h
gtk2_ardour/editor_markers.cc
gtk2_ardour/editor_rulers.cc
gtk2_ardour/marker.cc
gtk2_ardour/marker.h

index 122391f0322c0e584d07f8c382a61f94ae552a57..98b746129230d11437ddd35486c8358299440005 100644 (file)
@@ -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);
index e80551bd6bc478d690856fed69b5ed41972e9338..00a71ed4301f227d8c76454bafba7bf2053d9b95 100644 (file)
@@ -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)
 {
index f2ef7423303a65c2e026f150d25d086e916a9b23..ff759f4b765a2f3eb9edf7510c914dfd22b0c4a4 100644 (file)
@@ -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
index 1752cbeae697bd2930e210590bd6b28df9ffe82a..98be8a622a6fd9c5b12026a68177fe1d8e33ca88 100644 (file)
@@ -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
index e5885e66115b6763505e6aff64813d903f58052d..a6e48fc9c3685dcacadc2be58afabc4522399120 100644 (file)
@@ -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