コード例 #1
0
 def browser_action(self, button):
     """close and display browser panel action trigger."""
     if button.direction == "left":
         anim = Animation(width=0, d=.2, t='linear')
     else:
         anim = Animation(width=250, d=.2, t='linear')
     anim.fbind('on_complete', self.browser_action_handler, button)
     anim.start(self.file_chooser)
コード例 #2
0
 def tracker_action(self, button):
     """Close and display tracker panel action trigger."""
     if button.direction == "right":
         anim = Animation(width=0, d=.2, t='linear')
     else:
         anim = Animation(width=150, d=.2, t='linear')
     anim.fbind('on_complete', self.tracker_action_handler, button)
     anim.start(self.list_view)
コード例 #3
0
ファイル: main.py プロジェクト: RedXBeard/kivyjewel
 def on_bring_to_front(self, touch):
     print self.pos, self.parent
     super(CustomScatter, self).on_bring_to_front(touch)
     anim = Animation(x=self.pre_pos[0], y=self.pre_pos[1], t="linear", duration=0.2)
     parent = self.parent
     if parent:
         anim.fbind("on_complete", parent.check_bubbles, [], [], False)
     anim.start(self)
コード例 #4
0
ファイル: main.py プロジェクト: ibrahimgunduz34/PictureViewer
 def rotate(self, angle):
     """
     Rotation handler
     """
     if self.picture.image_source.source and self.picture.image_name.text:
         rotation = self.selectedimage.rotation + angle
         anim = Animation(rotation=rotation, t="linear", duration=0.2)
         anim.fbind("on_complete", self.norm_photo, angle)
         anim.start(self.photo)
コード例 #5
0
ファイル: main.py プロジェクト: ibrahimgunduz34/PictureViewer
 def tracker_action(self, button, *args, **kwargs):
     """
     close and display tracker panel action trigger
     """
     if button.direction == "right":
         anim = Animation(width=0, d=0.2, t="linear")
     else:
         anim = Animation(width=150, d=0.2, t="linear")
     anim.fbind("on_complete", self._tracker_action, button)
     anim.start(self.list_view)
コード例 #6
0
ファイル: main.py プロジェクト: ibrahimgunduz34/PictureViewer
 def browser_action(self, button, *args, **kwargs):
     """
     close and display browser panel action trigger.
     """
     if button.direction == "left":
         anim = Animation(width=0, d=0.2, t="linear")
     else:
         anim = Animation(width=250, d=0.2, t="linear")
     anim.fbind("on_complete", self._browser_action, button)
     anim.start(self.file_chooser)
コード例 #7
0
ファイル: main.py プロジェクト: RedXBeard/kivyjewel
 def change_pos(self, *args, **kwargs):
     column = kwargs.get("column", [])
     index = kwargs.get("index", 0)
     try:
         scatter = column[index]
     except IndexError:
         return
     anim = Animation(y=scatter.pre_pos[1], t="linear", duration=0.05)
     anim.fbind("on_complete", self.change_pos, column=column, index=index + 1)
     anim.start(scatter)
コード例 #8
0
 def rotate(self, angle):
     """
     Rotation handler
     """
     if self.picture.image_source.source and self.picture.image_name.text:
         rotation = self.selectedimage.rotation + angle
         anim = Animation(
             rotation=rotation,
             t='linear', duration=.2)
         anim.fbind('on_complete', self.norm_photo, angle)
         anim.start(self.photo)
コード例 #9
0
    def fall_animation(self, real_x, real_y, parent_level, single_time, fix_once, smooth_animation):
        global play_area

        if smooth_animation:  # So may the animation be smoother (only executed by items that were destroyed in triad)
            drop_animation = Animation(pos=(real_x, real_y+10000), duration=.3) + \
                             Animation(pos=(real_x, real_y), duration=.3)
        else:
            drop_animation = Animation(pos=(real_x, real_y), duration=.6)
        if single_time and fix_once:
            drop_animation.fbind('on_complete', parent_level.fix_play_area, True)
        drop_animation.start(self.item_button)
