Skip to content

Commit

Permalink
Merge branch 'bends' of https://github.com/Igevorse/MuseScore into Ig…
Browse files Browse the repository at this point in the history
…evorse-bends
  • Loading branch information
lasconic committed Jun 23, 2015
2 parents f6959ac + 6304ad0 commit c7c7a18
Show file tree
Hide file tree
Showing 14 changed files with 811 additions and 1 deletion.
50 changes: 50 additions & 0 deletions libmscore/bend.cpp
Expand Up @@ -38,6 +38,7 @@ Bend::Bend(Score* s)
: Element(s)
{
setFlags(ElementFlag::MOVABLE | ElementFlag::SELECTABLE);
setPlayBend(true);
}

//---------------------------------------------------------
Expand Down Expand Up @@ -259,6 +260,7 @@ void Bend::write(Xml& xml) const
xml.tagE(QString("point time=\"%1\" pitch=\"%2\" vibrato=\"%3\"")
.arg(v.time).arg(v.pitch).arg(v.vibrato));
}
writeProperty(xml, P_ID::PLAY_BEND);
Element::writeProperties(xml);
xml.etag();
}
Expand All @@ -278,10 +280,58 @@ void Bend::read(XmlReader& e)
_points.append(pv);
e.readNext();
}
else if (e.name() == "playBend") {
setPlayBend(e.readBool());
}
else if (!Element::readProperties(e))
e.unknown();
}
}

//---------------------------------------------------------
// getProperty
//---------------------------------------------------------

QVariant Bend::getProperty(P_ID propertyId) const
{
switch (propertyId) {
case P_ID::PLAY_BEND:
return bool(playBend());
default:
return Element::getProperty(propertyId);
}
}

//---------------------------------------------------------
// setProperty
//---------------------------------------------------------

bool Bend::setProperty(P_ID propertyId, const QVariant& v)
{
switch (propertyId) {
case P_ID::PLAY_BEND:
setPlayBend(v.toBool());
break;
default:
return Element::setProperty(propertyId, v);
}
score()->setLayoutAll(true);
return true;
}

//---------------------------------------------------------
// propertyDefault
//---------------------------------------------------------

QVariant Bend::propertyDefault(P_ID propertyId) const
{
switch (propertyId) {
case P_ID::PLAY_BEND:
return true;
default:
return Element::propertyDefault(propertyId);
}
}

}

8 changes: 8 additions & 0 deletions libmscore/bend.h
Expand Up @@ -31,6 +31,7 @@ class Bend : public Element {
qreal _lw;
QPointF notePos;
qreal noteWidth;
bool _playBend;

public:
Bend(Score* s);
Expand All @@ -43,6 +44,13 @@ class Bend : public Element {
QList<PitchValue>& points() { return _points; }
const QList<PitchValue>& points() const { return _points; }
void setPoints(const QList<PitchValue>& p) { _points = p; }
bool playBend() const { return _playBend; }
void setPlayBend(bool v) { _playBend = v; }

// property methods
virtual QVariant getProperty(P_ID propertyId) const override;
virtual bool setProperty(P_ID propertyId, const QVariant&) override;
virtual QVariant propertyDefault(P_ID) const override;
};


Expand Down
1 change: 1 addition & 0 deletions libmscore/property.cpp
Expand Up @@ -228,6 +228,7 @@ static const PropertyData propertyList[] = {
{ P_ID::TRACK, false, 0, P_TYPE::INT },

{ P_ID::GLISSANDO_STYLE, false, "glissandoStyle", P_TYPE::GLISSANDO_STYLE},
{ P_ID::PLAY_BEND, false, "playBend", P_TYPE::BOOL},
{ P_ID::END, false, "", P_TYPE::INT }
};

Expand Down
1 change: 1 addition & 0 deletions libmscore/property.h
Expand Up @@ -222,6 +222,7 @@ enum class P_ID : unsigned char {
TRACK,

GLISSANDO_STYLE,
PLAY_BEND,
END
};

Expand Down
2 changes: 2 additions & 0 deletions libmscore/rendermidi.cpp
Expand Up @@ -245,6 +245,8 @@ static void collectNote(EventMap* events, int channel, const Note* note, int vel
if (e == 0 || e->type() != Element::Type::BEND)
continue;
Bend* bend = static_cast<Bend*>(e);
if (!bend->playBend())
break;
const QList<PitchValue>& points = bend->points();
int pitchSize = points.size();

Expand Down
1 change: 1 addition & 0 deletions mscore/CMakeLists.txt
Expand Up @@ -123,6 +123,7 @@ QT5_WRAP_UI (ui_headers
inspector/inspector_empty.ui
inspector/inspector_fret.ui
inspector/inspector_break.ui
inspector/inspector_bend.ui
${SCRIPT_UI}
)

Expand Down
20 changes: 20 additions & 0 deletions mscore/inspector/inspector.cpp
Expand Up @@ -244,6 +244,9 @@ void Inspector::setElements(const QList<Element*>& l)
case Element::Type::LAYOUT_BREAK:
ie = new InspectorBreak(this);
break;
case Element::Type::BEND:
ie = new InspectorBend(this);
break;
default:
if (_element->isText())
ie = new InspectorText(this);
Expand Down Expand Up @@ -628,6 +631,23 @@ InspectorAccidental::InspectorAccidental(QWidget* parent)
mapSignals();
}

//---------------------------------------------------------
// InspectorBend
//---------------------------------------------------------

InspectorBend::InspectorBend(QWidget* parent)
: InspectorBase(parent)
{
e.setupUi(addWidget());
g.setupUi(addWidget());

iList = {
{ P_ID::PLAY_BEND, 0, 0, g.playBend, g.resetPlayBend }
};

mapSignals();
}

//---------------------------------------------------------
// InspectorClef
//---------------------------------------------------------
Expand Down
15 changes: 15 additions & 0 deletions mscore/inspector/inspector.h
Expand Up @@ -16,6 +16,7 @@

#include "inspectorBase.h"
#include "ui_inspector_element.h"
#include "ui_inspector_bend.h"
#include "ui_inspector_break.h"
#include "ui_inspector_vbox.h"
#include "ui_inspector_tbox.h"
Expand Down Expand Up @@ -241,6 +242,20 @@ class InspectorAccidental : public InspectorBase {
InspectorAccidental(QWidget* parent);
};

//---------------------------------------------------------
// InspectorBend
//---------------------------------------------------------

class InspectorBend : public InspectorBase {
Q_OBJECT

UiInspectorElement e;
Ui::InspectorBend g;

public:
InspectorBend(QWidget* parent);
};

//---------------------------------------------------------
// InspectorTempoText
//---------------------------------------------------------
Expand Down
113 changes: 113 additions & 0 deletions mscore/inspector/inspector_bend.ui
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>InspectorBend</class>
<widget class="QWidget" name="InspectorBend">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>270</width>
<height>58</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<property name="accessibleName">
<string>Glissando Inspector</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="elementName">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="accessibleName">
<string/>
</property>
<property name="text">
<string>Bend</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="minimumSize">
<size>
<width>0</width>
<height>6</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="horizontalSpacing">
<number>3</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="playBend">
<property name="text">
<string>Play</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="resetPlayBend">
<property name="accessibleName">
<string>Reset Play value</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Binary file added mtest/libmscore/midi/testBends1-ref.mid
Binary file not shown.

0 comments on commit c7c7a18

Please sign in to comment.