[MouseHighlighter]Add always-on pointer (#27186)

* [MouseHighlighter]Add always pointer

Make color pick UI ARGB
Delete Opacity setting

* Fix opacity and color

Fix "always color" incorrectly initialized
Revert default opacity to 65%, which was unintentionally lowered to 25% when
changing to percent

* Fix crash when opening MouseUtils settings page

Migration code was bugged, made malformed json and led to settings page crash.

* Implement migration in module side
This commit is contained in:
hayatogh
2023-07-26 23:48:00 +09:00
committed by GitHub
parent a99b2e0bc0
commit a71411d931
12 changed files with 331 additions and 74 deletions

View File

@@ -0,0 +1,42 @@
<UserControl
x:Class="Microsoft.PowerToys.Settings.UI.Controls.AlphaColorPickerButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Microsoft.PowerToys.Settings.UI.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="300"
d:DesignWidth="400"
mc:Ignorable="d">
<Grid>
<!--TODO(stefan): ToDisplayName is no longer available in ColorHelper
<DropDownButton Padding="4,4,8,4" AutomationProperties.FullDescription="{x:Bind clr:ColorHelper.ToDisplayName(SelectedColor), Mode=OneWay }">
-->
<DropDownButton Padding="4,4,8,4">
<Border
x:Name="ColorPreviewBorder"
Width="48"
Height="24"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="{ThemeResource ControlCornerRadius}">
<Border.Background>
<SolidColorBrush Color="{x:Bind SelectedColor, Mode=OneWay}" />
</Border.Background>
</Border>
<DropDownButton.Flyout>
<Flyout>
<ColorPicker
IsAlphaEnabled="True"
IsAlphaSliderVisible="True"
IsAlphaTextInputVisible="True"
IsColorChannelTextInputVisible="True"
IsColorSliderVisible="True"
IsHexInputVisible="True"
Color="{x:Bind SelectedColor, Mode=TwoWay}" />
</Flyout>
</DropDownButton.Flyout>
</DropDownButton>
</Grid>
</UserControl>

View File

@@ -0,0 +1,59 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Windows.UI;
namespace Microsoft.PowerToys.Settings.UI.Controls
{
public sealed partial class AlphaColorPickerButton : UserControl
{
private Color _selectedColor;
public Color SelectedColor
{
get
{
return _selectedColor;
}
set
{
if (_selectedColor != value)
{
_selectedColor = value;
SetValue(SelectedColorProperty, value);
}
}
}
public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register("SelectedColor", typeof(Color), typeof(AlphaColorPickerButton), new PropertyMetadata(null));
public AlphaColorPickerButton()
{
this.InitializeComponent();
IsEnabledChanged -= AlphaColorPickerButton_IsEnabledChanged;
SetEnabledState();
IsEnabledChanged += AlphaColorPickerButton_IsEnabledChanged;
}
private void AlphaColorPickerButton_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
{
SetEnabledState();
}
private void SetEnabledState()
{
if (this.IsEnabled)
{
ColorPreviewBorder.Opacity = 1;
}
else
{
ColorPreviewBorder.Opacity = 0.2;
}
}
}
}