13
0

API to set tooltip y-margin

This commit is contained in:
Robin Gareus 2015-04-25 01:16:39 +02:00
parent e22d7c2e28
commit 7565ebd4ed
2 changed files with 5 additions and 3 deletions

View File

@ -32,7 +32,7 @@ namespace Gtkmm2ext {
class LIBGTKMM2EXT_API PersistentTooltip : public sigc::trackable
{
public:
PersistentTooltip (Gtk::Widget *);
PersistentTooltip (Gtk::Widget *, int margin_y = 0);
virtual ~PersistentTooltip ();
void set_tip (std::string);
@ -62,6 +62,7 @@ private:
sigc::connection _timeout;
/** The tip text */
std::string _tip;
int _margin_y;
};
}

View File

@ -28,11 +28,12 @@ using namespace Gtk;
using namespace Gtkmm2ext;
/** @param target The widget to provide the tooltip for */
PersistentTooltip::PersistentTooltip (Gtk::Widget* target)
PersistentTooltip::PersistentTooltip (Gtk::Widget* target, int margin_y)
: _target (target)
, _window (0)
, _label (0)
, _maybe_dragging (false)
, _margin_y (margin_y)
{
target->signal_enter_notify_event().connect (sigc::mem_fun (*this, &PersistentTooltip::enter), false);
target->signal_leave_notify_event().connect (sigc::mem_fun (*this, &PersistentTooltip::leave), false);
@ -138,7 +139,7 @@ PersistentTooltip::show ()
int rx, ry, sw;
sw= gdk_screen_width();
_target->get_window()->get_origin (rx, ry);
_window->move (rx, ry + _target->get_height());
_window->move (rx, ry + _target->get_height() + _margin_y);
_window->present ();
/* the window needs to be realized first