1 //=============================================================================
2 //  MuseScore
3 //  Music Composition & Notation
4 //
5 //  Copyright (C) 2012 Werner Schweer
6 //
7 //  This program is free software; you can redistribute it and/or modify
8 //  it under the terms of the GNU General Public License version 2
9 //  as published by the Free Software Foundation and appearing in
10 //  the file LICENSE.GPL
11 //=============================================================================
12 
13 #include "inspector.h"
14 #include "inspectorTextLine.h"
15 #include "inspectorHairpin.h"
16 #include "libmscore/hairpin.h"
17 #include "libmscore/changeMap.h"
18 
19 namespace Ms {
20 
21 //---------------------------------------------------------
22 //   InspectorHairpin
23 //---------------------------------------------------------
24 
InspectorHairpin(QWidget * parent)25 InspectorHairpin::InspectorHairpin(QWidget* parent)
26 //   : InspectorElementBase(parent)
27    : InspectorTextLineBase(parent)
28       {
29       h.setupUi(addWidget());
30 
31       h.hairpinType->clear();
32       h.hairpinType->addItem(tr("Crescendo Hairpin"),   int(HairpinType::CRESC_HAIRPIN));
33       h.hairpinType->addItem(tr("Decrescendo Hairpin"), int(HairpinType::DECRESC_HAIRPIN));
34       h.hairpinType->addItem(tr("Crescendo Line"),      int(HairpinType::CRESC_LINE));
35       h.hairpinType->addItem(tr("Decrescendo Line"),    int(HairpinType::DECRESC_LINE));
36 
37       h.veloChangeMethod->clear();
38       h.veloChangeMethod->addItem(tr("Default (linear)"),   int(ChangeMethod::NORMAL));
39       h.veloChangeMethod->addItem(tr("Ease-in and out"),    int(ChangeMethod::EASE_IN_OUT));
40       h.veloChangeMethod->addItem(tr("Ease-in"),            int(ChangeMethod::EASE_IN));
41       h.veloChangeMethod->addItem(tr("Ease-out"),           int(ChangeMethod::EASE_OUT));
42       h.veloChangeMethod->addItem(tr("Exponential"),        int(ChangeMethod::EXPONENTIAL));
43 
44       const std::vector<InspectorItem> il = {
45             { Pid::HAIRPIN_CIRCLEDTIP,   0, h.hairpinCircledTip,   h.resetHairpinCircledTip },
46             { Pid::HAIRPIN_TYPE,         0, h.hairpinType,         0                        },
47             { Pid::PLACEMENT,            0, h.placement,           h.resetPlacement         },
48             { Pid::DYNAMIC_RANGE,        0, h.dynRange,            h.resetDynRange          },
49             { Pid::VELO_CHANGE,          0, h.veloChange,          h.resetVeloChange        },
50             { Pid::HAIRPIN_HEIGHT,       0, h.hairpinHeight,       h.resetHairpinHeight     },
51             { Pid::HAIRPIN_CONT_HEIGHT,  0, h.hairpinContHeight,   h.resetHairpinContHeight },
52             { Pid::SINGLE_NOTE_DYNAMICS, 0, h.singleNoteDynamics,  h.resetSingleNoteDynamics},
53             { Pid::VELO_CHANGE_METHOD,   0, h.veloChangeMethod,    h.resetVeloChangeMethod  },
54             };
55       const std::vector<InspectorPanel> ppList = {
56             { h.title, h.panel }
57             };
58       mapSignals(il, ppList);
59       }
60 
61 //---------------------------------------------------------
62 //   updateLineType
63 //---------------------------------------------------------
64 
updateLineType()65 void InspectorHairpin::updateLineType()
66       {
67       HairpinSegment* hs = toHairpinSegment(inspector->element());
68       Hairpin* hp = hs->hairpin();
69       bool userDash = hp->lineStyle() == Qt::CustomDashLine;
70 
71       l.dashLineLength->setVisible(userDash);
72       l.dashGapLength->setVisible(userDash);
73       l.resetDashLineLength->setVisible(userDash);
74       l.resetDashGapLength->setVisible(userDash);
75       l.dashLineLengthLabel->setVisible(userDash);
76       l.dashGapLengthLabel->setVisible(userDash);
77       }
78 
79 //---------------------------------------------------------
80 //   valueChanged
81 //---------------------------------------------------------
82 
valueChanged(int idx)83 void InspectorHairpin::valueChanged(int idx)
84       {
85       InspectorTextLineBase::valueChanged(idx);
86       if (iList[idx].t == Pid::LINE_STYLE)
87             updateLineType();
88       }
89 
90 //---------------------------------------------------------
91 //   setElement
92 //---------------------------------------------------------
93 
setElement()94 void InspectorHairpin::setElement()
95       {
96       InspectorTextLineBase::setElement();
97       updateLineType();
98       if (!h.singleNoteDynamics->isChecked()) {
99             h.labelVeloChangeMethod->setEnabled(false);
100             h.veloChangeMethod->setEnabled(false);
101             h.resetVeloChangeMethod->setEnabled(false);
102             }
103       }
104 
105 //---------------------------------------------------------
106 //   postInit
107 //---------------------------------------------------------
108 
postInit()109 void InspectorHairpin::postInit()
110       {
111       bool useTextLine = h.hairpinType->currentIndex() == int(HairpinType::CRESC_LINE)
112          || h.hairpinType->currentIndex() == int(HairpinType::DECRESC_LINE);
113       l.lineVisible->setEnabled(useTextLine);
114       h.gridWidget->setHidden(useTextLine);
115       }
116 
117 }
118 
119