diff options
author | Yann Leboulanger <asterix@lagaule.org> | 2013-10-30 16:44:19 +0400 |
---|---|---|
committer | Yann Leboulanger <asterix@lagaule.org> | 2013-10-30 16:44:19 +0400 |
commit | f0bdd075c67a526473c53f54257b065525e0e8b4 (patch) | |
tree | 9ec2e00ea2f3cef2d0995e220f69471b2a0e0578 /src/tooltips.py | |
parent | c8c466a4667f09d311a46e6e9fb93ee3d8bc4bc6 (diff) |
fix position of tooltip when tooltip is too high for the screen. Fixes #7490
Diffstat (limited to 'src/tooltips.py')
-rw-r--r-- | src/tooltips.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/tooltips.py b/src/tooltips.py index 3b373b927..6521a7ed7 100644 --- a/src/tooltips.py +++ b/src/tooltips.py @@ -115,6 +115,22 @@ class BaseTooltip: def on_size_allocate(self, widget, rect): half_width = rect.width / 2 + 1 + if self.preferred_position[1] + rect.height > self.screen.get_height(): + # flip tooltip up + self.preferred_position[1] -= rect.height + self.widget_height + 8 + if self.preferred_position[1] < 0: + self.preferred_position[1] = self.screen.get_height() - \ + rect.height - 2 + + if self.preferred_position[0] + rect.width + 7 < \ + self.screen.get_width(): + self.preferred_position[0] = self.preferred_position[0] + 7 + else: + self.preferred_position[0] = self.preferred_position[0] - \ + rect.width - 7 + self.win.move(self.preferred_position[0], + self.preferred_position[1]) + return if self.preferred_position[0] < half_width: self.preferred_position[0] = 0 elif self.preferred_position[0] + rect.width > \ @@ -122,11 +138,6 @@ class BaseTooltip: self.preferred_position[0] = self.screen.get_width() - rect.width elif not self.check_last_time: self.preferred_position[0] -= half_width - if self.preferred_position[1] + rect.height > self.screen.get_height(): - # flip tooltip up - self.preferred_position[1] -= rect.height + self.widget_height + 8 - if self.preferred_position[1] < 0: - self.preferred_position[1] = 0 self.win.move(self.preferred_position[0], self.preferred_position[1]) def show_tooltip(self, data, widget_height, widget_y_position): |