Skip to content

Commit a13dc4c

Browse files
committed
CQ: set drag area in TabBar
1 parent d25fc8e commit a13dc4c

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

src/Files.App/UserControls/TabBar/TabBar.xaml.cs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ public GridLength TitleBarWidth
6767

6868
public static event EventHandler<TabBarItem?>? SelectedTabItemChanged;
6969

70-
public event EventHandler<SizeChangedEventArgs>? TabControlAreaSizeChanged;
71-
7270
// Constructor
7371

7472
public TabBar()
@@ -96,9 +94,6 @@ public TabBar()
9694
};
9795
}
9896

99-
private void BaseTabBar_Loaded(object sender, RoutedEventArgs e)
100-
=> MainWindow.Instance.AppWindow.Changed += (_, _) => MainWindow.Instance.RaiseSetTitleBarDragRegion(SetTitleBarDragRegion);
101-
10297
private void TabView_TabItemsChanged(TabView sender, Windows.Foundation.Collections.IVectorChangedEventArgs args)
10398
{
10499
if (args.CollectionChange == Windows.Foundation.Collections.CollectionChange.ItemRemoved)
@@ -383,17 +378,9 @@ private void TabViewItem_Loaded(object sender, RoutedEventArgs e)
383378
}
384379

385380
private void DragAreaRectangle_Loaded(object sender, RoutedEventArgs e)
386-
{
387-
var width = HorizontalTabView.ActualWidth - TabBarAddNewTabButton.Width - TitleBarWidth.Value;
388-
var height = HorizontalTabView.ActualHeight;
389-
HorizontalTabView.Measure(new(width >= 0 ? width : 0, height >= 0 ? height : 0));
390-
391-
MainWindow.Instance.RaiseSetTitleBarDragRegion(SetTitleBarDragRegion);
392-
SizeChanged += (s, e) => TabControlAreaSizeChanged?.Invoke(s, e);
393-
DragArea.SizeChanged += (s, e) => TabControlAreaSizeChanged?.Invoke(s, e);
394-
}
381+
=> HorizontalTabView.Measure(new(HorizontalTabView.ActualWidth - TabBarAddNewTabButton.Width - TitleBarWidth.Value, HorizontalTabView.ActualHeight));
395382

396-
private int SetTitleBarDragRegion(InputNonClientPointerSource source, SizeInt32 size, double scaleFactor, Func<UIElement, RectInt32?, RectInt32> getScaledRect)
383+
public int SetTitleBarDragRegion(InputNonClientPointerSource source, SizeInt32 size, double scaleFactor, Func<UIElement, RectInt32?, RectInt32> getScaledRect)
397384
{
398385
var height = (int)ActualHeight;
399386
var width = (int)(ActualWidth - DragArea.ActualWidth);

src/Files.App/Views/MainPage.xaml.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,14 @@ private void UserSettingsService_OnSettingChangedEvent(object? sender, SettingCh
125125
}
126126

127127
private void HorizontalMultitaskingControl_Loaded(object sender, RoutedEventArgs e)
128-
=> TabControl.TabControlAreaSizeChanged += TabControlArea_SizeChanged;
128+
{
129+
TabControl.SizeChanged += TabControlArea_SizeChanged;
130+
TabControl.DragArea.SizeChanged += TabControlArea_SizeChanged;
131+
}
129132

130133
private void TabControlArea_SizeChanged(object sender, SizeChangedEventArgs e)
131134
{
135+
MainWindow.Instance.RaiseSetTitleBarDragRegion(TabControl.SetTitleBarDragRegion);
132136
if (ViewModel.MultitaskingControl is not TabBar)
133137
{
134138
ViewModel.MultitaskingControl = TabControl;
@@ -274,6 +278,8 @@ protected override void OnLostFocus(RoutedEventArgs e)
274278

275279
private void Page_Loaded(object sender, RoutedEventArgs e)
276280
{
281+
MainWindow.Instance.AppWindow.Changed += (_, _) => MainWindow.Instance.RaiseSetTitleBarDragRegion(TabControl.SetTitleBarDragRegion);
282+
277283
// Defers the status bar loading until after the page has loaded to improve startup perf
278284
FindName(nameof(StatusBar));
279285
FindName(nameof(InnerNavigationToolbar));

0 commit comments

Comments
 (0)