Mercurial > hg > svgui
comparison layer/WaveformLayer.cpp @ 216:34bbbcb3c01f sv1-1.0pre1
* Make getPropertyRangeAndValue return the default separately from the current
value. Previously some contexts were incorrectly treating the current value
as a default.
author | Chris Cannam |
---|---|
date | Fri, 02 Mar 2007 14:00:12 +0000 |
parents | 8520b7918104 |
children | 28c8e8e3c537 |
comparison
equal
deleted
inserted
replaced
215:d2334a77db73 | 216:34bbbcb3c01f |
---|---|
135 return QString(); | 135 return QString(); |
136 } | 136 } |
137 | 137 |
138 int | 138 int |
139 WaveformLayer::getPropertyRangeAndValue(const PropertyName &name, | 139 WaveformLayer::getPropertyRangeAndValue(const PropertyName &name, |
140 int *min, int *max) const | 140 int *min, int *max, int *deflt) const |
141 { | 141 { |
142 int deft = 0; | 142 int val = 0; |
143 | 143 |
144 int garbage0, garbage1; | 144 int garbage0, garbage1, garbage2; |
145 if (!min) min = &garbage0; | 145 if (!min) min = &garbage0; |
146 if (!max) max = &garbage1; | 146 if (!max) max = &garbage1; |
147 if (!deflt) deflt = &garbage2; | |
147 | 148 |
148 if (name == "Gain") { | 149 if (name == "Gain") { |
149 | 150 |
150 *min = -50; | 151 *min = -50; |
151 *max = 50; | 152 *max = 50; |
152 | 153 *deflt = 0; |
153 deft = lrint(log10(m_gain) * 20.0); | 154 |
154 if (deft < *min) deft = *min; | 155 val = lrint(log10(m_gain) * 20.0); |
155 if (deft > *max) deft = *max; | 156 if (val < *min) val = *min; |
157 if (val > *max) val = *max; | |
156 | 158 |
157 } else if (name == "Normalize Visible Area") { | 159 } else if (name == "Normalize Visible Area") { |
158 | 160 |
159 deft = (m_autoNormalize ? 1 : 0); | 161 val = (m_autoNormalize ? 1 : 0); |
162 *deflt = 0; | |
160 | 163 |
161 } else if (name == "Colour") { | 164 } else if (name == "Colour") { |
162 | 165 |
163 *min = 0; | 166 *min = 0; |
164 *max = 5; | 167 *max = 5; |
165 | 168 *deflt = 0; |
166 if (m_colour == Qt::black) deft = 0; | 169 |
167 else if (m_colour == Qt::darkRed) deft = 1; | 170 if (m_colour == Qt::black) val = 0; |
171 else if (m_colour == Qt::darkRed) val = 1; | |
168 else if (m_colour == Qt::darkBlue || | 172 else if (m_colour == Qt::darkBlue || |
169 m_colour == QColor(84, 177, 248)) deft = 2; | 173 m_colour == QColor(84, 177, 248)) val = 2; |
170 else if (m_colour == Qt::darkGreen) deft = 3; | 174 else if (m_colour == Qt::darkGreen) val = 3; |
171 else if (m_colour == QColor(200, 50, 255)) deft = 4; | 175 else if (m_colour == QColor(200, 50, 255)) val = 4; |
172 else if (m_colour == QColor(255, 150, 50)) deft = 5; | 176 else if (m_colour == QColor(255, 150, 50)) val = 5; |
173 | 177 |
174 } else if (name == "Channels") { | 178 } else if (name == "Channels") { |
175 | 179 |
176 *min = 0; | 180 *min = 0; |
177 *max = 2; | 181 *max = 2; |
178 if (m_channelMode == MixChannels) deft = 1; | 182 *deflt = 0; |
179 else if (m_channelMode == MergeChannels) deft = 2; | 183 if (m_channelMode == MixChannels) val = 1; |
180 else deft = 0; | 184 else if (m_channelMode == MergeChannels) val = 2; |
185 else val = 0; | |
181 | 186 |
182 } else if (name == "Scale") { | 187 } else if (name == "Scale") { |
183 | 188 |
184 *min = 0; | 189 *min = 0; |
185 *max = 2; | 190 *max = 2; |
186 | 191 *deflt = 0; |
187 deft = (int)m_scale; | 192 |
193 val = (int)m_scale; | |
188 | 194 |
189 } else { | 195 } else { |
190 deft = Layer::getPropertyRangeAndValue(name, min, max); | 196 val = Layer::getPropertyRangeAndValue(name, min, max, deflt); |
191 } | 197 } |
192 | 198 |
193 return deft; | 199 return val; |
194 } | 200 } |
195 | 201 |
196 QString | 202 QString |
197 WaveformLayer::getPropertyValueLabel(const PropertyName &name, | 203 WaveformLayer::getPropertyValueLabel(const PropertyName &name, |
198 int value) const | 204 int value) const |