xref: /MusicPlayer2/MusicPlayer2/CortanaLyric.h (revision 707992f6ac3e145ee5bce35ee9c2fc0f36e01ca7)
1 #pragma once
2 #include "ColorConvert.h"
3 #include "MusicPlayer2.h"
4 #include "CUIDrawer.h"
5 
6 #define LIGHT_MODE_SEARCH_BOX_BACKGROUND_COLOR RGB(240, 240, 240)
7 #define SEARCH_BOX_DEFAULT_TRANSPARENT_COLOR RGB(255, 0, 255)
8 class CCortanaLyric
9 {
10 public:
11     CCortanaLyric();
12     ~CCortanaLyric();
13 
14     void Init();	//初始化,获取Cortana句柄、矩形区域等
15     static void InitFont();
16     void SetEnable(bool enable);
17 
18     void DrawInfo();
19 
20     void ResetCortanaText();		//将Cortana搜索框的文本恢复为默认
21     void AlbumCoverEnable(bool enable);
22     void SetBeatAmp(int beat_amp);
23     void SetUIColors();
24     void SetDarkMode(bool dark_mode);		//设置搜索框是否为黑色模式
25     void ApplySearchBoxTransparentChanged();
26 
27     bool IsSearchBoxAvailable() const;
28 
29 private:
30     struct CortanaUIColors		//界面颜色
31     {
32         COLORREF text_color;		//已播放歌词的颜色
33         COLORREF text_color2;		//未播放歌词的颜色
34         COLORREF info_text_color;	//歌曲信息文本的颜色
35         COLORREF back_color;		//背景色
36         //COLORREF sprctrum_color;
37         bool dark;			//是否使用深色作为背景色绘制
38     };
39 
40 private:
41 	void SetCortanaBarOpaque(bool opaque);
42 
43     //在Cortana搜索框上绘制文本
44     //str:	要绘制的字符串
45     //align:	对齐方式
46     void DrawCortanaTextSimple(LPCTSTR str, Alignment align);
47 
48     /* 在Cortana搜索框上绘制滚动显示的文本
49     参数:
50     	str:	要绘制的字符串
51     	reset:	如果为true则重置滚动位置
52     	scroll_pixel:	文本滚动一次移动的像素值(这个值越大则滚动越快)
53     */
54     void DrawCortanaText(LPCTSTR str, bool reset, double scroll_pixel);
55 
56     /* 在Cortana搜索框上绘制动态显示歌词的文本
57     参数:
58     	str:	要绘制的字符串
59     	progress:	当前歌词的进度(范围为0~1000)
60     */
61     void DrawCortanaText(LPCTSTR str, int progress);
62 
63     void DrawAlbumCover(const CImage& album_cover);
64 
65     void DrawSpectrum();
66 
67     CRect TextRect() const;
68     CRect CoverRect() const;
69 
70 private:
71     bool m_enable;
72 	HWND m_hCortanaBar{};		////Cortana栏的句柄
73     HWND m_cortana_hwnd{};		//Cortana的句柄
74     HWND m_hCortanaStatic;
75     wstring m_cortana_default_text;	//Cortana搜索框中原来的文本
76     CUIDrawer m_draw{ m_lyric_colors };		//用于在Cortana搜索框中绘图的对象
77     CWnd* m_cortana_wnd{};		//Cortana搜索框的指针
78     CFont m_default_font;		//在Cortana搜索框中原来的字体
79     CRect m_cortana_rect;		//Cortana搜索框框的矩形区域
80     int m_cover_width;
81     CDC* m_pDC{};				//在Cortana搜索框中绘图的DC
82 
83     bool m_dark_mode{ true };			//Cortana搜索框是否处于深色模式
84 
85     //CPoint m_check_dark_point{};			//用于判断Cortana搜索框是否为深色模式的点的位置
86     //COLORREF m_back_color;
87     const COLORREF m_border_color{ GRAY(180) };		//浅色模式时边框的颜色
88 
89     CortanaUIColors m_colors;
90     UIColors m_lyric_colors;
91 
92     bool m_show_album_cover{ false };			//是否在Cortana图标处显示专辑封面
93     int m_beat_amp{0};						//小娜图标跳动的幅值,取值为0~1000
94 
95     bool m_cortana_opaque{ false };           //是否设置了搜索框不透明
96 
97     static CCriticalSection m_critical;
98 
99 public:
100     //bool m_cortana_disabled;
101 };
102 
103