[FancyZones] Zone Number Settings (#14910)

This commit is contained in:
Davide Giacometti
2021-12-20 17:50:51 +01:00
committed by GitHub
parent 3805348afd
commit 288e0487a0
17 changed files with 208 additions and 73 deletions

View File

@@ -874,7 +874,7 @@ void FancyZones::AddWorkArea(HMONITOR monitor, const std::wstring& deviceId) noe
parentId = parentArea->UniqueId(); parentId = parentArea->UniqueId();
} }
auto workArea = MakeWorkArea(m_hinstance, monitor, uniqueId, parentId, GetZoneColors(), m_settings->GetSettings()->overlappingZonesAlgorithm); auto workArea = MakeWorkArea(m_hinstance, monitor, uniqueId, parentId, GetZoneColors(), m_settings->GetSettings()->overlappingZonesAlgorithm, m_settings->GetSettings()->showZoneNumber);
if (workArea) if (workArea)
{ {
m_workAreaHandler.AddWorkArea(m_currentDesktopId, monitor, workArea); m_workAreaHandler.AddWorkArea(m_currentDesktopId, monitor, workArea);
@@ -1394,13 +1394,14 @@ ZoneColors FancyZones::GetZoneColors() const noexcept
if (m_settings->GetSettings()->systemTheme) if (m_settings->GetSettings()->systemTheme)
{ {
GetSystemTheme(); GetSystemTheme();
auto textColor = currentBackgroundColor == RGB(0, 0, 0) ? RGB(255, 255, 255) : RGB(0, 0, 0); auto numberColor = currentBackgroundColor == RGB(0, 0, 0) ? RGB(255, 255, 255) : RGB(0, 0, 0);
return ZoneColors{ return ZoneColors{
.primaryColor = currentBackgroundColor, .primaryColor = currentBackgroundColor,
.borderColor = currentAccentColor, .borderColor = currentAccentColor,
.highlightColor = currentAccentColor, .highlightColor = currentAccentColor,
.textColor = textColor, .numberColor = numberColor,
.highlightOpacity = m_settings->GetSettings()->zoneHighlightOpacity .highlightOpacity = m_settings->GetSettings()->zoneHighlightOpacity
}; };
} }
@@ -1410,7 +1411,7 @@ ZoneColors FancyZones::GetZoneColors() const noexcept
.primaryColor = FancyZonesUtils::HexToRGB(m_settings->GetSettings()->zoneColor), .primaryColor = FancyZonesUtils::HexToRGB(m_settings->GetSettings()->zoneColor),
.borderColor = FancyZonesUtils::HexToRGB(m_settings->GetSettings()->zoneBorderColor), .borderColor = FancyZonesUtils::HexToRGB(m_settings->GetSettings()->zoneBorderColor),
.highlightColor = FancyZonesUtils::HexToRGB(m_settings->GetSettings()->zoneHighlightColor), .highlightColor = FancyZonesUtils::HexToRGB(m_settings->GetSettings()->zoneHighlightColor),
.textColor = RGB(0, 0, 0), .numberColor = FancyZonesUtils::HexToRGB(m_settings->GetSettings()->zoneNumberColor),
.highlightOpacity = m_settings->GetSettings()->zoneHighlightOpacity .highlightOpacity = m_settings->GetSettings()->zoneHighlightOpacity
}; };
} }

View File

