Ctrl_gen.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * ctrl_gen.h
  3. * ----------
  4. * Purpose: General tab, upper panel.
  5. * Notes : (currently none)
  6. * Authors: Olivier Lapicque
  7. * OpenMPT Devs
  8. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  9. */
  10. #pragma once
  11. #include "openmpt/all/BuildSettings.hpp"
  12. #include "CDecimalSupport.h"
  13. OPENMPT_NAMESPACE_BEGIN
  14. namespace Util { class MultimediaClock; }
  15. class CVuMeter final : public CWnd
  16. {
  17. protected:
  18. int m_lastDisplayedLevel = -1, m_lastLevel = 0;
  19. DWORD m_lastVuUpdateTime;
  20. public:
  21. CVuMeter() { m_lastVuUpdateTime = timeGetTime(); }
  22. void SetVuMeter(int level, bool force = false);
  23. protected:
  24. void DrawVuMeter(CDC &dc, bool redraw = false);
  25. protected:
  26. afx_msg void OnPaint();
  27. DECLARE_MESSAGE_MAP();
  28. };
  29. class CCtrlGeneral final : public CModControlDlg
  30. {
  31. public:
  32. CCtrlGeneral(CModControlView &parent, CModDoc &document);
  33. Setting<LONG> &GetSplitPosRef() override { return TrackerSettings::Instance().glGeneralWindowHeight; }
  34. private:
  35. // Determine how the global volume slider should be scaled to actual global volume.
  36. // Display range for XM / S3M should be 0...64, for other formats it's 0...256.
  37. uint32 GetGlobalVolumeFactor() const
  38. {
  39. return (m_sndFile.GetType() & (MOD_TYPE_XM | MOD_TYPE_S3M)) ? uint32(MAX_SLIDER_GLOBAL_VOL / 64) : uint32(MAX_SLIDER_GLOBAL_VOL / 128);
  40. }
  41. public:
  42. CEdit m_EditTitle, m_EditArtist;
  43. CEdit m_EditSpeed, m_EditGlobalVol, m_EditRestartPos,
  44. m_EditSamplePA, m_EditVSTiVol;
  45. CNumberEdit m_EditTempo;
  46. CButton m_BtnModType;
  47. CSpinButtonCtrl m_SpinTempo, m_SpinSpeed, m_SpinGlobalVol, m_SpinRestartPos,
  48. m_SpinSamplePA, m_SpinVSTiVol;
  49. CComboBox m_CbnResampling;
  50. CSliderCtrl m_SliderTempo, m_SliderSamplePreAmp, m_SliderGlobalVol, m_SliderVSTiVol;
  51. CVuMeter m_VuMeterLeft, m_VuMeterRight;
  52. std::unique_ptr<Util::MultimediaClock> m_tapTimer;
  53. bool m_editsLocked = false;
  54. TEMPO m_tempoMin, m_tempoMax;
  55. //{{AFX_VIRTUAL(CCtrlGeneral)
  56. BOOL OnInitDialog() override;
  57. void DoDataExchange(CDataExchange *pDX) override; // DDX/DDV support
  58. void RecalcLayout() override;
  59. void UpdateView(UpdateHint hint, CObject *pObj = nullptr) override;
  60. CRuntimeClass *GetAssociatedViewClass() override;
  61. void OnActivatePage(LPARAM) override;
  62. void OnDeactivatePage() override;
  63. BOOL GetToolTipText(UINT uId, LPTSTR pszText) override;
  64. //}}AFX_VIRTUAL
  65. protected:
  66. static constexpr int MAX_SLIDER_GLOBAL_VOL = 256;
  67. static constexpr int MAX_SLIDER_VSTI_VOL = 255;
  68. static constexpr int MAX_SLIDER_SAMPLE_VOL = 255;
  69. // At this point, the tempo slider moves in more coarse steps to provide detailed values in the regions where it matters
  70. static constexpr auto TEMPO_SPLIT_THRESHOLD = TEMPO(256, 0);
  71. static constexpr int TEMPO_SPLIT_PRECISION = 3;
  72. TEMPO TempoSliderRange() const;
  73. TEMPO SliderToTempo(int value) const;
  74. int TempoToSlider(TEMPO tempo) const;
  75. //{{AFX_MSG(CCtrlGeneral)
  76. afx_msg LRESULT OnUpdatePosition(WPARAM, LPARAM);
  77. afx_msg void OnVScroll(UINT, UINT, CScrollBar *);
  78. afx_msg void OnTapTempo();
  79. afx_msg void OnTitleChanged();
  80. afx_msg void OnArtistChanged();
  81. afx_msg void OnTempoChanged();
  82. afx_msg void OnSpeedChanged();
  83. afx_msg void OnGlobalVolChanged();
  84. afx_msg void OnVSTiVolChanged();
  85. afx_msg void OnSamplePAChanged();
  86. afx_msg void OnRestartPosChanged();
  87. afx_msg void OnRestartPosDone();
  88. afx_msg void OnSongProperties();
  89. afx_msg void OnLoopSongChanged();
  90. afx_msg void OnEnSetfocusEditSongtitle();
  91. afx_msg void OnResamplingChanged();
  92. //}}AFX_MSG
  93. DECLARE_MESSAGE_MAP()
  94. };
  95. OPENMPT_NAMESPACE_END