Skip to content

Commit

Permalink
Merge pull request #267 from corytodd/OptionalShowOnHover
Browse files Browse the repository at this point in the history
Optional show hidden LayoutAnchorable on hover
  • Loading branch information
Dirkster99 authored May 1, 2021
2 parents 99b2fdc + e845e66 commit 47ce0f9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/Components/AvalonDock/Controls/LayoutAnchorControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e)
{
base.OnMouseEnter(e);

if (!e.Handled)
// 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);
_openUpTimer.Interval = TimeSpan.FromMilliseconds(400);
Expand Down
28 changes: 28 additions & 0 deletions source/Components/AvalonDock/Layout/LayoutContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,30 @@ public bool CanFloat

#endregion CanFloat

#region CanShowOnHover

private bool _canShowOnHover = true;

/// <summary>
/// Set to false to disable the behavior of auto-showing
/// a <see cref="LayoutAnchorableControl"/> on mouse over.
/// When true, hovering the mouse over an anchorable tab
/// will cause the anchorable to show itself.
/// </summary>
/// <remarks>Defaults to true</remarks>
public bool CanShowOnHover
{
get => _canShowOnHover;
set
{
if (value == _canShowOnHover) return;
_canShowOnHover = value;
RaisePropertyChanged(nameof(CanShowOnHover));
}
}

#endregion CanShowOnHover

#region IsEnabled

private bool _isEnabled = true;
Expand Down Expand Up @@ -531,6 +555,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();
}
Expand Down Expand Up @@ -570,6 +596,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);
Expand Down

0 comments on commit 47ce0f9

Please # to comment.