Separate verbose cursor out into its own class and clean up the API. Fixes #4010.
authorCarl Hetherington <carl@carlh.net>
Mon, 2 May 2011 13:38:16 +0000 (13:38 +0000)
committerCarl Hetherington <carl@carlh.net>
Mon, 2 May 2011 13:38:16 +0000 (13:38 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9455 d708f5d6-7413-0410-9779-e7cbd77b26cf

13 files changed:
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_canvas.cc
gtk2_ardour/editor_canvas_events.cc
gtk2_ardour/editor_drag.cc
gtk2_ardour/editor_drag.h
gtk2_ardour/editor_mouse.cc
gtk2_ardour/midi_region_view.cc
gtk2_ardour/midi_region_view.h
gtk2_ardour/public_editor.h
gtk2_ardour/verbose_cursor.cc [new file with mode: 0644]
gtk2_ardour/verbose_cursor.h [new file with mode: 0644]
gtk2_ardour/wscript

index bfcaba145feeafa5620e747b9c32ea5d664b6e55..ef81f06f2bb876e9956f0a142d60e00727b45e21 100644 (file)
@@ -331,7 +331,6 @@ Editor::Editor ()
        current_interthread_info = 0;
        _show_measures = true;
        show_gain_after_trim = false;
-       verbose_cursor_on = true;
        last_item_entered = 0;
 
        have_pending_keyboard_selection = false;
@@ -3277,79 +3276,6 @@ Editor::duplicate_dialog (bool with_dialog)
        }
 }
 
-void
-Editor::show_verbose_canvas_cursor ()
-{
-       verbose_canvas_cursor->raise_to_top();
-       verbose_canvas_cursor->show();
-       verbose_cursor_visible = true;
-}
-
-void
-Editor::hide_verbose_canvas_cursor ()
-{
-       verbose_canvas_cursor->hide();
-       verbose_cursor_visible = false;
-}
-
-double
-Editor::clamp_verbose_cursor_x (double x)
-{
-       if (x < 0) {
-               x = 0;
-       } else {
-               x = min (_canvas_width - 200.0, x);
-       }
-       return x;
-}
-
-double
-Editor::clamp_verbose_cursor_y (double y)
-{
-       if (y < canvas_timebars_vsize) {
-               y = canvas_timebars_vsize;
-       } else {
-               y = min (_canvas_height - 50, y);
-       }
-       return y;
-}
-
-void
-Editor::show_verbose_canvas_cursor_with (const string & txt, int32_t xoffset, int32_t yoffset)
-{
-       verbose_canvas_cursor->property_text() = txt.c_str();
-
-       int x, y;
-       double wx, wy;
-
-       track_canvas->get_pointer (x, y);
-       track_canvas->window_to_world (x, y, wx, wy);
-
-       wx += xoffset;
-       wy += yoffset;
-
-       /* don't get too close to the edge */
-       verbose_canvas_cursor->property_x() = clamp_verbose_cursor_x (wx);
-       verbose_canvas_cursor->property_y() = clamp_verbose_cursor_y (wy);
-
-       show_verbose_canvas_cursor ();
-}
-
-void
-Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
-{
-       verbose_canvas_cursor->property_text() = txt.c_str();
-       /* don't get too close to the edge */
-       verbose_canvas_cursor->property_x() = clamp_verbose_cursor_x (x);
-       verbose_canvas_cursor->property_y() = clamp_verbose_cursor_y (y);
-}
-
-void
-Editor::set_verbose_canvas_cursor_text (const string & txt)
-{
-       verbose_canvas_cursor->property_text() = txt.c_str();
-}
-
 void
 Editor::set_edit_mode (EditMode m)
 {
index 10fba5e8b62e3995a53305cbebe05635ad627901..8150f44ae3398b6f85a6fe29ca6833db3f37dc0f 100644 (file)
@@ -131,6 +131,7 @@ class RegionLayeringOrderEditor;
 class ProgressReporter;
 class EditorCursor;
 class MouseCursors;
+class VerboseCursor;
 
 /* <CMT Additions> */
 class ImageFrameView;
@@ -416,9 +417,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void get_regions_corresponding_to (boost::shared_ptr<ARDOUR::Region> region, std::vector<RegionView*>& regions);
 
-       void show_verbose_canvas_cursor_with (const std::string& txt, int32_t xoffset = 0, int32_t yoffset = 0);
-       void hide_verbose_canvas_cursor();
-
        void center_screen (framepos_t);
 
        TrackViewList axis_views_from_routes (boost::shared_ptr<ARDOUR::RouteList>) const;
@@ -448,6 +446,12 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
                return _cursors;
        }
 
+       VerboseCursor* verbose_cursor () const {
+               return _verbose_cursor;
+       }
+
+       void get_pointer_position (double &, double &) const;
+
   protected:
        void map_transport_state ();
        void map_position_change (framepos_t);
@@ -691,19 +695,13 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        ArdourCanvas::Canvas* track_canvas;
 
-       ArdourCanvas::NoEventText* verbose_canvas_cursor;
-       bool                 verbose_cursor_visible;
+       friend class VerboseCursor;
+       VerboseCursor* _verbose_cursor;
 
        void parameter_changed (std::string);
 
        bool track_canvas_motion (GdkEvent*);
 
-       void set_verbose_canvas_cursor (const std::string &, double x, double y);
-       void set_verbose_canvas_cursor_text (const std::string &);
-       void show_verbose_canvas_cursor();
-
-       bool verbose_cursor_on; // so far unused
-
        Gtk::EventBox             time_canvas_event_box;
        Gtk::EventBox             track_canvas_event_box;
        Gtk::EventBox             time_button_event_box;
@@ -1333,11 +1331,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void mouse_brush_insert_region (RegionView*, framepos_t pos);
 
-       void show_verbose_time_cursor (framepos_t frame, double offset = 0, double xpos=-1, double ypos=-1);
-       void show_verbose_duration_cursor (framepos_t start, framepos_t end, double offset = 0, double xpos=-1, double ypos=-1);
-       double clamp_verbose_cursor_x (double);
-       double clamp_verbose_cursor_y (double);
-
        /* Canvas event handlers */
 
        bool canvas_control_point_event (GdkEvent* event,ArdourCanvas::Item*, ControlPoint*);
