Added option to paint selected pieces. Fixes #561.

This commit is contained in:
Leonardo Zide 2020-12-29 19:20:03 -08:00
parent 3358553e1d
commit 58981f9580
6 changed files with 55 additions and 1 deletions

View file

@ -1172,6 +1172,13 @@ const lcCommand gCommands[] =
QT_TRANSLATE_NOOP("Status", "Create a copy of the selected pieces"), QT_TRANSLATE_NOOP("Status", "Create a copy of the selected pieces"),
"Ctrl+D" "Ctrl+D"
}, },
// LC_PIECE_PAINT_SELECTED
{
QT_TRANSLATE_NOOP("Action", "Piece.PaintSelected"),
QT_TRANSLATE_NOOP("Menu", "&Paint Selected"),
QT_TRANSLATE_NOOP("Status", "Change the color of the selected pieces"),
""
},
// LC_PIECE_RESET_PIVOT_POINT // LC_PIECE_RESET_PIVOT_POINT
{ {
QT_TRANSLATE_NOOP("Action", "Piece.ResetPivotPoint"), QT_TRANSLATE_NOOP("Action", "Piece.ResetPivotPoint"),

View file

@ -183,6 +183,7 @@ enum lcCommandId
LC_PIECE_INSERT, LC_PIECE_INSERT,
LC_PIECE_DELETE, LC_PIECE_DELETE,
LC_PIECE_DUPLICATE, LC_PIECE_DUPLICATE,
LC_PIECE_PAINT_SELECTED,
LC_PIECE_RESET_PIVOT_POINT, LC_PIECE_RESET_PIVOT_POINT,
LC_PIECE_REMOVE_KEY_FRAMES, LC_PIECE_REMOVE_KEY_FRAMES,
LC_PIECE_CONTROL_POINT_INSERT, LC_PIECE_CONTROL_POINT_INSERT,

View file

@ -567,6 +567,7 @@ void lcMainWindow::CreateMenus()
PieceMenu->addAction(mActions[LC_PIECE_INSERT]); PieceMenu->addAction(mActions[LC_PIECE_INSERT]);
PieceMenu->addAction(mActions[LC_PIECE_DELETE]); PieceMenu->addAction(mActions[LC_PIECE_DELETE]);
PieceMenu->addAction(mActions[LC_PIECE_DUPLICATE]); PieceMenu->addAction(mActions[LC_PIECE_DUPLICATE]);
PieceMenu->addAction(mActions[LC_PIECE_PAINT_SELECTED]);
PieceMenu->addAction(mActions[LC_PIECE_ARRAY]); PieceMenu->addAction(mActions[LC_PIECE_ARRAY]);
PieceMenu->addAction(mActions[LC_PIECE_MINIFIG_WIZARD]); PieceMenu->addAction(mActions[LC_PIECE_MINIFIG_WIZARD]);
PieceMenu->addAction(mActions[LC_PIECE_RESET_PIVOT_POINT]); PieceMenu->addAction(mActions[LC_PIECE_RESET_PIVOT_POINT]);
@ -709,7 +710,25 @@ void lcMainWindow::CreateToolBars()
mColorList = new lcQColorList(); mColorList = new lcQColorList();
connect(mColorList, SIGNAL(colorChanged(int)), this, SLOT(ColorChanged(int))); connect(mColorList, SIGNAL(colorChanged(int)), this, SLOT(ColorChanged(int)));
mColorsToolBar->setWidget(mColorList); QWidget* ColorWidget = new QWidget(mColorsToolBar);
QVBoxLayout* ColorLayout = new QVBoxLayout(ColorWidget);
QHBoxLayout* ColorButtonLayout = new QHBoxLayout();
ColorButtonLayout->setContentsMargins(0, 0, 0, 0);
ColorLayout->addLayout(ColorButtonLayout);
mColorButton = new QToolButton(ColorWidget);
mColorButton->setAutoRaise(true);
mColorButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
mColorButton->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
ColorButtonLayout->addWidget(mColorButton);
connect(mColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
ColorLayout->addWidget(mColorList);
mColorsToolBar->setWidget(ColorWidget);
addDockWidget(Qt::RightDockWidgetArea, mColorsToolBar); addDockWidget(Qt::RightDockWidgetArea, mColorsToolBar);
mPropertiesToolBar = new QDockWidget(tr("Properties"), this); mPropertiesToolBar = new QDockWidget(tr("Properties"), this);
@ -1110,6 +1129,14 @@ void lcMainWindow::ColorChanged(int ColorIndex)
SetColorIndex(ColorIndex); SetColorIndex(ColorIndex);
} }
void lcMainWindow::ColorButtonClicked()
{
lcModel* ActiveModel = GetActiveModel();
if (ActiveModel)
ActiveModel->PaintSelectedPieces();
}
void lcMainWindow::ProjectFileChanged(const QString& Path) void lcMainWindow::ProjectFileChanged(const QString& Path)
{ {
static bool Ignore; static bool Ignore;
@ -2038,6 +2065,7 @@ void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged)
mActions[LC_PIECE_DELETE]->setEnabled(Flags & LC_SEL_SELECTED); mActions[LC_PIECE_DELETE]->setEnabled(Flags & LC_SEL_SELECTED);
mActions[LC_PIECE_DUPLICATE]->setEnabled(Flags & LC_SEL_SELECTED); mActions[LC_PIECE_DUPLICATE]->setEnabled(Flags & LC_SEL_SELECTED);
mActions[LC_PIECE_PAINT_SELECTED]->setEnabled(Flags & LC_SEL_PIECE);
mActions[LC_PIECE_RESET_PIVOT_POINT]->setEnabled(Flags & LC_SEL_SELECTED); mActions[LC_PIECE_RESET_PIVOT_POINT]->setEnabled(Flags & LC_SEL_SELECTED);
mActions[LC_PIECE_REMOVE_KEY_FRAMES]->setEnabled(Flags & LC_SEL_SELECTED); mActions[LC_PIECE_REMOVE_KEY_FRAMES]->setEnabled(Flags & LC_SEL_SELECTED);
mActions[LC_PIECE_ARRAY]->setEnabled(Flags & LC_SEL_PIECE); mActions[LC_PIECE_ARRAY]->setEnabled(Flags & LC_SEL_PIECE);
@ -2152,6 +2180,11 @@ void lcMainWindow::UpdateSnap()
void lcMainWindow::UpdateColor() void lcMainWindow::UpdateColor()
{ {
QPixmap Pixmap(16, 16);
Pixmap.fill(QColor::fromRgbF(gColorList[mColorIndex].Value[0], gColorList[mColorIndex].Value[1], gColorList[mColorIndex].Value[2]));
mColorButton->setIcon(Pixmap);
mColorButton->setText(QString(" ") + gColorList[mColorIndex].Name);
mColorList->setCurrentColor(mColorIndex); mColorList->setCurrentColor(mColorIndex);
} }
@ -2885,6 +2918,11 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
ActiveModel->DuplicateSelectedPieces(); ActiveModel->DuplicateSelectedPieces();
break; break;
case LC_PIECE_PAINT_SELECTED:
if (ActiveModel)
ActiveModel->PaintSelectedPieces();
break;
case LC_PIECE_RESET_PIVOT_POINT: case LC_PIECE_RESET_PIVOT_POINT:
if (ActiveModel) if (ActiveModel)
ActiveModel->ResetSelectedPiecesPivotPoint(); ActiveModel->ResetSelectedPiecesPivotPoint();

View file

@ -370,6 +370,7 @@ protected slots:
void ClipboardChanged(); void ClipboardChanged();
void ActionTriggered(); void ActionTriggered();
void ColorChanged(int ColorIndex); void ColorChanged(int ColorIndex);
void ColorButtonClicked();
void Print(QPrinter* Printer); void Print(QPrinter* Printer);
void EnableWindowFlags(bool); void EnableWindowFlags(bool);
@ -442,6 +443,7 @@ protected:
lcPartSelectionWidget* mPartSelectionWidget; lcPartSelectionWidget* mPartSelectionWidget;
lcQColorList* mColorList; lcQColorList* mColorList;
QToolButton* mColorButton;
lcQPropertiesTree* mPropertiesWidget; lcQPropertiesTree* mPropertiesWidget;
lcTimelineWidget* mTimelineWidget; lcTimelineWidget* mTimelineWidget;
QLineEdit* mTransformXEdit; QLineEdit* mTransformXEdit;

View file

@ -1231,6 +1231,11 @@ void lcModel::DuplicateSelectedPieces()
SaveCheckpoint(tr("Duplicating Pieces")); SaveCheckpoint(tr("Duplicating Pieces"));
} }
void lcModel::PaintSelectedPieces()
{
SetSelectedPiecesColorIndex(gMainWindow->mColorIndex);
}
void lcModel::GetScene(lcScene* Scene, lcCamera* ViewCamera, bool AllowHighlight, bool AllowFade) const void lcModel::GetScene(lcScene* Scene, lcCamera* ViewCamera, bool AllowHighlight, bool AllowFade) const
{ {
if (mPieceInfo) if (mPieceInfo)

View file

@ -236,6 +236,7 @@ public:
void Copy(); void Copy();
void Paste(); void Paste();
void DuplicateSelectedPieces(); void DuplicateSelectedPieces();
void PaintSelectedPieces();
void GetScene(lcScene* Scene, lcCamera* ViewCamera, bool AllowHighlight, bool AllowFade) const; void GetScene(lcScene* Scene, lcCamera* ViewCamera, bool AllowHighlight, bool AllowFade) const;
void AddSubModelRenderMeshes(lcScene* Scene, const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcRenderMeshState RenderMeshState, bool ParentActive) const; void AddSubModelRenderMeshes(lcScene* Scene, const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcRenderMeshState RenderMeshState, bool ParentActive) const;