Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/atoidepoc/ui/screens.py
diff options
context:
space:
mode:
Diffstat (limited to 'atoidepoc/ui/screens.py')
-rw-r--r--atoidepoc/ui/screens.py216
1 files changed, 159 insertions, 57 deletions
diff --git a/atoidepoc/ui/screens.py b/atoidepoc/ui/screens.py
index 0371c45..690c6a9 100644
--- a/atoidepoc/ui/screens.py
+++ b/atoidepoc/ui/screens.py
@@ -105,24 +105,29 @@ class ScreenBrowserSounds(ScreenBrowser):
ScreenBrowser.__init__(self, toolbar, title=_('Sounds'),
_type='sound')
-PROMENEUR_KEYS = [(20, 12), (40, 12), (60, 12), (80, 12), (100, 12), (80, 12),
- (100, 12), (120, 12), (100, 12), (80, 12), (60, 12), (80, 12),
- (100, 12), (120, 12), (140, 12), (160, 12), (120, 12), (200, 12),
- (120, 12), (200, 12), (220, 12), (220, 12), (220, 12), (220, 12)]
+PROMENEUR_KEYS = [(1.95, 2.2), (3.9, 2.2), (5.86, 2.2), (7.8, 2.2), (9.77, 2.2),
+ (7.8, 2.2), (9.77, 2.2), (11.72, 2.2), (9.77, 2.2), (7.8, 2.2),
+ (5.86, 2.2), (7.8, 2.2), (9.77, 2.2), (11.72, 2.2), (13.67, 2.2),
+ (15.625, 2.2), (17.56, 2.2), (19.53, 2.2), (19.53, 2.2), (19.53, 2.2),
+ (21.48, 2.2), (21.48, 2.2), (19.53, 2.2), (17.56, 2.2)]
-CHIEN_KEYS = [(80, 54), (100, 32), (80, 54), (100, 32), (120, 54), (140, 32),
- (140, 54), (160, 32), (200, 54), (200, 32), (220, 54), (240, 32),
- (260, 54), (240, 32), (220, 54), (200, 32), (180, 54), (160, 32),
- (200, 54), (200, 32), (220, 54), (240, 32), (160, 54), (280, 32)]
+CHIEN_KEYS = [(7.8, 12.3), (9.77, 10.125), (7.8, 12.3), (9.77, 10.125), (11.72, 12.3),
+ (13.67, 10.125), (13.67, 12.3), (15.625, 10.125), (19.53, 12.3), (19.53, 10.125),
+ (21.48, 12.3), (23.44, 10.125), (25.4, 12.3), (23.44, 10.125), (21.48, 12.3),
+ (19.53, 10.125), (17.56, 12.3), (15.625, 10.125), (19.53, 12.3), (19.53, 10.125),
+ (21.48, 12.3), (23.44, 10.125), (25.4, 12.3), (27.34, 10.125)]
-MAISONS_KEYS = [(0, 0), (0, 2), (2, 4), (0, 2), (2, 0), (2, 2),
- (0, 4), (0, 6), (-2, 8), (0, 6), (-2, 4), (0, 2),
- (0, 2), (2, 2), (0, 0), (-2, 2), (0, 4), (2, 6),
- (0, 8), (0, 6), (0, 4), (-2, 2), (-2, 2), (0, 0)]
+MAISONS_KEYS = [(0, 0), (0, 0.2), (0.2, 0.4), (0, 0.2), (0.2, 0),
+ (0.2, 0.2), (0, 0.4), (0, 0.6), (-0.2, 0.8), (0, 0.6),
+ (-0.2, 0.4), (0, 0.2), (0, 0.2), (0.2, 0.2), (0, 0),
+ (-0.2, 0.2), (0, 0.4), (0.2, 0.6), (0, 0.8), (0, 0.6),
+ (0, 0.4), (-0.2, 0.2), (-0.2, 0.2), (0, 0)]
-CIEL_KEYS = [(0, -9) for _i in range(24)]
+CIEL_KEYS = [(0, -1.8) for _i in range(24)]
-BOTTOM_KEYS = [(0, 16) for _i in range(24)]
+BOTTOM_KEYS = [(0, 1.56) for _i in range(24)]
+
+OVERLAY_KEYS = [(-0.4*_i, 0) for _i in range(24)]
DEFAULT_KEYS = [(0, 0) for _i in range(24)]
@@ -132,7 +137,7 @@ ALL_KEYS = {
'ROUTE': DEFAULT_KEYS,
'PROMENEUR': PROMENEUR_KEYS,
'CHIEN': CHIEN_KEYS,
- 'OVERLAY': DEFAULT_KEYS,
+ 'OVERLAY': OVERLAY_KEYS,
'mask_default': DEFAULT_KEYS,
}
@@ -144,26 +149,53 @@ NAMES = [
'CHIEN',
'OVERLAY',
'mask_default',
- ]
+ ]
+NUMBER_OF_KEYS = 24
-class ThreadMove(threading.Thread):
+class ThreadAnim(threading.Thread):
- def __init__(self, fixed, filename):
+ def __init__(self, fixed):
# init parent
threading.Thread.__init__(self)
# ...
self._fixed = fixed
- self._filename = filename
def run(self):
- for _align in ALL_KEYS[self._filename]:
+ # first pass
+ for _i in range(NUMBER_OF_KEYS):
+ # first refresh
+ self._fixed.refresh(_i)
+ # ...
+ time.sleep(0.5)
+ # second pass
+ for _i in range(NUMBER_OF_KEYS):
+ # first refresh
+ self._fixed.refresh()
+ # for each images
+ for _n in NAMES:
+ # do move
+ self._fixed._move_image(_n, align=ALL_KEYS[_n][-_i-1])
+ # disable changed flag
+ self._fixed._fullscreen_changed = False
# ...
- self._fixed._move_image(self._filename, align=_align)
+ time.sleep(0.5)
+ # ...
+ for _i in range(60):
+ # first refresh
+ self._fixed.refresh(frame=None)
# ...
time.sleep(1)
+def _set_fixed_bg(fixed):
+ # do it
+ fixed.set_has_window(True)
+ fixed.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0, 0, 0))
+ # conveniant return
+ return fixed
+
+
class ScreenStory(gtk.Fixed):
def __init__(self, toolbar):
@@ -171,53 +203,119 @@ class ScreenStory(gtk.Fixed):
gtk.Fixed.__init__(self)
# keep toolbar
self.toolbar = toolbar
- # init image dict
+ # set has window for bg color issue
+ _set_fixed_bg(self)
+ # create dummy
+ self.__dummy = _set_fixed_bg(gtk.Fixed())
+ # init image dicts
self.__graphics = dict()
self.__sizes = dict()
self.__positions = dict()
- # keep some info
+ # init fullscreen flag
+ self.fullscreen = False
+ self._fullscreen_changed = False
+ # do refresh first
self._screen_height = gtk.gdk.screen_height()
self._screen_width = gtk.gdk.screen_width()
# render
self._render()
+ #
+ self.refresh(0)
# and show
self._show()
# do anim
- for _n in NAMES:
- self._anim(_n)
+ ThreadAnim(self).start()
- def _anim(self, filename):
- # init thread
- _t = ThreadMove(self, filename)
- # start it
- _t.start()
+ def _hide_all(self):
+ # show dummy
+ self.__dummy.show()
+ # update toolbar
+ self.toolbar.activity.set_canvas(self.__dummy)
+ # hide us
+ self.hide()
+
+ def _show_all(self):
+ # show us
+ self._show()
+ # hide dummy
+ self.__dummy.hide()
+
+ def set_fullscreen(self, fullscreen):
+ # update fullscreen flag
+ self.fullscreen = fullscreen
+ # has changed
+ self._fullscreen_changed = True
+ # hide all
+ self._hide_all()
+
+ def refresh(self, frame=None):
+ # keep some info
+ self._screen_height = gtk.gdk.screen_height()
+ self._screen_width = gtk.gdk.screen_width()
+ # for each images
+ for _n in NAMES:
+ _align = None if frame is None else ALL_KEYS[_n][frame]
+ # do move
+ self._move_image(_n, align=_align)
+ # show
+ if self._fullscreen_changed is True:
+ # disable changed flag
+ self._fullscreen_changed = False
+ # show all
+ self._show_all()
+ else:
+ pass
def _render(self):
- # png check
- self._add_image('CIEL', align=(0, -10))
- self._add_image('MAISONS', align=(0, 0))
- self._add_image('ROUTE', align=(0, 16))
- self._add_image('PROMENEUR', align=(0, 16))
- self._add_image('CHIEN', align=(0, 16))
- self._add_image('OVERLAY', align=(0, 0))
- # add border
- self._add_image('mask_default', align=(0, 0))
+ for _n in NAMES:
+ # add image
+ self._add_image(_n, align=ALL_KEYS[_n][0])
def _get_image_path(self, filename):
return os.path.join(activity.get_bundle_path(),
'static', 'graphics', '%s.png' % filename)
+ def _update_w_h(self, filename):
+ # get image size
+ _w, _h = self.__sizes[filename]
+ # ..
+ if self._fullscreen_changed is True:
+ if self.fullscreen is True:
+ _new_w = _w * self._screen_width / 1024
+ _new_h = _h * _new_w / _w
+ else:
+ # get graphics path
+ _path = self._get_image_path(filename)
+ # get file size
+ _c, _new_w, _new_h = image.get_image_info(_path)
+ # update size
+ self.__sizes[filename] = _new_w, _new_h
+ # return new values
+ return _new_w, _new_h
+ else:
+ # return current values
+ return _w, _h
+
def _update_x_y(self, width, height, x, y):
+ #
+ if self.fullscreen is True:
+ _scene_with = self._screen_width
+ _scene_height = 468 * _scene_with / 1024.0
+ else:
+ _scene_with = 1024
+ _scene_height = 468
# update x
- x = ((gtk.gdk.screen_width() - width) / 2) + x
+ _x = ((self._screen_width - width) / 2)
+ _x += int(x * _scene_with / 100.0)
# update y
- y = ((gtk.gdk.screen_height() - height - + 88) / 2) + y
+ _y = ((self._screen_height - height - + 88) / 2)
+ _y += int(y * _scene_height / 100.0)
# return it
- return x, y
+ return _x, _y
def _move_image(self, filename, align=None):
- # get graphic from dict
- _image = self.__graphics[filename]
+ # get/update width and height
+ _w, _h = self._update_w_h(filename)
# set alignment
if align is None:
# use current position by default
@@ -225,13 +323,21 @@ class ScreenStory(gtk.Fixed):
else:
# parse align value
_x, _y = align
- # get image size
- _w, _h = self.__sizes[filename]
- # update x, y
- _x, _y = self._update_x_y(_w, _h, _x, _y)
- self.__positions[filename] = (_x, _y)
- # move
- self.move(_image, _x, _y)
+ # update positions
+ self.__positions[filename] = align
+ # get graphic from dict
+ _image = self.__graphics[filename]
+ # redraw all or move only
+ if self._fullscreen_changed is True:
+ # remove previous image
+ _image.destroy()
+ # create new image
+ self._add_image(filename, align=(_x, _y), size=(_w, _h))
+ else:
+ # update x, y
+ _x, _y = self._update_x_y(_w, _h, _x, _y)
+ # do move
+ self.move(_image, _x, _y)
def _add_image(self, filename, align=None, size=None):
# get graphics path
@@ -259,6 +365,8 @@ class ScreenStory(gtk.Fixed):
else:
# parse align value
_x, _y = align
+ # init positions
+ self.__positions[filename] = (_x, _y)
# TODO manage cb for click or dnd
# ...
# show
@@ -268,18 +376,12 @@ class ScreenStory(gtk.Fixed):
self.__sizes[filename] = (_w, _h)
# update x, y
_x, _y = self._update_x_y(_w, _h, _x, _y)
- self.__positions[filename] = (_x, _y)
# add
self.put(_image, _x, _y)
def _show(self):
# show self
self.show()
-
- # DEBUG
- logger.debug('[screen_story] _show - width: %s' % gtk.gdk.screen_width())
- # DEBUG
-
# update toolbar
self.toolbar.activity.set_canvas(self)