Skip to content

Commit

Permalink
[MouseJump] move Mouse Jump settings into separate control (microsoft…
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeclayton committed Oct 21, 2024
1 parent dc7c7ef commit 6dcbd29
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 200 deletions.
12 changes: 10 additions & 2 deletions src/settings-ui/Settings.UI.Library/MouseJumpProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ public class MouseJumpProperties
public HotkeySettings DefaultActivationShortcut => new HotkeySettings(true, false, false, true, 0x44);

[JsonPropertyName("activation_shortcut")]
public HotkeySettings ActivationShortcut { get; set; }
public HotkeySettings ActivationShortcut
{
get;
set;
}

[JsonPropertyName("thumbnail_size")]
public MouseJumpThumbnailSize ThumbnailSize { get; set; }
public MouseJumpThumbnailSize ThumbnailSize
{
get;
set;
}

public MouseJumpProperties()
{
Expand Down
117 changes: 117 additions & 0 deletions src/settings-ui/Settings.UI/SettingsXAML/Panels/MouseJumpPanel.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<UserControl
x:Class="Microsoft.PowerToys.Settings.UI.Panels.MouseJumpPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
xmlns:converters="using:Microsoft.PowerToys.Settings.UI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
xmlns:tkconverters="using:CommunityToolkit.WinUI.Converters"
xmlns:ui="using:CommunityToolkit.WinUI"
AutomationProperties.LandmarkType="Main"
mc:Ignorable="d">

<controls:SettingsGroup x:Uid="MouseUtils_MouseJump">

<tkcontrols:SettingsCard
x:Uid="MouseUtils_Enable_MouseJump"
HeaderIcon="{ui:BitmapIcon Source=/Assets/Settings/Icons/MouseJump.png}"
IsEnabled="{x:Bind ViewModel.IsJumpEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
<ToggleSwitch x:Uid="ToggleSwitch" IsOn="{x:Bind ViewModel.IsMouseJumpEnabled, Mode=TwoWay}" />
</tkcontrols:SettingsCard>

<InfoBar
x:Uid="GPO_SettingIsManaged"
IsClosable="False"
IsOpen="{x:Bind ViewModel.IsJumpEnabledGpoConfigured, Mode=OneWay}"
IsTabStop="{x:Bind ViewModel.IsJumpEnabledGpoConfigured, Mode=OneWay}"
Severity="Informational" />

<tkcontrols:SettingsCard
x:Uid="MouseUtils_MouseJump_ActivationShortcut"
HeaderIcon="{ui:FontIcon Glyph=&#xEDA7;}"
IsEnabled="{x:Bind ViewModel.IsMouseJumpEnabled, Mode=OneWay}">
<controls:ShortcutControl MinWidth="{StaticResource SettingActionControlMinWidth}" HotkeySettings="{x:Bind Path=ViewModel.MouseJumpActivationShortcut, Mode=TwoWay}" />
</tkcontrols:SettingsCard>

<tkcontrols:SettingsCard

x:Uid="MouseUtils_MouseJump_ThumbnailSize"
HeaderIcon="{ui:FontIcon Glyph=&#xE740;}"
IsEnabled="{x:Bind ViewModel.IsMouseJumpEnabled, Mode=OneWay}">
<tkcontrols:SettingsCard.Description>
<StackPanel
Grid.Row="1"
Grid.Column="1"
Margin="0,4,0,0"
Orientation="Horizontal">
<TextBlock
x:Uid="MouseUtils_MouseJump_ThumbnailSize_Description_Prefix"
Margin="0,0,4,0"
Style="{ThemeResource SecondaryTextStyle}" />
<TextBlock
Margin="0,0,4,0"
FontWeight="SemiBold"
Style="{ThemeResource SecondaryTextStyle}"
Text="{x:Bind ViewModel.MouseJumpThumbnailSize.Width, Mode=OneWay}" />
<TextBlock
Margin="0,5,4,0"
AutomationProperties.AccessibilityView="Raw"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="10"
Foreground="{ThemeResource SystemBaseMediumColor}"
Style="{ThemeResource SecondaryTextStyle}"
Text="&#xE947;" />
<TextBlock
Margin="0,0,4,0"
FontWeight="SemiBold"
Style="{ThemeResource SecondaryTextStyle}"
Text="{x:Bind ViewModel.MouseJumpThumbnailSize.Height, Mode=OneWay}" />
<TextBlock
x:Uid="MouseUtils_MouseJump_ThumbnailSize_Description_Suffix"
Margin="0,0,4,0"
Foreground="{ThemeResource SystemBaseMediumColor}"
Style="{ThemeResource SecondaryTextStyle}" />
</StackPanel>
</tkcontrols:SettingsCard.Description>
<StackPanel
Grid.Column="2"
HorizontalAlignment="Right"
Orientation="Horizontal"
Spacing="8">
<Button
x:Uid="EditButton"
Width="40"
Height="36"
Content="&#xE70F;"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
Style="{StaticResource SubtleButtonStyle}">
<ToolTipService.ToolTip>
<TextBlock x:Uid="EditTooltip" />
</ToolTipService.ToolTip>
<Button.Flyout>
<Flyout x:Uid="MouseJumpThumbnailSize_Edit" ShouldConstrainToRootBounds="False">
<StackPanel Spacing="16">
<NumberBox
x:Uid="MouseUtils_MouseJump_ThumbnailSize_Edit_Width"
Width="140"
Minimum="160"
SpinButtonPlacementMode="Compact"
Value="{x:Bind ViewModel.MouseJumpThumbnailSize.Width, Mode=TwoWay}" />
<NumberBox
x:Uid="MouseUtils_MouseJump_ThumbnailSize_Edit_Height"
Width="140"
Minimum="120"
SpinButtonPlacementMode="Compact"
Value="{x:Bind ViewModel.MouseJumpThumbnailSize.Height, Mode=TwoWay}" />
</StackPanel>
</Flyout>
</Button.Flyout>
</Button>
</StackPanel>
</tkcontrols:SettingsCard>

</controls:SettingsGroup>

</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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.PowerToys.Settings.UI.ViewModels;
using Microsoft.UI.Xaml.Controls;

namespace Microsoft.PowerToys.Settings.UI.Panels
{
public sealed partial class MouseJumpPanel : UserControl
{
internal MouseUtilsViewModel ViewModel { get; set; }

public MouseJumpPanel()
{
InitializeComponent();
}
}
}
97 changes: 2 additions & 95 deletions src/settings-ui/Settings.UI/SettingsXAML/Views/MouseUtilsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
xmlns:converters="using:Microsoft.PowerToys.Settings.UI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:panels="using:Microsoft.PowerToys.Settings.UI.Panels"
xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
xmlns:tkconverters="using:CommunityToolkit.WinUI.Converters"
xmlns:ui="using:CommunityToolkit.WinUI"
Expand Down Expand Up @@ -245,101 +246,7 @@
</tkcontrols:SettingsExpander>
</controls:SettingsGroup>

<controls:SettingsGroup x:Uid="MouseUtils_MouseJump">
<tkcontrols:SettingsCard
x:Uid="MouseUtils_Enable_MouseJump"
HeaderIcon="{ui:BitmapIcon Source=/Assets/Settings/Icons/MouseJump.png}"
IsEnabled="{x:Bind ViewModel.IsJumpEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
<ToggleSwitch x:Uid="ToggleSwitch" IsOn="{x:Bind ViewModel.IsMouseJumpEnabled, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
<InfoBar
x:Uid="GPO_SettingIsManaged"
IsClosable="False"
IsOpen="{x:Bind ViewModel.IsJumpEnabledGpoConfigured, Mode=OneWay}"
IsTabStop="{x:Bind ViewModel.IsJumpEnabledGpoConfigured, Mode=OneWay}"
Severity="Informational" />
<tkcontrols:SettingsCard
x:Uid="MouseUtils_MouseJump_ActivationShortcut"
HeaderIcon="{ui:FontIcon Glyph=&#xEDA7;}"
IsEnabled="{x:Bind ViewModel.IsMouseJumpEnabled, Mode=OneWay}">
<controls:ShortcutControl MinWidth="{StaticResource SettingActionControlMinWidth}" HotkeySettings="{x:Bind Path=ViewModel.MouseJumpActivationShortcut, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
<tkcontrols:SettingsCard
x:Uid="MouseUtils_MouseJump_ThumbnailSize"
HeaderIcon="{ui:FontIcon Glyph=&#xE740;}"
IsEnabled="{x:Bind ViewModel.IsMouseJumpEnabled, Mode=OneWay}">
<tkcontrols:SettingsCard.Description>
<StackPanel
Grid.Row="1"
Grid.Column="1"
Margin="0,4,0,0"
Orientation="Horizontal">
<TextBlock
x:Uid="MouseUtils_MouseJump_ThumbnailSize_Description_Prefix"
Margin="0,0,4,0"
Style="{ThemeResource SecondaryTextStyle}" />
<TextBlock
Margin="0,0,4,0"
FontWeight="SemiBold"
Style="{ThemeResource SecondaryTextStyle}"
Text="{x:Bind ViewModel.MouseJumpThumbnailSize.Width, Mode=OneWay}" />
<TextBlock
Margin="0,5,4,0"
AutomationProperties.AccessibilityView="Raw"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="10"
Foreground="{ThemeResource SystemBaseMediumColor}"
Style="{ThemeResource SecondaryTextStyle}"
Text="&#xE947;" />
<TextBlock
Margin="0,0,4,0"
FontWeight="SemiBold"
Style="{ThemeResource SecondaryTextStyle}"
Text="{x:Bind ViewModel.MouseJumpThumbnailSize.Height, Mode=OneWay}" />
<TextBlock
x:Uid="MouseUtils_MouseJump_ThumbnailSize_Description_Suffix"
Margin="0,0,4,0"
Foreground="{ThemeResource SystemBaseMediumColor}"
Style="{ThemeResource SecondaryTextStyle}" />
</StackPanel>
</tkcontrols:SettingsCard.Description>
<StackPanel
Grid.Column="2"
HorizontalAlignment="Right"
Orientation="Horizontal"
Spacing="8">
<Button
x:Uid="EditButton"
Width="40"
Height="36"
Content="&#xE70F;"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
Style="{StaticResource SubtleButtonStyle}">
<ToolTipService.ToolTip>
<TextBlock x:Uid="EditTooltip" />
</ToolTipService.ToolTip>
<Button.Flyout>
<Flyout x:Uid="MouseJumpThumbnailSize_Edit" ShouldConstrainToRootBounds="False">
<StackPanel Spacing="16">
<NumberBox
x:Uid="MouseUtils_MouseJump_ThumbnailSize_Edit_Width"
Width="140"
Minimum="160"
SpinButtonPlacementMode="Compact"
Value="{x:Bind ViewModel.MouseJumpThumbnailSize.Width, Mode=TwoWay}" />
<NumberBox
x:Uid="MouseUtils_MouseJump_ThumbnailSize_Edit_Height"
Width="140"
Minimum="120"
SpinButtonPlacementMode="Compact"
Value="{x:Bind ViewModel.MouseJumpThumbnailSize.Height, Mode=TwoWay}" />
</StackPanel>
</Flyout>
</Button.Flyout>
</Button>
</StackPanel>
</tkcontrols:SettingsCard>
</controls:SettingsGroup>
<panels:MouseJumpPanel x:Name="MouseUtils_MouseJump_Panel" x:Uid="MouseUtils_MouseJump_Panel" />

<controls:SettingsGroup x:Uid="MouseUtils_MousePointerCrosshairs">
<tkcontrols:SettingsCard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public MouseUtilsPage()

DataContext = ViewModel;
InitializeComponent();

this.MouseUtils_MouseJump_Panel.ViewModel = ViewModel;
}

public void RefreshEnabledState()
Expand Down
Loading

0 comments on commit 6dcbd29

Please sign in to comment.