2 * Copyright (C) 2014-2015 Paul Davis <paul@linuxaudiosystems.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "canvas/canvas.h"
22 #include "canvas/tracking_text.h"
24 using namespace ArdourCanvas;
26 TrackingText::TrackingText (Canvas* c)
30 , offset (Duple (10, 10))
35 TrackingText::TrackingText (Item* p)
39 , offset (Duple (10, 10))
47 _canvas->MouseMotion.connect (sigc::mem_fun (*this, &TrackingText::pointer_motion));
48 set_ignore_events (true);
54 TrackingText::pointer_motion (Duple const & winpos)
60 Duple pos (_parent->window_to_item (winpos));
70 pos = pos.translate (offset);
72 /* keep inside the window */
74 Rect r (0, 0, _canvas->width(), _canvas->height());
76 /* border of 200 pixels on the right, and 50 on all other sides */
78 const double border = 50.0;
81 r.x1 = std::max (r.x0, (r.x1 - 200.0));
83 r.y1 = std::max (r.y0, (r.y1 - border));
89 } else if (pos.x > r.x1) {
95 } else if (pos.y > r.y1) {
105 TrackingText::show_and_track (bool tx, bool ty)
110 bool was_visible = _visible;
114 /* move to current pointer location. do this after show() so that
115 * _visible is true, and thus ::pointer_motion() will do
120 if (!_canvas->get_mouse_position (winpos)) {
124 pointer_motion (winpos);
129 TrackingText::set_x_offset (double o)
137 TrackingText::set_y_offset (double o)
145 TrackingText::set_offset (Duple const & d)