Mercurial > hg > svgui
comparison widgets/PropertyBox.cpp @ 1178:ed99d432dc57 levelpanwidget
Introduce level-pan widget to property box
author | Chris Cannam |
---|---|
date | Mon, 05 Dec 2016 17:13:01 +0000 |
parents | 3f5c82034f9b |
children | 7c31eb5bc77d |
comparison
equal
deleted
inserted
replaced
1177:916b62baf7ac | 1178:ed99d432dc57 |
---|---|
25 #include "base/RangeMapper.h" | 25 #include "base/RangeMapper.h" |
26 | 26 |
27 #include "AudioDial.h" | 27 #include "AudioDial.h" |
28 #include "LEDButton.h" | 28 #include "LEDButton.h" |
29 #include "IconLoader.h" | 29 #include "IconLoader.h" |
30 #include "LevelPanWidget.h" | |
30 #include "WidgetScale.h" | 31 #include "WidgetScale.h" |
31 | 32 |
32 #include "NotifyingCheckBox.h" | 33 #include "NotifyingCheckBox.h" |
33 #include "NotifyingComboBox.h" | 34 #include "NotifyingComboBox.h" |
34 #include "NotifyingPushButton.h" | 35 #include "NotifyingPushButton.h" |
202 layout->addWidget(playParamButton); | 203 layout->addWidget(playParamButton); |
203 connect(playParamButton, SIGNAL(clicked()), | 204 connect(playParamButton, SIGNAL(clicked()), |
204 this, SLOT(editPlayParameters())); | 205 this, SLOT(editPlayParameters())); |
205 } | 206 } |
206 | 207 |
207 AudioDial *gainDial = new AudioDial; | 208 LevelPanWidget *levelPan = new LevelPanWidget; |
208 layout->addWidget(gainDial); | 209 layout->addWidget(levelPan); |
209 gainDial->setMeterColor(Qt::darkRed); | 210 connect(levelPan, SIGNAL(levelChanged(float)), |
210 gainDial->setMinimum(-50); | 211 this, SLOT(playGainControlChanged(float))); |
211 gainDial->setMaximum(50); | 212 connect(levelPan, SIGNAL(panChanged(float)), |
212 gainDial->setPageStep(1); | 213 this, SLOT(playPanControlChanged(float))); |
213 gainDial->setFixedWidth(WidgetScale::scalePixelSize(24)); | 214 connect(params, SIGNAL(playGainChanged(float)), |
214 gainDial->setFixedHeight(WidgetScale::scalePixelSize(24)); | 215 levelPan, SLOT(setLevel(float))); |
215 gainDial->setNotchesVisible(false); | 216 connect(params, SIGNAL(playPanChanged(float)), |
216 gainDial->setObjectName(tr("Playback Gain")); | 217 levelPan, SLOT(setPan(float))); |
217 gainDial->setRangeMapper(new LinearRangeMapper | |
218 (-50, 50, -25, 25, tr("dB"))); | |
219 gainDial->setDefaultValue(0); | |
220 gainDial->setShowToolTip(true); | |
221 connect(gainDial, SIGNAL(valueChanged(int)), | |
222 this, SLOT(playGainDialChanged(int))); | |
223 connect(params, SIGNAL(playGainChanged(float)), | |
224 this, SLOT(playGainChanged(float))); | |
225 connect(this, SIGNAL(changePlayGainDial(int)), | |
226 gainDial, SLOT(setValue(int))); | |
227 connect(gainDial, SIGNAL(mouseEntered()), | |
228 this, SLOT(mouseEnteredWidget())); | |
229 connect(gainDial, SIGNAL(mouseLeft()), | |
230 this, SLOT(mouseLeftWidget())); | |
231 playGainChanged(params->getPlayGain()); | |
232 layout->setAlignment(gainDial, Qt::AlignVCenter); | |
233 | |
234 AudioDial *panDial = new AudioDial; | |
235 layout->addWidget(panDial); | |
236 panDial->setMeterColor(Qt::darkGreen); | |
237 panDial->setMinimum(-50); | |
238 panDial->setMaximum(50); | |
239 panDial->setPageStep(1); | |
240 panDial->setFixedWidth(WidgetScale::scalePixelSize(24)); | |
241 panDial->setFixedHeight(WidgetScale::scalePixelSize(24)); | |
242 panDial->setNotchesVisible(false); | |
243 panDial->setToolTip(tr("Playback Pan / Balance")); | |
244 panDial->setDefaultValue(0); | |
245 panDial->setObjectName(tr("Playback Pan / Balance")); | |
246 panDial->setShowToolTip(true); | |
247 connect(panDial, SIGNAL(valueChanged(int)), | |
248 this, SLOT(playPanDialChanged(int))); | |
249 connect(params, SIGNAL(playPanChanged(float)), | |
250 this, SLOT(playPanChanged(float))); | |
251 connect(this, SIGNAL(changePlayPanDial(int)), | |
252 panDial, SLOT(setValue(int))); | |
253 connect(panDial, SIGNAL(mouseEntered()), | |
254 this, SLOT(mouseEnteredWidget())); | |
255 connect(panDial, SIGNAL(mouseLeft()), | |
256 this, SLOT(mouseLeftWidget())); | |
257 playPanChanged(params->getPlayPan()); | |
258 layout->setAlignment(panDial, Qt::AlignVCenter); | |
259 | 218 |
260 } else { | 219 } else { |
261 | 220 |
262 layout->insertStretch(-1, 10); | 221 layout->insertStretch(-1, 10); |
263 } | 222 } |
706 new PlayParameterRepository::EditCommand(params); | 665 new PlayParameterRepository::EditCommand(params); |
707 command->setPlayAudible(audible); | 666 command->setPlayAudible(audible); |
708 CommandHistory::getInstance()->addCommand(command, true, true); | 667 CommandHistory::getInstance()->addCommand(command, true, true); |
709 } | 668 } |
710 } | 669 } |
711 | 670 |
712 void | 671 void |
713 PropertyBox::playGainChanged(float gain) | 672 PropertyBox::playGainControlChanged(float gain) |
714 { | |
715 int dialValue = int(lrint(log10(gain) * 20.0)); | |
716 if (dialValue < -50) dialValue = -50; | |
717 if (dialValue > 50) dialValue = 50; | |
718 emit changePlayGainDial(dialValue); | |
719 } | |
720 | |
721 void | |
722 PropertyBox::playGainDialChanged(int dialValue) | |
723 { | 673 { |
724 QObject *obj = sender(); | 674 QObject *obj = sender(); |
725 | 675 |
726 PlayParameters *params = m_container->getPlayParameters(); | 676 PlayParameters *params = m_container->getPlayParameters(); |
727 if (!params) return; | 677 if (!params) return; |
728 | |
729 float gain = float(pow(10, float(dialValue) / 20.0)); | |
730 | 678 |
731 if (params->getPlayGain() != gain) { | 679 if (params->getPlayGain() != gain) { |
732 PlayParameterRepository::EditCommand *command = | 680 PlayParameterRepository::EditCommand *command = |
733 new PlayParameterRepository::EditCommand(params); | 681 new PlayParameterRepository::EditCommand(params); |
734 command->setPlayGain(gain); | 682 command->setPlayGain(gain); |
735 CommandHistory::getInstance()->addCommand(command, true, true); | 683 CommandHistory::getInstance()->addCommand(command, true, true); |
736 } | 684 } |
737 | 685 |
738 updateContextHelp(obj); | 686 updateContextHelp(obj); |
739 } | 687 } |
740 | 688 |
741 void | 689 void |
742 PropertyBox::playPanChanged(float pan) | 690 PropertyBox::playPanControlChanged(float pan) |
743 { | |
744 int dialValue = int(lrint(pan * 50.0)); | |
745 if (dialValue < -50) dialValue = -50; | |
746 if (dialValue > 50) dialValue = 50; | |
747 emit changePlayPanDial(dialValue); | |
748 } | |
749 | |
750 void | |
751 PropertyBox::playPanDialChanged(int dialValue) | |
752 { | 691 { |
753 QObject *obj = sender(); | 692 QObject *obj = sender(); |
754 | 693 |
755 PlayParameters *params = m_container->getPlayParameters(); | 694 PlayParameters *params = m_container->getPlayParameters(); |
756 if (!params) return; | 695 if (!params) return; |
757 | |
758 float pan = float(dialValue) / 50.f; | |
759 if (pan < -1.f) pan = -1.f; | |
760 if (pan > 1.f) pan = 1.f; | |
761 | 696 |
762 if (params->getPlayPan() != pan) { | 697 if (params->getPlayPan() != pan) { |
763 PlayParameterRepository::EditCommand *command = | 698 PlayParameterRepository::EditCommand *command = |
764 new PlayParameterRepository::EditCommand(params); | 699 new PlayParameterRepository::EditCommand(params); |
765 command->setPlayPan(pan); | 700 command->setPlayPan(pan); |