index 5d2d8d01665a491cd7b3c3d071448f21f2c2cf8f..816f551fcfcf957ff8aaddba86ac0946303d58ab 100644 (file)
@@ -54,6 +54,7 @@
 #include "keyboard.h"
 #include "editor_cursors.h"
 #include "mouse_cursors.h"
+#include "verbose_cursor.h"
 
 #include "i18n.h"
 
@@ -116,18 +117,8 @@ Editor::initialize_canvas ()
         gint phys_width = physical_screen_width (Glib::RefPtr<Gdk::Window>());
         gint phys_height = physical_screen_height (Glib::RefPtr<Gdk::Window>());
 
-       /* stuff for the verbose canvas cursor */
-
-       Pango::FontDescription* font = get_font_for_style (N_("VerboseCanvasCursor"));
-
-       verbose_canvas_cursor = new ArdourCanvas::NoEventText (*track_canvas->root());
-       verbose_canvas_cursor->property_font_desc() = *font;
-       verbose_canvas_cursor->property_anchor() = ANCHOR_NW;
-
-       delete font;
-
-       verbose_cursor_visible = false;
-
+       _verbose_cursor = new VerboseCursor (this);
+       
        /* on the bottom, an image */
 
        if (Profile->get_sae()) {
@@ -774,7 +765,7 @@ void
 Editor::color_handler()
 {
        playhead_cursor->canvas_item.property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_PlayHead.get();
-       verbose_canvas_cursor->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_VerboseCanvasCursor.get();
+       _verbose_cursor->set_color (ARDOUR_UI::config()->canvasvar_VerboseCanvasCursor.get());
 
        meter_bar->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MeterBar.get();
        meter_bar->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerBarSeparator.get();
index fe94cac08410fb3a94b0d436678fd77f9e024689..5b527d57de049c0fa4b2888ec01e655db28322ba 100644 (file)
@@ -47,6 +47,7 @@
 #include "editor_drag.h"
 #include "midi_time_axis.h"
 #include "editor_regions.h"
+#include "verbose_cursor.h"
 
 #include "i18n.h"
 
@@ -178,9 +179,8 @@ Editor::track_canvas_motion_notify_event (GdkEventMotion */*event*/)
 bool
 Editor::track_canvas_motion (GdkEvent *ev)
 {
-       if (verbose_cursor_visible) {
-               verbose_canvas_cursor->property_x() = clamp_verbose_cursor_x (ev->motion.x + 10);
-               verbose_canvas_cursor->property_y() = clamp_verbose_cursor_y (ev->motion.y + 10);
+       if (_verbose_cursor->visible ()) {
+               _verbose_cursor->set_position (ev->motion.x + 10, ev->motion.y + 10);
        }
 
        return false;
index 462324207e267e399a07d13d36c82fe46bbc1216..b1c26ffb9d3b03a4ff6340f94b0b14dfa77c2648 100644 (file)
@@ -54,6 +54,7 @@
 #include "debug.h"
 #include "editor_cursors.h"
 #include "mouse_cursors.h"
+#include "verbose_cursor.h"
 
 using namespace std;
 using namespace ARDOUR;
@@ -273,7 +274,7 @@ Drag::end_grab (GdkEvent* event)
 
        finished (event, _move_threshold_passed);
 
-       _editor->hide_verbose_canvas_cursor();
+       _editor->verbose_cursor()->hide ();
 
        return _move_threshold_passed;
 }
@@ -352,9 +353,46 @@ Drag::abort ()
        aborted (_move_threshold_passed);
 
        _editor->stop_canvas_autoscroll ();
-       _editor->hide_verbose_canvas_cursor ();
+       _editor->verbose_cursor()->hide ();
 }
 
+void
+Drag::show_verbose_cursor_time (framepos_t frame)
+{
+       _editor->verbose_cursor()->set_time (
+               frame,
+               _drags->current_pointer_x() + 10 - _editor->horizontal_position(),
+               _drags->current_pointer_y() + 10 - _editor->vertical_adjustment.get_value() + _editor->canvas_timebars_vsize
+               );
+
+       _editor->verbose_cursor()->show ();
+}
+
+void
+Drag::show_verbose_cursor_duration (framepos_t start, framepos_t end)
+{
+       _editor->verbose_cursor()->set_duration (
+               start, end,
+               _drags->current_pointer_x() + 10 - _editor->horizontal_position(),
+               _drags->current_pointer_y() + 10 - _editor->vertical_adjustment.get_value() + _editor->canvas_timebars_vsize
+               );
+
+       _editor->verbose_cursor()->show ();
+}
+
+void
+Drag::show_verbose_cursor_text (string const & text)
+{
+       _editor->verbose_cursor()->set (
+               text,
+               _drags->current_pointer_x() + 10 - _editor->horizontal_position(),
+               _drags->current_pointer_y() + 10 - _editor->vertical_adjustment.get_value() + _editor->canvas_timebars_vsize
+               );
+
+       _editor->verbose_cursor()->show ();
+}
+
+
 struct EditorOrderTimeAxisViewSorter {
     bool operator() (TimeAxisView* a, TimeAxisView* b) {
            RouteTimeAxisView* ra = dynamic_cast<RouteTimeAxisView*> (a);
@@ -441,7 +479,7 @@ RegionMotionDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
 {
        Drag::start_grab (event, cursor);
 
-       _editor->show_verbose_time_cursor (_last_frame_position, 10);
+       show_verbose_cursor_time (_last_frame_position);
 
        pair<TimeAxisView*, int> const tv = _editor->trackview_by_y_position (_drags->current_pointer_y ());
        _last_pointer_time_axis_view = find_time_axis_view (tv.first);
@@ -551,7 +589,7 @@ RegionMotionDrag::motion (GdkEvent* event, bool first_move)
        /* Bail early if we're not over a track */
        RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv.first);
        if (!rtv || !rtv->is_track()) {
-               _editor->hide_verbose_canvas_cursor ();
+               _editor->verbose_cursor()->hide ();
                return;
        }
 
@@ -693,7 +731,7 @@ RegionMotionDrag::motion (GdkEvent* event, bool first_move)
        }
 
        if (x_delta != 0 && !_brushing) {
-               _editor->show_verbose_time_cursor (_last_frame_position, 10);
+               show_verbose_cursor_time (_last_frame_position);
        }
 
        _last_pointer_time_axis_view += delta_time_axis_view;
@@ -1284,7 +1322,7 @@ RegionSpliceDrag::motion (GdkEvent* event, bool)
                /* To make sure we hide the verbose canvas cursor when the mouse is
                   not held over and audiotrack.
                */
-               _editor->hide_verbose_canvas_cursor ();
+               _editor->verbose_cursor()->hide ();
                return;
        }
 
@@ -1576,16 +1614,16 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*)
 
        switch (_operation) {
        case StartTrim:
-               _editor->show_verbose_time_cursor (region_start, 10);
+               show_verbose_cursor_time (region_start);
                for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
                        i->view->trim_front_starting ();
                }
                break;
        case EndTrim:
-               _editor->show_verbose_time_cursor (region_end, 10);
+               show_verbose_cursor_time (region_end);
                break;
        case ContentsTrim:
-               _editor->show_verbose_time_cursor (pf, 10);
+               show_verbose_cursor_time (pf);
                break;
        }
 
