1
0

AbstractVstEditor.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * AbstractVstEditor.h
  3. * -------------------
  4. * Purpose: Common plugin editor interface class. This code is shared between custom and default plugin user interfaces.
  5. * Notes : (currently none)
  6. * Authors: OpenMPT Devs
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #pragma once
  10. #include "openmpt/all/BuildSettings.hpp"
  11. #ifndef NO_PLUGINS
  12. #include <vector>
  13. #include "../soundlib/Snd_defs.h"
  14. #include "Moddoc.h"
  15. OPENMPT_NAMESPACE_BEGIN
  16. class IMixPlugin;
  17. struct UpdateHint;
  18. class CAbstractVstEditor: public CDialog
  19. {
  20. protected:
  21. CMenu m_Menu;
  22. CMenu m_PresetMenu;
  23. std::vector<std::unique_ptr<CMenu>> m_presetMenuGroup;
  24. CMenu m_InputMenu;
  25. CMenu m_OutputMenu;
  26. CMenu m_MacroMenu;
  27. CMenu m_OptionsMenu;
  28. static UINT m_clipboardFormat;
  29. int32 m_currentPresetMenu = 0;
  30. int32 m_clientHeight;
  31. int m_nLearnMacro = -1;
  32. int m_nCurProg = -1;
  33. INSTRUMENTINDEX m_nInstrument;
  34. bool m_isMinimized = false;
  35. bool m_updateDisplay = false;
  36. CModDoc::NoteToChannelMap m_noteChannel; // Note -> Preview channel assignment
  37. // Adjust window size if menu bar height changes
  38. class WindowSizeAdjuster
  39. {
  40. CWnd &m_wnd;
  41. int m_menuHeight = 0;
  42. public:
  43. WindowSizeAdjuster(CWnd &wnd);
  44. ~WindowSizeAdjuster();
  45. };
  46. public:
  47. IMixPlugin &m_VstPlugin;
  48. CAbstractVstEditor(IMixPlugin &plugin);
  49. virtual ~CAbstractVstEditor();
  50. void SetupMenu(bool force = false);
  51. void SetTitle();
  52. void SetLearnMacro(int inMacro);
  53. int GetLearnMacro();
  54. void SetPreset(int32 preset);
  55. void UpdatePresetField();
  56. afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
  57. afx_msg void OnLoadPreset();
  58. afx_msg void OnSavePreset();
  59. afx_msg void OnCopyParameters();
  60. afx_msg void OnPasteParameters();
  61. afx_msg void OnRandomizePreset();
  62. afx_msg void OnRenamePlugin();
  63. afx_msg void OnSetPreset(UINT nID);
  64. afx_msg void OnBypassPlug();
  65. afx_msg void OnRecordAutomation();
  66. afx_msg void OnRecordMIDIOut();
  67. afx_msg void OnPassKeypressesToPlug();
  68. afx_msg void OnSetPreviousVSTPreset();
  69. afx_msg void OnSetNextVSTPreset();
  70. afx_msg void OnVSTPresetBackwardJump();
  71. afx_msg void OnVSTPresetForwardJump();
  72. afx_msg void OnVSTPresetRename();
  73. afx_msg void OnCreateInstrument();
  74. afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hMenu);
  75. afx_msg LRESULT OnCustomKeyMsg(WPARAM, LPARAM);
  76. afx_msg LRESULT OnMidiMsg(WPARAM, LPARAM);
  77. afx_msg void OnDropFiles(HDROP hDropInfo);
  78. afx_msg void OnMove(int x, int y);
  79. afx_msg void OnClose() { DoClose(); }
  80. // Overridden methods:
  81. void PostNcDestroy() override;
  82. void OnOK() override { DoClose(); }
  83. void OnCancel() override { DoClose(); }
  84. virtual bool OpenEditor(CWnd *parent);
  85. virtual void DoClose();
  86. virtual void UpdateParamDisplays() { if(m_updateDisplay) { SetupMenu(true); m_updateDisplay = false; } }
  87. virtual void UpdateParam(int32 /*param*/) { }
  88. virtual void UpdateView(UpdateHint hint);
  89. virtual bool IsResizable() const = 0;
  90. virtual bool SetSize(int contentWidth, int contentHeight) = 0;
  91. void UpdateDisplay() { m_updateDisplay = true; }
  92. DECLARE_MESSAGE_MAP()
  93. protected:
  94. BOOL PreTranslateMessage(MSG *msg) override;
  95. bool HandleKeyMessage(MSG &msg);
  96. void UpdatePresetMenu(bool force = false);
  97. void GeneratePresetMenu(int32 offset, CMenu &parent);
  98. void UpdateInputMenu();
  99. void UpdateOutputMenu();
  100. void UpdateMacroMenu();
  101. void UpdateOptionsMenu();
  102. INSTRUMENTINDEX GetBestInstrumentCandidate() const;
  103. bool CheckInstrument(INSTRUMENTINDEX ins) const;
  104. bool ValidateCurrentInstrument();
  105. void OnToggleEditor(UINT nID);
  106. void OnSetInputInstrument(UINT nID);
  107. afx_msg void OnInitMenu(CMenu* pMenu);
  108. void PrepareToLearnMacro(UINT nID);
  109. void OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized);
  110. void StoreWindowPos();
  111. void RestoreWindowPos();
  112. };
  113. OPENMPT_NAMESPACE_END
  114. #endif // NO_PLUGINS