@@ -266,4 +266,10 @@
<data name="Setting_Description_System_Theme" xml:space="preserve"> <data name="Setting_Description_System_Theme" xml:space="preserve">
<value>Use system theme</value> <value>Use system theme</value>
</data> </data>
<data name="Setting_Description_Zone_Number_Color" xml:space="preserve">
<value>Zone number color (Default #000000)</value>
</data>
<data name="Setting_Description_Show_Zone_Number" xml:space="preserve">
<value>Show zone number</value>
</data>
</root> </root>

View File

@@ -28,16 +28,18 @@ namespace NonLocalizable
const wchar_t SpanZonesAcrossMonitorsID[] = L"fancyzones_span_zones_across_monitors"; const wchar_t SpanZonesAcrossMonitorsID[] = L"fancyzones_span_zones_across_monitors";
const wchar_t MakeDraggedWindowTransparentID[] = L"fancyzones_makeDraggedWindowTransparent"; const wchar_t MakeDraggedWindowTransparentID[] = L"fancyzones_makeDraggedWindowTransparent";
const wchar_t SystemTheme[] = L"fancyzones_systemTheme"; const wchar_t SystemThemeID[] = L"fancyzones_systemTheme";
const wchar_t ZoneColorID[] = L"fancyzones_zoneColor"; const wchar_t ZoneColorID[] = L"fancyzones_zoneColor";
const wchar_t ZoneBorderColorID[] = L"fancyzones_zoneBorderColor"; const wchar_t ZoneBorderColorID[] = L"fancyzones_zoneBorderColor";
const wchar_t ZoneHighlightColorID[] = L"fancyzones_zoneHighlightColor"; const wchar_t ZoneHighlightColorID[] = L"fancyzones_zoneHighlightColor";
const wchar_t ZoneNumberColorID[] = L"fancyzones_zoneNumberColor";
const wchar_t EditorHotkeyID[] = L"fancyzones_editor_hotkey"; const wchar_t EditorHotkeyID[] = L"fancyzones_editor_hotkey";
const wchar_t WindowSwitchingToggleID[] = L"fancyzones_windowSwitching"; const wchar_t WindowSwitchingToggleID[] = L"fancyzones_windowSwitching";
const wchar_t NextTabHotkeyID[] = L"fancyzones_nextTab_hotkey"; const wchar_t NextTabHotkeyID[] = L"fancyzones_nextTab_hotkey";
const wchar_t PrevTabHotkeyID[] = L"fancyzones_prevTab_hotkey"; const wchar_t PrevTabHotkeyID[] = L"fancyzones_prevTab_hotkey";
const wchar_t ExcludedAppsID[] = L"fancyzones_excluded_apps"; const wchar_t ExcludedAppsID[] = L"fancyzones_excluded_apps";
const wchar_t ZoneHighlightOpacityID[] = L"fancyzones_highlight_opacity"; const wchar_t ZoneHighlightOpacityID[] = L"fancyzones_highlight_opacity";
const wchar_t ShowZoneNumberID[] = L"fancyzones_showZoneNumber";
const wchar_t ToggleEditorActionID[] = L"ToggledFZEditor"; const wchar_t ToggleEditorActionID[] = L"ToggledFZEditor";
const wchar_t IconKeyID[] = L"pt-fancy-zones"; const wchar_t IconKeyID[] = L"pt-fancy-zones";
@@ -81,7 +83,7 @@ private:
PCWSTR name; PCWSTR name;
bool* value; bool* value;
int resourceId; int resourceId;
} m_configBools[18] = { } m_configBools[19] = {
{ NonLocalizable::ShiftDragID, &m_settings.shiftDrag, IDS_SETTING_DESCRIPTION_SHIFTDRAG }, { NonLocalizable::ShiftDragID, &m_settings.shiftDrag, IDS_SETTING_DESCRIPTION_SHIFTDRAG },
{ NonLocalizable::MouseSwitchID, &m_settings.mouseSwitch, IDS_SETTING_DESCRIPTION_MOUSESWITCH }, { NonLocalizable::MouseSwitchID, &m_settings.mouseSwitch, IDS_SETTING_DESCRIPTION_MOUSESWITCH },
{ NonLocalizable::OverrideSnapHotKeysID, &m_settings.overrideSnapHotkeys, IDS_SETTING_DESCRIPTION_OVERRIDE_SNAP_HOTKEYS }, { NonLocalizable::OverrideSnapHotKeysID, &m_settings.overrideSnapHotkeys, IDS_SETTING_DESCRIPTION_OVERRIDE_SNAP_HOTKEYS },
@@ -99,7 +101,8 @@ private:
{ NonLocalizable::SpanZonesAcrossMonitorsID, &m_settings.spanZonesAcrossMonitors, IDS_SETTING_DESCRIPTION_SPAN_ZONES_ACROSS_MONITORS }, { NonLocalizable::SpanZonesAcrossMonitorsID, &m_settings.spanZonesAcrossMonitors, IDS_SETTING_DESCRIPTION_SPAN_ZONES_ACROSS_MONITORS },
{ NonLocalizable::MakeDraggedWindowTransparentID, &m_settings.makeDraggedWindowTransparent, IDS_SETTING_DESCRIPTION_MAKE_DRAGGED_WINDOW_TRANSPARENT }, { NonLocalizable::MakeDraggedWindowTransparentID, &m_settings.makeDraggedWindowTransparent, IDS_SETTING_DESCRIPTION_MAKE_DRAGGED_WINDOW_TRANSPARENT },
{ NonLocalizable::WindowSwitchingToggleID, &m_settings.windowSwitching, IDS_SETTING_WINDOW_SWITCHING_TOGGLE_LABEL }, { NonLocalizable::WindowSwitchingToggleID, &m_settings.windowSwitching, IDS_SETTING_WINDOW_SWITCHING_TOGGLE_LABEL },
{ NonLocalizable::SystemTheme, &m_settings.systemTheme, IDS_SETTING_DESCRIPTION_SYSTEM_THEME }, { NonLocalizable::SystemThemeID, &m_settings.systemTheme, IDS_SETTING_DESCRIPTION_SYSTEM_THEME },
{ NonLocalizable::ShowZoneNumberID, &m_settings.showZoneNumber, IDS_SETTING_DESCRIPTION_SHOW_ZONE_NUMBER },
}; };
}; };
@@ -185,6 +188,11 @@ void FancyZonesSettings::LoadSettings(PCWSTR config, bool fromFile) noexcept
m_settings.zoneHighlightColor = std::move(*val); m_settings.zoneHighlightColor = std::move(*val);
} }
if (auto val = values.get_string_value(NonLocalizable::ZoneNumberColorID))
{
m_settings.zoneNumberColor = std::move(*val);
}
if (const auto val = values.get_json(NonLocalizable::EditorHotkeyID)) if (const auto val = values.get_json(NonLocalizable::EditorHotkeyID))
{ {
m_settings.editorHotkey = PowerToysSettings::HotkeyObject::from_json(*val); m_settings.editorHotkey = PowerToysSettings::HotkeyObject::from_json(*val);
@@ -261,6 +269,7 @@ void FancyZonesSettings::SaveSettings() noexcept
values.add_property(NonLocalizable::ZoneColorID, m_settings.zoneColor); values.add_property(NonLocalizable::ZoneColorID, m_settings.zoneColor);
values.add_property(NonLocalizable::ZoneBorderColorID, m_settings.zoneBorderColor); values.add_property(NonLocalizable::ZoneBorderColorID, m_settings.zoneBorderColor);
values.add_property(NonLocalizable::ZoneHighlightColorID, m_settings.zoneHighlightColor); values.add_property(NonLocalizable::ZoneHighlightColorID, m_settings.zoneHighlightColor);
values.add_property(NonLocalizable::ZoneNumberColorID, m_settings.zoneNumberColor);
values.add_property(NonLocalizable::ZoneHighlightOpacityID, m_settings.zoneHighlightOpacity); values.add_property(NonLocalizable::ZoneHighlightOpacityID, m_settings.zoneHighlightOpacity);
values.add_property(NonLocalizable::OverlappingZonesAlgorithmID, (int)m_settings.overlappingZonesAlgorithm); values.add_property(NonLocalizable::OverlappingZonesAlgorithmID, (int)m_settings.overlappingZonesAlgorithm);
values.add_property(NonLocalizable::EditorHotkeyID, m_settings.editorHotkey.get_json()); values.add_property(NonLocalizable::EditorHotkeyID, m_settings.editorHotkey.get_json());

View File

@@ -33,9 +33,11 @@ struct Settings
bool spanZonesAcrossMonitors = false; bool spanZonesAcrossMonitors = false;
bool makeDraggedWindowTransparent = true; bool makeDraggedWindowTransparent = true;
bool systemTheme = true; bool systemTheme = true;
bool showZoneNumber = true;
std::wstring zoneColor = L"#AACDFF"; std::wstring zoneColor = L"#AACDFF";
std::wstring zoneBorderColor = L"#FFFFFF"; std::wstring zoneBorderColor = L"#FFFFFF";
std::wstring zoneHighlightColor = L"#008CFF"; std::wstring zoneHighlightColor = L"#008CFF";
std::wstring zoneNumberColor = L"#000000";
int zoneHighlightOpacity = 50; int zoneHighlightOpacity = 50;
OverlappingZonesAlgorithm overlappingZonesAlgorithm = OverlappingZonesAlgorithm::Smallest; OverlappingZonesAlgorithm overlappingZonesAlgorithm = OverlappingZonesAlgorithm::Smallest;
PowerToysSettings::HotkeyObject editorHotkey = PowerToysSettings::HotkeyObject::from_settings(true, false, false, true, VK_OEM_3); PowerToysSettings::HotkeyObject editorHotkey = PowerToysSettings::HotkeyObject::from_settings(true, false, false, true, VK_OEM_3);

View File

@@ -109,7 +109,7 @@ public:
WorkArea(HINSTANCE hinstance); WorkArea(HINSTANCE hinstance);
~WorkArea(); ~WorkArea();
bool Init(HINSTANCE hinstance, HMONITOR monitor, const FancyZonesDataTypes::DeviceIdData& uniqueId, const FancyZonesDataTypes::DeviceIdData& parentUniqueId, const ZoneColors& zoneColors, OverlappingZonesAlgorithm overlappingAlgorithm); bool Init(HINSTANCE hinstance, HMONITOR monitor, const FancyZonesDataTypes::DeviceIdData& uniqueId, const FancyZonesDataTypes::DeviceIdData& parentUniqueId, const ZoneColors& zoneColors, OverlappingZonesAlgorithm overlappingAlgorithm, const bool showZoneText);
IFACEMETHODIMP MoveSizeEnter(HWND window) noexcept; IFACEMETHODIMP MoveSizeEnter(HWND window) noexcept;
IFACEMETHODIMP MoveSizeUpdate(POINT const& ptScreen, bool dragEnabled, bool selectManyZones) noexcept; IFACEMETHODIMP MoveSizeUpdate(POINT const& ptScreen, bool dragEnabled, bool selectManyZones) noexcept;
@@ -172,6 +172,7 @@ private:
std::unique_ptr<ZonesOverlay> m_zonesOverlay; std::unique_ptr<ZonesOverlay> m_zonesOverlay;
ZoneColors m_zoneColors; ZoneColors m_zoneColors;
OverlappingZonesAlgorithm m_overlappingAlgorithm; OverlappingZonesAlgorithm m_overlappingAlgorithm;
bool m_showZoneText;
}; };
WorkArea::WorkArea(HINSTANCE hinstance) WorkArea::WorkArea(HINSTANCE hinstance)
@@ -190,10 +191,11 @@ WorkArea::~WorkArea()
windowPool.FreeZonesOverlayWindow(m_window); windowPool.FreeZonesOverlayWindow(m_window);
} }
bool WorkArea::Init(HINSTANCE hinstance, HMONITOR monitor, const FancyZonesDataTypes::DeviceIdData& uniqueId, const FancyZonesDataTypes::DeviceIdData& parentUniqueId, const ZoneColors& zoneColors, OverlappingZonesAlgorithm overlappingAlgorithm) bool WorkArea::Init(HINSTANCE hinstance, HMONITOR monitor, const FancyZonesDataTypes::DeviceIdData& uniqueId, const FancyZonesDataTypes::DeviceIdData& parentUniqueId, const ZoneColors& zoneColors, OverlappingZonesAlgorithm overlappingAlgorithm, const bool showZoneText)
{ {
m_zoneColors = zoneColors; m_zoneColors = zoneColors;
m_overlappingAlgorithm = overlappingAlgorithm; m_overlappingAlgorithm = overlappingAlgorithm;
m_showZoneText = showZoneText;
Rect workAreaRect; Rect workAreaRect;
m_monitor = monitor; m_monitor = monitor;
@@ -275,7 +277,7 @@ IFACEMETHODIMP WorkArea::MoveSizeUpdate(POINT const& ptScreen, bool dragEnabled,
if (redraw) if (redraw)
{ {
m_zonesOverlay->DrawActiveZoneSet(m_zoneSet->GetZones(), m_highlightZone, m_zoneColors); m_zonesOverlay->DrawActiveZoneSet(m_zoneSet->GetZones(), m_highlightZone, m_zoneColors, m_showZoneText);
} }
return S_OK; return S_OK;
@@ -405,7 +407,7 @@ WorkArea::ShowZonesOverlay() noexcept
if (m_window) if (m_window)
{ {
SetAsTopmostWindow(); SetAsTopmostWindow();
m_zonesOverlay->DrawActiveZoneSet(m_zoneSet->GetZones(), m_highlightZone, m_zoneColors); m_zonesOverlay->DrawActiveZoneSet(m_zoneSet->GetZones(), m_highlightZone, m_zoneColors, m_showZoneText);
m_zonesOverlay->Show(); m_zonesOverlay->Show();
} }
} }
@@ -429,7 +431,7 @@ WorkArea::UpdateActiveZoneSet() noexcept
if (m_window) if (m_window)
{ {
m_highlightZone.clear(); m_highlightZone.clear();
m_zonesOverlay->DrawActiveZoneSet(m_zoneSet->GetZones(), m_highlightZone, m_zoneColors); m_zonesOverlay->DrawActiveZoneSet(m_zoneSet->GetZones(), m_highlightZone, m_zoneColors, m_showZoneText);
} }
} }
@@ -448,7 +450,7 @@ WorkArea::ClearSelectedZones() noexcept
if (m_highlightZone.size()) if (m_highlightZone.size())
{ {
m_highlightZone.clear(); m_highlightZone.clear();
m_zonesOverlay->DrawActiveZoneSet(m_zoneSet->GetZones(), m_highlightZone, m_zoneColors); m_zonesOverlay->DrawActiveZoneSet(m_zoneSet->GetZones(), m_highlightZone, m_zoneColors, m_showZoneText);
} }
} }
@@ -458,7 +460,7 @@ WorkArea::FlashZones() noexcept
if (m_window) if (m_window)
{ {
SetAsTopmostWindow(); SetAsTopmostWindow();
m_zonesOverlay->DrawActiveZoneSet(m_zoneSet->GetZones(), {}, m_zoneColors); m_zonesOverlay->DrawActiveZoneSet(m_zoneSet->GetZones(), {}, m_zoneColors, m_showZoneText);
m_zonesOverlay->Flash(); m_zonesOverlay->Flash();
} }
} }
@@ -635,10 +637,10 @@ LRESULT CALLBACK WorkArea::s_WndProc(HWND window, UINT message, WPARAM wparam, L
DefWindowProc(window, message, wparam, lparam); DefWindowProc(window, message, wparam, lparam);
} }
winrt::com_ptr<IWorkArea> MakeWorkArea(HINSTANCE hinstance, HMONITOR monitor, const FancyZonesDataTypes::DeviceIdData& uniqueId, const FancyZonesDataTypes::DeviceIdData& parentUniqueId, const ZoneColors& zoneColors, OverlappingZonesAlgorithm overlappingAlgorithm) noexcept winrt::com_ptr<IWorkArea> MakeWorkArea(HINSTANCE hinstance, HMONITOR monitor, const FancyZonesDataTypes::DeviceIdData& uniqueId, const FancyZonesDataTypes::DeviceIdData& parentUniqueId, const ZoneColors& zoneColors, OverlappingZonesAlgorithm overlappingAlgorithm, const bool showZoneText) noexcept
{ {
auto self = winrt::make_self<WorkArea>(hinstance); auto self = winrt::make_self<WorkArea>(hinstance);
if (self->Init(hinstance, monitor, uniqueId, parentUniqueId, zoneColors, overlappingAlgorithm)) if (self->Init(hinstance, monitor, uniqueId, parentUniqueId, zoneColors, overlappingAlgorithm, showZoneText))
{ {
return self; return self;
} }

View File

@@ -145,4 +145,4 @@ interface __declspec(uuid("{7F017528-8110-4FB3-BE41-F472969C2560}")) IWorkArea :
IFACEMETHOD_(void, SetOverlappingZonesAlgorithm)(OverlappingZonesAlgorithm overlappingAlgorithm) = 0; IFACEMETHOD_(void, SetOverlappingZonesAlgorithm)(OverlappingZonesAlgorithm overlappingAlgorithm) = 0;
}; };
winrt::com_ptr<IWorkArea> MakeWorkArea(HINSTANCE hinstance, HMONITOR monitor, const FancyZonesDataTypes::DeviceIdData& uniqueId, const FancyZonesDataTypes::DeviceIdData& parentUniqueId, const ZoneColors& zoneColors, OverlappingZonesAlgorithm overlappingAlgorithm) noexcept; winrt::com_ptr<IWorkArea> MakeWorkArea(HINSTANCE hinstance, HMONITOR monitor, const FancyZonesDataTypes::DeviceIdData& uniqueId, const FancyZonesDataTypes::DeviceIdData& parentUniqueId, const ZoneColors& zoneColors, OverlappingZonesAlgorithm overlappingAlgorithm, const bool showZoneText) noexcept;

