Mercurial > hg > svgui
comparison widgets/Pane.cpp @ 70:bf306158803d
* Add stub for item-edit dialog (for editing properties of an item on double-
click) -- doesn't actually do anything yet
* Add code to invoke said non-working item-edit dialog on double-click in
time-value, time-instants and note layers
* Add overlay mode (no text, basic text, all text)
author | Chris Cannam |
---|---|
date | Thu, 30 Mar 2006 15:00:22 +0000 |
parents | 193b569a975f |
children | fd348f36c0d3 |
comparison
equal
deleted
inserted
replaced
69:6dad2724f3aa | 70:bf306158803d |
---|---|
142 int verticalScaleWidth = 0; | 142 int verticalScaleWidth = 0; |
143 | 143 |
144 int fontHeight = paint.fontMetrics().height(); | 144 int fontHeight = paint.fontMetrics().height(); |
145 int fontAscent = paint.fontMetrics().ascent(); | 145 int fontAscent = paint.fontMetrics().ascent(); |
146 | 146 |
147 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { | 147 if (m_manager && |
148 --vi; | 148 m_manager->getOverlayMode() != ViewManager::NoOverlays) { |
149 | 149 |
150 if (dynamic_cast<WaveformLayer *>(*vi)) { | 150 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { |
151 waveformModel = (*vi)->getModel(); | 151 --vi; |
152 } | 152 |
153 | 153 if (dynamic_cast<WaveformLayer *>(*vi)) { |
154 verticalScaleWidth = (*vi)->getVerticalScaleWidth(this, paint); | 154 waveformModel = (*vi)->getModel(); |
155 | 155 } |
156 if (verticalScaleWidth > 0 && r.left() < verticalScaleWidth) { | 156 |
157 verticalScaleWidth = (*vi)->getVerticalScaleWidth(this, paint); | |
158 | |
159 if (verticalScaleWidth > 0 && r.left() < verticalScaleWidth) { | |
157 | 160 |
158 // Profiler profiler("Pane::paintEvent - painting vertical scale", true); | 161 // Profiler profiler("Pane::paintEvent - painting vertical scale", true); |
159 | 162 |
160 // std::cerr << "Pane::paintEvent: calling paint.save() in vertical scale block" << std::endl; | 163 // std::cerr << "Pane::paintEvent: calling paint.save() in vertical scale block" << std::endl; |
161 paint.save(); | 164 paint.save(); |
162 | 165 |
163 paint.setPen(Qt::black); | 166 paint.setPen(Qt::black); |
164 paint.setBrush(Qt::white); | 167 paint.setBrush(Qt::white); |
165 paint.drawRect(0, -1, verticalScaleWidth, height()+1); | 168 paint.drawRect(0, -1, verticalScaleWidth, height()+1); |
166 | 169 |
167 paint.setBrush(Qt::NoBrush); | 170 paint.setBrush(Qt::NoBrush); |
168 (*vi)->paintVerticalScale | 171 (*vi)->paintVerticalScale |
169 (this, paint, QRect(0, 0, verticalScaleWidth, height())); | 172 (this, paint, QRect(0, 0, verticalScaleWidth, height())); |
170 | 173 |
171 paint.restore(); | 174 paint.restore(); |
172 } | 175 } |
173 | 176 |
174 if (m_identifyFeatures) { | 177 if (m_identifyFeatures) { |
175 | 178 |
176 QPoint pos = m_identifyPoint; | 179 QPoint pos = m_identifyPoint; |
177 QString desc = (*vi)->getFeatureDescription(this, pos); | 180 QString desc = (*vi)->getFeatureDescription(this, pos); |
178 | 181 |
179 if (desc != "") { | 182 if (desc != "") { |
180 | 183 |
181 paint.save(); | 184 paint.save(); |
182 | 185 |
183 int tabStop = | 186 int tabStop = |
184 paint.fontMetrics().width(tr("Some lengthy prefix:")); | 187 paint.fontMetrics().width(tr("Some lengthy prefix:")); |
185 | 188 |
186 QRect boundingRect = | 189 QRect boundingRect = |
187 paint.fontMetrics().boundingRect | 190 paint.fontMetrics().boundingRect |
188 (rect(), | 191 (rect(), |
189 Qt::AlignRight | Qt::AlignTop | Qt::TextExpandTabs, | 192 Qt::AlignRight | Qt::AlignTop | Qt::TextExpandTabs, |
190 desc, tabStop); | 193 desc, tabStop); |
191 | 194 |
192 if (hasLightBackground()) { | 195 if (hasLightBackground()) { |
193 paint.setPen(Qt::NoPen); | 196 paint.setPen(Qt::NoPen); |
194 paint.setBrush(QColor(250, 250, 250, 200)); | 197 paint.setBrush(QColor(250, 250, 250, 200)); |
195 } else { | 198 } else { |
196 paint.setPen(Qt::NoPen); | 199 paint.setPen(Qt::NoPen); |
197 paint.setBrush(QColor(50, 50, 50, 200)); | 200 paint.setBrush(QColor(50, 50, 50, 200)); |
198 } | 201 } |
199 | 202 |
200 int extra = paint.fontMetrics().descent(); | 203 int extra = paint.fontMetrics().descent(); |
201 paint.drawRect(width() - boundingRect.width() - 10 - extra, | 204 paint.drawRect(width() - boundingRect.width() - 10 - extra, |
202 10 - extra, | 205 10 - extra, |
203 boundingRect.width() + 2 * extra, | 206 boundingRect.width() + 2 * extra, |
204 boundingRect.height() + extra); | 207 boundingRect.height() + extra); |
205 | 208 |
206 if (hasLightBackground()) { | 209 if (hasLightBackground()) { |
207 paint.setPen(QColor(150, 20, 0)); | 210 paint.setPen(QColor(150, 20, 0)); |
208 } else { | 211 } else { |
209 paint.setPen(QColor(255, 150, 100)); | 212 paint.setPen(QColor(255, 150, 100)); |
210 } | 213 } |
211 | 214 |
212 QTextOption option; | 215 QTextOption option; |
213 option.setWrapMode(QTextOption::NoWrap); | 216 option.setWrapMode(QTextOption::NoWrap); |
214 option.setAlignment(Qt::AlignRight | Qt::AlignTop); | 217 option.setAlignment(Qt::AlignRight | Qt::AlignTop); |
215 option.setTabStop(tabStop); | 218 option.setTabStop(tabStop); |
216 paint.drawText(QRectF(width() - boundingRect.width() - 10, 10, | 219 paint.drawText(QRectF(width() - boundingRect.width() - 10, 10, |
217 boundingRect.width(), | 220 boundingRect.width(), |
218 boundingRect.height()), | 221 boundingRect.height()), |
219 desc, | 222 desc, |
220 option); | 223 option); |
221 | 224 |
222 paint.restore(); | 225 paint.restore(); |
223 } | 226 } |
224 } | 227 } |
225 | 228 |
226 break; | 229 break; |
230 } | |
227 } | 231 } |
228 | 232 |
229 int sampleRate = getModelsSampleRate(); | 233 int sampleRate = getModelsSampleRate(); |
230 paint.setBrush(Qt::NoBrush); | 234 paint.setBrush(Qt::NoBrush); |
231 | 235 |
262 // y already set correctly | 266 // y already set correctly |
263 break; | 267 break; |
264 } | 268 } |
265 } | 269 } |
266 | 270 |
267 if (sampleRate) { | 271 if (m_manager && |
268 | 272 m_manager->getOverlayMode() != ViewManager::NoOverlays) { |
269 QString text(QString::fromStdString | 273 |
270 (RealTime::frame2RealTime | 274 if (sampleRate) { |
271 (m_centreFrame, sampleRate).toText(true))); | 275 |
272 | 276 QString text(QString::fromStdString |
273 int tw = paint.fontMetrics().width(text); | 277 (RealTime::frame2RealTime |
274 int x = width()/2 - 4 - tw; | 278 (m_centreFrame, sampleRate).toText(true))); |
275 | 279 |
276 drawVisibleText(paint, x, y, text, OutlinedText); | 280 int tw = paint.fontMetrics().width(text); |
277 } | 281 int x = width()/2 - 4 - tw; |
278 | 282 |
279 QString text = QString("%1").arg(m_centreFrame); | 283 drawVisibleText(paint, x, y, text, OutlinedText); |
280 | 284 } |
281 int tw = paint.fontMetrics().width(text); | 285 |
282 int x = width()/2 + 4; | 286 QString text = QString("%1").arg(m_centreFrame); |
283 | 287 |
284 drawVisibleText(paint, x, y, text, OutlinedText); | 288 int tw = paint.fontMetrics().width(text); |
289 int x = width()/2 + 4; | |
290 | |
291 drawVisibleText(paint, x, y, text, OutlinedText); | |
292 } | |
285 | 293 |
286 } else { | 294 } else { |
287 | 295 |
288 paint.setPen(QColor(50, 50, 50)); | 296 paint.setPen(QColor(50, 50, 50)); |
289 } | 297 } |
290 | 298 |
291 if (waveformModel && | 299 if (waveformModel && |
300 m_manager && | |
301 m_manager->getOverlayMode() != ViewManager::NoOverlays && | |
292 r.y() + r.height() >= height() - fontHeight - 6) { | 302 r.y() + r.height() >= height() - fontHeight - 6) { |
293 | 303 |
294 size_t mainModelRate = m_manager->getMainModelSampleRate(); | 304 size_t mainModelRate = m_manager->getMainModelSampleRate(); |
295 size_t playbackRate = m_manager->getPlaybackSampleRate(); | 305 size_t playbackRate = m_manager->getPlaybackSampleRate(); |
296 | 306 |
320 height() - fontHeight + fontAscent - 6, | 330 height() - fontHeight + fontAscent - 6, |
321 desc, OutlinedText); | 331 desc, OutlinedText); |
322 } | 332 } |
323 } | 333 } |
324 | 334 |
325 if (r.y() + r.height() >= height() - m_layers.size() * fontHeight - 6) { | 335 if (m_manager && |
336 m_manager->getOverlayMode() == ViewManager::AllOverlays && | |
337 r.y() + r.height() >= height() - m_layers.size() * fontHeight - 6) { | |
326 | 338 |
327 std::vector<QString> texts; | 339 std::vector<QString> texts; |
328 int maxTextWidth = 0; | 340 int maxTextWidth = 0; |
329 | 341 |
330 for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { | 342 for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { |