API to set tooltip y-margin
authorRobin Gareus <robin@gareus.org>
Fri, 24 Apr 2015 23:16:39 +0000 (01:16 +0200)
committerRobin Gareus <robin@gareus.org>
Fri, 24 Apr 2015 23:16:39 +0000 (01:16 +0200)
libs/gtkmm2ext/gtkmm2ext/persistent_tooltip.h
libs/gtkmm2ext/persistent_tooltip.cc

index 840280f701b77cf5aef49573cd01f4859e6cdcb9..6507bbb4795021b4bac0c8042299a85af94b2a8a 100644 (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;
 };
 
 }
index 731ede52d9d7bf4aa29bf6dc6d3088afb27b3c03..ae4c2e45c61407f8aa8b0a160971408143f451b5 100644 (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