[engraving] moved draw Accidental

This commit is contained in:
Igor Korsukov 2023-07-27 16:33:46 +03:00
parent 224f03bfe5
commit 28ee0207b8
25 changed files with 740 additions and 49 deletions

View file

@ -136,7 +136,7 @@ void Paint::paintScore(draw::Painter* painter, Score* score, const Options& opt)
}
std::vector<EngravingItem*> elements = page->items(drawRect.translated(-pagePos));
paintElements(*painter, elements, opt.isPrinting);
paintItems(*painter, elements, opt.isPrinting);
if (disableClipping) {
painter->setClipping(false);
@ -207,38 +207,38 @@ SizeF Paint::pageSizeInch(const Score* score, const Options& opt)
return pageRect.size() / mu::engraving::DPI;
}
void Paint::paintElement(mu::draw::Painter& painter, const EngravingItem* element)
void Paint::paintItem(mu::draw::Painter& painter, const EngravingItem* item)
{
TRACEFUNC;
if (element->skipDraw()) {
if (item->skipDraw()) {
return;
}
element->itemDiscovered = false;
PointF elementPosition(element->pagePos());
item->itemDiscovered = false;
PointF itemPosition(item->pagePos());
painter.translate(elementPosition);
element->draw(&painter);
painter.translate(-elementPosition);
painter.translate(itemPosition);
EngravingItem::layout()->drawItem(item, &painter);
painter.translate(-itemPosition);
}
void Paint::paintElements(mu::draw::Painter& painter, const std::vector<EngravingItem*>& elements, bool isPrinting)
void Paint::paintItems(mu::draw::Painter& painter, const std::vector<EngravingItem*>& items, bool isPrinting)
{
TRACEFUNC;
std::vector<EngravingItem*> sortedElements(elements.begin(), elements.end());
std::vector<EngravingItem*> sortedItems(items.begin(), items.end());
std::sort(sortedElements.begin(), sortedElements.end(), mu::engraving::elementLessThan);
std::sort(sortedItems.begin(), sortedItems.end(), mu::engraving::elementLessThan);
for (const EngravingItem* element : sortedElements) {
if (!element->isInteractionAvailable()) {
for (const EngravingItem* item : sortedItems) {
if (!item->isInteractionAvailable()) {
continue;
}
paintElement(painter, element);
paintItem(painter, item);
}
#ifdef MUE_ENABLE_ENGRAVING_PAINT_DEBUGGER
if (!isPrinting) {
DebugPaint::paintElementsDebug(painter, sortedElements);
DebugPaint::paintElementsDebug(painter, sortedItems);
}
#else
UNUSED(isPrinting);

View file

@ -53,8 +53,8 @@ public:
};
static void paintScore(draw::Painter* painter, Score* score, const Options& opt);
static void paintElement(draw::Painter& painter, const EngravingItem* element);
static void paintElements(draw::Painter& painter, const std::vector<EngravingItem*>& elements, bool isPrinting);
static void paintItem(draw::Painter& painter, const EngravingItem* item);
static void paintItems(draw::Painter& painter, const std::vector<EngravingItem*>& items, bool isPrinting);
static SizeF pageSizeInch(const Score* score);
static SizeF pageSizeInch(const Score* score, const Options& opt);

View file

@ -1,6 +1,8 @@
set(LAYOUT_DEV_SRC
${CMAKE_CURRENT_LIST_DIR}/tdraw.cpp
${CMAKE_CURRENT_LIST_DIR}/tdraw.h
${CMAKE_CURRENT_LIST_DIR}/tlayout.cpp
${CMAKE_CURRENT_LIST_DIR}/tlayout.h
${CMAKE_CURRENT_LIST_DIR}/layout.cpp

View file

@ -27,6 +27,7 @@
#include "libmscore/harmony.h"
#include "libmscore/chord.h"
#include "tdraw.h"
#include "tlayout.h"
#include "chordlayout.h"
#include "layoutcontext.h"
@ -50,6 +51,11 @@ void Layout::doLayoutItem(EngravingItem* item)
TLayout::layoutItem(item, ctx);
}
void Layout::doDrawItem(const EngravingItem* item, draw::Painter* p)
{
TDraw::drawItem(item, p);
}
void Layout::layoutText1(TextBase* item, bool base)
{
LayoutContext ctx(item->score());

View file

@ -55,6 +55,8 @@ public:
private:
// Layout Single Item
void doLayoutItem(EngravingItem* item) override;
void doDrawItem(const EngravingItem* item, draw::Painter* p) override;
};
}

View file

@ -0,0 +1,55 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2023 MuseScore BVBA and others
*
* 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 "tdraw.h"
#include "libmscore/accidental.h"
#include "libmscore/note.h"
#include "infrastructure/rtti.h"
using namespace mu::engraving;
using namespace mu::engraving::rtti;
using namespace mu::engraving::layout::dev;
void TDraw::drawItem(const EngravingItem* item, draw::Painter* painter)
{
switch (item->type()) {
case ElementType::ACCIDENTAL: draw(item_cast<const Accidental*>(item), painter);
break;
default:
item->draw(painter);
}
}
void TDraw::draw(const Accidental* item, draw::Painter* painter)
{
TRACE_DRAW_ITEM;
if (item->layoutData().isSkipDraw) {
return;
}
painter->setPen(item->curColor());
for (const Accidental::LayoutData::Sym& e : item->layoutData().syms) {
item->drawSymbol(e.sym, painter, PointF(e.x, e.y));
}
}

View file

@ -0,0 +1,178 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2023 MuseScore BVBA and others
*
* 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/>.
*/
#ifndef MU_ENGRAVING_TDRAW_DEV_H
#define MU_ENGRAVING_TDRAW_DEV_H
#include "libmscore/engravingitem.h"
namespace mu::engraving {
class Accidental;
class ActionIcon;
class Ambitus;
class Arpeggio;
class Articulation;
class BagpipeEmbellishment;
class BarLine;
class Beam;
class Bend;
class Box;
class HBox;
class VBox;
class FBox;
class TBox;
class Bracket;
class Breath;
class Chord;
class ChordLine;
class Clef;
class Capo;
class DeadSlapped;
class Dynamic;
class Expression;
class Fermata;
class FiguredBassItem;
class FiguredBass;
class Fingering;
class FretDiagram;
class FretCircle;
class Glissando;
class GlissandoSegment;
class GraceNotesGroup;
class GradualTempoChangeSegment;
class GradualTempoChange;
class HairpinSegment;
class Hairpin;
class HarpPedalDiagram;
class HarmonicMarkSegment;
class Harmony;
class Hook;
class Image;
class InstrumentChange;
class InstrumentName;
class Jump;
class KeySig;
class LayoutBreak;
class LedgerLine;
class LetRing;
class LetRingSegment;
class LineSegment;
class Lyrics;
class LyricsLine;
class LyricsLineSegment;
class Marker;
class MeasureBase;
class MeasureNumber;
class MeasureNumberBase;
class MeasureRepeat;
class MMRest;
class MMRestRange;
class Note;
class NoteDot;
class Ornament;
class Ottava;
class OttavaSegment;
class PalmMute;
class PalmMuteSegment;
class Pedal;
class PedalSegment;
class PickScrapeSegment;
class PlayTechAnnotation;
class RasgueadoSegment;
class RehearsalMark;
class Rest;
class ShadowNote;
class SLine;
class Slur;
class Spacer;
class SpannerSegment;
class StaffLines;
class StaffState;
class StaffText;
class StaffTypeChange;
class Stem;
class StemSlash;
class Sticking;
class StretchedBend;
class BSymbol;
class Symbol;
class FSymbol;
class SystemDivider;
class SystemText;
class TabDurationSymbol;
class TempoText;
class TextBase;
class Text;
class TextLine;
class TextLineSegment;
class TextLineBase;
class TextLineBaseSegment;
class Tie;
class TimeSig;
class Tremolo;
class TremoloBar;
class TrillSegment;
class TripletFeel;
class Trill;
class Tuplet;
class VibratoSegment;
class Vibrato;
class Volta;
class VoltaSegment;
class WhammyBarSegment;
}
namespace mu::engraving::layout::dev {
class TDraw
{
public:
static void drawItem(const EngravingItem* item, draw::Painter* p); // factory
static void draw(const Accidental* item, draw::Painter* p);
};
}
#endif // MU_ENGRAVING_TDRAW_DEV_H

View file

@ -398,6 +398,7 @@ static void layoutAccidental(const Accidental* item, const LayoutContext& ctx, A
// TODO: remove Accidental in layout
// don't show accidentals for tab or slash notation
if (item->onTabStaff() || (item->note() && item->note()->fixed())) {
data.isSkipDraw = true;
return;
}

View file

@ -28,6 +28,10 @@
#include "types/fraction.h"
namespace mu::draw {
class Painter;
}
namespace mu::engraving {
class Score;
class EngravingItem;
@ -157,9 +161,17 @@ public:
// Layout Text 1
virtual void layoutText1(TextBase* item, bool base = false) = 0;
//! --- DRAW ---
void drawItem(const EngravingItem* item, draw::Painter* p)
{
doDrawItem(item, p);
}
private:
// Layout Single Item
virtual void doLayoutItem(EngravingItem* item) = 0;
virtual void doDrawItem(const EngravingItem* item, draw::Painter* p) = 0;
};
}

View file

@ -1,6 +1,8 @@
set(LAYOUT_STABLE_SRC
${CMAKE_CURRENT_LIST_DIR}/tdraw.cpp
${CMAKE_CURRENT_LIST_DIR}/tdraw.h
${CMAKE_CURRENT_LIST_DIR}/tlayout.cpp
${CMAKE_CURRENT_LIST_DIR}/tlayout.h
${CMAKE_CURRENT_LIST_DIR}/layout.cpp

View file

@ -27,6 +27,7 @@
#include "libmscore/harmony.h"
#include "libmscore/chord.h"
#include "tdraw.h"
#include "tlayout.h"
#include "chordlayout.h"
#include "layoutcontext.h"
@ -50,6 +51,11 @@ void Layout::doLayoutItem(EngravingItem* item)
TLayout::layoutItem(item, ctx);
}
void Layout::doDrawItem(const EngravingItem* item, draw::Painter* p)
{
TDraw::drawItem(item, p);
}
void Layout::layoutText1(TextBase* item, bool base)
{
LayoutContext ctx(item->score());

View file

@ -55,6 +55,8 @@ public:
private:
// Layout Single Item
void doLayoutItem(EngravingItem* item) override;
void doDrawItem(const EngravingItem* item, draw::Painter* p) override;
};
}

View file

@ -0,0 +1,56 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2023 MuseScore BVBA and others
*
* 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 "tdraw.h"
#include "libmscore/accidental.h"
#include "libmscore/note.h"
#include "infrastructure/rtti.h"
using namespace mu::engraving;
using namespace mu::engraving::rtti;
using namespace mu::engraving::layout::stable;
void TDraw::drawItem(const EngravingItem* item, draw::Painter* painter)
{
switch (item->type()) {
case ElementType::ACCIDENTAL: draw(item_cast<const Accidental*>(item), painter);
break;
default:
item->draw(painter);
}
}
void TDraw::draw(const Accidental* item, draw::Painter* painter)
{
TRACE_DRAW_ITEM;
// don't show accidentals for tab or slash notation
if (item->onTabStaff() || (item->note() && item->note()->fixed())) {
return;
}
painter->setPen(item->curColor());
for (const Accidental::LayoutData::Sym& e : item->layoutData().syms) {
item->drawSymbol(e.sym, painter, PointF(e.x, e.y));
}
}

View file

@ -0,0 +1,178 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2023 MuseScore BVBA and others
*
* 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/>.
*/
#ifndef MU_ENGRAVING_TDRAW_STABLE_H
#define MU_ENGRAVING_TDRAW_STABLE_H
#include "libmscore/engravingitem.h"
namespace mu::engraving {
class Accidental;
class ActionIcon;
class Ambitus;
class Arpeggio;
class Articulation;
class BagpipeEmbellishment;
class BarLine;
class Beam;
class Bend;
class Box;
class HBox;
class VBox;
class FBox;
class TBox;
class Bracket;
class Breath;
class Chord;
class ChordLine;
class Clef;
class Capo;
class DeadSlapped;
class Dynamic;
class Expression;
class Fermata;
class FiguredBassItem;
class FiguredBass;
class Fingering;
class FretDiagram;
class FretCircle;
class Glissando;
class GlissandoSegment;
class GraceNotesGroup;
class GradualTempoChangeSegment;
class GradualTempoChange;
class HairpinSegment;
class Hairpin;
class HarpPedalDiagram;
class HarmonicMarkSegment;
class Harmony;
class Hook;
class Image;
class InstrumentChange;
class InstrumentName;
class Jump;
class KeySig;
class LayoutBreak;
class LedgerLine;
class LetRing;
class LetRingSegment;
class LineSegment;
class Lyrics;
class LyricsLine;
class LyricsLineSegment;
class Marker;
class MeasureBase;
class MeasureNumber;
class MeasureNumberBase;
class MeasureRepeat;
class MMRest;
class MMRestRange;
class Note;
class NoteDot;
class Ornament;
class Ottava;
class OttavaSegment;
class PalmMute;
class PalmMuteSegment;
class Pedal;
class PedalSegment;
class PickScrapeSegment;
class PlayTechAnnotation;
class RasgueadoSegment;
class RehearsalMark;
class Rest;
class ShadowNote;
class SLine;
class Slur;
class Spacer;
class SpannerSegment;
class StaffLines;
class StaffState;
class StaffText;
class StaffTypeChange;
class Stem;
class StemSlash;
class Sticking;
class StretchedBend;
class BSymbol;
class Symbol;
class FSymbol;
class SystemDivider;
class SystemText;
class TabDurationSymbol;
class TempoText;
class TextBase;
class Text;
class TextLine;
class TextLineSegment;
class TextLineBase;
class TextLineBaseSegment;
class Tie;
class TimeSig;
class Tremolo;
class TremoloBar;
class TrillSegment;
class TripletFeel;
class Trill;
class Tuplet;
class VibratoSegment;
class Vibrato;
class Volta;
class VoltaSegment;
class WhammyBarSegment;
}
namespace mu::engraving::layout::stable {
class TDraw
{
public:
static void drawItem(const EngravingItem* item, draw::Painter* p); // factory
static void draw(const Accidental* item, draw::Painter* p);
};
}
#endif // MU_ENGRAVING_TDRAW_STABLE_H

View file

@ -371,22 +371,14 @@ AccidentalType Accidental::value2subtype(AccidentalVal v)
void Accidental::setLayoutData(const LayoutData& data)
{
m_layoutData = data;
setSkipDraw(data.isSkipDraw);
setbbox(data.bbox);
setPos(data.pos);
}
void Accidental::draw(mu::draw::Painter* painter) const
void Accidental::draw(mu::draw::Painter*) const
{
TRACE_ITEM_DRAW;
// don't show accidentals for tab or slash notation
if (onTabStaff() || (note() && note()->fixed())) {
return;
}
painter->setPen(curColor());
for (const LayoutData::Sym& e : m_layoutData.syms) {
score()->engravingFont()->draw(e.sym, painter, magS(), PointF(e.x, e.y));
}
UNREACHABLE;
}
//---------------------------------------------------------

View file

@ -123,6 +123,7 @@ public:
: sym(_sym), x(_x), y(_y) {}
};
bool isSkipDraw = false;
std::vector<Sym> syms;
RectF bbox;
PointF pos;