@@ -1698,13 +1736,13 @@ TrimDrag::motion (GdkEvent* event, bool first_move)
 
        switch (_operation) {
        case StartTrim:
-               _editor->show_verbose_time_cursor ((framepos_t) (rv->region()->position() / speed), 10);
+               show_verbose_cursor_time ((framepos_t) (rv->region()->position() / speed));
                break;
        case EndTrim:
-               _editor->show_verbose_time_cursor ((framepos_t) (rv->region()->last_frame() / speed), 10);
+               show_verbose_cursor_time ((framepos_t) (rv->region()->last_frame() / speed));
                break;
        case ContentsTrim:
-               _editor->show_verbose_time_cursor (adjusted_current_frame (event), 10);
+               show_verbose_cursor_time (adjusted_current_frame (event));
                break;
        }
 }
@@ -1857,7 +1895,7 @@ MeterMarkerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
 
        Drag::start_grab (event, cursor);
 
-       _editor->show_verbose_time_cursor (adjusted_current_frame(event), 10);
+       show_verbose_cursor_time (adjusted_current_frame(event));
 }
 
 void
@@ -1873,7 +1911,7 @@ MeterMarkerDrag::motion (GdkEvent* event, bool)
 
        _marker->set_position (pf);
        
-       _editor->show_verbose_time_cursor (pf, 10);
+       show_verbose_cursor_time (pf);
 }
 
 void
@@ -1952,7 +1990,7 @@ TempoMarkerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
 
        Drag::start_grab (event, cursor);
 
-       _editor->show_verbose_time_cursor (adjusted_current_frame (event), 10);
+       show_verbose_cursor_time (adjusted_current_frame (event));
 }
 
 void
@@ -1966,7 +2004,7 @@ TempoMarkerDrag::motion (GdkEvent* event, bool)
 {
        framepos_t const pf = adjusted_current_frame (event);
        _marker->set_position (pf);
-       _editor->show_verbose_time_cursor (pf, 10);
+       show_verbose_cursor_time (pf);
 }
 
 void
@@ -2033,7 +2071,7 @@ CursorDrag::fake_locate (framepos_t t)
                s->send_full_time_code (f);
        }
 
-       _editor->show_verbose_time_cursor (t, 10);
+       show_verbose_cursor_time (t);
        _editor->UpdateAllTransportClocks (t);
 }
 
@@ -2127,7 +2165,7 @@ FadeInDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
        AudioRegionView* arv = dynamic_cast<AudioRegionView*> (_primary);
        boost::shared_ptr<AudioRegion> const r = arv->audio_region ();
 
-       _editor->show_verbose_duration_cursor (r->position(), r->position() + r->fade_in()->back()->when, 10);
+       show_verbose_cursor_duration (r->position(), r->position() + r->fade_in()->back()->when);
        
        arv->show_fade_line((framepos_t) r->fade_in()->back()->when);
 }
@@ -2169,7 +2207,7 @@ FadeInDrag::motion (GdkEvent* event, bool)
                tmp->show_fade_line((framecnt_t) fade_length);
        }
 
-       _editor->show_verbose_duration_cursor (region->position(), region->position() + fade_length, 10);
+       show_verbose_cursor_duration (region->position(), region->position() + fade_length);
 }
 
 void
@@ -2246,7 +2284,7 @@ FadeOutDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
        AudioRegionView* arv = dynamic_cast<AudioRegionView*> (_primary);
        boost::shared_ptr<AudioRegion> r = arv->audio_region ();
 
-       _editor->show_verbose_duration_cursor (r->last_frame() - r->fade_out()->back()->when, r->last_frame(), 10);
+       show_verbose_cursor_duration (r->last_frame() - r->fade_out()->back()->when, r->last_frame());
        
        arv->show_fade_line(r->length() - r->fade_out()->back()->when);
 }
@@ -2290,7 +2328,7 @@ FadeOutDrag::motion (GdkEvent* event, bool)
                tmp->show_fade_line(region->length() - fade_length);
        }
 
-       _editor->show_verbose_duration_cursor (region->last_frame() - fade_length, region->last_frame(), 10);
+       show_verbose_cursor_duration (region->last_frame() - fade_length, region->last_frame());
 }
 
 void
@@ -2390,9 +2428,9 @@ MarkerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
        // _line->raise_to_top();
 
        if (is_start) {
-               _editor->show_verbose_time_cursor (location->start(), 10);
+               show_verbose_cursor_time (location->start());
        } else {
-               _editor->show_verbose_time_cursor (location->end(), 10);
+               show_verbose_cursor_time (location->end());
        }
 
        Selection::Operation op = ArdourKeyboard::selection_type (event->button.state);
@@ -2596,7 +2634,7 @@ MarkerDrag::motion (GdkEvent* event, bool)
 
        assert (!_copied_locations.empty());
 
-       _editor->show_verbose_time_cursor (newframe, 10);
+       show_verbose_cursor_time (newframe);
 
 #ifdef GTKOSX
        _editor->update_canvas_now ();
@@ -2702,10 +2740,10 @@ ControlPointDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
 
        _point->line().start_drag_single (_point, _fixed_grab_x, fraction);
 
-       _editor->set_verbose_canvas_cursor (_point->line().get_verbose_cursor_string (fraction),
-                                           event->button.x + 10, event->button.y + 10);
+       _editor->verbose_cursor()->set (_point->line().get_verbose_cursor_string (fraction),
+                                       event->button.x + 10, event->button.y + 10);
 
-       _editor->show_verbose_canvas_cursor ();
+       _editor->verbose_cursor()->show ();
 }
 
 void