View File

@@ -6,6 +6,6 @@ struct ZoneColors
COLORREF primaryColor; COLORREF primaryColor;
COLORREF borderColor; COLORREF borderColor;
COLORREF highlightColor; COLORREF highlightColor;
COLORREF textColor; COLORREF numberColor;
int highlightOpacity; int highlightOpacity;
}; };

View File

@@ -149,7 +149,6 @@ ZonesOverlay::RenderResult ZonesOverlay::Render()
drawableRect.borderColor.a *= animationAlpha; drawableRect.borderColor.a *= animationAlpha;
drawableRect.fillColor.a *= animationAlpha; drawableRect.fillColor.a *= animationAlpha;
m_renderTarget->CreateSolidColorBrush(drawableRect.textColor, &textBrush);
m_renderTarget->CreateSolidColorBrush(drawableRect.borderColor, &borderBrush); m_renderTarget->CreateSolidColorBrush(drawableRect.borderColor, &borderBrush);
m_renderTarget->CreateSolidColorBrush(drawableRect.fillColor, &fillBrush); m_renderTarget->CreateSolidColorBrush(drawableRect.fillColor, &fillBrush);
@@ -167,16 +166,21 @@ ZonesOverlay::RenderResult ZonesOverlay::Render()
std::wstring idStr = std::to_wstring(drawableRect.id + 1); std::wstring idStr = std::to_wstring(drawableRect.id + 1);
if (textFormat && textBrush) if (drawableRect.showText)
{ {
textFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); m_renderTarget->CreateSolidColorBrush(drawableRect.textColor, &textBrush);
textFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
m_renderTarget->DrawTextW(idStr.c_str(), (UINT32)idStr.size(), textFormat, drawableRect.rect, textBrush);
}
if (textBrush) if (textFormat && textBrush)
{ {
textBrush->Release(); textFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);
textFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
m_renderTarget->DrawTextW(idStr.c_str(), (UINT32)idStr.size(), textFormat, drawableRect.rect, textBrush);
}
if (textBrush)
{
textBrush->Release();
}
} }
} }
@@ -278,7 +282,8 @@ void ZonesOverlay::Flash()
void ZonesOverlay::DrawActiveZoneSet(const IZoneSet::ZonesMap& zones, void ZonesOverlay::DrawActiveZoneSet(const IZoneSet::ZonesMap& zones,
const ZoneIndexSet& highlightZones, const ZoneIndexSet& highlightZones,
const ZoneColors& colors) const ZoneColors& colors,
const bool showZoneText)
{ {
_TRACER_; _TRACER_;
std::unique_lock lock(m_mutex); std::unique_lock lock(m_mutex);
@@ -288,7 +293,7 @@ void ZonesOverlay::DrawActiveZoneSet(const IZoneSet::ZonesMap& zones,
auto borderColor = ConvertColor(colors.borderColor); auto borderColor = ConvertColor(colors.borderColor);
auto inactiveColor = ConvertColor(colors.primaryColor); auto inactiveColor = ConvertColor(colors.primaryColor);
auto highlightColor = ConvertColor(colors.highlightColor); auto highlightColor = ConvertColor(colors.highlightColor);
auto textColor = ConvertColor(colors.textColor); auto numberColor = ConvertColor(colors.numberColor);
inactiveColor.a = colors.highlightOpacity / 100.f; inactiveColor.a = colors.highlightOpacity / 100.f;
highlightColor.a = colors.highlightOpacity / 100.f; highlightColor.a = colors.highlightOpacity / 100.f;
@@ -313,8 +318,9 @@ void ZonesOverlay::DrawActiveZoneSet(const IZoneSet::ZonesMap& zones,
.rect = ConvertRect(zone->GetZoneRect()), .rect = ConvertRect(zone->GetZoneRect()),
.borderColor = borderColor, .borderColor = borderColor,
.fillColor = inactiveColor, .fillColor = inactiveColor,
.textColor = textColor, .textColor = numberColor,
.id = zone->Id() .id = zone->Id(),
.showText = showZoneText
}; };
m_sceneRects.push_back(drawableRect); m_sceneRects.push_back(drawableRect);
@@ -335,8 +341,9 @@ void ZonesOverlay::DrawActiveZoneSet(const IZoneSet::ZonesMap& zones,
.rect = ConvertRect(zone->GetZoneRect()), .rect = ConvertRect(zone->GetZoneRect()),
.borderColor = borderColor, .borderColor = borderColor,
.fillColor = highlightColor, .fillColor = highlightColor,
.textColor = textColor, .textColor = numberColor,
.id = zone->Id() .id = zone->Id(),
.showText = showZoneText
}; };
m_sceneRects.push_back(drawableRect); m_sceneRects.push_back(drawableRect);

View File

@@ -22,6 +22,7 @@ class ZonesOverlay
D2D1_COLOR_F fillColor; D2D1_COLOR_F fillColor;
D2D1_COLOR_F textColor; D2D1_COLOR_F textColor;
ZoneIndex id; ZoneIndex id;
bool showText;
}; };
struct AnimationInfo struct AnimationInfo
@@ -67,5 +68,6 @@ public:
void Flash(); void Flash();
void DrawActiveZoneSet(const IZoneSet::ZonesMap& zones, void DrawActiveZoneSet(const IZoneSet::ZonesMap& zones,
const ZoneIndexSet& highlightZones, const ZoneIndexSet& highlightZones,
const ZoneColors& colors); const ZoneColors& colors,
const bool showZoneText);
}; };