View file

@ -174,7 +174,7 @@ void Score::print(mu::draw::Painter* painter, int pageNo)
}
painter->save();
painter->translate(e->pagePos());
e->draw(painter);
EngravingItem::layout()->drawItem(e, painter);
painter->restore();
}
MScore::pdfPrinting = false;

View file

@ -293,17 +293,21 @@ public:
private:
Painter* m_painter = nullptr;
};
}
#ifdef MUE_ENABLE_DRAW_TRACE
#define TRACE_ITEM_DRAW \
mu::draw::PainterItemMarker __drawItemMarker(painter, typeName())
#define TRACE_DRAW_ITEM \
mu::draw::PainterItemMarker __drawItemMarker(painter, item->typeName())
#define TRACE_ITEM_DRAW_C(painter, itemName) \
mu::draw::PainterItemMarker __drawItemMarker(painter, itemName)
#else
#define TRACE_ITEM_DRAW
#define TRACE_DRAW_ITEM
#define TRACE_ITEM_DRAW_C(painter, objName)
#endif
}
#endif // MU_DRAW_PAINTER_H

View file

@ -147,7 +147,7 @@ mu::Ret SvgWriter::write(INotationPtr notation, QIODevice& destinationDevice, co
if (measure->isMeasure() && mu::engraving::toMeasure(measure)->visible(staffIndex)) {
mu::engraving::StaffLines* sl = mu::engraving::toMeasure(measure)->staffLines(static_cast<int>(staffIndex));
printer.setElement(sl);
engraving::Paint::paintElement(painter, sl);
engraving::Paint::paintItem(painter, sl);
}
}
} else { // Draw staff lines once per system
@ -164,7 +164,7 @@ mu::Ret SvgWriter::write(INotationPtr notation, QIODevice& destinationDevice, co
firstSL->setLines(lines);
printer.setElement(firstSL);
engraving::Paint::paintElement(painter, firstSL);
engraving::Paint::paintItem(painter, firstSL);
}
}
}
@ -224,7 +224,7 @@ mu::Ret SvgWriter::write(INotationPtr notation, QIODevice& destinationDevice, co
printer.setElement(element);
// Paint it
engraving::Paint::paintElement(painter, element);
engraving::Paint::paintItem(painter, element);
}
painter.endDraw(); // Writes MuseScore SVG file to disk, finally

View file

@ -45,6 +45,8 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/internal/paletteactionscontroller.h
${CMAKE_CURRENT_LIST_DIR}/internal/palettelayout.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/palettelayout.h
${CMAKE_CURRENT_LIST_DIR}/internal/palettedraw.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/palettedraw.h
${CMAKE_CURRENT_LIST_DIR}/internal/ipaletteprovider.h
${CMAKE_CURRENT_LIST_DIR}/internal/paletteprovider.cpp

View file

@ -32,6 +32,7 @@
#include "engraving/style/defaultstyle.h"
#include "palettelayout.h"
#include "palettedraw.h"
#include "log.h"
@ -189,35 +190,35 @@ void PaletteCellIconEngine::paintScoreElement(Painter& painter, EngravingItem* i
PaintContext ctx;
ctx.painter = &painter;
item->scanElements(&ctx, paintPaletteElement);
item->scanElements(&ctx, paintPaletteItem);
painter.restore();
}
void PaletteCellIconEngine::paintPaletteElement(void* context, EngravingItem* element)
void PaletteCellIconEngine::paintPaletteItem(void* context, EngravingItem* item)
{
PaintContext* ctx = static_cast<PaintContext*>(context);
Painter* painter = ctx->painter;
painter->save();
painter->translate(element->pos()); // necessary for drawing child elements
painter->translate(item->pos()); // necessary for drawing child elements
Color colorBackup = element->getProperty(Pid::COLOR).value<Color>();
Color frameColorBackup = element->getProperty(Pid::FRAME_FG_COLOR).value<Color>();
bool colorsInversionEnabledBackup = element->colorsInversionEnabled();
Color colorBackup = item->getProperty(Pid::COLOR).value<Color>();
Color frameColorBackup = item->getProperty(Pid::FRAME_FG_COLOR).value<Color>();
bool colorsInversionEnabledBackup = item->colorsInversionEnabled();
element->setColorsInverionEnabled(ctx->colorsInversionEnabled);
item->setColorsInverionEnabled(ctx->colorsInversionEnabled);
if (!ctx->useElementColors) {
Color color = configuration()->elementsColor();
element->setProperty(Pid::COLOR, color);
element->setProperty(Pid::FRAME_FG_COLOR, color);
item->setProperty(Pid::COLOR, color);
item->setProperty(Pid::FRAME_FG_COLOR, color);
}
element->draw(painter);
PaletteDraw::drawItem(item, painter);
element->setColorsInverionEnabled(colorsInversionEnabledBackup);
element->setProperty(Pid::COLOR, colorBackup);
element->setProperty(Pid::FRAME_FG_COLOR, frameColorBackup);
item->setColorsInverionEnabled(colorsInversionEnabledBackup);
item->setProperty(Pid::COLOR, colorBackup);
item->setProperty(Pid::FRAME_FG_COLOR, frameColorBackup);
painter->restore();
}

View file

@ -52,7 +52,7 @@ public:
bool colorsInversionEnabled = false;
};
static void paintPaletteElement(void* context, mu::engraving::EngravingItem* element);
static void paintPaletteItem(void* context, mu::engraving::EngravingItem* element);
private:
void paintCell(draw::Painter& painter, const RectF& rect, bool selected, bool current, qreal dpi) const;

View file

@ -0,0 +1,57 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore BVBA and others
*
* 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 "palettedraw.h"
#include "draw/painter.h"
#include "libmscore/accidental.h"
#include "libmscore/note.h"
#include "infrastructure/rtti.h"
using namespace mu::palette;
using namespace mu::engraving;
using namespace mu::engraving::rtti;
void PaletteDraw::drawItem(const EngravingItem* item, draw::Painter* painter)
{
switch (item->type()) {
case ElementType::ACCIDENTAL: draw(item_cast<const Accidental*>(item), painter);
break;
default:
item->draw(painter);
}
}
void PaletteDraw::draw(const Accidental* item, draw::Painter* painter)
{
// don't show accidentals for tab or slash notation
if (item->onTabStaff() || (item->note() && item->note()->fixed())) {
return;
}
painter->setPen(item->curColor());
for (const Accidental::LayoutData::Sym& e : item->layoutData().syms) {
item->drawSymbol(e.sym, painter, PointF(e.x, e.y));
}
}

View file

@ -0,0 +1,134 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore BVBA and others
*
* 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/>.
*/
#ifndef MU_PALETTE_PALETTEDRAW_H
#define MU_PALETTE_PALETTEDRAW_H
#include "libmscore/engravingitem.h"
namespace mu::engraving {
class MStyle;
class IEngravingFont;
class Score;
class Accidental;
class ActionIcon;
class Ambitus;
class Arpeggio;
class Articulation;
class BagpipeEmbellishment;
class BarLine;
class Bend;
class Bracket;
class Breath;
class Capo;
class Chord;
class ChordLine;
class Clef;
class Dynamic;
class Expression;
class Fermata;
class Fingering;
class FretDiagram;
class FSymbol;
class Glissando;
class GlissandoSegment;
class GradualTempoChange;
class GradualTempoChangeSegment;
class Hairpin;
class HairpinSegment;
class HarpPedalDiagram;
class InstrumentChange;
class Jump;
class KeySig;
class LayoutBreak;
class LetRing;
class LetRingSegment;
class SLine;
class LineSegment;
class Marker;
class MeasureNumber;
class MeasureRepeat;
class NoteHead;
class Ornament;
class Ottava;
class OttavaSegment;
class PalmMute;
class PalmMuteSegment;
class Pedal;
class PedalSegment;
class PlayTechAnnotation;
class RehearsalMark;
class Slur;
class Spacer;
class StaffText;
class StaffTypeChange;
class Symbol;
class SystemText;
class TempoText;
class Text;
class TextBase;
class TextLine;
class TextLineSegment;
class TextLineBaseSegment;
class TimeSig;
class Tremolo;
class TremoloBar;
class Trill;
class TrillSegment;
class Vibrato;
class VibratoSegment;
class Volta;
class VoltaSegment;
}
namespace mu::palette {
class PaletteDraw
{
public:
static void drawItem(const engraving::EngravingItem* item, draw::Painter* p); // factory
private:
static void draw(const engraving::Accidental* item, draw::Painter* p);
};
}
#endif // MU_PALETTE_PALETTEDRAW_H

View file

@ -635,7 +635,7 @@ QPixmap PaletteWidget::pixmapForCellAt(int paletteIdx) const
PaletteCellIconEngine::PaintContext ctx;
ctx.painter = &painter;
element->scanElements(&ctx, PaletteCellIconEngine::paintPaletteElement);
element->scanElements(&ctx, PaletteCellIconEngine::paintPaletteItem);
element->setPos(pos);
return pm;
@ -1112,7 +1112,7 @@ void PaletteWidget::paintEvent(QPaintEvent* /*event*/)
ctx.useElementColors = m_paintOptions.useElementColors;
ctx.colorsInversionEnabled = m_paintOptions.colorsInverionsEnabled;
el->scanElements(&ctx, PaletteCellIconEngine::paintPaletteElement);
el->scanElements(&ctx, PaletteCellIconEngine::paintPaletteItem);
painter.restore();
}
}