@@ -2761,7 +2799,7 @@ ControlPointDrag::motion (GdkEvent* event, bool)
 
        _point->line().drag_motion (_editor->frame_to_unit (cx_frames), fraction, false, push);
 
-       _editor->set_verbose_canvas_cursor_text (_point->line().get_verbose_cursor_string (fraction));
+       _editor->verbose_cursor()->set_text (_point->line().get_verbose_cursor_string (fraction));
 }
 
 void
@@ -2847,10 +2885,10 @@ LineDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
 
        _line->start_drag_line (before, after, fraction);
 
-       _editor->set_verbose_canvas_cursor (_line->get_verbose_cursor_string (fraction),
-                                           event->button.x + 10, event->button.y + 10);
+       _editor->verbose_cursor()->set (_line->get_verbose_cursor_string (fraction),
+                                       event->button.x + 10, event->button.y + 10);
 
-       _editor->show_verbose_canvas_cursor ();
+       _editor->verbose_cursor()->show ();
 }
 
 void
@@ -2882,7 +2920,7 @@ LineDrag::motion (GdkEvent* event, bool)
        /* we are ignoring x position for this drag, so we can just pass in anything */
        _line->drag_motion (0, fraction, true, push);
 
-       _editor->set_verbose_canvas_cursor_text (_line->get_verbose_cursor_string (fraction));
+       _editor->verbose_cursor()->set_text (_line->get_verbose_cursor_string (fraction));
 }
 
 void
@@ -2992,7 +3030,7 @@ void
 RubberbandSelectDrag::start_grab (GdkEvent* event, Gdk::Cursor *)
 {
        Drag::start_grab (event);
-       _editor->show_verbose_time_cursor (adjusted_current_frame (event), 10);
+       show_verbose_cursor_time (adjusted_current_frame (event));
 }
 
 void
@@ -3042,7 +3080,7 @@ RubberbandSelectDrag::motion (GdkEvent* event, bool)
                _editor->rubberband_rect->show();
                _editor->rubberband_rect->raise_to_top();
 
-               _editor->show_verbose_time_cursor (pf, 10);
+               show_verbose_cursor_time (pf);
        }
 }
 
@@ -3104,7 +3142,7 @@ TimeFXDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
 {
        Drag::start_grab (event, cursor);
 
-       _editor->show_verbose_time_cursor (adjusted_current_frame (event), 10);
+       show_verbose_cursor_time (adjusted_current_frame (event));
 }
 
 void
@@ -3118,7 +3156,7 @@ TimeFXDrag::motion (GdkEvent* event, bool)
                rv->get_time_axis_view().show_timestretch (rv->region()->position(), pf);
        }
 
-       _editor->show_verbose_time_cursor (pf, 10);
+       show_verbose_cursor_time (pf);
 }
 
 void
@@ -3247,9 +3285,9 @@ SelectionDrag::start_grab (GdkEvent* event, Gdk::Cursor*)
        }
 
        if (_operation == SelectionMove) {
-               _editor->show_verbose_time_cursor (_editor->selection->time[_editor->clicked_selection].start, 10);
+               show_verbose_cursor_time (_editor->selection->time[_editor->clicked_selection].start);
        } else {
-               _editor->show_verbose_time_cursor (adjusted_current_frame (event), 10);
+               show_verbose_cursor_time (adjusted_current_frame (event));
        }
 
        _original_pointer_time_axis = _editor->trackview_by_y_position (_drags->current_pointer_y ()).first->order ();
@@ -3415,9 +3453,9 @@ SelectionDrag::motion (GdkEvent* event, bool first_move)
        }
 
        if (_operation == SelectionMove) {
-               _editor->show_verbose_time_cursor(start, 10);
+               show_verbose_cursor_time(start);
        } else {
-               _editor->show_verbose_time_cursor(pending_position, 10);
+               show_verbose_cursor_time(pending_position);
        }
 }
 
@@ -3509,7 +3547,7 @@ RangeMarkerBarDrag::start_grab (GdkEvent* event, Gdk::Cursor *)
 
        Drag::start_grab (event, cursor);
 
-       _editor->show_verbose_time_cursor (adjusted_current_frame (event), 10);
+       show_verbose_cursor_time (adjusted_current_frame (event));
 }
 
 void
@@ -3581,7 +3619,7 @@ RangeMarkerBarDrag::motion (GdkEvent* event, bool first_move)
                update_item (_editor->temp_location);
        }
 
-       _editor->show_verbose_time_cursor (pf, 10);
+       show_verbose_cursor_time (pf);
 
 }
 
@@ -3699,7 +3737,7 @@ MouseZoomDrag::start_grab (GdkEvent* event, Gdk::Cursor *)
                _zoom_out = false;
        }
                
-       _editor->show_verbose_time_cursor (adjusted_current_frame (event), 10);
+       show_verbose_cursor_time (adjusted_current_frame (event));
 }
 
 void
@@ -3731,7 +3769,7 @@ MouseZoomDrag::motion (GdkEvent* event, bool first_move)
 
                _editor->reposition_zoom_rect(start, end);
 
-               _editor->show_verbose_time_cursor (pf, 10);
+               show_verbose_cursor_time (pf);
        }
 }
 
@@ -3866,7 +3904,7 @@ NoteDrag::motion (GdkEvent *, bool)
                snprintf (buf, sizeof (buf), "%s (%d)", Evoral::midi_note_name (_primary->note()->note() + note_delta).c_str(),
                          (int) floor (_primary->note()->note() + note_delta));
                 
-               _editor->show_verbose_canvas_cursor_with (buf);
+               show_verbose_cursor_text (buf);
        }
 }
 
index 740f6e42c973674c79683a89ec9bddb604c57af2..e40975b5a5250c4947c4513cbfcad8570c396001 100644 (file)
@@ -212,6 +212,10 @@ protected:
                return _last_pointer_frame;
        }
 
+       void show_verbose_cursor_time (framepos_t);
+       void show_verbose_cursor_duration (framepos_t, framepos_t);
+       void show_verbose_cursor_text (std::string const &);
+
        Editor* _editor; ///< our editor
        DragManager* _drags;
        ArdourCanvas::Item* _item; ///< our item
index a931ad36863a94b28cc3cc5bf2f87555aad7444a..da1e18b31215e73414e5eeccffa2a5fe7592406b 100644 (file)
@@ -60,6 +60,7 @@
 #include "edit_note_dialog.h"
 #include "mouse_cursors.h"
 #include "editor_cursors.h"
