comparison widgets/LevelPanWidget.cpp @ 1249:8ef67917c301

Ctrl-click, and middle-button click, on level-pan widget reset to default (not implemented yet for level-pan tool button though)
author Chris Cannam
date Tue, 28 Feb 2017 14:20:56 +0000
parents a68c25ba1153
children c49a48fcc364
comparison
equal deleted inserted replaced
1248:fc40742bb911 1249:8ef67917c301
38 m_level(maxLevel), 38 m_level(maxLevel),
39 m_pan(0), 39 m_pan(0),
40 m_monitorLeft(-1), 40 m_monitorLeft(-1),
41 m_monitorRight(-1), 41 m_monitorRight(-1),
42 m_editable(true), 42 m_editable(true),
43 m_editing(false),
43 m_includeMute(true) 44 m_includeMute(true)
44 { 45 {
45 setToolTip(tr("Drag vertically to adjust level, horizontally to adjust pan")); 46 setToolTip(tr("Drag vertically to adjust level, horizontally to adjust pan"));
46 setLevel(1.0); 47 setLevel(1.0);
47 setPan(0.0); 48 setPan(0.0);
48 } 49 }
49 50
50 LevelPanWidget::~LevelPanWidget() 51 LevelPanWidget::~LevelPanWidget()
51 { 52 {
53 }
54
55 void
56 LevelPanWidget::setToDefault()
57 {
58 setLevel(1.0);
59 setPan(0.0);
52 } 60 }
53 61
54 QSize 62 QSize
55 LevelPanWidget::sizeHint() const 63 LevelPanWidget::sizeHint() const
56 { 64 {
209 } 217 }
210 218
211 void 219 void
212 LevelPanWidget::mousePressEvent(QMouseEvent *e) 220 LevelPanWidget::mousePressEvent(QMouseEvent *e)
213 { 221 {
222 if (e->button() == Qt::MidButton ||
223 ((e->button() == Qt::LeftButton) &&
224 (e->modifiers() & Qt::ControlModifier))) {
225 setToDefault();
226 } else if (e->button() == Qt::LeftButton) {
227 m_editing = true;
228 mouseMoveEvent(e);
229 }
230 }
231
232 void
233 LevelPanWidget::mouseReleaseEvent(QMouseEvent *e)
234 {
214 mouseMoveEvent(e); 235 mouseMoveEvent(e);
236 m_editing = false;
215 } 237 }
216 238
217 void 239 void
218 LevelPanWidget::mouseMoveEvent(QMouseEvent *e) 240 LevelPanWidget::mouseMoveEvent(QMouseEvent *e)
219 { 241 {
220 if (!m_editable) return; 242 if (!m_editable) return;
243 if (!m_editing) return;
221 244
222 int level, pan; 245 int level, pan;
223 toCell(rect(), e->pos(), level, pan); 246 toCell(rect(), e->pos(), level, pan);
224 if (level == m_level && pan == m_pan) { 247 if (level == m_level && pan == m_pan) {
225 return; 248 return;
231 if (pan != m_pan) { 254 if (pan != m_pan) {
232 m_pan = pan; 255 m_pan = pan;
233 emitPanChanged(); 256 emitPanChanged();
234 } 257 }
235 update(); 258 update();
236 }
237
238 void
239 LevelPanWidget::mouseReleaseEvent(QMouseEvent *e)
240 {
241 mouseMoveEvent(e);
242 } 259 }
243 260
244 void 261 void
245 LevelPanWidget::wheelEvent(QWheelEvent *e) 262 LevelPanWidget::wheelEvent(QWheelEvent *e)
246 { 263 {