コード例 #10
0
ファイル: main.py プロジェクト: RedXBeard/kivyjewel
 def fill_column(self, *args, **kwargs):
     column = kwargs.get("column")
     index = kwargs.get("index", 0)
     board = self.board
     try:
         row = column[index]
     except IndexError:
         board.check_bubbles()
         return
     board.add_widget(row)
     anim = Animation(x=row.pre_pos[0], y=row.pre_pos[1], t="linear", duration=0.1)
     anim.fbind("on_complete", self.fill_column, column=column, index=index + 1)
     anim.start(row)
コード例 #11
0
class Help(OverlayView):

    target_widget = ObjectProperty(None, allownone=True, baseclass=Widget)

    def __init__(self, **kwargs):
        super(Help, self).__init__(**kwargs)
        self._anim_open = Animation(d=0.4)
        self._anim_open.fbind('on_complete', self._on_anim_open_complete)
        self._anim_dismiss = Animation(d=0.4)
        self._anim_dismiss.fbind('on_complete', self._on_anim_dismiss_complete)
        self._current_anim = None

    def open(self, *largs):
        if self._current_anim:
            return
        if self._window is not None:
            Logger.warning('ModalView: you can only open once.')
            return
        # search window
        self._window = self._search_window()
        if not self._window:
            Logger.warning('ModalView: cannot open view, no window found.')
            return
        self._window.add_widget(self)
        self._window.bind(on_keyboard=self._handle_keyboard)
        self._align_center()
        self.pos = (0, -self.height)
        target_widget = self.target_widget
        if target_widget:
            target_widget.bind(center=self._align_center)
        else:
            self._window.bind(on_resize=self._align_center)
        anim = self._anim_open
        anim.animated_properties.update(self._create_open_properties())
        anim.start(self)
        self._current_anim = anim

    def dismiss(self, *largs, **kwargs):
        if self._current_anim is self._anim_open:
            self._anim_open.cancel(self)
        anim = self._anim_dismiss
        if self._current_anim is anim:
            return
        anim.animated_properties.update(self._create_dismiss_properties())
        anim.start(self)
        self._current_anim = anim

    def _on_anim_open_complete(self, *args):
        self._current_anim = None
        self.dispatch('on_open')

    def _on_anim_dismiss_complete(self, *args):
        self._current_anim = None
        self.dispatch('on_dismiss')
        self._real_remove_widget()

    def _create_open_properties(self):
        target_widget = self.target_widget
        if target_widget:
            center = target_widget.to_window(*target_widget.center)
        else:
            center = self._window.center
        return {'center': center}

    def _create_dismiss_properties(self):
        return {'top': 0}

    def _align_center(self, *l):
        if self.target_widget:
            self.size = self.target_widget.size
        else:
            self.size = self._window.size
        self._update_animation()

    def _update_animation(self, *args):
        anim = self._current_anim
        if anim:
            anim.cancel(self)
            if anim is self._anim_open:
                properties = self._create_open_properties()
            else:
                properties = self._create_dismiss_properties()
            anim.animated_properties.update(properties)
            anim.start(self)

    def _real_remove_widget(self):
        super(Help, self)._real_remove_widget()
        target_widget = self.target_widget
        if target_widget:
            target_widget.unbind(center=self._align_center)
