1 //=========================================================
2 // MusE
3 // Linux Music Editor
4 // $Id: velocity.cpp,v 1.1.1.1 2003/10/27 18:55:04 wschweer Exp $
5 // (C) Copyright 2001 Werner Schweer (ws@seh.de)
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; version 2 of
10 // the License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 //
21 //=========================================================
22
23 #include <QButtonGroup>
24 #include "velocity.h"
25 #include "xml.h"
26
27 namespace MusEGui {
28
29 FunctionReturnDialogFlags_t Velocity::_ret_flags = FunctionReturnNoFlags;
30 FunctionDialogElements_t Velocity::_elements = FunctionDialogNoElements;
31 int Velocity::_range = FunctionSelectedEventsButton;
32 int Velocity::_parts = FunctionSelectedPartsButton;
33 int Velocity::rateVal = 100;
34 int Velocity::offsetVal = 0;
35
36 //---------------------------------------------------------
37 // Velocity
38 //---------------------------------------------------------
39
Velocity(QWidget * parent)40 Velocity::Velocity(QWidget* parent)
41 : FunctionDialogBase(parent)
42 {
43 setupUi(this);
44
45 //--------------------------------------------
46 // Set range and parts containers if available.
47 //--------------------------------------------
48
49 _range_container = rangeBox;
50 _parts_container = partsBox;
51
52 //--------------------------------------------
53 // Add element widgets to range and parts groups.
54 //--------------------------------------------
55
56 _range_group->addButton(allEvents, FunctionAllEventsButton);
57 _range_group->addButton(selectedEvents,FunctionSelectedEventsButton);
58 _range_group->addButton(loopedEvents, FunctionLoopedButton);
59 _range_group->addButton(selectedLooped, FunctionSelectedLoopedButton);
60
61 _parts_group->addButton(not_all_parts_button, FunctionSelectedPartsButton);
62 _parts_group->addButton(all_parts_button, FunctionAllPartsButton);
63 }
64
65 //---------------------------------------------------------
66 // pullValues
67 //---------------------------------------------------------
68
pull_values()69 void Velocity::pull_values()
70 {
71 //--------------------------------------------
72 // Grab IDs or values from common base object
73 // (range and parts groups etc.)
74 //--------------------------------------------
75
76 FunctionDialogBase::pull_values();
77
78 //--------------------------------------------
79 // Grab this dialog's specific IDs or values.
80 //--------------------------------------------
81
82 rateVal = rate->value();
83 offsetVal = offset->value();
84 }
85
setupDialog()86 void Velocity::setupDialog()
87 {
88 //------------------------------------
89 // Setup common base object items.
90 //------------------------------------
91
92 FunctionDialogBase::setupDialog();
93
94 //------------------------------------
95 // Setup this dialog's specific items.
96 //------------------------------------
97
98 rate->setValue(rateVal);
99 offset->setValue(offsetVal);
100 }
101
read_configuration(MusECore::Xml & xml)102 void Velocity::read_configuration(MusECore::Xml& xml)
103 {
104 for (;;)
105 {
106 MusECore::Xml::Token token = xml.parse();
107 if (token == MusECore::Xml::Error || token == MusECore::Xml::End)
108 break;
109
110 const QString& tag = xml.s1();
111 switch (token)
112 {
113 case MusECore::Xml::TagStart:
114
115 //-----------------------------------------
116 // Handle any common base settings.
117 //-----------------------------------------
118
119 if(!FunctionDialogBase::read_configuration(tag, xml))
120 {
121 //-----------------------------------------
122 // Handle this dialog's specific settings.
123 //-----------------------------------------
124
125 if (tag == "range")
126 _range = xml.parseInt();
127 else if (tag == "parts")
128 _parts = xml.parseInt();
129 else if (tag == "rate")
130 rateVal=xml.parseInt();
131 else if (tag == "offset")
132 offsetVal=xml.parseInt();
133 else
134 xml.unknown("ModVelo");
135 }
136 break;
137
138 case MusECore::Xml::TagEnd:
139 if (tag == "mod_velo")
140 return;
141
142 default:
143 break;
144 }
145 }
146 }
147
write_configuration(int level,MusECore::Xml & xml)148 void Velocity::write_configuration(int level, MusECore::Xml& xml)
149 {
150 xml.tag(level++, "mod_velo");
151
152 //-----------------------------------------
153 // Write any common base settings.
154 //-----------------------------------------
155
156 FunctionDialogBase::write_configuration(level, xml);
157
158 //-----------------------------------------
159 // Write this dialog's specific settings.
160 //-----------------------------------------
161
162 xml.intTag(level, "range", _range);
163 xml.intTag(level, "parts", _parts);
164 xml.intTag(level, "offset", offsetVal);
165 xml.intTag(level, "rate", rateVal);
166 xml.tag(level, "/mod_velo");
167 }
168
169 } // namespace MusEGui
170