aboutsummaryrefslogtreecommitdiff
path: root/Src/Winamp/IVideoD3DOSD.h
blob: 6a91fbbc62f54ea0ed7eb57ca8a4c594d0a4a7be (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#pragma once
#include <d3d9.h>
#include <d3dx9.h>
#include <dxerr.h>
#include "videoosd.h"
#include "videooutput.h"
#include "resource.h"

extern HWND hMainWindow;


class IVideoD3DOSD :
	public IVideoOSD
{
public:
	IVideoD3DOSD(void);
	~IVideoD3DOSD(void);

	enum UI_ELEM
	{
		NO_BUTTON,
		PREV_BUTTON,
		PLAY_BUTTON,
		PAUSE_BUTTON,
		STOP_BUTTON,
		NEXT_BUTTON,
		ENDFS_BUTTON,
		MUTE_BUTTON,
		PROGRESS_FRAME,
		VOLUME_FRAME,
		PROGRESS_SLIDER,
		VOLUME_SLIDER
	};

	enum BUTTON_STATE 
	{
	NORMAL,
	CLICKED,
	HILITE,
	DISABLED
	};

	void CreateOSD(IDirect3DDevice9 * device);
	void UpdateOSD(HWND hWnd, VideoOutput *adjuster);
	void DrawOSD(IDirect3DDevice9 * device);
	void LostOSD();
	void ResetOSD(IDirect3DDevice9 *device);
	UI_ELEM HitTest(float x, float y);
	bool MouseDown(int xpt, int ypt, WPARAM wParam);
	bool MouseMove(int xpt, int ypt, WPARAM wParam);
	bool MouseUp(int xpt, int ypt, WPARAM wParam);
	void SetScalingFactor(float x, float y);
	bool isOSDInited(){return isInited;}
	bool isOSDReadyToDraw(){return isReadyToDraw;};

protected:
	ID3DXSprite *osdSprite;
	IDirect3DTexture9 *osdAtlasTexture;
	ID3DXFont *osdTimeFont;
	ID3DXFont *osdTitleFont;

	// Texture Src Coordinates for sprite images
	// Right and Bottom (last two) excluded from image
	RECT osdPrevButtonNormalSrcCoords;
	RECT osdPlayButtonNormalSrcCoords;
	RECT osdPauseButtonNormalSrcCoords;
	RECT osdStopButtonNormalSrcCoords;
	RECT osdNextButtonNormalSrcCoords;
	RECT osdProgressFrameNormalSrcCoords;
	RECT osdVolumeFrameNormalSrcCoords;
	RECT osdEndFSButtonNormalSrcCoords;
	RECT osdMuteButtonNormalSrcCoords;
	RECT osdProgressSliderNormalSrcCoords;
	RECT osdVolumeSliderNormalSrcCoords;
	RECT osdProgressProgressSrcCoords;
	RECT osdVolumeProgressSrcCoords;

	RECT osdPrevButtonClickSrcCoords;
	RECT osdPlayButtonClickSrcCoords;
	RECT osdPauseButtonClickSrcCoords;
	RECT osdStopButtonClickSrcCoords;
	RECT osdNextButtonClickSrcCoords;
	RECT osdEndFSButtonClickSrcCoords;
	RECT osdProgressSliderClickSrcCoords;
	RECT osdVolumeSliderClickSrcCoords;

	RECT osdPrevButtonDisabledSrcCoords;
	RECT osdNextButtonDisabledSrcCoords;
//	RECT osdProgressFrameDisabledSrcCoords;
//	RECT osdProgressSliderDisabledSrcCoords;

	RECT osdPrevButtonHiliteSrcCoords;
	RECT osdPlayButtonHiliteSrcCoords;
	RECT osdPauseButtonHiliteSrcCoords;
	RECT osdStopButtonHiliteSrcCoords;
	RECT osdNextButtonHiliteSrcCoords;
//	RECT osdProgressFrameHiliteSrcCoords;
//	RECT osdVolumeFrameHiliteSrcCoords;
	RECT osdEndFSButtonHiliteSrcCoords;
	RECT osdProgressSliderHiliteSrcCoords;
	RECT osdVolumeSliderHiliteSrcCoords;

	RECT osdBkgrndTextSrcCoords;
	RECT osdTimeRect;
	RECT osdTitleRect;

	// Position of sprites in screen coordinates
	// Center of sprite (where the position is mapped) is left to default to upper left corner
    // except for progress and volume sliders, which are mapped to their center
	// Note the Bkgrnd is positioned and then all other sprites are relative to that
	D3DXVECTOR3 osdBkgrndPosition;
	D3DXVECTOR3 osdPrevButtonPosition;
	D3DXVECTOR3 osdPlayButtonPosition;
	D3DXVECTOR3 osdPauseButtonPosition;
	D3DXVECTOR3 osdStopButtonPosition;
	D3DXVECTOR3 osdNextButtonPosition;
	D3DXVECTOR3 osdProgressFramePosition;
	D3DXVECTOR3 osdVolumeFramePosition;
	D3DXVECTOR3 osdEndFSButtonPosition;
	D3DXVECTOR3 osdMuteButtonPosition;
	D3DXVECTOR3 osdProgressSliderPosition;
	D3DXVECTOR3 osdVolumeSliderPosition;

	// Hit test rects for buttons
	RECT osdPrevButtonHit;
	RECT osdPlayButtonHit;
	RECT osdPauseButtonHit;
	RECT osdStopButtonHit;
	RECT osdNextButtonHit;
	RECT osdEndFSButtonHit;
	RECT osdProgressFrameHit;
	RECT osdVolumeFrameHit;
	RECT osdProgressSliderHit;
	RECT osdVolumeSliderHit;

	float xScalingFactor; 
	float yScalingFactor;
	BUTTON_STATE bState[12];	// bState[0] is for NO_BUTTON
	bool streaming;
	wchar_t *displayTitle;		// title displayed in osd UI
	wchar_t *marqueeTitleSrc;   // temp string used to create displayTitle if title does not fit.
	size_t titleRestart;		// location in title to loop back to for marquee effect 
	bool titleFits;				// indicates whether the title will fit in the UI title field
	DWORD dtFormat;				// format of title text rect based on title size, i.e., center or left justified

	UI_ELEM mouseOver;
	UI_ELEM mouseLastOver;
	UI_ELEM mousePressed;
	UI_ELEM mouseLastPressed;	// used to verify that the LMouse up event matches the LMouse down
	bool mouseDragging;			// whether dragging is in progress to decide to update from winamp info

	bool isInited;				// has run CreateOSD to create all the d3d objects
	bool isReadyToDraw;			// has run UpdateOSD to init OSD for drawing, i.e., positioning the UI elements

	bool PointInRect(float x, float y, RECT testRect);
	RECT BuildHitRect(D3DXVECTOR3 position, RECT size);
	RECT * GetTextCoords(UI_ELEM item);
};