コード例 #12
0
    def load_files(self, selection):
        """Browsed photo siblings selection, not all but limited ones."""
        try:
            file_dir = get_dir(selection)
            self.files = []
            # Selected image action handler
            if os.path.isfile(selection):
                if self.picture.image_source.source != selection:
                    image_source = self.picture.image_source.source
                    if image_source and self.picture.image_name.text:
                        anim = Animation(
                            width=0, t='linear', duration=.2,
                            center_x=self.picture.image_source.center_x + 2
                        )
                        anim.fbind(
                            'on_complete', self.change_image_source, selection
                        )
                        anim.start(self.picture.image_source)
                    else:
                        center_x = self.picture.image_source.center_x

                        self.picture.image_source.width = 0
                        self.selectedimage.path = selection
                        self.selectedimage.name = selection.rsplit("/", 1)[1]
                        self.selectedimage.rotation = 0

                        anim = Animation(
                            width=self.photo.width, t='linear', duration=.2,
                            center_x=center_x - 2
                        )
                        anim.fbind('on_complete', self.activate_buttons)
                        anim.start(self.picture.image_source)
                else:
                    self.selectedimage.path = selection
                    self.selectedimage.name = selection.rsplit("/", 1)[1]
                    self.selectedimage.rotation = 0
                    anim = Animation(
                        width=self.photo.width, t='linear', duration=.2,
                        center_x=self.picture.image_source.center_x + 2
                    )
                    anim.bind(on_complete=self.activate_buttons)
                    anim.start(self.picture.image_source)

            # Files filtered and collect.
            selected = {}
            for ext in FILE_EXTENSIONS:
                files = glob("%s/*.%s" % (file_dir, ext))
                for f_path in files:
                    tmp = {
                        'name': f_path.rsplit("/", 1)[1],
                        'path': f_path,
                        'is_selected': selection == f_path and True or False,
                        'rotation': 0
                    }
                    self.files.append(tmp)
                    if tmp['is_selected']:
                        selected = tmp
            self.files = sorted(self.files, key=lambda x: x.get('path'))
            self.selected_index_onlist = self.files.index(selected)
            display_range = (
                max(self.selected_index_onlist - 4, 0),
                min(self.selected_index_onlist + 5, len(self.files))
            )
            self.files = self.files[display_range[0]:display_range[1]]
            self.selected_index_onlist = self.files.index(selected)
            # Browser can trace viewed photo
            for item in self.file_chooser._items:
                item.color_selected = get_color_from_hex('B3B3B3')
                if item.path == selection:
                    item.parent.select_node(item)
        except IndexError:
            pass
コード例 #13
0
ファイル: main.py プロジェクト: avour/PianoTiles
    def start_tiles(self):
        self.add_widget(self.back_btn)
        self.tile_list = []

        self.btn_y = 0
        self.btn_width = Window.width / 4
        self.btn_x = [
            self.btn_width * 0, self.btn_width * 1, self.btn_width * 2,
            self.btn_width * 3
        ]

        global box_slide
        box_slide = BoxLayout(orientation='vertical', pos=(-Window.width, 0))

        with box_slide.canvas:
            Color(.2, .5, 1, .7)
            box_slide.rect1 = Rectangle(pos=(box_slide.pos),
                                        size=(Window.size))

        self.restart_btn = Button(text='Restart',
                                  size_hint=(None, None),
                                  pos_hint={
                                      'center_x': .5,
                                      'center_y': .4
                                  })
        self.restart_btn.bind(on_press=self.game_over1)
        box_slide.add_widget(
            Label(text='Game Over',
                  font_size=40,
                  pos_hint={
                      'center_x': .5,
                      'center_y': .7
                  }))
        box_slide.add_widget(self.restart_btn)

        global slide_anim
        slide_anim = Animation(pos=(0, 0), d=1)

        for i in range(50):

            self.btn = btn(size_hint=(None, None),
                           size=(self.btn_width, Window.height / 4),
                           pos=(random.choice(self.btn_x),
                                Window.height + self.btn_y))

            self.btn_y += self.btn.height
            ##            self.btn.bind(on_press=self.play_sound)
            self.add_widget(self.btn)
            self.btn.bind(on_press=self._state)

        self.add_widget(box_slide)
        self.add_widget(self.score)

        for child in self.children:

            if child != box_slide and child != self.back_btn and child != self.score:
                self.time = (child.y + Window.height / 4) / 200
                global anim
                anim = Animation(y=-(Window.height / 4), d=self.time)

                self.tile_list.append(child)

                anim.start(child)
                anim.fbind('on_complete', self.delete_btn)
            else:
                pass
コード例 #14
0
 def animate_swap(self, real_x, real_y, parent_level):
     swap_animation = Animation(pos=(real_x, real_y), duration=.25)
     swap_animation.fbind('on_complete', self.play, parent_level)
     swap_animation.start(self.item_button)