Example #1
0
def show(items, duration=0):
    # set the current parent
    parent = exp._current_parent

    # See if there is already a swap state
    add_swap_state = True
    if parent.timeline.events.has_key(parent.cur_event_time):
        # see if there is a swap state at that time
        states = parent.timeline.events[parent.cur_event_time]
        for s in states:
            if isinstance(s, SwapState):
                # no need to add a swap state
                add_swap_state = False

                # get the preproc state for that swap
                # it will have the same parent
                preproc = None
                for c in s.parent.children():
                    if isinstance(c, PreprocState):
                        preproc = c
                        break
                if preproc is None:
                    raise AssertionError("Proprocessing state was not found.")
                # no need to keep looking
                break

    if add_swap_state:
        # create the preproc and swap with the same serial parent
        with Serial():
            with PreprocState():
                # add the show to it with lag
                ShowState(items,
                          event_time=exp._current_parent.cur_event_time - LAG)
            # append swap state
            s = SwapState()
            exp._add_transition_if_needed(s)
    else:
        print "Appending to existing swap"
        # add the show to existing preproc (found above)
        ShowState(items,
                  parent=preproc,
                  event_time=preproc.cur_event_time - LAG)

        # add a new dummy state in the current flow
        s = DummyState()
        exp._add_transition_if_needed(s)

    # if we have a specified duration, wait and call hide
    if duration > 0:
        if exp._current_parent.childMode() == QState.ExclusiveStates:
            wait(duration)
            hide(items)
        else:
            with Serial():
                wait(duration)
                hide(items)
    return items
Example #2
0
def show(items,duration=0):
    # set the current parent
    parent = exp._current_parent

    # See if there is already a swap state
    add_swap_state = True
    if parent.timeline.events.has_key(parent.cur_event_time):
        # see if there is a swap state at that time
        states = parent.timeline.events[parent.cur_event_time]
        for s in states:
            if isinstance(s,SwapState):
                # no need to add a swap state
                add_swap_state = False

                # get the preproc state for that swap
                # it will have the same parent
                preproc = None
                for c in s.parent.children():
                    if isinstance(c,PreprocState):
                        preproc = c
                        break
                if preproc is None:
                    raise AssertionError("Proprocessing state was not found.")
                # no need to keep looking
                break

    if add_swap_state:
        # create the preproc and swap with the same serial parent
        with Serial():
            with PreprocState():
                # add the show to it with lag
                ShowState(items, event_time=exp._current_parent.cur_event_time-LAG)
            # append swap state
            s = SwapState()
            exp._add_transition_if_needed(s)
    else:
        print "Appending to existing swap"
        # add the show to existing preproc (found above)
        ShowState(items, parent=preproc, 
                  event_time=preproc.cur_event_time-LAG)

        # add a new dummy state in the current flow
        s = DummyState()
        exp._add_transition_if_needed(s)

    # if we have a specified duration, wait and call hide
    if duration > 0:
        if exp._current_parent.childMode() == QState.ExclusiveStates:
            wait(duration)
            hide(items)
        else:
            with Serial():
                wait(duration)
                hide(items)
    return items
Example #3
0
def hide(items):
    # set the current parent
    parent = exp._current_parent

    # See if there is already a swap state
    add_swap_state = True
    if parent.timeline.events.has_key(parent.cur_event_time):
        # see if there is a swap state at that time
        states = parent.timeline.events[parent.cur_event_time]
        for s in states:
            if isinstance(s, SwapState):
                # no need to add a swap state
                add_swap_state = False

                # get the preproc state for that swap
                # it will have the same parent
                for c in s.parent.children():
                    if isinstance(c, PreprocState):
                        preproc = c
                        break
                # no need to keep looking
                break

    if add_swap_state:
        # create the preproc and swap with the same serial parent
        with Serial():
            with PreprocState():
                # add the hide to it
                HideState(items,
                          event_time=exp._current_parent.cur_event_time - LAG)
            # append swap state
            s = SwapState(parent=exp._current_parent)
            exp._add_transition_if_needed(s)
    else:
        # add the show to existing preproc (found above)
        HideState(items,
                  parent=preproc,
                  event_time=preproc.cur_event_time - LAG)

        # add a new dummy state in the current flow
        s = DummyState()
        exp._add_transition_if_needed(s)

    return items
Example #4
0
def hide(items):
    # set the current parent
    parent = exp._current_parent

    # See if there is already a swap state
    add_swap_state = True
    if parent.timeline.events.has_key(parent.cur_event_time):
        # see if there is a swap state at that time
        states = parent.timeline.events[parent.cur_event_time]
        for s in states:
            if isinstance(s,SwapState):
                # no need to add a swap state
                add_swap_state = False

                # get the preproc state for that swap
                # it will have the same parent
                for c in s.parent.children():
                    if isinstance(c,PreprocState):
                        preproc = c
                        break
                # no need to keep looking
                break

    if add_swap_state:
        # create the preproc and swap with the same serial parent
        with Serial():
            with PreprocState():
                # add the hide to it
                HideState(items, event_time=exp._current_parent.cur_event_time-LAG)
            # append swap state
            s = SwapState(parent=exp._current_parent)
            exp._add_transition_if_needed(s)
    else:
        # add the show to existing preproc (found above)
        HideState(items, parent=preproc, 
                  event_time=preproc.cur_event_time-LAG)

        # add a new dummy state in the current flow
        s = DummyState()
        exp._add_transition_if_needed(s)

    return items