View File

@@ -32,6 +32,7 @@ namespace FancyZonesUnitTests
GUID m_virtualDesktopGuid{}; GUID m_virtualDesktopGuid{};
ZoneColors m_zoneColors{}; ZoneColors m_zoneColors{};
OverlappingZonesAlgorithm m_overlappingAlgorithm = OverlappingZonesAlgorithm::Positional; OverlappingZonesAlgorithm m_overlappingAlgorithm = OverlappingZonesAlgorithm::Positional;
bool m_showZoneText = true;
FancyZonesData& m_fancyZonesData = FancyZonesDataInstance(); FancyZonesData& m_fancyZonesData = FancyZonesDataInstance();
@@ -78,7 +79,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (CreateWorkArea) TEST_METHOD (CreateWorkArea)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
testWorkArea(workArea); testWorkArea(workArea);
auto* zoneSet{ workArea->ZoneSet() }; auto* zoneSet{ workArea->ZoneSet() };
@@ -89,7 +90,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (CreateWorkAreaNoHinst) TEST_METHOD (CreateWorkAreaNoHinst)
{ {
auto workArea = MakeWorkArea({}, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea({}, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
testWorkArea(workArea); testWorkArea(workArea);
auto* zoneSet{ workArea->ZoneSet() }; auto* zoneSet{ workArea->ZoneSet() };
@@ -100,7 +101,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (CreateWorkAreaNoHinstFlashZones) TEST_METHOD (CreateWorkAreaNoHinstFlashZones)
{ {
auto workArea = MakeWorkArea({}, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea({}, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
testWorkArea(workArea); testWorkArea(workArea);
auto* zoneSet{ workArea->ZoneSet() }; auto* zoneSet{ workArea->ZoneSet() };
@@ -111,7 +112,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (CreateWorkAreaNoMonitor) TEST_METHOD (CreateWorkAreaNoMonitor)
{ {
auto workArea = MakeWorkArea(m_hInst, {}, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, {}, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
testWorkArea(workArea); testWorkArea(workArea);
} }
@@ -130,7 +131,7 @@ namespace FancyZonesUnitTests
uniqueIdData.height = monitorRect.height(); uniqueIdData.height = monitorRect.height();
} }
auto workArea = MakeWorkArea(m_hInst, m_monitor, uniqueIdData, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, uniqueIdData, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
const std::wstring expectedWorkArea = std::to_wstring(m_monitorInfo.rcMonitor.right) + L"_" + std::to_wstring(m_monitorInfo.rcMonitor.bottom); const std::wstring expectedWorkArea = std::to_wstring(m_monitorInfo.rcMonitor.right) + L"_" + std::to_wstring(m_monitorInfo.rcMonitor.bottom);
const FancyZonesDataTypes::DeviceIdData expectedUniqueId{ L"FallbackDevice", m_monitorInfo.rcMonitor.right - m_monitorInfo.rcMonitor.left, m_monitorInfo.rcMonitor.bottom - m_monitorInfo.rcMonitor.top, m_virtualDesktopGuid }; const FancyZonesDataTypes::DeviceIdData expectedUniqueId{ L"FallbackDevice", m_monitorInfo.rcMonitor.right - m_monitorInfo.rcMonitor.left, m_monitorInfo.rcMonitor.bottom - m_monitorInfo.rcMonitor.top, m_virtualDesktopGuid };
@@ -159,7 +160,7 @@ namespace FancyZonesUnitTests
uniqueId.height = monitorRect.height(); uniqueId.height = monitorRect.height();
} }
auto workArea = MakeWorkArea(m_hInst, m_monitor, uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
const std::wstring expectedWorkArea = std::to_wstring(m_monitorInfo.rcMonitor.right) + L"_" + std::to_wstring(m_monitorInfo.rcMonitor.bottom); const std::wstring expectedWorkArea = std::to_wstring(m_monitorInfo.rcMonitor.right) + L"_" + std::to_wstring(m_monitorInfo.rcMonitor.bottom);
Assert::IsNotNull(workArea.get()); Assert::IsNotNull(workArea.get());
@@ -182,10 +183,10 @@ namespace FancyZonesUnitTests
const auto parentDeviceInfo = DeviceInfoData{ parentZoneSet, true, spacing, zoneCount }; const auto parentDeviceInfo = DeviceInfoData{ parentZoneSet, true, spacing, zoneCount };
m_fancyZonesData.SetDeviceInfo(m_parentUniqueId, parentDeviceInfo); m_fancyZonesData.SetDeviceInfo(m_parentUniqueId, parentDeviceInfo);
auto parentWorkArea = MakeWorkArea(m_hInst, m_monitor, m_parentUniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto parentWorkArea = MakeWorkArea(m_hInst, m_monitor, m_parentUniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
// newWorkArea = false - workArea won't be cloned from parent // newWorkArea = false - workArea won't be cloned from parent
auto actualWorkArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto actualWorkArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
Assert::IsNotNull(actualWorkArea->ZoneSet()); Assert::IsNotNull(actualWorkArea->ZoneSet());
@@ -208,6 +209,7 @@ namespace FancyZonesUnitTests
MONITORINFO m_monitorInfo{}; MONITORINFO m_monitorInfo{};
ZoneColors m_zoneColors{}; ZoneColors m_zoneColors{};
OverlappingZonesAlgorithm m_overlappingAlgorithm = OverlappingZonesAlgorithm::Positional; OverlappingZonesAlgorithm m_overlappingAlgorithm = OverlappingZonesAlgorithm::Positional;
bool m_showZoneText = true;
FancyZonesData& m_fancyZonesData = FancyZonesDataInstance(); FancyZonesData& m_fancyZonesData = FancyZonesDataInstance();
@@ -238,7 +240,7 @@ namespace FancyZonesUnitTests
public: public:
TEST_METHOD (MoveSizeEnter) TEST_METHOD (MoveSizeEnter)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
const auto expected = S_OK; const auto expected = S_OK;
const auto actual = workArea->MoveSizeEnter(Mocks::Window()); const auto actual = workArea->MoveSizeEnter(Mocks::Window());
@@ -248,7 +250,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (MoveSizeEnterTwice) TEST_METHOD (MoveSizeEnterTwice)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
const auto expected = S_OK; const auto expected = S_OK;
@@ -260,7 +262,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (MoveSizeUpdate) TEST_METHOD (MoveSizeUpdate)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
const auto expected = S_OK; const auto expected = S_OK;
const auto actual = workArea->MoveSizeUpdate(POINT{ 0, 0 }, true, false); const auto actual = workArea->MoveSizeUpdate(POINT{ 0, 0 }, true, false);
@@ -270,7 +272,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (MoveSizeUpdatePointNegativeCoordinates) TEST_METHOD (MoveSizeUpdatePointNegativeCoordinates)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
const auto expected = S_OK; const auto expected = S_OK;
const auto actual = workArea->MoveSizeUpdate(POINT{ -10, -10 }, true, false); const auto actual = workArea->MoveSizeUpdate(POINT{ -10, -10 }, true, false);
@@ -280,7 +282,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (MoveSizeUpdatePointBigCoordinates) TEST_METHOD (MoveSizeUpdatePointBigCoordinates)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
const auto expected = S_OK; const auto expected = S_OK;
const auto actual = workArea->MoveSizeUpdate(POINT{ m_monitorInfo.rcMonitor.right + 1, m_monitorInfo.rcMonitor.bottom + 1 }, true, false); const auto actual = workArea->MoveSizeUpdate(POINT{ m_monitorInfo.rcMonitor.right + 1, m_monitorInfo.rcMonitor.bottom + 1 }, true, false);
@@ -290,7 +292,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (MoveSizeEnd) TEST_METHOD (MoveSizeEnd)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
const auto window = Mocks::Window(); const auto window = Mocks::Window();
workArea->MoveSizeEnter(window); workArea->MoveSizeEnter(window);
@@ -307,7 +309,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (MoveSizeEndWindowNotAdded) TEST_METHOD (MoveSizeEndWindowNotAdded)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
const auto window = Mocks::Window(); const auto window = Mocks::Window();
workArea->MoveSizeEnter(window); workArea->MoveSizeEnter(window);
@@ -323,7 +325,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (MoveSizeEndDifferentWindows) TEST_METHOD (MoveSizeEndDifferentWindows)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
const auto window = Mocks::Window(); const auto window = Mocks::Window();
workArea->MoveSizeEnter(window); workArea->MoveSizeEnter(window);
@@ -336,7 +338,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (MoveSizeEndWindowNotSet) TEST_METHOD (MoveSizeEndWindowNotSet)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
const auto expected = E_INVALIDARG; const auto expected = E_INVALIDARG;
const auto actual = workArea->MoveSizeEnd(Mocks::Window(), POINT{ 0, 0 }); const auto actual = workArea->MoveSizeEnd(Mocks::Window(), POINT{ 0, 0 });
@@ -346,7 +348,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (MoveSizeEndInvalidPoint) TEST_METHOD (MoveSizeEndInvalidPoint)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
const auto window = Mocks::Window(); const auto window = Mocks::Window();
workArea->MoveSizeEnter(window); workArea->MoveSizeEnter(window);
@@ -363,7 +365,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (MoveWindowIntoZoneByIndex) TEST_METHOD (MoveWindowIntoZoneByIndex)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
Assert::IsNotNull(workArea->ZoneSet()); Assert::IsNotNull(workArea->ZoneSet());
workArea->MoveWindowIntoZoneByIndex(Mocks::Window(), 0); workArea->MoveWindowIntoZoneByIndex(Mocks::Window(), 0);
@@ -373,7 +375,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (MoveWindowIntoZoneByDirectionAndIndex) TEST_METHOD (MoveWindowIntoZoneByDirectionAndIndex)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
Assert::IsNotNull(workArea->ZoneSet()); Assert::IsNotNull(workArea->ZoneSet());
const auto window = Mocks::WindowCreate(m_hInst); const auto window = Mocks::WindowCreate(m_hInst);
@@ -388,7 +390,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (MoveWindowIntoZoneByDirectionManyTimes) TEST_METHOD (MoveWindowIntoZoneByDirectionManyTimes)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
Assert::IsNotNull(workArea->ZoneSet()); Assert::IsNotNull(workArea->ZoneSet());
const auto window = Mocks::WindowCreate(m_hInst); const auto window = Mocks::WindowCreate(m_hInst);
@@ -405,7 +407,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (SaveWindowProcessToZoneIndexNullptrWindow) TEST_METHOD (SaveWindowProcessToZoneIndexNullptrWindow)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
Assert::IsNotNull(workArea->ZoneSet()); Assert::IsNotNull(workArea->ZoneSet());
workArea->SaveWindowProcessToZoneIndex(nullptr); workArea->SaveWindowProcessToZoneIndex(nullptr);
@@ -416,7 +418,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (SaveWindowProcessToZoneIndexNoWindowAdded) TEST_METHOD (SaveWindowProcessToZoneIndexNoWindowAdded)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
Assert::IsNotNull(workArea->ZoneSet()); Assert::IsNotNull(workArea->ZoneSet());
auto window = Mocks::WindowCreate(m_hInst); auto window = Mocks::WindowCreate(m_hInst);
@@ -431,7 +433,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (SaveWindowProcessToZoneIndexNoWindowAddedWithFilledAppZoneHistory) TEST_METHOD (SaveWindowProcessToZoneIndexNoWindowAddedWithFilledAppZoneHistory)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
Assert::IsNotNull(workArea->ZoneSet()); Assert::IsNotNull(workArea->ZoneSet());
const auto window = Mocks::WindowCreate(m_hInst); const auto window = Mocks::WindowCreate(m_hInst);
@@ -459,7 +461,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (SaveWindowProcessToZoneIndexWindowAdded) TEST_METHOD (SaveWindowProcessToZoneIndexWindowAdded)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
Assert::IsNotNull(workArea->ZoneSet()); Assert::IsNotNull(workArea->ZoneSet());
auto window = Mocks::WindowCreate(m_hInst); auto window = Mocks::WindowCreate(m_hInst);
@@ -489,7 +491,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (WhenWindowIsNotResizablePlacingItIntoTheZoneShouldNotResizeIt) TEST_METHOD (WhenWindowIsNotResizablePlacingItIntoTheZoneShouldNotResizeIt)
{ {
auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm); auto workArea = MakeWorkArea(m_hInst, m_monitor, m_uniqueId, {}, m_zoneColors, m_overlappingAlgorithm, m_showZoneText);
Assert::IsNotNull(workArea->ZoneSet()); Assert::IsNotNull(workArea->ZoneSet());
auto window = Mocks::WindowCreate(m_hInst); auto window = Mocks::WindowCreate(m_hInst);

View File

@@ -10,6 +10,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
public static readonly string DefaultFancyZonesZoneHighlightColor = "#0078D7"; public static readonly string DefaultFancyZonesZoneHighlightColor = "#0078D7";
public static readonly string DefaultFancyZonesInActiveColor = "#F5FCFF"; public static readonly string DefaultFancyZonesInActiveColor = "#F5FCFF";
public static readonly string DefaultFancyzonesBorderColor = "#FFFFFF"; public static readonly string DefaultFancyzonesBorderColor = "#FFFFFF";
public static readonly string DefaultFancyzonesNumberColor = "#000000";
// Fancy Zones Default Flags. // Fancy Zones Default Flags.
public static readonly bool DefaultFancyzonesShiftDrag = true; public static readonly bool DefaultFancyzonesShiftDrag = true;

View File

@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
@@ -46,7 +46,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library
FancyzonesExcludedApps = new StringProperty(); FancyzonesExcludedApps = new StringProperty();
FancyzonesInActiveColor = new StringProperty(ConfigDefaults.DefaultFancyZonesInActiveColor); FancyzonesInActiveColor = new StringProperty(ConfigDefaults.DefaultFancyZonesInActiveColor);
FancyzonesBorderColor = new StringProperty(ConfigDefaults.DefaultFancyzonesBorderColor); FancyzonesBorderColor = new StringProperty(ConfigDefaults.DefaultFancyzonesBorderColor);
FancyzonesNumberColor = new StringProperty(ConfigDefaults.DefaultFancyzonesNumberColor);
FancyzonesSystemTheme = new BoolProperty(true); FancyzonesSystemTheme = new BoolProperty(true);
FancyzonesShowZoneNumber = new BoolProperty(true);
} }
[JsonPropertyName("fancyzones_shiftDrag")] [JsonPropertyName("fancyzones_shiftDrag")]
@@ -127,9 +129,15 @@ namespace Microsoft.PowerToys.Settings.UI.Library
[JsonPropertyName("fancyzones_zoneColor")] [JsonPropertyName("fancyzones_zoneColor")]
public StringProperty FancyzonesInActiveColor { get; set; } public StringProperty FancyzonesInActiveColor { get; set; }
[JsonPropertyName("fancyzones_zoneNumberColor")]
public StringProperty FancyzonesNumberColor { get; set; }
[JsonPropertyName("fancyzones_systemTheme")] [JsonPropertyName("fancyzones_systemTheme")]
public BoolProperty FancyzonesSystemTheme { get; set; } public BoolProperty FancyzonesSystemTheme { get; set; }
[JsonPropertyName("fancyzones_showZoneNumber")]
public BoolProperty FancyzonesShowZoneNumber { get; set; }
// converts the current to a json string. // converts the current to a json string.
public string ToJsonString() public string ToJsonString()
{ {

View File

@@ -3,8 +3,6 @@
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System; using System;
using System.Drawing;
using System.Globalization;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
@@ -89,6 +87,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
_highlightOpacity = Settings.Properties.FancyzonesHighlightOpacity.Value; _highlightOpacity = Settings.Properties.FancyzonesHighlightOpacity.Value;
_excludedApps = Settings.Properties.FancyzonesExcludedApps.Value; _excludedApps = Settings.Properties.FancyzonesExcludedApps.Value;
_systemTheme = Settings.Properties.FancyzonesSystemTheme.Value; _systemTheme = Settings.Properties.FancyzonesSystemTheme.Value;
_showZoneNumber = Settings.Properties.FancyzonesShowZoneNumber.Value;
EditorHotkey = Settings.Properties.FancyzonesEditorHotkey.Value; EditorHotkey = Settings.Properties.FancyzonesEditorHotkey.Value;
_windowSwitching = Settings.Properties.FancyzonesWindowSwitching.Value; _windowSwitching = Settings.Properties.FancyzonesWindowSwitching.Value;
NextTabHotkey = Settings.Properties.FancyzonesNextTabHotkey.Value; NextTabHotkey = Settings.Properties.FancyzonesNextTabHotkey.Value;
@@ -98,13 +97,16 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
SendConfigMSG = ipcMSGCallBackFunc; SendConfigMSG = ipcMSGCallBackFunc;
string inactiveColor = Settings.Properties.FancyzonesInActiveColor.Value; string inactiveColor = Settings.Properties.FancyzonesInActiveColor.Value;
_zoneInActiveColor = !string.IsNullOrEmpty(inactiveColor) ? inactiveColor : "#F5FCFF"; _zoneInActiveColor = !string.IsNullOrEmpty(inactiveColor) ? inactiveColor : ConfigDefaults.DefaultFancyZonesInActiveColor;
string borderColor = Settings.Properties.FancyzonesBorderColor.Value; string borderColor = Settings.Properties.FancyzonesBorderColor.Value;
_zoneBorderColor = !string.IsNullOrEmpty(borderColor) ? borderColor : "#FFFFFF"; _zoneBorderColor = !string.IsNullOrEmpty(borderColor) ? borderColor : ConfigDefaults.DefaultFancyzonesBorderColor;
string highlightColor = Settings.Properties.FancyzonesZoneHighlightColor.Value; string highlightColor = Settings.Properties.FancyzonesZoneHighlightColor.Value;
_zoneHighlightColor = !string.IsNullOrEmpty(highlightColor) ? highlightColor : "#0078D7"; _zoneHighlightColor = !string.IsNullOrEmpty(highlightColor) ? highlightColor : ConfigDefaults.DefaultFancyZonesZoneHighlightColor;
string numberColor = Settings.Properties.FancyzonesNumberColor.Value;
_zoneNumberColor = !string.IsNullOrEmpty(numberColor) ? numberColor : ConfigDefaults.DefaultFancyzonesNumberColor;
_isEnabled = GeneralSettingsConfig.Enabled.FancyZones; _isEnabled = GeneralSettingsConfig.Enabled.FancyZones;
} }
@@ -128,6 +130,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private bool _showOnAllMonitors; private bool _showOnAllMonitors;
private bool _makeDraggedWindowTransparent; private bool _makeDraggedWindowTransparent;
private bool _systemTheme; private bool _systemTheme;
private bool _showZoneNumber;
private int _highlightOpacity; private int _highlightOpacity;
private string _excludedApps; private string _excludedApps;
@@ -138,6 +141,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private string _zoneInActiveColor; private string _zoneInActiveColor;
private string _zoneBorderColor; private string _zoneBorderColor;
private string _zoneHighlightColor; private string _zoneHighlightColor;
private string _zoneNumberColor;
public bool IsEnabled public bool IsEnabled
{ {
@@ -540,6 +544,24 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
} }
} }
public bool ShowZoneNumber
{
get
{
return _showZoneNumber;
}
set
{
if (value != _showZoneNumber)
{
_showZoneNumber = value;
Settings.Properties.FancyzonesShowZoneNumber.Value = value;
NotifyPropertyChanged();
}
}
}
// For the following setters we use OrdinalIgnoreCase string comparison since // For the following setters we use OrdinalIgnoreCase string comparison since
// we expect value to be a hex code. // we expect value to be a hex code.
public string ZoneHighlightColor public string ZoneHighlightColor
@@ -608,6 +630,28 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
} }
} }
public string ZoneNumberColor
{
get
{
return _zoneNumberColor;
}
set
{
// The fallback value is based on ToRGBHex's behavior, which returns
// #FFFFFF if any exceptions are encountered, e.g. from passing in a null value.
// This extra handling is added here to deal with FxCop warnings.
value = (value != null) ? SettingsUtilities.ToRGBHex(value) : "#FFFFFF";
if (!value.Equals(_zoneNumberColor, StringComparison.OrdinalIgnoreCase))
{
_zoneNumberColor = value;
Settings.Properties.FancyzonesNumberColor.Value = value;
NotifyPropertyChanged();
}
}
}
public int HighlightOpacity public int HighlightOpacity
{ {
get get

View File

@@ -15,16 +15,20 @@
<ResourceDictionary.ThemeDictionaries> <ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Dark"> <ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="SolidBackgroundBrush" Color="Black" /> <SolidColorBrush x:Key="SolidBackgroundBrush" Color="Black" />
<SolidColorBrush x:Key="SolidZoneNumberBrush" Color="White" />
</ResourceDictionary> </ResourceDictionary>
<ResourceDictionary x:Key="Light"> <ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="SolidBackgroundBrush" Color="White" /> <SolidColorBrush x:Key="SolidBackgroundBrush" Color="White" />
<SolidColorBrush x:Key="SolidZoneNumberBrush" Color="Black" />
</ResourceDictionary> </ResourceDictionary>
<ResourceDictionary x:Key="HighContrast"> <ResourceDictionary x:Key="HighContrast">
<SolidColorBrush x:Key="SolidBackgroundBrush" Color="Black" /> <SolidColorBrush x:Key="SolidBackgroundBrush" Color="Black" />
<SolidColorBrush x:Key="SolidZoneNumberBrush" Color="White" />
</ResourceDictionary> </ResourceDictionary>
</ResourceDictionary.ThemeDictionaries> </ResourceDictionary.ThemeDictionaries>
<SolidColorBrush x:Key="DefaultAccentBrush" Color="{ThemeResource SystemAccentColor}"/> <SolidColorBrush x:Key="DefaultAccentBrush" Color="{ThemeResource SystemAccentColor}"/>
<SolidColorBrush x:Key="DefaultBorderBrush" Color="{ThemeResource SystemAccentColor}"/> <SolidColorBrush x:Key="DefaultBorderBrush" Color="{ThemeResource SystemAccentColor}"/>
<converters:BoolToObjectConverter x:Key="BoolToVisibilityConverter" TrueValue="Visible" FalseValue="Collapsed"/>
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
@@ -43,8 +47,14 @@
</Border> </Border>
<Grid Background="{ThemeResource SystemControlAcrylicElementBrush}" Grid.Row="2" Grid.ColumnSpan="2"/> <Grid Background="{ThemeResource SystemControlAcrylicElementBrush}" Grid.Row="2" Grid.ColumnSpan="2"/>
<Border x:Name="Zone1" Margin="4,4,2,4" CornerRadius="2" Grid.RowSpan="2" BorderThickness="1"/> <Border x:Name="Zone1" Margin="4,4,2,4" CornerRadius="2" Grid.RowSpan="2" BorderThickness="1">
<Border x:Name="Zone2" Margin="2,4,4,2" CornerRadius="2" Grid.Column="1" BorderThickness="1"/> <TextBlock x:Name="Zone1Number" Text="1" FontWeight="SemiBold" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{x:Bind ShowZoneNumber, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"/>
<Border x:Name="Zone3" Margin="2,2,4,4" CornerRadius="2" Grid.Row="1" Grid.Column="1" BorderThickness="1"/> </Border>
<Border x:Name="Zone2" Margin="2,4,4,2" CornerRadius="2" Grid.Column="1" BorderThickness="1">
<TextBlock x:Name="Zone2Number" Text="2" FontWeight="SemiBold" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{x:Bind ShowZoneNumber, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"/>
</Border>
<Border x:Name="Zone3" Margin="2,2,4,4" CornerRadius="2" Grid.Row="1" Grid.Column="1" BorderThickness="1">
<TextBlock x:Name="Zone3Number" Text="3" FontWeight="SemiBold" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{x:Bind ShowZoneNumber, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"/>
</Border>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@@ -40,14 +40,14 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
set { SetValue(IsSystemThemeProperty, value); } set { SetValue(IsSystemThemeProperty, value); }
} }
public static readonly DependencyProperty IsSystemThemeProperty = DependencyProperty.Register("IsSystemTheme", typeof(bool), typeof(FancyZonesPreviewControl), new PropertyMetadata(default(bool), OnPropertyChanged));
public string WallpaperPath public string WallpaperPath
{ {
get { return (string)GetValue(WallpaperPathProperty); } get { return (string)GetValue(WallpaperPathProperty); }
set { SetValue(WallpaperPathProperty, value); } set { SetValue(WallpaperPathProperty, value); }
} }
public static readonly DependencyProperty IsSystemThemeProperty = DependencyProperty.Register("IsSystemTheme", typeof(bool), typeof(FancyZonesPreviewControl), new PropertyMetadata(default(bool), OnPropertyChanged));
public static readonly DependencyProperty WallpaperPathProperty = DependencyProperty.Register("WallpaperPath", typeof(string), typeof(FancyZonesPreviewControl), new PropertyMetadata("ms-appx:///Assets/wallpaper_placeholder.png")); public static readonly DependencyProperty WallpaperPathProperty = DependencyProperty.Register("WallpaperPath", typeof(string), typeof(FancyZonesPreviewControl), new PropertyMetadata("ms-appx:///Assets/wallpaper_placeholder.png"));
public Color CustomBorderColor public Color CustomBorderColor
@@ -74,6 +74,22 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
public static readonly DependencyProperty CustomHighlightColorProperty = DependencyProperty.Register("CustomHighlightColor", typeof(Color), typeof(FancyZonesPreviewControl), new PropertyMetadata(null, OnPropertyChanged)); public static readonly DependencyProperty CustomHighlightColorProperty = DependencyProperty.Register("CustomHighlightColor", typeof(Color), typeof(FancyZonesPreviewControl), new PropertyMetadata(null, OnPropertyChanged));
public Color CustomNumberColor
{
get { return (Color)GetValue(CustomNumberColorProperty); }
set { SetValue(CustomNumberColorProperty, value); }
}
public static readonly DependencyProperty CustomNumberColorProperty = DependencyProperty.Register("CustomNumberColor", typeof(Color), typeof(FancyZonesPreviewControl), new PropertyMetadata(null, OnPropertyChanged));
public bool ShowZoneNumber
{
get { return (bool)GetValue(ShowZoneNumberProperty); }
set { SetValue(ShowZoneNumberProperty, value); }
}
public static readonly DependencyProperty ShowZoneNumberProperty = DependencyProperty.Register("ShowZoneNumber", typeof(bool), typeof(FancyZonesPreviewControl), new PropertyMetadata(default(bool), OnPropertyChanged));
public double HighlightOpacity public double HighlightOpacity
{ {
get { return (double)GetValue(HighlightOpacityProperty); } get { return (double)GetValue(HighlightOpacityProperty); }
@@ -90,6 +106,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
private SolidColorBrush highlightBrush; private SolidColorBrush highlightBrush;
private SolidColorBrush inActiveBrush; private SolidColorBrush inActiveBrush;
private SolidColorBrush borderBrush; private SolidColorBrush borderBrush;
private SolidColorBrush numberBrush;
private void Update() private void Update()
{ {
@@ -98,12 +115,14 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
highlightBrush = new SolidColorBrush(CustomHighlightColor); highlightBrush = new SolidColorBrush(CustomHighlightColor);
inActiveBrush = new SolidColorBrush(CustomInActiveColor); inActiveBrush = new SolidColorBrush(CustomInActiveColor);
borderBrush = new SolidColorBrush(CustomBorderColor); borderBrush = new SolidColorBrush(CustomBorderColor);
numberBrush = new SolidColorBrush(CustomNumberColor);
} }
else else
{ {
highlightBrush = (SolidColorBrush)this.Resources["DefaultAccentBrush"]; highlightBrush = (SolidColorBrush)this.Resources["DefaultAccentBrush"];
inActiveBrush = (SolidColorBrush)this.Resources["SolidBackgroundBrush"]; inActiveBrush = (SolidColorBrush)this.Resources["SolidBackgroundBrush"];
borderBrush = (SolidColorBrush)this.Resources["DefaultBorderBrush"]; borderBrush = (SolidColorBrush)this.Resources["DefaultBorderBrush"];
numberBrush = (SolidColorBrush)this.Resources["SolidZoneNumberBrush"];
} }
highlightBrush.Opacity = HighlightOpacity / 100; highlightBrush.Opacity = HighlightOpacity / 100;
@@ -115,6 +134,10 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
Zone1.BorderBrush = borderBrush; Zone1.BorderBrush = borderBrush;
Zone2.BorderBrush = borderBrush; Zone2.BorderBrush = borderBrush;
Zone3.BorderBrush = borderBrush; Zone3.BorderBrush = borderBrush;
Zone1Number.Foreground = numberBrush;
Zone2Number.Foreground = numberBrush;
Zone3Number.Foreground = numberBrush;
} }
} }
} }

View File

@@ -1550,7 +1550,7 @@ From there, simply click on a Markdown file, PDF file or SVG icon in the File Ex
<data name="EditButton.AutomationProperties.Name" xml:space="preserve"> <data name="EditButton.AutomationProperties.Name" xml:space="preserve">
<value>Edit</value> <value>Edit</value>
</data> </data>
<data name="ImageResizer_EditSize.AutomationProperties.Name" xml:space="preserve"> <data name="ImageResizer_EditSize.AutomationProperties.Name" xml:space="preserve">
<value>Edit size</value> <value>Edit size</value>
</data> </data>
<data name="No" xml:space="preserve"> <data name="No" xml:space="preserve">
@@ -1848,6 +1848,12 @@ From there, simply click on a Markdown file, PDF file or SVG icon in the File Ex
<value>Enable G-code (.gcode) preview</value> <value>Enable G-code (.gcode) preview</value>
<comment>Do you want this feature on / off</comment> <comment>Do you want this feature on / off</comment>
</data> </data>
<data name="FancyZones_NumberColor.Header" xml:space="preserve">
<value>Number color</value>
</data>
<data name="FancyZones_ShowZoneNumberCheckBoxControl.Content" xml:space="preserve">
<value>Show zone number</value>
</data>
<data name="ToggleSwitch.OffContent" xml:space="preserve"> <data name="ToggleSwitch.OffContent" xml:space="preserve">
<value>Off</value> <value>Off</value>
<comment>The state of a ToggleSwitch when it's off</comment> <comment>The state of a ToggleSwitch when it's off</comment>

View File

@@ -113,11 +113,17 @@
CustomHighlightColor="{x:Bind Path=ViewModel.ZoneHighlightColor, Mode=OneWay}" CustomHighlightColor="{x:Bind Path=ViewModel.ZoneHighlightColor, Mode=OneWay}"
CustomBorderColor="{x:Bind Path=ViewModel.ZoneBorderColor, Mode=OneWay}" CustomBorderColor="{x:Bind Path=ViewModel.ZoneBorderColor, Mode=OneWay}"
CustomInActiveColor="{x:Bind Path=ViewModel.ZoneInActiveColor, Mode=OneWay}" CustomInActiveColor="{x:Bind Path=ViewModel.ZoneInActiveColor, Mode=OneWay}"
CustomNumberColor="{x:Bind Path=ViewModel.ZoneNumberColor, Mode=OneWay}"
ShowZoneNumber="{x:Bind Path=ViewModel.ShowZoneNumber, Mode=OneWay}"
Margin="{StaticResource ExpanderSettingMargin}" Margin="{StaticResource ExpanderSettingMargin}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Width="170" Width="170"
Grid.Column="1" Grid.Column="1"
Height="86"/> Height="86"/>
<Rectangle Style="{StaticResource ExpanderSeparatorStyle}" />
<CheckBox x:Uid="FancyZones_ShowZoneNumberCheckBoxControl" IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.ShowZoneNumber}" Margin="{StaticResource ExpanderSettingMargin}"/>
<controls:Setting x:Uid="FancyZones_HighlightOpacity" Style="{StaticResource ExpanderContentSettingStyle}"> <controls:Setting x:Uid="FancyZones_HighlightOpacity" Style="{StaticResource ExpanderContentSettingStyle}">
<controls:Setting.ActionContent> <controls:Setting.ActionContent>
<Slider Minimum="0" <Slider Minimum="0"
@@ -127,7 +133,7 @@
HorizontalAlignment="Right"/> HorizontalAlignment="Right"/>
</controls:Setting.ActionContent> </controls:Setting.ActionContent>
</controls:Setting> </controls:Setting>
<StackPanel Visibility="{x:Bind Mode=OneWay, Path=ViewModel.SystemTheme, Converter={StaticResource FalseToVisibleConverter}}" > <StackPanel Visibility="{x:Bind Mode=OneWay, Path=ViewModel.SystemTheme, Converter={StaticResource FalseToVisibleConverter}}" >
<controls:Setting x:Uid="FancyZones_ZoneHighlightColor" Style="{StaticResource ExpanderContentSettingStyle}"> <controls:Setting x:Uid="FancyZones_ZoneHighlightColor" Style="{StaticResource ExpanderContentSettingStyle}">
<controls:Setting.ActionContent> <controls:Setting.ActionContent>
@@ -146,6 +152,12 @@
<controls:ColorPickerButton SelectedColor="{x:Bind Path=ViewModel.ZoneBorderColor, Mode=TwoWay}" /> <controls:ColorPickerButton SelectedColor="{x:Bind Path=ViewModel.ZoneBorderColor, Mode=TwoWay}" />
</controls:Setting.ActionContent> </controls:Setting.ActionContent>
</controls:Setting> </controls:Setting>
<controls:Setting x:Uid="FancyZones_NumberColor" Style="{StaticResource ExpanderContentSettingStyle}">
<controls:Setting.ActionContent>
<controls:ColorPickerButton SelectedColor="{x:Bind Path=ViewModel.ZoneNumberColor, Mode=TwoWay}" />
</controls:Setting.ActionContent>
</controls:Setting>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</controls:SettingExpander.Content> </controls:SettingExpander.Content>