From c8bb8d0fbba6d41ac0cb83a62ae805a466ce4f99 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 22 May 2018 11:52:51 +1000 Subject: Add INDIC_GRADIENT and INDIC_GRADIENTCENTRE indicator types. --- src/Indicator.cxx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src') diff --git a/src/Indicator.cxx b/src/Indicator.cxx index 91f98ac58..eef4048e8 100644 --- a/src/Indicator.cxx +++ b/src/Indicator.cxx @@ -138,6 +138,27 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r rcBox.right = rc.right; surface->AlphaRectangle(rcBox, (sacDraw.style == INDIC_ROUNDBOX) ? 1 : 0, sacDraw.fore, fillAlpha, sacDraw.fore, outlineAlpha, 0); + } else if (sacDraw.style == INDIC_GRADIENT || + sacDraw.style == INDIC_GRADIENTCENTRE) { + PRectangle rcBox = rc; + rcBox.top = rcLine.top + 1; + rcBox.bottom = rcLine.bottom; + const Surface::GradientOptions options = Surface::GradientOptions::topToBottom; + const ColourAlpha start(sacNormal.fore, fillAlpha); + const ColourAlpha end(sacNormal.fore, 0); + std::vector stops; + switch (sacDraw.style) { + case INDIC_GRADIENT: + stops.push_back(ColourStop(0.0, start)); + stops.push_back(ColourStop(1.0, end)); + break; + case INDIC_GRADIENTCENTRE: + stops.push_back(ColourStop(0.0, end)); + stops.push_back(ColourStop(0.5, start)); + stops.push_back(ColourStop(1.0, end)); + break; + } + surface->GradientRectangle(rcBox, stops, options); } else if (sacDraw.style == INDIC_DOTBOX) { PRectangle rcBox = PixelGridAlign(rc); rcBox.top = rcLine.top + 1; -- cgit v1.2.3