Skip to content

Commit

Permalink
Merge pull request #130 from scdmitryvodich/Issue_117_OuterDockingBut…
Browse files Browse the repository at this point in the history
…tons

Fix #117 with hiding outer docking buttons.
  • Loading branch information
Dirkster99 authored Feb 26, 2020
2 parents c13facc + 89f11b7 commit 4efb7bb
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 15 deletions.
10 changes: 8 additions & 2 deletions source/Components/AvalonDock.Themes.Aero/Theme.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<avalonDockConverters:LayoutItemFromLayoutModelConverter x:Key="LayoutItemFromLayoutModelConverter" />
<avalonDockConverters:ActivateCommandLayoutItemFromLayoutModelConverter x:Key="ActivateCommandLayoutItemFromLayoutModelConverter" />
<avalonDockConverters:AnchorableContextMenuHideVisibilityConverter x:Key="AnchorableContextMenuHideVisibilityConverter" />
<avalonDockConverters:OverlayWindowToVisibilityConverter x:Key="OverlayWindowToVisibilityConverter" />

<!--DocumentPaneControlStyle-->
<Style x:Key="AvalonDock_ThemeAero_DocumentPaneControlStyle"
Expand Down Expand Up @@ -829,9 +830,14 @@
</Grid.RowDefinitions>
<Image Grid.ColumnSpan="5"
Grid.RowSpan="5"
Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource OverlayWindowToVisibilityConverter}, ConverterParameter=True}"
Source="Images/DockPaneLargeEmpty.PNG"
Stretch="None" >
</Image>
Stretch="None" />
<Image Grid.ColumnSpan="5"
Grid.RowSpan="5"
Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource OverlayWindowToVisibilityConverter}, ConverterParameter=False}"
Source="Images/DockPaneEmpty.PNG"
Stretch="None" />
<Border Name="PART_DocumentPaneFullDropTargetTop"
Grid.Column="2"
Grid.Row="1">
Expand Down
10 changes: 8 additions & 2 deletions source/Components/AvalonDock.Themes.Metro/Theme.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<avalonDockConverters:LayoutItemFromLayoutModelConverter x:Key="LayoutItemFromLayoutModelConverter" />
<avalonDockConverters:ActivateCommandLayoutItemFromLayoutModelConverter x:Key="ActivateCommandLayoutItemFromLayoutModelConverter" />
<avalonDockConverters:AnchorableContextMenuHideVisibilityConverter x:Key="AnchorableContextMenuHideVisibilityConverter" />
<avalonDockConverters:OverlayWindowToVisibilityConverter x:Key="OverlayWindowToVisibilityConverter" />

<Style x:Key="AvalonDock_ThemeMetro_ToolButtonStyle"
TargetType="ToggleButton">
Expand Down Expand Up @@ -851,9 +852,14 @@
</Grid.RowDefinitions>
<Image Grid.ColumnSpan="5"
Grid.RowSpan="5"
Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource OverlayWindowToVisibilityConverter}, ConverterParameter=True}"
Source="Images/DockPaneLargeEmpty.PNG"
Stretch="None" >
</Image>
Stretch="None" />
<Image Grid.ColumnSpan="5"
Grid.RowSpan="5"
Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource OverlayWindowToVisibilityConverter}, ConverterParameter=False}"
Source="Images/DockPaneEmpty.PNG"
Stretch="None" />
<Border Name="PART_DocumentPaneFullDropTargetTop"
Grid.Column="2"
Grid.Row="1">
Expand Down
10 changes: 8 additions & 2 deletions source/Components/AvalonDock.Themes.VS2010/Theme.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<avalonDockConverters:LayoutItemFromLayoutModelConverter x:Key="LayoutItemFromLayoutModelConverter" />
<avalonDockConverters:ActivateCommandLayoutItemFromLayoutModelConverter x:Key="ActivateCommandLayoutItemFromLayoutModelConverter" />
<avalonDockConverters:AnchorableContextMenuHideVisibilityConverter x:Key="AnchorableContextMenuHideVisibilityConverter" />
<avalonDockConverters:OverlayWindowToVisibilityConverter x:Key="OverlayWindowToVisibilityConverter" />


<Style x:Key="AvalonDock_ThemeVS2010_ToolButtonStyle"
Expand Down Expand Up @@ -947,9 +948,14 @@
</Grid.RowDefinitions>
<Image Grid.ColumnSpan="5"
Grid.RowSpan="5"
Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource OverlayWindowToVisibilityConverter}, ConverterParameter=True}"
Source="Images/DockPaneLargeEmpty.PNG"
Stretch="None" >
</Image>
Stretch="None" />
<Image Grid.ColumnSpan="5"
Grid.RowSpan="5"
Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource OverlayWindowToVisibilityConverter}, ConverterParameter=False}"
Source="Images/DockPaneEmpty.PNG"
Stretch="None" />
<Border Name="PART_DocumentPaneFullDropTargetTop"
Grid.Column="2"
Grid.Row="1">
Expand Down
12 changes: 6 additions & 6 deletions source/Components/AvalonDock.Themes.VS2013/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1095,16 +1095,16 @@
>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition MinWidth="{DynamicResource {x:Static reskeys:ResourceKeys.DockingButtonWidthKey}}" />
<ColumnDefinition MinWidth="{DynamicResource {x:Static reskeys:ResourceKeys.DockingButtonWidthKey}}" />
<ColumnDefinition MinWidth="{DynamicResource {x:Static reskeys:ResourceKeys.DockingButtonWidthKey}}" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition MinHeight="{DynamicResource {x:Static reskeys:ResourceKeys.DockingButtonHeightKey}}" />
<RowDefinition MinHeight="{DynamicResource {x:Static reskeys:ResourceKeys.DockingButtonHeightKey}}" />
<RowDefinition MinHeight="{DynamicResource {x:Static reskeys:ResourceKeys.DockingButtonHeightKey}}" />
<RowDefinition />
</Grid.RowDefinitions>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,10 @@ protected override void Drop(LayoutDocumentFloatingWindow floatingWindow)
#endregion DropTargetType.DocumentPaneDockInside
}

