def on_touch_move(self, touch):
        """If a card is being dragged, move other cards out of the way to show
        where the dragged card will go if you drop it.

        """
        if (
                'card' not in touch.ud or
                'layout' not in touch.ud or
                touch.ud['layout'] != self
        ):
            return
        if (
                touch.ud['layout'] == self and
                not hasattr(touch.ud['card'], '_topdecked')
        ):
            touch.ud['card']._topdecked = InstructionGroup()
            touch.ud['card']._topdecked.add(touch.ud['card'].canvas)
            self.canvas.after.add(touch.ud['card']._topdecked)
        for i, deck in enumerate(self.decks):
            cards = [card for card in deck if not card.dragging]
            maxidx = max(card.idx for card in cards) if cards else 0
            if self.direction == 'descending':
                cards.reverse()
            cards_collided = [
                card for card in cards if card.collide_point(*touch.pos)
            ]
            if cards_collided:
                collided = cards_collided.pop()
                for card in cards_collided:
                    if card.idx > collided.idx:
                        collided = card
                if collided.deck == touch.ud['deck']:
                    self.insertion_card = (
                        1 if collided.idx == 0 else
                        maxidx + 1 if collided.idx == maxidx else
                        collided.idx + 1 if collided.idx > touch.ud['idx']
                        else collided.idx
                    )
                else:
                    dropdeck = self.decks[collided.deck]
                    maxidx = max(card.idx for card in dropdeck)
                    self.insertion_card = (
                        1 if collided.idx == 0 else
                        maxidx + 1 if collided.idx == maxidx else
                        collided.idx + 1
                    )
                if self.insertion_deck != collided.deck:
                    self.insertion_deck = collided.deck
                return
            else:
                if self.insertion_deck == i:
                    if self.insertion_card in (0, len(deck)):
                        pass
                    elif self.point_before_card(
                            cards[0], *touch.pos
                    ):
                        self.insertion_card = 0
                    elif self.point_after_card(
                        cards[-1], *touch.pos
                    ):
                        self.insertion_card = cards[-1].idx
                else:
                    for j, found in enumerate(self._foundations):
                        if (
                                found is not None and
                                found.collide_point(*touch.pos)
                        ):
                            self.insertion_deck = j
                            self.insertion_card = 0
                            return
def on_touch_move ( self , touch ) : if ( 'card' not in touch . ud or 'layout' not in touch . ud or touch . ud [ 'layout' ] != self ) : return if ( touch . ud [ 'layout' ] == self and not hasattr ( touch . ud [ 'card' ] , '_topdecked' ) ) : touch . ud [ 'card' ] . _topdecked = InstructionGroup ( ) touch . ud [ 'card' ] . _topdecked . add ( touch . ud [ 'card' ] . canvas ) self . canvas . after . add ( touch . ud [ 'card' ] . _topdecked ) for i , deck in enumerate ( self . decks ) : cards = [ card for card in deck if not card . dragging ] maxidx = max ( card . idx for card in cards ) if cards else 0 if self . direction == 'descending' : cards . reverse ( ) cards_collided = [ card for card in cards if card . collide_point ( * touch . pos ) ] if cards_collided : collided = cards_collided . pop ( ) for card in cards_collided : if card . idx > collided . idx : collided = card if collided . deck == touch . ud [ 'deck' ] : self . insertion_card = ( 1 if collided . idx == 0 else maxidx + 1 if collided . idx == maxidx else collided . idx + 1 if collided . idx > touch . ud [ 'idx' ] else collided . idx ) else : dropdeck = self . decks [ collided . deck ] maxidx = max ( card . idx for card in dropdeck ) self . insertion_card = ( 1 if collided . idx == 0 else maxidx + 1 if collided . idx == maxidx else collided . idx + 1 ) if self . insertion_deck != collided . deck : self . insertion_deck = collided . deck return else : if self . insertion_deck == i : if self . insertion_card in ( 0 , len ( deck ) ) : pass elif self . point_before_card ( cards [ 0 ] , * touch . pos ) : self . insertion_card = 0 elif self . point_after_card ( cards [ - 1 ] , * touch . pos ) : self . insertion_card = cards [ - 1 ] . idx else : for j , found in enumerate ( self . _foundations ) : if ( found is not None and found . collide_point ( * touch . pos ) ) : self . insertion_deck = j self . insertion_card = 0 return
If a card is being dragged, move other cards out of the way to show
        where the dragged card will go if you drop it.