Skip to content

Commit

Permalink
添加树控件折叠标志图标
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongyang219 committed Aug 25, 2024
1 parent 5fc30e0 commit ec3944b
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 22 deletions.
19 changes: 9 additions & 10 deletions MusicPlayer2/CPlayerUIBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2728,28 +2728,27 @@ void CPlayerUIBase::DrawList(CRect rect, UiElement::ListElement* list_element, i
CRect rect_collapsd{ rect_item };
rect_collapsd.left = col_x + indent_space;
rect_collapsd.right = rect_collapsd.left + collapse_width;
//保存折叠标志矩形区域
if (tree_element != nullptr)
tree_element->collapsd_rects[i] = rect_collapsd;
//将折叠标志区域改为正方形
rect_collapsd.top += (rect_collapsd.Height() - collapse_width) / 2;
rect_collapsd.bottom = rect_collapsd.top + collapse_width;
//如果鼠标指向,则绘制背景
if (tree_element->collaps_indicator_hover_row == i)
{
//背景区域为矩形
CRect rect_background{ rect_collapsd };
rect_background.top += (rect_collapsd.Height() - collapse_width) / 2;
rect_background.bottom = rect_background.top + collapse_width;
BYTE alpha;
if (IsDrawBackgroundAlpha())
alpha = ALPHA_CHG(theApp.m_app_setting_data.background_transparency) * 2 / 3;
else
alpha = 255;
if (!theApp.m_app_setting_data.button_round_corners)
m_draw.FillAlphaRect(rect_background, m_colors.color_button_hover, alpha, true);
m_draw.FillAlphaRect(rect_collapsd, m_colors.color_button_hover, alpha, true);
else
m_draw.DrawRoundRect(rect_background, m_colors.color_button_hover, CalculateRoundRectRadius(rect_background), alpha);
m_draw.DrawRoundRect(rect_collapsd, m_colors.color_button_hover, CalculateRoundRectRadius(rect_collapsd), alpha);
}
//绘制折叠标志
m_draw.DrawWindowText(rect_collapsd, (tree_element->IsCollapsed(i) ? _T("+") : _T("-")), m_colors.color_text, Alignment::CENTER, true);
//保存折叠标志矩形区域
if (tree_element != nullptr)
tree_element->collapsd_rects[i] = rect_collapsd;
DrawUiIcon(rect_collapsd, (tree_element->IsCollapsed(i) ? IconMgr::IT_TreeCollapsed : IconMgr::IT_TreeExpanded));
}
indent_space += collapse_width;
}
Expand Down
4 changes: 4 additions & 0 deletions MusicPlayer2/IconMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ std::tuple<UINT, UINT, UINT, UINT> IconMgr::GetIconID(IconType type)
return { IDI_OK_D, NULL, NULL, NULL };
case IconMgr::IconType::IT_Cancel:
return { IDI_CLOSE_D, NULL, NULL, NULL };
case IconMgr::IconType::IT_TreeCollapsed:
return { IDI_TREE_COLLAPSED_D, IDI_TREE_COLLAPSED, NULL, NULL };
case IconMgr::IconType::IT_TreeExpanded:
return { IDI_TREE_EXPANDED_D, IDI_TREE_EXPANDED, NULL, NULL };
case IconMgr::IconType::IT_Default_Cover_Playing:
return { NULL, NULL, NULL, IDI_DEFAULT_COVER };
case IconMgr::IconType::IT_Default_Cover_Stopped:
Expand Down
3 changes: 3 additions & 0 deletions MusicPlayer2/IconMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class IconMgr
IT_Ok, // 圆/确认
IT_Cancel, // 叉/取消

IT_TreeCollapsed, // 折叠的树节点
IT_TreeExpanded, // 展开的树节点

IT_Default_Cover_Playing, // 默认封面(播放中)
IT_Default_Cover_Stopped, // 默认封面(已停止)

Expand Down
20 changes: 10 additions & 10 deletions MusicPlayer2/MusicPlayer2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,6 @@ END

#endif // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_FOLDER_EXPLORE ICON "res\\folder_explore.ico"

#endif // 中文(简体,中国) resources
/////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -445,6 +435,16 @@ IDI_NEW_FOLDER_D ICON "res\\new_folder_d.ico"

IDI_BACKGROUND_D ICON "res\\background_d.ico"

IDI_FOLDER_EXPLORE ICON "res\\folder_explore.ico"

IDI_TREE_COLLAPSED_D ICON "res\\tree_branch_collapsed_d.ico"

IDI_TREE_EXPANDED_D ICON "res\\tree_branch_expanded_d.ico"

IDI_TREE_COLLAPSED ICON "res\\tree_branch_collapsed.ico"

IDI_TREE_EXPANDED ICON "res\\tree_branch_expanded.ico"


/////////////////////////////////////////////////////////////////////////////
//
Expand Down
4 changes: 4 additions & 0 deletions MusicPlayer2/MusicPlayer2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,10 @@
<Image Include="res\system_titlebar_preview.bmp" />
<Image Include="res\tag.ico" />
<Image Include="res\toolbar1.bmp" />
<Image Include="res\tree_branch_collapsed.ico" />
<Image Include="res\tree_branch_collapsed_d.ico" />
<Image Include="res\tree_branch_expanded.ico" />
<Image Include="res\tree_branch_expanded_d.ico" />
<Image Include="res\unlink.ico" />
<Image Include="res\unlink_d.ico" />
<Image Include="res\up_d.ico" />
Expand Down
12 changes: 12 additions & 0 deletions MusicPlayer2/MusicPlayer2.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -2034,5 +2034,17 @@
<Image Include="res\folder_explore.ico">
<Filter>资源文件\Icons</Filter>
</Image>
<Image Include="res\tree_branch_collapsed.ico">
<Filter>资源文件\Icons</Filter>
</Image>
<Image Include="res\tree_branch_collapsed_d.ico">
<Filter>资源文件\Icons</Filter>
</Image>
<Image Include="res\tree_branch_expanded.ico">
<Filter>资源文件\Icons</Filter>
</Image>
<Image Include="res\tree_branch_expanded_d.ico">
<Filter>资源文件\Icons</Filter>
</Image>
</ItemGroup>
</Project>
Binary file added MusicPlayer2/res/tree_branch_collapsed.ico
Binary file not shown.
Binary file added MusicPlayer2/res/tree_branch_collapsed_d.ico
Binary file not shown.
Binary file added MusicPlayer2/res/tree_branch_expanded.ico
Binary file not shown.
Binary file added MusicPlayer2/res/tree_branch_expanded_d.ico
Binary file not shown.
8 changes: 6 additions & 2 deletions MusicPlayer2/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,12 @@
#define IDI_NEW_FOLDER 617
#define IDI_NEW_FOLDER_D 618
#define IDI_BACKGROUND_D 619
#define IDI_ICON1 620
#define IDI_FOLDER_EXPLORE 620
#define IDI_TREE_COLLAPSED_D 621
#define IDI_TREE_EXPANDED_D 622
#define IDI_TREE_COLLAPSED 623
#define IDI_ICON2 624
#define IDI_TREE_EXPANDED 624
#define IDC_LIST1 1002
#define IDC_PATH_LIST 1002
#define IDC_LYRIC_DOWN_LIST1 1002
Expand Down Expand Up @@ -991,7 +995,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 621
#define _APS_NEXT_RESOURCE_VALUE 625
#define _APS_NEXT_COMMAND_VALUE 33478
#define _APS_NEXT_CONTROL_VALUE 1371
#define _APS_NEXT_SYMED_VALUE 101
Expand Down

0 comments on commit ec3944b

Please sign in to comment.