documentActive.IsActive = true;
if (documentActive != null)
{
documentActive.IsActive = true;
}

base.Drop(floatingWindow);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ protected override IntPtr FilterMessage(IntPtr hwnd, int msg, IntPtr wParam, Int
case Win32Helper.WM_NCLBUTTONDOWN: //Left button down on title -> start dragging over docking manager
if (wParam.ToInt32() == Win32Helper.HT_CAPTION)
{
_model.Descendents().OfType<LayoutDocumentPane>().First(p => p.ChildrenCount > 0 && p.SelectedContent != null).SelectedContent.IsActive = true;
LayoutDocumentPane layoutDocumentPane = _model.Descendents().OfType<LayoutDocumentPane>().FirstOrDefault(p => p.ChildrenCount > 0 && p.SelectedContent != null);
if (layoutDocumentPane != null)
{
layoutDocumentPane.SelectedContent.IsActive = true;
}

handled = true;
}
break;
Expand Down
22 changes: 21 additions & 1 deletion source/Components/AvalonDock/Controls/OverlayWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ internal OverlayWindow(IOverlayWindowHost host)

#endregion

#region Properties.

/// <summary>
/// Gets whether the window is hosted in a floating window.
/// </summary>
public bool IsHostedInFloatingWindow => _host is LayoutDocumentFloatingWindowControl || _host is LayoutAnchorableFloatingWindowControl;

#endregion

#region Overrides

public override void OnApplyTemplate()
Expand Down Expand Up @@ -601,7 +610,17 @@ void IOverlayWindow.DragEnter(IDropArea area)
_documentPaneFullDropTargetBottom.Visibility = Visibility.Visible;
}

if (parentDocumentPaneGroup != null &&
if (layoutDocumentPane.IsHostedInFloatingWindow)
{
// Hide outer buttons if drop area is a document floating window host
// since these 4 drop area buttons are available over the DockingManager ONLY.
_documentPaneDropTargetBottomAsAnchorablePane.Visibility = System.Windows.Visibility.Collapsed;
_documentPaneDropTargetLeftAsAnchorablePane.Visibility = System.Windows.Visibility.Collapsed;
_documentPaneDropTargetRightAsAnchorablePane.Visibility = System.Windows.Visibility.Collapsed;
_documentPaneDropTargetTopAsAnchorablePane.Visibility = System.Windows.Visibility.Collapsed;
}

else if (parentDocumentPaneGroup != null &&
parentDocumentPaneGroup.Children.Where(c => c.IsVisible).Count() > 1)
{
int indexOfDocumentPane = parentDocumentPaneGroup.Children.Where(ch => ch.IsVisible).ToList().IndexOf(layoutDocumentPane);
Expand Down Expand Up @@ -649,6 +668,7 @@ void IOverlayWindow.DragEnter(IDropArea area)
}
else
{
// Showing a drop target structure with 5 centered star like buttons.
areaElement = _gridDocumentPaneDropTargets;
var dropAreaDocumentPaneGroup = area as DropArea<LayoutDocumentPaneControl>;
var layoutDocumentPane = dropAreaDocumentPaneGroup.AreaElement.Model as LayoutDocumentPane;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/************************************************************************
AvalonDock
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at https://opensource.org/licenses/MS-PL
************************************************************************/

using System;
using System.Windows;
using System.Windows.Data;
using AvalonDock.Controls;
using AvalonDock.Layout;

namespace AvalonDock.Converters
{
/// <summary>
/// Converts a <see cref="LayoutContent"/> into a <see cref="LayoutItem"/>
/// and ensures that other essential properties (Root, Root.Manager) are available.
///
/// Returns null or Binding.DoNothing otherwise.
/// </summary>
public class OverlayWindowToVisibilityConverter : IValueConverter
{
/// <summary>
/// Converts a <see cref="OverlayWindow"/> into a <see cref="Visibility"/>.
/// </summary>
/// <param name="value">The value produced by the binding source.</param>
/// <param name="targetType">The type of the binding target property.</param>
/// <param name="parameter">The converter parameter to use.</param>
/// <param name="culture">The culture to use in the converter.</param>
/// <returns>A converted value.</returns>
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool isHostedInFloatingWindow = value is OverlayWindow overlayWindow && overlayWindow.IsHostedInFloatingWindow;
if (parameter == null || !bool.TryParse(parameter.ToString(), out bool isLarge))
{
isLarge = false;
}

return isHostedInFloatingWindow && isLarge ? Visibility.Hidden : Visibility.Visible;
}

/// <summary>
/// Method is not implemented and will raise <see cref="System.NotSupportedException"/> when called.
/// </summary>
/// <param name="value">The value that is produced by the binding target.</param>
/// <param name="targetType">The type to convert to.</param>
/// <param name="parameter">The converter parameter to use.</param>
/// <param name="culture">The culture to use in the converter.</param>
/// <returns><see cref="System.NotSupportedException"/></returns>
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) => throw new NotSupportedException();
}
}

0 comments on commit 4efb7bb

Please sign in to comment.