Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Maplespe committed Jan 19, 2024
1 parent 535d9d4 commit 3909574
Show file tree
Hide file tree
Showing 21 changed files with 433 additions and 106 deletions.
4 changes: 3 additions & 1 deletion Common/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ namespace MDWMBlurGlass
bool applyglobal = false;
bool extendBorder = false;
bool reflection = false;
bool oldBtnHeight = false;
int extendRound = 10;
float blurAmount = 20.f;
COLORREF activeTextColor = 0xFF000000;
COLORREF inactiveTextColor = 0xFFB4B4B4;
COLORREF titleBarBlendColor = 0x64FFFFFF;
COLORREF activeBlendColor = 0x64FFFFFF;
COLORREF inactiveBlendColor = 0x64FFFFFF;

bool isDefault()
{
Expand Down
2 changes: 1 addition & 1 deletion DWMBlurGlass/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace MDWMBlurGlass
{
inline const std::wstring g_vernum = L"1.0.1";
inline const std::wstring g_vernum = L"1.0.2";

bool MainWindow_EventProc(Mui::MWindowCtx*, Mui::UINotifyEvent event, Mui::Ctrl::UIControl* control, Mui::_m_param param);

Expand Down
61 changes: 46 additions & 15 deletions DWMBlurGlass/Page/MainPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace MDWMBlurGlass
<UICheckBox frame="0,11" text="#applyglobal" name="applyglobal" />
<UICheckBox frame="0,11" text="#extendborder" name="extendBorder" />
<UICheckBox frame="0,11" text="#reflection" name="reflection" />
<UICheckBox frame="0,11" text="#oldBtnHeight" name="oldBtnHeight" />
<UIControl frame="0,10,100,100" autoSize="true">
<UILabel frame="0,1,60,20" text="#blurvalue" />
<UISlider frame="10,0,200,16" name="blurslider" maxValue="50" />
Expand All @@ -63,11 +64,13 @@ namespace MDWMBlurGlass
<UIControl frame="0,10,100,100" autoSize="true" align="LinearH">
<UIControl frame="0,0,100,100" autoSize="true" align="LinearV">
<UILabel frame="0,11,60,20" text="#blendcolor" />
<UILabel frame="0,22,60,20" text="#activecolor" />
<UILabel frame="0,22,60,20" text="#inactiveblendcolor" />
<UILabel frame="0,20,60,20" text="#activecolor" />
<UILabel frame="0,21,60,20" text="#inactivecolor" />
</UIControl>
<UIControl frame="0,0,100,100" autoSize="true" align="LinearV">
<ColorDisplay frame="10,5,190,30" name="blendcolor" prop="cdsp" curColor="255,255,255,100" showAlpha="true" />
<ColorDisplay frame="10,5,190,30" name="activeBlendColor" prop="cdsp" curColor="255,255,255,100" showAlpha="true" />
<ColorDisplay frame="10,5,190,30" name="inactiveBlendColor" prop="cdsp" curColor="255,255,255,100" showAlpha="true" />
<ColorDisplay frame="10,5,190,30" name="activetext" prop="cdsp" curColor="0,0,0,255" />
<ColorDisplay frame="10,5,190,30" name="inactivetext" prop="cdsp" curColor="180,180,180,255" />
</UIControl>
Expand Down Expand Up @@ -177,13 +180,16 @@ namespace MDWMBlurGlass
if (InstallScheduledTasks(errinfo))
{
std::wstring err;
if (MHostGetSymbolState() && !LoadDWMExtension(err, m_ui))
bool symbolState = MHostGetSymbolState();
if (symbolState && !LoadDWMExtension(err, m_ui))
{
MessageBoxW(hWnd, (m_ui->GetStringValue(L"loadfail") + err).c_str(), L"Error", MB_ICONERROR);
return false;
}
if (symbolState)
RefreshSysConfig();
MessageBoxW(hWnd,
m_ui->GetStringValue(MHostGetSymbolState() ? L"installsucs" : L"installsucs1").c_str(),
m_ui->GetStringValue(symbolState ? L"installsucs" : L"installsucs1").c_str(),
m_ui->GetStringValue(L"install").c_str(),
MB_ICONINFORMATION
);
Expand All @@ -202,8 +208,7 @@ namespace MDWMBlurGlass
ShutdownDWMExtension(errinfo);
if (DeleteScheduledTasks(errinfo))
{
BOOL enable = TRUE;
SystemParametersInfoW(SPI_SETGRADIENTCAPTIONS, 0, &enable, SPIF_SENDCHANGE);
RefreshSysConfig();

MessageBoxW(hWnd,
m_ui->GetStringValue(L"uninstallsucs").c_str(),
Expand Down Expand Up @@ -244,6 +249,8 @@ namespace MDWMBlurGlass
std::wstring err;
if (!LoadDWMExtension(err, m_ui))
MessageBoxW(hWnd, (m_ui->GetStringValue(L"loadfail") + err).c_str(), L"Error", MB_ICONERROR);
else
RefreshSysConfig();
}
}).detach();
}
Expand Down Expand Up @@ -310,6 +317,11 @@ namespace MDWMBlurGlass
m_cfgData.reflection = static_cast<UICheckBox*>(control)->GetSel();
SetButtonEnable(true);
}
else if (_MNAME(L"oldBtnHeight"))
{
m_cfgData.oldBtnHeight = static_cast<UICheckBox*>(control)->GetSel();
SetButtonEnable(true);
}
else
ret = false;
}
Expand Down Expand Up @@ -339,12 +351,16 @@ namespace MDWMBlurGlass
{
m_cfgData.inactiveTextColor = (_m_color)param;
}
else if(_MNAME(L"blendcolor"))
else if(_MNAME(L"activeBlendColor"))
{
auto bkgnd = m_effLayer->GetBkgndStyle();
bkgnd.bkgndColor = (_m_color)param;
m_effLayer->SetBackground(bkgnd);
m_cfgData.titleBarBlendColor = (_m_color)param;
m_cfgData.activeBlendColor = (_m_color)param;
}
else if (_MNAME(L"inactiveBlendColor"))
{
m_cfgData.inactiveBlendColor = (_m_color)param;
}
else
ret = false;
Expand Down Expand Up @@ -394,6 +410,7 @@ namespace MDWMBlurGlass
m_cfgData.applyglobal = Utils::GetIniString(path, L"config", L"applyglobal") == L"true";
m_cfgData.extendBorder = Utils::GetIniString(path, L"config", L"extendBorder") == L"true";
m_cfgData.reflection = Utils::GetIniString(path, L"config", L"reflection") == L"true";
m_cfgData.oldBtnHeight = Utils::GetIniString(path, L"config", L"oldBtnHeight") == L"true";

