From b80fa474e67e558e712a959020007062ad2447af Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Tue, 14 Jan 2025 20:48:52 -0500 Subject: [PATCH 01/15] Feature: Use DPI aware icons in the Details View --- .../Layout/LayoutPreferencesManager.cs | 8 +++++- src/Files.App/ViewModels/ShellViewModel.cs | 9 ++++--- .../Views/Layouts/DetailsLayoutPage.xaml | 12 +++++---- .../Views/Layouts/DetailsLayoutPage.xaml.cs | 26 ++++++++++++++++++- .../Views/Layouts/GridLayoutPage.xaml.cs | 6 ++--- 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs b/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs index 7f17895d5c85..b147a040584e 100644 --- a/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs +++ b/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs @@ -227,7 +227,13 @@ public uint GetRoundedIconSize() { return LayoutMode switch { - FolderLayoutModes.DetailsView + _ when LayoutMode == FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize <= DetailsViewSizeKind.Small + => Constants.ShellIconSizes.Small, + _ when LayoutMode == FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Medium + => 20, + _ when LayoutMode == FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Large + => 24, + _ when LayoutMode == FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.ExtraLarge => Constants.ShellIconSizes.Large, FolderLayoutModes.ListView => Constants.ShellIconSizes.Large, diff --git a/src/Files.App/ViewModels/ShellViewModel.cs b/src/Files.App/ViewModels/ShellViewModel.cs index e70acabdcdf1..2b193edf04a7 100644 --- a/src/Files.App/ViewModels/ShellViewModel.cs +++ b/src/Files.App/ViewModels/ShellViewModel.cs @@ -975,6 +975,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell var loadNonCachedThumbnail = false; var thumbnailSize = folderSettings.GetRoundedIconSize(); var returnIconOnly = UserSettingsService.FoldersSettingsService.ShowThumbnails == false || thumbnailSize < 48; + var useCurrentScale = folderSettings.LayoutMode == FolderLayoutModes.DetailsView; byte[]? result = null; @@ -988,7 +989,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell item.ItemPath, thumbnailSize, item.IsFolder, - IconOptions.ReturnThumbnailOnly | IconOptions.ReturnOnlyIfCached); + IconOptions.ReturnThumbnailOnly | IconOptions.ReturnOnlyIfCached | (useCurrentScale ? IconOptions.UseCurrentScale : 0)); cancellationToken.ThrowIfCancellationRequested(); loadNonCachedThumbnail = true; @@ -1001,7 +1002,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell item.ItemPath, thumbnailSize, item.IsFolder, - IconOptions.ReturnIconOnly); + IconOptions.ReturnIconOnly | (useCurrentScale ? IconOptions.UseCurrentScale : 0)); cancellationToken.ThrowIfCancellationRequested(); } @@ -1013,7 +1014,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell item.ItemPath, thumbnailSize, item.IsFolder, - returnIconOnly ? IconOptions.ReturnIconOnly : IconOptions.None); + returnIconOnly ? IconOptions.ReturnIconOnly | (useCurrentScale ? IconOptions.UseCurrentScale : 0) : (useCurrentScale ? IconOptions.UseCurrentScale : 0)); cancellationToken.ThrowIfCancellationRequested(); } @@ -1059,7 +1060,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(async () => item.ItemPath, thumbnailSize, item.IsFolder, - IconOptions.ReturnThumbnailOnly); + IconOptions.ReturnThumbnailOnly | (useCurrentScale ? IconOptions.UseCurrentScale : 0)); } finally { diff --git a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml index fd0cccd58557..74174bcaee2b 100644 --- a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml +++ b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml @@ -903,13 +903,16 @@ Loaded="StackPanel_Loaded" Orientation="Horizontal"> - + new GridLength(20), + DetailsViewSizeKind.Small => new GridLength(20), + DetailsViewSizeKind.Medium => new GridLength(24), + DetailsViewSizeKind.Large => new GridLength(28), + DetailsViewSizeKind.ExtraLarge => new GridLength(36), + _ => new GridLength(20) + }; + + ColumnsViewModel.IconColumn.UserLength = iconColumnWidth; } private void FileList_LayoutUpdated(object? sender, object e) diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs index 52958f736d02..2ef71e7eb58f 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs @@ -140,7 +140,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs) var parameters = (NavigationArguments)eventArgs.Parameter; if (parameters.IsLayoutSwitch) - ReloadItemIconsAsync(); + _ = ReloadItemIconsAsync(); } protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) @@ -204,7 +204,7 @@ private async void FolderSettings_LayoutModeChangeRequested(object? sender, Layo if (requestedIconSize != currentIconSize) { currentIconSize = requestedIconSize; - await ReloadItemIconsAsync(); + _ = ReloadItemIconsAsync(); } } } @@ -497,7 +497,7 @@ private async void FolderSettings_IconHeightChanged() { // Update icon size before refreshing currentIconSize = requestedIconSize; - await ReloadItemIconsAsync(); + _ = ReloadItemIconsAsync(); } } From ad7a17fa6756c17df505aecd795d357c075f00ca Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 15 Jan 2025 10:08:08 -0500 Subject: [PATCH 02/15] Update GridLayoutPage.xaml.cs --- src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs index 2ef71e7eb58f..eba65a6642b4 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs @@ -204,7 +204,8 @@ private async void FolderSettings_LayoutModeChangeRequested(object? sender, Layo if (requestedIconSize != currentIconSize) { currentIconSize = requestedIconSize; - _ = ReloadItemIconsAsync(); + // Don't change this await https://github.com/files-community/Files/pull/16708#discussion_r1916402106 + await ReloadItemIconsAsync(); } } } From de0ea8c04119823af89fc88b19752c6140e0c8cd Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 15 Jan 2025 20:06:33 -0500 Subject: [PATCH 03/15] Support for ListView --- .../Layout/LayoutPreferencesManager.cs | 46 ------------------- .../Helpers/Layout/LayoutSizeKindHelper.cs | 35 ++++++++++++++ src/Files.App/ViewModels/ShellViewModel.cs | 4 +- .../Views/Layouts/DetailsLayoutPage.xaml.cs | 16 ++----- .../Views/Layouts/GridLayoutPage.xaml | 7 ++- .../Views/Layouts/GridLayoutPage.xaml.cs | 17 +++++-- 6 files changed, 55 insertions(+), 70 deletions(-) diff --git a/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs b/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs index b147a040584e..5f350b9dba5e 100644 --- a/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs +++ b/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs @@ -1,9 +1,6 @@ // Copyright (c) Files Community // Licensed under the MIT License. -using Files.App.Data.Enums; -using System.Text.Json; -using Windows.Storage; using Windows.Win32; namespace Files.App.Helpers @@ -205,49 +202,6 @@ public LayoutPreferencesManager(FolderLayoutModes modeOverride) : this() // Methods - /// - /// This will round the current icon size to get the best result from the File Explorer thumbnail system. - /// - /// Details View: - /// Always uses the Large icon size (32). - /// - /// List View: - /// Always uses the Large icon size (32). - /// - /// Columns View: - /// Always uses the Large icon size (32). - /// - /// Tiles View: - /// Always uses 96, 128, or 256 depending on the layout size. - /// - /// Grid View: - /// Always uses 96, 128, or 256 depending on the layout size. - /// - public uint GetRoundedIconSize() - { - return LayoutMode switch - { - _ when LayoutMode == FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize <= DetailsViewSizeKind.Small - => Constants.ShellIconSizes.Small, - _ when LayoutMode == FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Medium - => 20, - _ when LayoutMode == FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Large - => 24, - _ when LayoutMode == FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.ExtraLarge - => Constants.ShellIconSizes.Large, - FolderLayoutModes.ListView - => Constants.ShellIconSizes.Large, - FolderLayoutModes.ColumnView - => Constants.ShellIconSizes.Large, - _ when LayoutMode == FolderLayoutModes.GridView && UserSettingsService.LayoutSettingsService.GridViewSize <= GridViewSizeKind.Small || - LayoutMode == FolderLayoutModes.TilesView - => 96, - _ when LayoutMode == FolderLayoutModes.GridView && UserSettingsService.LayoutSettingsService.GridViewSize <= GridViewSizeKind.Large - => 128, - _ => 256, - }; - } - public Type GetLayoutType(string path, bool changeLayoutMode = true) { var preferencesItem = GetLayoutPreferencesForPath(path); diff --git a/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs b/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs index 9f45fad22c2f..41c8ba6316fa 100644 --- a/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs +++ b/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs @@ -93,6 +93,41 @@ public static int GetListViewRowHeight(ListViewSizeKind listViewSizeKind) } } + /// + /// Gets the desired icon size for specified layout + /// + /// + /// + public static uint GetIconSize(FolderLayoutModes folderLayoutMode) + { + return folderLayoutMode switch + { + // Details + FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Compact => Constants.ShellIconSizes.Small, + FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Small => Constants.ShellIconSizes.Small, + FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Medium => 20, + FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Large => 24, + FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.ExtraLarge => Constants.ShellIconSizes.Large, + + // List + FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Compact => Constants.ShellIconSizes.Small, + FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Small => Constants.ShellIconSizes.Small, + FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Medium => 20, + FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Large => 24, + FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.ExtraLarge => Constants.ShellIconSizes.Large, + + // Columns + FolderLayoutModes.ColumnView => Constants.ShellIconSizes.Large, + + // Grid and Tiles + FolderLayoutModes.GridView when LayoutSettingsService.GridViewSize <= GridViewSizeKind.Small => 96, + FolderLayoutModes.TilesView => 96, + FolderLayoutModes.GridView when LayoutSettingsService.GridViewSize <= GridViewSizeKind.Large => 128, + + _ => 256, + }; + } + /// /// Gets the desired height for items in the Columns View /// diff --git a/src/Files.App/ViewModels/ShellViewModel.cs b/src/Files.App/ViewModels/ShellViewModel.cs index 2b193edf04a7..c6c4cb52db55 100644 --- a/src/Files.App/ViewModels/ShellViewModel.cs +++ b/src/Files.App/ViewModels/ShellViewModel.cs @@ -973,9 +973,9 @@ private async Task GetShieldIcon() private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancellationToken) { var loadNonCachedThumbnail = false; - var thumbnailSize = folderSettings.GetRoundedIconSize(); + var thumbnailSize = LayoutSizeKindHelper.GetIconSize(folderSettings.LayoutMode); var returnIconOnly = UserSettingsService.FoldersSettingsService.ShowThumbnails == false || thumbnailSize < 48; - var useCurrentScale = folderSettings.LayoutMode == FolderLayoutModes.DetailsView; + var useCurrentScale = folderSettings.LayoutMode == FolderLayoutModes.DetailsView || folderSettings.LayoutMode == FolderLayoutModes.ListView; byte[]? result = null; diff --git a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs index 70815d83ed4d..fca53a9ef5a1 100644 --- a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs @@ -137,7 +137,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs) base.OnNavigatedTo(eventArgs); - currentIconSize = FolderSettings.GetRoundedIconSize(); + currentIconSize = LayoutSizeKindHelper.GetIconSize(FolderLayoutModes.DetailsView); if (FolderSettings?.ColumnsViewModel is not null) { @@ -210,7 +210,7 @@ private async void LayoutSettingsService_PropertyChanged(object? sender, Propert ContentScroller?.ChangeView(null, previousOffset, null); // Reload icons with correct size but only if the size changed - var requestedIconSize = FolderSettings.GetRoundedIconSize(); + var requestedIconSize = LayoutSizeKindHelper.GetIconSize(FolderLayoutModes.DetailsView); if (requestedIconSize != currentIconSize) { currentIconSize = requestedIconSize; @@ -268,17 +268,7 @@ private void SetItemContainerStyle() } // Set icon column width - var iconColumnWidth = UserSettingsService.LayoutSettingsService.DetailsViewSize switch - { - DetailsViewSizeKind.Compact => new GridLength(20), - DetailsViewSizeKind.Small => new GridLength(20), - DetailsViewSizeKind.Medium => new GridLength(24), - DetailsViewSizeKind.Large => new GridLength(28), - DetailsViewSizeKind.ExtraLarge => new GridLength(36), - _ => new GridLength(20) - }; - - ColumnsViewModel.IconColumn.UserLength = iconColumnWidth; + ColumnsViewModel.IconColumn.UserLength = new GridLength(LayoutSizeKindHelper.GetIconSize(FolderLayoutModes.DetailsView) + 4); } private void FileList_LayoutUpdated(object? sender, object e) diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml b/src/Files.App/Views/Layouts/GridLayoutPage.xaml index de9dff0df41c..4a394e65df23 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml @@ -302,8 +302,8 @@ LayoutSizeKindHelper.GetListViewRowHeight(UserSettingsService.LayoutSettingsService.ListViewSize); } + + /// + /// Icon Box size in the List View layout. The value is increased by 4px to account for icon overlays. + /// + public int IconBoxSizeListView + { + get => (int)(LayoutSizeKindHelper.GetIconSize(FolderLayoutModes.ListView) + 4); + } /// /// Item width in the Tiles View layout @@ -127,7 +135,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs) base.OnNavigatedTo(eventArgs); - currentIconSize = FolderSettings.GetRoundedIconSize(); + currentIconSize = LayoutSizeKindHelper.GetIconSize(FolderSettings.LayoutMode); FolderSettings.LayoutModeChangeRequested -= FolderSettings_LayoutModeChangeRequested; FolderSettings.LayoutModeChangeRequested += FolderSettings_LayoutModeChangeRequested; @@ -162,10 +170,10 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang if (e.PropertyName == nameof(ILayoutSettingsService.ListViewSize)) { NotifyPropertyChanged(nameof(RowHeightListView)); + NotifyPropertyChanged(nameof(IconBoxSizeListView)); // Update the container style to match the item size SetItemContainerStyle(); - FolderSettings_IconHeightChanged(); } if (e.PropertyName == nameof(ILayoutSettingsService.TilesViewSize)) @@ -182,7 +190,6 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang // Update the container style to match the item size SetItemContainerStyle(); - FolderSettings_IconHeightChanged(); } @@ -200,7 +207,7 @@ private async void FolderSettings_LayoutModeChangeRequested(object? sender, Layo SetItemTemplate(); SetItemContainerStyle(); - var requestedIconSize = FolderSettings.GetRoundedIconSize(); + var requestedIconSize = LayoutSizeKindHelper.GetIconSize(FolderSettings.LayoutMode); if (requestedIconSize != currentIconSize) { currentIconSize = requestedIconSize; @@ -491,7 +498,7 @@ protected override bool CanGetItemFromElement(object element) private async void FolderSettings_IconHeightChanged() { // Get new icon size - var requestedIconSize = FolderSettings.GetRoundedIconSize(); + var requestedIconSize = LayoutSizeKindHelper.GetIconSize(FolderSettings.LayoutMode); // Prevents reloading icons when the icon size hasn't changed if (requestedIconSize != currentIconSize) From 4e444dd5eee722ab0686d2bacfdfef0cfb3a6f91 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 15 Jan 2025 20:11:51 -0500 Subject: [PATCH 04/15] Comments --- src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs | 4 ++-- src/Files.App/ViewModels/ShellViewModel.cs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs b/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs index 41c8ba6316fa..776c8c57c28c 100644 --- a/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs +++ b/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs @@ -94,9 +94,9 @@ public static int GetListViewRowHeight(ListViewSizeKind listViewSizeKind) } /// - /// Gets the desired icon size for specified layout + /// Gets the desired icon size for the requested layout /// - /// + /// /// public static uint GetIconSize(FolderLayoutModes folderLayoutMode) { diff --git a/src/Files.App/ViewModels/ShellViewModel.cs b/src/Files.App/ViewModels/ShellViewModel.cs index c6c4cb52db55..0fb64590672d 100644 --- a/src/Files.App/ViewModels/ShellViewModel.cs +++ b/src/Files.App/ViewModels/ShellViewModel.cs @@ -975,6 +975,8 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell var loadNonCachedThumbnail = false; var thumbnailSize = LayoutSizeKindHelper.GetIconSize(folderSettings.LayoutMode); var returnIconOnly = UserSettingsService.FoldersSettingsService.ShowThumbnails == false || thumbnailSize < 48; + + // TODO Remove this property when all the layouts can support different icon sizes var useCurrentScale = folderSettings.LayoutMode == FolderLayoutModes.DetailsView || folderSettings.LayoutMode == FolderLayoutModes.ListView; byte[]? result = null; From e5d8a7305c0011555a647e7de401d5c2768d1477 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 15 Jan 2025 20:16:59 -0500 Subject: [PATCH 05/15] Comments --- src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs | 5 +++++ src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs index fca53a9ef5a1..1215b958354c 100644 --- a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs @@ -29,6 +29,11 @@ public sealed partial class DetailsLayoutPage : BaseGroupableLayoutPage // Fields private ListedItem? _nextItemToSelect; + + /// + /// This reference is used to prevent unnecessary icon reloading by only reloading icons when their + /// size changes, even if the layout size changes (since some layout sizes share the same icon size). + /// private uint currentIconSize; // Properties diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs index 61ae6983c79d..f564d33e7b6c 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs @@ -23,7 +23,12 @@ public sealed partial class GridLayoutPage : BaseGroupableLayoutPage { // Fields + /// + /// This reference is used to prevent unnecessary icon reloading by only reloading icons when their + /// size changes, even if the layout size changes (since some layout sizes share the same icon size). + /// private uint currentIconSize; + private volatile bool shouldSetVerticalScrollMode; // Properties @@ -41,7 +46,7 @@ public int RowHeightListView { get => LayoutSizeKindHelper.GetListViewRowHeight(UserSettingsService.LayoutSettingsService.ListViewSize); } - + /// /// Icon Box size in the List View layout. The value is increased by 4px to account for icon overlays. /// From 0f955e1509054fa0582cd4dc80abd4f569ddc910 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 15 Jan 2025 20:17:45 -0500 Subject: [PATCH 06/15] Update DetailsLayoutPage.xaml.cs --- src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs index 1215b958354c..1fb883f83ccf 100644 --- a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs @@ -199,7 +199,7 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) UserSettingsService.LayoutSettingsService.PropertyChanged -= LayoutSettingsService_PropertyChanged; } - private async void LayoutSettingsService_PropertyChanged(object? sender, PropertyChangedEventArgs e) + private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(ILayoutSettingsService.DetailsViewSize)) { From 485fa5e1247deb6b5db2b2079bc70640089b9d39 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 15 Jan 2025 20:21:54 -0500 Subject: [PATCH 07/15] C --- .../Views/Layouts/DetailsLayoutPage.xaml.cs | 8 ++--- .../Views/Layouts/GridLayoutPage.xaml.cs | 30 +++++++------------ 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs index 1fb883f83ccf..964f5e900228 100644 --- a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs @@ -214,11 +214,11 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang // Restore correct scroll position ContentScroller?.ChangeView(null, previousOffset, null); - // Reload icons with correct size but only if the size changed - var requestedIconSize = LayoutSizeKindHelper.GetIconSize(FolderLayoutModes.DetailsView); - if (requestedIconSize != currentIconSize) + // Check if icons need to be reloaded + var newIconSize = LayoutSizeKindHelper.GetIconSize(FolderLayoutModes.DetailsView); + if (newIconSize != currentIconSize) { - currentIconSize = requestedIconSize; + currentIconSize = newIconSize; _ = ReloadItemIconsAsync(); } } diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs index f564d33e7b6c..3c8f951519dc 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs @@ -179,7 +179,7 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang // Update the container style to match the item size SetItemContainerStyle(); - FolderSettings_IconHeightChanged(); + FolderSettings_IconSizeChanged(); } if (e.PropertyName == nameof(ILayoutSettingsService.TilesViewSize)) { @@ -187,7 +187,7 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang // Update the container style to match the item size SetItemContainerStyle(); - FolderSettings_IconHeightChanged(); + FolderSettings_IconSizeChanged(); } if (e.PropertyName == nameof(ILayoutSettingsService.GridViewSize)) { @@ -195,14 +195,14 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang // Update the container style to match the item size SetItemContainerStyle(); - FolderSettings_IconHeightChanged(); + FolderSettings_IconSizeChanged(); } // Restore correct scroll position ContentScroller?.ChangeView(previousHorizontalOffset, previousVerticalOffset, null); } - private async void FolderSettings_LayoutModeChangeRequested(object? sender, LayoutModeEventArgs e) + private void FolderSettings_LayoutModeChangeRequested(object? sender, LayoutModeEventArgs e) { if (FolderSettings.LayoutMode == FolderLayoutModes.ListView || FolderSettings.LayoutMode == FolderLayoutModes.TilesView @@ -211,14 +211,7 @@ private async void FolderSettings_LayoutModeChangeRequested(object? sender, Layo // Set ItemTemplate SetItemTemplate(); SetItemContainerStyle(); - - var requestedIconSize = LayoutSizeKindHelper.GetIconSize(FolderSettings.LayoutMode); - if (requestedIconSize != currentIconSize) - { - currentIconSize = requestedIconSize; - // Don't change this await https://github.com/files-community/Files/pull/16708#discussion_r1916402106 - await ReloadItemIconsAsync(); - } + FolderSettings_IconSizeChanged(); } } @@ -500,16 +493,13 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv protected override bool CanGetItemFromElement(object element) => element is GridViewItem; - private async void FolderSettings_IconHeightChanged() + private void FolderSettings_IconSizeChanged() { - // Get new icon size - var requestedIconSize = LayoutSizeKindHelper.GetIconSize(FolderSettings.LayoutMode); - - // Prevents reloading icons when the icon size hasn't changed - if (requestedIconSize != currentIconSize) + // Check if icons need to be reloaded + var newIconSize = LayoutSizeKindHelper.GetIconSize(FolderSettings.LayoutMode); + if (newIconSize != currentIconSize) { - // Update icon size before refreshing - currentIconSize = requestedIconSize; + currentIconSize = newIconSize; _ = ReloadItemIconsAsync(); } } From 80aea5605c74aa6b46cf09b2455023a23af77bbc Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 15 Jan 2025 20:23:10 -0500 Subject: [PATCH 08/15] Update DetailsLayoutPage.xaml.cs --- src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs index 964f5e900228..c4ae0633368d 100644 --- a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs @@ -272,7 +272,7 @@ private void SetItemContainerStyle() FileList.ItemContainerStyle = RegularItemContainerStyle; } - // Set icon column width + // Set the width of the icon column. The value is increased by 4px to account for icon overlays. ColumnsViewModel.IconColumn.UserLength = new GridLength(LayoutSizeKindHelper.GetIconSize(FolderLayoutModes.DetailsView) + 4); } From 539ac2c2cf4a7748f3d196aac9cb70577e1430bc Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 15 Jan 2025 20:25:17 -0500 Subject: [PATCH 09/15] Update GridLayoutPage.xaml.cs --- src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs index 3c8f951519dc..b24102906d02 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs @@ -153,7 +153,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs) var parameters = (NavigationArguments)eventArgs.Parameter; if (parameters.IsLayoutSwitch) - _ = ReloadItemIconsAsync(); + FolderSettings_IconSizeChanged(); } protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) From 9dd4b16ec13c71f976378ee763de243778d47bca Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 15 Jan 2025 20:29:48 -0500 Subject: [PATCH 10/15] Update GridLayoutPage.xaml.cs --- src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs index b24102906d02..ee1435271b64 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs @@ -153,7 +153,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs) var parameters = (NavigationArguments)eventArgs.Parameter; if (parameters.IsLayoutSwitch) - FolderSettings_IconSizeChanged(); + ReloadItemIconsAsync(); } protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) From eeda9c047fc05016f3b4e9bdf56912611ae0031c Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Thu, 16 Jan 2025 10:29:11 -0500 Subject: [PATCH 11/15] Update src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs Co-authored-by: hishitetsu <66369541+hishitetsu@users.noreply.github.com> Signed-off-by: Yair <39923744+yaira2@users.noreply.github.com> --- src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs b/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs index 776c8c57c28c..25bda5f6dc5d 100644 --- a/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs +++ b/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs @@ -121,8 +121,8 @@ public static uint GetIconSize(FolderLayoutModes folderLayoutMode) // Grid and Tiles FolderLayoutModes.GridView when LayoutSettingsService.GridViewSize <= GridViewSizeKind.Small => 96, - FolderLayoutModes.TilesView => 96, FolderLayoutModes.GridView when LayoutSettingsService.GridViewSize <= GridViewSizeKind.Large => 128, + FolderLayoutModes.TilesView => 96, _ => 256, }; From 66f0ddd262db26543ccc953ec07f279d05e49c92 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Thu, 16 Jan 2025 10:29:22 -0500 Subject: [PATCH 12/15] Update src/Files.App/ViewModels/ShellViewModel.cs Co-authored-by: hishitetsu <66369541+hishitetsu@users.noreply.github.com> Signed-off-by: Yair <39923744+yaira2@users.noreply.github.com> --- src/Files.App/ViewModels/ShellViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/ViewModels/ShellViewModel.cs b/src/Files.App/ViewModels/ShellViewModel.cs index 0fb64590672d..be3c99997bf6 100644 --- a/src/Files.App/ViewModels/ShellViewModel.cs +++ b/src/Files.App/ViewModels/ShellViewModel.cs @@ -1004,7 +1004,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell item.ItemPath, thumbnailSize, item.IsFolder, - IconOptions.ReturnIconOnly | (useCurrentScale ? IconOptions.UseCurrentScale : 0)); + IconOptions.ReturnIconOnly | (useCurrentScale ? IconOptions.UseCurrentScale : IconOptions.None)); cancellationToken.ThrowIfCancellationRequested(); } From c3dee7b0729edfda6fb27a3627e4b631bb3643eb Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Thu, 16 Jan 2025 10:29:57 -0500 Subject: [PATCH 13/15] Update src/Files.App/ViewModels/ShellViewModel.cs Co-authored-by: hishitetsu <66369541+hishitetsu@users.noreply.github.com> Signed-off-by: Yair <39923744+yaira2@users.noreply.github.com> --- src/Files.App/ViewModels/ShellViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/ViewModels/ShellViewModel.cs b/src/Files.App/ViewModels/ShellViewModel.cs index be3c99997bf6..789c114dd3e3 100644 --- a/src/Files.App/ViewModels/ShellViewModel.cs +++ b/src/Files.App/ViewModels/ShellViewModel.cs @@ -991,7 +991,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell item.ItemPath, thumbnailSize, item.IsFolder, - IconOptions.ReturnThumbnailOnly | IconOptions.ReturnOnlyIfCached | (useCurrentScale ? IconOptions.UseCurrentScale : 0)); + IconOptions.ReturnThumbnailOnly | IconOptions.ReturnOnlyIfCached | (useCurrentScale ? IconOptions.UseCurrentScale : IconOptions.None)); cancellationToken.ThrowIfCancellationRequested(); loadNonCachedThumbnail = true; From 5a412d024928de3810ca19c4668186d40fdf873c Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Thu, 16 Jan 2025 10:30:15 -0500 Subject: [PATCH 14/15] Update src/Files.App/ViewModels/ShellViewModel.cs Co-authored-by: hishitetsu <66369541+hishitetsu@users.noreply.github.com> Signed-off-by: Yair <39923744+yaira2@users.noreply.github.com> --- src/Files.App/ViewModels/ShellViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/ViewModels/ShellViewModel.cs b/src/Files.App/ViewModels/ShellViewModel.cs index 789c114dd3e3..9f00aeb9f00d 100644 --- a/src/Files.App/ViewModels/ShellViewModel.cs +++ b/src/Files.App/ViewModels/ShellViewModel.cs @@ -1016,7 +1016,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell item.ItemPath, thumbnailSize, item.IsFolder, - returnIconOnly ? IconOptions.ReturnIconOnly | (useCurrentScale ? IconOptions.UseCurrentScale : 0) : (useCurrentScale ? IconOptions.UseCurrentScale : 0)); + (returnIconOnly ? IconOptions.ReturnIconOnly : IconOptions.None) | (useCurrentScale ? IconOptions.UseCurrentScale : IconOptions.None)); cancellationToken.ThrowIfCancellationRequested(); } From 64b624ed708d7c6c79206ecdb0071079e20761bb Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Thu, 16 Jan 2025 10:30:23 -0500 Subject: [PATCH 15/15] Update src/Files.App/ViewModels/ShellViewModel.cs Co-authored-by: hishitetsu <66369541+hishitetsu@users.noreply.github.com> Signed-off-by: Yair <39923744+yaira2@users.noreply.github.com> --- src/Files.App/ViewModels/ShellViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/ViewModels/ShellViewModel.cs b/src/Files.App/ViewModels/ShellViewModel.cs index 9f00aeb9f00d..40b950b695be 100644 --- a/src/Files.App/ViewModels/ShellViewModel.cs +++ b/src/Files.App/ViewModels/ShellViewModel.cs @@ -1062,7 +1062,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(async () => item.ItemPath, thumbnailSize, item.IsFolder, - IconOptions.ReturnThumbnailOnly | (useCurrentScale ? IconOptions.UseCurrentScale : 0)); + IconOptions.ReturnThumbnailOnly | (useCurrentScale ? IconOptions.UseCurrentScale : IconOptions.None)); } finally {