Table Of Contents
Touch Ripple¶
New in version 1.10.1.
Warning
This code is still experimental, and its API is subject to change in a future version.
This module contains mixin classes to add a touch ripple visual effect known from Google Material Design <https://en.wikipedia.org/wiki/Material_Design>_ to widgets.
For an overview of behaviors, please refer to the behaviors
documentation.
The class TouchRippleBehavior provides
rendering the ripple animation.
The class TouchRippleButtonBehavior
basically provides the same functionality as
ButtonBehavior but rendering the ripple
animation instead of default press/release visualization.
-
class
kivy.uix.behaviors.touchripple.TouchRippleBehavior(**kwargs)[source]¶ Bases:
builtins.objectTouch ripple behavior.
Supposed to be used as mixin on widget classes.
Ripple behavior does not trigger automatically, concrete implementation needs to call
ripple_show()respectiveripple_fade()manually.Here we create a Label which renders the touch ripple animation on interaction:
class RippleLabel(TouchRippleBehavior, Label): def __init__(self, **kwargs): super(RippleLabel, self).__init__(**kwargs) def on_touch_down(self, touch): collide_point = self.collide_point(touch.x, touch.y) if collide_point: touch.grab(self) self.ripple_show(touch) return True return False def on_touch_up(self, touch): if touch.grab_current is self: touch.ungrab(self) self.ripple_fade() return True return False
-
ripple_duration_in¶ Animation duration taken to show the overlay.
ripple_duration_inis aNumericPropertyand defaults to 0.5.
-
ripple_duration_out¶ Animation duration taken to fade the overlay.
ripple_duration_outis aNumericPropertyand defaults to 0.2.
-
ripple_fade_from_alpha¶ Alpha channel for ripple color the animation starts with.
ripple_fade_from_alphais aNumericPropertyand defaults to 0.5.
-
ripple_fade_to_alpha¶ Alpha channel for ripple color the animation targets to.
ripple_fade_to_alphais aNumericPropertyand defaults to 0.8.
-
ripple_func_in¶ Animation callback for showing the overlay.
ripple_func_inis aStringPropertyand defaults to in_cubic.
-
ripple_func_out¶ Animation callback for hiding the overlay.
ripple_func_outis aStringPropertyand defaults to out_quad.
-
ripple_rad_default¶ Default radius the animation starts from.
ripple_rad_defaultis aNumericPropertyand defaults to 10.
-
ripple_scale¶ Max scale of the animation overlay calculated from max(width/height) of the decorated widget.
ripple_scaleis aNumericPropertyand defaults to 2.0.
-
-
class
kivy.uix.behaviors.touchripple.TouchRippleButtonBehavior(**kwargs)[source]¶ Bases:
kivy.uix.behaviors.touchripple.TouchRippleBehaviorThis mixin class provides a similar behavior to
ButtonBehaviorbut provides touch ripple animation instead of button pressed/released as visual effect.Events: - on_press
Fired when the button is pressed.
- on_release
Fired when the button is released (i.e. the touch/click that pressed the button goes away).
-
always_release¶ This determines whether or not the widget fires an on_release event if the touch_up is outside the widget.
always_releaseis aBooleanPropertyand defaults to False.
-
last_touch¶ Contains the last relevant touch received by the Button. This can be used in on_press or on_release in order to know which touch dispatched the event.
last_touchis aObjectPropertyand defaults to None.