From 8d47afb19559e9ee9f6c61df715134aa593e357a Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 21 Jun 2013 14:24:06 -0400 Subject: [PATCH] slider: Use clutter_cairo_set_source_color This cuts down on the denseness of the code. https://bugzilla.gnome.org/show_bug.cgi?id=702825 --- js/ui/slider.js | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/js/ui/slider.js b/js/ui/slider.js index 534b3748b..f41637e78 100644 --- a/js/ui/slider.js +++ b/js/ui/slider.js @@ -58,33 +58,17 @@ const Slider = new Lang.Class({ let sliderActiveBorderColor = themeNode.get_color('-slider-active-border-color'); let sliderActiveColor = themeNode.get_color('-slider-active-background-color'); - cr.setSourceRGBA ( - sliderActiveColor.red / 255, - sliderActiveColor.green / 255, - sliderActiveColor.blue / 255, - sliderActiveColor.alpha / 255); cr.rectangle(0, (height - sliderHeight) / 2, width * this._value, sliderHeight); + Clutter.cairo_set_source_color(cr, sliderActiveColor); cr.fillPreserve(); - cr.setSourceRGBA ( - sliderActiveBorderColor.red / 255, - sliderActiveBorderColor.green / 255, - sliderActiveBorderColor.blue / 255, - sliderActiveBorderColor.alpha / 255); + Clutter.cairo_set_source_color(cr, sliderActiveBorderColor); cr.setLineWidth(sliderBorderWidth); cr.stroke(); - cr.setSourceRGBA ( - sliderColor.red / 255, - sliderColor.green / 255, - sliderColor.blue / 255, - sliderColor.alpha / 255); cr.rectangle(width * this._value, (height - sliderHeight) / 2, width * (1 - this._value), sliderHeight); + Clutter.cairo_set_source_color(cr, sliderColor); cr.fillPreserve(); - cr.setSourceRGBA ( - sliderBorderColor.red / 255, - sliderBorderColor.green / 255, - sliderBorderColor.blue / 255, - sliderBorderColor.alpha / 255); + Clutter.cairo_set_source_color(cr, sliderBorderColor); cr.setLineWidth(sliderBorderWidth); cr.stroke(); @@ -92,21 +76,13 @@ const Slider = new Lang.Class({ let handleX = handleRadius + (width - 2 * handleRadius) * this._value; let color = themeNode.get_foreground_color(); - cr.setSourceRGBA ( - color.red / 255, - color.green / 255, - color.blue / 255, - color.alpha / 255); + Clutter.cairo_set_source_color(cr, color); cr.arc(handleX, handleY, handleRadius, 0, 2 * Math.PI); cr.fillPreserve(); if (hasHandleColor && handleBorderWidth) { - cr.setSourceRGBA( - handleBorderColor.red / 255, - handleBorderColor.green / 255, - handleBorderColor.blue / 255, - handleBorderColor.alpha / 255); - cr.setLineWidth(handleBorderWidth); - cr.stroke(); + Clutter.cairo_set_source_color(cr, handleBorderColor); + cr.setLineWidth(handleBorderWidth); + cr.stroke(); } cr.$dispose(); },