SaWaterfallView.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SaWaterfallView.h - declaration of SaWaterfallView class.
  2. *
  3. * Copyright (c) 2019 Martin Pavelek <he29/dot/HS/at/gmail/dot/com>
  4. *
  5. * This file is part of LMMS - https://lmms.io
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public
  18. * License along with this program (see COPYING); if not, write to the
  19. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  20. * Boston, MA 02110-1301 USA.
  21. *
  22. */
  23. #ifndef SAWATERFALLVIEW_H
  24. #define SAWATERFALLVIEW_H
  25. #include <string>
  26. #include <utility>
  27. #include <vector>
  28. #include <QPainter>
  29. #include <QWidget>
  30. #include "SaControls.h"
  31. #include "SaProcessor.h"
  32. // Widget that displays a spectrum waterfall (spectrogram) and time labels.
  33. class SaWaterfallView : public QWidget
  34. {
  35. Q_OBJECT
  36. public:
  37. explicit SaWaterfallView(SaControls *controls, SaProcessor *processor, QWidget *_parent = 0);
  38. virtual ~SaWaterfallView() {}
  39. QSize sizeHint() const override {return QSize(400, 350);}
  40. // Check if waterfall should be displayed and adjust window size if needed.
  41. void updateVisibility();
  42. protected:
  43. void paintEvent(QPaintEvent *event) override;
  44. private slots:
  45. void periodicUpdate();
  46. private:
  47. const SaControls *m_controls;
  48. SaProcessor *m_processor;
  49. const EffectControlDialog *m_controlDialog;
  50. // Methods and data used to make time labels
  51. float m_oldTimePerLine;
  52. float timeToYPixel(float time, int height);
  53. std::vector<std::pair<float, std::string>> makeTimeTics();
  54. std::vector<std::pair<float, std::string>> m_timeTics; // 0..n (s)
  55. };
  56. #endif // SAWATERFALLVIEW_H