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();
}
示例#2
0
void setCurrentColor(const TPixel32 &color) {
  PaletteController *controller =
      TTool::getApplication()->getPaletteController();
  TPaletteHandle *ph = controller->getCurrentPalette();

  TColorStyle *cs = ph->getStyle();
  if (!cs) return;

  if (controller->isColorAutoApplyEnabled()) {
    TCleanupStyle *ccs = dynamic_cast<TCleanupStyle *>(cs);
    if (ccs) ccs->setCanUpdate(true);

    int index = ph->getStyleParamIndex();
    if (0 <= index && index < cs->getColorParamCount())
      cs->setColorParamValue(index, color);
    else
      cs->setMainColor(color);

    cs->invalidateIcon();
    ph->notifyColorStyleChanged();

    // per le palette animate
    int styleIndex    = ph->getStyleIndex();
    TPalette *palette = ph->getPalette();
    if (palette && palette->isKeyframe(styleIndex, palette->getFrame()))
      palette->setKeyframe(styleIndex, palette->getFrame());

    if (ccs) ccs->setCanUpdate(false);
  } else
    controller->setColorSample(color);
}
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;
}
示例#4
0
 void setColor(const TPixel32 &color) const {
   PaletteController *controller =
       TTool::getApplication()->getPaletteController();
   if (m_colorAutoApplyEnabled) {
     TColorStyle *cs = m_palette->getStyle(m_styleId);
     if (0 <= m_styleParamIndex &&
         m_styleParamIndex < cs->getColorParamCount())
       cs->setColorParamValue(m_styleParamIndex, color);
     else
       cs->setMainColor(color);
     cs->invalidateIcon();
     controller->getCurrentPalette()->notifyColorStyleChanged();
     updateLevel();
   } else {
     controller->setColorSample(color);
   }
 }
示例#5
0
 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();
   }
 }