Пример #1
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);
  }
}
Пример #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);
}