Skip to content

Commit 2cc3da6

Browse files
committedMar 25, 2025
Init
1 parent 3df6c02 commit 2cc3da6

19 files changed

+786
-586
lines changed
 

‎src/Files.App.Controls/BreadcrumbBar/BreadcrumbBar.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public BreadcrumbBar()
4242
{
4343
DefaultStyleKey = typeof(BreadcrumbBar);
4444

45-
_itemsRepeaterLayout = new(this, 2d);
45+
_itemsRepeaterLayout = new(this);
4646
}
4747

4848
// Methods

‎src/Files.App.Controls/BreadcrumbBar/BreadcrumbBar.xaml

+35-6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
xmlns:animatedvisuals="using:Microsoft.UI.Xaml.Controls.AnimatedVisuals"
66
xmlns:local="using:Files.App.Controls">
77

8-
<x:Double x:Key="BreadcrumbBarHeight">32</x:Double>
8+
<x:Double x:Key="BreadcrumbBarHeight">34</x:Double>
99
<x:Double x:Key="BreadcrumbBarMinWidth">120</x:Double>
1010
<x:Double x:Key="BreadcrumbBarEllipsisFontSize">16</x:Double>
1111

1212
<Thickness x:Key="BreadcrumbBarChevronPadding">4,0</Thickness>
1313
<Thickness x:Key="BreadcrumbBarItemPadding">8,0</Thickness>
1414
<Thickness x:Key="BreadcrumbBarRootItemPadding">16,0,8,0</Thickness>
15+
<Thickness x:Key="BreadcrumbBarItemMargin">2,0,0,0</Thickness>
1516

1617
<CornerRadius x:Key="BreadcrumbBarItemCornerRadius">2,2,2,2</CornerRadius>
1718
<CornerRadius x:Key="BreadcrumbBarChevronCornerRaduis">2,2,2,2</CornerRadius>
@@ -21,21 +22,33 @@
2122
<Style BasedOn="{StaticResource DefaultBreadcrumbBarItemStyle}" TargetType="local:BreadcrumbBarItem" />
2223

2324
<Style x:Key="DefaultBreadcrumbBarStyle" TargetType="local:BreadcrumbBar">
25+
2426
<Setter Property="MinWidth" Value="{StaticResource BreadcrumbBarMinWidth}" />
27+
28+
<Setter Property="HorizontalAlignment" Value="Stretch" />
29+
<Setter Property="HorizontalContentAlignment" Value="Center" />
30+
<Setter Property="VerticalAlignment" Value="Stretch" />
31+
<Setter Property="VerticalContentAlignment" Value="Center" />
32+
2533
<Setter Property="AutomationProperties.LandmarkType" Value="Navigation" />
34+
2635
<Setter Property="IsTabStop" Value="False" />
36+
2737
<Setter Property="Template">
2838
<Setter.Value>
2939
<ControlTemplate TargetType="local:BreadcrumbBar">
3040
<Grid
3141
MinWidth="{TemplateBinding MinWidth}"
32-
ColumnSpacing="2"
42+
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
43+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
44+
Background="{TemplateBinding Background}"
3345
TabFocusNavigation="Once"
3446
XYFocusKeyboardNavigation="Enabled">
3547
<Grid.ColumnDefinitions>
3648
<ColumnDefinition Width="Auto" />
3749
<ColumnDefinition Width="Auto" />
3850
<ColumnDefinition Width="*" />
51+
<ColumnDefinition Width="Auto" />
3952
</Grid.ColumnDefinitions>
4053

4154
<local:BreadcrumbBarItem
@@ -50,6 +63,7 @@
5063
<local:BreadcrumbBarItem
5164
x:Name="PART_EllipsisBreadcrumbBarItem"
5265
Grid.Column="1"
66+
Margin="{StaticResource BreadcrumbBarItemMargin}"
5367
AutomationProperties.AccessibilityView="Content"
5468
IsEllipsis="True"
5569
Visibility="Collapsed">
@@ -59,9 +73,18 @@
5973
<ItemsRepeater
6074
x:Name="PART_MainItemsRepeater"
6175
Grid.Column="2"
76+
Margin="{StaticResource BreadcrumbBarItemMargin}"
77+
HorizontalAlignment="Left"
6278
ItemTemplate="{Binding ItemTemplate, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
6379
ItemsSource="{Binding ItemsSource, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />
6480

