Beispiel #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);
}
Beispiel #2
0
void RGBPickerTool::pickRect() {
  TImageP image = TImageP(getImage(false));

  TTool::Application *app = TTool::getApplication();
  TPaletteHandle *ph      = app->getPaletteController()->getCurrentPalette();
  int styleId             = ph->getStyleIndex();
  TPalette *palette       = ph->getPalette();
  TRectD area             = m_selectingRect;
  if (!palette) return;
  if (m_selectingRect.x0 > m_selectingRect.x1) {
    area.x1 = m_selectingRect.x0;
    area.x0 = m_selectingRect.x1;
  }
  if (m_selectingRect.y0 > m_selectingRect.y1) {
    area.y1 = m_selectingRect.y0;
    area.y0 = m_selectingRect.y1;
  }
  m_selectingRect.empty();
  if (area.getLx() <= 1 || area.getLy() <= 1) return;
  StylePicker picker(image, palette);

  // iwsw commented out temporarily
  // if (m_viewer->get3DLutUtil() &&
  // Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
  //	m_viewer->get3DLutUtil()->bindFBO();

  m_currentValue = picker.pickColor(area);

  // iwsw commented out temporarily
  // if (m_viewer->get3DLutUtil() &&
  // Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
  //	m_viewer->get3DLutUtil()->releaseFBO();
}
Beispiel #3
0
void RGBPickerTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e) {
  TTool::Application *app   = TTool::getApplication();
  TPaletteHandle *pltHandle = app->getPaletteController()->getCurrentPalette();
  m_currentStyleId          = pltHandle->getStyleIndex();
  if (m_currentStyleId == 0) return;

  TColorStyle *colorStyle = pltHandle->getStyle();

  if (colorStyle) m_oldValue = colorStyle->getMainColor();

  if (m_pickType.getValue() == RECT_PICK) {
    m_selectingRect.x0 = e.m_pos.x;
    m_selectingRect.y0 = e.m_pos.y;
    m_selectingRect.x1 = e.m_pos.x;
    m_selectingRect.y1 = e.m_pos.y;
    m_drawingRect.x0   = pos.x;
    m_drawingRect.y0   = pos.y;
    m_drawingRect.x1   = pos.x;
    m_drawingRect.y1   = pos.y;
    invalidate();
    return;
  } else if (m_pickType.getValue() == FREEHAND_PICK) {
    startFreehand(pos, convert(e.m_pos));
    return;
  } else if (m_pickType.getValue() == POLYLINE_PICK) {
    addPointPolyline(pos, convert(e.m_pos));
    return;
  } else {
    pick(e.m_pos);
  }
}
Beispiel #4
0
void TApp::onLevelColorStyleSwitched() {
  TPaletteHandle *ph = m_paletteController->getCurrentLevelPalette();
  assert(ph);

  if (ToonzCheck::instance()->setColorIndex(ph->getStyleIndex())) {
    ToonzCheck *tc = ToonzCheck::instance();
    int mask       = tc->getChecks();

    if (mask & ToonzCheck::eInk || mask & ToonzCheck::ePaint) {
      IconGenerator::Settings s;
      s.m_blackBgCheck      = mask & ToonzCheck::eBlackBg;
      s.m_transparencyCheck = mask & ToonzCheck::eTransparency;
      s.m_inksOnly          = mask & ToonzCheck::eInksOnly;
      s.m_inkIndex   = mask & ToonzCheck::eInk ? tc->getColorIndex() : -1;
      s.m_paintIndex = mask & ToonzCheck::ePaint ? tc->getColorIndex() : -1;

      IconGenerator::instance()->setSettings(s);

      TXshLevel *sl = m_currentLevel->getLevel();
      if (!sl) return;

      std::vector<TFrameId> fids;
      sl->getFids(fids);

      for (int i = 0; i < (int)fids.size(); i++)
        IconGenerator::instance()->invalidate(sl, fids[i]);

      m_currentLevel->notifyLevelViewChange();
    }

    /*-- 表示オプションが切り替わっただけなので、DirtyFlagを立てない --*/
    m_currentScene->notifySceneChanged(false);
  }
}
Beispiel #5
0
/*! notify the color picked by rgb picker to palette controller
*/
void ImageViewer::setPickedColorToStyleEditor(const TPixel32 &color) {
  // do not modify the style #0
  TPaletteHandle *ph =
      TApp::instance()->getPaletteController()->getCurrentPalette();
  if (ph->getStyleIndex() == 0) return;

  TApp::instance()->getPaletteController()->setColorSample(color);
}
void TStyleSelection::toggleLink()
{
	if (!m_palette || m_pageIndex < 0)
		return;
	int n = m_styleIndicesInPage.size();
	if (n <= 0)
		return;

	bool somethingHasBeenLinked = false;

	bool currentStyleIsInSelection = false;
	TApp *app = TApp::instance();
	TPaletteHandle *ph = app->getCurrentPalette();

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

	for (std::set<int>::iterator it = m_styleIndicesInPage.begin();
		 it != m_styleIndicesInPage.end(); ++it) {
		TColorStyle *cs = page->getStyle(*it);
		assert(cs);
		wstring name = cs->getGlobalName();
		if (name != L"" && (name[0] == L'-' || name[0] == L'+')) {
			name[0] = name[0] == L'-' ? L'+' : L'-';
			cs->setGlobalName(name);
			if (name[0] == L'+')
				somethingHasBeenLinked = true;
		}

		if (*it == m_palette->getPage(m_pageIndex)->search(ph->getStyleIndex()))
			currentStyleIsInSelection = true;
	}
	if (somethingHasBeenLinked)
		StudioPalette::instance()->updateLinkedColors(m_palette.getPointer());

	ph->notifyPaletteChanged();

	if (currentStyleIsInSelection)
		ph->notifyColorStyleSwitched();

	// DA FARE: e' giusto mettere la nofica del dirty flag a current scene
	// o e' meglio farlo al livello corrente!?
	app->getCurrentScene()->setDirtyFlag(true);
	//  extern void setPaletteDirtyFlag();
	//  setPaletteDirtyFlag();
}
Beispiel #7
0
void setCurrentColorWithUndo(const TPixel32 &color) {
  TTool::Application *app = TTool::getApplication();
  TPaletteHandle *ph      = app->getPaletteController()->getCurrentPalette();
  int styleId             = ph->getStyleIndex();
  TPalette *palette       = ph->getPalette();
  TXshSimpleLevel *level  = app->getCurrentLevel()->getSimpleLevel();
  if (palette)
    TUndoManager::manager()->add(
        new UndoPickRGBM(palette, styleId, color, level));

  setCurrentColor(color);

  if (level) {
    std::vector<TFrameId> fids;
    level->getFids(fids);
    invalidateIcons(level, fids);
  }
}
Beispiel #8
0
void RGBPickerTool::onImageChanged() {
  if (m_currentStyleId != 0 && m_makePick &&
      (m_pickType.getValue() == POLYLINE_PICK ||
       m_pickType.getValue() == RECT_PICK)) {
    TTool::Application *app = TTool::getApplication();
    TPaletteHandle *ph      = app->getPaletteController()->getCurrentPalette();
    int styleId             = ph->getStyleIndex();
    TPalette *palette       = ph->getPalette();
    TXshSimpleLevel *level  = app->getCurrentLevel()->getSimpleLevel();
    if (palette)
      TUndoManager::manager()->add(
          new UndoPickRGBM(palette, styleId, m_currentValue, level));
    setCurrentColor(m_currentValue);
    if (level) {
      std::vector<TFrameId> fids;
      level->getFids(fids);
      invalidateIcons(level, fids);
    }
  }
  m_makePick = false;
}
Beispiel #9
0
void RGBPickerTool::pick(TPoint pos) {
  TImageP image = TImageP(getImage(false));

  TTool::Application *app = TTool::getApplication();
  TPaletteHandle *ph      = app->getPaletteController()->getCurrentPalette();
  int styleId             = ph->getStyleIndex();
  TPalette *palette       = ph->getPalette();
  if (!palette) return;

  TRectD area = TRectD(pos.x - 1, pos.y - 1, pos.x + 1, pos.y + 1);
  StylePicker picker(image, palette);

  // iwsw commented out temporarily
  // if (m_viewer->get3DLutUtil() &&
  // Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
  //	m_viewer->get3DLutUtil()->bindFBO();

  m_currentValue = picker.pickColor(area);

  // iwsw commented out temporarily
  // if (m_viewer->get3DLutUtil() &&
  // Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
  //	m_viewer->get3DLutUtil()->releaseFBO();

  TXshSimpleLevel *level = app->getCurrentLevel()->getSimpleLevel();
  UndoPickRGBM *cmd = new UndoPickRGBM(palette, styleId, m_currentValue, level);
  TUndoManager::manager()->add(cmd);
  cmd->redo();
  /*
setCurrentColor(m_currentValue);
if(level)
{
vector<TFrameId> fids;
level->getFids(fids);
invalidateIcons(level,fids);
}
*/
}
Beispiel #10
0
void RGBPickerTool::pickStroke() {
  TImageP image = TImageP(getImage(false));

  TTool::Application *app = TTool::getApplication();
  TPaletteHandle *ph      = app->getPaletteController()->getCurrentPalette();
  int styleId             = ph->getStyleIndex();
  TPalette *palette       = ph->getPalette();
  if (!palette) return;

  StylePicker picker(image, palette);
  TStroke *stroke = new TStroke(*m_stroke);

  // iwsw commented out temporarily
  // if (m_viewer->get3DLutUtil() &&
  // Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
  //	m_viewer->get3DLutUtil()->bindFBO();

  m_currentValue = picker.pickColor(stroke);

  // iwsw commented out temporarily
  // if (m_viewer->get3DLutUtil() &&
  // Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
  //	m_viewer->get3DLutUtil()->releaseFBO();

  if (!(m_pickType.getValue() == POLYLINE_PICK)) {
    TXshSimpleLevel *level = app->getCurrentLevel()->getSimpleLevel();
    TUndoManager::manager()->add(
        new UndoPickRGBM(palette, styleId, m_currentValue, level));
    setCurrentColor(m_currentValue);
    if (level) {
      std::vector<TFrameId> fids;
      level->getFids(fids);
      invalidateIcons(level, fids);
    }
  }
}