Skip to content

Commit

Permalink
Refactor color traits (#924)
Browse files Browse the repository at this point in the history
* Refactor color traits

This combines the two color traits in Enable: ColorTrait (which is mapped)
and RGBAColorTrait (which is not), updating them so that they don't use the
old `Trait` factory and are simple TraitTypes instead.  It combines validation
so that they accept the same wide set of values, and makes use of the code from
Pyface for parsing color values and the standard color names (Pyface's values
were originally taken from Enable).  It also unifies the editors, so that both
traits have the same editors.

* Prevent circular imports in Wx color editor code.

* Apply suggestions from code review

Co-authored-by: Mark Dickinson <mdickinson@enthought.com>

* Various improvements suggested from code review.

* Fix imports.

Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
  • Loading branch information
corranwebster and mdickinson authored Apr 21, 2022
1 parent 129299b commit 6f04712
Show file tree
Hide file tree
Showing 7 changed files with 323 additions and 525 deletions.
4 changes: 2 additions & 2 deletions docs/source/enable/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ something that doesn't draw but does respond to events, subclass
Container
~~~~~~~~~

All components have a :class:`Container`. They can only have a single
All components have a :class:`Container`. They can only have a single
container. One component can't be contained by two objects.

Whenever you request a component to redraw itself, it actually requests its
Expand Down Expand Up @@ -321,7 +321,7 @@ which are of interest to users:
bgcolor
^^^^^^^
``bgcolor`` is a :class:`ColorTrait` which can be used to specify the background
color of the component. The default value is ``"sys_window"``, which may or may
color of the component. The default value is ``"syswindow"``, which may or may
not match the default window background color of the GUI toolkit you are using.

high_resolution
Expand Down
2 changes: 1 addition & 1 deletion enable/abstract_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class AbstractWindow(HasTraits):

# The background window of the window. The entire window first gets
# painted with this color before the component gets to draw.
bgcolor = ColorTrait("sys_window")
bgcolor = ColorTrait("syswindow")

alt_pressed = Bool(False, transient=True)
ctrl_pressed = Bool(False, transient=True)
Expand Down
Loading

0 comments on commit 6f04712

Please sign in to comment.