Add none value for colors -> tabs.indicator.system.

This commit is contained in:
Florian Bruhin 2015-10-24 16:01:32 +02:00
parent 857a70ded7
commit f614e5b98a
5 changed files with 26 additions and 1 deletions

View File

@ -41,6 +41,8 @@ Added
* `completion -> scrollbar-padding`
* `colors -> completion.scrollbar.fg`
* `colors -> completion.scrollbar.bg`
- New value `none` for `colors -> tabs.indicator.system` to not display a
gradient for tab indicators.
Changed
~~~~~~~

View File

@ -644,12 +644,14 @@ class ColorSystem(MappingType):
special = True
valid_values = ValidValues(('rgb', "Interpolate in the RGB color system."),
('hsv', "Interpolate in the HSV color system."),
('hsl', "Interpolate in the HSL color system."))
('hsl', "Interpolate in the HSL color system."),
('none', "Don't show a gradient."))
MAPPING = {
'rgb': QColor.Rgb,
'hsv': QColor.Hsv,
'hsl': QColor.Hsl,
'none': None,
}

View File

@ -164,12 +164,20 @@ def interpolate_color(start, end, percent, colorspace=QColor.Rgb):
percent: Which value to get (0 - 100)
colorspace: The desired interpolation color system,
QColor::{Rgb,Hsv,Hsl} (from QColor::Spec enum)
If None, start is used except when percent is 100.
Return:
The interpolated QColor, with the same spec as the given start color.
"""
qtutils.ensure_valid(start)
qtutils.ensure_valid(end)
if colorspace is None:
if percent == 100:
return end
else:
return start
out = QColor()
if colorspace == QColor.Rgb:
a_c1, a_c2, a_c3, _alpha = start.getRgb()

View File

@ -844,6 +844,8 @@ class TestColorSystem:
'hsv': QColor.Hsv,
'HSL': QColor.Hsl,
'hsl': QColor.Hsl,
'none': None,
'None': None,
'': None,
}
INVALID = ['RRGB', 'HSV ', ''] # '' is invalid with none_ok=False

View File

@ -338,6 +338,17 @@ class TestInterpolateColor:
expected.setHsl(0, 30, 150)
assert Color(color) == expected
@pytest.mark.parametrize('percentage, expected', [
(0, (0, 0, 0)),
(99, (0, 0, 0)),
(100, (255, 255, 255)),
])
def test_interpolation_none(self, percentage, expected):
"""Test an interpolation with a gradient turned off."""
color = utils.interpolate_color(Color(0, 0, 0), Color(255, 255, 255),
percentage, None)
assert Color(color) == Color(*expected)
@pytest.mark.parametrize('seconds, out', [
(-1, '-0:01'),