13
0

new API for TrackingText and similar items

This commit is contained in:
Paul Davis 2014-06-26 15:07:12 -04:00
parent ae4c4c8f90
commit 3accf1d2af
2 changed files with 43 additions and 0 deletions

View File

@ -767,6 +767,28 @@ GtkCanvas::on_button_release_event (GdkEventButton* ev)
return deliver_event (reinterpret_cast<GdkEvent*>(&copy));
}
bool
GtkCanvas::get_mouse_position (Duple& winpos) const
{
int x;
int y;
Gdk::ModifierType mask;
Glib::RefPtr<Gdk::Window> self = Glib::RefPtr<Gdk::Window>::cast_const (get_window ());
if (!self) {
std::cerr << " no self window\n";
winpos = Duple (0, 0);
return false;
}
Glib::RefPtr<Gdk::Window> win = self->get_pointer (x, y, mask);
winpos.x = x;
winpos.y = y;
return true;
}
/** Handler for GDK motion events.
* @param ev Event.
* @return true if the event was handled.
@ -788,6 +810,8 @@ GtkCanvas::on_motion_notify_event (GdkEventMotion* ev)
DEBUG_TRACE (PBD::DEBUG::CanvasEvents, string_compose ("canvas motion @ %1, %2 canvas @ %3, %4\n", ev->x, ev->y, copy.motion.x, copy.motion.y));
MouseMotion (point); /* EMIT SIGNAL */
pick_current_item (point, ev->state);
/* Now deliver the motion event. It may seem a little inefficient

View File

@ -113,6 +113,23 @@ public:
virtual Coord width () const = 0;
virtual Coord height () const = 0;
/** Store the coordinates of the mouse pointer in window coordinates in
@param winpos. Return true if the position was within the window,
false otherwise.
*/
virtual bool get_mouse_position (Duple& winpos) const = 0;
/** Signal to be used by items that need to track the mouse position
within the window.
*/
sigc::signal<void,Duple const&> MouseMotion;
/** Ensures that the position given by @param winpos (in window
coordinates) is within the current window area, possibly reduced by
@param border.
*/
Duple clamp_to_window (Duple const& winpos, Duple border = Duple());
void zoomed();
std::string indent() const;
@ -150,6 +167,8 @@ public:
Coord width() const;
Coord height() const;
bool get_mouse_position (Duple& winpos) const;
protected:
bool on_scroll_event (GdkEventScroll *);
bool on_expose_event (GdkEventExpose *);