[engraving] moved layout Arpeggio
This commit is contained in:
parent
2b11fe197c
commit
6267e52033
4 changed files with 84 additions and 73 deletions
|
@ -31,6 +31,7 @@
|
|||
#include "../libmscore/accidental.h"
|
||||
#include "../libmscore/actionicon.h"
|
||||
#include "../libmscore/ambitus.h"
|
||||
#include "../libmscore/arpeggio.h"
|
||||
|
||||
#include "../libmscore/note.h"
|
||||
|
||||
|
@ -335,3 +336,70 @@ void TLayout::layout(Ambitus* item, LayoutContext&)
|
|||
.united(item->bottomAccidental()->bbox().translated(item->bottomAccidental()->ipos()))
|
||||
);
|
||||
}
|
||||
|
||||
void TLayout::layout(Arpeggio* item, LayoutContext&)
|
||||
{
|
||||
double top = item->calcTop();
|
||||
double bottom = item->calcBottom();
|
||||
if (item->score()->styleB(Sid::ArpeggioHiddenInStdIfTab)) {
|
||||
if (item->staff() && item->staff()->isPitchedStaff(item->tick())) {
|
||||
for (Staff* s : item->staff()->staffList()) {
|
||||
if (s->score() == item->score() && s->isTabStaff(item->tick()) && s->visible()) {
|
||||
item->setbbox(RectF());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (item->staff()) {
|
||||
item->setMag(item->staff()->staffMag(item->tick()));
|
||||
}
|
||||
switch (item->arpeggioType()) {
|
||||
case ArpeggioType::NORMAL: {
|
||||
item->symbolLine(SymId::wiggleArpeggiatoUp, SymId::wiggleArpeggiatoUp);
|
||||
// string is rotated -90 degrees
|
||||
RectF r(item->symBbox(item->symbols()));
|
||||
item->setbbox(RectF(0.0, -r.x() + top, r.height(), r.width()));
|
||||
}
|
||||
break;
|
||||
|
||||
case ArpeggioType::UP: {
|
||||
item->symbolLine(SymId::wiggleArpeggiatoUpArrow, SymId::wiggleArpeggiatoUp);
|
||||
// string is rotated -90 degrees
|
||||
RectF r(item->symBbox(item->symbols()));
|
||||
item->setbbox(RectF(0.0, -r.x() + top, r.height(), r.width()));
|
||||
}
|
||||
break;
|
||||
|
||||
case ArpeggioType::DOWN: {
|
||||
item->symbolLine(SymId::wiggleArpeggiatoUpArrow, SymId::wiggleArpeggiatoUp);
|
||||
// string is rotated +90 degrees (so that UpArrow turns into a DownArrow)
|
||||
RectF r(item->symBbox(item->symbols()));
|
||||
item->setbbox(RectF(0.0, r.x() + top, r.height(), r.width()));
|
||||
}
|
||||
break;
|
||||
|
||||
case ArpeggioType::UP_STRAIGHT: {
|
||||
double _spatium = item->spatium();
|
||||
double x1 = _spatium * .5;
|
||||
double w = item->symBbox(SymId::arrowheadBlackUp).width();
|
||||
item->setbbox(RectF(x1 - w * .5, top, w, bottom));
|
||||
}
|
||||
break;
|
||||
|
||||
case ArpeggioType::DOWN_STRAIGHT: {
|
||||
double _spatium = item->spatium();
|
||||
double x1 = _spatium * .5;
|
||||
double w = item->symBbox(SymId::arrowheadBlackDown).width();
|
||||
item->setbbox(RectF(x1 - w * .5, top, w, bottom));
|
||||
}
|
||||
break;
|
||||
|
||||
case ArpeggioType::BRACKET: {
|
||||
double _spatium = item->spatium();
|
||||
double w = item->score()->styleS(Sid::ArpeggioHookLen).val() * _spatium;
|
||||
item->setbbox(RectF(0.0, top, w, bottom));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace mu::engraving {
|
|||
class Accidental;
|
||||
class ActionIcon;
|
||||
class Ambitus;
|
||||
class Arpeggio;
|
||||
|
||||
class TLayout
|
||||
{
|
||||
|
@ -36,6 +37,7 @@ public:
|
|||
static void layout(Accidental* item, LayoutContext& ctx);
|
||||
static void layout(ActionIcon* item, LayoutContext& ctx);
|
||||
static void layout(Ambitus* item, LayoutContext& ctx);
|
||||
static void layout(Arpeggio* item, LayoutContext& ctx);
|
||||
|
||||
private:
|
||||
static void layoutSingleGlyphAccidental(Accidental* item, LayoutContext& ctx);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "iengravingfont.h"
|
||||
|
||||
#include "types/typesconv.h"
|
||||
#include "layout/tlayout.h"
|
||||
|
||||
#include "accidental.h"
|
||||
#include "chord.h"
|
||||
|
@ -88,14 +89,14 @@ void Arpeggio::symbolLine(SymId end, SymId fill)
|
|||
double mag = magS();
|
||||
IEngravingFontPtr f = score()->engravingFont();
|
||||
|
||||
symbols.clear();
|
||||
m_symbols.clear();
|
||||
double w1 = f->advance(end, mag);
|
||||
double w2 = f->advance(fill, mag);
|
||||
int n = lrint((w - w1) / w2);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
symbols.push_back(fill);
|
||||
m_symbols.push_back(fill);
|
||||
}
|
||||
symbols.push_back(end);
|
||||
m_symbols.push_back(end);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -194,69 +195,8 @@ double Arpeggio::calcBottom() const
|
|||
|
||||
void Arpeggio::layout()
|
||||
{
|
||||
double top = calcTop();
|
||||
double bottom = calcBottom();
|
||||
if (score()->styleB(Sid::ArpeggioHiddenInStdIfTab)) {
|
||||
if (staff() && staff()->isPitchedStaff(tick())) {
|
||||
for (Staff* s : staff()->staffList()) {
|
||||
if (s->score() == score() && s->isTabStaff(tick()) && s->visible()) {
|
||||
setbbox(RectF());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (staff()) {
|
||||
setMag(staff()->staffMag(tick()));
|
||||
}
|
||||
switch (arpeggioType()) {
|
||||
case ArpeggioType::NORMAL: {
|
||||
symbolLine(SymId::wiggleArpeggiatoUp, SymId::wiggleArpeggiatoUp);
|
||||
// string is rotated -90 degrees
|
||||
RectF r(symBbox(symbols));
|
||||
setbbox(RectF(0.0, -r.x() + top, r.height(), r.width()));
|
||||
}
|
||||
break;
|
||||
|
||||
case ArpeggioType::UP: {
|
||||
symbolLine(SymId::wiggleArpeggiatoUpArrow, SymId::wiggleArpeggiatoUp);
|
||||
// string is rotated -90 degrees
|
||||
RectF r(symBbox(symbols));
|
||||
setbbox(RectF(0.0, -r.x() + top, r.height(), r.width()));
|
||||
}
|
||||
break;
|
||||
|
||||
case ArpeggioType::DOWN: {
|
||||
symbolLine(SymId::wiggleArpeggiatoUpArrow, SymId::wiggleArpeggiatoUp);
|
||||
// string is rotated +90 degrees (so that UpArrow turns into a DownArrow)
|
||||
RectF r(symBbox(symbols));
|
||||
setbbox(RectF(0.0, r.x() + top, r.height(), r.width()));
|
||||
}
|
||||
break;
|
||||
|
||||
case ArpeggioType::UP_STRAIGHT: {
|
||||
double _spatium = spatium();
|
||||
double x1 = _spatium * .5;
|
||||
double w = symBbox(SymId::arrowheadBlackUp).width();
|
||||
setbbox(RectF(x1 - w * .5, top, w, bottom));
|
||||
}
|
||||
break;
|
||||
|
||||
case ArpeggioType::DOWN_STRAIGHT: {
|
||||
double _spatium = spatium();
|
||||
double x1 = _spatium * .5;
|
||||
double w = symBbox(SymId::arrowheadBlackDown).width();
|
||||
setbbox(RectF(x1 - w * .5, top, w, bottom));
|
||||
}
|
||||
break;
|
||||
|
||||
case ArpeggioType::BRACKET: {
|
||||
double _spatium = spatium();
|
||||
double w = score()->styleS(Sid::ArpeggioHookLen).val() * _spatium;
|
||||
setbbox(RectF(0.0, top, w, bottom));
|
||||
break;
|
||||
}
|
||||
}
|
||||
LayoutContext ctx(score());
|
||||
TLayout::layout(this, ctx);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -282,17 +222,17 @@ void Arpeggio::draw(mu::draw::Painter* painter) const
|
|||
case ArpeggioType::NORMAL:
|
||||
case ArpeggioType::UP:
|
||||
{
|
||||
RectF r(symBbox(symbols));
|
||||
RectF r(symBbox(m_symbols));
|
||||
painter->rotate(-90.0);
|
||||
score()->engravingFont()->draw(symbols, painter, magS(), PointF(-r.right() - y1, -r.bottom() + r.height()));
|
||||
score()->engravingFont()->draw(m_symbols, painter, magS(), PointF(-r.right() - y1, -r.bottom() + r.height()));
|
||||
}
|
||||
break;
|
||||
|
||||
case ArpeggioType::DOWN:
|
||||
{
|
||||
RectF r(symBbox(symbols));
|
||||
RectF r(symBbox(m_symbols));
|
||||
painter->rotate(90.0);
|
||||
score()->engravingFont()->draw(symbols, painter, magS(), PointF(-r.left() + y1, -r.top() - r.height()));
|
||||
score()->engravingFont()->draw(m_symbols, painter, magS(), PointF(-r.left() + y1, -r.top() - r.height()));
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class Arpeggio final : public EngravingItem
|
|||
double _userLen2;
|
||||
double _height;
|
||||
int _span; // spanning staves
|
||||
SymIdList symbols;
|
||||
SymIdList m_symbols;
|
||||
bool _playArpeggio;
|
||||
|
||||
double _stretch;
|
||||
|
@ -51,8 +51,6 @@ class Arpeggio final : public EngravingItem
|
|||
friend class Factory;
|
||||
Arpeggio(Chord* parent);
|
||||
|
||||
void symbolLine(SymId start, SymId fill);
|
||||
|
||||
void spatiumChanged(double /*oldValue*/, double /*newValue*/) override;
|
||||
std::vector<mu::LineF> dragAnchorLines() const override;
|
||||
std::vector<mu::LineF> gripAnchorLines(Grip) const override;
|
||||
|
@ -106,6 +104,9 @@ public:
|
|||
double Stretch() const { return _stretch; }
|
||||
void setStretch(double val) { _stretch = val; }
|
||||
|
||||
void symbolLine(SymId start, SymId fill);
|
||||
const SymIdList& symbols() { return m_symbols; }
|
||||
|
||||
PropertyValue getProperty(Pid propertyId) const override;
|
||||
bool setProperty(Pid propertyId, const PropertyValue&) override;
|
||||
PropertyValue propertyDefault(Pid propertyId) const override;
|
||||
|
|
Loading…
Reference in a new issue