13
0

API to set tooltip y-margin

Conflicts:
	libs/gtkmm2ext/gtkmm2ext/persistent_tooltip.h
	libs/gtkmm2ext/persistent_tooltip.cc
This commit is contained in:
Robin Gareus 2015-04-25 01:16:39 +02:00 committed by Paul Davis
parent 016beaab9b
commit 96078650c9
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 *, bool draggable = false);
PersistentTooltip (Gtk::Widget *, bool draggable = false, int margin_y = 0);
virtual ~PersistentTooltip ();
void set_tip (std::string);
@ -70,6 +70,7 @@ class LIBGTKMM2EXT_API PersistentTooltip : public sigc::trackable
std::string _tip;
Pango::FontDescription _font;
bool _align_to_center;
int _margin_y;
};
}

View File

@ -30,13 +30,14 @@ using namespace Gtk;
using namespace Gtkmm2ext;
/** @param target The widget to provide the tooltip for */
PersistentTooltip::PersistentTooltip (Gtk::Widget* target, bool draggable)
PersistentTooltip::PersistentTooltip (Gtk::Widget* target, bool draggable, int margin_y)
: _target (target)
, _window (0)
, _label (0)
, _draggable (draggable)
, _maybe_dragging (false)
, _align_to_center (true)
, _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);
@ -157,7 +158,7 @@ PersistentTooltip::show ()
the screen, so don't show it in the usual place.
*/
rx = sw - _window->get_width();
_window->move (rx, ry + _target->get_height());
_window->move (rx, ry + _target->get_height() + _margin_y);
} else {
if (_align_to_center) {
_window->move (rx + (_target->get_width () - _window->get_width ()) / 2, ry + _target->get_height());