+#include "verbose_cursor.h"
 
 #include "ardour/types.h"
 #include "ardour/profile.h"
@@ -1586,8 +1587,8 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_
                                set_canvas_cursor (_cursors->fader);
                        }
 
-                       set_verbose_canvas_cursor (cp->line().get_verbose_cursor_string (fraction), at_x, at_y);
-                       show_verbose_canvas_cursor ();
+                       _verbose_cursor->set (cp->line().get_verbose_cursor_string (fraction), at_x, at_y);
+                       _verbose_cursor->show ();
                }
                break;
 
@@ -1802,7 +1803,7 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_
                        set_canvas_cursor (current_canvas_cursor);
                }
 
-               hide_verbose_canvas_cursor ();
+               _verbose_cursor->hide ();
                break;
 
        case RegionViewNameHighlight:
@@ -2181,156 +2182,6 @@ Editor::region_view_item_click (AudioRegionView& rv, GdkEventButton* event)
        }
 }
 
-void
-Editor::show_verbose_time_cursor (framepos_t frame, double offset, double xpos, double ypos)
-{
-       char buf[128];
-       Timecode::Time timecode;
-       Timecode::BBT_Time bbt;
-       int hours, mins;
-       framepos_t frame_rate;
-       float secs;
-
-       if (_session == 0) {
-               return;
-       }
-
-       AudioClock::Mode m;
-
-       if (Profile->get_sae() || Profile->get_small_screen()) {
-               m = ARDOUR_UI::instance()->primary_clock.mode();
-       } else {
-               m = ARDOUR_UI::instance()->secondary_clock.mode();
-       }
-
-       switch (m) {
-       case AudioClock::BBT:
-               _session->bbt_time (frame, bbt);
-               snprintf (buf, sizeof (buf), "%02" PRIu32 "|%02" PRIu32 "|%02" PRIu32, bbt.bars, bbt.beats, bbt.ticks);
-               break;
-
-       case AudioClock::Timecode:
-               _session->timecode_time (frame, timecode);
-               snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%02" PRId32 ":%02" PRId32, timecode.hours, timecode.minutes, timecode.seconds, timecode.frames);
-               break;
-
-       case AudioClock::MinSec:
-               /* XXX this is copied from show_verbose_duration_cursor() */
-               frame_rate = _session->frame_rate();
-               hours = frame / (frame_rate * 3600);
-               frame = frame % (frame_rate * 3600);
-               mins = frame / (frame_rate * 60);
-               frame = frame % (frame_rate * 60);
-               secs = (float) frame / (float) frame_rate;
-               snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%07.4f", hours, mins, secs);
-               break;
-
-       default:
-               snprintf (buf, sizeof(buf), "%" PRIi64, frame);
-               break;
-       }
-
-       if (xpos >= 0 && ypos >=0) {
-               set_verbose_canvas_cursor (buf, xpos + offset, ypos + offset);
-       } else {
-               set_verbose_canvas_cursor (buf, _drags->current_pointer_x() + offset - horizontal_position(), _drags->current_pointer_y() + offset - vertical_adjustment.get_value() + canvas_timebars_vsize);
-       }
-       show_verbose_canvas_cursor ();
-}
-
-void
-Editor::show_verbose_duration_cursor (framepos_t start, framepos_t end, double offset, double xpos, double ypos)
-{
-       char buf[128];
-       Timecode::Time timecode;
-       Timecode::BBT_Time sbbt;
-       Timecode::BBT_Time ebbt;
-       int hours, mins;
-       framepos_t distance, frame_rate;
-       float secs;
-       Meter meter_at_start(_session->tempo_map().meter_at(start));
-
-       if (_session == 0) {
-               return;
-       }
-
-       AudioClock::Mode m;
-
-       if (Profile->get_sae() || Profile->get_small_screen()) {
-               m = ARDOUR_UI::instance()->primary_clock.mode ();
-       } else {
-               m = ARDOUR_UI::instance()->secondary_clock.mode ();
-       }
-
-       switch (m) {
-       case AudioClock::BBT:
-       {
-               _session->bbt_time (start, sbbt);
-               _session->bbt_time (end, ebbt);
-
-               /* subtract */
-               /* XXX this computation won't work well if the
-               user makes a selection that spans any meter changes.
-               */
-
-               /* use signed integers for the working values so that
-                  we can underflow.
-               */
-
-               int ticks = ebbt.ticks;
-               int beats = ebbt.beats;
-               int bars = ebbt.bars;
-
-               ticks -= sbbt.ticks;
-               if (ticks < 0) {
-                       ticks += int (Timecode::BBT_Time::ticks_per_beat);
-                       --beats;
-               }
-
-               beats -= sbbt.beats;
-               if (beats < 0) {
-                       beats += int (meter_at_start.beats_per_bar());
-                       --bars;
-               }
-
-               bars -= sbbt.bars;
-
-               snprintf (buf, sizeof (buf), "%02" PRIu32 "|%02" PRIu32 "|%02" PRIu32, bars, beats, ticks);
-               break;
-       }
-
-       case AudioClock::Timecode:
-               _session->timecode_duration (end - start, timecode);
-               snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%02" PRId32 ":%02" PRId32, timecode.hours, timecode.minutes, timecode.seconds, timecode.frames);
-               break;
-
-       case AudioClock::MinSec:
-               /* XXX this stuff should be elsewhere.. */
-               distance = end - start;
-               frame_rate = _session->frame_rate();
-               hours = distance / (frame_rate * 3600);
-               distance = distance % (frame_rate * 3600);
-               mins = distance / (frame_rate * 60);
-               distance = distance % (frame_rate * 60);
-               secs = (float) distance / (float) frame_rate;
-               snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%07.4f", hours, mins, secs);
-               break;
-
-       default:
-               snprintf (buf, sizeof(buf), "%" PRIi64, end - start);
-               break;
-       }
-
-       if (xpos >= 0 && ypos >=0) {
-               set_verbose_canvas_cursor (buf, xpos + offset, ypos + offset);
-       }
-       else {
-               set_verbose_canvas_cursor (buf, _drags->current_pointer_x() + offset, _drags->current_pointer_y() + offset);
-       }
-
-       show_verbose_canvas_cursor ();
-}
-
 void
 Editor::collect_new_region_view (RegionView* rv)
 {
@@ -2794,3 +2645,12 @@ Editor::set_canvas_cursor_for_region_view (double x, RegionView* rv)
                }
        }
 }
