fixes for line edit mode

This commit is contained in:
ws 2013-08-11 11:46:04 +02:00
parent feff123ba1
commit 8fd9d2c479
5 changed files with 43 additions and 20 deletions

View file

@ -206,6 +206,8 @@ QPointF LineSegment::gripAnchor(int grip) const
bool LineSegment::edit(MuseScoreView* sv, int curGrip, int key, Qt::KeyboardModifiers modifiers, const QString&)
{
printf("LineSegment::edit\n");
if (!((modifiers & Qt::ShiftModifier)
&& ((spannerSegmentType() == SEGMENT_SINGLE)
|| (spannerSegmentType() == SEGMENT_BEGIN && curGrip == GRIP_LINE_START)
@ -221,23 +223,35 @@ bool LineSegment::edit(MuseScoreView* sv, int curGrip, int key, Qt::KeyboardModi
if (l->anchor() == Spanner::ANCHOR_SEGMENT) {
Segment* s1 = score()->tick2nearestSegment(spanner()->tick());
Segment* s2 = score()->tick2nearestSegment(spanner()->tick2());
if (!s1 || !s2)
if (!s1) {
qDebug("LineSegment::edit: no start segment");
return true;
}
if (key == Qt::Key_Left) {
if (curGrip == GRIP_LINE_START)
s1 = prevSeg1(s1, track);
else if (curGrip == GRIP_LINE_END || curGrip == GRIP_LINE_MIDDLE)
s2 = prevSeg1(s2, track);
else if (curGrip == GRIP_LINE_END || curGrip == GRIP_LINE_MIDDLE) {
if (s2)
s2 = prevSeg1(s2, track);
else {
Measure* m = score()->lastMeasure();
s2 = m->last();
if (s2->segmentType() != Segment::SegChordRest)
s2 = s2->prev(Segment::SegChordRest);
}
}
}
else if (key == Qt::Key_Right) {
if (curGrip == GRIP_LINE_START)
s1 = nextSeg1(s1, track);
else if (curGrip == GRIP_LINE_END || curGrip == GRIP_LINE_MIDDLE) {
if ((s2->system()->firstMeasure() == s2->measure())
&& (s2->tick() == s2->measure()->tick()))
bspDirty = true;
s2 = nextSeg1(s2, track);
if (s2) {
if ((s2->system()->firstMeasure() == s2->measure())
&& (s2->tick() == s2->measure()->tick()))
bspDirty = true;
s2 = nextSeg1(s2, track);
}
}
}
if (s1 == 0 || s2 == 0 || s1->tick() >= s2->tick())
@ -454,7 +468,7 @@ QPointF SLine::linePos(int grip, System** sys)
{
qreal _spatium = spatium();
qreal x = 0.0;
switch(anchor()) {
switch (anchor()) {
case Spanner::ANCHOR_SEGMENT:
{
if (grip == GRIP_LINE_START) {

View file

@ -56,7 +56,6 @@ void OttavaSegment::layout()
qreal yo(score()->styleS(ST_ottavaY).val() * spatium());
if (ottava()->placement() == BELOW)
yo = -yo + staff()->height();
// rypos() += yo;
rypos() = yo;
}
adjustReadPos();

View file

@ -1454,7 +1454,7 @@ void SpannerView::setElement(Element* e)
Spanner* spanner = static_cast<Spanner*>(e);
ShowElementBase::setElement(e);
sp.tick->setValue(spanner->tick());
sp.tickLen->setValue(spanner->tickLen());
sp.tick2->setValue(spanner->tick2());
sp.anchor->setCurrentIndex(int(spanner->anchor()));
sp.segments->clear();

View file

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>436</width>
<width>489</width>
<height>214</height>
</rect>
</property>
@ -17,7 +17,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>8</number>
</property>
<property name="topMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>8</number>
</property>
<item>
@ -70,7 +79,7 @@
<item row="0" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>tickLen:</string>
<string>tick2:</string>
</property>
</widget>
</item>
@ -116,7 +125,7 @@
</widget>
</item>
<item row="0" column="3">
<widget class="QSpinBox" name="tickLen">
<widget class="QSpinBox" name="tick2">
<property name="maximum">
<number>999999</number>
</property>

View file

@ -1532,21 +1532,22 @@ void ScoreView::paintEvent(QPaintEvent* ev)
}
if (grips) {
qreal lw = 2.0/vp.matrix().m11();
QPen pen(MScore::frameMarginColor);
pen.setWidthF(lw);
if (grips == 6) { // HACK: this are grips of a slur
vp.setPen(pen);
QPolygonF polygon(grips+1);
for (int i = 0; i < grips; ++i)
polygon[i] = QPointF(grip[i].center());
polygon[grips] = QPointF(grip[0].center());
QPen pen(MScore::frameMarginColor, 2.0/vp.matrix().m11());
vp.setPen(pen);
vp.drawPolyline(polygon);
}
pen.setColor(MScore::defaultColor);
QPen pen(MScore::defaultColor, 0.0);
vp.setPen(pen);
for (int i = 0; i < grips; ++i) {
vp.setBrush(((i == curGrip) && hasFocus()) ? MScore::selectColor[0] : Qt::NoBrush);
if (i == curGrip && hasFocus())
vp.setBrush(MScore::selectColor[0]);
else
vp.setBrush(Qt::NoBrush);
vp.drawRect(grip[i]);
}
if (editObject) // if object is moved, it may not be covered by bsp