Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sources/iwlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "iwtimelinekeyselection.h"
#include "iwtrianglecache.h"
#include "keydragtool.h"
#include "menubarcommandids.h"

#include <QVector>
#include <QPainter>
Expand Down Expand Up @@ -862,6 +863,9 @@ void IwLayer::onRightClick(int row, QMenu& menu) {
menu.addAction(parentChildAct);
//----

menu.addAction(
CommandManager::instance()->getAction(MI_PasteMatteInfo));

return;
}
currentRow += shapePair->getRowCount();
Expand Down
76 changes: 76 additions & 0 deletions sources/iwshapepairselection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ void IwShapePairSelection::enableCommands() {
enableCommand(this, MI_ToggleShapeLock, &IwShapePairSelection::toggleLocks);
enableCommand(this, MI_ToggleVisibility,
&IwShapePairSelection::toggleVisibility);
enableCommand(this, MI_PasteMatteInfo, &IwShapePairSelection::pasteMatteInfo);
}

bool IwShapePairSelection::isEmpty() const { return m_shapes.isEmpty(); }
Expand Down Expand Up @@ -680,6 +681,44 @@ void IwShapePairSelection::setShapeTag(int tagId, bool on) {
new SetShapeTagUndo(m_shapes, project, tagId, on));
}

//---------------------------------------------------
// マット情報貼り付け
//---------------------------------------------------
void IwShapePairSelection::pasteMatteInfo() {
// プロジェクト無ければreturn
IwProject* project = IwApp::instance()->getCurrentProject()->getProject();
if (!project) return;

// クリップボードからデータを取り、ShapePairDataかどうか確認
QClipboard* clipboard = QApplication::clipboard();
const QMimeData* mimeData = clipboard->mimeData();
const ShapePairData* shapePairData =
dynamic_cast<const ShapePairData*>(mimeData);
// データが違っていたらreturn
if (!shapePairData) return;
// とりあえず、コピーしたシェイプは1つだけである必要
if (shapePairData->m_data.count() != 1) return;

ShapePair::MatteInfo matteInfo = shapePairData->m_data[0]->matteInfo();

// 選択シェイプ取得
QList<OneShape>::iterator i = m_shapes.begin();
QList<ShapePair*> shapePairs;
while (i != m_shapes.end()) {
if ((*i).shapePairP && project->contains((*i).shapePairP) &&
!shapePairs.contains((*i).shapePairP)) {
shapePairs.append((*i).shapePairP);
}
i++;
}

if (shapePairs.isEmpty()) return;

// Undoに登録 同時にredoが呼ばれる
IwUndoManager::instance()->push(
new PasteMatteInfoUndo(shapePairs, project, matteInfo));
}

//---------------------------------------------------
// 以下、Undoコマンドを登録
//---------------------------------------------------
Expand Down Expand Up @@ -894,3 +933,40 @@ void SetShapeTagUndo::setTag(bool isUndo) {
void SetShapeTagUndo::undo() { setTag(true); }

void SetShapeTagUndo::redo() { setTag(false); }

//---------------------------------------------------
// マット情報貼り付けのUndo
//---------------------------------------------------

PasteMatteInfoUndo::PasteMatteInfoUndo(QList<ShapePair*>& shapePairs,
IwProject* project,
ShapePair::MatteInfo newInfo)
: m_project(project), m_newInfo(newInfo) {
for (auto shapePair : shapePairs) {
m_prevMatteInfos.append(QPair<ShapePair*, ShapePair::MatteInfo>(
shapePair, shapePair->matteInfo()));
}
}

void PasteMatteInfoUndo::undo() {
for (auto infoData : m_prevMatteInfos) {
ShapePair* shapePair = infoData.first;
ShapePair::MatteInfo info = infoData.second;
shapePair->setMatteLayerName(info.layerName);
shapePair->setMatteColors(info.colors);
shapePair->setMatteTolerance(info.tolerance);
}
if (m_project->isCurrent())
IwApp::instance()->getCurrentProject()->notifyProjectChanged();
}

void PasteMatteInfoUndo::redo() {
for (auto infoData : m_prevMatteInfos) {
ShapePair* shapePair = infoData.first;
shapePair->setMatteLayerName(m_newInfo.layerName);
shapePair->setMatteColors(m_newInfo.colors);
shapePair->setMatteTolerance(m_newInfo.tolerance);
}
if (m_project->isCurrent())
IwApp::instance()->getCurrentProject()->notifyProjectChanged();
}
19 changes: 19 additions & 0 deletions sources/iwshapepairselection.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ class IwShapePairSelection : public IwSelection // singleton

// シェイプタグ切り替え
void setShapeTag(int tagId, bool on);

// マット情報貼り付け
void pasteMatteInfo();
};

//---------------------------------------------------
Expand Down Expand Up @@ -245,4 +248,20 @@ class SetShapeTagUndo : public QUndoCommand {
void undo();
void redo();
};

//---------------------------------------------------
// マット情報貼り付けのUndo
//---------------------------------------------------

class PasteMatteInfoUndo : public QUndoCommand {
QList<QPair<ShapePair*, ShapePair::MatteInfo>> m_prevMatteInfos;
IwProject* m_project;
ShapePair::MatteInfo m_newInfo;

public:
PasteMatteInfoUndo(QList<ShapePair*>& shapePairs, IwProject* project,
ShapePair::MatteInfo newInfo);
void undo();
void redo();
};
#endif
2 changes: 2 additions & 0 deletions sources/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ void MainWindow::defineActions() {
MenuShapeCommandType);
createAction(MI_ToggleVisibility, tr("Toggle Visibility of Selected Shapes"),
"", MenuShapeCommandType);
createAction(MI_PasteMatteInfo, tr("Paste Matte Info"), "Ctrl+Alt+V",
MenuShapeCommandType);
}

//---------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions sources/menubarcommandids.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#define MI_ToggleShapeLock "MI_ToggleShapeLock"
#define MI_ToggleVisibility "MI_ToggleVisibility"
#define MI_MatteInfo "MI_MatteInfo"
#define MI_PasteMatteInfo "MI_PasteMatteInfo"

//---- 上側の表示コントロールツールバーのコマンド
// #define VMI_MultiFrameMode "VMI_MultiFrameMode"
Expand Down
1 change: 1 addition & 0 deletions sources/shapeoptionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ void ShapeOptionsDialog::onSelectionChanged(IwSelection *selection) {
m_depthEdit->setText(QString::number(minDepth));
else
m_depthEdit->setText(QString("%1 - %2").arg(minDepth).arg(maxDepth));

} else {
m_depthSlider->setDisabled(true);
m_depthEdit->setDisabled(true);
Expand Down
Loading