if (!ret.empty())
m_cfgData.blurAmount = (float)Helper::M_Clamp(0.0, 50.0, _wtof(ret.data()));
Expand All @@ -406,13 +423,18 @@ namespace MDWMBlurGlass
if (!ret.empty())
m_cfgData.inactiveTextColor = (COLORREF)_wtoll(ret.data());

ret = Utils::GetIniString(path, L"config", L"titlebarBlendColor");
ret = Utils::GetIniString(path, L"config", L"activeBlendColor");
if (!ret.empty())
m_cfgData.titleBarBlendColor = (COLORREF)_wtoll(ret.data());
m_cfgData.activeBlendColor = (COLORREF)_wtoll(ret.data());

ret = Utils::GetIniString(path, L"config", L"inactiveBlendColor");
if (!ret.empty())
m_cfgData.inactiveBlendColor = (COLORREF)_wtoll(ret.data());

m_page->Child<UICheckBox>(L"applyglobal")->SetSel(m_cfgData.applyglobal);
m_page->Child<UICheckBox>(L"extendBorder")->SetSel(m_cfgData.extendBorder);
m_page->Child<UICheckBox>(L"reflection")->SetSel(m_cfgData.reflection);
m_page->Child<UICheckBox>(L"oldBtnHeight")->SetSel(m_cfgData.oldBtnHeight);

_m_color textColor = (m_cfgData.activeTextColor & 0x00FFFFFF) | 0xFF000000;
m_page->Child<UILabel>(L"sampletitle")->SetAttributeSrc(L"fontColor", textColor, false);
Expand All @@ -422,11 +444,12 @@ namespace MDWMBlurGlass
m_page->Child(L"inactivetext")->SetAttribute(L"curColor", Color::M_RGBA_STR(textColor), false);

