From: JucaBlues Date: Fri, 14 Aug 2009 03:33:33 +0000 (+0000) Subject: use a function instead of copy-pasting code X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2e6bdbbb1475a101f7b6a288bd7bb68ac96f0b33;p=inkscape.git use a function instead of copy-pasting code --- diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index bc8c4763b..6012f4e20 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -206,6 +206,11 @@ sp_color_wheel_selector_new (void) /* Helpers for setting color value */ +static void preserve_icc(SPColor *color, SPColorWheelSelector *cs){ + ColorSelector* selector = (ColorSelector*)(SP_COLOR_SELECTOR(cs)->base); + color->icc = selector->getColor().icc ? new SVGICCColor(*selector->getColor().icc) : 0; +} + void ColorWheelSelector::_colorChanged() { #ifdef DUMP_CHANGE_INFO @@ -238,10 +243,7 @@ void ColorWheelSelector::_adjustmentChanged( GtkAdjustment *adjustment, SPColorW wheelSelector->_updating = TRUE; - /* Preserve ICC color */ - ColorSelector* selector = (ColorSelector*)(SP_COLOR_SELECTOR(cs)->base); - wheelSelector->_color.icc = selector->getColor().icc ? new SVGICCColor(*selector->getColor().icc) : 0; - + preserve_icc(&wheelSelector->_color, cs); wheelSelector->_updateInternals( wheelSelector->_color, ColorScales::getScaled( wheelSelector->_adj ), wheelSelector->_dragging ); wheelSelector->_updating = FALSE; @@ -255,10 +257,7 @@ void ColorWheelSelector::_sliderGrabbed( SPColorSlider *slider, SPColorWheelSele wheelSelector->_dragging = TRUE; wheelSelector->_grabbed(); - /* Preserve ICC color */ - ColorSelector* selector = (ColorSelector*)(SP_COLOR_SELECTOR(cs)->base); - wheelSelector->_color.icc = selector->getColor().icc ? new SVGICCColor(*selector->getColor().icc) : 0; - + preserve_icc(&wheelSelector->_color, cs); wheelSelector->_updateInternals( wheelSelector->_color, ColorScales::getScaled( wheelSelector->_adj ), wheelSelector->_dragging ); } } @@ -271,10 +270,7 @@ void ColorWheelSelector::_sliderReleased( SPColorSlider *slider, SPColorWheelSel wheelSelector->_dragging = FALSE; wheelSelector->_released(); - /* Preserve ICC color */ - ColorSelector* selector = (ColorSelector*)(SP_COLOR_SELECTOR(cs)->base); - wheelSelector->_color.icc = selector->getColor().icc ? new SVGICCColor(*selector->getColor().icc) : 0; - + preserve_icc(&wheelSelector->_color, cs); wheelSelector->_updateInternals( wheelSelector->_color, ColorScales::getScaled( wheelSelector->_adj ), wheelSelector->_dragging ); } } @@ -284,10 +280,7 @@ void ColorWheelSelector::_sliderChanged( SPColorSlider *slider, SPColorWheelSele (void)slider; ColorWheelSelector* wheelSelector = (ColorWheelSelector*)(SP_COLOR_SELECTOR(cs)->base); - /* Preserve ICC color */ - ColorSelector* selector = (ColorSelector*)(SP_COLOR_SELECTOR(cs)->base); - wheelSelector->_color.icc = selector->getColor().icc ? new SVGICCColor(*selector->getColor().icc) : 0; - + preserve_icc(&wheelSelector->_color, cs); wheelSelector->_updateInternals( wheelSelector->_color, ColorScales::getScaled( wheelSelector->_adj ), wheelSelector->_dragging ); } @@ -304,10 +297,7 @@ void ColorWheelSelector::_wheelChanged( SPColorWheel *wheel, SPColorWheelSelecto sp_color_slider_set_colors (SP_COLOR_SLIDER(wheelSelector->_slider), start, mid, end); - /* Preserve ICC color */ - ColorSelector* selector = (ColorSelector*)(SP_COLOR_SELECTOR(cs)->base); - color.icc = selector->getColor().icc ? new SVGICCColor(*selector->getColor().icc) : 0; - + preserve_icc(&color, cs); wheelSelector->_updateInternals( color, wheelSelector->_alpha, sp_color_wheel_is_adjusting( wheel ) ); }