+
+/** Obtain the pointer position in world coordinates */
+void
+Editor::get_pointer_position (double& x, double& y) const
+{
+       int px, py;
+       track_canvas->get_pointer (px, py);
+       track_canvas->window_to_world (px, py, x, y);
+}
index 07beeafa72df6f9cc2bc25e8539fe40385a941b4..57ad64e0149db2e1bfda711930d7f7cc1fd8b383 100644 (file)
@@ -69,6 +69,7 @@
 #include "utils.h"
 #include "mouse_cursors.h"
 #include "patch_change_dialog.h"
+#include "verbose_cursor.h"
 
 #include "i18n.h"
 
@@ -358,7 +359,7 @@ MidiRegionView::leave_notify (GdkEventCrossing*)
 {
        _mouse_mode_connection.disconnect ();
        
-        trackview.editor().hide_verbose_canvas_cursor ();
+        trackview.editor().verbose_cursor()->hide ();
        remove_ghost_note ();
         return false;
 }
@@ -370,7 +371,7 @@ MidiRegionView::mouse_mode_changed ()
                create_ghost_note (_last_event_x, _last_event_y);
        } else {
                remove_ghost_note ();
-               trackview.editor().hide_verbose_canvas_cursor ();
+               trackview.editor().verbose_cursor()->hide ();
        }
 }
 
@@ -529,7 +530,7 @@ MidiRegionView::motion (GdkEventMotion* ev)
                delete _ghost_note;
                 _ghost_note = 0;
                
-               trackview.editor().hide_verbose_canvas_cursor ();
+               trackview.editor().verbose_cursor()->hide ();
        }
        else if (_ghost_note && trackview.editor().current_mouse_mode() == MouseRange) {
                 update_ghost_note (ev->x, ev->y);
@@ -608,7 +609,7 @@ MidiRegionView::motion (GdkEventMotion* ev)
                                delete _ghost_note;
                                _ghost_note = 0;
                
-                               trackview.editor().hide_verbose_canvas_cursor ();
+                               trackview.editor().verbose_cursor()->hide ();
                        }
 
                         return true;
@@ -675,7 +676,7 @@ MidiRegionView::scroll (GdkEventScroll* ev)
                 return false;
         }
 
-       trackview.editor().hide_verbose_canvas_cursor ();
+       trackview.editor().verbose_cursor()->hide ();
 
         bool fine = !Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier);
         
@@ -1168,7 +1169,7 @@ MidiRegionView::~MidiRegionView ()
 {
        in_destructor = true;
 
-       trackview.editor().hide_verbose_canvas_cursor ();
+       trackview.editor().verbose_cursor()->hide ();
 
         note_delete_connection.disconnect ();
 
@@ -1819,7 +1820,7 @@ MidiRegionView::delete_note (boost::shared_ptr<NoteType> n)
        _note_diff_command->remove (n);
        apply_diff ();
 
-       trackview.editor().hide_verbose_canvas_cursor ();
+       trackview.editor().verbose_cursor()->hide ();
 }
 
 void
@@ -2395,7 +2396,7 @@ MidiRegionView::update_resizing (ArdourCanvas::CanvasNoteEvent* primary, bool at
 
                         char buf[16];
                         snprintf (buf, sizeof (buf), "%.3g beats", len);
-                        trackview.editor().show_verbose_canvas_cursor_with (buf);
+                        show_verbose_cursor (buf, 0, 0);
 
                         cursor_set = true;
                 }
@@ -2643,7 +2644,7 @@ MidiRegionView::change_velocities (bool up, bool fine, bool allow_smush)
                 char buf[24];
                 snprintf (buf, sizeof (buf), "Vel %d", 
                           (int) (*_selection.begin())->note()->velocity());
-                trackview.editor().show_verbose_canvas_cursor_with (buf, 10, 10);
+                show_verbose_cursor (buf, 10, 10);
         }
 }
 
@@ -2819,7 +2820,7 @@ MidiRegionView::note_entered(ArdourCanvas::CanvasNoteEvent* ev)
                note_selected (ev, true);
        }
 
-       show_verbose_canvas_cursor (ev->note ());
+       show_verbose_cursor (ev->note ());
 }
 
 void
@@ -2831,7 +2832,7 @@ MidiRegionView::note_left (ArdourCanvas::CanvasNoteEvent*)
                (*i)->hide_velocity ();
        }
 
-       editor->hide_verbose_canvas_cursor ();
+       editor->verbose_cursor()->hide ();
 
         if (pre_enter_cursor) {
                 editor->set_canvas_cursor (pre_enter_cursor);
@@ -2844,13 +2845,13 @@ MidiRegionView::patch_entered (ArdourCanvas::CanvasPatchChange* ev)
 {
        ostringstream s;
        s << ((int) ev->patch()->program() + 1) << ":" << (ev->patch()->bank() + 1);
-       trackview.editor().show_verbose_canvas_cursor_with (s.str().c_str(), 10, 20);
+       show_verbose_cursor (s.str(), 10, 20);
 }
 
 void
 MidiRegionView::patch_left (ArdourCanvas::CanvasPatchChange *)
 {
-       trackview.editor().hide_verbose_canvas_cursor ();
+       trackview.editor().verbose_cursor()->hide ();
 }
 
 void
@@ -3169,7 +3170,7 @@ MidiRegionView::update_ghost_note (double x, double y)
        /* the ghost note does not appear in ghost regions, so pass false in here */
        update_note (_ghost_note, false);
 
-       show_verbose_canvas_cursor (_ghost_note->note ());
+       show_verbose_cursor (_ghost_note->note ());
 }
 
 void
@@ -3187,7 +3188,7 @@ MidiRegionView::create_ghost_note (double x, double y)
        _last_ghost_x = x;
        _last_ghost_y = y;
 
-       show_verbose_canvas_cursor (_ghost_note->note ());
+       show_verbose_cursor (_ghost_note->note ());
 }
 
 void
@@ -3200,18 +3201,6 @@ MidiRegionView::snap_changed ()
        create_ghost_note (_last_ghost_x, _last_ghost_y);
 }
 
