Skip to content

Added Spacing and Padding options for compact layouts #7941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/Files/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@
<StaticResource x:Key="SidebarContentBackgroundBrush" ResourceKey="LayerFillColorDefaultBrush" />
<SolidColorBrush x:Key="TitlebarContentBackgroundBrush" Color="Transparent" />
<SolidColorBrush x:Key="NavigationViewContentBackground" Color="Transparent" />
<Thickness x:Key="ExpanderContentPadding">20,0,0,0</Thickness>
<Thickness x:Key="ExpanderMinHeight">1</Thickness>
<Thickness x:Key="GridViewHeaderPadding">12,8,12,0</Thickness>
<Thickness x:Key="GridViewHeaderMinHeight">0</Thickness>
<Thickness x:Key="GridViewHeaderItemMinHeight">0</Thickness>
<Thickness x:Key="ListViewRowPadding">8,0,8,8</Thickness>
<Thickness x:Key="ListViewHeaderGridHeight">38</Thickness>
<Thickness x:Key="ListedItemPadding">10,0</Thickness>
<Thickness x:Key="ListedItemHeight">32</Thickness>
<Thickness x:Key="ListViewMinHeight">1</Thickness>
<Thickness x:Key="ListViewHeight">36</Thickness>
<Thickness x:Key="ListViewItemMinHeight">1</Thickness>
<Thickness x:Key="ListViewHeaderItemPadding">12,8,12,0</Thickness>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<Color x:Key="SolidBackgroundAcrylic">#2C2C2C</Color>
Expand Down Expand Up @@ -104,6 +117,19 @@
<StaticResource x:Key="SidebarContentBackgroundBrush" ResourceKey="LayerFillColorDefaultBrush" />
<SolidColorBrush x:Key="TitlebarContentBackgroundBrush" Color="Transparent" />
<SolidColorBrush x:Key="NavigationViewContentBackground" Color="Transparent" />
<Thickness x:Key="ExpanderContentPadding">20,0,0,0</Thickness>
<Thickness x:Key="ExpanderMinHeight">1</Thickness>
<Thickness x:Key="GridViewHeaderPadding">12,8,12,0</Thickness>
<Thickness x:Key="GridViewHeaderMinHeight">0</Thickness>
<Thickness x:Key="GridViewHeaderItemMinHeight">0</Thickness>
<Thickness x:Key="ListViewRowPadding">8,0,8,8</Thickness>
<Thickness x:Key="ListViewHeaderGridHeight">38</Thickness>
<Thickness x:Key="ListedItemPadding">10,0</Thickness>
<Thickness x:Key="ListedItemHeight">32</Thickness>
<Thickness x:Key="ListViewMinHeight">1</Thickness>
<Thickness x:Key="ListViewHeight">36</Thickness>
<Thickness x:Key="ListViewItemMinHeight">1</Thickness>
<Thickness x:Key="ListViewHeaderItemPadding">12,8,12,0</Thickness>
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<SolidColorBrush x:Key="ApplicationPageBackgroundThemeBrush" Color="{StaticResource SystemColorWindowColor}" />
Expand Down Expand Up @@ -152,6 +178,19 @@
<StaticResource x:Key="SidebarContentBackgroundBrush" ResourceKey="LayerFillColorDefaultBrush" />
<SolidColorBrush x:Key="TitlebarContentBackgroundBrush" Color="Transparent" />
<SolidColorBrush x:Key="NavigationViewContentBackground" Color="#0F000000" />
<Thickness x:Key="ExpanderContentPadding">20,0,0,0</Thickness>
<Thickness x:Key="ExpanderMinHeight">1</Thickness>
<Thickness x:Key="GridViewHeaderPadding">12,8,12,0</Thickness>
<Thickness x:Key="GridViewHeaderMinHeight">0</Thickness>
<Thickness x:Key="GridViewHeaderItemMinHeight">0</Thickness>
<Thickness x:Key="ListViewRowPadding">8,0,8,8</Thickness>
<Thickness x:Key="ListViewHeaderGridHeight">38</Thickness>
<Thickness x:Key="ListedItemPadding">10,0</Thickness>
<Thickness x:Key="ListedItemHeight">32</Thickness>
<Thickness x:Key="ListViewMinHeight">1</Thickness>
<Thickness x:Key="ListViewHeight">36</Thickness>
<Thickness x:Key="ListViewItemMinHeight">1</Thickness>
<Thickness x:Key="ListViewHeaderItemPadding">12,8,12,0</Thickness>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<LinearGradientBrush x:Key="ControlElevationBorderBrush" MappingMode="Absolute" StartPoint="0,0" EndPoint="0,3">
Expand Down
28 changes: 28 additions & 0 deletions src/Files/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Navigation;
Expand Down Expand Up @@ -317,6 +318,7 @@ public BaseLayout()
protected abstract void HookEvents();

