diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-06-20 03:05:25 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-06-20 03:05:25 (GMT) |
commit | 8212ce759543ae7fee15c48040256dd2bedd8ee0 (patch) | |
tree | 4af59da650945c72fbd251dc07bee89772390711 /sugar | |
parent | 758d9fba4350d7f5eb48a3ebe6fbd3cba4a7fcf0 (diff) |
Ensure to not do unnecessary move when sliding
Diffstat (limited to 'sugar')
-rw-r--r-- | sugar/shell/WindowManager.py | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/sugar/shell/WindowManager.py b/sugar/shell/WindowManager.py index 7e9a2fe..776b991 100644 --- a/sugar/shell/WindowManager.py +++ b/sugar/shell/WindowManager.py @@ -54,7 +54,7 @@ class WindowManager: def set_position(self, position): self._position = position - def _update_size_and_position(self): + def _calc_size_and_position(self): screen_width = self._window.get_screen().get_width() screen_height = self._window.get_screen().get_height() @@ -69,27 +69,37 @@ class WindowManager: height = int(screen_height * self._height) if self._position is WindowManager.CENTER: - x = int((screen_width - width) / 2) - y = int((screen_height - height) / 2) + self._x = int((screen_width - width) / 2) + self._y = int((screen_height - height) / 2) elif self._position is WindowManager.LEFT: - x = - int((1.0 - self._sliding_pos) * width) - y = int((screen_height - height) / 2) + self._x = - int((1.0 - self._sliding_pos) * width) + self._y = int((screen_height - height) / 2) elif self._position is WindowManager.TOP: - x = int((screen_width - width) / 2) - y = - int((1.0 - self._sliding_pos) * height) - - self._window.move(x, y) - self._window.resize(width, height) + self._x = int((screen_width - width) / 2) + self._y = - int((1.0 - self._sliding_pos) * height) + + self._real_width = width + self._real_height = height + + def _update_size_and_position(self): + self._calc_size_and_position() + self._window.move(self._x, self._y) + self._window.resize(self._real_width, self._real_height) + + def _update_position(self): + self._calc_size_and_position() + self._window.move(self._x, self._y) def __slide_in_timeout_cb(self): - self._window.show() + if self._sliding_pos == 0: + self._window.show() self._sliding_pos += 0.05 if self._sliding_pos > 1.0: self._sliding_pos = 1.0 - self._update_size_and_position() + self._update_position() if self._sliding_pos == 1.0: return False @@ -104,7 +114,7 @@ class WindowManager: if self._sliding_pos < 0: self._sliding_pos = 0 - self._update_size_and_position() + self._update_position() if self._sliding_pos == 0: self._window.hide() |