-void
-MidiRegionView::show_verbose_canvas_cursor (boost::shared_ptr<NoteType> n) const
-{
-       char buf[24];
-       snprintf (buf, sizeof (buf), "%s (%d) Chn %d\nVel %d", 
-                  Evoral::midi_note_name (n->note()).c_str(), 
-                  (int) n->note (),
-                 (int) n->channel() + 1,
-                  (int) n->velocity());
-       trackview.editor().show_verbose_canvas_cursor_with (buf, 10, 20);
-}
-
 void
 MidiRegionView::drop_down_keys ()
 {
@@ -3438,3 +3427,31 @@ MidiRegionView::edit_patch_change (ArdourCanvas::CanvasPatchChange* pc)
 
        change_patch_change (pc->patch(), d.patch ());
 }
+
+
+void
+MidiRegionView::show_verbose_cursor (boost::shared_ptr<NoteType> n) const
+{
+       char buf[24];
+       snprintf (buf, sizeof (buf), "%s (%d) Chn %d\nVel %d", 
+                  Evoral::midi_note_name (n->note()).c_str(), 
+                  (int) n->note (),
+                 (int) n->channel() + 1,
+                  (int) n->velocity());
+       
+       show_verbose_cursor (buf, 10, 20);
+}
+
+void
+MidiRegionView::show_verbose_cursor (string const & text, double xoffset, double yoffset) const
+{
+       double wx, wy;
+
+       trackview.editor().get_pointer_position (wx, wy);
+
+       wx += xoffset;
+       wy += yoffset;
+
+       trackview.editor().verbose_cursor()->set (text, wx, wy);
+       trackview.editor().verbose_cursor()->show ();
+}
index 97cc07b7e2fd3c0f261d8a81f2113a7a3bad77f2..574fc8b1531c63cd3a81db1b991d06c4bcbbadff 100644 (file)
@@ -335,6 +335,9 @@ class MidiRegionView : public RegionView
 
        uint8_t get_channel_for_add () const;
 
+       void show_verbose_cursor (std::string const &, double, double) const;
+       void show_verbose_cursor (boost::shared_ptr<NoteType>) const;
+
        int8_t   _force_channel;
        uint16_t _last_channel_selection;
        uint8_t  _current_range_min;
@@ -418,8 +421,6 @@ class MidiRegionView : public RegionView
        void snap_changed ();
        PBD::ScopedConnection snap_changed_connection;
 
-       void show_verbose_canvas_cursor (boost::shared_ptr<NoteType>) const;
-
         bool motion (GdkEventMotion*);
         bool scroll (GdkEventScroll*);
         bool key_press (GdkEventKey*);
index fe27370c4504424405041a516e6e948c25153f77..b5db8377d304724adfedae0fa3ad6a2c7eb40c41 100644 (file)
@@ -87,6 +87,7 @@ class ImageFrameTimeAxis;
 class MarkerView;
 class DragManager;
 class MouseCursors;
+class VerboseCursor;
 
 using ARDOUR::framepos_t;
 using ARDOUR::framecnt_t;
