[Mouse Crosshairs] Hide crosshairs when cursor hides (#27381)

* hide crosshairs when cursor hides

* fix formatting
This commit is contained in:
Davide Giacometti
2023-07-18 14:33:32 +02:00
committed by GitHub
parent ed44db25e3
commit 7e4e8f59bb
7 changed files with 143 additions and 18 deletions

View File

@@ -31,6 +31,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library
[JsonPropertyName("crosshairs_border_size")]
public IntProperty CrosshairsBorderSize { get; set; }
[JsonPropertyName("crosshairs_auto_hide")]
public BoolProperty CrosshairsAutoHide { get; set; }
public MousePointerCrosshairsProperties()
{
ActivationShortcut = DefaultActivationShortcut;
@@ -40,6 +43,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
CrosshairsThickness = new IntProperty(5);
CrosshairsBorderColor = new StringProperty("#FFFFFF");
CrosshairsBorderSize = new IntProperty(1);
CrosshairsAutoHide = new BoolProperty(false);
}
}
}

View File

@@ -2150,7 +2150,7 @@ From there, simply click on one of the supported files in the File Explorer and
<data name="OobeWindow_Title" xml:space="preserve">
<value>Welcome to PowerToys</value>
</data>
<data name="OobeWindow_TitleTxt.Text" xml:space="preserve">
<data name="OobeWindow_TitleTxt.Text" xml:space="preserve">
<value>Welcome to PowerToys</value>
</data>
<data name="SettingsWindow_Title" xml:space="preserve">
@@ -2469,10 +2469,10 @@ From there, simply click on one of the supported files in the File Explorer and
<value>Cancel</value>
</data>
<data name="Activation_Shortcut_Description.Text" xml:space="preserve">
<value>Press a combination of keys to change this shortcut</value>
<value>Press a combination of keys to change this shortcut</value>
</data>
<data name="Activation_Shortcut_Reset" xml:space="preserve">
<value>Reset</value>
<value>Reset</value>
</data>
<data name="Activation_Shortcut_Save" xml:space="preserve">
<value>Save</value>
@@ -3318,7 +3318,7 @@ Activate by holding the key for the character you want to add an accent to, then
<data name="FileLocksmith_Toggle_StandardContextMenu.Content" xml:space="preserve">
<value>Default and extended context menu</value>
</data>
<data name="FileLocksmith_Toggle_ExtendedContextMenu.Content" xml:space="preserve">
<data name="FileLocksmith_Toggle_ExtendedContextMenu.Content" xml:space="preserve">
<value>Extended context menu only</value>
</data>
<data name="FileLocksmith_Toggle_ContextMenu.Header" xml:space="preserve">
@@ -3551,9 +3551,9 @@ Activate by holding the key for the character you want to add an accent to, then
<value>Maximum width (px)</value>
<comment>px = pixels</comment>
</data>
<data name="SettingsWindow_TitleTxt.Text" xml:space="preserve">
<data name="SettingsWindow_TitleTxt.Text" xml:space="preserve">
<value>PowerToys Settings</value>
</data>
</data>
<data name="Oobe_Peek.Description" xml:space="preserve">
<value>A lightning fast file preview feature for Windows.</value>
</data>
@@ -3582,4 +3582,7 @@ Activate by holding the key for the character you want to add an accent to, then
<data name="Hosts_Encoding_Utf8Bom.Content" xml:space="preserve">
<value>UTF-8 with BOM</value>
</data>
<data name="MouseUtils_MousePointerCrosshairs_CrosshairsAutoHide.Content" xml:space="preserve">
<value>Automatically hide crosshairs when the mouse pointer is hidden</value>
</data>
</root>

View File

@@ -106,6 +106,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
_mousePointerCrosshairsRadius = MousePointerCrosshairsSettingsConfig.Properties.CrosshairsRadius.Value;
_mousePointerCrosshairsThickness = MousePointerCrosshairsSettingsConfig.Properties.CrosshairsThickness.Value;
_mousePointerCrosshairsBorderSize = MousePointerCrosshairsSettingsConfig.Properties.CrosshairsBorderSize.Value;
_mousePointerCrosshairsAutoHide = MousePointerCrosshairsSettingsConfig.Properties.CrosshairsAutoHide.Value;
// set the callback functions value to handle outgoing IPC message.
SendConfigMSG = ipcMSGCallBackFunc;
@@ -792,6 +793,24 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
public bool MousePointerCrosshairsAutoHide
{
get
{
return _mousePointerCrosshairsAutoHide;
}
set
{
if (value != _mousePointerCrosshairsAutoHide)
{
_mousePointerCrosshairsAutoHide = value;
MousePointerCrosshairsSettingsConfig.Properties.CrosshairsAutoHide.Value = value;
NotifyMousePointerCrosshairsPropertyChanged();
}
}
}
public void NotifyMousePointerCrosshairsPropertyChanged([CallerMemberName] string propertyName = null)
{
OnPropertyChanged(propertyName);
@@ -850,5 +869,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private int _mousePointerCrosshairsThickness;
private string _mousePointerCrosshairsBorderColor;
private int _mousePointerCrosshairsBorderSize;
private bool _mousePointerCrosshairsAutoHide;
}
}

View File

@@ -382,6 +382,12 @@
SpinButtonPlacementMode="Compact"
Value="{x:Bind Mode=TwoWay, Path=ViewModel.MousePointerCrosshairsBorderSize}" />
</labs:SettingsCard>
<labs:SettingsCard ContentAlignment="Left">
<CheckBox
x:Uid="MouseUtils_MousePointerCrosshairs_CrosshairsAutoHide"
IsChecked="{x:Bind ViewModel.MousePointerCrosshairsAutoHide, Mode=TwoWay}" />
</labs:SettingsCard>
</labs:SettingsExpander.Items>
</labs:SettingsExpander>
</controls:SettingsGroup>