Python kivy.animation.Animation.cancel_all() Examples
The following are 30
code examples of kivy.animation.Animation.cancel_all().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
kivy.animation.Animation
, or try the search function
.
Example #1
Source File: carousel.py From Tickeys-linux with MIT License | 6 votes |
def on_touch_down(self, touch): if not self.collide_point(*touch.pos): touch.ud[self._get_uid('cavoid')] = True return if self.disabled: return True if self._touch: return super(Carousel, self).on_touch_down(touch) Animation.cancel_all(self) self._touch = touch uid = self._get_uid() touch.grab(self) touch.ud[uid] = { 'mode': 'unknown', 'time': touch.time_start} Clock.schedule_once(self._change_touch_mode, self.scroll_timeout / 1000.) return True
Example #2
Source File: carousel.py From Tickeys-linux with MIT License | 6 votes |
def on_touch_down(self, touch): if not self.collide_point(*touch.pos): touch.ud[self._get_uid('cavoid')] = True return if self.disabled: return True if self._touch: return super(Carousel, self).on_touch_down(touch) Animation.cancel_all(self) self._touch = touch uid = self._get_uid() touch.grab(self) touch.ud[uid] = { 'mode': 'unknown', 'time': touch.time_start} Clock.schedule_once(self._change_touch_mode, self.scroll_timeout / 1000.) return True
Example #3
Source File: spinner.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def _reset(self, *args): Animation.cancel_all(self, '_angle_start', '_rotation_angle', '_angle_end', '_alpha') self._angle_start = 0 self._angle_end = 8 self._rotation_angle = 360 self._alpha = 0 self.active = False
Example #4
Source File: button.py From KivyMD with MIT License | 5 votes |
def on_touch_down(self, touch): if not self.disabled: if touch.is_mouse_scrolling: return False if not self.collide_point(touch.x, touch.y): return False if self in touch.ud: return False Animation.cancel_all(self, 'elevation') self.elevation_press_anim.start(self) return super(MDRaisedButton, self).on_touch_down(touch)
Example #5
Source File: ripplebehavior.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def fade_out(self, *args): rc = self.ripple_color if not self.fading_out: Animation.cancel_all(self, 'ripple_color') anim = Animation(ripple_color=[rc[0], rc[1], rc[2], 0.], t=self.ripple_func_out, duration=self.ripple_duration_out) anim.bind(on_complete=self.anim_complete) self.fading_out = True anim.start(self)
Example #6
Source File: ripplebehavior.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def finish_ripple(self): if self.doing_ripple and not self.finishing_ripple: Animation.cancel_all(self, 'ripple_rad') anim = Animation(ripple_rad=self.finish_rad, t=self.ripple_func_in, duration=self.ripple_duration_in_fast) anim.bind(on_complete=self.fade_out) self.finishing_ripple = True anim.start(self)
Example #7
Source File: ripplebehavior.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def on_touch_down(self, touch): if touch.is_mouse_scrolling: return False if not self.collide_point(touch.x, touch.y): return False if not self.disabled: if self.doing_ripple: Animation.cancel_all(self, 'ripple_rad', 'ripple_color', 'rect_color') self.anim_complete() self.ripple_rad = self.ripple_rad_default self.ripple_pos = (touch.x, touch.y) if self.ripple_color != []: pass elif hasattr(self, 'theme_cls'): self.ripple_color = self.theme_cls.ripple_color else: # If no theme, set Grey 300 self.ripple_color = [0.8784313725490196, 0.8784313725490196, 0.8784313725490196, self.ripple_alpha] self.ripple_color[3] = self.ripple_alpha self.lay_canvas_instructions() self.finish_rad = max(self.width, self.height) * self.ripple_scale self.start_ripple() return super(CommonRipple, self).on_touch_down(touch)
Example #8
Source File: button.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def on_touch_up(self, touch): if not self.disabled: if touch.grab_current is not self: return super(ButtonBehavior, self).on_touch_up(touch) Animation.cancel_all(self, 'elevation') self.elevation_release_anim.start(self) else: Animation.cancel_all(self, 'elevation') self.elevation = 0 return super(MDRaisedButton, self).on_touch_up(touch)
Example #9
Source File: button.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def on_touch_down(self, touch): if not self.disabled: if touch.is_mouse_scrolling: return False if not self.collide_point(touch.x, touch.y): return False if self in touch.ud: return False Animation.cancel_all(self, 'elevation') self.elevation_press_anim.start(self) return super(MDRaisedButton, self).on_touch_down(touch)
Example #10
Source File: __init__.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def on_touch_down(self, touch): col_self = self.collide_point(*touch.pos) col_side = self._side_panel.collide_point(*touch.pos) col_main = self._main_panel.collide_point(*touch.pos) if self._anim_progress < 0.001: # i.e. closed valid_region = (self.x <= touch.x <= (self.x + self.touch_accept_width)) if not valid_region: self._main_panel.on_touch_down(touch) return False else: if col_side and not self._main_above: self._side_panel.on_touch_down(touch) return False valid_region = (self._main_panel.x <= touch.x <= (self._main_panel.x + self._main_panel.width)) if not valid_region: if self._main_above: if col_main: self._main_panel.on_touch_down(touch) elif col_side: self._side_panel.on_touch_down(touch) else: if col_side: self._side_panel.on_touch_down(touch) elif col_main: self._main_panel.on_touch_down(touch) return False Animation.cancel_all(self) self._anim_init_progress = self._anim_progress self._touch = touch touch.ud['type'] = self.state touch.ud['panels_jiggled'] = False # If user moved panels back # and forth, don't default # to close on touch release touch.grab(self) return True
Example #11
Source File: __init__.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def on_state(self, *args): Animation.cancel_all(self) if self.state == 'open': self._anim_progress = 1 else: self._anim_progress = 0
Example #12
Source File: __init__.py From pydelhi_mobile with GNU Affero General Public License v3.0 | 5 votes |
def on_touch_down(self, touch): col_self = self.collide_point(*touch.pos) col_side = self._side_panel.collide_point(*touch.pos) col_main = self._main_panel.collide_point(*touch.pos) if self._anim_progress < 0.001: # i.e. closed valid_region = (self.x <= touch.x <= (self.x + self.touch_accept_width)) if not valid_region: self._main_panel.on_touch_down(touch) return False else: if col_side and not self._main_above: self._side_panel.on_touch_down(touch) return False valid_region = (self._main_panel.x <= touch.x <= (self._main_panel.x + self._main_panel.width)) if not valid_region: if self._main_above: if col_main: self._main_panel.on_touch_down(touch) elif col_side: self._side_panel.on_touch_down(touch) else: if col_side: self._side_panel.on_touch_down(touch) elif col_main: self._main_panel.on_touch_down(touch) return False Animation.cancel_all(self) self._anim_init_progress = self._anim_progress self._touch = touch touch.ud['type'] = self.state touch.ud['panels_jiggled'] = False # If user moved panels back # and forth, don't default # to close on touch release touch.grab(self) return True
Example #13
Source File: __init__.py From pydelhi_mobile with GNU Affero General Public License v3.0 | 5 votes |
def on_state(self, *args): Animation.cancel_all(self) if self.state == 'open': self._anim_progress = 1 else: self._anim_progress = 0
Example #14
Source File: behaviors.py From pydelhi_mobile with GNU Affero General Public License v3.0 | 5 votes |
def on_touch_down(self, touch): if self.collide_point(touch.x, touch.y): # self.anim_complete(self, self) self.ripple_pos = ripple_pos = (touch.x, touch.y) Animation.cancel_all(self, 'ripple_rad', 'ripple_color') rc = self.ripple_color ripple_rad = self.ripple_rad self.ripple_color = [rc[0], rc[1], rc[2], 1.] anim = Animation( ripple_rad=max(self.width, self.height) * self.ripple_scale, t=self.ripple_func_in, ripple_color=[rc[0], rc[1], rc[2], self.fade_to_alpha], duration=self.ripple_duration_in) anim.bind(on_complete=self.anim_complete) anim.start(self) with self.canvas: StencilPush() Rectangle(size=self.size, pos=self.pos) StencilUse() self.col_instruction = Color(rgba=self.ripple_color, group='one') self.ellipse = Ellipse(size=(ripple_rad, ripple_rad), pos=(ripple_pos[0] - ripple_rad/2., ripple_pos[1] - ripple_rad/2.), group='one') StencilUnUse() Rectangle(size=self.size, pos=self.pos) StencilPop() self.bind(ripple_color=self.set_color, ripple_pos=self.set_ellipse, ripple_rad=self.set_ellipse) return super(TouchRippleBehavior, self).on_touch_down(touch)
Example #15
Source File: interpreter.py From Pyonic-interpreter with GNU General Public License v3.0 | 5 votes |
def ensure_no_ctrl_c_button(self): Clock.unschedule(self._switch_to_ctrl_c_button) c = self.ids.carousel if c.index == 1: c.load_previous() else: Animation.cancel_all(c) c._start_animation(new_offset=0)
Example #16
Source File: menu.py From Pyonic-interpreter with GNU General Public License v3.0 | 5 votes |
def animate_dismiss(self): Animation.cancel_all(self) anim = Animation(anim_progress=1, d=0.2, t='out_cubic') anim.bind(on_complete=self.immediate_dismiss) anim.start(self)
Example #17
Source File: menu.py From Pyonic-interpreter with GNU General Public License v3.0 | 5 votes |
def animate_open(self): Animation.cancel_all(self) self.anim_progress = 1 Animation(anim_progress=0, d=0.4, t='out_cubic').start(self)
Example #18
Source File: __init__.py From PyCon-Mobile-App with GNU General Public License v3.0 | 5 votes |
def on_touch_down(self, touch): col_self = self.collide_point(*touch.pos) col_side = self._side_panel.collide_point(*touch.pos) col_main = self._main_panel.collide_point(*touch.pos) if self._anim_progress < 0.001: # i.e. closed valid_region = (self.x <= touch.x <= (self.x + self.touch_accept_width)) if not valid_region: self._main_panel.on_touch_down(touch) return False else: if col_side and not self._main_above: self._side_panel.on_touch_down(touch) return False valid_region = (self._main_panel.x <= touch.x <= (self._main_panel.x + self._main_panel.width)) if not valid_region: if self._main_above: if col_main: self._main_panel.on_touch_down(touch) elif col_side: self._side_panel.on_touch_down(touch) else: if col_side: self._side_panel.on_touch_down(touch) elif col_main: self._main_panel.on_touch_down(touch) return False Animation.cancel_all(self) self._anim_init_progress = self._anim_progress self._touch = touch touch.ud['type'] = self.state touch.ud['panels_jiggled'] = False # If user moved panels back # and forth, don't default # to close on touch release touch.grab(self) return True
Example #19
Source File: __init__.py From PyCon-Mobile-App with GNU General Public License v3.0 | 5 votes |
def on_state(self, *args): Animation.cancel_all(self) if self.state == 'open': self._anim_progress = 1 else: self._anim_progress = 0
Example #20
Source File: behaviors.py From PyCon-Mobile-App with GNU General Public License v3.0 | 5 votes |
def on_touch_down(self, touch): if self.collide_point(touch.x, touch.y): # self.anim_complete(self, self) self.ripple_pos = ripple_pos = (touch.x, touch.y) Animation.cancel_all(self, 'ripple_rad', 'ripple_color') rc = self.ripple_color ripple_rad = self.ripple_rad self.ripple_color = [rc[0], rc[1], rc[2], 1.] anim = Animation( ripple_rad=max(self.width, self.height) * self.ripple_scale, t=self.ripple_func_in, ripple_color=[rc[0], rc[1], rc[2], self.fade_to_alpha], duration=self.ripple_duration_in) anim.bind(on_complete=self.anim_complete) anim.start(self) with self.canvas: StencilPush() Rectangle(size=self.size, pos=self.pos) StencilUse() self.col_instruction = Color( rgba=self.ripple_color, group='one') self.ellipse = Ellipse( size=(ripple_rad, ripple_rad), pos=(ripple_pos[0] - ripple_rad/2., ripple_pos[1] - ripple_rad/2.), group='one') StencilUnUse() Rectangle(size=self.size, pos=self.pos) StencilPop() self.bind( ripple_color=self.set_color, ripple_pos=self.set_ellipse, ripple_rad=self.set_ellipse) return super(TouchRippleBehavior, self).on_touch_down(touch)
Example #21
Source File: spinner.py From KivyMD with MIT License | 5 votes |
def _reset(self, *args): Animation.cancel_all(self, '_angle_start', '_rotation_angle', '_angle_end', '_alpha') self._angle_start = 0 self._angle_end = 8 self._rotation_angle = 360 self._alpha = 0 self.active = False
Example #22
Source File: textfields.py From KivyMD with MIT License | 5 votes |
def on_focus(self, *args): if self.focus: Animation.cancel_all(self, '_line_width', '_hint_y', '_hint_lbl_font_size') if len(self.text) == 0: self.hint_anim_in.start(self) if not self.error: self.anim.start(self) else: Animation.cancel_all(self, '_line_width', '_hint_y', '_hint_lbl_font_size') if len(self.text) == 0: self.hint_anim_out.start(self) if not self.error: self._line_width = 0
Example #23
Source File: ripplebehavior.py From KivyMD with MIT License | 5 votes |
def fade_out(self, *args): rc = self.ripple_color if not self.fading_out: Animation.cancel_all(self, 'ripple_color') anim = Animation(ripple_color=[rc[0], rc[1], rc[2], 0.], t=self.ripple_func_out, duration=self.ripple_duration_out) anim.bind(on_complete=self.anim_complete) self.fading_out = True anim.start(self)
Example #24
Source File: ripplebehavior.py From KivyMD with MIT License | 5 votes |
def finish_ripple(self): if self.doing_ripple and not self.finishing_ripple: Animation.cancel_all(self, 'ripple_rad') anim = Animation(ripple_rad=self.finish_rad, t=self.ripple_func_in, duration=self.ripple_duration_in_fast) anim.bind(on_complete=self.fade_out) self.finishing_ripple = True anim.start(self)
Example #25
Source File: ripplebehavior.py From KivyMD with MIT License | 5 votes |
def on_touch_down(self, touch): if touch.is_mouse_scrolling: return False if not self.collide_point(touch.x, touch.y): return False if not self.disabled: if self.doing_ripple: Animation.cancel_all(self, 'ripple_rad', 'ripple_color', 'rect_color') self.anim_complete() self.ripple_rad = self.ripple_rad_default self.ripple_pos = (touch.x, touch.y) if self.ripple_color != []: pass elif hasattr(self, 'theme_cls'): self.ripple_color = self.theme_cls.ripple_color else: # If no theme, set Grey 300 self.ripple_color = [0.8784313725490196, 0.8784313725490196, 0.8784313725490196, self.ripple_alpha] self.ripple_color[3] = self.ripple_alpha self.lay_canvas_instructions() self.finish_rad = max(self.width, self.height) * self.ripple_scale self.start_ripple() return super(CommonRipple, self).on_touch_down(touch)
Example #26
Source File: button.py From KivyMD with MIT License | 5 votes |
def on_touch_up(self, touch): if not self.disabled: if touch.grab_current is not self: return super(ButtonBehavior, self).on_touch_up(touch) Animation.cancel_all(self, 'elevation') self.elevation_release_anim.start(self) return super(MDRaisedButton, self).on_touch_up(touch)
Example #27
Source File: carousel.py From Tickeys-linux with MIT License | 4 votes |
def _start_animation(self, *args, **kwargs): # compute target offset for ease back, next or prev new_offset = 0 direction = kwargs.get('direction', self.direction) is_horizontal = direction[0] in ['r', 'l'] extent = self.width if is_horizontal else self.height min_move = kwargs.get('min_move', self.min_move) _offset = kwargs.get('offset', self._offset) if _offset < min_move * -extent: new_offset = -extent elif _offset > min_move * extent: new_offset = extent # if new_offset is 0, it wasnt enough to go next/prev dur = self.anim_move_duration if new_offset == 0: dur = self.anim_cancel_duration # detect edge cases if not looping len_slides = len(self.slides) index = self.index if not self.loop or len_slides == 1: is_first = (index == 0) is_last = (index == len_slides - 1) if direction[0] in ['r', 't']: towards_prev = (new_offset > 0) towards_next = (new_offset < 0) else: towards_prev = (new_offset < 0) towards_next = (new_offset > 0) if (is_first and towards_prev) or (is_last and towards_next): new_offset = 0 anim = Animation(_offset=new_offset, d=dur, t=self.anim_type) anim.cancel_all(self) def _cmp(*l): if self._skip_slide is not None: self.index = self._skip_slide self._skip_slide = None anim.bind(on_complete=_cmp) anim.start(self)
Example #28
Source File: carousel.py From Tickeys-linux with MIT License | 4 votes |
def _start_animation(self, *args, **kwargs): # compute target offset for ease back, next or prev new_offset = 0 direction = kwargs.get('direction', self.direction) is_horizontal = direction[0] in ['r', 'l'] extent = self.width if is_horizontal else self.height min_move = kwargs.get('min_move', self.min_move) _offset = kwargs.get('offset', self._offset) if _offset < min_move * -extent: new_offset = -extent elif _offset > min_move * extent: new_offset = extent # if new_offset is 0, it wasnt enough to go next/prev dur = self.anim_move_duration if new_offset == 0: dur = self.anim_cancel_duration # detect edge cases if not looping len_slides = len(self.slides) index = self.index if not self.loop or len_slides == 1: is_first = (index == 0) is_last = (index == len_slides - 1) if direction[0] in ['r', 't']: towards_prev = (new_offset > 0) towards_next = (new_offset < 0) else: towards_prev = (new_offset < 0) towards_next = (new_offset > 0) if (is_first and towards_prev) or (is_last and towards_next): new_offset = 0 anim = Animation(_offset=new_offset, d=dur, t=self.anim_type) anim.cancel_all(self) def _cmp(*l): if self._skip_slide is not None: self.index = self._skip_slide self._skip_slide = None anim.bind(on_complete=_cmp) anim.start(self)
Example #29
Source File: interpreter.py From Pyonic-interpreter with GNU General Public License v3.0 | 4 votes |
def _start_animation(self, *args, **kwargs): # compute target offset for ease back, next or prev new_offset = 0 direction = kwargs.get('direction', self.direction) is_horizontal = direction[0] in ['r', 'l'] extent = self.width if is_horizontal else self.height min_move = kwargs.get('min_move', self.min_move) _offset = kwargs.get('offset', self._offset) if _offset < min_move * -extent: new_offset = -extent elif _offset > min_move * extent: new_offset = extent if 'new_offset' in kwargs: new_offset = kwargs['new_offset'] # if new_offset is 0, it wasnt enough to go next/prev dur = self.anim_move_duration if new_offset == 0: dur = self.anim_cancel_duration # detect edge cases if not looping len_slides = len(self.slides) index = self.index if not self.loop or len_slides == 1: is_first = (index == 0) is_last = (index == len_slides - 1) if direction[0] in ['r', 't']: towards_prev = (new_offset > 0) towards_next = (new_offset < 0) else: towards_prev = (new_offset < 0) towards_next = (new_offset > 0) if (is_first and towards_prev) or (is_last and towards_next): new_offset = 0 anim = Animation(_offset=new_offset, d=dur, t=self.anim_type) anim.cancel_all(self) def _cmp(*l): if self._skip_slide is not None: self.index = self._skip_slide self._skip_slide = None anim.bind(on_complete=_cmp) anim.start(self)
Example #30
Source File: textfields.py From Blogs-Posts-Tutorials with MIT License | 4 votes |
def on_focus(self, *args): if self.focus: Animation.cancel_all(self, '_line_width', '_hint_y', '_hint_lbl_font_size') if len(self.text) == 0: self.hint_anim_in.start(self) if self.error: Animation(duration=.2, _current_hint_text_color=self.error_color).start(self) if self.mode == "on_error": Animation(duration=.2, _current_error_color=self.error_color).start(self) elif self.mode == "persistent": Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self) elif self.mode == "on_focus": Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self) else: pass elif not self.error: self.on_width(None, self.width) self.anim.start(self) Animation(duration=.2, _current_hint_text_color=self.line_color_focus).start(self) if self.mode == "on_error": Animation(duration=.2, _current_error_color=(0, 0, 0, 0)).start(self) if self.mode == "persistent": Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self) elif self.mode == "on_focus": Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self) else: pass else: Animation.cancel_all(self, '_line_width', '_hint_y', '_hint_lbl_font_size') if len(self.text) == 0: self.hint_anim_out.start(self) if not self.error: self.line_color_focus = self.base_line_color_focus Animation(duration=.2, _current_line_color=self.line_color_focus, _current_hint_text_color=self.theme_cls.disabled_hint_text_color).start(self) if self.mode == "on_error": Animation(duration=.2, _current_error_color=(0, 0, 0, 0)).start(self) elif self.mode == "persistent": Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self) elif self.mode == "on_focus": Animation(duration=.2, _current_error_color=(0, 0, 0, 0)).start(self) self.on_width(None, 0) self.anim.start(self) elif self.error: Animation(duration=.2, _current_line_color=self.error_color, _current_hint_text_color=self.error_color).start(self) if self.mode == "on_error": Animation(duration=.2, _current_error_color=self.error_color).start(self) elif self.mode == "persistent": Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self) elif self.mode == "on_focus": Animation(duration=.2, _current_error_color=(0, 0, 0, 0)).start(self)