Skip to content

Commit d934b93

Browse files
committed
Fix: Init
1 parent 973a3f8 commit d934b93

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
<Grid.ColumnDefinitions>
229229
<ColumnDefinition Width="Auto" />
230230
<ColumnDefinition Width="*" />
231-
<ColumnDefinition x:Name="RightPaddingColumn" Width="0" />
231+
<ColumnDefinition x:Name="RightPaddingColumn" Width="{x:Bind TitleBarWidth, Mode=OneWay}" />
232232
</Grid.ColumnDefinitions>
233233

234234
<!-- Height is not divisble by four in order to properly align the button -->
@@ -260,7 +260,8 @@
260260
Grid.ColumnSpan="2"
261261
HorizontalAlignment="Stretch"
262262
VerticalAlignment="Stretch"
263-
Fill="Transparent" />
263+
Fill="Transparent"
264+
Loaded="DragAreaRectangle_Loaded" />
264265

265266
</Grid>
266267
</TabView.TabStripFooter>

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public sealed partial class TabBar : BaseTabBar, INotifyPropertyChanged
2828

2929
private bool _lockDropOperation = false;
3030

31+
private static int _gap = 6;
32+
3133
// Starting position when dragging a tab
3234
private System.Drawing.Point dragStartPoint;
3335

@@ -51,6 +53,14 @@ public bool AllowTabsDrag
5153
public Rectangle DragArea
5254
=> DragAreaRectangle;
5355

56+
private GridLength _titleBarWidth;
57+
58+
public GridLength TitleBarWidth
59+
{
60+
get => _titleBarWidth;
61+
set => _titleBarWidth = new(value.Value + _gap);
62+
}
63+
5464
// Events
5565

5666
public static event EventHandler<TabBarItem?>? SelectedTabItemChanged;
@@ -66,12 +76,10 @@ public TabBar()
6676

6777
var appWindow = MainWindow.Instance.AppWindow;
6878

69-
double rightPaddingColumnWidth =
70-
FilePropertiesHelpers.FlowDirectionSettingIsRightToLeft
79+
TitleBarWidth =
80+
new(FilePropertiesHelpers.FlowDirectionSettingIsRightToLeft
7181
? appWindow.TitleBar.LeftInset
72-
: appWindow.TitleBar.RightInset;
73-
74-
RightPaddingColumn.Width = new(rightPaddingColumnWidth >= 0 ? rightPaddingColumnWidth : 0);
82+
: appWindow.TitleBar.RightInset);
7583

7684
AppearanceSettingsService.PropertyChanged += (s, e) =>
7785
{
@@ -366,5 +374,8 @@ private void TabViewItem_Loaded(object sender, RoutedEventArgs e)
366374
});
367375
}
368376
}
377+
378+
private void DragAreaRectangle_Loaded(object sender, RoutedEventArgs e)
379+
=> HorizontalTabView.Measure(new(HorizontalTabView.ActualWidth - TabBarAddNewTabButton.Width - TitleBarWidth.Value, HorizontalTabView.ActualHeight));
369380
}
370381
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,13 @@ private void UserSettingsService_OnSettingChangedEvent(object? sender, SettingCh
126126

127127
private void HorizontalMultitaskingControl_Loaded(object sender, RoutedEventArgs e)
128128
{
129-
TabControl.DragArea.SizeChanged += (_, _) => MainWindow.Instance.RaiseSetTitleBarDragRegion(SetTitleBarDragRegion);
129+
TabControl.SizeChanged += TabControlArea_SizeChanged;
130+
TabControl.DragArea.SizeChanged += TabControlArea_SizeChanged;
131+
}
132+
133+
private void TabControlArea_SizeChanged(object sender, SizeChangedEventArgs e)
134+
{
135+
MainWindow.Instance.RaiseSetTitleBarDragRegion(SetTitleBarDragRegion);
130136
if (ViewModel.MultitaskingControl is not TabBar)
131137
{
132138
ViewModel.MultitaskingControl = TabControl;
@@ -138,7 +144,9 @@ private void HorizontalMultitaskingControl_Loaded(object sender, RoutedEventArgs
138144
private int SetTitleBarDragRegion(InputNonClientPointerSource source, SizeInt32 size, double scaleFactor, Func<UIElement, RectInt32?, RectInt32> getScaledRect)
139145
{
140146
var height = (int)TabControl.ActualHeight;
141-
source.SetRegionRects(NonClientRegionKind.Passthrough, [getScaledRect(this, new RectInt32(0, 0, (int)(TabControl.ActualWidth + TabControl.Margin.Left - TabControl.DragArea.ActualWidth), height))]);
147+
var width = (int)(TabControl.ActualWidth - TabControl.DragArea.ActualWidth);
148+
149+
source.SetRegionRects(NonClientRegionKind.Passthrough, [getScaledRect(this, new RectInt32(0, 0, width, height))]);
142150
return height;
143151
}
144152

0 commit comments

Comments
 (0)