-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Percussion panel - notation preview basics
- Loading branch information
1 parent
a0f2a79
commit 8bb9e07
Showing
10 changed files
with
188 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
* MuseScore-Studio-CLA-applies | ||
* | ||
* MuseScore Studio | ||
* Music Composition & Notation | ||
* | ||
* Copyright (C) 2024 MuseScore Limited | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "paintedengravingitem.h" | ||
|
||
#include "notation/utilities/engravingitempreviewpainter.h" | ||
|
||
using namespace mu::notation; | ||
|
||
PaintedEngravingItem::PaintedEngravingItem(QQuickItem* parent) | ||
: QQuickPaintedItem(parent) | ||
{ | ||
} | ||
|
||
void PaintedEngravingItem::setEngravingItem(mu::engraving::EngravingItem* item) | ||
{ | ||
if (item == m_item) { | ||
return; | ||
} | ||
m_item = item; | ||
} | ||
|
||
void PaintedEngravingItem::paint(QPainter* painter) | ||
{ | ||
qreal dpi = painter->device()->logicalDpiX(); | ||
muse::draw::Painter p(painter, "paintedengravingitem"); | ||
p.save(); | ||
p.setAntialiasing(true); | ||
paintNotationPreview(p, dpi); | ||
p.restore(); | ||
} | ||
|
||
void PaintedEngravingItem::paintNotationPreview(muse::draw::Painter& painter, qreal dpi) const | ||
{ | ||
IF_ASSERT_FAILED(m_item) { | ||
return; | ||
} | ||
|
||
EngravingItemPreviewPainter::PaintParams params; | ||
params.painter = &painter; | ||
|
||
params.color = QColor("black"); // TODO: set this properly | ||
|
||
params.rect = muse::RectF(0, 0, parentItem()->width(), parentItem()->height()); | ||
params.dpi = dpi; | ||
|
||
params.spatium = configuration()->paletteSpatium(); // TODO: don't use the palette for this | ||
|
||
params.drawStaff = true; | ||
|
||
painter.fillRect(params.rect, muse::draw::Color::WHITE); // TODO: set this properly | ||
|
||
EngravingItemPreviewPainter::paintPreview(m_item, params); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
* MuseScore-Studio-CLA-applies | ||
* | ||
* MuseScore Studio | ||
* Music Composition & Notation | ||
* | ||
* Copyright (C) 2024 MuseScore Limited | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <QQuickPaintedItem> | ||
|
||
#include "modularity/ioc.h" | ||
#include "palette/ipaletteconfiguration.h" | ||
|
||
#include "engraving/dom/engravingitem.h" | ||
|
||
#include "notation/utilities/engravingitempreviewpainter.h" | ||
|
||
namespace mu::notation { | ||
class PaintedEngravingItem : public QQuickPaintedItem | ||
{ | ||
// TODO: don't use the palette for this | ||
INJECT_STATIC(palette::IPaletteConfiguration, configuration) | ||
|
||
Q_OBJECT | ||
|
||
public: | ||
explicit PaintedEngravingItem(QQuickItem* parent = nullptr); | ||
|
||
void setEngravingItem(mu::engraving::EngravingItem* item); | ||
void paint(QPainter* painter) override; | ||
|
||
private: | ||
void paintNotationPreview(muse::draw::Painter& painter, qreal dpi) const; | ||
|
||
mu::engraving::EngravingItem* m_item = nullptr; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters