diff --git a/src/engraving/dom/box.cpp b/src/engraving/dom/box.cpp index 6b7d5c8e477a7..a53a6063441a6 100644 --- a/src/engraving/dom/box.cpp +++ b/src/engraving/dom/box.cpp @@ -62,6 +62,24 @@ static const String FRET_BOX_DIAGRAMS_SEPARATOR = u","; Box::Box(const ElementType& type, System* parent) : MeasureBase(type, parent) { + m_iconFont = Font(configuration()->iconsFontFamily(), Font::Type::Icon); + m_iconFont.setPointSizeF(UI_ICONS_DEFAULT_FONT_SIZE); + switch (type) { + case ElementType::FBOX: + m_iconCode = 0xF491; + break; + case ElementType::HBOX: + m_iconCode = 0xEF6D; + break; + case ElementType::TBOX: + m_iconCode = 0xEF6E; + break; + case ElementType::VBOX: + m_iconCode = 0xEF6C; + break; + default: + break; + } } //--------------------------------------------------------- diff --git a/src/engraving/dom/box.h b/src/engraving/dom/box.h index bc4182b3e449c..9ee67770f57bd 100644 --- a/src/engraving/dom/box.h +++ b/src/engraving/dom/box.h @@ -25,6 +25,8 @@ #include "measurebase.h" #include "property.h" +#include "draw/types/font.h" + namespace mu::engraving { //--------------------------------------------------------- // Box @@ -88,6 +90,10 @@ class Box : public MeasureBase bool canBeExcludedFromOtherParts() const override { return true; } void manageExclusionFromParts(bool exclude) override; + // For use in palettes + char16_t iconCode() const { return m_iconCode; } + const muse::draw::Font& iconFont() const { return m_iconFont; } + private: Spatium m_boxWidth; // only valid for HBox Spatium m_boxHeight; // only valid for VBox @@ -100,6 +106,9 @@ class Box : public MeasureBase double m_topMargin = 0.0; double m_bottomMargin = 0.0; bool m_isAutoSizeEnabled = true; + + char16_t m_iconCode = 0; + muse::draw::Font m_iconFont; }; //--------------------------------------------------------- diff --git a/src/engraving/rendering/single/singledraw.cpp b/src/engraving/rendering/single/singledraw.cpp index ca6c091219c25..8241455f70ffa 100644 --- a/src/engraving/rendering/single/singledraw.cpp +++ b/src/engraving/rendering/single/singledraw.cpp @@ -38,6 +38,7 @@ #include "dom/barline.h" #include "dom/beam.h" #include "dom/bend.h" +#include "dom/box.h" #include "dom/bracket.h" #include "dom/breath.h" @@ -191,6 +192,8 @@ void SingleDraw::drawItem(const EngravingItem* item, Painter* painter, const Pai case ElementType::EXPRESSION: draw(item_cast(item), painter, opt); break; + case ElementType::FBOX: draw(item_cast(item), painter, opt); + break; case ElementType::FERMATA: draw(item_cast(item), painter, opt); break; case ElementType::FIGURED_BASS: draw(item_cast(item), painter, opt); @@ -223,6 +226,8 @@ void SingleDraw::drawItem(const EngravingItem* item, Painter* painter, const Pai break; case ElementType::HARMONY: draw(item_cast(item), painter, opt); break; + case ElementType::HBOX: draw(item_cast(item), painter, opt); + break; case ElementType::HOOK: draw(item_cast(item), painter, opt); break; @@ -318,6 +323,8 @@ void SingleDraw::drawItem(const EngravingItem* item, Painter* painter, const Pai case ElementType::TAPPING: draw(item_cast(item), painter, opt); break; + case ElementType::TBOX: draw(item_cast(item), painter, opt); + break; case ElementType::TEMPO_TEXT: draw(item_cast(item), painter, opt); break; case ElementType::TEXT: draw(item_cast(item), painter, opt); @@ -341,6 +348,8 @@ void SingleDraw::drawItem(const EngravingItem* item, Painter* painter, const Pai case ElementType::TUPLET: draw(item_cast(item), painter, opt); break; + case ElementType::VBOX: draw(item_cast(item), painter, opt); + break; case ElementType::VIBRATO_SEGMENT: draw(item_cast(item), painter, opt); break; case ElementType::VOLTA_SEGMENT: draw(item_cast(item), painter, opt); @@ -952,6 +961,14 @@ void SingleDraw::draw(const Bend* item, Painter* painter, const PaintOptions& op } } +void SingleDraw::draw(const Box* item, Painter* painter, const PaintOptions&) +{ + TRACE_DRAW_ITEM; + const Box::LayoutData* ldata = item->ldata(); + painter->setFont(item->iconFont()); + painter->drawText(ldata->bbox(), muse::draw::AlignCenter, Char(item->iconCode())); +} + void SingleDraw::draw(const Bracket* item, Painter* painter, const PaintOptions& opt) { TRACE_DRAW_ITEM; diff --git a/src/engraving/rendering/single/singledraw.h b/src/engraving/rendering/single/singledraw.h index 9325c80c6f0e9..ecff7a4864f78 100644 --- a/src/engraving/rendering/single/singledraw.h +++ b/src/engraving/rendering/single/singledraw.h @@ -43,6 +43,7 @@ class BagpipeEmbellishment; class BarLine; class Beam; class Bend; +class Box; class Bracket; class Breath; @@ -183,6 +184,7 @@ class SingleDraw static void draw(const BarLine* item, muse::draw::Painter* painter, const PaintOptions& opt); static void draw(const Beam* item, muse::draw::Painter* painter, const PaintOptions& opt); static void draw(const Bend* item, muse::draw::Painter* painter, const PaintOptions& opt); + static void draw(const Box* item, muse::draw::Painter* painter, const PaintOptions& opt); static void draw(const Bracket* item, muse::draw::Painter* painter, const PaintOptions& opt); static void draw(const Breath* item, muse::draw::Painter* painter, const PaintOptions& opt); diff --git a/src/engraving/rendering/single/singlelayout.cpp b/src/engraving/rendering/single/singlelayout.cpp index 3a2ff57fd75b2..0a2e7f05c987f 100644 --- a/src/engraving/rendering/single/singlelayout.cpp +++ b/src/engraving/rendering/single/singlelayout.cpp @@ -38,6 +38,7 @@ #include "dom/actionicon.h" #include "dom/ambitus.h" #include "dom/articulation.h" +#include "dom/box.h" #include "dom/bagpembell.h" #include "dom/barline.h" #include "dom/bend.h" @@ -148,6 +149,8 @@ void SingleLayout::layoutItem(EngravingItem* item) break; case ElementType::EXPRESSION: layout(toExpression(item), ctx); break; + case ElementType::FBOX: layout(toBox(item), ctx); + break; case ElementType::FERMATA: layout(toFermata(item), ctx); break; case ElementType::FINGERING: layout(toFingering(item), ctx); @@ -168,6 +171,8 @@ void SingleLayout::layoutItem(EngravingItem* item) break; case ElementType::HARP_DIAGRAM: layout(toHarpPedalDiagram(item), ctx); break; + case ElementType::HBOX: layout(toBox(item), ctx); + break; case ElementType::IMAGE: layout(toImage(item), ctx); break; case ElementType::INSTRUMENT_CHANGE: layout(toInstrumentChange(item), ctx); @@ -226,6 +231,8 @@ void SingleLayout::layoutItem(EngravingItem* item) break; case ElementType::TAPPING: layout(toTapping(item), ctx); break; + case ElementType::TBOX: layout(toBox(item), ctx); + break; case ElementType::TEMPO_TEXT: layout(toTempoText(item), ctx); break; case ElementType::TEXT: layout(toText(item), ctx); @@ -242,6 +249,8 @@ void SingleLayout::layoutItem(EngravingItem* item) break; case ElementType::TRILL: layout(toTrill(item), ctx); break; + case ElementType::VBOX: layout(toBox(item), ctx); + break; case ElementType::VIBRATO: layout(toVibrato(item), ctx); break; case ElementType::VOLTA: layout(toVolta(item), ctx); @@ -718,6 +727,12 @@ void SingleLayout::layout(Bend* item, const Context&) ldata->setPos(0.0, 0.0); } +void SingleLayout::layout(Box* item, const Context&) +{ + FontMetrics fontMetrics(item->iconFont()); + item->setbbox(fontMetrics.boundingRect(Char(item->iconCode()))); +} + void SingleLayout::layout(Bracket* item, const Context& ctx) { Bracket::LayoutData* ldata = item->mutldata(); diff --git a/src/engraving/rendering/single/singlelayout.h b/src/engraving/rendering/single/singlelayout.h index a687f60e815d3..0c43b959966fe 100644 --- a/src/engraving/rendering/single/singlelayout.h +++ b/src/engraving/rendering/single/singlelayout.h @@ -41,6 +41,7 @@ class Articulation; class BagpipeEmbellishment; class BarLine; class Bend; +class Box; class Bracket; class Breath; @@ -165,6 +166,7 @@ class SingleLayout static void layout(BagpipeEmbellishment* item, const Context& ctx); static void layout(BarLine* item, const Context& ctx); static void layout(Bend* item, const Context& ctx); + static void layout(Box* item, const Context& ctx); // Boxes share layout method static void layout(Bracket* item, const Context& ctx); static void layout(Breath* item, const Context&); diff --git a/src/notation/internal/notationinteraction.cpp b/src/notation/internal/notationinteraction.cpp index 94db1c37a3897..75399ba62dd26 100644 --- a/src/notation/internal/notationinteraction.cpp +++ b/src/notation/internal/notationinteraction.cpp @@ -1396,10 +1396,6 @@ bool NotationInteraction::isOutgoingDragElementAllowed(const EngravingItem* elem switch (element->type()) { case ElementType::MEASURE: case ElementType::NOTE: - case ElementType::VBOX: - case ElementType::HBOX: - case ElementType::TBOX: - case ElementType::FBOX: // TODO: Bends & NoteLines can't be copy-dragged until corresponding SingleLayout::layout and SingleDraw::draw methods have been implemented case ElementType::GUITAR_BEND: case ElementType::GUITAR_BEND_SEGMENT: diff --git a/src/palette/internal/palettecell.cpp b/src/palette/internal/palettecell.cpp index e5a1806c22485..8f91a2bbdbbc7 100644 --- a/src/palette/internal/palettecell.cpp +++ b/src/palette/internal/palettecell.cpp @@ -25,6 +25,7 @@ #include "mimedatautils.h" #include "engraving/dom/actionicon.h" +#include "engraving/dom/box.h" #include "engraving/dom/engravingitem.h" #include "engraving/dom/factory.h" #include "engraving/dom/fret.h" @@ -341,7 +342,24 @@ PaletteCellPtr PaletteCell::fromElementMimeData(const QByteArray& data) } } - const String name = (element->isFretDiagram()) ? toFretDiagram(element.get())->harmonyPlainText() : element->translatedTypeUserName(); + String name = (element->isFretDiagram()) ? toFretDiagram(element.get())->harmonyPlainText() : element->translatedTypeUserName(); + if (element->isBox()) { + Text* t = nullptr; + if (element->isTBox()) { + t = toTBox(element.get())->text(); + } else { + for (EngravingItem* e : toBox(element.get())->el()) { + if (e->isText()) { + t = toText(e); + break; + } + } + } + String text = t ? t->plainText().simplified() : String(); + if (!text.empty()) { + name = String("%1: %2").arg(name, text); + } + } return std::make_shared(element, name); }