Skip to content

Commit

Permalink
Use ColorProperty instead of ListProperty to represent color value.
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonic64 committed Jun 3, 2020
1 parent f044806 commit 9bdfa41
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 75 deletions.
7 changes: 4 additions & 3 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,13 +1202,13 @@ 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`
:attr:`shape_color_key` is a :class:`~kivy.properties.ColorProperty`
instance and defaults to [1, 1, 1, 1].
'''
def on_shape_color_key(self, instane, value):
Expand Down
14 changes: 7 additions & 7 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,11 +211,11 @@ 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
:attr:`color` is a :class:`~kivy.properties.ColorProperty` and defaults
to [1, 1, 1, 1].
'''

Expand Down Expand Up @@ -522,11 +522,11 @@ 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
:attr:`background_color` is a :class:`~kivy.properties.ColorProperty` and
defaults to [1, 1, 1, 1].
'''

Expand Down Expand Up @@ -790,11 +790,11 @@ 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
:attr:`background_color` is a :class:`~kivy.properties.ColorProperty` and
defaults to [1, 1, 1, 1].
'''

Expand Down
6 changes: 3 additions & 3 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,11 +91,11 @@ 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
:attr:`background_color` is a :class:`~kivy.properties.ColorProperty` and
defaults to [1, 1, 1, 1].
'''

Expand Down
6 changes: 3 additions & 3 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 @@ -71,7 +71,7 @@ class Button(ButtonBehavior, Label):
.. versionadded:: 1.0.8
The :attr:`background_color` is a
:class:`~kivy.properties.ListProperty` and defaults to [1, 1, 1, 1].
:class:`~kivy.properties.ColorProperty` and defaults to [1, 1, 1, 1].
'''

background_normal = StringProperty(
Expand Down
6 changes: 3 additions & 3 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 @@ -164,7 +164,7 @@ def _set_active(self, value):
.. versionadded:: 1.10.0
:attr:`color` is a
:class:`~kivy.properties.ListProperty` and defaults to
:class:`~kivy.properties.ColorProperty` and defaults to
'[1, 1, 1, 1]'.
'''

Expand Down
6 changes: 3 additions & 3 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,14 +123,14 @@ 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.
.. versionadded:: 1.0.6
:attr:`color` is a :class:`~kivy.properties.ListProperty` and defaults to
:attr:`color` is a :class:`~kivy.properties.ColorProperty` and defaults to
[1, 1, 1, 1].
'''

Expand Down
10 changes: 5 additions & 5 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,13 +441,13 @@ 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
:attr:`disabled_color` is a :class:`~kivy.properties.ColorProperty` and
defaults to [1, 1, 1, .3].
'''

Expand Down Expand Up @@ -755,10 +755,10 @@ 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
:attr:`color` is a :class:`~kivy.properties.ColorProperty` and defaults to
[1, 1, 1, 1].
'''

Expand Down
10 changes: 5 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 @@ -130,7 +130,7 @@ class ModalView(AnchorLayout):
:attr:`background_normal` to ``''``.
The :attr:`background_color` is a
:class:`~kivy.properties.ListProperty` and defaults to [1, 1, 1, 1].
:class:`~kivy.properties.ColorProperty` and defaults to [1, 1, 1, 1].
.. versionchanged:: 2.0.0
Changed behavior to affect the background of the widget itself, not
Expand Down Expand Up @@ -159,11 +159,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
10 changes: 5 additions & 5 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,21 +171,21 @@ 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
:attr:`title_color` is a :class:`~kivy.properties.ColorProperty` and
defaults to [1, 1, 1, 1].
'''

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
:attr:`separator_color` is a :class:`~kivy.properties.ColorProperty` and
defaults to [47 / 255., 167 / 255., 212 / 255., 1.]
'''

Expand Down
6 changes: 3 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,12 +460,12 @@ 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`
:attr:`clearcolor` is a :class:`~kivy.properties.ColorProperty`
and defaults to [0, 0, 0, 1].'''

def make_screen_fbo(self, screen):
Expand Down
11 changes: 6 additions & 5 deletions kivy/uix/scrollview.py
Expand Up @@ -151,7 +151,8 @@
from kivy.metrics import sp, dp
from kivy.effects.dampedscroll import DampedScrollEffect
from kivy.properties import NumericProperty, BooleanProperty, AliasProperty, \
ObjectProperty, ListProperty, ReferenceListProperty, OptionProperty
ObjectProperty, ListProperty, ReferenceListProperty, OptionProperty, \
ColorProperty
from kivy.uix.behaviors import FocusBehavior


Expand Down Expand Up @@ -334,23 +335,23 @@ def _get_hbar(self):
:attr:`vbar` is a :class:`~kivy.properties.AliasProperty`, readonly.
'''

bar_color = ListProperty([.7, .7, .7, .9])
bar_color = ColorProperty([.7, .7, .7, .9])
'''Color of horizontal / vertical scroll bar, in RGBA format.
.. versionadded:: 1.2.0
:attr:`bar_color` is a :class:`~kivy.properties.ListProperty` and defaults
:attr:`bar_color` is a :class:`~kivy.properties.ColorProperty` and defaults
to [.7, .7, .7, .9].
'''

bar_inactive_color = ListProperty([.7, .7, .7, .2])
bar_inactive_color = ColorProperty([.7, .7, .7, .2])
'''Color of horizontal / vertical scroll bar (in RGBA format), when no
scroll is happening.
.. versionadded:: 1.9.0
:attr:`bar_inactive_color` is a
:class:`~kivy.properties.ListProperty` and defaults to [.7, .7, .7, .2].
:class:`~kivy.properties.ColorProperty` and defaults to [.7, .7, .7, .2].
'''

bar_width = NumericProperty('2dp')
Expand Down
5 changes: 3 additions & 2 deletions kivy/uix/slider.py
Expand Up @@ -42,7 +42,8 @@
from kivy.uix.widget import Widget
from kivy.properties import (NumericProperty, AliasProperty, OptionProperty,
ReferenceListProperty, BoundedNumericProperty,
StringProperty, ListProperty, BooleanProperty)
StringProperty, ListProperty, BooleanProperty,
ColorProperty)


class Slider(Widget):
Expand Down Expand Up @@ -244,7 +245,7 @@ class Slider(Widget):
and defaults to False.
"""

value_track_color = ListProperty([1, 1, 1, 1])
value_track_color = ColorProperty([1, 1, 1, 1])
"""Color of the :attr:`value_line` in rgba format.
.. versionadded 1.10.0
Expand Down
7 changes: 4 additions & 3 deletions kivy/uix/tabbedpanel.py
Expand Up @@ -136,7 +136,8 @@
from kivy.logger import Logger
from kivy.metrics import dp
from kivy.properties import ObjectProperty, StringProperty, OptionProperty, \
ListProperty, NumericProperty, AliasProperty, BooleanProperty
ListProperty, NumericProperty, AliasProperty, BooleanProperty, \
ColorProperty


class TabbedPanelException(Exception):
Expand Down Expand Up @@ -266,10 +267,10 @@ class TabbedPanel(GridLayout):
'''The TabbedPanel 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).
:attr:`background_color` is a :class:`~kivy.properties.ListProperty` and
:attr:`background_color` is a :class:`~kivy.properties.ColorProperty` and
defaults to [1, 1, 1, 1].
'''

Expand Down

0 comments on commit 9bdfa41

Please sign in to comment.