Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ColorProperty: Use ColorProperty instead of ListProperty for color property #6918

Merged
merged 2 commits into from Jun 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions kivy/core/window/__init__.py
Expand Up @@ -21,7 +21,8 @@
from kivy.modules import Modules
from kivy.event import EventDispatcher
from kivy.properties import ListProperty, ObjectProperty, AliasProperty, \
NumericProperty, OptionProperty, StringProperty, BooleanProperty
NumericProperty, OptionProperty, StringProperty, BooleanProperty, \
ColorProperty
from kivy.utils import platform, reify, deprecated, pi_version
from kivy.context import get_current_context
from kivy.uix.behaviors import FocusBehavior
Expand Down Expand Up @@ -1201,14 +1202,18 @@ def _set_shape_mode(self, value):
:attr:`shape_mode` is an :class:`~kivy.properties.AliasProperty`.
'''

shape_color_key = ListProperty([1, 1, 1, 1])
shape_color_key = ColorProperty([1, 1, 1, 1])
'''Color key of the shaped window - sets which color will be hidden from
the window :attr:`shape_image` (only works for sdl2 window provider).

.. versionadded:: 1.10.1

:attr:`shape_color_key` is a :class:`~kivy.properties.ListProperty`
instance and defaults to [1, 1, 1, 1].

.. versionchanged:: 2.0.0
Changed from :class:`~kivy.properties.ListProperty` to
:class:`~kivy.properties.ColorProperty`.
'''
def on_shape_color_key(self, instane, value):
self._set_shape(
Expand Down
20 changes: 16 additions & 4 deletions kivy/uix/actionbar.py
Expand Up @@ -48,7 +48,7 @@
from kivy.uix.label import Label
from kivy.config import Config
from kivy.properties import ObjectProperty, NumericProperty, BooleanProperty, \
StringProperty, ListProperty, OptionProperty, AliasProperty
StringProperty, ListProperty, OptionProperty, AliasProperty, ColorProperty
from kivy.metrics import sp
from kivy.lang import Builder
from functools import partial
Expand Down Expand Up @@ -211,12 +211,16 @@ class ActionPrevious(BoxLayout, ActionItem):
and defaults to 0.
'''

color = ListProperty([1, 1, 1, 1])
color = ColorProperty([1, 1, 1, 1])
'''
Text color, in the format (r, g, b, a)

:attr:`color` is a :class:`~kivy.properties.ListProperty` and defaults
to [1, 1, 1, 1].

.. versionchanged:: 2.0.0
Changed from :class:`~kivy.properties.ListProperty` to
:class:`~kivy.properties.ColorProperty`.
'''

