Skip to content

Commit 0ddad70

Browse files
mohnjilesclaude
andcommitted
Fit Images toggle: choose between blur-fit and crop-fill cards
Some users prefer the original UniformToFill behavior (sharper, edge- to-edge fill — at the cost of cropping portrait images) over the new blur-fit pattern. Add a "Fit Images" ToggleButton next to Hide Installed and a CivArchiveBrowserFitCardImages setting (default true so the new behavior is the out-of-box experience). Card template now has three mutually-exclusive image layers chosen by the parent VM's FitCardImages flag: - Fit on (default): blurred UniformToFill background + Uniform foreground - Fit off: single UniformToFill (original cropped fill) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f5bf411 commit 0ddad70

3 files changed

Lines changed: 48 additions & 6 deletions

File tree

StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CivArchiveBrowserViewModel.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ IModelIndexService modelIndexService
5656
[ObservableProperty]
5757
private double resizeFactor = 1.0;
5858

59+
/// <summary>
60+
/// True (default) renders card images in Fit mode (whole image visible with a blurred
61+
/// edge-fill behind it). False switches to Fill mode (UniformToFill, may crop edges).
62+
/// </summary>
63+
[ObservableProperty]
64+
private bool fitCardImages = true;
65+
5966
public bool IsEndOfResults => HasSearched && TotalHits > 0 && rawResults.Count >= TotalHits;
6067

6168
public bool HasResultCount => HasSearched && TotalHits > 0;
@@ -232,6 +239,15 @@ protected override async Task OnInitialLoadedAsync()
232239
)
233240
);
234241

242+
AddDisposable(
243+
settingsManager.RelayPropertyFor(
244+
this,
245+
vm => vm.FitCardImages,
246+
s => s.CivArchiveBrowserFitCardImages,
247+
true
248+
)
249+
);
250+
235251
EventHandler indexHandler = (_, _) => Dispatcher.UIThread.Post(OnLocalModelIndexChanged);
236252
EventManager.Instance.ModelIndexChanged += indexHandler;
237253
AddDisposable(Disposable.Create(() => EventManager.Instance.ModelIndexChanged -= indexHandler));

StabilityMatrix.Avalonia/Views/CivArchiveBrowserPage.axaml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,15 @@
135135
<Grid Width="330" RowDefinitions="300,Auto">
136136
<Grid ClipToBounds="True">
137137
<!--
138-
Two-layer blur-fill so portrait images aren't cropped (Uniform on the
139-
foreground keeps the whole image visible) but we don't get letterbox
140-
bars either (the same image, blurred and UniformToFilled, fills the
141-
leftover space behind it).
138+
Three image layers, mutually-exclusive based on the FitCardImages
139+
toggle on the parent VM:
140+
• Fit mode (default): blurred UniformToFill background +
141+
Uniform foreground (whole image visible, no letterbox).
142+
• Fill mode: single UniformToFill (may crop edges, original).
142143
-->
143144
<controls:BetterAdvancedImage
144145
CornerRadius="8"
145-
IsVisible="{Binding ImageUrl, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
146+
IsVisible="{Binding $parent[scroll:BetterScrollViewer].((checkpointBrowser:CivArchiveBrowserViewModel)DataContext).FitCardImages, FallbackValue=True, TargetNullValue=True}"
146147
Source="{Binding ImageUrl}"
147148
Stretch="UniformToFill">
148149
<controls:BetterAdvancedImage.Effect>
@@ -151,9 +152,14 @@
151152
</controls:BetterAdvancedImage>
152153
<controls:BetterAdvancedImage
153154
CornerRadius="8"
154-
IsVisible="{Binding ImageUrl, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
155+
IsVisible="{Binding $parent[scroll:BetterScrollViewer].((checkpointBrowser:CivArchiveBrowserViewModel)DataContext).FitCardImages, FallbackValue=True, TargetNullValue=True}"
155156
Source="{Binding ImageUrl}"
156157
Stretch="Uniform" />
158+
<controls:BetterAdvancedImage
159+
CornerRadius="8"
160+
IsVisible="{Binding !$parent[scroll:BetterScrollViewer].((checkpointBrowser:CivArchiveBrowserViewModel)DataContext).FitCardImages, FallbackValue=False, TargetNullValue=False}"
161+
Source="{Binding ImageUrl}"
162+
Stretch="UniformToFill" />
157163

158164
<!-- Placeholder when no image -->
159165
<Border Background="{DynamicResource ControlAltFillColorSecondaryBrush}" IsVisible="{Binding ImageUrl, Converter={x:Static StringConverters.IsNullOrEmpty}}">
@@ -768,6 +774,24 @@
768774
</ToggleButton>
769775
</StackPanel>
770776

777+
<!-- Fit Images toggle: on = whole image with blurred edge fill, off = crop to fill -->
778+
<StackPanel Margin="0,0,4,4" Spacing="2">
779+
<TextBlock
780+
Margin="2,0,0,0"
781+
FontSize="11"
782+
Opacity="0"
783+
Text="." />
784+
<ToggleButton IsChecked="{Binding FitCardImages, Mode=TwoWay}" ToolTip.Tip="Fit: show whole image with blurred edges. Off: crop to fill (may cut off content).">
785+
<StackPanel Orientation="Horizontal" Spacing="6">
786+
<fa:Icon
787+
VerticalAlignment="Center"
788+
FontSize="12"
789+
Value="fa-solid fa-image" />
790+
<TextBlock VerticalAlignment="Center" Text="Fit Images" />
791+
</StackPanel>
792+
</ToggleButton>
793+
</StackPanel>
794+
771795
<!-- Reset filters -->
772796
<StackPanel Margin="0,0,0,4" Spacing="2">
773797
<TextBlock

StabilityMatrix.Core/Models/Settings/Settings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ public IReadOnlyDictionary<string, string> EnvironmentVariables
252252

253253
public double CivArchiveBrowserResizeFactor { get; set; } = 1.0d;
254254

255+
public bool CivArchiveBrowserFitCardImages { get; set; } = true;
256+
255257
public bool HideEarlyAccessModels { get; set; }
256258

257259
public bool CivitUseDiscoveryApi { get; set; }

0 commit comments

Comments
 (0)