summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-06-26 15:07:29 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2014-06-26 15:10:24 -0400
commit4e689d9496394e7218e1b09d0cef2a61f3791b62 (patch)
tree1f6e11cdc7c55df744e739e7792a1bd50590afbe
parent3accf1d2af0834cb2c13df0e6de085a2ce7d521c (diff)
use new TrackingText for verbose cursor
-rw-r--r--gtk2_ardour/editor_drag.cc68
-rw-r--r--gtk2_ardour/editor_mouse.cc27
-rw-r--r--gtk2_ardour/midi_region_view.cc24
-rw-r--r--gtk2_ardour/verbose_cursor.cc77
-rw-r--r--gtk2_ardour/verbose_cursor.h28
5 files changed, 52 insertions, 172 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 05e24fa84c..c4000ddd45 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -406,58 +406,22 @@ Drag::abort ()
void
Drag::show_verbose_cursor_time (framepos_t frame)
{
- /* We use DragManager::current_pointer_y() here
- because we need to position the verbose canvas
- cursor within the overall canvas, regardless
- of this particular drag's _trackview_only
- setting.
- */
-
- _editor->verbose_cursor()->set_time (
- frame,
- _drags->current_pointer_x() + 10,
- _drags->current_pointer_y() + 10
- );
-
+ _editor->verbose_cursor()->set_time (frame);
_editor->verbose_cursor()->show ();
}
void
-Drag::show_verbose_cursor_duration (framepos_t start, framepos_t end, double xoffset)
+Drag::show_verbose_cursor_duration (framepos_t start, framepos_t end, double /*xoffset*/)
{
- _editor->verbose_cursor()->show (xoffset);
-
- /* We use DragManager::current_pointer_y() here
- because we need to position the verbose canvas
- cursor within the overall canvas, regardless
- of this particular drag's _trackview_only
- setting.
- */
-
- _editor->verbose_cursor()->set_duration (
- start, end,
- _drags->current_pointer_x() + 10,
- _drags->current_pointer_y() + 10
- );
+ _editor->verbose_cursor()->set_duration (start, end);
+ _editor->verbose_cursor()->show ();
}
void
Drag::show_verbose_cursor_text (string const & text)
{
+ _editor->verbose_cursor()->set (text);
_editor->verbose_cursor()->show ();
-
- /* We use DragManager::current_pointer_y() here
- because we need to position the verbose canvas
- cursor within the overall canvas, regardless
- of this particular drag's _trackview_only
- setting.
- */
-
- _editor->verbose_cursor()->set (
- text,
- _drags->current_pointer_x() + 10,
- _drags->current_pointer_y() + 10
- );
}
boost::shared_ptr<Region>
@@ -1533,6 +1497,8 @@ RegionSpliceDrag::motion (GdkEvent* event, bool)
*/
_editor->verbose_cursor()->hide ();
return;
+ } else {
+ _editor->verbose_cursor()->show ();
}
int dir;
@@ -1798,8 +1764,7 @@ VideoTimeLineDrag::start_grab (GdkEvent* event, Gdk::Cursor*)
Timecode::Time timecode;
_editor->session()->sample_to_timecode(abs(_startdrag_video_offset), timecode, true /* use_offset */, false /* use_subframes */ );
snprintf (buf, sizeof (buf), "Video Start:\n%c%02" PRId32 ":%02" PRId32 ":%02" PRId32 ":%02" PRId32, (_startdrag_video_offset<0?'-':' '), timecode.hours, timecode.minutes, timecode.seconds, timecode.frames);
- _editor->verbose_cursor()->set(buf, event->button.x + 10, event->button.y + 10);
- _editor->verbose_cursor()->show ();
+ show_verbose_cursor_text (buf);
}
void
@@ -1848,8 +1813,7 @@ VideoTimeLineDrag::motion (GdkEvent* event, bool first_move)
, _("Diff:"),
(dt<0?'-':' '), timediff.hours, timediff.minutes, timediff.seconds, timediff.frames
);
- _editor->verbose_cursor()->set(buf, event->button.x + 10, event->button.y + 10);
- _editor->verbose_cursor()->show ();
+ show_verbose_cursor_text (buf);
}
void
@@ -3288,10 +3252,7 @@ ControlPointDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
_point->line().start_drag_single (_point, _fixed_grab_x, fraction);
- _editor->verbose_cursor()->set (_point->line().get_verbose_cursor_string (fraction),
- event->button.x + 10, event->button.y + 10);
-
- _editor->verbose_cursor()->show ();
+ show_verbose_cursor_text (_point->line().get_verbose_cursor_string (fraction));
_pushing = Keyboard::modifier_state_contains (event->button.state, Keyboard::PrimaryModifier);
@@ -3351,7 +3312,7 @@ ControlPointDrag::motion (GdkEvent* event, bool)
_point->line().drag_motion (_editor->sample_to_pixel_unrounded (cx_frames), fraction, false, _pushing, _final_index);
- _editor->verbose_cursor()->set_text (_point->line().get_verbose_cursor_string (fraction));
+ show_verbose_cursor_text (_point->line().get_verbose_cursor_string (fraction));
}
void
@@ -3437,10 +3398,7 @@ LineDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
_line->start_drag_line (before, after, fraction);
- _editor->verbose_cursor()->set (_line->get_verbose_cursor_string (fraction),
- event->button.x + 10, event->button.y + 10);
-
- _editor->verbose_cursor()->show ();
+ show_verbose_cursor_text (_line->get_verbose_cursor_string (fraction));
}
void
@@ -3465,7 +3423,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, false, ignored);
- _editor->verbose_cursor()->set_text (_line->get_verbose_cursor_string (fraction));
+ show_verbose_cursor_text (_line->get_verbose_cursor_string (fraction));
}
void
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc
index 479a3f272e..d0287328c5 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -1738,16 +1738,9 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_
cp = static_cast<ControlPoint*>(item->get_data ("control_point"));
cp->show ();
- double at_x, at_y;
- at_x = cp->get_x();
- at_y = cp->get_y ();
- cp->i2w (at_x, at_y);
- at_x += 10.0;
- at_y += 10.0;
-
fraction = 1.0 - (cp->get_y() / cp->line().height());
- _verbose_cursor->set (cp->line().get_verbose_cursor_string (fraction), at_x, at_y);
+ _verbose_cursor->set (cp->line().get_verbose_cursor_string (fraction));
_verbose_cursor->show ();
}
break;
@@ -1859,7 +1852,7 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent*, ItemType item_type)
switch (item_type) {
case ControlPointItem:
- _verbose_cursor->hide ();
+ _verbose_cursor->hide ();
break;
case GainLineItem:
@@ -2019,25 +2012,19 @@ Editor::motion_handler (ArdourCanvas::Item* /*item*/, GdkEvent* event, bool from
current_stepping_trackview = 0;
step_timeout.disconnect ();
}
-
+
if (_session && _session->actively_recording()) {
/* Sorry. no dragging stuff around while we record */
return true;
}
-
+
update_join_object_range_location (event->motion.y);
-
- bool handled = false;
+
if (_drags->active ()) {
- handled = _drags->motion_handler (event, from_autoscroll);
- }
-
- if (!handled) {
- return false;
+ return _drags->motion_handler (event, from_autoscroll);
}
- track_canvas_motion (event);
- return true;
+ return false;
}
bool
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index 00cbad7733..a738b3c0c4 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -44,6 +44,7 @@
#include "evoral/midi_util.h"
#include "canvas/debug.h"
+#include "canvas/text.h"
#include "automation_region_view.h"
#include "automation_time_axis.h"
@@ -3809,28 +3810,9 @@ MidiRegionView::show_verbose_cursor (boost::shared_ptr<NoteType> n) const
void
MidiRegionView::show_verbose_cursor (string const & text, double xoffset, double yoffset) const
{
- double wx, wy;
-
- trackview.editor().verbose_cursor()->set_text (text);
- trackview.editor().get_pointer_position (wx, wy);
-
- wx += xoffset;
- wy += yoffset;
-
- /* Flip the cursor above the mouse pointer if it would overlap the bottom of the canvas */
-
- boost::optional<ArdourCanvas::Rect> bbo = trackview.editor().verbose_cursor()->item().bounding_box();
-
- assert (bbo);
-
- ArdourCanvas::Rect bb = bbo.get();
-
- if ((wy + bb.y1 - bb.y0) > trackview.editor().visible_canvas_height()) {
- wy -= (bb.y1 - bb.y0) + 2 * yoffset;
- }
-
- trackview.editor().verbose_cursor()->set_position (wx, wy);
+ trackview.editor().verbose_cursor()->set (text);
trackview.editor().verbose_cursor()->show ();
+ trackview.editor().verbose_cursor()->set_offset (ArdourCanvas::Duple (xoffset, yoffset));
}
/** @param p A session framepos.
diff --git a/gtk2_ardour/verbose_cursor.cc b/gtk2_ardour/verbose_cursor.cc
index e1c37f591b..3ce093511b 100644
--- a/gtk2_ardour/verbose_cursor.cc
+++ b/gtk2_ardour/verbose_cursor.cc
@@ -24,6 +24,7 @@
#include "canvas/debug.h"
#include "canvas/scroll_group.h"
+#include "canvas/tracking_text.h"
#include "ardour_ui.h"
#include "audio_clock.h"
@@ -39,13 +40,9 @@ using namespace ARDOUR;
VerboseCursor::VerboseCursor (Editor* editor)
: _editor (editor)
- , _visible (false)
- , _xoffset (0)
- , _yoffset (0)
{
- _canvas_item = new ArdourCanvas::Text (_editor->get_noscroll_group());
+ _canvas_item = new ArdourCanvas::TrackingText (_editor->get_noscroll_group());
CANVAS_DEBUG_NAME (_canvas_item, "verbose canvas cursor");
- _canvas_item->set_ignore_events (true);
_canvas_item->set_font_description (Pango::FontDescription (ARDOUR_UI::config()->get_canvasvar_LargerBoldFont()));
}
@@ -55,63 +52,38 @@ VerboseCursor::canvas_item () const
return _canvas_item;
}
-/** Set the contents and position of the cursor. Coordinates are in window space
+/** Set the contents of the cursor.
*/
void
-VerboseCursor::set (string const & text, double x, double y)
-{
- set_text (text);
- set_position (x, y);
-}
-
-void
-VerboseCursor::set_text (string const & text)
+VerboseCursor::set (string const & text)
{
_canvas_item->set (text);
}
-/** @param xoffset x offset to be applied on top of any set_position() call
- * before the next show ().
- * @param yoffset y offset as above.
- */
void
-VerboseCursor::show (double xoffset, double yoffset)
+VerboseCursor::show ()
{
- _xoffset = xoffset;
- _yoffset = yoffset;
-
- if (_visible) {
- return;
- }
-
- _canvas_item->raise_to_top ();
- _canvas_item->show ();
- _visible = true;
+ _canvas_item->show_and_track (true, true);
+ _canvas_item->parent()->raise_to_top ();
}
void
VerboseCursor::hide ()
{
_canvas_item->hide ();
- _visible = false;
+ _canvas_item->parent()->lower_to_bottom ();
+ /* reset back to a sensible default for the next time we display the VC */
+ _canvas_item->set_offset (ArdourCanvas::Duple (10, 10));
}
-double
-VerboseCursor::clamp_x (double x)
-{
- _editor->clamp_verbose_cursor_x (x);
- return x;
-}
-
-double
-VerboseCursor::clamp_y (double y)
+void
+VerboseCursor::set_offset (ArdourCanvas::Duple const & d)
{
- _editor->clamp_verbose_cursor_y (y);
- return y;
+ _canvas_item->set_offset (d);
}
void
-VerboseCursor::set_time (framepos_t frame, double x, double y)
+VerboseCursor::set_time (framepos_t frame)
{
char buf[128];
Timecode::Time timecode;
@@ -159,11 +131,11 @@ VerboseCursor::set_time (framepos_t frame, double x, double y)
break;
}
- set (buf, x, y);
+ _canvas_item->set (buf);
}
void
-VerboseCursor::set_duration (framepos_t start, framepos_t end, double x, double y)
+VerboseCursor::set_duration (framepos_t start, framepos_t end)
{
char buf[128];
Timecode::Time timecode;
@@ -245,7 +217,7 @@ VerboseCursor::set_duration (framepos_t start, framepos_t end, double x, double
break;
}
- set (buf, x, y);
+ _canvas_item->set (buf);
}
void
@@ -254,21 +226,8 @@ VerboseCursor::set_color (uint32_t color)
_canvas_item->set_color (color);
}
-/** Set the position of the verbose cursor. Any x/y offsets
- * passed to the last call to show() will be applied to the
- * coordinates passed in here.
- *
- * Coordinates are in window space.
- */
-void
-VerboseCursor::set_position (double x, double y)
-{
- _canvas_item->set_x_position (clamp_x (x + _xoffset));
- _canvas_item->set_y_position (clamp_y (y + _yoffset));
-}
-
bool
VerboseCursor::visible () const
{
- return _visible;
+ return _canvas_item->visible();
}
diff --git a/gtk2_ardour/verbose_cursor.h b/gtk2_ardour/verbose_cursor.h
index 8db45608cd..95cd65e7b8 100644
--- a/gtk2_ardour/verbose_cursor.h
+++ b/gtk2_ardour/verbose_cursor.h
@@ -18,11 +18,14 @@
*/
#include "ardour/types.h"
-#include "canvas/text.h"
#include "canvas/canvas.h"
class Editor;
+namespace ArdourCanvas {
+ class TrackingText;
+}
+
class VerboseCursor
{
public:
@@ -33,24 +36,15 @@ public:
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 set (std::string const &);
+ void set_time (framepos_t);
+ void set_duration (framepos_t, framepos_t);
+ void set_offset (ArdourCanvas::Duple const&);
- void show (double xoffset = 0, double yoffset = 0);
+ void show ();
void hide ();
- ArdourCanvas::Item& item() { return *_canvas_item; }
-
private:
- double clamp_x (double);
- double clamp_y (double);
-
- Editor* _editor;
- ArdourCanvas::Text* _canvas_item;
- bool _visible;
- double _xoffset;
- double _yoffset;
+ Editor* _editor;
+ ArdourCanvas::TrackingText* _canvas_item;
};