mirror of
https://github.com/microsoft/PowerToys
synced 2025-08-31 06:25:20 +00:00
* adding fancy zone opacity setting, enhancement #631 * applying zone opacity setting to all zones during zone selection * changing opacity setting to percentage
This commit is contained in:
@@ -68,6 +68,10 @@ public:
|
||||
}
|
||||
return GUID_NULL;
|
||||
}
|
||||
IFACEMETHODIMP_(int) GetZoneHighlightOpacity() noexcept
|
||||
{
|
||||
return m_settings->GetSettings().zoneHighlightOpacity;
|
||||
}
|
||||
|
||||
LRESULT WndProc(HWND, UINT, WPARAM, LPARAM) noexcept;
|
||||
void OnDisplayChange(DisplayChangeType changeType) noexcept;
|
||||
@@ -321,7 +325,6 @@ void FancyZones::ToggleEditor() noexcept
|
||||
monitor = MonitorFromWindow(foregroundWindow, MONITOR_DEFAULTTOPRIMARY);
|
||||
}
|
||||
|
||||
|
||||
if (!monitor)
|
||||
{
|
||||
return;
|
||||
@@ -352,7 +355,7 @@ void FancyZones::ToggleEditor() noexcept
|
||||
|
||||
const auto taskbar_x_offset = MulDiv(mi.rcWork.left - mi.rcMonitor.left, DPIAware::DEFAULT_DPI, dpi_x);
|
||||
const auto taskbar_y_offset = MulDiv(mi.rcWork.top - mi.rcMonitor.top, DPIAware::DEFAULT_DPI, dpi_y);
|
||||
|
||||
|
||||
// Do not scale window params by the dpi, that will be done in the editor - see LayoutModel.Apply
|
||||
const auto x = mi.rcMonitor.left + taskbar_x_offset;
|
||||
const auto y = mi.rcMonitor.top + taskbar_y_offset;
|
||||
|
@@ -36,6 +36,7 @@ interface __declspec(uuid("{5C8D99D6-34B2-4F4A-A8E5-7483F6869775}")) IZoneWindow
|
||||
IFACEMETHOD_(void, MoveWindowsOnActiveZoneSetChange)() = 0;
|
||||
IFACEMETHOD_(COLORREF, GetZoneHighlightColor)() = 0;
|
||||
IFACEMETHOD_(GUID, GetCurrentMonitorZoneSetId)(HMONITOR monitor) = 0;
|
||||
IFACEMETHOD_(int, GetZoneHighlightOpacity)() = 0;
|
||||
};
|
||||
|
||||
winrt::com_ptr<IFancyZones> MakeFancyZones(HINSTANCE hinstance, IFancyZonesSettings* settings) noexcept;
|
||||
|
@@ -49,6 +49,7 @@ private:
|
||||
const std::wstring m_zoneHiglightName = L"fancyzones_zoneHighlightColor";
|
||||
const std::wstring m_editorHotkeyName = L"fancyzones_editor_hotkey";
|
||||
const std::wstring m_excludedAppsName = L"fancyzones_excluded_apps";
|
||||
const std::wstring m_zoneHighlightOpacity = L"fancyzones_highlight_opacity";
|
||||
};
|
||||
|
||||
IFACEMETHODIMP_(bool) FancyZonesSettings::GetConfig(_Out_ PWSTR buffer, _Out_ int *buffer_size) noexcept
|
||||
@@ -76,6 +77,7 @@ IFACEMETHODIMP_(bool) FancyZonesSettings::GetConfig(_Out_ PWSTR buffer, _Out_ in
|
||||
settings.add_bool_toogle(setting.name, setting.resourceId, *setting.value);
|
||||
}
|
||||
|
||||
settings.add_int_spinner(m_zoneHighlightOpacity, IDS_SETTINGS_HIGHLIGHT_OPACITY, m_settings.zoneHighlightOpacity, 0, 100, 1);
|
||||
settings.add_color_picker(m_zoneHiglightName, IDS_SETTING_DESCRIPTION_ZONEHIGHLIGHTCOLOR, m_settings.zoneHightlightColor);
|
||||
settings.add_multiline_string(m_excludedAppsName, IDS_SETTING_EXCLCUDED_APPS_DESCRIPTION, m_settings.excludedApps);
|
||||
|
||||
@@ -153,6 +155,11 @@ void FancyZonesSettings::LoadSettings(PCWSTR config, bool fromFile) noexcept try
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (auto val = values.get_int_value(m_zoneHighlightOpacity))
|
||||
{
|
||||
m_settings.zoneHighlightOpacity = *val;
|
||||
}
|
||||
}
|
||||
CATCH_LOG();
|
||||
|
||||
@@ -166,6 +173,7 @@ void FancyZonesSettings::SaveSettings() noexcept try
|
||||
}
|
||||
|
||||
values.add_property(m_zoneHiglightName, m_settings.zoneHightlightColor);
|
||||
values.add_property(m_zoneHighlightOpacity, m_settings.zoneHighlightOpacity);
|
||||
values.add_property(m_editorHotkeyName, m_settings.editorHotkey.get_json());
|
||||
values.add_property(m_excludedAppsName, m_settings.excludedApps);
|
||||
|
||||
|
@@ -15,6 +15,7 @@ struct Settings
|
||||
bool appLastZone_moveWindows = false;
|
||||
bool use_cursorpos_editor_startupscreen = true;
|
||||
std::wstring zoneHightlightColor = L"#0078D7";
|
||||
int zoneHighlightOpacity = 90;
|
||||
PowerToysSettings::HotkeyObject editorHotkey = PowerToysSettings::HotkeyObject::from_settings(true, false, false, false, VK_OEM_3);
|
||||
std::wstring excludedApps = L"";
|
||||
std::vector<std::wstring> excludedAppsArray;
|
||||
|
@@ -546,8 +546,8 @@ void ZoneWindow::DrawActiveZoneSet(wil::unique_hdc& hdc, RECT const& clientRect)
|
||||
|
||||
// { fillAlpha, fill, borderAlpha, border, thickness }
|
||||
ColorSetting const colorHints { 225, RGB(81, 92, 107), 255, RGB(104, 118, 138), -2 };
|
||||
ColorSetting colorViewer { 225, 0, 255, RGB(40, 50, 60), -2 };
|
||||
ColorSetting colorHighlight { 225, 0, 255, 0, -2 };
|
||||
ColorSetting colorViewer { OpacitySettingToAlpha(m_host->GetZoneHighlightOpacity()), 0, 255, RGB(40, 50, 60), -2 };
|
||||
ColorSetting colorHighlight { OpacitySettingToAlpha(m_host->GetZoneHighlightOpacity()), 0, 255, 0, -2 };
|
||||
ColorSetting const colorFlash { 200, RGB(81, 92, 107), 200, RGB(104, 118, 138), -2 };
|
||||
|
||||
auto zones = m_activeZoneSet->GetZones();
|
||||
|
Binary file not shown.
@@ -13,3 +13,4 @@
|
||||
#define IDS_SETTING_LAUNCH_EDITOR_DESCRIPTION 113
|
||||
#define IDS_SETTING_LAUNCH_EDITOR_HOTKEY_LABEL 114
|
||||
#define IDS_SETTING_EXCLCUDED_APPS_DESCRIPTION 115
|
||||
#define IDS_SETTINGS_HIGHLIGHT_OPACITY 116
|
||||
|
@@ -133,3 +133,9 @@ inline void ParseDeviceId(PCWSTR deviceId, PWSTR parsedId, size_t size)
|
||||
StringCchCopy(parsedId, size, L"FallbackDevice");
|
||||
}
|
||||
}
|
||||
|
||||
inline int OpacitySettingToAlpha(int opacity)
|
||||
{
|
||||
// convert percentage to a 0-255 alpha value
|
||||
return opacity * 2.55;
|
||||
}
|
||||
|
@@ -22,6 +22,11 @@ namespace FancyZonesUnitTests
|
||||
{
|
||||
return m_guid;
|
||||
}
|
||||
IFACEMETHODIMP_(int)
|
||||
GetZoneHighlightOpacity() noexcept
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
GUID m_guid;
|
||||
};
|
||||
|
Reference in New Issue
Block a user