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); } }
void undo() const override { TXshLevel *level = m_levelHandle->getLevel(); if (level) { std::vector<TFrameId> fids; level->getFids(fids); invalidateIcons(level, fids); } }
void TApp::onXshLevelChanged() { TXshLevel *level = m_currentLevel->getLevel(); std::vector<TFrameId> fids; if (level != 0) level->getFids(fids); m_currentFrame->setFrameIds(fids); // update current tool m_currentTool->onImageChanged((TImage::Type)getCurrentImageType()); }
void Filmstrip::onLevelSwitched(TXshLevel *oldLevel) { updateWindowTitle(); int tc = ToonzCheck::instance()->getChecks(); if (tc & (ToonzCheck::eInk | ToonzCheck::ePaint)) { TXshLevel *sl = TApp::instance()->getCurrentLevel()->getLevel(); if (!sl) return; std::vector<TFrameId> fids; sl->getFids(fids); removeIcons(sl, fids, true); } update(); }
void StudioPaletteTreeViewer::loadInCurrentPalette() { QList<QTreeWidgetItem *> items = selectedItems(); int count = items.size(); if (count == 0) return; TPalette *palette = m_levelPaletteHandle->getPalette(); if (!palette) return; if (palette->isLocked()) { DVGui::warning("Palette is Locked!"); return; } TPalette *newPalette = StudioPalette::instance()->getPalette(getItemPath(items[0]), false); if (!newPalette) return; if (m_xsheetHandle) { int ret = DVGui::eraseStylesInDemand(palette, m_xsheetHandle, newPalette); if (ret == 0) return; } StudioPaletteCmd::loadIntoCurrentPalette(m_levelPaletteHandle, newPalette); m_currentLevelHandle->notifyLevelChange(); TXshLevel *level = m_currentLevelHandle->getLevel(); if (level) { std::vector<TFrameId> fids; level->getFids(fids); invalidateIcons(level, fids); } int i; for (i = 1; i < count; i++) { TFilePath path = getItemPath(items[i]); StudioPaletteCmd::mergeIntoCurrentPalette(m_levelPaletteHandle, path); } // in order to update the title bar of palette viewer m_levelPaletteHandle->getPalette()->setDirtyFlag(true); m_levelPaletteHandle->notifyPaletteChanged(); }
void mergeColumns(int column, int mColumn, bool isRedo) { MergeColumnsSessionId++; TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); int start, end; xsh->getCellRange(column, start, end); if (start > end) return; vector<TXshCell> cell(end - start + 1); vector<TXshCell> mCell(end - start + 1); xsh->getCells(start, column, cell.size(), &(cell[0])); xsh->getCells(start, mColumn, cell.size(), &(mCell[0])); TXshColumn *col = xsh->getColumn(column); TXshColumn *mcol = xsh->getColumn(mColumn); vector<MatchlinePair> matchingLevels; std::set<TFrameId> alreadyDoneSet; TXshSimpleLevel *level = 0, *mLevel = 0; TXshLevelP xl; bool areRasters = false; std::map<TFrameId, QString> images; for (int i = 0; i < (int)cell.size(); i++) { if (cell[i].isEmpty() || mCell[i].isEmpty()) continue; if (!level) { level = cell[i].getSimpleLevel(); xl = cell[i].m_level; } else if (level != cell[i].getSimpleLevel()) { MsgBox(WARNING, QObject::tr("It is not possible to perform a merging involving more than one level per column.")); return; } if (!mLevel) mLevel = mCell[i].getSimpleLevel(); else if (mLevel != mCell[i].getSimpleLevel()) { MsgBox(WARNING, QObject::tr("It is not possible to perform a merging involving more than one level per column.")); return; } TImageP img = cell[i].getImage(true); TImageP match = mCell[i].getImage(false); TFrameId fid = cell[i].m_frameId; TFrameId mFid = mCell[i].m_frameId; if (!img || !match) continue; if (alreadyDoneSet.find(fid) == alreadyDoneSet.end()) { TRasterImageP timg = (TRasterImageP)img; TRasterImageP tmatch = (TRasterImageP)match; TVectorImageP vimg = (TVectorImageP)img; TVectorImageP vmatch = (TVectorImageP)match; if (timg) { if (!tmatch) { MsgBox(WARNING, QObject::tr("Only raster levels can be merged to a raster level.")); return; } areRasters = true; } else if (vimg) { if (!vmatch) { MsgBox(WARNING, QObject::tr("Only vector levels can be merged to a vector level.")); return; } } else { MsgBox(WARNING, QObject::tr("It is possible to merge only Toonz vector levels or standard raster levels.")); return; } QString id = "MergeColumnsUndo" + QString::number(MergeColumnsSessionId) + "-" + QString::number(fid.getNumber()); TImageCache::instance()->add(id, (timg) ? timg->cloneImage() : vimg->cloneImage()); images[fid] = id; TAffine imgAff, matchAff; getColumnPlacement(imgAff, xsh, start + i, column, false); getColumnPlacement(matchAff, xsh, start + i, mColumn, false); TAffine dpiAff = getDpiAffine(level, fid); TAffine mdpiAff = getDpiAffine(mLevel, mFid); matchingLevels.push_back(MatchlinePair(cell[i], imgAff * dpiAff, mCell[i], matchAff * mdpiAff)); alreadyDoneSet.insert(fid); } } if (matchingLevels.empty()) { MsgBox(WARNING, QObject::tr("It is possible to merge only Toonz vector levels or standard raster levels.")); return; } ToonzScene *sc = TApp::instance()->getCurrentScene()->getScene(); TXshSimpleLevel *simpleLevel = sc->getLevelSet()->getLevel(column)->getSimpleLevel(); if (!isRedo) TUndoManager::manager()->add(new MergeColumnsUndo(xl, MergeColumnsSessionId, column, level, images, mColumn, level->getPalette())); if (areRasters) { mergeRasterColumns(matchingLevels); for (int i = 0; i < (int)cell.size(); i++) //the saveboxes must be updated { if (cell[i].isEmpty() || mCell[i].isEmpty()) continue; if (!cell[i].getImage(false) || !mCell[i].getImage(false)) continue; ToolUtils::updateSaveBox(cell[i].getSimpleLevel(), cell[i].m_frameId); } } else mergeVectorColumns(matchingLevels); TXshLevel *sl = TApp::instance()->getCurrentScene()->getScene()->getLevelSet()->getLevel(column); vector<TFrameId> fidsss; sl->getFids(fidsss); invalidateIcons(sl, fidsss); sl->setDirtyFlag(true); level->setDirtyFlag(true); TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); }
void FilmstripFrames::mousePressEvent(QMouseEvent *event) { m_selecting = false; int index = y2index(event->pos().y()); TFrameId fid = index2fid(index); TXshSimpleLevel *sl = getLevel(); int i0 = y2index(0); int frameHeight = m_iconSize.height() + fs_frameSpacing + fs_iconMarginTop + fs_iconMarginBottom; QPoint clickedPos = event->pos() - QPoint(0, (index - i0) * frameHeight); if (event->button() == Qt::LeftButton) { if (fid == TFrameId()) return; ComboViewerPanel *inknPaintViewerPanel = TApp::instance()->getInknPaintViewerPanel(); // navigator pan if (fid == TApp::instance()->getCurrentFrame()->getFid() && sl->getType() == TZP_XSHLEVEL && inknPaintViewerPanel && inknPaintViewerPanel->isVisible() && QRect(QPoint(fs_leftMargin + fs_iconMarginLR, fs_frameSpacing / 2 + fs_iconMarginTop) //<- top-left position of the icon , m_iconSize) .contains(clickedPos)) { m_isNavigatorPanning = true; execNavigatorPan(event->pos()); QApplication::setOverrideCursor(Qt::ClosedHandCursor); } else m_isNavigatorPanning = false; if (event->modifiers() & Qt::ShiftModifier) { select(index, SHIFT_SELECT); if (m_selection->isSelected(fid)) { // click su di un frame gia' selezionato. Puo' essere l'inizio di un // drag'n'drop m_dragDropArmed = true; m_pos = event->pos(); } } else if (event->modifiers() & Qt::ControlModifier) select(index, CTRL_SELECT); // inbetween else if (sl->getType() == PLI_XSHLEVEL && m_selection->isInInbetweenRange(fid) && event->pos().x() > width() - 20 - fs_rightMargin) { inbetween(); } else { // move current frame when clicked without modifier TApp *tapp = TApp::instance(); std::vector<TFrameId> fids; TXshLevel *level = tapp->getCurrentLevel()->getLevel(); level->getFids(fids); tapp->getCurrentFrame()->setFrameIds(fids); tapp->getCurrentFrame()->setFid(fid); if (!m_selection->isSelected(fid)) // selezione semplice { // click su un frame non selezionato m_selecting = true; // posso estendere la selezione con il drag select(index, START_DRAG_SELECT); } else if (m_selection->isSelected(fid)) { // click su di un frame gia' selezionato. Puo' essere l'inizio di un // drag'n'drop m_dragDropArmed = true; m_pos = event->pos(); } } update(); } else if (event->button() == Qt::MidButton) { m_pos = event->globalPos(); return; } else if (event->button() == Qt::RightButton) { select(index); } }