Ensure to not do unnecessary move when sliding
This commit is contained in:
parent
758d9fba43
commit
8212ce7595
@ -54,7 +54,7 @@ class WindowManager:
|
|||||||
def set_position(self, position):
|
def set_position(self, position):
|
||||||
self._position = 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_width = self._window.get_screen().get_width()
|
||||||
screen_height = self._window.get_screen().get_height()
|
screen_height = self._window.get_screen().get_height()
|
||||||
|
|
||||||
@ -69,27 +69,37 @@ class WindowManager:
|
|||||||
height = int(screen_height * self._height)
|
height = int(screen_height * self._height)
|
||||||
|
|
||||||
if self._position is WindowManager.CENTER:
|
if self._position is WindowManager.CENTER:
|
||||||
x = int((screen_width - width) / 2)
|
self._x = int((screen_width - width) / 2)
|
||||||
y = int((screen_height - height) / 2)
|
self._y = int((screen_height - height) / 2)
|
||||||
elif self._position is WindowManager.LEFT:
|
elif self._position is WindowManager.LEFT:
|
||||||
x = - int((1.0 - self._sliding_pos) * width)
|
self._x = - int((1.0 - self._sliding_pos) * width)
|
||||||
y = int((screen_height - height) / 2)
|
self._y = int((screen_height - height) / 2)
|
||||||
elif self._position is WindowManager.TOP:
|
elif self._position is WindowManager.TOP:
|
||||||
x = int((screen_width - width) / 2)
|
self._x = int((screen_width - width) / 2)
|
||||||
y = - int((1.0 - self._sliding_pos) * height)
|
self._y = - int((1.0 - self._sliding_pos) * height)
|
||||||
|
|
||||||
self._window.move(x, y)
|
self._real_width = width
|
||||||
self._window.resize(width, height)
|
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):
|
def __slide_in_timeout_cb(self):
|
||||||
self._window.show()
|
if self._sliding_pos == 0:
|
||||||
|
self._window.show()
|
||||||
|
|
||||||
self._sliding_pos += 0.05
|
self._sliding_pos += 0.05
|
||||||
|
|
||||||
if self._sliding_pos > 1.0:
|
if self._sliding_pos > 1.0:
|
||||||
self._sliding_pos = 1.0
|
self._sliding_pos = 1.0
|
||||||
|
|
||||||
self._update_size_and_position()
|
self._update_position()
|
||||||
|
|
||||||
if self._sliding_pos == 1.0:
|
if self._sliding_pos == 1.0:
|
||||||
return False
|
return False
|
||||||
@ -104,7 +114,7 @@ class WindowManager:
|
|||||||
if self._sliding_pos < 0:
|
if self._sliding_pos < 0:
|
||||||
self._sliding_pos = 0
|
self._sliding_pos = 0
|
||||||
|
|
||||||
self._update_size_and_position()
|
self._update_position()
|
||||||
|
|
||||||
if self._sliding_pos == 0:
|
if self._sliding_pos == 0:
|
||||||
self._window.hide()
|
self._window.hide()
|
||||||
|
Loading…
Reference in New Issue
Block a user