Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Silbe <silbe@activitycentral.com>2011-03-21 14:15:40 (GMT)
committer Sascha Silbe <silbe@activitycentral.com>2011-12-20 13:19:23 (GMT)
commitf98abcc2bff53188311a417a08d53350185c266f (patch)
treeff0b5d66a759b31d68cecfff3021f8e7db6bf077
parenta884783172da16ed1181f3d01dcf3b3311c38c55 (diff)
accelerated scrolling WIPmultimodewindow
-rw-r--r--src/sugar/graphics/window.py60
1 files changed, 48 insertions, 12 deletions
diff --git a/src/sugar/graphics/window.py b/src/sugar/graphics/window.py
index 506c046..f5bd8d3 100644
--- a/src/sugar/graphics/window.py
+++ b/src/sugar/graphics/window.py
@@ -308,8 +308,8 @@ class MultiModeWindow(gtk.Window):
A transition effect may be provided when switching between modes.
"""
- _SCROLL_INTERVAL_MS = 40
- _SCROLL_TIME_MS = 500
+ _SCROLL_INTERVAL_MS = 300
+ _SCROLL_TIME_MS = 2100
_SCROLL_STEPS = _SCROLL_TIME_MS // _SCROLL_INTERVAL_MS
def __init__(self, modes, **args):
@@ -339,6 +339,8 @@ class MultiModeWindow(gtk.Window):
self.__scroll_step = 0
self.__scroll_direction = 1
self.__scroll_start_time = None
+ self.__scroll_old_snaphot = None
+ self.__scroll_new_snaphot = None
for mode in modes:
self.__vboxes[mode] = gtk.VBox()
@@ -394,11 +396,33 @@ class MultiModeWindow(gtk.Window):
else:
self.__scroll_direction = -1
+ old_pixmap = self.__vboxes[self._current_mode].get_snapshot()
+ self.__scroll_old_snapshot = gtk.image_new_from_pixmap(old_pixmap,
+ None)
+
+ # gtk.OffscreenWindow is only available in PyGtk 2.22+, so we need to
+ # resort to a hack for now
self.__vboxes[mode].hide()
+ self.__vboxes[mode].connect('expose-event', self._switch_to_mode_cb)
self.__layout.put(self.__vboxes[mode],
self.__width * self.__scroll_direction, 0)
self.__vboxes[mode].resize_children()
self.__vboxes[mode].show()
+# gobject.idle_add(self._switch_to_mode_cb)
+
+ @trace()
+ def _switch_to_mode_cb(self, *args):
+ new_pixmap = self.__vboxes[self._next_mode].get_snapshot()
+ self.__layout.remove(self.__vboxes[self._next_mode])
+ self.__scroll_new_snapshot = gtk.image_new_from_pixmap(new_pixmap,
+ None)
+
+ self.__layout.remove(self.__vboxes[self._current_mode])
+ self.__layout.add(self.__scroll_old_snapshot)
+ self.__layout.put(self.__scroll_new_snapshot,
+ self.__width * self.__scroll_direction, 0)
+ self.__layout.show_all()
+
gobject.timeout_add(MultiModeWindow._SCROLL_INTERVAL_MS,
self.__scroll_cb)
@@ -436,8 +460,8 @@ class MultiModeWindow(gtk.Window):
self._unfullscreen_button_timeout_id = None
self._unfullscreen_button_timeout_id = \
- gobject.timeout_add_seconds( \
- _UNFULLSCREEN_BUTTON_VISIBILITY_TIMEOUT, \
+ gobject.timeout_add_seconds(
+ _UNFULLSCREEN_BUTTON_VISIBILITY_TIMEOUT,
self.__unfullscreen_button_timeout_cb)
def unfullscreen(self):
@@ -573,8 +597,8 @@ class MultiModeWindow(gtk.Window):
self._unfullscreen_button_timeout_id = None
self._unfullscreen_button_timeout_id = \
- gobject.timeout_add_seconds( \
- _UNFULLSCREEN_BUTTON_VISIBILITY_TIMEOUT, \
+ gobject.timeout_add_seconds(
+ _UNFULLSCREEN_BUTTON_VISIBILITY_TIMEOUT,
self.__unfullscreen_button_timeout_cb)
return False
@@ -625,22 +649,34 @@ class MultiModeWindow(gtk.Window):
pixel_per_step = self.__width // MultiModeWindow._SCROLL_STEPS
scroll_pixels = self.__scroll_step * pixel_per_step
+ #~ if self.__scroll_direction == 1:
+ #~ self.__layout.move(self.__vboxes[self._current_mode],
+ #~ -scroll_pixels, 0)
+ #~ self.__layout.move(self.__vboxes[self._next_mode],
+ #~ self.__width - scroll_pixels, 0)
+ #~ else:
+ #~ self.__layout.move(self.__vboxes[self._current_mode],
+ #~ scroll_pixels, 0)
+ #~ self.__layout.move(self.__vboxes[self._next_mode],
+ #~ scroll_pixels - self.__width, 0)
if self.__scroll_direction == 1:
- self.__layout.move(self.__vboxes[self._current_mode],
+ self.__layout.move(self.__scroll_old_snapshot,
-scroll_pixels, 0)
- self.__layout.move(self.__vboxes[self._next_mode],
+ self.__layout.move(self.__scroll_new_snapshot,
self.__width - scroll_pixels, 0)
else:
- self.__layout.move(self.__vboxes[self._current_mode],
+ self.__layout.move(self.__scroll_old_snapshot,
scroll_pixels, 0)
- self.__layout.move(self.__vboxes[self._next_mode],
+ self.__layout.move(self.__scroll_new_snapshot,
scroll_pixels - self.__width, 0)
return True
@trace()
def _switch_mode_now(self):
- self.__layout.remove(self.__vboxes[self._current_mode])
- self.__layout.move(self.__vboxes[self._next_mode], 0, 0)
+# self.__layout.remove(self.__vboxes[self._current_mode])
+ self.__layout.add(self.__vboxes[self._next_mode])
+ self.__layout.remove(self.__scroll_old_snapshot)
+ self.__layout.remove(self.__scroll_new_snapshot)
self._current_mode = self._next_mode
self._next_mode = None