예제 #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);
}
예제 #2
0
void TStyleSelection::pasteStylesValue()
{
	if (!m_palette || m_pageIndex < 0)
		return;
	if (m_pageIndex == 0 && isSelected(m_palette, 0, 0)) {
		MsgBox(CRITICAL, "Can't modify color #0");
		return;
	}

	TPalette::Page *page = m_palette->getPage(m_pageIndex);
	assert(page);
	const StyleData *data = dynamic_cast<const StyleData *>(QApplication::clipboard()->mimeData());
	if (!data)
		return;
	int i = 0;
	UndoPasteValues *undo = new UndoPasteValues(m_palette);
	std::set<int>::iterator it;
	for (it = m_styleIndicesInPage.begin(); it != m_styleIndicesInPage.end() && i < data->getStyleCount(); ++it, i++) {
		int styleId = page->getStyleId(*it);
		undo->addItem(styleId, m_palette->getStyle(styleId), data->getStyle(i));
		m_palette->setStyle(styleId, data->getStyle(i)->clone());
	}
	TUndoManager::manager()->add(undo);

	TPaletteHandle *ph = TApp::instance()->getCurrentPalette();
	ph->notifyColorStyleChanged();
	ph->updateColor();
}