1
0

PatternEditorDialogs.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*
  2. * PatternEditorDialogs.h
  3. * ----------------------
  4. * Purpose: Code for various dialogs that are used in the pattern editor.
  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 "dlg_misc.h" // for keyboard control
  13. #include "EffectInfo.h"
  14. #include "PatternCursor.h"
  15. #include "TrackerSettings.h"
  16. #include "ResizableDialog.h"
  17. #include "ColorPickerButton.h"
  18. OPENMPT_NAMESPACE_BEGIN
  19. class CModDoc;
  20. struct SplitKeyboardSettings;
  21. class CPatternPropertiesDlg: public CDialog
  22. {
  23. protected:
  24. CModDoc &modDoc;
  25. TempoSwing m_tempoSwing;
  26. PATTERNINDEX m_nPattern;
  27. public:
  28. CPatternPropertiesDlg(CModDoc &modParent, PATTERNINDEX nPat, CWnd *parent=NULL)
  29. : CDialog(IDD_PATTERN_PROPERTIES, parent)
  30. , modDoc(modParent)
  31. , m_nPattern(nPat)
  32. { }
  33. protected:
  34. BOOL OnInitDialog() override;
  35. void OnOK() override;
  36. afx_msg void OnHalfRowNumber();
  37. afx_msg void OnDoubleRowNumber();
  38. afx_msg void OnOverrideSignature();
  39. afx_msg void OnTempoSwing();
  40. DECLARE_MESSAGE_MAP()
  41. };
  42. //////////////////////////////////////////////////////////////////////////
  43. // Command Editing
  44. class CEditCommand: public CDialog
  45. {
  46. protected:
  47. CComboBox cbnNote, cbnInstr, cbnVolCmd, cbnCommand, cbnPlugParam;
  48. CSliderCtrl sldVolParam, sldParam;
  49. CSoundFile &sndFile;
  50. const CModSpecifications *oldSpecs = nullptr;
  51. ModCommand *m = nullptr;
  52. EffectInfo effectInfo;
  53. PATTERNINDEX editPattern = PATTERNINDEX_INVALID;
  54. CHANNELINDEX editChannel = CHANNELINDEX_INVALID;
  55. ROWINDEX editRow = ROWINDEX_INVALID;
  56. UINT xParam, xMultiplier;
  57. bool modified = false;
  58. public:
  59. CEditCommand(CSoundFile &sndFile);
  60. public:
  61. bool ShowEditWindow(PATTERNINDEX pat, const PatternCursor &cursor, CWnd *parent);
  62. protected:
  63. void InitAll() { InitNote(); InitVolume(); InitEffect(); InitPlugParam(); }
  64. void InitNote();
  65. void InitVolume();
  66. void InitEffect();
  67. void InitPlugParam();
  68. void UpdateVolCmdRange();
  69. void UpdateVolCmdValue();
  70. void UpdateEffectRange(bool set);
  71. void UpdateEffectValue(bool set);
  72. void PrepareUndo(const char *description);
  73. //{{AFX_VIRTUAL(CEditCommand)
  74. void DoDataExchange(CDataExchange *pDX) override;
  75. void OnOK() override { ShowWindow(SW_HIDE); }
  76. void OnCancel() override { ShowWindow(SW_HIDE); }
  77. BOOL PreTranslateMessage(MSG *pMsg) override;
  78. afx_msg void OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized);
  79. afx_msg void OnClose() { ShowWindow(SW_HIDE); }
  80. afx_msg void OnNoteChanged();
  81. afx_msg void OnVolCmdChanged();
  82. afx_msg void OnCommandChanged();
  83. afx_msg void OnPlugParamChanged();
  84. afx_msg void OnHScroll(UINT, UINT, CScrollBar *);
  85. //}}AFX_MSG
  86. DECLARE_MESSAGE_MAP()
  87. };
  88. /////////////////////////////////////////////////////////////////////////
  89. // Chord Editor
  90. class CChordEditor : public ResizableDialog
  91. {
  92. protected:
  93. CKeyboardControl m_Keyboard;
  94. CComboBox m_CbnShortcut, m_CbnBaseNote, m_CbnNote[MPTChord::notesPerChord - 1];
  95. MPTChords m_chords;
  96. MPTChord::NoteType m_mouseDownKey = MPTChord::noNote, m_dragKey = MPTChord::noNote;
  97. static constexpr MPTChord::NoteType CHORD_MIN = -24;
  98. static constexpr MPTChord::NoteType CHORD_MAX = 24;
  99. public:
  100. CChordEditor(CWnd *parent = nullptr);
  101. protected:
  102. MPTChord &GetChord();
  103. void DoDataExchange(CDataExchange* pDX) override;
  104. BOOL OnInitDialog() override;
  105. void OnOK() override;
  106. void UpdateKeyboard();
  107. afx_msg LRESULT OnKeyboardNotify(WPARAM, LPARAM);
  108. afx_msg void OnChordChanged();
  109. afx_msg void OnBaseNoteChanged();
  110. afx_msg void OnNote1Changed() { OnNoteChanged(0); }
  111. afx_msg void OnNote2Changed() { OnNoteChanged(1); }
  112. afx_msg void OnNote3Changed() { OnNoteChanged(2); }
  113. void OnNoteChanged(int noteIndex);
  114. DECLARE_MESSAGE_MAP()
  115. };
  116. /////////////////////////////////////////////////////////////////////////
  117. // Keyboard Split Settings (pattern editor)
  118. class CSplitKeyboardSettings : public CDialog
  119. {
  120. protected:
  121. CComboBox m_CbnSplitInstrument, m_CbnSplitNote, m_CbnOctaveModifier, m_CbnSplitVolume;
  122. CSoundFile &sndFile;
  123. public:
  124. SplitKeyboardSettings &m_Settings;
  125. CSplitKeyboardSettings(CWnd *parent, CSoundFile &sf, SplitKeyboardSettings &settings) : CDialog(IDD_KEYBOARD_SPLIT, parent), sndFile(sf), m_Settings(settings) { }
  126. protected:
  127. void DoDataExchange(CDataExchange* pDX) override;
  128. BOOL OnInitDialog() override;
  129. void OnOK() override;
  130. void OnCancel() override;
  131. afx_msg void OnOctaveModifierChanged();
  132. DECLARE_MESSAGE_MAP()
  133. };
  134. /////////////////////////////////////////////////////////////////////////
  135. // Show channel properties from pattern editor
  136. class QuickChannelProperties : public CDialog
  137. {
  138. protected:
  139. CModDoc *m_document = nullptr;
  140. CHANNELINDEX m_channel = 0;
  141. bool m_visible = false;
  142. bool m_settingsChanged = false;
  143. bool m_settingColor = false;
  144. ColorPickerButton m_colorBtn, m_colorBtnPrev, m_colorBtnNext;
  145. CSliderCtrl m_volSlider, m_panSlider;
  146. CSpinButtonCtrl m_volSpin, m_panSpin;
  147. CEdit m_nameEdit;
  148. public:
  149. QuickChannelProperties() = default;
  150. ~QuickChannelProperties();
  151. void Show(CModDoc *modDoc, CHANNELINDEX chn, CPoint position);
  152. void UpdateDisplay();
  153. CHANNELINDEX GetChannel() const { return m_channel; }
  154. protected:
  155. void DoDataExchange(CDataExchange *pDX) override;
  156. void PrepareUndo();
  157. void PickColorFromChannel(CHANNELINDEX channel);
  158. afx_msg void OnActivate(UINT nState, CWnd *, BOOL);
  159. afx_msg void OnVolChanged();
  160. afx_msg void OnPanChanged();
  161. afx_msg void OnHScroll(UINT, UINT, CScrollBar *);
  162. afx_msg void OnMuteChanged();
  163. afx_msg void OnSurroundChanged();
  164. afx_msg void OnNameChanged();
  165. afx_msg void OnPrevChannel();
  166. afx_msg void OnNextChannel();
  167. afx_msg void OnChangeColor();
  168. afx_msg void OnPickPrevColor();
  169. afx_msg void OnPickNextColor();
  170. afx_msg LRESULT OnCustomKeyMsg(WPARAM, LPARAM);
  171. afx_msg BOOL OnToolTipText(UINT, NMHDR *pNMHDR, LRESULT *pResult);
  172. BOOL PreTranslateMessage(MSG *pMsg);
  173. DECLARE_MESSAGE_MAP();
  174. };
  175. OPENMPT_NAMESPACE_END