protected abstract void UnhookEvents();
protected abstract SelectorItem ContainerFromItem(ListedItem listedItem);

private void HookBaseEvents()
{
Expand Down Expand Up @@ -516,6 +518,32 @@ public void SetSelectedItemsOnNavigation()
{
}
}
public void UpdateAppearanceSettings()
{
foreach (ListedItem listedItem in ParentShellPageInstance.FilesystemViewModel.FilesAndFolders.ToList())
{
try
{
Control itemContainer = ContainerFromItem(listedItem);
if (itemContainer != null)
{
// Doing it this way to keep Left and Right Margin and Padding for the selectedItem selector (the little blue bar)
itemContainer.Margin = new Thickness(itemContainer.Margin.Left, listedItem.SpacingSize/2, itemContainer.Margin.Right, listedItem.SpacingSize/2);
itemContainer.Padding = new Thickness(itemContainer.Padding.Left, listedItem.PaddingSize / 2, itemContainer.Padding.Right, listedItem.PaddingSize / 2);
// Leaving this here in case we'll want to change the ListViewItem/GridViewItem children in the future
//Grid itemGrid = itemContainer.FindDescendant<Grid>();
//if (itemGrid != null)
//{
// itemGrid.Padding = listedItem.PaddingSize;
//}
}
}
catch (Exception error)
{
Debug.WriteLine(error.Message);
}
}
}

private CancellationTokenSource groupingCancellationToken;

Expand Down
21 changes: 21 additions & 0 deletions src/Files/Filesystem/ListedItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Linq;
using System.Threading;
using Windows.Storage;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media.Imaging;

#pragma warning disable CS0618 // Type or member is obsolete
Expand All @@ -25,6 +26,26 @@ public class ListedItem : ObservableObject, IGroupableItem
{
protected static IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetService<IUserSettingsService>();

// Need to access this in the DataTemplate to read the updated padding
public double SpacingSize
{
get => UserSettingsService.AppearanceSettingsService.SpacingSizePx;
set
{
OnPropertyChanged(nameof(SpacingSize));
}
}

public double PaddingSize
{
get => UserSettingsService.AppearanceSettingsService.PaddingSizePx;
set
{
OnPropertyChanged(nameof(PaddingSize));
}
}


protected static IFileTagsSettingsService FileTagsSettingsService { get; } = Ioc.Default.GetService<IFileTagsSettingsService>();

public bool IsHiddenItem { get; set; } = false;
Expand Down
2 changes: 2 additions & 0 deletions src/Files/Helpers/RegistryToJsonSettingsMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public static void MergeSettings()
userSettingsService.PreferencesSettingsService.OpenFoldersInNewTab = appSettings.Get(false, "OpenFoldersNewTab");

// Appearance
userSettingsService.AppearanceSettingsService.SpacingSizePx = appSettings.Get(2d, "SpacingSizePx");
userSettingsService.AppearanceSettingsService.PaddingSizePx = appSettings.Get(2d, "PaddingSizePx");
userSettingsService.AppearanceSettingsService.MoveOverflowMenuItemsToSubMenu = appSettings.Get(true, "MoveOverflowMenuItemsToSubMenu");

// Startup
Expand Down
10 changes: 10 additions & 0 deletions src/Files/Services/IAppearanceSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ public interface IAppearanceSettingsService : IBaseSettingsService, INotifyPrope

#region Internal Settings

/// <summary>
/// Gets or sets a value indicating the spacing size in px of the items in list view.
/// </summary>
double SpacingSizePx { get; set; }

/// <summary>
/// Gets or sets a value indicating the padding size in px of the items in list view.
/// </summary>
double PaddingSizePx { get; set; }

/// <summary>
/// Gets or sets a value indicating the width of the sidebar pane when open.
/// </summary>
Expand Down
14 changes: 14 additions & 0 deletions src/Files/Services/Implementation/AppearanceSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ public double SidebarWidth
get => Get(Math.Min(Math.Max(Get(255d), Constants.UI.MinimumSidebarWidth), 500d));
set => Set(value);
}
public double SpacingSizePx
{
get => Get(Math.Min(Math.Max(Get(100d), 2d), 50d));
set => Set(value);
}
public double PaddingSizePx
{
get => Get(Math.Min(Math.Max(Get(100d), 2d), 50d));
set => Set(value);
}

