Mainbar.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. * Mainbar.h
  3. * ---------
  4. * Purpose: Implementation of OpenMPT's window toolbar.
  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. #include "UpdateToolTip.h"
  12. OPENMPT_NAMESPACE_BEGIN
  13. class CStereoVU: public CStatic
  14. {
  15. protected:
  16. uint8 numChannels;
  17. uint32 vuMeter[4];
  18. DWORD lastVuUpdateTime;
  19. int lastV[4];
  20. bool lastClip[4];
  21. bool horizontal;
  22. bool allowRightToLeft;
  23. public:
  24. CStereoVU() { numChannels = 2; MemsetZero(vuMeter); lastVuUpdateTime = timeGetTime(); horizontal = true; MemsetZero(lastV); MemsetZero(lastClip); allowRightToLeft = false; }
  25. void SetVuMeter(uint8 validChannels, const uint32 channels[4], bool force=false);
  26. void SetOrientation(bool h) { horizontal = h; }
  27. protected:
  28. void DrawVuMeters(CDC &dc, bool redraw=false);
  29. void DrawVuMeter(CDC &dc, const CRect &rect, int index, bool redraw=false);
  30. protected:
  31. afx_msg void OnPaint();
  32. afx_msg void OnLButtonDown(UINT, CPoint);
  33. DECLARE_MESSAGE_MAP();
  34. };
  35. #define MIN_BASEOCTAVE 0
  36. #define MAX_BASEOCTAVE 8
  37. class CSoundFile;
  38. class CModDoc;
  39. class CModTree;
  40. class CMainFrame;
  41. class CToolBarEx: public CToolBar
  42. {
  43. protected:
  44. bool m_bVertical = false, m_bFlatButtons = false;
  45. public:
  46. CToolBarEx() {}
  47. ~CToolBarEx() override {}
  48. public:
  49. BOOL EnableControl(CWnd &wnd, UINT nIndex, UINT nHeight=0);
  50. void ChangeCtrlStyle(LONG lStyle, BOOL bSetStyle);
  51. void EnableFlatButtons(BOOL bFlat);
  52. public:
  53. //{{AFX_VIRTUAL(CToolBarEx)
  54. CSize CalcDynamicLayout(int nLength, DWORD dwMode) override;
  55. virtual void SetHorizontal();
  56. virtual void SetVertical();
  57. //}}AFX_VIRTUAL
  58. };
  59. class CMainToolBar: public CToolBarEx
  60. {
  61. protected:
  62. UpdateToolTip m_tooltip;
  63. CImageListEx m_ImageList, m_ImageListDisabled;
  64. CStatic m_EditTempo, m_EditSpeed, m_EditOctave, m_EditRowsPerBeat;
  65. CStatic m_StaticTempo, m_StaticSpeed, m_StaticRowsPerBeat;
  66. CSpinButtonCtrl m_SpinTempo, m_SpinSpeed, m_SpinOctave, m_SpinRowsPerBeat;
  67. int nCurrentSpeed, nCurrentOctave, nCurrentRowsPerBeat;
  68. TEMPO nCurrentTempo;
  69. public:
  70. CStereoVU m_VuMeter;
  71. public:
  72. CMainToolBar() {}
  73. ~CMainToolBar() override {}
  74. protected:
  75. void SetRowsPerBeat(ROWINDEX nNewRPB);
  76. public:
  77. //{{AFX_VIRTUAL(CMainToolBar)
  78. void SetHorizontal() override;
  79. void SetVertical() override;
  80. //}}AFX_VIRTUAL
  81. public:
  82. #if MPT_COMPILER_CLANG
  83. #pragma clang diagnostic push
  84. #pragma clang diagnostic ignored "-Woverloaded-virtual"
  85. #endif // MPT_COMPILER_CLANG
  86. BOOL Create(CWnd *parent);
  87. #if MPT_COMPILER_CLANG
  88. #pragma clang diagnostic pop
  89. #endif // MPT_COMPILER_CLANG
  90. void Init(CMainFrame *);
  91. UINT GetBaseOctave() const;
  92. BOOL SetBaseOctave(UINT nOctave);
  93. BOOL SetCurrentSong(CSoundFile *pModDoc);
  94. bool ShowUpdateInfo(const CString &newVersion, const CString &infoURL, bool showHighLight);
  95. void RemoveUpdateInfo();
  96. protected:
  97. //{{AFX_MSG(CMainToolBar)
  98. afx_msg void OnVScroll(UINT, UINT, CScrollBar *);
  99. afx_msg void OnTbnDropDownToolBar(NMHDR* pNMHDR, LRESULT* pResult);
  100. afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult);
  101. afx_msg void OnSelectMIDIDevice(UINT id);
  102. //}}AFX_MSG
  103. DECLARE_MESSAGE_MAP()
  104. };
  105. class CModTreeBar: public CDialogBar
  106. {
  107. protected:
  108. enum Status
  109. {
  110. MTB_VERTICAL = 0x01,
  111. MTB_CAPTURE = 0x02,
  112. MTB_DRAGGING = 0x04,
  113. MTB_TRACKER = 0x08,
  114. };
  115. DWORD m_dwStatus = 0; // MTB_XXXX
  116. UINT m_nCursorDrag = 0;
  117. CPoint ptDragging;
  118. UINT m_cxOriginal = 0, m_cyOriginal = 0, m_nTrackPos = 0;
  119. UINT m_nTreeSplitRatio = 0;
  120. public:
  121. CModTree *m_pModTree = nullptr, *m_pModTreeData = nullptr;
  122. CModTreeBar();
  123. ~CModTreeBar() override;
  124. public:
  125. void Init();
  126. void RecalcLayout();
  127. void DoMouseMove(CPoint point);
  128. void DoLButtonDown(CPoint point);
  129. void DoLButtonUp();
  130. void CancelTracking();
  131. void OnInvertTracker(UINT x);
  132. void RefreshDlsBanks();
  133. void RefreshMidiLibrary();
  134. void OnOptionsChanged();
  135. void OnDocumentCreated(CModDoc *pModDoc);
  136. void OnDocumentClosed(CModDoc *pModDoc);
  137. void OnUpdate(CModDoc *pModDoc, UpdateHint hint, CObject *pHint = nullptr);
  138. void UpdatePlayPos(CModDoc *pModDoc, Notification *pNotify);
  139. HWND GetModTreeHWND(); //rewbs.customKeys
  140. LRESULT SendMessageToModTree(UINT cmdID, WPARAM wParam, LPARAM lParam);
  141. bool SetTreeSoundfile(FileReader &file);
  142. protected:
  143. //{{AFX_VIRTUAL(CModTreeBar)
  144. CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz) override;
  145. //}}AFX_VIRTUAL
  146. protected:
  147. //{{AFX_MSG(CModTreeBar)
  148. afx_msg void OnNcPaint();
  149. afx_msg LRESULT OnNcHitTest(CPoint point);
  150. afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
  151. afx_msg void OnSize(UINT nType, int cx, int cy);
  152. afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
  153. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  154. afx_msg void OnNcLButtonDown(UINT, CPoint);
  155. afx_msg void OnLButtonDown(UINT, CPoint);
  156. afx_msg void OnNcLButtonUp(UINT, CPoint);
  157. afx_msg void OnLButtonUp(UINT, CPoint);
  158. afx_msg void OnNcRButtonDown(UINT, CPoint) { CancelTracking(); }
  159. afx_msg void OnRButtonDown(UINT, CPoint) { CancelTracking(); }
  160. afx_msg LRESULT OnInitDialog(WPARAM, LPARAM);
  161. //}}AFX_MSG
  162. DECLARE_MESSAGE_MAP()
  163. };
  164. OPENMPT_NAMESPACE_END