previous_image = StringProperty(
Expand Down Expand Up @@ -522,12 +526,16 @@ class ActionView(BoxLayout):
and defaults to None.
'''

background_color = ListProperty([1, 1, 1, 1])
background_color = ColorProperty([1, 1, 1, 1])
'''
Background color in the format (r, g, b, a).

:attr:`background_color` is a :class:`~kivy.properties.ListProperty` and
defaults to [1, 1, 1, 1].

.. versionchanged:: 2.0.0
Changed from :class:`~kivy.properties.ListProperty` to
:class:`~kivy.properties.ColorProperty`.
'''

background_image = StringProperty(
Expand Down Expand Up @@ -790,12 +798,16 @@ class ActionBar(BoxLayout):
defaults to None or the last ActionView instance added to the ActionBar.
'''

background_color = ListProperty([1, 1, 1, 1])
background_color = ColorProperty([1, 1, 1, 1])
'''
Background color, in the format (r, g, b, a).

:attr:`background_color` is a :class:`~kivy.properties.ListProperty` and
defaults to [1, 1, 1, 1].

.. versionchanged:: 2.0.0
Changed from :class:`~kivy.properties.ListProperty` to
:class:`~kivy.properties.ColorProperty`.
'''

background_image = StringProperty(
Expand Down
8 changes: 6 additions & 2 deletions kivy/uix/bubble.py
Expand Up @@ -66,7 +66,7 @@
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.properties import ObjectProperty, StringProperty, OptionProperty, \
ListProperty, BooleanProperty
ListProperty, BooleanProperty, ColorProperty
from kivy.clock import Clock
from kivy.base import EventLoop
from kivy.metrics import dp
Expand All @@ -91,12 +91,16 @@ class Bubble(GridLayout):
'''Bubble class. See module documentation for more information.
'''

background_color = ListProperty([1, 1, 1, 1])
background_color = ColorProperty([1, 1, 1, 1])
'''Background color, in the format (r, g, b, a). To use it you have to set
either :attr:`background_image` or :attr:`arrow_image` first.

:attr:`background_color` is a :class:`~kivy.properties.ListProperty` and
defaults to [1, 1, 1, 1].

.. versionchanged:: 2.0.0
Changed from :class:`~kivy.properties.ListProperty` to
:class:`~kivy.properties.ColorProperty`.
'''

border = ListProperty([16, 16, 16, 16])
Expand Down
8 changes: 6 additions & 2 deletions kivy/uix/button.py
Expand Up @@ -47,7 +47,7 @@ def callback(instance, value):
__all__ = ('Button', )

from kivy.uix.label import Label
from kivy.properties import StringProperty, ListProperty
from kivy.properties import StringProperty, ListProperty, ColorProperty
from kivy.uix.behaviors import ButtonBehavior


Expand All @@ -60,7 +60,7 @@ class Button(ButtonBehavior, Label):

'''

background_color = ListProperty([1, 1, 1, 1])
background_color = ColorProperty([1, 1, 1, 1])
'''Background color, in the format (r, g, b, a).

This acts as a *multiplier* to the texture colour. The default
Expand All @@ -72,6 +72,10 @@ class Button(ButtonBehavior, Label):

The :attr:`background_color` is a
:class:`~kivy.properties.ListProperty` and defaults to [1, 1, 1, 1].

.. versionchanged:: 2.0.0
Changed from :class:`~kivy.properties.ListProperty` to
:class:`~kivy.properties.ColorProperty`.
'''

background_normal = StringProperty(
Expand Down
8 changes: 6 additions & 2 deletions kivy/uix/checkbox.py
Expand Up @@ -30,7 +30,7 @@ def on_checkbox_active(checkbox, value):

__all__ = ('CheckBox', )

from kivy.properties import AliasProperty, StringProperty, ListProperty
from kivy.properties import AliasProperty, StringProperty, ColorProperty
from kivy.uix.behaviors import ToggleButtonBehavior
from kivy.uix.widget import Widget

Expand Down Expand Up @@ -155,7 +155,7 @@ def _set_active(self, value):
'atlas://data/images/defaulttheme/checkbox_radio_disabled_on'.
'''

color = ListProperty([1, 1, 1, 1])
color = ColorProperty([1, 1, 1, 1])
'''Color is used for tinting the default graphical representation
of checkbox and radio button (images).

Expand All @@ -166,6 +166,10 @@ def _set_active(self, value):
:attr:`color` is a
:class:`~kivy.properties.ListProperty` and defaults to
'[1, 1, 1, 1]'.

.. versionchanged:: 2.0.0
Changed from :class:`~kivy.properties.ListProperty` to
:class:`~kivy.properties.ColorProperty`.
'''

def __init__(self, **kwargs):
Expand Down
8 changes: 6 additions & 2 deletions kivy/uix/image.py
Expand Up @@ -59,7 +59,7 @@ class FullImage(Image):
from kivy.core.image import Image as CoreImage
from kivy.resources import resource_find
from kivy.properties import StringProperty, ObjectProperty, ListProperty, \
AliasProperty, BooleanProperty, NumericProperty
AliasProperty, BooleanProperty, NumericProperty, ColorProperty
from kivy.logger import Logger

# delayed imports
Expand Down Expand Up @@ -123,7 +123,7 @@ def get_image_ratio(self):
read-only.
'''

color = ListProperty([1, 1, 1, 1])
color = ColorProperty([1, 1, 1, 1])
'''Image color, in the format (r, g, b, a). This attribute can be used to
'tint' an image. Be careful: if the source image is not gray/white, the
color will not really work as expected.
Expand All @@ -132,6 +132,10 @@ def get_image_ratio(self):

:attr:`color` is a :class:`~kivy.properties.ListProperty` and defaults to
[1, 1, 1, 1].

.. versionchanged:: 2.0.0
Changed from :class:`~kivy.properties.ListProperty` to
:class:`~kivy.properties.ColorProperty`.
'''

allow_stretch = BooleanProperty(False)
Expand Down
14 changes: 11 additions & 3 deletions kivy/uix/label.py
Expand Up @@ -287,7 +287,7 @@ def build(self):
from kivy.core.text.markup import MarkupLabel as CoreMarkupLabel
from kivy.properties import StringProperty, OptionProperty, \
NumericProperty, BooleanProperty, ReferenceListProperty, \
ListProperty, ObjectProperty, DictProperty
ListProperty, ObjectProperty, DictProperty, ColorProperty
from kivy.utils import get_hex_from_color


Expand Down Expand Up @@ -441,14 +441,18 @@ def on_ref_press(self, ref):
# Properties
#

disabled_color = ListProperty([1, 1, 1, .3])
disabled_color = ColorProperty([1, 1, 1, .3])
'''The color of the text when the widget is disabled, in the (r, g, b, a)
format.

.. versionadded:: 1.8.0

:attr:`disabled_color` is a :class:`~kivy.properties.ListProperty` and
defaults to [1, 1, 1, .3].

.. versionchanged:: 2.0.0
Changed from :class:`~kivy.properties.ListProperty` to
:class:`~kivy.properties.ColorProperty`.
'''

text = StringProperty('')
Expand Down Expand Up @@ -755,11 +759,15 @@ def on_ref_press(self, ref):
or set a :attr:`text_size` to change this behavior.
'''

color = ListProperty([1, 1, 1, 1])
color = ColorProperty([1, 1, 1, 1])
'''Text color, in the format (r, g, b, a).

:attr:`color` is a :class:`~kivy.properties.ListProperty` and defaults to
[1, 1, 1, 1].

.. versionchanged:: 2.0.0
Changed from :class:`~kivy.properties.ListProperty` to
:class:`~kivy.properties.ColorProperty`.
'''

outline_width = NumericProperty(None, allownone=True)
Expand Down
11 changes: 6 additions & 5 deletions kivy/uix/modalview.py
Expand Up @@ -78,7 +78,7 @@ def my_callback(instance):
from kivy.animation import Animation
from kivy.uix.anchorlayout import AnchorLayout
from kivy.properties import StringProperty, BooleanProperty, ObjectProperty, \
NumericProperty, ListProperty
NumericProperty, ListProperty, ColorProperty


class ModalView(AnchorLayout):
Expand Down Expand Up @@ -121,7 +121,7 @@ class ModalView(AnchorLayout):
defaults to None.
'''

background_color = ListProperty([1, 1, 1, 1])
background_color = ColorProperty([1, 1, 1, 1])
'''Background color, in the format (r, g, b, a).

This acts as a *multiplier* to the texture colour. The default
Expand All @@ -135,7 +135,8 @@ class ModalView(AnchorLayout):
.. versionchanged:: 2.0.0
Changed behavior to affect the background of the widget itself, not
the overlay dimming.

Changed from :class:`~kivy.properties.ListProperty` to
:class:`~kivy.properties.ColorProperty`.
'''

background = StringProperty(
Expand All @@ -159,11 +160,11 @@ class ModalView(AnchorLayout):
(16, 16, 16, 16).
'''

overlay_color = ListProperty([0, 0, 0, .7])
overlay_color = ColorProperty([0, 0, 0, .7])
'''Overlay color in the format (r, g, b, a).
Used for dimming the window behind the modal view.

:attr:`overlay_color` is a :class:`~kivy.properties.ListProperty` and
:attr:`overlay_color` is a :class:`~kivy.properties.ColorProperty` and
defaults to [0, 0, 0, .7].

.. versionadded:: 2.0.0
Expand Down
16 changes: 12 additions & 4 deletions kivy/uix/popup.py
Expand Up @@ -106,7 +106,7 @@ def my_callback(instance):
from kivy.core.text import DEFAULT_FONT
from kivy.uix.modalview import ModalView
from kivy.properties import (StringProperty, ObjectProperty, OptionProperty,
NumericProperty, ListProperty)
NumericProperty, ColorProperty)


class PopupException(Exception):
Expand Down Expand Up @@ -171,22 +171,30 @@ class Popup(ModalView):
to None.
'''

title_color = ListProperty([1, 1, 1, 1])
title_color = ColorProperty([1, 1, 1, 1])
'''Color used by the Title.

.. versionadded:: 1.8.0

:attr:`title_color` is a :class:`~kivy.properties.ListProperty` and
defaults to [1, 1, 1, 1].

.. versionchanged:: 2.0.0
Changed from :class:`~kivy.properties.ListProperty` to
:class:`~kivy.properties.ColorProperty`.
'''

separator_color = ListProperty([47 / 255., 167 / 255., 212 / 255., 1.])
separator_color = ColorProperty([47 / 255., 167 / 255., 212 / 255., 1.])
'''Color used by the separator between title and content.

.. versionadded:: 1.1.0

:attr:`separator_color` is a :class:`~kivy.properties.ListProperty` and
defaults to [47 / 255., 167 / 255., 212 / 255., 1.]
defaults to [47 / 255., 167 / 255., 212 / 255., 1.].

.. versionchanged:: 2.0.0
Changed from :class:`~kivy.properties.ListProperty` to
:class:`~kivy.properties.ColorProperty`.
'''

separator_height = NumericProperty('2dp')
Expand Down
11 changes: 8 additions & 3 deletions kivy/uix/screenmanager.py
Expand Up @@ -197,7 +197,7 @@ def build(self):
from kivy.uix.floatlayout import FloatLayout
from kivy.properties import (StringProperty, ObjectProperty, AliasProperty,
NumericProperty, ListProperty, OptionProperty,
BooleanProperty)
BooleanProperty, ColorProperty)
from kivy.animation import Animation, AnimationTransition
from kivy.uix.relativelayout import RelativeLayout
from kivy.lang import Builder
Expand Down Expand Up @@ -460,13 +460,18 @@ class ShaderTransition(TransitionBase):
:attr:`vs` is a :class:`~kivy.properties.StringProperty` and defaults to
None.'''

clearcolor = ListProperty([0, 0, 0, 1])
clearcolor = ColorProperty([0, 0, 0, 1])
'''Sets the color of Fbo ClearColor.

.. versionadded:: 1.9.0

:attr:`clearcolor` is a :class:`~kivy.properties.ListProperty`
and defaults to [0, 0, 0, 1].'''
and defaults to [0, 0, 0, 1].

.. versionchanged:: 2.0.0
Changed from :class:`~kivy.properties.ListProperty` to
:class:`~kivy.properties.ColorProperty`.
'''

def make_screen_fbo(self, screen):
fbo = Fbo(size=screen.size, with_stencilbuffer=True)
Expand Down