diff options
author | florent <florent.pigout@gmail.com> | 2011-06-17 19:23:27 (GMT) |
---|---|---|
committer | florent <florent.pigout@gmail.com> | 2011-06-17 19:23:27 (GMT) |
commit | 204fcb935f2e798f4f1fd4f40c26bb97c1c38de2 (patch) | |
tree | 7514c6f79b81652a9ec271f9546eaddb3e696379 | |
parent | 74d06470998afa3c4204a02f29ebacbccbcf8f0c (diff) |
add simple splash when loading edit screens
-rw-r--r-- | activity.py | 17 | ||||
-rw-r--r-- | atoidejouer/ui/screens.py | 55 | ||||
-rw-r--r-- | static/data/graphics/splash.png | bin | 0 -> 1006 bytes |
3 files changed, 70 insertions, 2 deletions
diff --git a/activity.py b/activity.py index 2de755a..2cc4574 100644 --- a/activity.py +++ b/activity.py @@ -7,7 +7,7 @@ from functools import partial from gettext import gettext as _ # gtk import -import gtk +import gtk, glib # ... gtk.gdk.threads_init() @@ -154,6 +154,8 @@ class AToiDeJouerActivity(activity.Activity): self._current = None self._handler_id = None self._number_of_keys = 1 + # .. + self.__splash = None # sequence dict and list self.graphic_keys = StoryKeys('graphics', self) self.sound_keys = StoryKeys('sounds', self) @@ -236,6 +238,19 @@ class AToiDeJouerActivity(activity.Activity): else: # update current screen name self._current = toolbar.name if name is None else name + # init splash + if self._current in ['graphics', 'sounds']: + if self.__splash is None: + self.__splash = screens.Splash(toolbar) + else: + self.__splash._show() + # ... + glib.idle_add(partial(self.__idle_change, toolbar)) + else: + # .. + self.__idle_change(toolbar) + + def __idle_change(self, toolbar): # already exist if self._current in self._screens: # show diff --git a/atoidejouer/ui/screens.py b/atoidejouer/ui/screens.py index 31518ea..551edab 100644 --- a/atoidejouer/ui/screens.py +++ b/atoidejouer/ui/screens.py @@ -479,7 +479,7 @@ class ScreenStory(graphics.Scene): def _show(self): # first refresh - # self.refresh() + self.refresh() # .. self.show() # update size request @@ -491,6 +491,59 @@ class ScreenStory(graphics.Scene): pass +class Splash(graphics.Scene): + + def __init__(self, toolbar): + # .. + graphics.Scene.__init__(self) + # .. + # self.background_color = "#ffffff" + # .. + self.__current = 0 + # toolbar keep + self.toolbar = toolbar + # .. + self._image = None + # .. + if self.toolbar is None: + self._screen_height = None + self._screen_width = None + else: + # keep some info + self._screen_height = gtk.gdk.screen_height() + self._screen_width = gtk.gdk.screen_width() + # .. + self._show() + + def _update_x_y(self, path): + # get file size + _c, _w, _h = image.get_image_info(path) + # update x + _x = ((self._screen_width - _w) / 2) + # update y + _y = ((self._screen_height - _h - 88) / 2) + # return it + return _x, _y + + def _get_image(self): + # get path + _path = storage.get_image_path('splash', dir_='data') + # .. + _x, _y = self._update_x_y(_path) + # image + return graphics.Image(_path, x=_x, y=_y, draggable=False) + + def _show(self): + # .. + self._image = self._get_image() + # do add + self.add_child(self._image) + # show + self.show() + # update toolbar + self.toolbar.activity.set_canvas(self) + + class ScreenEdit(gtk.HBox): def __init__(self, toolbar): diff --git a/static/data/graphics/splash.png b/static/data/graphics/splash.png Binary files differnew file mode 100644 index 0000000..54d6b83 --- /dev/null +++ b/static/data/graphics/splash.png |