Skip to content

Commit

Permalink
fix #18193
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Sep 24, 2012
1 parent a97e17e commit 9e62388
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 36 deletions.
11 changes: 8 additions & 3 deletions libmscore/box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ void Box::read(const QDomElement& de)
add(image);
}
}
else if (tag == "FretDiagram") {
FretDiagram* f = new FretDiagram(score());
f->read(e);
add(f);
}
else if (tag == "LayoutBreak") {
LayoutBreak* lb = new LayoutBreak(score());
lb->read(e);
Expand Down Expand Up @@ -610,7 +615,7 @@ void VBox::setGrip(int, const QPointF& pt)

void FBox::layout()
{
setPos(QPointF()); // !?
// setPos(QPointF()); // !?
setbbox(QRectF(0.0, 0.0, system()->width(), point(boxHeight())));
Box::layout();
}
Expand All @@ -624,8 +629,8 @@ void FBox::add(Element* e)
{
e->setParent(this);
if (e->type() == FRET_DIAGRAM) {
FretDiagram* fd = static_cast<FretDiagram*>(e);
fd->setFlag(ELEMENT_MOVABLE, false);
// FretDiagram* fd = static_cast<FretDiagram*>(e);
// fd->setFlag(ELEMENT_MOVABLE, false);
}
else {
qDebug("FBox::add: element not allowed\n");
Expand Down
1 change: 1 addition & 0 deletions libmscore/element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ QRectF Element::drag(const EditData& data)
int n = lrint(y / vRaster);
y = vRaster * n;
}
printf("drag %s\n", name());

This comment has been minimized.

Copy link
@Jojo-Schmitz

Jojo-Schmitz Sep 24, 2012

Contributor

This is debug output, isn't it?

This comment has been minimized.

Copy link
@wschweer

wschweer Sep 24, 2012

Author Contributor

yes

setUserOff(QPointF(x, y));
return canvasBoundingRect() | r;
}
Expand Down
63 changes: 36 additions & 27 deletions libmscore/fret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static const int DEFAULT_FRETS = 5;
FretDiagram::FretDiagram(Score* score)
: Element(score)
{
setFlags(ELEMENT_MOVABLE | ELEMENT_SELECTABLE);
setFlag(ELEMENT_MOVABLE, true);
_strings = DEFAULT_STRINGS;
_frets = DEFAULT_FRETS;
_maxFrets = 24;
Expand Down Expand Up @@ -96,11 +96,16 @@ QPointF FretDiagram::pagePos() const
{
if (parent() == 0)
return pos();
System* system = measure()->system();
qreal yp = y();
if (system)
yp += system->staffY(staffIdx());
return QPointF(pageX(), yp);
if (parent()->type() == SEGMENT) {
Measure* m = static_cast<Segment*>(parent())->measure();
System* system = m->system();
qreal yp = y();
if (system)
yp += system->staffY(staffIdx());
return QPointF(pageX(), yp);
}
else
return Element::pagePos();
}

//---------------------------------------------------------
Expand All @@ -109,29 +114,33 @@ QPointF FretDiagram::pagePos() const

QLineF FretDiagram::dragAnchor() const
{
Measure* m = measure();
System* system = m->system();
qreal yp = system->staff(staffIdx())->y() + system->y();
qreal xp = m->tick2pos(segment()->tick()) + m->pagePos().x();
QPointF p1(xp, yp);

qreal x = 0.0;
qreal y = 0.0;
if (parent()->type() == SEGMENT) {
Segment* s = static_cast<Segment*>(parent());
Measure* m = s->measure();
System* system = m->system();
qreal yp = system->staff(staffIdx())->y() + system->y();
qreal xp = m->tick2pos(s->tick()) + m->pagePos().x();
QPointF p1(xp, yp);

qreal x = 0.0;
qreal y = 0.0;
#if 0 // TODOxx
qreal tw = width();
qreal th = height();
if (_align & ALIGN_BOTTOM)
y = th;
else if (_align & ALIGN_VCENTER)
y = (th * .5);
else if (_align & ALIGN_BASELINE)
y = baseLine();
if (_align & ALIGN_RIGHT)
x = tw;
else if (_align & ALIGN_HCENTER)
x = (tw * .5);
qreal tw = width();
qreal th = height();
if (_align & ALIGN_BOTTOM)
y = th;
else if (_align & ALIGN_VCENTER)
y = (th * .5);
else if (_align & ALIGN_BASELINE)
y = baseLine();
if (_align & ALIGN_RIGHT)
x = tw;
else if (_align & ALIGN_HCENTER)
x = (tw * .5);
#endif
return QLineF(p1, abbox().topLeft() + QPointF(x, y));
return QLineF(p1, abbox().topLeft() + QPointF(x, y));
}
return QLineF(parent()->pagePos(), abbox().topLeft());
}

//---------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions libmscore/fret.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class FretDiagram : public Element {
~FretDiagram();
virtual void draw(QPainter*) const;
virtual FretDiagram* clone() const { return new FretDiagram(*this); }
Segment* segment() const { return (Segment*)parent(); }
Measure* measure() const { return (Measure*)parent()->parent(); }
// Segment* segment() const { return (Segment*)parent(); }
// Measure* measure() const { return (Measure*)parent()->parent(); }

virtual ElementType type() const { return FRET_DIAGRAM; }
virtual void layout();
Expand Down
4 changes: 1 addition & 3 deletions libmscore/trill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,8 @@ void Trill::add(Element* e)

void Trill::remove(Element* e)
{
if (!_el.remove(e)) {
printf("Trill remove %s\n", e->name());
if (!_el.remove(e))
Spanner::remove(e);
}
}

//---------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion mscore/dragelement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ void ScoreView::endDrag()
if (dragElement->type() == Element::MEASURE) {
qreal userDist = dragStaff->userDist();
dragStaff->setUserDist(staffUserDist);
printf("endDrag measure: %f -> %f\n", dragStaff->userDist(), userDist);
score()->undo(new ChangeStaffUserDist(dragStaff, userDist));
}
else {
Expand Down

0 comments on commit 9e62388

Please sign in to comment.