ViewManager.cpp
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam and QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #include "ViewManager.h"
17 #include "base/AudioPlaySource.h"
18 #include "base/AudioRecordTarget.h"
19 #include "base/RealTime.h"
20 #include "data/model/Model.h"
21 #include "widgets/CommandHistory.h"
22 #include "View.h"
23 #include "Overview.h"
24 
25 #include "system/System.h"
26 
27 #include <QSettings>
28 #include <QApplication>
29 #include <QStyleFactory>
30 
31 #include <iostream>
32 
33 //#define DEBUG_VIEW_MANAGER 1
34 
36  m_playSource(nullptr),
37  m_recordTarget(nullptr),
38  m_globalCentreFrame(0),
39  m_globalZoom(ZoomLevel::FramesPerPixel, 1024),
40  m_playbackFrame(0),
41  m_mainModelSampleRate(0),
42  m_lastLeft(0),
43  m_lastRight(0),
44  m_inProgressExclusive(true),
45  m_toolMode(NavigateMode),
46  m_playLoopMode(false),
47  m_playSelectionMode(false),
48  m_playSoloMode(false),
49  m_alignMode(false),
50  m_overlayMode(StandardOverlays),
51  m_zoomWheelsEnabled(true),
52  m_opportunisticEditingEnabled(true),
53  m_showCentreLine(true),
54  m_illuminateLocalFeatures(true),
55  m_showWorkTitle(false),
56  m_showDuration(true),
57  m_lightPalette(QApplication::palette()),
58  m_darkPalette(QApplication::palette())
59 {
60  QSettings settings;
61  settings.beginGroup("MainWindow");
63  (settings.value("overlay-mode", int(m_overlayMode)).toInt());
64 
65  if (m_overlayMode != NoOverlays &&
69  }
70 
72  settings.value("zoom-wheels-enabled", m_zoomWheelsEnabled).toBool();
74  settings.value("show-centre-line", m_showCentreLine).toBool();
75  settings.endGroup();
76 
78  // i.e. widgets are already dark; create a light palette in
79  // case we are asked to switch to it, but don't create a dark
80  // one because it will be assigned from the actual application
81  // palette if we switch
82 
83  m_lightPalette = QPalette(QColor("#000000"), // WindowText
84  QColor("#dddfe4"), // Button
85  QColor("#ffffff"), // Light
86  QColor("#555555"), // Dark
87  QColor("#c7c7c7"), // Mid
88  QColor("#000000"), // Text
89  QColor("#ffffff"), // BrightText
90  QColor("#ffffff"), // Base
91  QColor("#efefef")); // Window
92 
93  m_lightPalette.setColor(QPalette::Highlight, Qt::darkBlue);
94  if (!OSReportsDarkThemeActive()) {
95  int r, g, b;
96  if (OSQueryAccentColour(&r, &g, &b)) {
97  m_lightPalette.setColor(QPalette::Highlight, QColor(r, g, b));
98  }
99  }
100 
101  } else {
102  // i.e. widgets are currently light; create a dark palette in
103  // case we are asked to switch to it, but don't create a light
104  // one because it will be assigned from the actual application
105  // palette if we switch
106 
107  m_darkPalette = QPalette(QColor("#f0f0f0"), // WindowText
108  QColor("#3e3e3e"), // Button
109  QColor("#808080"), // Light
110  QColor("#1e1e1e"), // Dark
111  QColor("#404040"), // Mid
112  QColor("#f0f0f0"), // Text
113  QColor("#ffffff"), // BrightText
114  QColor("#000000"), // Base
115  QColor("#202020")); // Window
116 
117  m_darkPalette.setColor(QPalette::Highlight, QColor(25, 130, 220));
118  if (OSReportsDarkThemeActive()) {
119  int r, g, b;
120  if (OSQueryAccentColour(&r, &g, &b)) {
121  m_darkPalette.setColor(QPalette::Highlight, QColor(r, g, b));
122  }
123  }
124 
125  m_darkPalette.setColor(QPalette::Link, QColor(50, 175, 255));
126  m_darkPalette.setColor(QPalette::LinkVisited, QColor(50, 175, 255));
127 
128  m_darkPalette.setColor(QPalette::Disabled, QPalette::WindowText,
129  QColor("#808080"));
130  m_darkPalette.setColor(QPalette::Disabled, QPalette::Text,
131  QColor("#808080"));
132  m_darkPalette.setColor(QPalette::Disabled, QPalette::Shadow,
133  QColor("#000000"));
134  }
135 }
136 
138 {
139 }
140 
141 sv_frame_t
143 {
144 #ifdef DEBUG_VIEW_MANAGER
145  cerr << "ViewManager::getGlobalCentreFrame: returning " << m_globalCentreFrame << endl;
146 #endif
147  return m_globalCentreFrame;
148 }
149 
150 void
152 {
153 #ifdef DEBUG_VIEW_MANAGER
154  cerr << "ViewManager::setGlobalCentreFrame to " << f << endl;
155 #endif
157  emit globalCentreFrameChanged(f);
158 }
159 
160 ZoomLevel
162 {
163 #ifdef DEBUG_VIEW_MANAGER
164  cerr << "ViewManager::getGlobalZoom: returning " << m_globalZoom << endl;
165 #endif
166  return m_globalZoom;
167 }
168 
169 sv_frame_t
171 {
172  if (isRecording()) {
173  m_playbackFrame = m_recordTarget->getRecordDuration();
174 #ifdef DEBUG_VIEW_MANAGER
175  cout << "ViewManager::getPlaybackFrame(recording) -> " << m_playbackFrame << endl;
176 #endif
177  } else if (isPlaying()) {
178  m_playbackFrame = m_playSource->getCurrentPlayingFrame();
179 #ifdef DEBUG_VIEW_MANAGER
180  cout << "ViewManager::getPlaybackFrame(playing) -> " << m_playbackFrame << endl;
181 #endif
182  } else {
183 #ifdef DEBUG_VIEW_MANAGER
184  cout << "ViewManager::getPlaybackFrame(not playing) -> " << m_playbackFrame << endl;
185 #endif
186  }
187  return m_playbackFrame;
188 }
189 
190 void
192 {
193 #ifdef DEBUG_VIEW_MANAGER
194  cerr << "ViewManager::setPlaybackFrame(" << f << ")" << endl;
195 #endif
196  if (f < 0) f = 0;
197  if (m_playbackFrame != f) {
198  m_playbackFrame = f;
199  emit playbackFrameChanged(f);
200  if (isPlaying()) {
201  m_playSource->play(f);
202  }
203  }
204 }
205 
206 ModelId
208 {
209  return m_playbackModel;
210 }
211 
212 void
214 {
215  m_playbackModel = model;
216 }
217 
218 sv_frame_t
220 {
221 #ifdef DEBUG_VIEW_MANAGER
222  cerr << "ViewManager::alignPlaybackFrameToReference(" << frame << "): playback model is " << m_playbackModel << endl;
223 #endif
224  if (m_playbackModel.isNone() || !m_alignMode) {
225  return frame;
226  } else {
227  auto playbackModel = ModelById::get(m_playbackModel);
228  if (!playbackModel) {
229  return frame;
230  }
231  sv_frame_t f = playbackModel->alignToReference(frame);
232 #ifdef DEBUG_VIEW_MANAGER
233  cerr << "aligned frame = " << f << endl;
234 #endif
235  return f;
236  }
237 }
238 
239 sv_frame_t
241 {
242 #ifdef DEBUG_VIEW_MANAGER
243  cerr << "ViewManager::alignReferenceToPlaybackFrame(" << frame << "): playback model is " << m_playbackModel << endl;
244 #endif
245  if (m_playbackModel.isNone() || !m_alignMode) {
246  return frame;
247  } else {
248  auto playbackModel = ModelById::get(m_playbackModel);
249  if (!playbackModel) {
250  return frame;
251  }
252  sv_frame_t f = playbackModel->alignFromReference(frame);
253 #ifdef DEBUG_VIEW_MANAGER
254  cerr << "aligned frame = " << f << endl;
255 #endif
256  return f;
257  }
258 }
259 
260 bool
262 {
263  return !m_inProgressSelection.isEmpty();
264 }
265 
266 const Selection &
268 {
269  exclusive = m_inProgressExclusive;
270  return m_inProgressSelection;
271 }
272 
273 void
274 ViewManager::setInProgressSelection(const Selection &selection, bool exclusive)
275 {
276  m_inProgressExclusive = exclusive;
277  m_inProgressSelection = selection;
278  if (exclusive) clearSelections();
280 }
281 
282 void
284 {
285  m_inProgressSelection = Selection();
287 }
288 
289 const MultiSelection &
291 {
292  return m_selections;
293 }
294 
295 const MultiSelection::SelectionList &
297 {
298  return m_selections.getSelections();
299 }
300 
301 void
302 ViewManager::setSelection(const Selection &selection)
303 {
304  MultiSelection ms(m_selections);
305  ms.setSelection(selection);
306  setSelections(ms);
307 }
308 
309 void
310 ViewManager::addSelection(const Selection &selection)
311 {
312  MultiSelection ms(m_selections);
313  ms.addSelection(selection);
314  setSelections(ms);
315 }
316 
317 void
318 ViewManager::addSelectionQuietly(const Selection &selection)
319 {
320  MultiSelection ms(m_selections);
321  ms.addSelection(selection);
322  setSelections(ms, true);
323 }
324 
325 void
326 ViewManager::removeSelection(const Selection &selection)
327 {
328  MultiSelection ms(m_selections);
329  ms.removeSelection(selection);
330  setSelections(ms);
331 }
332 
333 void
335 {
336  MultiSelection ms(m_selections);
337  ms.clearSelections();
338  setSelections(ms);
339 }
340 
341 void
342 ViewManager::setSelections(const MultiSelection &ms, bool quietly)
343 {
344  if (m_selections.getSelections() == ms.getSelections()) return;
345  SetSelectionCommand *command = new SetSelectionCommand(this, ms);
347  if (!quietly) {
348  emit selectionChangedByUser();
349  }
350 }
351 
352 sv_frame_t
354 {
355  MultiSelection::SelectionList sl = getSelections();
356  if (sl.empty()) return frame;
357 
358  for (MultiSelection::SelectionList::const_iterator i = sl.begin();
359  i != sl.end(); ++i) {
360 
361  if (frame < i->getEndFrame()) {
362  if (frame < i->getStartFrame()) {
363  return i->getStartFrame();
364  } else {
365  return frame;
366  }
367  }
368  }
369 
370  return sl.begin()->getStartFrame();
371 }
372 
373 void
375 {
376  emit selectionChanged();
377 }
378 
380  const MultiSelection &ms) :
381  m_vm(vm),
382  m_oldSelection(vm->m_selections),
383  m_newSelection(ms)
384 {
385 }
386 
388 
389 void
391 {
394 }
395 
396 void
398 {
401 }
402 
403 QString
405 {
406  if (m_newSelection.getSelections().empty()) return tr("Clear Selection");
407  if (m_newSelection.getSelections().size() > 1) return tr("Select Multiple Regions");
408  else return tr("Select Region");
409 }
410 
411 Selection
412 ViewManager::getContainingSelection(sv_frame_t frame, bool defaultToFollowing) const
413 {
414  return m_selections.getContainingSelection(frame, defaultToFollowing);
415 }
416 
417 void
419 {
420  m_toolMode = mode;
421 
422  emit toolModeChanged();
423 
424  switch (mode) {
425  case NavigateMode: emit activity(tr("Enter Navigate mode")); break;
426  case SelectMode: emit activity(tr("Enter Select mode")); break;
427  case EditMode: emit activity(tr("Enter Edit mode")); break;
428  case DrawMode: emit activity(tr("Enter Draw mode")); break;
429  case EraseMode: emit activity(tr("Enter Erase mode")); break;
430  case MeasureMode: emit activity(tr("Enter Measure mode")); break;
431  case NoteEditMode: emit activity(tr("Enter NoteEdit mode")); break; // GF: NoteEditMode activity (I'm not yet certain why we need to emit this.)
432  };
433 }
434 
437 {
438  if (m_toolModeOverrides.find(v) == m_toolModeOverrides.end()) {
439  return getToolMode();
440  } else {
441  return m_toolModeOverrides.find(v)->second;
442  }
443 }
444 
445 void
447 {
448  m_toolModeOverrides[v] = mode;
449 }
450 
451 void
453 {
454  m_toolModeOverrides.clear();
455 }
456 
457 void
459 {
460  if (m_playLoopMode != mode) {
461 
462  m_playLoopMode = mode;
463 
464  emit playLoopModeChanged();
465  emit playLoopModeChanged(mode);
466 
467  if (mode) emit activity(tr("Switch on Loop mode"));
468  else emit activity(tr("Switch off Loop mode"));
469  }
470 }
471 
472 void
474 {
475  if (m_playSelectionMode != mode) {
476 
477  m_playSelectionMode = mode;
478 
480  emit playSelectionModeChanged(mode);
481 
482  if (mode) emit activity(tr("Switch on Play Selection mode"));
483  else emit activity(tr("Switch off Play Selection mode"));
484  }
485 }
486 
487 void
489 {
490  if (m_playSoloMode != mode) {
491 
492  m_playSoloMode = mode;
493 
494  emit playSoloModeChanged();
495  emit playSoloModeChanged(mode);
496 
497  if (mode) emit activity(tr("Switch on Play Solo mode"));
498  else emit activity(tr("Switch off Play Solo mode"));
499  }
500 }
501 
502 void
504 {
505  if (m_alignMode != mode) {
506 
507  m_alignMode = mode;
508 
509  emit alignModeChanged();
510  emit alignModeChanged(mode);
511 
512  if (mode) emit activity(tr("Switch on Alignment mode"));
513  else emit activity(tr("Switch off Alignment mode"));
514  }
515 }
516 
517 sv_samplerate_t
519 {
520  if (m_playSource) {
521  return m_playSource->getSourceSampleRate();
522  }
523  return 0;
524 }
525 
526 sv_samplerate_t
528 {
529  if (m_playSource) {
530  return m_playSource->getDeviceSampleRate();
531  }
532  return 0;
533 }
534 
535 void
536 ViewManager::setAudioPlaySource(AudioPlaySource *source)
537 {
538  if (!m_playSource) {
539  QTimer::singleShot(100, this, SLOT(checkPlayStatus()));
540  }
541  m_playSource = source;
542 }
543 
544 void
545 ViewManager::setAudioRecordTarget(AudioRecordTarget *target)
546 {
547  if (!m_recordTarget) {
548  QTimer::singleShot(100, this, SLOT(checkPlayStatus()));
549  }
550  m_recordTarget = target;
551 }
552 
553 void
555 {
556 #ifdef DEBUG_VIEW_MANAGER
557  cerr << "ViewManager::playStatusChanged" << endl;
558 #endif
559  checkPlayStatus();
560 }
561 
562 void
563 ViewManager::recordStatusChanged(bool /* recording */)
564 {
565 #ifdef DEBUG_VIEW_MANAGER
566  cerr << "ViewManager::recordStatusChanged" << endl;
567 #endif
568  checkPlayStatus();
569 }
570 
571 void
573 {
574  if (isRecording()) {
575 
576  float left = 0, right = 0;
577  if (m_recordTarget->getInputLevels(left, right)) {
578  if (left != m_lastLeft || right != m_lastRight) {
579  emit monitoringLevelsChanged(left, right);
580  m_lastLeft = left;
581  m_lastRight = right;
582  }
583  }
584 
585  m_playbackFrame = m_recordTarget->getRecordDuration();
586 
587 #ifdef DEBUG_VIEW_MANAGER
588  cerr << "ViewManager::checkPlayStatus: Recording, frame " << m_playbackFrame << ", levels " << m_lastLeft << "," << m_lastRight << endl;
589 #endif
590 
592 
593  QTimer::singleShot(500, this, SLOT(checkPlayStatus()));
594 
595  } else if (isPlaying()) {
596 
597  float left = 0, right = 0;
598  if (m_playSource->getOutputLevels(left, right)) {
599  if (left != m_lastLeft || right != m_lastRight) {
600  emit monitoringLevelsChanged(left, right);
601  m_lastLeft = left;
602  m_lastRight = right;
603  }
604  }
605 
606  m_playbackFrame = m_playSource->getCurrentPlayingFrame();
607 
608 #ifdef DEBUG_VIEW_MANAGER
609  cerr << "ViewManager::checkPlayStatus: Playing, frame " << m_playbackFrame << ", levels " << m_lastLeft << "," << m_lastRight << endl;
610 #endif
611 
613 
614  QTimer::singleShot(20, this, SLOT(checkPlayStatus()));
615 
616  } else {
617 
618  if (m_lastLeft != 0.0 || m_lastRight != 0.0) {
619  emit monitoringLevelsChanged(0.0, 0.0);
620  m_lastLeft = 0.0;
621  m_lastRight = 0.0;
622  }
623 
624 #ifdef DEBUG_VIEW_MANAGER
625  cerr << "ViewManager::checkPlayStatus: Not playing or recording" << endl;
626 #endif
627  }
628 }
629 
630 bool
632 {
633  return m_playSource && m_playSource->isPlaying();
634 }
635 
636 bool
638 {
639  return m_recordTarget && m_recordTarget->isRecording();
640 }
641 
642 void
643 ViewManager::viewCentreFrameChanged(sv_frame_t f, bool locked,
644  PlaybackFollowMode mode)
645 {
646  View *v = dynamic_cast<View *>(sender());
647 
648 #ifdef DEBUG_VIEW_MANAGER
649  cerr << "ViewManager::viewCentreFrameChanged(" << f << ", " << locked << ", " << mode << "), view is " << v << endl;
650 #endif
651 
652  if (locked) {
654  emit globalCentreFrameChanged(f);
655  } else {
656  if (v) emit viewCentreFrameChanged(v, f);
657  }
658 
659  if (!dynamic_cast<Overview *>(v) || (mode != PlaybackIgnore)) {
660  if (m_mainModelSampleRate != 0) {
661  emit activity(tr("Scroll to %1")
662  .arg(RealTime::frame2RealTime
663  (f, m_mainModelSampleRate).toText().c_str()));
664  }
665  }
666 
667  if (mode == PlaybackScrollPageWithCentre ||
668  mode == PlaybackScrollContinuous) {
669  seek(f);
670  }
671 }
672 
673 void
674 ViewManager::seek(sv_frame_t f)
675 {
676 #ifdef DEBUG_VIEW_MANAGER
677  cerr << "ViewManager::seek(" << f << ")" << endl;
678 #endif
679 
680  if (isRecording()) {
681  // ignore
682 #ifdef DEBUG_VIEW_MANAGER
683  cerr << "ViewManager::seek: Ignoring during recording" << endl;
684 #endif
685  return;
686  }
687 
688  if (isPlaying()) {
689  sv_frame_t playFrame = m_playSource->getCurrentPlayingFrame();
690  sv_frame_t diff = std::max(f, playFrame) - std::min(f, playFrame);
691  if (diff > 20000) {
692  m_playbackFrame = f;
693  m_playSource->play(f);
694 #ifdef DEBUG_VIEW_MANAGER
695  cerr << "ViewManager::seek: reseeking from " << playFrame << " to " << f << endl;
696 #endif
697  emit playbackFrameChanged(f);
698  }
699  } else {
700  if (m_playbackFrame != f) {
701  m_playbackFrame = f;
702  emit playbackFrameChanged(f);
703  }
704  }
705 }
706 
707 void
708 ViewManager::viewZoomLevelChanged(ZoomLevel z, bool locked)
709 {
710  View *v = dynamic_cast<View *>(sender());
711 
712  if (!v) {
713  SVDEBUG << "ViewManager::viewZoomLevelChanged: WARNING: sender is not a view" << endl;
714  return;
715  }
716 
718 
719  if (locked) {
720  m_globalZoom = z;
721  }
722 
723 #ifdef DEBUG_VIEW_MANAGER
724  cerr << "ViewManager::viewZoomLevelChanged(" << v << ", " << z << ", " << locked << ")" << endl;
725 #endif
726 
727  emit viewZoomLevelChanged(v, z, locked);
728 
729  if (!dynamic_cast<Overview *>(v)) {
730  if (z.zone == ZoomLevel::FramesPerPixel) {
731  emit activity(tr("Zoom to %n sample(s) per pixel", "", z.level));
732  } else {
733  emit activity(tr("Zoom to %n pixels per sample", "", z.level));
734  }
735  }
736 }
737 
738 void
740 {
741  if (m_overlayMode != mode) {
742  m_overlayMode = mode;
743  emit overlayModeChanged();
744  emit activity(tr("Change overlay level"));
745  }
746 
747  QSettings settings;
748  settings.beginGroup("MainWindow");
749  settings.setValue("overlay-mode", int(m_overlayMode));
750  settings.endGroup();
751 }
752 
753 void
755 {
756  if (m_zoomWheelsEnabled != enabled) {
757  m_zoomWheelsEnabled = enabled;
759  if (enabled) emit activity("Show zoom wheels");
760  else emit activity("Hide zoom wheels");
761  }
762 
763  QSettings settings;
764  settings.beginGroup("MainWindow");
765  settings.setValue("zoom-wheels-enabled", m_zoomWheelsEnabled);
766  settings.endGroup();
767 }
768 
769 void
771 {
772  if (m_opportunisticEditingEnabled != enabled) {
775  }
776 }
777 
778 void
780 {
781  if (m_showCentreLine != show) {
782  m_showCentreLine = show;
783  emit showCentreLineChanged();
784  if (show) emit activity("Show centre line");
785  else emit activity("Hide centre line");
786  }
787 
788  QSettings settings;
789  settings.beginGroup("MainWindow");
790  settings.setValue("show-centre-line", int(m_showCentreLine));
791  settings.endGroup();
792 }
793 
794 void
796 {
797  // also save the current palette, in case the user has changed it
798  // since construction
799  if (getGlobalDarkBackground()) {
800  m_darkPalette = QApplication::palette();
801  } else {
802  m_lightPalette = QApplication::palette();
803  }
804 
805 #ifdef Q_OS_MAC
806  return;
807 #endif
808 
809  if (dark) {
810 
811 #ifdef Q_OS_WIN32
812  // The Windows Vista style doesn't use the palette for many of
813  // its controls. They can be styled with stylesheets, but that
814  // takes a lot of fiddly and fragile custom bits. Easier and
815  // more reliable to switch to a non-Vista style which does use
816  // the palette.
817 
818  QStyle *plainWindowsStyle = QStyleFactory::create("windows");
819  if (!plainWindowsStyle) {
820  SVCERR << "Failed to load plain Windows style" << endl;
821  } else {
822  qApp->setStyle(plainWindowsStyle);
823  }
824 #endif
825 
826  QApplication::setPalette(m_darkPalette);
827 
828  } else {
829 
830 #ifdef Q_OS_WIN32
831  // Switch back to Vista style
832 
833  QStyle *fancyWindowsStyle = QStyleFactory::create("windowsvista");
834  if (!fancyWindowsStyle) {
835  SVCERR << "Failed to load fancy Windows style" << endl;
836  } else {
837  qApp->setStyle(fancyWindowsStyle);
838  }
839 #endif
840 
841  QApplication::setPalette(m_lightPalette);
842  }
843 }
844 
845 bool
847 {
848  bool dark = false;
849  QColor windowBg = QApplication::palette().color(QPalette::Window);
850  if (windowBg.red() + windowBg.green() + windowBg.blue() < 384) {
851  dark = true;
852  }
853  return dark;
854 }
855 
856 int
858 {
859  static double ratio = 0.0;
860  if (ratio == 0.0) {
861  double baseEm;
862 #ifdef Q_OS_MAC
863  baseEm = 17.0;
864 #else
865  baseEm = 15.0;
866 #endif
867  double em = QFontMetrics(QFont()).height();
868  ratio = em / baseEm;
869 
870  SVDEBUG << "ViewManager::scalePixelSize: ratio is " << ratio
871  << " (em = " << em << ")" << endl;
872  }
873 
874  int scaled = int(pixels * ratio + 0.5);
875 // SVDEBUG << "scaledSize: " << pixels << " -> " << scaled << " at ratio " << ratio << endl;
876  if (pixels != 0 && scaled == 0) scaled = 1;
877  return scaled;
878 }
879 
void zoomWheelsEnabledChanged()
Emitted when the zoom wheels have been toggled.
void selectionChangedByUser()
Emitted when the selection has been changed through an explicit selection-editing action...
bool haveInProgressSelection() const
void playSelectionModeChanged()
Emitted when the play selection mode has been changed.
void setSelections(const MultiSelection &ms, bool quietly=false)
ModelId m_playbackModel
Definition: ViewManager.h:352
ToolMode m_toolMode
Definition: ViewManager.h:364
View scrolls continuously during playback, keeping the playback position at the centre.
Definition: ViewManager.h:44
void checkPlayStatus()
void toolModeChanged()
Emitted when the tool mode has been changed.
bool getGlobalDarkBackground() const
SetSelectionCommand(ViewManager *vm, const MultiSelection &ms)
void showCentreLineChanged()
Emitted when the centre line visibility has been changed.
Selection getContainingSelection(sv_frame_t frame, bool defaultToFollowing) const override
Return the selection that contains a given frame.
static int scalePixelSize(int pixels)
Take a "design pixel" size and scale it for the actual display.
void viewCentreFrameChanged(View *v, sv_frame_t frame)
Emitted when user scrolls a view, but doesn&#39;t affect global centre.
void setGlobalDarkBackground(bool dark)
bool m_alignMode
Definition: ViewManager.h:370
sv_frame_t getGlobalCentreFrame() const
sv_frame_t alignPlaybackFrameToReference(sv_frame_t) const override
sv_samplerate_t m_mainModelSampleRate
Definition: ViewManager.h:353
void viewZoomLevelChanged(View *v, ZoomLevel zoom, bool locked)
Emitted when a view zooms.
const MultiSelection & getSelection() const override
void addCommand(Command *command)
Add a command to the command history.
void setAudioPlaySource(AudioPlaySource *source) override
void setPlaybackModel(ModelId)
const Selection & getInProgressSelection(bool &exclusive) const
void playStatusChanged(bool playing)
void inProgressSelectionChanged()
Emitted when the in-progress (rubberbanding) selection has changed.
sv_frame_t m_globalCentreFrame
Definition: ViewManager.h:349
void removeSelection(const Selection &selection)
void addSelection(const Selection &selection)
sv_frame_t getPlaybackFrame() const
void clearSelections()
ToolMode getToolMode() const
Definition: ViewManager.h:144
AudioRecordTarget * m_recordTarget
Definition: ViewManager.h:347
sv_frame_t alignReferenceToPlaybackFrame(sv_frame_t) const override
void signalSelectionChange()
sv_samplerate_t getPlaybackSampleRate() const
The sample rate that is used for playback.
void setPlaySelectionMode(bool on)
ToolMode getToolModeFor(const View *v) const
Return override mode if it exists for this view or global mode otherwise.
sv_samplerate_t getDeviceSampleRate() const
The sample rate of the audio output device.
Selection m_inProgressSelection
Definition: ViewManager.h:359
void setOpportunisticEditingEnabled(bool enable)
Enable or disable opportunistic editing.
View follows playback page-by-page, but dragging the view relocates playback to the centre frame...
Definition: ViewManager.h:51
ZoomLevel getGlobalZoom() const
void overlayModeChanged()
Emitted when the overlay mode has been changed.
void monitoringLevelsChanged(float left, float right)
Emitted when the output or record levels change.
void setInProgressSelection(const Selection &selection, bool exclusive)
void recordStatusChanged(bool recording)
void setPlaybackFrame(sv_frame_t)
void setPlaySoloMode(bool on)
void selectionChanged()
Emitted whenever the selection has changed.
void setOverlayMode(OverlayMode mode)
PlaybackFollowMode
Definition: ViewManager.h:38
View is detached from playback.
Definition: ViewManager.h:64
bool isRecording() const
ZoomLevel m_globalZoom
Definition: ViewManager.h:350
void addSelectionQuietly(const Selection &selection)
Adding a selection normally emits the selectionChangedByUser signal.
bool m_inProgressExclusive
Definition: ViewManager.h:360
QString getName() const override
void setZoomWheelsEnabled(bool enable)
void alignModeChanged()
Emitted when the alignment mode has been changed.
static CommandHistory * getInstance()
QPalette m_lightPalette
Definition: ViewManager.h:398
void setShowCentreLine(bool show)
sv_frame_t constrainFrameToSelection(sv_frame_t frame) const override
MultiSelection m_selections
Definition: ViewManager.h:358
void playSoloModeChanged()
Emitted when the play solo mode has been changed.
OverlayMode m_overlayMode
Definition: ViewManager.h:390
void opportunisticEditingEnabledChanged()
Emitted when editing-enabled has been toggled.
void playbackFrameChanged(sv_frame_t frame)
Emitted when the playback frame changes.
AudioPlaySource * m_playSource
!! void considerZoomChange(void *, int, bool);
Definition: ViewManager.h:346
void setAudioRecordTarget(AudioRecordTarget *target) override
void clearInProgressSelection()
ModelId getPlaybackModel() const
void setSelection(const Selection &selection)
bool m_opportunisticEditingEnabled
Definition: ViewManager.h:392
View is the base class of widgets that display one or more overlaid views of data against a horizonta...
Definition: View.h:55
void setToolModeFor(const View *v, ToolMode mode)
Override the tool mode for a specific view.
float m_lastRight
Definition: ViewManager.h:356
The ViewManager manages properties that may need to be synchronised between separate Views...
Definition: ViewManager.h:78
bool m_playSelectionMode
Definition: ViewManager.h:368
QPalette m_darkPalette
Definition: ViewManager.h:399
const MultiSelection::SelectionList & getSelections() const override
void seek(sv_frame_t)
void globalCentreFrameChanged(sv_frame_t frame)
Emitted when user causes the global centre frame to change.
void setPlayLoopMode(bool on)
bool m_showCentreLine
Definition: ViewManager.h:393
bool m_playLoopMode
Definition: ViewManager.h:367
void setAlignMode(bool on)
void activity(QString)
Emitted when any loggable activity has occurred.
void playLoopModeChanged()
Emitted when the play loop mode has been changed.
virtual ~ViewManager()
bool isPlaying() const
void clearToolModeOverrides()
Clear all current view-specific overrides.
bool m_playSoloMode
Definition: ViewManager.h:369
float m_lastLeft
Definition: ViewManager.h:355
bool m_zoomWheelsEnabled
Definition: ViewManager.h:391
std::map< const View *, ToolMode > m_toolModeOverrides
Definition: ViewManager.h:365
void setToolMode(ToolMode mode)
void setGlobalCentreFrame(sv_frame_t)
sv_frame_t m_playbackFrame
Definition: ViewManager.h:351