@@ -361,9 +362,6 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible {
 
        virtual TimeAxisView* axis_view_from_route (boost::shared_ptr<ARDOUR::Route>) const = 0;
 
-       virtual void show_verbose_canvas_cursor_with (const std::string& txt, int32_t xoffset = 0, int32_t yoffset = 0) = 0;
-       virtual void hide_verbose_canvas_cursor() = 0;
-
         virtual void set_current_trimmable (boost::shared_ptr<ARDOUR::Trimmable>) = 0;
         virtual void set_current_movable (boost::shared_ptr<ARDOUR::Movable>) = 0;
 
@@ -380,7 +378,10 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible {
        virtual void stop_canvas_autoscroll () = 0;
 
        virtual MouseCursors const * cursors () const = 0;
+       virtual VerboseCursor * verbose_cursor () const = 0;
 
+       virtual void get_pointer_position (double &, double &) const = 0;
+       
        /// Singleton instance, set up by Editor::Editor()
 
        static PublicEditor* _instance;
diff --git a/gtk2_ardour/verbose_cursor.cc b/gtk2_ardour/verbose_cursor.cc
new file mode 100644 (file)
index 0000000..9380b36
--- /dev/null
@@ -0,0 +1,258 @@
+/*
+    Copyright (C) 2000-2011 Paul Davis
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <string>
+#include <gtkmm/enums.h>
+#include "ardour/profile.h"
+#include "editor.h"
+#include "ardour_ui.h"
+#include "verbose_cursor.h"
+#include "utils.h"
+#include "editor_drag.h"
+
+#include "i18n.h"
+
+using namespace std;
+using namespace ARDOUR;
+
+VerboseCursor::VerboseCursor (Editor* editor)
+       : _editor (editor)
+       , _visible (false)
+{
+       Pango::FontDescription* font = get_font_for_style (N_("VerboseCanvasCursor"));
+
+       _canvas_item = new ArdourCanvas::NoEventText (*_editor->track_canvas->root());
+       _canvas_item->property_font_desc() = *font;
+       _canvas_item->property_anchor() = Gtk::ANCHOR_NW;
+
+       delete font;
+}
+
+ArdourCanvas::Item *
+VerboseCursor::canvas_item () const
+{
+       return _canvas_item;
+}
+
+void
+VerboseCursor::set (string const & text, double x, double y)
+{
+       set_text (text);
+       set_position (x, y);
+}
+
+void
+VerboseCursor::set_text (string const & text)
+{
+       _canvas_item->property_text() = text.c_str();
+}
+
+void
+VerboseCursor::show ()
+{
+       _canvas_item->raise_to_top ();
+       _canvas_item->show ();
+       _visible = true;
+}
+
+void
+VerboseCursor::hide ()
+{
+       _canvas_item->hide ();
+       _visible = false;
+}
+
+double
+VerboseCursor::clamp_x (double x)
+{
+       if (x < 0) {
+               x = 0;
+       } else {
+               x = min (_editor->_canvas_width - 200.0, x);
+       }
+       return x;
+}
+
+double
+VerboseCursor::clamp_y (double y)
+{
+       if (y < _editor->canvas_timebars_vsize) {
+               y = _editor->canvas_timebars_vsize;
+       } else {
+               y = min (_editor->_canvas_height - 50, y);
+       }
+       return y;
+}
+
+void
+VerboseCursor::set_time (framepos_t frame, double x, double y)
+{
+       char buf[128];
+       Timecode::Time timecode;
+       Timecode::BBT_Time bbt;
+       int hours, mins;
+       framepos_t frame_rate;
+       float secs;
+
+       if (_editor->_session == 0) {
+               return;
+       }
+
+       AudioClock::Mode m;
+
+       if (Profile->get_sae() || Profile->get_small_screen()) {
+               m = ARDOUR_UI::instance()->primary_clock.mode();
+       } else {
+               m = ARDOUR_UI::instance()->secondary_clock.mode();
+       }
+
+       switch (m) {
+       case AudioClock::BBT:
+               _editor->_session->bbt_time (frame, bbt);
+               snprintf (buf, sizeof (buf), "%02" PRIu32 "|%02" PRIu32 "|%02" PRIu32, bbt.bars, bbt.beats, bbt.ticks);
+               break;
+
+       case AudioClock::Timecode:
+               _editor->_session->timecode_time (frame, timecode);
+               snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%02" PRId32 ":%02" PRId32, timecode.hours, timecode.minutes, timecode.seconds, timecode.frames);
+               break;
+
+       case AudioClock::MinSec:
+               /* XXX this is copied from show_verbose_duration_cursor() */
+               frame_rate = _editor->_session->frame_rate();
+               hours = frame / (frame_rate * 3600);
+               frame = frame % (frame_rate * 3600);
+               mins = frame / (frame_rate * 60);
+               frame = frame % (frame_rate * 60);
+               secs = (float) frame / (float) frame_rate;
+               snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%07.4f", hours, mins, secs);
+               break;
+
+       default:
+               snprintf (buf, sizeof(buf), "%" PRIi64, frame);
+               break;
+       }
+
+       set (buf, x, y);
+}
+
+void
+VerboseCursor::set_duration (framepos_t start, framepos_t end, double x, double y)
+{
+       char buf[128];
+       Timecode::Time timecode;
+       Timecode::BBT_Time sbbt;
+       Timecode::BBT_Time ebbt;
+       int hours, mins;
+       framepos_t distance, frame_rate;
+       float secs;
+       Meter meter_at_start (_editor->_session->tempo_map().meter_at(start));
+
+       if (_editor->_session == 0) {
+               return;
+       }
+
+       AudioClock::Mode m;
+
+       if (Profile->get_sae() || Profile->get_small_screen()) {
+               m = ARDOUR_UI::instance()->primary_clock.mode ();
+       } else {
+               m = ARDOUR_UI::instance()->secondary_clock.mode ();
+       }
+
+       switch (m) {
+       case AudioClock::BBT:
+       {
+               _editor->_session->bbt_time (start, sbbt);
+               _editor->_session->bbt_time (end, ebbt);
+
+               /* subtract */
+               /* XXX this computation won't work well if the
+               user makes a selection that spans any meter changes.
+               */
+
+               /* use signed integers for the working values so that
+                  we can underflow.
+               */
+
+               int ticks = ebbt.ticks;
+               int beats = ebbt.beats;
+               int bars = ebbt.bars;
+
+               ticks -= sbbt.ticks;
+               if (ticks < 0) {
+                       ticks += int (Timecode::BBT_Time::ticks_per_beat);
+                       --beats;
+               }
+
+               beats -= sbbt.beats;
+               if (beats < 0) {
+                       beats += int (meter_at_start.beats_per_bar());
+                       --bars;
+               }
+
+               bars -= sbbt.bars;
+
+               snprintf (buf, sizeof (buf), "%02" PRIu32 "|%02" PRIu32 "|%02" PRIu32, bars, beats, ticks);
+               break;
+       }
+
+       case AudioClock::Timecode:
+               _editor->_session->timecode_duration (end - start, timecode);
+               snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%02" PRId32 ":%02" PRId32, timecode.hours, timecode.minutes, timecode.seconds, timecode.frames);
+               break;
+
+       case AudioClock::MinSec:
+               /* XXX this stuff should be elsewhere.. */
+               distance = end - start;
+               frame_rate = _editor->_session->frame_rate();
+               hours = distance / (frame_rate * 3600);
+               distance = distance % (frame_rate * 3600);
+               mins = distance / (frame_rate * 60);
+               distance = distance % (frame_rate * 60);
+               secs = (float) distance / (float) frame_rate;
+               snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%07.4f", hours, mins, secs);
+               break;
+
+       default:
+               snprintf (buf, sizeof(buf), "%" PRIi64, end - start);
+               break;
+       }
+
+       set (buf, x, y);
+}
+
+void
+VerboseCursor::set_color (uint32_t color)
+{
+       _canvas_item->property_fill_color_rgba() = color;
+}
+
+void
+VerboseCursor::set_position (double x, double y)
+{
+       _canvas_item->property_x() = clamp_x (x);
+       _canvas_item->property_y() = clamp_y (y);
+}
+
+bool
+VerboseCursor::visible () const
+{
+       return _visible;
+}
diff --git a/gtk2_ardour/verbose_cursor.h b/gtk2_ardour/verbose_cursor.h
new file mode 100644 (file)
index 0000000..26b21bf
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+    Copyright (C) 2000-2011 Paul Davis
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <libgnomecanvasmm/item.h>
+#include "ardour/types.h"
+#include "canvas-noevent-text.h"
+#include "canvas.h"
+
+class Editor;
+
+class VerboseCursor
+{
+public:
+       VerboseCursor (Editor *);
+       
+       ArdourCanvas::Item* canvas_item () const;
+       bool visible () const;
+
+       void set_color (uint32_t);
+       
+       void set (std::string const &, double, double);
+       void set_text (std::string const &);
+       void set_position (double, double);
+       void set_time (framepos_t, double, double);
+       void set_duration (framepos_t, framepos_t, double, double);
+
+       void show ();
+       void hide ();
+
+private:
+       double clamp_x (double);
+       double clamp_y (double);
+
+       Editor* _editor;
+       ArdourCanvas::NoEventText* _canvas_item;
+       bool _visible;
+};
index bde630e325444007083eec9e91d27ac3a62b0d80..cb4de41062538859f921b14b0dc1fee89f80a9a0 100644 (file)
@@ -223,6 +223,7 @@ gtk2_ardour_sources = [
         'transpose_dialog.cc',
         'ui_config.cc',
         'utils.cc',
+        'verbose_cursor.cc',
         'version.cc',
         'volume_controller.cc',
         'waveview.cc',