Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflorent <florent.pigout@gmail.com>2011-02-24 14:32:38 (GMT)
committer florent <florent.pigout@gmail.com>2011-02-24 14:32:38 (GMT)
commit1c835e1f92a53b1070730bc8a6838c3ff78b1719 (patch)
tree0e69cc2d54cc3b01381c4cc1b3ec56bc567925b7
parent1bca40986ceccc80afb2c314fe70d6cb71d1e415 (diff)
add svg boder src | manage position in percentage | manage fullscreen
-rw-r--r--activity.py2
-rw-r--r--atoidepoc/ui/screens.py216
-rw-r--r--atoidepoc/ui/toolbar.py72
-rw-r--r--docs/img/src/mask_default.svg74
4 files changed, 294 insertions, 70 deletions
diff --git a/activity.py b/activity.py
index de710d9..05904bc 100644
--- a/activity.py
+++ b/activity.py
@@ -32,7 +32,7 @@ class AToiDePocActivity(activity.Activity):
# show
_toolbox.show()
# init toolbars
- for _n in ['story', 'graphic', 'sound']:
+ for _n in ['story']: # , 'graphic', 'sound'
# init toolbar
_t = toolbar.Toolbar(self, name=_n)
# if default toolbar .. set default screen
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)
diff --git a/atoidepoc/ui/toolbar.py b/atoidepoc/ui/toolbar.py
index 5caf66f..fa3fed5 100644
--- a/atoidepoc/ui/toolbar.py
+++ b/atoidepoc/ui/toolbar.py
@@ -32,24 +32,52 @@ def _cb_add(widget, toolbar):
def _cb_open(widget, toolbar):
# DEBUG
- logger.debug('[toolbar] _cb_open - name: %s' % toolbar.name)
+ logger.debug('[toolbar] _cb_open - name: %s' % toolbar.name)
def _cb_play(widget, toolbar):
# DEBUG
- logger.debug('[toolbar] _cb_play - name: %s' % toolbar.name)
+ logger.debug('[toolbar] _cb_play - name: %s' % toolbar.name)
+
+
+def _cb_view_fullscreen(widget, toolbar):
+ # DEBUG
+ logger.debug('[toolbar] _cb_fullscreen - name: %s' % toolbar.name)
+ # remove fullscreen button
+ toolbar._remove_button('view_fullscreen')
+ # add return button
+ toolbar._add_button('view_return')
+ # get current screen
+ _screen = toolbar.activity.get_canvas()
+ # enbale fullscreen
+ _screen.set_fullscreen(True)
+
+
+def _cb_view_return(widget, toolbar):
+ # DEBUG
+ logger.debug('[toolbar] _cb_fullscreen - name: %s' % toolbar.name)
+ # remove return button
+ toolbar._remove_button('view_return')
+ # add fullscreen button
+ toolbar._add_button('view_fullscreen')
+ # get current screen
+ _screen = toolbar.activity.get_canvas()
+ # disable fullscreen
+ _screen.set_fullscreen(False)
BUTTONS = {
- 'add' : ['list-add', _cb_add],
- 'open' : ['media', _cb_open],
- 'play' : ['player_play', _cb_play],
+ 'add' : ['list-add', _cb_add],
+ 'open' : ['media', _cb_open],
+ 'play' : ['player_play', _cb_play],
+ 'view_fullscreen' : ['view-fullscreen', _cb_view_fullscreen],
+ 'view_return' : ['view-return', _cb_view_return],
}
TOOLBARS = {
- 'graphic' : ['add',],
- 'sound' : ['add', 'play',],
- 'story' : ['open', 'play',],
+ 'graphic' : ['add',],
+ 'sound' : ['add', 'play',],
+ 'story' : ['view_fullscreen',], # 'open', 'play',
}
TITLES = {
@@ -69,8 +97,10 @@ TITLES = {
'story' : {
'toolbar': _('Story'),
'buttons': {
- 'open': _('Open Story'),
- 'play': _('Play Story'),
+ # 'open': _('Open Story'),
+ # 'play': _('Play Story'),
+ 'view_fullscreen': _('Fullscreen'),
+ 'view_return': _('Default Screen'),
}
},
}
@@ -85,14 +115,17 @@ class Toolbar(gtk.Toolbar):
self.activity = activity
# keep the name
self.set_name(name)
+ # init widget dict
+ self._button_dict = dict()
# add buttons
for _b in TOOLBARS[self.name]:
+ # add button
self._add_button(_b)
# add to parent
_toolbox = self.activity.get_toolbox()
_toolbox.add_toolbar(TITLES[self.name]['toolbar'], self)
# connect focus event
- self.connect('focus', self._on_focus)
+ # self.connect('focus', self._on_focus)
# show
self.show()
@@ -121,10 +154,25 @@ class Toolbar(gtk.Toolbar):
# do connect
_buton.connect('clicked', _cb, self)
# add to the toolbar
- self.insert(_buton, -1)
+ self.add(_buton)
# show it
_buton.show()
+ # update the button dict
+ self._button_dict[button_id] = _buton
# ??
else:
# DEBUG
logger.debug('[toolbar] _add_button - unknown: %s' % button_id)
+
+ def _remove_button(self, button_id):
+ # little check
+ if button_id in self._button_dict:
+ # get button
+ _buton = self._button_dict.pop(button_id)
+ # do remove
+ self.remove(_buton)
+ # ??
+ else:
+ # DEBUG
+ logger.debug('[toolbar] _remove_button - unknown: %s' % button_id)
+
diff --git a/docs/img/src/mask_default.svg b/docs/img/src/mask_default.svg
new file mode 100644
index 0000000..0152976
--- /dev/null
+++ b/docs/img/src/mask_default.svg
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="1920"
+ height="1080"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.47 r22583"
+ sodipodi:docname="mask_default.svg">
+ <defs
+ id="defs4">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.35"
+ inkscape:cx="895.92015"
+ inkscape:cy="508.57143"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ showguides="true"
+ inkscape:guide-bbox="true"
+ inkscape:window-width="1174"
+ inkscape:window-height="786"
+ inkscape:window-x="342"
+ inkscape:window-y="24"
+ inkscape:window-maximized="0" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,27.637817)">
+ <path
+ style="color:#000000;fill:#000000;fill-opacity:1;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="M 0 0 L 0 1080 L 1920 1080 L 1920 0 L 0 0 z M 448 306 L 1472 306 L 1472 774 L 448 774 L 448 306 z "
+ transform="translate(0,-27.637817)"
+ id="rect2816"
+ inkscape:export-filename="/home/florent/Desktop/mask_default.png"
+ inkscape:export-xdpi="90.00679"
+ inkscape:export-ydpi="90.00679" />
+ </g>
+</svg>