1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4     Rosegarden
5     A MIDI and audio sequencer and musical notation editor.
6     Copyright 2000-2021 the Rosegarden development team.
7 
8     Other copyrights also apply to some parts of this work.  Please
9     see the AUTHORS file and individual file headers for details.
10 
11     This program is free software; you can redistribute it and/or
12     modify it under the terms of the GNU General Public License as
13     published by the Free Software Foundation; either version 2 of the
14     License, or (at your option) any later version.  See the file
15     COPYING included with this distribution for more information.
16 */
17 
18 #include "IncreaseParameterPattern.h"
19 #include "gui/dialogs/EventParameterDialog.h"
20 
21 namespace Rosegarden
22 {
23 
24 IncreaseParameterPattern IncreaseParameterPattern::increase(true);
25 
26 IncreaseParameterPattern IncreaseParameterPattern::decrease(false);
27 
28 QString
getText(QString propertyName) const29 IncreaseParameterPattern::getText(QString propertyName) const
30 {
31     QString text;
32     if (m_isIncrease) {
33         text = QObject::tr("Increase - raise each %1 by value");
34     } else {
35         text = QObject::tr("Decrease - lower each %1 by value");
36     }
37     return text.arg(propertyName);
38 }
39 
40 ParameterPattern::SliderSpecVector
getSliderSpec(const SelectionSituation * situation) const41 IncreaseParameterPattern::getSliderSpec(const SelectionSituation * situation) const
42 {
43     QString valueText;
44     if (m_isIncrease) {
45         valueText = QObject::tr("Increase by");
46     } else {
47         valueText = QObject::tr("Decrease by");
48     }
49 
50     SliderSpecVector result;
51     result.push_back(SliderSpec(
52             valueText,  // label
53             10,  // defaultValue
54             situation));
55 
56     return result;
57 }
58 
59 void
setEventProperties(iterator begin,iterator end,Result * result) const60 IncreaseParameterPattern::setEventProperties(iterator begin, iterator end,
61                                              Result *result) const
62 {
63     const int          delta    = result->m_parameters[0];
64     const int          increase = m_isIncrease ? delta : -delta;
65     for (iterator i = begin; i != end; ++i) {
66         result->m_situation->addToValue(*i, increase);
67     }
68 }
69 
70 } // End namespace Rosegarden
71