Exemplo n.º 1
0
/*! Update current square colore and, if click event is enable set current
		StyleSample \b TColorStyle style to \b style.
*/
void StyleSample::setStyle(TColorStyle &style)
{
	/*-- TSolidColorStyleの場合のみ、単色塗りつぶし --*/
	if (style.getTagId() == 3)
		setColor(style.getMainColor());
	else {
		TRaster32P icon = style.getIcon(qsize2Dimension(m_samplePixmap.rect().size()));
		m_samplePixmap = rasterToQImage(icon, false); //modified in 6.2
		update();
	}
	if (m_clickEnabled)
		m_style = style.clone();
}
Exemplo n.º 2
0
void TStyleSelection::blendStyles()
{
	if (!m_palette || m_pageIndex < 0)
		return;
	int n = m_styleIndicesInPage.size();
	if (n < 2)
		return;

	TPalette::Page *page = m_palette->getPage(m_pageIndex);
	assert(page);

	std::vector<TColorStyle *> styles;
	std::vector<std::pair<int, TColorStyle *>> oldStyles;
	for (std::set<int>::iterator it = m_styleIndicesInPage.begin();
		 it != m_styleIndicesInPage.end(); ++it) {
		TColorStyle *cs = page->getStyle(*it);
		assert(cs);
		styles.push_back(cs);
		oldStyles.push_back(std::pair<int, TColorStyle *>(*it, cs->clone()));
	}
	assert(styles.size() >= 2);

	TPixel32 c0 = styles.front()->getMainColor();
	TPixel32 c1 = styles.back()->getMainColor();

	bool areAllStyleLincked = true;
	int i;
	for (i = 1; i < n - 1; i++) {
		QString gname = QString::fromStdWString(styles[i]->getGlobalName());
		if (!gname.isEmpty() && gname[0] != L'-')
			continue;
		areAllStyleLincked = false;
		styles[i]->setMainColor(blend(c0, c1, (double)i / (double)(n - 1)));
		styles[i]->invalidateIcon();
	}
	if (areAllStyleLincked)
		return;
	TApp::instance()->getCurrentPalette()->notifyColorStyleChanged();

	UndoBlendColor *undo = new UndoBlendColor(m_palette, m_pageIndex, oldStyles, c0, c1);
	TUndoManager::manager()->add(undo);
}