Skip to content

Commit 447a813

Browse files
committed
Fixes for TabStrip
1 parent 08e7996 commit 447a813

12 files changed

+274
-247
lines changed

Files UWP/AddItem.xaml.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ public static void AddItemsToList()
3535
private async void ListView_ItemClick(object sender, ItemClickEventArgs e)
3636
{
3737

38-
ProHome.AddItemBox.Hide();
38+
ItemViewModel.GetCurrentSelectedTabInstance<ProHome>().AddItemBox.Hide();
3939
var currentPath = App.ViewModel.Universal.path;
4040
StorageFolder folderToCreateItem = await StorageFolder.GetFolderFromPathAsync(currentPath);
4141
if ((e.ClickedItem as AddListItem).Header == "Folder")
4242
{
43-
await ProHome.NameBox.ShowAsync();
44-
var userInput = ProHome.inputForRename;
43+
await ItemViewModel.GetCurrentSelectedTabInstance<ProHome>().NameBox.ShowAsync();
44+
var userInput = ItemViewModel.GetCurrentSelectedTabInstance<ProHome>().inputForRename;
4545
if (userInput != null)
4646
{
4747
var folder = await folderToCreateItem.CreateFolderAsync(userInput, CreationCollisionOption.FailIfExists);
@@ -50,8 +50,8 @@ private async void ListView_ItemClick(object sender, ItemClickEventArgs e)
5050
}
5151
else if ((e.ClickedItem as AddListItem).Header == "Text Document")
5252
{
53-
await ProHome.NameBox.ShowAsync();
54-
var userInput = ProHome.inputForRename;
53+
await ItemViewModel.GetCurrentSelectedTabInstance<ProHome>().NameBox.ShowAsync();
54+
var userInput = ItemViewModel.GetCurrentSelectedTabInstance<ProHome>().inputForRename;
5555
if (userInput != null)
5656
{
5757
var folder = await folderToCreateItem.CreateFileAsync(userInput + ".txt", CreationCollisionOption.FailIfExists);
@@ -60,8 +60,8 @@ private async void ListView_ItemClick(object sender, ItemClickEventArgs e)
6060
}
6161
else if ((e.ClickedItem as AddListItem).Header == "Bitmap Image")
6262
{
63-
await ProHome.NameBox.ShowAsync();
64-
var userInput = ProHome.inputForRename;
63+
await ItemViewModel.GetCurrentSelectedTabInstance<ProHome>().NameBox.ShowAsync();
64+
var userInput = ItemViewModel.GetCurrentSelectedTabInstance<ProHome>().inputForRename;
6565
if (userInput != null)
6666
{
6767
var folder = await folderToCreateItem.CreateFileAsync(userInput + ".bmp", CreationCollisionOption.FailIfExists);

Files UWP/App.xaml.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Files.Navigation;
1+
using Files.Interacts;
2+
using Files.Navigation;
23
using System;
34
using System.Diagnostics;
45
using System.Threading;
@@ -68,7 +69,9 @@ public App()
6869
public static Interacts.Layout.LayoutItemsState LayoutItems { get; set; } = new Interacts.Layout.LayoutItemsState();
6970
public static Interacts.AlwaysPresentCommandsState AlwaysPresentCommands { get; set; } = new Interacts.AlwaysPresentCommandsState();
7071
public static DisplayedPathText PathText { get; set; } = new DisplayedPathText();
71-
public static Filesystem.LoadingVisibility Loading { get; set; } = new Filesystem.LoadingVisibility();
72+
public static Filesystem.LoadingVisibility Loading { get; set; } = new Filesystem.LoadingVisibility();
73+
public static RefreshState RS { get; set; } = new RefreshState();
74+
7275

7376
/// <summary>
7477
/// Invoked when the application is launched normally by the end user. Other entry points

Files UWP/Filesystem/ItemViewModel.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using ByteSizeLib;
2+
using Files.Interacts;
23
using Files.Navigation;
4+
using Microsoft.Toolkit.Uwp.UI.Controls;
35
using System;
46
using System.Collections.Generic;
57
using System.Collections.ObjectModel;
@@ -90,9 +92,22 @@ public void CancelLoadAndClearFiles()
9092
}
9193
}
9294

93-
public static async void DisplayConsentDialog()
95+
public static T GetCurrentSelectedTabInstance<T>()
9496
{
95-
await ProHome.permissionBox.ShowAsync();
97+
var selectedTabContent = ((InstanceTabsView.tabView.SelectedItem as TabViewItem).Content as Grid);
98+
foreach (UIElement uiElement in selectedTabContent.Children)
99+
{
100+
if (uiElement.GetType() == typeof(Frame))
101+
{
102+
return (T) ((uiElement as Frame).Content);
103+
}
104+
}
105+
return default;
106+
}
107+
108+
public async void DisplayConsentDialog()
109+
{
110+
await GetCurrentSelectedTabInstance<ProHome>().permissionBox.ShowAsync();
96111
}
97112

98113
public async void AddItemsToCollectionAsync(string path, Page currentPage)
@@ -147,9 +162,9 @@ public async void AddItemsToCollectionAsync(string path, Page currentPage)
147162
_rootFolder = await StorageFolder.GetFolderFromPathAsync(Universal.path);
148163

149164
//History.AddToHistory(Universal.path);
150-
151-
ProHome.BackButton.IsEnabled = ProHome.accessibleContentFrame.CanGoBack;
152-
ProHome.ForwardButton.IsEnabled = ProHome.accessibleContentFrame.CanGoForward;
165+
166+
GetCurrentSelectedTabInstance<ProHome>().BackButton.IsEnabled = GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.CanGoBack;
167+
GetCurrentSelectedTabInstance<ProHome>().ForwardButton.IsEnabled = GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.CanGoForward;
153168

154169
switch (await _rootFolder.GetIndexedStateAsync())
155170
{

Files UWP/GenericFileBrowser.xaml.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ private void Clipboard_ContentChanged(object sender, object e)
9696
protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
9797
{
9898
base.OnNavigatedTo(eventArgs);
99-
ProHome.BackButton.IsEnabled = ProHome.accessibleContentFrame.CanGoBack;
100-
ProHome.ForwardButton.IsEnabled = ProHome.accessibleContentFrame.CanGoForward;
101-
ProHome.RS.isEnabled = true;
99+
ItemViewModel.GetCurrentSelectedTabInstance<ProHome>().BackButton.IsEnabled = ItemViewModel.GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.CanGoBack;
100+
ItemViewModel.GetCurrentSelectedTabInstance<ProHome>().ForwardButton.IsEnabled = ItemViewModel.GetCurrentSelectedTabInstance<ProHome>().accessibleContentFrame.CanGoForward;
101+
ItemViewModel.GetCurrentSelectedTabInstance<ProHome>().RefreshButton.IsEnabled = true;
102102
App.AlwaysPresentCommands.isEnabled = true;
103103
var parameters = (string)eventArgs.Parameter;
104104
App.ViewModel.CancelLoadAndClearFiles();
105105
App.ViewModel.Universal.path = parameters;
106-
ProHome.RefreshButton.Click += NavigationActions.Refresh_Click;
107-
ProHome.AddItemButton.Click += AddItem_Click;
106+
ItemViewModel.GetCurrentSelectedTabInstance<ProHome>().RefreshButton.Click += NavigationActions.Refresh_Click;
107+
ItemViewModel.GetCurrentSelectedTabInstance<ProHome>().AddItemButton.Click += AddItem_Click;
108108
App.ViewModel.AddItemsToCollectionAsync(App.ViewModel.Universal.path, GenericItemView);
109109
Interaction.page = this;
110110
if (parameters.Equals(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)))

Files UWP/InstanceTabsView.xaml

Lines changed: 77 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,26 @@
77
xmlns:Custom="using:Microsoft.Toolkit.Uwp.UI.Controls"
88
x:Class="Files.InstanceTabsView"
99
mc:Ignorable="d"
10-
Background="{ThemeResource SystemControlChromeHighAcrylicWindowMediumBrush}" Name="InstanceTabsPage">
10+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
11+
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters">
1112
<Page.Resources>
1213
<ResourceDictionary>
1314
<ResourceDictionary.MergedDictionaries>
1415
<ResourceDictionary>
1516
<ResourceDictionary.ThemeDictionaries>
1617
<ResourceDictionary x:Key="Default">
1718
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundSelected" Color="White" />
18-
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="LightGray" />
19+
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="White" />
1920
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPressed" Color="White" />
2021
</ResourceDictionary>
2122
<ResourceDictionary x:Key="Light">
2223
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundSelected" Color="White" />
23-
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="LightGray" />
24+
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="White" />
2425
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPressed" Color="White" />
2526
</ResourceDictionary>
2627
<ResourceDictionary x:Key="Dark">
2728
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundSelected" Color="#191919" />
28-
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="DarkGray" />
29+
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPointerOver" Color="#191919" />
2930
<SolidColorBrush x:Key="TabViewItemHeaderBackgroundPressed" Color="#191919" />
3031
</ResourceDictionary>
3132
<ResourceDictionary x:Key="HighContrast">
@@ -34,53 +35,90 @@
3435
</ResourceDictionary.ThemeDictionaries>
3536
</ResourceDictionary>
3637
</ResourceDictionary.MergedDictionaries>
38+
<StaticResource x:Key="TabViewItemHeaderRevealBorderBrush" ResourceKey="SystemControlBackgroundTransparentRevealBorderBrush"/>
39+
<converters:DoubleToVisibilityConverter x:Key="GreaterThanToleranceVisibilityConverter" GreaterThan="65.0"/>
40+
<Style x:Key="TabViewScrollViewer" TargetType="ScrollViewer">
41+
<Setter Property="HorizontalScrollMode" Value="Auto"/>
42+
<Setter Property="VerticalScrollMode" Value="Auto"/>
43+
<Setter Property="IsHorizontalRailEnabled" Value="True"/>
44+
<Setter Property="IsVerticalRailEnabled" Value="True"/>
45+
<Setter Property="IsTabStop" Value="False"/>
46+
<Setter Property="ZoomMode" Value="Disabled"/>
47+
<Setter Property="HorizontalContentAlignment" Value="Left"/>
48+
<Setter Property="VerticalContentAlignment" Value="Top"/>
49+
<Setter Property="VerticalScrollBarVisibility" Value="Visible"/>
50+
<Setter Property="Padding" Value="0"/>
51+
<Setter Property="BorderThickness" Value="1,0,0,0"/>
52+
<Setter Property="BorderBrush" Value="{ThemeResource TabViewItemHeaderRevealBorderBrush}"/>
53+
<Setter Property="Background" Value="Transparent"/>
54+
<Setter Property="UseSystemFocusVisuals" Value="True"/>
55+
<Setter Property="Template">
56+
<Setter.Value>
57+
<ControlTemplate TargetType="ScrollViewer">
58+
<Border x:Name="Root" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
59+
<Grid Background="{TemplateBinding Background}">
60+
<Grid.ColumnDefinitions>
61+
<ColumnDefinition Width="Auto"/>
62+
<ColumnDefinition Width="*"/>
63+
<ColumnDefinition Width="Auto"/>
64+
</Grid.ColumnDefinitions>
65+
<RepeatButton x:Name="ScrollBackButton" Background="Transparent" BorderThickness="1" Content="&#xE76B;" Delay="50" FontFamily="Segoe MDL2 Assets" Interval="100" Style="{StaticResource RepeatButtonRevealStyle}" VerticalAlignment="Stretch" Visibility="{Binding ScrollableWidth, Converter={StaticResource GreaterThanToleranceVisibilityConverter}, FallbackValue=Collapsed, RelativeSource={RelativeSource Mode=TemplatedParent}, TargetNullValue=Collapsed}"/>
66+
<ScrollContentPresenter x:Name="ScrollContentPresenter" Grid.Column="1" Margin="{TemplateBinding Padding}" TabFocusNavigation="Once"/>
67+
<RepeatButton x:Name="ScrollForwardButton" Background="Transparent" BorderThickness="1" Content="&#xE76C;" Grid.Column="2" Delay="50" FontFamily="Segoe MDL2 Assets" Interval="100" Style="{StaticResource RepeatButtonRevealStyle}" VerticalAlignment="Stretch" Visibility="{Binding ScrollableWidth, Converter={StaticResource GreaterThanToleranceVisibilityConverter}, FallbackValue=Collapsed, RelativeSource={RelativeSource Mode=TemplatedParent}, TargetNullValue=Collapsed}"/>
68+
</Grid>
69+
</Border>
70+
</ControlTemplate>
71+
</Setter.Value>
72+
</Setter>
73+
</Style>
74+
<ControlTemplate x:Key="TabViewTemplate1" TargetType="Custom:TabView">
75+
<Grid Background="{ThemeResource SystemControlChromeHighAcrylicWindowMediumBrush}" x:Name="TabViewContainer">
76+
<Grid.ColumnDefinitions>
77+
<ColumnDefinition Width="Auto"/>
78+
<ColumnDefinition Custom:TabView.ConstrainColumn="True" Custom:TabView.IgnoreColumn="True" Width="Auto"/>
79+
<ColumnDefinition Width="Auto"/>
80+
<ColumnDefinition Width="Auto"/>
81+
<ColumnDefinition Custom:TabView.IgnoreColumn="True" Width="*"/>
82+
<ColumnDefinition Width="175"/>
83+
</Grid.ColumnDefinitions>
84+
<Grid.RowDefinitions>
85+
<RowDefinition Height="Auto"/>
86+
<RowDefinition Height="Auto"/>
87+
<RowDefinition Height="*"/>
88+
<RowDefinition Height="Auto"/>
89+
</Grid.RowDefinitions>
90+
<ContentPresenter ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" Grid.ColumnSpan="6" Grid.Row="0"/>
91+
<ContentPresenter ContentTemplate="{TemplateBinding TabStartHeaderTemplate}" Content="{TemplateBinding TabStartHeader}" Grid.Column="0" Grid.Row="1"/>
92+
<ScrollViewer x:Name="ScrollViewer" AutomationProperties.AccessibilityView="Raw" BringIntoViewOnFocusChange="{TemplateBinding ScrollViewer.BringIntoViewOnFocusChange}" Grid.Column="1" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" IsVerticalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsVerticalScrollChainingEnabled}" IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}" IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}" IsHorizontalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsHorizontalScrollChainingEnabled}" Grid.Row="1" Style="{StaticResource TabViewScrollViewer}" TabNavigation="{TemplateBinding TabNavigation}" VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}">
93+
<ItemsPresenter x:Name="TabsItemsPresenter" Padding="{TemplateBinding Padding}"/>
94+
</ScrollViewer>
95+
<ContentPresenter ContentTemplate="{TemplateBinding TabActionHeaderTemplate}" Content="{TemplateBinding TabActionHeader}" Grid.Column="3" HorizontalAlignment="Left" Grid.Row="1"/>
96+
<Grid Background="Transparent" Name="DragArea" Loaded="DragArea_Loaded" Grid.Column="4" Grid.Row="1"/>
97+
<ContentPresenter ContentTemplate="{TemplateBinding TabEndHeaderTemplate}" Content="{TemplateBinding TabEndHeader}" Grid.Column="5" Grid.Row="1"/>
98+
<ContentPresenter x:Name="TabContentPresenter" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Grid.ColumnSpan="6" Grid.Row="2"/>
99+
<ContentPresenter ContentTemplate="{TemplateBinding FooterTemplate}" Content="{TemplateBinding Footer}" Grid.ColumnSpan="6" Grid.Row="3"/>
100+
</Grid>
101+
</ControlTemplate>
37102
</ResourceDictionary>
38103
</Page.Resources>
39104

40-
<Grid Background="Transparent">
41-
<Grid.RowDefinitions>
42-
<RowDefinition Height="Auto"/>
43-
<RowDefinition/>
44-
</Grid.RowDefinitions>
45-
46-
<Grid.ColumnDefinitions>
47-
<ColumnDefinition Width="{Binding Width, ElementName=LeftPaddingColumn}"/>
48-
<ColumnDefinition/>
49-
<ColumnDefinition Width="{Binding Width, ElementName=RightPaddingColumn}"/>
50-
</Grid.ColumnDefinitions>
51-
52-
<ContentPresenter Name="tabContentPresenter" Grid.Row="1" Grid.ColumnSpan="3" Content="{x:Bind local:InstanceTabsView.ContentPresGrid, Mode=OneWay}"/>
53-
54-
<Grid Grid.ColumnSpan="3" Name="DragArea" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Loaded="DragArea_Loaded" Background="Transparent">
55-
<Grid.ColumnDefinitions>
56-
<ColumnDefinition x:Name="LeftPaddingColumn" Width="0"/>
57-
<ColumnDefinition/>
58-
<ColumnDefinition x:Name="RightPaddingColumn" Width="0"/>
59-
</Grid.ColumnDefinitions>
60-
</Grid>
61-
62-
<Custom:TabView CanReorderItems="False" SelectionChanged="TabStrip_SelectionChanged" Name="TabStrip" SelectedTabWidth="150" IsCloseButtonOverlay="False" Background="Transparent" TabWidthBehavior="Actual" CanCloseTabs="True" ItemsSource="{x:Bind local:InstanceTabsView.instanceTabs}" TabClosing="TabStrip_TabClosing">
105+
<Grid Name="rootGrid" Background="Transparent">
106+
<Custom:TabView Template="{StaticResource TabViewTemplate1}" Grid.ColumnSpan="3" CanReorderItems="False" Name="TabStrip" IsCloseButtonOverlay="False" Background="Transparent" SelectedTabWidth="200" CanCloseTabs="True">
63107
<Custom:TabView.Resources>
64108
<x:Double x:Key="TabViewItemHeaderMinHeight">32</x:Double>
65109
<StaticResource x:Key="TabViewSelectionIndicatorForeground" ResourceKey="SystemControlTransparentBrush" />
66110
</Custom:TabView.Resources>
67-
<Custom:TabView.ItemTemplate>
68-
<DataTemplate/>
69-
</Custom:TabView.ItemTemplate>
70-
71-
<Custom:TabView.ItemHeaderTemplate>
72-
<DataTemplate>
73-
<Grid Canvas.ZIndex="5" Width="150">
74-
<TextBlock VerticalAlignment="Center" Text="{Binding HeaderText}"/>
75-
</Grid>
76-
</DataTemplate>
77-
</Custom:TabView.ItemHeaderTemplate>
78-
111+
<Custom:TabView.TabEndHeader>
112+
<Grid Background="Transparent"/>
113+
</Custom:TabView.TabEndHeader>
79114
<Custom:TabView.TabActionHeader>
80115
<Button BorderThickness="1" x:Name="NewTabButton" Canvas.ZIndex="2" Background="Transparent" Style="{StaticResource ButtonRevealStyle}" Height="32" Width="32" Click="NewTabButton_Click">
81116
<Button.Content>
82117
<FontIcon FontSize="12" Glyph="&#xE710;"/>
83118
</Button.Content>
119+
<Button.KeyboardAccelerators>
120+
<KeyboardAccelerator Modifiers="Control" Key="T"/>
121+
</Button.KeyboardAccelerators>
84122
</Button>
85123
</Custom:TabView.TabActionHeader>
86124

0 commit comments

Comments
 (0)