From f207b76ec41527f42f49210328a11493ec738f1b Mon Sep 17 00:00:00 2001 From: Cory Todd Date: Tue, 27 Apr 2021 18:36:25 -0700 Subject: [PATCH 1/3] Add option to not show anchorable on hover For our use case, it is nice if we have the option to not unhide an anchorable when the mouse enters the docked tab. This adds an optional property to control this behavior. The default is to show on hover just like always. Serialization support is included. --- .../Controls/LayoutAnchorControl.cs | 2 +- .../AvalonDock/Layout/LayoutContent.cs | 21 +++++++++++++++++++ source/TestApp/MainWindow.xaml | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/source/Components/AvalonDock/Controls/LayoutAnchorControl.cs b/source/Components/AvalonDock/Controls/LayoutAnchorControl.cs index 9eb14aca..d4bbb2db 100644 --- a/source/Components/AvalonDock/Controls/LayoutAnchorControl.cs +++ b/source/Components/AvalonDock/Controls/LayoutAnchorControl.cs @@ -138,7 +138,7 @@ protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e) { base.OnMouseEnter(e); - if (!e.Handled) + if (!e.Handled && _model.CanShowOnHover) { _openUpTimer = new DispatcherTimer(DispatcherPriority.ApplicationIdle); _openUpTimer.Interval = TimeSpan.FromMilliseconds(400); diff --git a/source/Components/AvalonDock/Layout/LayoutContent.cs b/source/Components/AvalonDock/Layout/LayoutContent.cs index 753cd56a..84e1b99f 100644 --- a/source/Components/AvalonDock/Layout/LayoutContent.cs +++ b/source/Components/AvalonDock/Layout/LayoutContent.cs @@ -462,6 +462,23 @@ public bool CanFloat #endregion CanFloat + #region CanShowOnHover + + private bool _canShowOnHover = true; + + public bool CanShowOnHover + { + get => _canShowOnHover; + set + { + if (value == _canShowOnHover) return; + _canShowOnHover = value; + RaisePropertyChanged(nameof(CanShowOnHover)); + } + } + + #endregion CanShowOnHover + #region IsEnabled private bool _isEnabled = true; @@ -531,6 +548,8 @@ public virtual void ReadXml(System.Xml.XmlReader reader) CanFloat = bool.Parse(reader.Value); if (reader.MoveToAttribute(nameof(LastActivationTimeStamp))) LastActivationTimeStamp = DateTime.Parse(reader.Value, CultureInfo.InvariantCulture); + if (reader.MoveToAttribute(nameof(CanShowOnHover))) + CanShowOnHover = bool.Parse(reader.Value); reader.Read(); } @@ -570,6 +589,8 @@ public virtual void WriteXml(System.Xml.XmlWriter writer) if (LastActivationTimeStamp != null) writer.WriteAttributeString(nameof(LastActivationTimeStamp), LastActivationTimeStamp.Value.ToString(CultureInfo.InvariantCulture)); + if (!CanShowOnHover) writer.WriteAttributeString(nameof(CanShowOnHover), CanShowOnHover.ToString()); + if (_previousContainer is ILayoutPaneSerializable paneSerializable) { writer.WriteAttributeString("PreviousContainerId", paneSerializable.Id); diff --git a/source/TestApp/MainWindow.xaml b/source/TestApp/MainWindow.xaml index 81e1ee09..ecfea73c 100644 --- a/source/TestApp/MainWindow.xaml +++ b/source/TestApp/MainWindow.xaml @@ -121,6 +121,7 @@ From c84f360f0b4323f12c16a2e301c1d3278b91da51 Mon Sep 17 00:00:00 2001 From: Cory Todd Date: Tue, 27 Apr 2021 18:38:26 -0700 Subject: [PATCH 2/3] Revert change to TestApp.MainWindow.xaml Leave the test app alone --- source/TestApp/MainWindow.xaml | 1 - 1 file changed, 1 deletion(-) diff --git a/source/TestApp/MainWindow.xaml b/source/TestApp/MainWindow.xaml index ecfea73c..81e1ee09 100644 --- a/source/TestApp/MainWindow.xaml +++ b/source/TestApp/MainWindow.xaml @@ -121,7 +121,6 @@ From e845e662c0db53ffec27fb030b4cb222b81360ec Mon Sep 17 00:00:00 2001 From: Cory Todd Date: Fri, 30 Apr 2021 09:56:34 -0700 Subject: [PATCH 3/3] pr fixes Document changes relating to this new behavior --- .../Components/AvalonDock/Controls/LayoutAnchorControl.cs | 1 + source/Components/AvalonDock/Layout/LayoutContent.cs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/source/Components/AvalonDock/Controls/LayoutAnchorControl.cs b/source/Components/AvalonDock/Controls/LayoutAnchorControl.cs index d4bbb2db..1199afcb 100644 --- a/source/Components/AvalonDock/Controls/LayoutAnchorControl.cs +++ b/source/Components/AvalonDock/Controls/LayoutAnchorControl.cs @@ -138,6 +138,7 @@ protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e) { base.OnMouseEnter(e); + // If the model wants to auto-show itself on hover then initiate the show action if (!e.Handled && _model.CanShowOnHover) { _openUpTimer = new DispatcherTimer(DispatcherPriority.ApplicationIdle); diff --git a/source/Components/AvalonDock/Layout/LayoutContent.cs b/source/Components/AvalonDock/Layout/LayoutContent.cs index 84e1b99f..9e4f6c57 100644 --- a/source/Components/AvalonDock/Layout/LayoutContent.cs +++ b/source/Components/AvalonDock/Layout/LayoutContent.cs @@ -466,6 +466,13 @@ public bool CanFloat private bool _canShowOnHover = true; + /// + /// Set to false to disable the behavior of auto-showing + /// a on mouse over. + /// When true, hovering the mouse over an anchorable tab + /// will cause the anchorable to show itself. + /// + /// Defaults to true public bool CanShowOnHover { get => _canShowOnHover;