Mercurial > hg > svgui
comparison widgets/AudioDial.cpp @ 344:832d246b327b
* better progress reporting in FileSource
* fix set-to-default for audio dials with mappers
author | Chris Cannam |
---|---|
date | Fri, 04 Jan 2008 17:08:10 +0000 |
parents | cd2492c5fe45 |
children | 06b5f110c5d2 |
comparison
equal
deleted
inserted
replaced
343:1b6879d03cb6 | 344:832d246b327b |
---|---|
73 AudioDial::AudioDial(QWidget *parent) : | 73 AudioDial::AudioDial(QWidget *parent) : |
74 QDial(parent), | 74 QDial(parent), |
75 m_knobColor(Qt::black), | 75 m_knobColor(Qt::black), |
76 m_meterColor(Qt::white), | 76 m_meterColor(Qt::white), |
77 m_defaultValue(0), | 77 m_defaultValue(0), |
78 m_defaultMappedValue(0), | |
78 m_mappedValue(0), | 79 m_mappedValue(0), |
79 m_noMappedUpdate(false), | 80 m_noMappedUpdate(false), |
80 m_showTooltip(true), | 81 m_showTooltip(true), |
81 m_rangeMapper(0) | 82 m_rangeMapper(0) |
82 { | 83 { |
332 | 333 |
333 | 334 |
334 void AudioDial::setDefaultValue(int defaultValue) | 335 void AudioDial::setDefaultValue(int defaultValue) |
335 { | 336 { |
336 m_defaultValue = defaultValue; | 337 m_defaultValue = defaultValue; |
337 } | 338 if (m_rangeMapper) { |
338 | 339 m_defaultMappedValue = m_rangeMapper->getValueForPosition(defaultValue); |
340 } | |
341 } | |
339 | 342 |
340 void AudioDial::setValue(int value) | 343 void AudioDial::setValue(int value) |
341 { | 344 { |
342 QDial::setValue(value); | 345 QDial::setValue(value); |
343 updateMappedValue(value); | 346 updateMappedValue(value); |
344 } | 347 } |
345 | 348 |
349 void AudioDial::setDefaultMappedValue(float value) | |
350 { | |
351 m_defaultMappedValue = value; | |
352 if (m_rangeMapper) { | |
353 m_defaultValue = m_rangeMapper->getPositionForValue(value); | |
354 } | |
355 } | |
346 | 356 |
347 void AudioDial::setMappedValue(float mappedValue) | 357 void AudioDial::setMappedValue(float mappedValue) |
348 { | 358 { |
349 if (m_rangeMapper) { | 359 if (m_rangeMapper) { |
350 int newPosition = m_rangeMapper->getPositionForValue(mappedValue); | 360 int newPosition = m_rangeMapper->getPositionForValue(mappedValue); |
405 } | 415 } |
406 setToolTip(text); | 416 setToolTip(text); |
407 } | 417 } |
408 } | 418 } |
409 | 419 |
420 void | |
421 AudioDial::setToDefault() | |
422 { | |
423 if (m_rangeMapper) { | |
424 setMappedValue(m_defaultMappedValue); | |
425 return; | |
426 } | |
427 int dv = m_defaultValue; | |
428 if (dv < minimum()) dv = minimum(); | |
429 if (dv > maximum()) dv = maximum(); | |
430 setValue(m_defaultValue); | |
431 } | |
410 | 432 |
411 // Alternate mouse behavior event handlers. | 433 // Alternate mouse behavior event handlers. |
412 void AudioDial::mousePressEvent(QMouseEvent *mouseEvent) | 434 void AudioDial::mousePressEvent(QMouseEvent *mouseEvent) |
413 { | 435 { |
414 if (m_mouseDial) { | 436 if (m_mouseDial) { |
415 QDial::mousePressEvent(mouseEvent); | 437 QDial::mousePressEvent(mouseEvent); |
416 } else if (mouseEvent->button() == Qt::MidButton || | 438 } else if (mouseEvent->button() == Qt::MidButton || |
417 ((mouseEvent->button() == Qt::LeftButton) && | 439 ((mouseEvent->button() == Qt::LeftButton) && |
418 (mouseEvent->modifiers() & Qt::ControlModifier))) { | 440 (mouseEvent->modifiers() & Qt::ControlModifier))) { |
419 int dv = m_defaultValue; | 441 setToDefault(); |
420 if (dv < minimum()) dv = minimum(); | |
421 if (dv > maximum()) dv = maximum(); | |
422 setValue(m_defaultValue); | |
423 } else if (mouseEvent->button() == Qt::LeftButton) { | 442 } else if (mouseEvent->button() == Qt::LeftButton) { |
424 m_mousePressed = true; | 443 m_mousePressed = true; |
425 m_posMouse = mouseEvent->pos(); | 444 m_posMouse = mouseEvent->pos(); |
426 } | 445 } |
427 } | 446 } |