diff options
author | sr55 <[email protected]> | 2021-01-09 22:26:13 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2021-01-09 22:26:13 +0000 |
commit | 0b23e2d421f3edac2b06f968aa4a7b4b7e057273 (patch) | |
tree | d03ad913e1aa145fc20d6b58d5afcb837ce07e91 /win | |
parent | 413bf9f67ba703a97df384e17b1dd02a8f1c0981 (diff) |
WinGui: UI improvements around presets.
- The Toolbar "Presets" button has been changed to a dropdown button. This now allows access to the Preset manage, and also displays all the preset categories. This is similar to the preset overlay window on macOS.
- Use a larger font size for the default preset in the Preset Manager in place of what used to be bold to make it a bit more noticable.
Diffstat (limited to 'win')
-rw-r--r-- | win/CS/HandBrakeWPF/Commands/OpenPresetManagerCommand.cs | 26 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Converters/PresetsMenuConverter.cs | 23 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs | 2 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/MainView.xaml | 27 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/MainView.xaml.cs | 13 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/PresetManagerView.xaml | 1 |
6 files changed, 79 insertions, 13 deletions
diff --git a/win/CS/HandBrakeWPF/Commands/OpenPresetManagerCommand.cs b/win/CS/HandBrakeWPF/Commands/OpenPresetManagerCommand.cs new file mode 100644 index 000000000..27e36b80e --- /dev/null +++ b/win/CS/HandBrakeWPF/Commands/OpenPresetManagerCommand.cs @@ -0,0 +1,26 @@ +using System; + +namespace HandBrakeWPF.Commands +{ + using System.Windows.Input; + + using Caliburn.Micro; + + using HandBrakeWPF.ViewModels.Interfaces; + + public class OpenPresetManagerCommand : ICommand + { + public bool CanExecute(object? parameter) + { + return true; + } + + public void Execute(object? parameter) + { + IMainViewModel viewModel = IoC.Get<IMainViewModel>(); + viewModel.OpenPresetWindow(); + } + + public event EventHandler? CanExecuteChanged; + } +} diff --git a/win/CS/HandBrakeWPF/Converters/PresetsMenuConverter.cs b/win/CS/HandBrakeWPF/Converters/PresetsMenuConverter.cs index 059860294..ef82d2e71 100644 --- a/win/CS/HandBrakeWPF/Converters/PresetsMenuConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/PresetsMenuConverter.cs @@ -11,6 +11,7 @@ namespace HandBrakeWPF.Converters { using System; using System.Collections.Generic; + using System.Diagnostics; using System.Globalization; using System.Linq; using System.Windows; @@ -41,7 +42,20 @@ namespace HandBrakeWPF.Converters return null; } - Dictionary<string, MenuItem> groupedMenu = new Dictionary<string, MenuItem>(); + Dictionary<string, object> groupedMenu = new Dictionary<string, object>(); + + if (parameter != null && "true".Equals(parameter)) + { + MenuItem presetManagerMenuItem = new MenuItem + { + Header = Resources.PresetManger_Title, + Tag = null, + Command = new OpenPresetManagerCommand() + }; + groupedMenu.Add("hb_preset_manager", presetManagerMenuItem); + groupedMenu.Add("hb_menu_seperator", new Separator()); + } + foreach (IPresetObject item in presets) { PresetDisplayCategory category = item as PresetDisplayCategory; @@ -72,7 +86,7 @@ namespace HandBrakeWPF.Converters throw new NotImplementedException(); } - private void ProcessPreset(Dictionary<string, MenuItem> groupedMenu, Preset preset) + private void ProcessPreset(Dictionary<string, object> groupedMenu, Preset preset) { if (groupedMenu.ContainsKey(preset.Category)) { @@ -89,7 +103,8 @@ namespace HandBrakeWPF.Converters newMenuItem.FontSize = 14; } - groupedMenu[preset.Category].Items.Add(newMenuItem); + MenuItem menu = groupedMenu[preset.Category] as MenuItem; + menu?.Items.Add(newMenuItem); } else { @@ -114,7 +129,7 @@ namespace HandBrakeWPF.Converters } } - private void ProcessCategory(Dictionary<string, MenuItem> groupedMenu, PresetDisplayCategory category) + private void ProcessCategory(Dictionary<string, object> groupedMenu, PresetDisplayCategory category) { foreach (Preset preset in category.Presets) { diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs index e2e4fd1aa..0d851b07b 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs @@ -55,6 +55,8 @@ namespace HandBrakeWPF.ViewModels.Interfaces void AddAllToQueue();
void AddSelectionToQueue();
+ void OpenPresetWindow();
+
/// <summary>
/// The launch help.
/// </summary>
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index 96a5adb0a..af1d7fd09 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -103,6 +103,8 @@ <MenuItem Header="{x:Static Properties:Resources.MainView_PresetsMenu}" ItemsSource="{Binding PresetsCategories, Converter={StaticResource presetsMenuConverter}}" />
<Separator />
+ <MenuItem Header="{x:Static Properties:Resources.PresetManger_Title}" cal:Message.Attach="[Event Click] = [Action OpenPresetWindow]" />
+ <Separator />
<MenuItem Header="{x:Static Properties:Resources.MainView_UpdateSelectedPreset}" cal:Message.Attach="[Event Click] = [Action PresetUpdate]" />
<MenuItem Header="{x:Static Properties:Resources.MainView_PresetManage}" cal:Message.Attach="[Event Click] = [Action PresetManage]" />
<MenuItem Header="{x:Static Properties:Resources.MainView_PresetRemove}" cal:Message.Attach="[Event Click] = [Action PresetRemove]" />
@@ -180,7 +182,7 @@ </StackPanel>
<Grid x:Name="dropdown" Background="Transparent" >
- <Path Height="5" Margin="2,2,2,0" VerticalAlignment="Center" HorizontalAlignment="Center"
+ <Path Height="5" Margin="4,2,2,0" VerticalAlignment="Center" HorizontalAlignment="Center"
Data="M 0 0 L 4 4 L 8 0 Z"
Fill="{DynamicResource GlyphBrush}" x:Name="dropdownArrow" />
</Grid>
@@ -307,16 +309,23 @@ </StackPanel>
</Button>
-
- <Button Name="PresetPane" AutomationProperties.Name="Show Preset Pane" cal:Message.Attach="[Event Click] = [Action OpenPresetWindow]">
+ <Button PreviewMouseLeftButtonDown="Presets_PreviewMouseDown" ContextMenuService.IsEnabled="False" AutomationProperties.Name="{x:Static Properties:Resources.MainView_Presets}">
<StackPanel Orientation="Horizontal">
- <Image Width="32"
- Height="32"
- Source="{Binding Converter={StaticResource themeConverter}, ConverterParameter='Presets2.png'}"/>
- <Label Margin="8,0,0,0"
- VerticalAlignment="Center"
- Content="{x:Static Properties:Resources.MainView_Presets}"/>
+ <StackPanel Orientation="Horizontal">
+ <Image Width="32" Height="32" SnapsToDevicePixels="True" Source="{Binding Converter={StaticResource themeConverter}, ConverterParameter='Presets2.png'}" />
+ <Label Margin="8,0,0,0" VerticalAlignment="Center" Content="{x:Static Properties:Resources.MainView_Presets}" />
+ </StackPanel>
+
+ <Grid x:Name="presetsDropdown" Background="Transparent" >
+ <Path Height="5" Margin="4,2,2,0" VerticalAlignment="Center" HorizontalAlignment="Center"
+ Data="M 0 0 L 4 4 L 8 0 Z"
+ Fill="{DynamicResource GlyphBrush}" x:Name="presetsDropdownArrow" />
+ </Grid>
</StackPanel>
+
+ <Button.ContextMenu>
+ <ContextMenu ItemsSource="{Binding PresetsCategories, Converter={StaticResource presetsMenuConverter}, ConverterParameter=true}" />
+ </Button.ContextMenu>
</Button>
</ToolBar>
</StackPanel>
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml.cs b/win/CS/HandBrakeWPF/Views/MainView.xaml.cs index eb12c38c0..b542565a5 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml.cs @@ -65,6 +65,19 @@ namespace HandBrakeWPF.Views ((IMainViewModel)this.DataContext).AddToQueueWithErrorHandling();
}
+ private void Presets_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ // If we've clicked the dropdown part of the button, display the context menu below the button.
+ Button button = (sender as Button);
+ if (button != null)
+ {
+ button.ContextMenu.IsEnabled = true;
+ button.ContextMenu.PlacementTarget = button;
+ button.ContextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
+ button.ContextMenu.IsOpen = true;
+ }
+ }
+
private void TabControl_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.Source is TabControl && e.AddedItems.Count > 0)
diff --git a/win/CS/HandBrakeWPF/Views/PresetManagerView.xaml b/win/CS/HandBrakeWPF/Views/PresetManagerView.xaml index c9e769d19..9fb2f7ef0 100644 --- a/win/CS/HandBrakeWPF/Views/PresetManagerView.xaml +++ b/win/CS/HandBrakeWPF/Views/PresetManagerView.xaml @@ -70,6 +70,7 @@ <Style.Triggers> <DataTrigger Binding="{Binding IsDefault}" Value="True" > <Setter Property="FontStyle" Value="Italic" /> + <Setter Property="FontSize" Value="14" /> </DataTrigger> <DataTrigger Binding="{Binding IsDefault}" Value="False" > <Setter Property="FontStyle" Value="Normal" /> |