auto bkgnd = m_effLayer->GetBkgndStyle();
bkgnd.bkgndColor = m_cfgData.titleBarBlendColor;
bkgnd.bkgndColor = m_cfgData.activeBlendColor;
m_effLayer->SetBackground(bkgnd);
m_effLayer->SetEffectValue(m_cfgData.blurAmount);

m_page->Child(L"blendcolor")->SetAttribute(L"curColor", Color::M_RGBA_STR(bkgnd.bkgndColor), false);
m_page->Child(L"activeBlendColor")->SetAttribute(L"curColor", Color::M_RGBA_STR(bkgnd.bkgndColor), false);
m_page->Child(L"inactiveBlendColor")->SetAttribute(L"curColor", Color::M_RGBA_STR(m_cfgData.inactiveBlendColor), false);

m_blurValue->SetCurValue((int)m_cfgData.blurAmount, false);
m_blurValueLabel->SetAttribute(L"text", std::to_wstring((int)m_cfgData.blurAmount), false);
Expand All @@ -439,19 +462,27 @@ namespace MDWMBlurGlass
SetIniString(path, L"config", L"applyglobal", m_cfgData.applyglobal ? L"true" : L"false");
SetIniString(path, L"config", L"extendBorder", m_cfgData.extendBorder ? L"true" : L"false");
SetIniString(path, L"config", L"reflection", m_cfgData.reflection ? L"true" : L"false");
SetIniString(path, L"config", L"oldBtnHeight", m_cfgData.oldBtnHeight ? L"true" : L"false");
SetIniString(path, L"config", L"blurAmount", std::to_wstring(m_cfgData.blurAmount));
SetIniString(path, L"config", L"activeTextColor", std::to_wstring(m_cfgData.activeTextColor));
SetIniString(path, L"config", L"inactiveTextColor", std::to_wstring(m_cfgData.inactiveTextColor));
SetIniString(path, L"config", L"titlebarBlendColor", std::to_wstring(m_cfgData.titleBarBlendColor));
SetIniString(path, L"config", L"activeBlendColor", std::to_wstring(m_cfgData.activeBlendColor));
SetIniString(path, L"config", L"inactiveBlendColor", std::to_wstring(m_cfgData.inactiveBlendColor));
}

void MainWindowPage::RefreshDWMConfig()
{
MHostNotify(MHostNotifyType::Refresh);
if(IsInstallTasks())
{
BOOL enable = TRUE;
SystemParametersInfoW(SPI_SETGRADIENTCAPTIONS, 0, &enable, SPIF_SENDCHANGE);
RefreshSysConfig();
}
}

void MainWindowPage::RefreshSysConfig()
{
BOOL enable = TRUE;
SystemParametersInfoW(SPI_SETGRADIENTCAPTIONS, 0, &enable, SPIF_SENDCHANGE);
SendNotifyMessageW(HWND_BROADCAST, WM_DWMCOLORIZATIONCOLORCHANGED, m_cfgData.activeBlendColor, 1);
}
}
1 change: 1 addition & 0 deletions DWMBlurGlass/Page/MainPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace MDWMBlurGlass
void SaveConfig(std::wstring_view path);

void RefreshDWMConfig();
void RefreshSysConfig();

Ctrl::UIEffectLayer* m_effLayer = nullptr;
Ctrl::UISlider* m_blurValue = nullptr;
Expand Down
Binary file modified DWMBlurGlass/Resource.rc
Binary file not shown.
2 changes: 1 addition & 1 deletion DWMBlurGlass/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
return 0;
}

auto context = engine.CreateWindowCtx({ 0,0,500,588 }, MWindowType::Normal,
auto context = engine.CreateWindowCtx({ 0,0,500,648 }, MWindowType::Normal,
L"DWMBlurGlass " + MDWMBlurGlass::g_vernum, true, true, 0, WS_EX_NOREDIRECTIONBITMAP);
if(!context)
{
Expand Down
Loading

0 comments on commit 3909574

Please sign in to comment.