From 0bc1f9f2d89fe269d6a07df42025826c288775f3 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Wed, 22 Jul 2015 20:45:26 +0000 Subject: Add a tilt transition The tilt transition is like pan, only vertical instead of horizontal. --- example/demo.rst | 17 ++++++++++++----- presentty/rst.py | 1 + presentty/transition.py | 10 ++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/example/demo.rst b/example/demo.rst index bafd9ba..c105e7d 100644 --- a/example/demo.rst +++ b/example/demo.rst @@ -2,11 +2,11 @@ The following directives, when used at the top of the file, set default values for all slides: - This sets the transition style. Values are: 'dissolve', 'pan', or - 'cut'. The optional argument of 'duration' sets the duration of - the transition in seconds (0.4 seconds by default). The same - syntax may be used within a slide to override the transition for - that slide alone. + This sets the transition style. Values are: 'dissolve', 'pan', + 'tilt', or 'cut'. The optional argument of 'duration' sets the + duration of the transition in seconds (0.4 seconds by default). + The same syntax may be used within a slide to override thes + transition for that slide alone. .. transition:: dissolve :duration: 0.4 @@ -77,6 +77,13 @@ Pan Transition ...or "pan," where the slides appear horizontally adjacent and move right to left... +Tilt Transition +=============== +.. transition:: tilt + +...or "tilt," where the slides appear vertically adjacent and move +bottom to top... + Cut Transition ============== .. transition:: cut diff --git a/presentty/rst.py b/presentty/rst.py index e96ff21..ab06f76 100644 --- a/presentty/rst.py +++ b/presentty/rst.py @@ -65,6 +65,7 @@ class UrwidTranslator(docutils.nodes.GenericNodeVisitor): transition_map = {'dissolve': transition_mod.DissolveTransition, 'cut': transition_mod.CutTransition, 'pan': transition_mod.PanTransition, + 'tilt': transition_mod.TiltTransition, } def __init__(self, document, palette, hinter=None, basedir='.'): diff --git a/presentty/transition.py b/presentty/transition.py index c699ddb..5592cd9 100644 --- a/presentty/transition.py +++ b/presentty/transition.py @@ -46,6 +46,16 @@ class PanTransition(Transition): c.pad_trim_left_right(0-offset, 0-(size[0]-offset)) return c +class TiltTransition(Transition): + def render(self, size, focus=False): + old = self.old.render((size[0], size[1])) + new = self.new.render((size[0], size[1])) + c = urwid.CanvasCombine([(old, None, False), + (new, None, False)]) + offset = int(size[1] * self.progress) + c.pad_trim_top_bottom(0-offset, 0-(size[1]-offset)) + return c + class DissolveTransition(Transition): def __init__(self, *args, **kw): super(DissolveTransition, self).__init__(*args, **kw) -- cgit v1.2.3