[Mouse Highlighter]Change opacity setting to 1-100 (#20964)

* mouse highlighter opacity 1-100
This commit is contained in:
Davide Giacometti
2022-10-16 14:51:08 +02:00
committed by GitHub
parent 982415f578
commit a2638d01dc
5 changed files with 20 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
#pragma once
#include "pch.h"
constexpr int MOUSE_HIGHLIGHTER_DEFAULT_OPACITY = 160;
constexpr int MOUSE_HIGHLIGHTER_DEFAULT_OPACITY = 65;
const winrt::Windows::UI::Color MOUSE_HIGHLIGHTER_DEFAULT_LEFT_BUTTON_COLOR = winrt::Windows::UI::ColorHelper::FromArgb(MOUSE_HIGHLIGHTER_DEFAULT_OPACITY, 255, 255, 0);
const winrt::Windows::UI::Color MOUSE_HIGHLIGHTER_DEFAULT_RIGHT_BUTTON_COLOR = winrt::Windows::UI::ColorHelper::FromArgb(MOUSE_HIGHLIGHTER_DEFAULT_OPACITY, 0, 0, 255);
constexpr int MOUSE_HIGHLIGHTER_DEFAULT_RADIUS = 20;

View File

@@ -215,6 +215,13 @@ public:
{
Logger::warn("Failed to initialize Opacity from settings. Will use default value");
}
// Convert % to uint8_t
if ((std::wstring)settingsObject.GetNamedString(L"version") != L"1.0")
{
opacity = opacity * 255 / 100;
}
try
{
// Parse left button click color

View File

@@ -34,7 +34,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
ActivationShortcut = new HotkeySettings(true, false, false, true, 0x48);
LeftButtonClickColor = new StringProperty("#FFFF00");
RightButtonClickColor = new StringProperty("#0000FF");
HighlightOpacity = new IntProperty(160);
HighlightOpacity = new IntProperty(65);
HighlightRadius = new IntProperty(20);
HighlightFadeDelayMs = new IntProperty(500);
HighlightFadeDurationMs = new IntProperty(250);

View File

@@ -18,7 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
{
Name = ModuleName;
Properties = new MouseHighlighterProperties();
Version = "1.0";
Version = "1.1";
}
public string GetModuleName()
@@ -29,6 +29,14 @@ namespace Microsoft.PowerToys.Settings.UI.Library
// This can be utilized in the future if the settings.json file is to be modified/deleted.
public bool UpgradeSettingsConfiguration()
{
// Migrate settings from 1.0 to 1.1
if (Version == "1.0")
{
Version = "1.1";
Properties.HighlightOpacity = new IntProperty(Properties.HighlightOpacity.Value * 100 / 255);
return true;
}
return false;
}
}

View File

@@ -178,8 +178,8 @@
<controls:Setting x:Uid="MouseUtils_MouseHighlighter_HighlightOpacity" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsMouseHighlighterEnabled}" Style="{StaticResource ExpanderContentSettingStyle}">
<controls:Setting.ActionContent>
<Slider Minimum="0"
Maximum="255"
<Slider Minimum="1"
Maximum="100"
MinWidth="{StaticResource SettingActionControlMinWidth}"
Value="{x:Bind Mode=TwoWay, Path=ViewModel.MouseHighlighterOpacity}"
HorizontalAlignment="Right"/>