Exemple #1
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);
}
Exemple #2
0
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()));
}
Exemple #3
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);
   }
 }