81+
<Border Grid.Column="3" Canvas.ZIndex="-10">
82+
<FontIcon
83+
Margin="12,0,12,0"
84+
FontSize="14"
85+
Glyph="&#xE70D;" />
86+
</Border>
87+
6588
</Grid>
6689
</ControlTemplate>
6790
</Setter.Value>
@@ -85,7 +108,7 @@
85108
<Setter Property="HorizontalAlignment" Value="Stretch" />
86109
<Setter Property="HorizontalContentAlignment" Value="Center" />
87110
<Setter Property="VerticalAlignment" Value="Stretch" />
88-
<Setter Property="VerticalContentAlignment" Value="Center" />
111+
<Setter Property="VerticalContentAlignment" Value="Stretch" />
89112

90113
<Setter Property="FocusVisualMargin" Value="1" />
91114
<Setter Property="IsTabStop" Value="False" />
@@ -95,7 +118,6 @@
95118
<ControlTemplate TargetType="local:BreadcrumbBarItem">
96119
<Grid
97120
x:Name="PART_LayoutRoot"
98-
ColumnSpacing="2"
99121
TabFocusNavigation="Once"
100122
XYFocusKeyboardNavigation="Enabled">
101123
<Grid.ColumnDefinitions>
@@ -107,14 +129,20 @@
107129
<Button
108130
x:Name="PART_ItemContentButton"
109131
Padding="{TemplateBinding Padding}"
110-
VerticalAlignment="Stretch"
132+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
111133
AutomationProperties.AccessibilityView="Raw"
112134
Background="{TemplateBinding Background}"
113135
BorderBrush="{TemplateBinding BorderBrush}"
114136
BorderThickness="{TemplateBinding BorderThickness}"
115137
Control.IsTemplateFocusTarget="True"
116138
CornerRadius="{TemplateBinding CornerRadius}"
117139
UseSystemFocusVisuals="True">
140+
<Button.Resources>
141+
<ResourceDictionary>
142+
<StaticResource x:Key="ButtonBackgroundPointerOver" ResourceKey="SubtleFillColorTertiaryBrush" />
143+
<StaticResource x:Key="ButtonBackgroundPressed" ResourceKey="SubtleFillColorSecondaryBrush" />
144+
</ResourceDictionary>
145+
</Button.Resources>
118146
<FlyoutBase.AttachedFlyout>
119147
<MenuFlyout
120148
x:Name="PART_ItemEllipsisDropDownMenuFlyout"
@@ -151,8 +179,9 @@
151179
<Button
152180
x:Name="PART_ItemChevronButton"
153181
Grid.Column="1"
182+
Margin="{StaticResource BreadcrumbBarItemMargin}"
154183
Padding="{StaticResource BreadcrumbBarChevronPadding}"
155-
VerticalAlignment="Stretch"
184+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
156185
AutomationProperties.AccessibilityView="Content"
157186
Background="{TemplateBinding Background}"
158187
BorderBrush="{TemplateBinding BorderBrush}"

‎src/Files.App.Controls/BreadcrumbBar/BreadcrumbBarLayout.cs

+5-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public partial class BreadcrumbBarLayout : NonVirtualizingLayout
1313
// Fields
1414

1515
private readonly WeakReference<BreadcrumbBar>? _ownerRef;
16-
private readonly double _spacing = 0d;
1716

1817
private Size _availableSize;
1918
private BreadcrumbBarItem? _ellipsisButton = null;
@@ -24,10 +23,9 @@ public partial class BreadcrumbBarLayout : NonVirtualizingLayout
2423
public int IndexAfterEllipsis { get; private set; }
2524
public int VisibleItemsCount { get; private set; }
2625

27-
public BreadcrumbBarLayout(BreadcrumbBar breadcrumb, double spacing)
26+
public BreadcrumbBarLayout(BreadcrumbBar breadcrumb)
2827
{
2928
_ownerRef = new(breadcrumb);
30-
_spacing = spacing;
3129
}
3230

3331
protected override Size MeasureOverride(NonVirtualizingLayoutContext context, Size availableSize)
@@ -79,7 +77,6 @@ protected override Size ArrangeOverride(NonVirtualizingLayoutContext context, Si
7977
breadcrumbItem.Arrange(new Rect(accumulatedWidths, 0, breadcrumbItem.DesiredSize.Width, breadcrumbItem.DesiredSize.Height));
8078

8179
accumulatedWidths += breadcrumbItem.DesiredSize.Width;
82-
accumulatedWidths += _spacing;
8380

8481
VisibleItemsCount++;
8582
}
@@ -89,15 +86,17 @@ protected override Size ArrangeOverride(NonVirtualizingLayoutContext context, Si
8986
if (_ownerRef?.TryGetTarget(out var breadcrumbBar) ?? false)
9087
breadcrumbBar.OnLayoutUpdated();
9188

89+
finalSize.Width = accumulatedWidths;
90+
9291
return finalSize;
9392
}
9493

