From 0893b98d2bcd5b979de3078fa9775a0e554b28e2 Mon Sep 17 00:00:00 2001 From: VladiStep Date: Wed, 13 Sep 2023 14:29:44 +0300 Subject: [PATCH 1/3] Fix #1472. --- UndertaleModTool/MainWindow.xaml | 2 +- UndertaleModTool/MainWindow.xaml.cs | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/UndertaleModTool/MainWindow.xaml b/UndertaleModTool/MainWindow.xaml index 181344326..ddc95807d 100644 --- a/UndertaleModTool/MainWindow.xaml +++ b/UndertaleModTool/MainWindow.xaml @@ -498,7 +498,7 @@ + PreviewMouseWheel="TabScrollViewer_PreviewMouseWheel" PreviewMouseDown="TabScrollViewer_PreviewMouseDown"> diff --git a/UndertaleModTool/MainWindow.xaml.cs b/UndertaleModTool/MainWindow.xaml.cs index 4f0a29f87..ef8fd1842 100644 --- a/UndertaleModTool/MainWindow.xaml.cs +++ b/UndertaleModTool/MainWindow.xaml.cs @@ -3669,8 +3669,6 @@ private void TabController_SelectionChanged(object sender, SelectionChangedEvent { CurrentTab?.SaveTabContentState(); - ScrollToTab(CurrentTabIndex); - Tab newTab = Tabs[CurrentTabIndex]; if (CurrentTab?.CurrentObject != newTab.CurrentObject) @@ -3681,6 +3679,8 @@ private void TabController_SelectionChanged(object sender, SelectionChangedEvent UpdateObjectLabel(CurrentTab.CurrentObject); CurrentTab.RestoreTabContentState(); + + ScrollToTab(CurrentTabIndex); } } @@ -3784,6 +3784,10 @@ private void TabScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArg ScrollTabs(e.Delta < 0 ? ScrollDirection.Right : ScrollDirection.Left); e.Handled = true; } + private void TabScrollViewer_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + initTabContPos = e.GetPosition(TabScrollViewer); + } private void TabsScrollLeftButton_Click(object sender, RoutedEventArgs e) { ScrollTabs(ScrollDirection.Left); @@ -3823,6 +3827,7 @@ private void TabItem_MouseUp(object sender, MouseButtonEventArgs e) } } + private Point initTabContPos; // source - https://stackoverflow.com/a/10738247/12136394 private void TabItem_PreviewMouseMove(object sender, MouseEventArgs e) { @@ -3831,6 +3836,12 @@ private void TabItem_PreviewMouseMove(object sender, MouseEventArgs e) if (Mouse.PrimaryDevice.LeftButton == MouseButtonState.Pressed) { + // Filter false mouse move events, because it sometimes + // triggers even on a mouse click + Point currPos = e.GetPosition(TabScrollViewer); + if (Point.Subtract(currPos, initTabContPos).X < 2) + return; + CurrentTabIndex = tabItem.TabIndex; try { From a3b484f5e1e6f2be7d1816fa13383d061c0069b4 Mon Sep 17 00:00:00 2001 From: VladiStep Date: Wed, 13 Sep 2023 14:34:27 +0300 Subject: [PATCH 2/3] Fix #1473. --- UndertaleModTool/MainWindow.xaml.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/UndertaleModTool/MainWindow.xaml.cs b/UndertaleModTool/MainWindow.xaml.cs index ef8fd1842..4c82ce870 100644 --- a/UndertaleModTool/MainWindow.xaml.cs +++ b/UndertaleModTool/MainWindow.xaml.cs @@ -3757,16 +3757,12 @@ private void ScrollToTab(int tabIndex) tabItems.RemoveAt(tabItems.Count - 1); } - TabItem currTabItem = null; double offset = 0; int i = 0; foreach (TabItem item in tabItems) { if (i == tabIndex) - { - currTabItem = item; break; - } offset += item.ActualWidth; i++; @@ -3775,8 +3771,6 @@ private void ScrollToTab(int tabIndex) double endOffset = TabScrollViewer.HorizontalOffset + TabScrollViewer.ViewportWidth; if (offset < TabScrollViewer.HorizontalOffset || offset > endOffset) TabScrollViewer.ScrollToHorizontalOffset(offset); - else - currTabItem?.BringIntoView(); } } private void TabScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e) From dfae57c3cfa16aa8ebed39ac1276e9abd8bbf6da Mon Sep 17 00:00:00 2001 From: VladiStep Date: Tue, 19 Sep 2023 16:48:49 +0300 Subject: [PATCH 3/3] Fix tab swapping to the left --- UndertaleModTool/MainWindow.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UndertaleModTool/MainWindow.xaml.cs b/UndertaleModTool/MainWindow.xaml.cs index 4c82ce870..0400e6445 100644 --- a/UndertaleModTool/MainWindow.xaml.cs +++ b/UndertaleModTool/MainWindow.xaml.cs @@ -3833,7 +3833,7 @@ private void TabItem_PreviewMouseMove(object sender, MouseEventArgs e) // Filter false mouse move events, because it sometimes // triggers even on a mouse click Point currPos = e.GetPosition(TabScrollViewer); - if (Point.Subtract(currPos, initTabContPos).X < 2) + if (Math.Abs(Point.Subtract(currPos, initTabContPos).X) < 2) return; CurrentTabIndex = tabItem.TabIndex;