diff options
author | Agustin Zubiaga <aguz@sugarlabs.org> | 2012-05-28 01:32:10 (GMT) |
---|---|---|
committer | Agustin Zubiaga <aguz@sugarlabs.org> | 2012-05-28 01:32:10 (GMT) |
commit | 6a79db9e131b629e66737eb32c74db430c8e7e5b (patch) | |
tree | d39f5290748b513dd85cb408524c2d753347ff5f | |
parent | d0a428cbf055feaddcd8473a712f295835220785 (diff) |
Few changes in animation mode, ping pong mode added
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | activity.py | 37 | ||||
-rw-r--r-- | animation.py | 24 | ||||
-rw-r--r-- | icons/normal-mode.svg | 88 | ||||
-rw-r--r-- | icons/ping-pong.svg | 63 |
5 files changed, 197 insertions, 16 deletions
@@ -4,5 +4,6 @@ New functions: - Select the frames when the activitie loads them. Fixes: - Enable drag and drop between frames. + - Correct frame selection in ping pong mode Bugs: Void. diff --git a/activity.py b/activity.py index 06c6bfa..4375b7a 100644 --- a/activity.py +++ b/activity.py @@ -31,13 +31,14 @@ from sugar.activity.widgets import ActivityToolbarButton from sugar.graphics.objectchooser import ObjectChooser from sugar.graphics.toolbarbox import ToolbarBox from sugar.graphics.toolbutton import ToolButton -from sugar.graphics.toggletoolbutton import ToggleToolButton +from sugar.graphics.radiotoolbutton import RadioToolButton from sugar import mime from gettext import gettext as _ +import animation + from frames_list import FramesList -from animation import Animation class AnimateActivity(activity.Activity): @@ -95,12 +96,24 @@ class AnimateActivity(activity.Activity): options_button = ToolbarButton(icon_name='preferences-system') options_toolbar = gtk.Toolbar() - returnbutton = ToggleToolButton("media-playlist-repeat") - returnbutton.set_tooltip(_("Repeat")) - returnbutton.set_active(True) - returnbutton.connect("toggled", self._set_return) + returnbutton = RadioToolButton(icon_name="media-playlist-repeat") + returnbutton.set_tooltip(_("Repeat Mode")) + returnbutton.connect("clicked", self._set_return_mode) options_toolbar.insert(returnbutton, -1) + normalmode = RadioToolButton(icon_name='normal-mode') + normalmode.props.group = returnbutton + normalmode.set_tooltip(_('Normal Mode')) + normalmode.set_active(True) + normalmode.connect("clicked", self._set_normal_mode) + options_toolbar.insert(normalmode, -1) + + pingpong = RadioToolButton(icon_name='ping-pong') + pingpong.props.group = returnbutton + pingpong.set_tooltip(_("Ping Pong Mode")) + pingpong.connect("clicked", self._set_pingpong_mode) + options_toolbar.insert(pingpong, -1) + options_button.props.page = options_toolbar options_toolbar.show_all() @@ -159,8 +172,14 @@ class AnimateActivity(activity.Activity): else: return - def _set_return(self, widget): - self._animation.set_return(widget.get_active()) + def _set_return_mode(self, widget): + self._animation.set_mode(animation.RETURN_MODE) + + def _set_normal_mode(self, widget): + self._animation.set_mode(animation.NORMAL_MODE) + + def _set_pingpong_mode(self, widget): + self._animation.set_mode(animation.PING_PONG_MODE) def _previous_frame(self, widget): self._animation.back() @@ -192,7 +211,7 @@ class AnimateActivity(activity.Activity): width, height = self._get_animation_size() if not self._animation: - self._animation = Animation(width, height) + self._animation = animation.Animation(width, height) self._animation.show_all() self._frames_list._animation = self._animation diff --git a/animation.py b/animation.py index 837aeaa..4dd810a 100644 --- a/animation.py +++ b/animation.py @@ -29,6 +29,10 @@ _logger = logging.getLogger('animate-animation') _logger.setLevel(logging.DEBUG) logging.basicConfig() +NORMAL_MODE = 0 +RETURN_MODE = 1 +PING_PONG_MODE = 2 + class Animation(gtk.Image): __gsignals__ = {"current-frame-updated": (gobject.SIGNAL_RUN_LAST, @@ -40,7 +44,7 @@ class Animation(gtk.Image): self._current_image = 0 self._timeout = None - self._return = True + self._mode = NORMAL_MODE self._running = False self.images = [] @@ -57,10 +61,9 @@ class Animation(gtk.Image): self.set_from_pixbuf(None) self._current_image = 0 - def set_return(self, _return=True): - """Defines if when get to the last image, - should return to the first""" - self._return = _return + def set_mode(self, mode): + """Defines animation mode""" + self._mode = mode def set_size(self, width, height): """Defines animation size""" @@ -128,7 +131,11 @@ class Animation(gtk.Image): if self._current_image != len(self.images) - 1: self._current_image += 1 - elif not self._current_image != len(self.images) - 1 and self._return: + elif not self._current_image != len(self.images) - 1 and \ + not self._mode == NORMAL_MODE: + if self._mode == PING_PONG_MODE: + self.images.reverse() + self._current_image = 0 self.emit("current-frame-updated", self._current_image) @@ -140,7 +147,10 @@ class Animation(gtk.Image): if self._current_image != 0: self._current_image -= 1 - elif self._current_image == 0 and self._return: + elif self._current_image == 0 and not self._mode == NORMAL_MODE: + if self._mode == PING_PONG_MODE: + self._images.reverse() + self._current_image = -1 self.emit("current-frame-updated", self._current_image) diff --git a/icons/normal-mode.svg b/icons/normal-mode.svg new file mode 100644 index 0000000..e8233c8 --- /dev/null +++ b/icons/normal-mode.svg @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<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" + enable-background="new 0 0 55 55" + height="55px" + id="Layer_1" + version="1.1" + viewBox="0 0 55 55" + width="55px" + x="0px" + xml:space="preserve" + y="0px" + inkscape:version="0.48.1 r9760" + sodipodi:docname="normal-mode.svg"><metadata + id="metadata8052"><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><defs + id="defs8050" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1280" + inkscape:window-height="742" + id="namedview8048" + showgrid="false" + inkscape:zoom="4.4363636" + inkscape:cx="17.946691" + inkscape:cy="17.617557" + inkscape:window-x="0" + inkscape:window-y="26" + inkscape:window-maximized="1" + inkscape:current-layer="g8042" /> +<g + display="block" + id="document-save" + style="stroke:#000000;stroke-opacity:1"> + <g + id="g8020" + style="stroke:#000000;stroke-opacity:1"> + + + + + + + + + <g + id="g8042" + style="stroke:#000000;stroke-opacity:1" + transform="translate(-87.459016,-11.721311)"> + <line + x1="124.66853" + x2="102.38506" + y1="28.787703" + y2="28.833689" + id="line8044" + style="fill:none;stroke:#ffffff;stroke-width:4.47242498000000044;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /> + <polyline + points=" 51.562,15.306 41.17,16.188 42.053,5.794 " + id="polyline8046" + style="fill:none;stroke:#ffffff;stroke-width:3.50000000000000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + transform="matrix(-0.70885129,-0.70535795,0.70535795,-0.70885129,146.70018,69.530891)" /> + <line + x1="124.66879" + x2="102.38551" + y1="48.227848" + y2="48.273834" + id="line8044-5" + style="fill:none;stroke:#ffffff;stroke-width:4.47242498000000044;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><polyline + points=" 51.562,15.306 41.17,16.188 42.053,5.794 " + id="polyline8046-1" + style="fill:none;stroke:#ffffff;stroke-width:3.50000000000000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + transform="matrix(-0.70885129,-0.70535795,0.70535795,-0.70885129,146.70047,88.971075)" /></g> + </g> +</g> +</svg>
\ No newline at end of file diff --git a/icons/ping-pong.svg b/icons/ping-pong.svg new file mode 100644 index 0000000..df55366 --- /dev/null +++ b/icons/ping-pong.svg @@ -0,0 +1,63 @@ +<?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" + version="1.1" + width="55" + height="55" + viewBox="0 0 55 55" + id="Layer_1" + xml:space="preserve"><metadata + id="metadata8052"><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><defs + id="defs8050" /> +<g + id="document-save" + style="stroke:#000000;stroke-opacity:1;display:block"> + <g + id="g8020" + style="stroke:#000000;stroke-opacity:1"> + + + + + + + + + <g + transform="translate(-87.459016,-11.721311)" + id="g8042" + style="stroke:#000000;stroke-opacity:1"> + <line + x1="124.44312" + x2="102.15965" + y1="31.943439" + y2="31.989426" + id="line8044" + style="fill:none;stroke:#ffffff;stroke-width:4.47242498;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /> + <polyline + points=" 51.562,15.306 41.17,16.188 42.053,5.794 " + id="polyline8046" + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + transform="matrix(-0.70885129,-0.70535795,0.70535795,-0.70885129,146.47477,72.686629)" /> + <line + x1="105.94048" + x2="128.22377" + y1="45.284023" + y2="45.330009" + id="line8044-5" + style="fill:none;stroke:#ffffff;stroke-width:4.47242498;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><polyline + points=" 51.562,15.306 41.17,16.188 42.053,5.794 " + id="polyline8046-1" + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + transform="matrix(0.70885129,-0.70535795,-0.70535795,-0.70885129,83.908812,86.02721)" /></g> + </g> +</g> +</svg>
\ No newline at end of file |