9594
private int GetFirstIndexToRender(NonVirtualizingLayoutContext context)
9695
{
9796
var itemCount = context.Children.Count;
98-
var accumulatedWidth = _spacing;
97+
var accumulatedWidth = 0d;
9998

100-
// Go through all items from the end
99+
// Go through all items from the last item
101100
for (int index = itemCount - 1; index >= 0; index--)
102101
{
103102
var newAccumulatedWidth = accumulatedWidth + context.Children[index].DesiredSize.Width;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
namespace Files.App.Controls
5+
{
6+
public partial class Omnibar
7+
{
8+
private void Omnibar_SizeChanged(object sender, SizeChangedEventArgs e)
9+
{
10+
_textBoxSuggestionsContainerBorder.Width = ActualWidth;
11+
}
12+
13+
private void AutoSuggestBox_GotFocus(object sender, RoutedEventArgs e)
14+
{
15+
_isFocused = true;
16+
17+
VisualStateManager.GoToState(CurrentSelectedMode, "Focused", true);
18+
VisualStateManager.GoToState(_textBox, "InputAreaVisible", true);
19+
20+
TryToggleIsSuggestionsPopupOpen(true);
21+
}
22+
23+
private void AutoSuggestBox_LostFocus(object sender, RoutedEventArgs e)
24+
{
25+
_isFocused = false;
26+
27+
if (CurrentSelectedMode?.ContentOnInactive is not null)
28+
{
29+
VisualStateManager.GoToState(CurrentSelectedMode, "CurrentUnfocused", true);
30+
VisualStateManager.GoToState(_textBox, "InputAreaCollapsed", true);
31+
}
32+
33+
TryToggleIsSuggestionsPopupOpen(false);
34+
}
35+
36+
private void AutoSuggestBox_TextChanged(object sender, TextChangedEventArgs e)
37+
{
38+
if (_shouldPopupOpen)
39+
{
40+
_shouldPopupOpen = false;
41+
return;
42+
}
43+
44+
TryToggleIsSuggestionsPopupOpen(true);
45+
}
46+
47+
private void AutoSuggestBoxSuggestionsPopup_GettingFocus(UIElement sender, Microsoft.UI.Xaml.Input.GettingFocusEventArgs args)
48+
{
49+
args.TryCancel();
50+
}
51+
52+
private void AutoSuggestBoxSuggestionsListView_ItemClick(object sender, ItemClickEventArgs e)
53+
{
54+
if (CurrentSelectedMode is null)
55+
return;
56+
57+
// Get the text to put into the text box from the chosen suggestion item
58+
if (e.ClickedItem is string text)
59+
{
60+
CurrentSelectedMode.Text = text;
61+
}
62+
else
63+
{
64+
CurrentSelectedMode.Text = CurrentSelectedMode.DisplayMemberPath is null
65+
? e.ClickedItem.ToString()
66+
: e.ClickedItem.GetType().GetProperty(CurrentSelectedMode.DisplayMemberPath)?.GetValue(e.ClickedItem)?.ToString();
67+
}
68+
69+
TryToggleIsSuggestionsPopupOpen(false);
70+
71+
_shouldPopupOpen = true;
72+
}
73+
}
74+
}

‎src/Files.App.Controls/Omnibar/Omnibar.Properties.cs

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22
// Licensed under the MIT License.
33

44
using CommunityToolkit.WinUI;
5-
using Microsoft.UI.Xaml;
6-
using Microsoft.UI.Xaml.Controls;
7-
using Microsoft.UI.Xaml.Media;
8-
using Microsoft.UI.Xaml.Markup;
9-
using Microsoft.UI.Xaml.Shapes;
10-
using System.Linq;
11-
using System.Collections.Generic;
125

136
namespace Files.App.Controls
147
{
@@ -19,5 +12,8 @@ public partial class Omnibar
1912

2013
[GeneratedDependencyProperty]
2114
public partial OmnibarMode? CurrentSelectedMode { get; set; }
15+
16+
[GeneratedDependencyProperty]
17+
public partial Thickness AutoSuggestBoxPadding { get; set; }
2218
}
2319
}

0 commit comments

Comments
 (0)
Failed to load comments.