public bool IsSidebarOpen
{
Expand Down Expand Up @@ -81,6 +91,8 @@ public override void RaiseOnSettingChangedEvent(object sender, EventArguments.Se
switch (e.settingName)
{
case nameof(MoveOverflowMenuItemsToSubMenu):
case nameof(SpacingSizePx):
case nameof(PaddingSizePx):
case nameof(ShowFavoritesSection):
case nameof(ShowLibrarySection):
case nameof(ShowCloudDrivesSection):
Expand All @@ -98,6 +110,8 @@ public void ReportToAppCenter()
{
Analytics.TrackEvent($"{nameof(MoveOverflowMenuItemsToSubMenu)}, {MoveOverflowMenuItemsToSubMenu}");
Analytics.TrackEvent($"{nameof(ShowFavoritesSection)}, {ShowFavoritesSection}");
Analytics.TrackEvent($"{nameof(SpacingSizePx)}, {SpacingSizePx}");
Analytics.TrackEvent($"{nameof(PaddingSizePx)}, {PaddingSizePx}");
Analytics.TrackEvent($"{nameof(ShowLibrarySection)}, {ShowLibrarySection}");
Analytics.TrackEvent($"{nameof(ShowCloudDrivesSection)}, {ShowCloudDrivesSection}");
Analytics.TrackEvent($"{nameof(ShowNetworkDrivesSection)}, {ShowNetworkDrivesSection}");
Expand Down
59 changes: 53 additions & 6 deletions src/Files/UserControls/InnerNavigationToolbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -752,24 +752,71 @@
BorderBrush="{ThemeResource ControlStrokeColorDefault}"
BorderThickness="1" />

<Grid RowSpacing="4">
<Grid RowSpacing="4" ColumnSpacing="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="15" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition MinHeight="40" />
<RowDefinition MinHeight="40" />
<RowDefinition MinHeight="30" />
<RowDefinition MinHeight="30" />
</Grid.RowDefinitions>
<TextBlock
x:Uid="NavToolbarShowHiddenItemsHeader"
x:Uid="NavToolbarSpacingSliderHeader"
Grid.Row="0"
Grid.Column="0"
VerticalAlignment="Center"
Text="Spacing" />
<Slider
x:Uid="NavToolbarSpacingSlider"
Grid.Row="0"
Grid.Column="1"
Minimum="1"
Maximum="30"
TickFrequency="1"
TickPlacement="BottomRight"
Value="{x:Bind UserSettingsService.AppearanceSettingsService.SpacingSizePx, Mode=TwoWay}"
ValueChanged="NavToolbarSpacingSlider_ValueChanged"
/>
<TextBlock
Grid.Row="0"
Grid.Column="2"
VerticalAlignment="Center"
Text="px " />
<TextBlock
x:Uid="NavToolbarPaddingSliderHeader"
Grid.Row="1"
Grid.Column="0"
VerticalAlignment="Center"
Text="Padding " />
<Slider
x:Uid="NavToolbarPaddingSlider"
Grid.Row="1"
Grid.Column="1"
Minimum="1"
Maximum="30"
TickFrequency="1"
TickPlacement="BottomRight"
Value="{x:Bind UserSettingsService.AppearanceSettingsService.PaddingSizePx, Mode=TwoWay}"
ValueChanged="NavToolbarPaddingSlider_ValueChanged"
/>
<TextBlock
Grid.Row="1"
Grid.Column="2"
VerticalAlignment="Center"
Text="px " />
<TextBlock
x:Uid="NavToolbarShowHiddenItemsHeader"
Grid.Row="2"
Grid.Column="0"
VerticalAlignment="Center"
Text="Show hidden items" />
<ToggleSwitch
x:Uid="NavToolbarShowHiddenItems"
Grid.Row="0"
Grid.Row="2"
Grid.Column="1"
HorizontalAlignment="Right"
AutomationProperties.Name="Show hidden items"
Expand All @@ -778,13 +825,13 @@

<TextBlock
x:Uid="NavToolbarShowFileExtensionsHeader"
Grid.Row="1"
Grid.Row="3"
Grid.Column="0"
VerticalAlignment="Center"
Text="Show file extensions" />
<ToggleSwitch
x:Uid="NavToolbarShowFileExtensions"
Grid.Row="1"
Grid.Row="3"
Grid.Column="1"
HorizontalAlignment="Right"
AutomationProperties.Name="Show file extensions"
Expand Down
9 changes: 9 additions & 0 deletions src/Files/UserControls/InnerNavigationToolbar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ private void NewEmptySpace_Opening(object sender, object e)
}
}

private void NavToolbarSpacingSlider_ValueChanged(object sender, Windows.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e)
{
UserSettingsService.AppearanceSettingsService.SpacingSizePx = e.NewValue;
}
private void NavToolbarPaddingSlider_ValueChanged(object sender, Windows.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e)
{
UserSettingsService.AppearanceSettingsService.PaddingSizePx = e.NewValue;

}
private void NavToolbarDetailsHeader_Tapped(object sender, TappedRoutedEventArgs e)
=> ViewModel.InstanceViewModel.FolderSettings.ToggleLayoutModeDetailsView.Execute(true);
private void NavToolbarTilesHeader_Tapped(object sender, TappedRoutedEventArgs e)
Expand Down
8 changes: 4 additions & 4 deletions src/Files/UserControls/Settings/SettingsBlockControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
<Setter Property="BorderBrush" Value="{ThemeResource ExpanderHeaderBorderBrush}" />
<Setter Property="BorderThickness" Value="{ThemeResource ExpanderHeaderBorderThickness}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="MinHeight" Value="{StaticResource ExpanderMinHeight}" />
<Setter Property="Padding" Value="{StaticResource ExpanderContentPadding}" />
<Setter Property="MinHeight" Value="{ThemeResource ExpanderMinHeight}" />
<Setter Property="Padding" Value="{ThemeResource ExpanderContentPadding}" />
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
</Style>

Expand All @@ -44,8 +44,8 @@
<Setter Property="BorderThickness" Value="{ThemeResource ExpanderHeaderBorderThickness}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Padding" Value="{StaticResource ExpanderContentPadding}" />
<Setter Property="MinHeight" Value="{StaticResource ExpanderMinHeight}" />
<Setter Property="Padding" Value="{ThemeResource ExpanderContentPadding}" />
<Setter Property="MinHeight" Value="{ThemeResource ExpanderMinHeight}" />
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
</Style>
</UserControl.Resources>
Expand Down
Loading