Skip to content

Commit

Permalink
[palette] added layout for Slur
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkorsukov committed Jul 10, 2023
1 parent 63e57ab commit e433234
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/engraving/layout/pal/tlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1703,10 +1703,10 @@ void TLayout::layoutLine(SLine* item, LayoutContext& ctx)
item->setbbox(lineSegm->bbox());
}

void TLayout::layout(Slur* item, LayoutContext& ctx)
void TLayout::layout(Slur*, LayoutContext&)
{
v0::LayoutContext ctxv0(ctx.score());
v0::SlurTieLayout::layout(item, ctxv0);
//! NOTE Moved to PaletteLayout
UNREACHABLE;
}

void TLayout::layout(Spacer*, LayoutContext&)
Expand Down
28 changes: 28 additions & 0 deletions src/palette/internal/palettelayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#include "engraving/libmscore/pedal.h"
#include "engraving/libmscore/playtechannotation.h"
#include "engraving/libmscore/rehearsalmark.h"
#include "engraving/libmscore/slur.h"
#include "engraving/libmscore/stafftext.h"
#include "engraving/libmscore/symbol.h"
#include "engraving/libmscore/systemtext.h"
Expand Down Expand Up @@ -173,6 +174,8 @@ void PaletteLayout::layoutItem(EngravingItem* item)
break;
case ElementType::REHEARSAL_MARK: layout(toRehearsalMark(item), ctx);
break;
case ElementType::SLUR: layout(toSlur(item), ctx);
break;
case ElementType::SPACER: layout(toSpacer(item), ctx);
break;
case ElementType::STAFF_TEXT: layout(toStaffText(item), ctx);
Expand Down Expand Up @@ -1208,6 +1211,31 @@ void PaletteLayout::layout(RehearsalMark* item, const Context& ctx)
layoutTextBase(item, ctx);
}

void PaletteLayout::layout(Slur* item, const Context& ctx)
{
double spatium = item->spatium();
SlurSegment* s = nullptr;
if (item->spannerSegments().empty()) {
s = new SlurSegment(ctx.dummyParent()->system());
s->setTrack(item->track());
item->add(s);
} else {
s = item->frontSegment();
}

s->setSpannerSegmentType(SpannerSegmentType::SINGLE);

s->setPos(PointF());
s->ups(Grip::START).p = PointF(0, 0);
s->ups(Grip::END).p = PointF(spatium * 6, 0);
s->setExtraHeight(0.0);

s->computeBezier();
s->setbbox(s->path().boundingRect());

item->setbbox(s->bbox());
}

void PaletteLayout::layout(Spacer* item, const Context&)
{
UNUSED(item);
Expand Down
2 changes: 2 additions & 0 deletions src/palette/internal/palettelayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class PlayTechAnnotation;

class RehearsalMark;

class Slur;
class Spacer;
class StaffText;
class Symbol;
Expand Down Expand Up @@ -197,6 +198,7 @@ class PaletteLayout

static void layout(engraving::RehearsalMark* item, const Context& ctx);

static void layout(engraving::Slur* item, const Context& ctx);
static void layout(engraving::Spacer* item, const Context&);
static void layout(engraving::StaffText* item, const Context& ctx);
static void layout(engraving::Symbol* item, const Context& ctx);
Expand Down

0 comments on commit e433234

Please sign in to comment.