Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/sugar/graphics
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-02-03 14:03:36 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-02-03 14:03:36 (GMT)
commite8c36247a533c662e057ab28a01707bd15d596e1 (patch)
tree7a80ec963f980b66fbad40734342096583bf9961 /src/sugar/graphics
parentd0d4f551218eeb026fe49da6541b2642c871c190 (diff)
Palette positioning fixes #298
Don't try to align the palette to the edges if the invoker is AT_CURSOR, and always try to move the palette completely into the screen if at all possible.
Diffstat (limited to 'src/sugar/graphics')
-rw-r--r--src/sugar/graphics/palette.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/sugar/graphics/palette.py b/src/sugar/graphics/palette.py
index de5b8e0..070eb08 100644
--- a/src/sugar/graphics/palette.py
+++ b/src/sugar/graphics/palette.py
@@ -836,7 +836,17 @@ class Invoker(gobject.GObject):
def get_position(self, palette_dim):
alignment = self.get_alignment(palette_dim)
- return self._get_position_for_alignment(alignment, palette_dim)
+ rect = self._get_position_for_alignment(alignment, palette_dim)
+
+ # In case our efforts to find an optimum place inside the screen failed,
+ # just make sure the palette fits inside the screen if at all possible.
+ rect.x = max(0, rect.x)
+ rect.y = max(0, rect.y)
+
+ rect.x = min(rect.x, self._screen_area.width - rect.width)
+ rect.y = min(rect.y, self._screen_area.height - rect.height)
+
+ return rect
def get_alignment(self, palette_dim):
best_alignment = None
@@ -877,7 +887,7 @@ class Invoker(gobject.GObject):
pv = -float(palette_dim[1] - dbottom - rect.height) \
/ palette_dim[1]
- else:
+ elif best_alignment in self.TOP or best_alignment in self.BOTTOM:
dleft = rect.x - screen_area.x
dright = screen_area.x + screen_area.width - rect.x - rect.width