1 #pragma once 2 #include "DrawCommon.h" 3 #include "CPlayerUIHelper.h" 4 5 class CUIDrawer : 6 public CDrawCommon 7 { 8 public: 9 enum SpectrumCol //绘制频谱分析的柱形数量 10 { 11 SC_64, 12 SC_32, 13 SC_16, 14 SC_8 15 }; 16 17 public: 18 CUIDrawer(UIColors& colors); 19 ~CUIDrawer(); 20 21 // 设置歌词&翻译字体 22 void SetLyricFont(CFont* lyric_font, CFont* lyric_tr_font); 23 24 void DrawLryicCommon(CRect rect, Alignment align = Alignment::AUTO, bool show_song_info = false); 25 26 int GetLyricTextHeight() const; 27 virtual void Create(CDC* pDC, CFont* pFont/* = nullptr */) override; 28 bool IsDrawMultiLine(int height) const; //根据一个高度判断是否绘制多行歌词 29 void SetForCortanaLyric(bool for_cortana_lyric = true); 30 31 // 调用绘制多行滚动歌词 32 void DrawLyricTextMultiLine(CRect rect, Alignment align = Alignment::AUTO, bool show_song_info = false); 33 // 调用以自适应绘制单双行歌词,需要提供静态变量flag以记忆双行切换状态 34 void DrawLyricTextSingleLine(CRect rect, int& flag, bool double_line = true, Alignment align = Alignment::AUTO, bool show_song_info = false); 35 36 //绘制频谱分析 37 //rect:频谱的矩形区域 38 //col:频谱的柱形的数量 39 //draw_reflex:是否绘制倒影 40 //fixed_width:每个柱形是否使用相同的宽度 41 void DrawSpectrum(CRect rect, SpectrumCol col = SC_64, bool draw_reflex = false, bool low_freq_in_center = false, bool fixed_width = false, Alignment alignment = Alignment::LEFT); 42 43 //绘制频谱分析 44 //col_width:每一个柱形的宽度 45 //gap_width:柱形间间隙的宽度 46 //cols:频谱的柱形的数量,必须为2的n次方,且小于或等于SPECTRUM_COL 47 //color:频谱分析的颜色 48 //draw_reflex:是否绘制倒影 49 //draw_peak: 是否绘制顶端 50 //sprctrum_height: 设置频谱整体的高度,大于0有效,否则使用设置中的值theApp.m_app_setting_data.sprctrum_height 51 void DrawSpectrum(CRect rect, int col_width, int gap_width, int cols, COLORREF color, bool draw_reflex = false, bool low_freq_in_center = false, Alignment alignment = Alignment::LEFT, bool draw_peak = true, int sprctrum_height = 0); 52 53 int DPI(int pixel); 54 55 private: 56 // 实际绘制双行歌词 57 void DrawLyricDoubleLine(CRect rect, LPCTSTR lyric, LPCTSTR next_lyric, Alignment align, int progress, bool switch_flag, int fade_percent = 100); 58 59 private: 60 UIColors& m_colors; 61 CFont* m_lyric_font = nullptr; 62 CFont* m_lyric_tr_font = nullptr; 63 bool m_for_cortana_lyric{ false }; //是否用于显示搜索框歌词 64 }; 65 66