IVideoD3DOSD.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #pragma once
  2. #include <d3d9.h>
  3. #include <d3dx9.h>
  4. #include <dxerr.h>
  5. #include "videoosd.h"
  6. #include "videooutput.h"
  7. #include "resource.h"
  8. extern HWND hMainWindow;
  9. class IVideoD3DOSD :
  10. public IVideoOSD
  11. {
  12. public:
  13. IVideoD3DOSD(void);
  14. ~IVideoD3DOSD(void);
  15. enum UI_ELEM
  16. {
  17. NO_BUTTON,
  18. PREV_BUTTON,
  19. PLAY_BUTTON,
  20. PAUSE_BUTTON,
  21. STOP_BUTTON,
  22. NEXT_BUTTON,
  23. ENDFS_BUTTON,
  24. MUTE_BUTTON,
  25. PROGRESS_FRAME,
  26. VOLUME_FRAME,
  27. PROGRESS_SLIDER,
  28. VOLUME_SLIDER
  29. };
  30. enum BUTTON_STATE
  31. {
  32. NORMAL,
  33. CLICKED,
  34. HILITE,
  35. DISABLED
  36. };
  37. void CreateOSD(IDirect3DDevice9 * device);
  38. void UpdateOSD(HWND hWnd, VideoOutput *adjuster);
  39. void DrawOSD(IDirect3DDevice9 * device);
  40. void LostOSD();
  41. void ResetOSD(IDirect3DDevice9 *device);
  42. UI_ELEM HitTest(float x, float y);
  43. bool MouseDown(int xpt, int ypt, WPARAM wParam);
  44. bool MouseMove(int xpt, int ypt, WPARAM wParam);
  45. bool MouseUp(int xpt, int ypt, WPARAM wParam);
  46. void SetScalingFactor(float x, float y);
  47. bool isOSDInited(){return isInited;}
  48. bool isOSDReadyToDraw(){return isReadyToDraw;};
  49. protected:
  50. ID3DXSprite *osdSprite;
  51. IDirect3DTexture9 *osdAtlasTexture;
  52. ID3DXFont *osdTimeFont;
  53. ID3DXFont *osdTitleFont;
  54. // Texture Src Coordinates for sprite images
  55. // Right and Bottom (last two) excluded from image
  56. RECT osdPrevButtonNormalSrcCoords;
  57. RECT osdPlayButtonNormalSrcCoords;
  58. RECT osdPauseButtonNormalSrcCoords;
  59. RECT osdStopButtonNormalSrcCoords;
  60. RECT osdNextButtonNormalSrcCoords;
  61. RECT osdProgressFrameNormalSrcCoords;
  62. RECT osdVolumeFrameNormalSrcCoords;
  63. RECT osdEndFSButtonNormalSrcCoords;
  64. RECT osdMuteButtonNormalSrcCoords;
  65. RECT osdProgressSliderNormalSrcCoords;
  66. RECT osdVolumeSliderNormalSrcCoords;
  67. RECT osdProgressProgressSrcCoords;
  68. RECT osdVolumeProgressSrcCoords;
  69. RECT osdPrevButtonClickSrcCoords;
  70. RECT osdPlayButtonClickSrcCoords;
  71. RECT osdPauseButtonClickSrcCoords;
  72. RECT osdStopButtonClickSrcCoords;
  73. RECT osdNextButtonClickSrcCoords;
  74. RECT osdEndFSButtonClickSrcCoords;
  75. RECT osdProgressSliderClickSrcCoords;
  76. RECT osdVolumeSliderClickSrcCoords;
  77. RECT osdPrevButtonDisabledSrcCoords;
  78. RECT osdNextButtonDisabledSrcCoords;
  79. // RECT osdProgressFrameDisabledSrcCoords;
  80. // RECT osdProgressSliderDisabledSrcCoords;
  81. RECT osdPrevButtonHiliteSrcCoords;
  82. RECT osdPlayButtonHiliteSrcCoords;
  83. RECT osdPauseButtonHiliteSrcCoords;
  84. RECT osdStopButtonHiliteSrcCoords;
  85. RECT osdNextButtonHiliteSrcCoords;
  86. // RECT osdProgressFrameHiliteSrcCoords;
  87. // RECT osdVolumeFrameHiliteSrcCoords;
  88. RECT osdEndFSButtonHiliteSrcCoords;
  89. RECT osdProgressSliderHiliteSrcCoords;
  90. RECT osdVolumeSliderHiliteSrcCoords;
  91. RECT osdBkgrndTextSrcCoords;
  92. RECT osdTimeRect;
  93. RECT osdTitleRect;
  94. // Position of sprites in screen coordinates
  95. // Center of sprite (where the position is mapped) is left to default to upper left corner
  96. // except for progress and volume sliders, which are mapped to their center
  97. // Note the Bkgrnd is positioned and then all other sprites are relative to that
  98. D3DXVECTOR3 osdBkgrndPosition;
  99. D3DXVECTOR3 osdPrevButtonPosition;
  100. D3DXVECTOR3 osdPlayButtonPosition;
  101. D3DXVECTOR3 osdPauseButtonPosition;
  102. D3DXVECTOR3 osdStopButtonPosition;
  103. D3DXVECTOR3 osdNextButtonPosition;
  104. D3DXVECTOR3 osdProgressFramePosition;
  105. D3DXVECTOR3 osdVolumeFramePosition;
  106. D3DXVECTOR3 osdEndFSButtonPosition;
  107. D3DXVECTOR3 osdMuteButtonPosition;
  108. D3DXVECTOR3 osdProgressSliderPosition;
  109. D3DXVECTOR3 osdVolumeSliderPosition;
  110. // Hit test rects for buttons
  111. RECT osdPrevButtonHit;
  112. RECT osdPlayButtonHit;
  113. RECT osdPauseButtonHit;
  114. RECT osdStopButtonHit;
  115. RECT osdNextButtonHit;
  116. RECT osdEndFSButtonHit;
  117. RECT osdProgressFrameHit;
  118. RECT osdVolumeFrameHit;
  119. RECT osdProgressSliderHit;
  120. RECT osdVolumeSliderHit;
  121. float xScalingFactor;
  122. float yScalingFactor;
  123. BUTTON_STATE bState[12]; // bState[0] is for NO_BUTTON
  124. bool streaming;
  125. wchar_t *displayTitle; // title displayed in osd UI
  126. wchar_t *marqueeTitleSrc; // temp string used to create displayTitle if title does not fit.
  127. size_t titleRestart; // location in title to loop back to for marquee effect
  128. bool titleFits; // indicates whether the title will fit in the UI title field
  129. DWORD dtFormat; // format of title text rect based on title size, i.e., center or left justified
  130. UI_ELEM mouseOver;
  131. UI_ELEM mouseLastOver;
  132. UI_ELEM mousePressed;
  133. UI_ELEM mouseLastPressed; // used to verify that the LMouse up event matches the LMouse down
  134. bool mouseDragging; // whether dragging is in progress to decide to update from winamp info
  135. bool isInited; // has run CreateOSD to create all the d3d objects
  136. bool isReadyToDraw; // has run UpdateOSD to init OSD for drawing, i.e., positioning the UI elements
  137. bool PointInRect(float x, float y, RECT testRect);
  138. RECT BuildHitRect(D3DXVECTOR3 position, RECT size);
  139. RECT * GetTextCoords(UI_ELEM item);
  140. };