void TColorStyle::assignBlend(const TColorStyle &a, const TColorStyle &b, double t) { // Blend colors { int col, colCount = getColorParamCount(); assert(a.getColorParamCount() == colCount && b.getColorParamCount() == colCount); for (col = 0; col != colCount; ++col) setColorParamValue( col, blend(a.getColorParamValue(col), b.getColorParamValue(col), t)); } // Blend parameters { int par, parCount = getParamCount(); assert(a.getParamCount() == parCount && b.getParamCount() == parCount); for (par = 0; par != parCount; ++par) { switch (getParamType(par)) { case DOUBLE: setParamValue(par, (1 - t) * a.getParamValue(double_tag(), par) + t * b.getParamValue(double_tag(), par)); break; default: break; } } } invalidateIcon(); }
void CleanupColorFieldEditorController::edit( DVGui::CleanupColorField *colorField) { if (m_currentColorField && m_currentColorField->isEditing()) m_currentColorField->setIsEditing(false); m_currentColorField = colorField; if (!colorField) return; m_currentColorField->setIsEditing(true); // Setto come stile corrente quello del colorField TColorStyle *fieldStyle = colorField->getStyle(); m_blackColor = dynamic_cast<TBlackCleanupStyle *>(fieldStyle); if (m_blackColor) { m_palette->setStyle(1, new TSolidColorStyle); m_palette->getStyle(1)->setMainColor(fieldStyle->getColorParamValue(1)); } else { m_palette->setStyle(1, new TColorCleanupStyle); TColorStyle *style = m_palette->getStyle(1); style->setMainColor(fieldStyle->getMainColor()); style->setColorParamValue(1, fieldStyle->getColorParamValue(1)); } // Setto m_colorFieldHandle come paletteHandle corrente. TApp::instance()->getPaletteController()->setCurrentPalette( m_colorFieldHandle); connect(m_colorFieldHandle, SIGNAL(colorStyleChanged()), SLOT(onColorStyleChanged())); }
bool TColorStyle::operator==(const TColorStyle &cs) const { if (getTagId() != cs.getTagId()) return false; if (getMainColor() != cs.getMainColor()) return false; int paramCount = getParamCount(); if (paramCount != cs.getParamCount()) return false; int colorParamCount = getColorParamCount(); if (colorParamCount != cs.getColorParamCount()) return false; if (m_name != cs.getName()) return false; if (m_originalName != cs.getOriginalName()) return false; if (m_globalName != cs.getGlobalName()) return false; if (m_isEditedFromOriginal != cs.getIsEditedFlag()) return false; if (m_pickedPosition != cs.getPickedPosition()) return false; if (m_flags != cs.getFlags()) return false; for (int p = 0; p < colorParamCount; ++p) if (getColorParamValue(p) != cs.getColorParamValue(p)) return false; for (int p = 0; p < paramCount; ++p) { switch (getParamType(p)) { case BOOL: if (getParamValue(bool_tag(), p) != cs.getParamValue(bool_tag(), p)) return false; break; case INT: case ENUM: if (getParamValue(int_tag(), p) != cs.getParamValue(int_tag(), p)) return false; break; case DOUBLE: if (getParamValue(double_tag(), p) != cs.getParamValue(double_tag(), p)) return false; break; case FILEPATH: if (getParamValue(TFilePath_tag(), p) != cs.getParamValue(TFilePath_tag(), p)) return false; break; default: assert(false); } } return true; }
void CleanupColorFieldEditorController::onColorStyleChanged() { if (!m_currentColorField) return; assert(!!m_palette); TColorStyle *style = m_palette->getStyle(1); if (m_blackColor) { if (m_currentColorField->getOutputColor() == style->getMainColor()) return; m_currentColorField->setOutputColor(style->getMainColor()); } else { if (m_currentColorField->getColor() == style->getMainColor() && m_currentColorField->getOutputColor() == style->getColorParamValue(1)) return; m_currentColorField->setStyle(style); } }
UndoPickRGBM(TPalette *palette, int styleId, const TPixel32 newValue, const TXshSimpleLevelP &level) : m_palette(palette) , m_styleId(styleId) , m_newValue(newValue) , m_level(level) , m_colorAutoApplyEnabled(true) { PaletteController *controller = TTool::getApplication()->getPaletteController(); m_colorAutoApplyEnabled = controller->isColorAutoApplyEnabled(); m_styleParamIndex = controller->getCurrentPalette()->getStyleParamIndex(); if (m_colorAutoApplyEnabled) { TColorStyle *cs = m_palette->getStyle(m_styleId); if (0 <= m_styleParamIndex && m_styleParamIndex < cs->getColorParamCount()) m_oldValue = cs->getColorParamValue(m_styleParamIndex); else m_oldValue = cs->getMainColor(); } else { m_oldValue = controller->getColorSample(); } }