Skip to content

Commit

Permalink
V4.2.0 Released
Browse files Browse the repository at this point in the history
  • Loading branch information
XceedBoucherS committed Dec 2, 2021
1 parent 024d905 commit 5a8bbe7
Show file tree
Hide file tree
Showing 62 changed files with 1,450 additions and 625 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,6 @@ protected override Size ArrangeOverride( Size finalSize )
return finalSize;
}

protected override void OnMouseLeave( System.Windows.Input.MouseEventArgs e )
{
if( e.LeftButton == System.Windows.Input.MouseButtonState.Pressed &&
LayoutAnchorableTabItem.IsDraggingItem() )
{
var contentModel = LayoutAnchorableTabItem.GetDraggingItem().Model as LayoutAnchorable;
var manager = contentModel.Root.Manager;
LayoutAnchorableTabItem.ResetDraggingItem();

manager.StartDraggingFloatingWindowForContent( contentModel );
}

base.OnMouseLeave( e );
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public void Drop( LayoutFloatingWindow floatingWindow )
currentActiveContent.IsSelected = false;
currentActiveContent.IsActive = false;
currentActiveContent.IsActive = true;
currentActiveContent.IsFloating = false;
} ), DispatcherPriority.Background );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ protected override void SetDefaultBindings()
if( DockCommand == null )
this.SetCurrentValue( LayoutAnchorableItem.DockCommandProperty, _defaultDockCommand );

Visibility = _anchorable.IsVisible ? Visibility.Visible : System.Windows.Visibility.Hidden;
this.SetCurrentValue( LayoutAnchorableItem.VisibilityProperty, _anchorable.IsVisible ? Visibility.Visible : System.Windows.Visibility.Hidden );
base.SetDefaultBindings();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ COMMUNITY LICENSE AGREEMENT (for non-commercial use) as published at
***********************************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
Expand All @@ -27,9 +29,17 @@ public class LayoutAnchorableTabItem : Control
{
#region Members

private static double MinDragBuffer = 5d;
private static double MaxDragBuffer = 50d;

private bool _isMouseDown = false;
private static LayoutAnchorableTabItem _draggingItem = null;
private static bool _cancelMouseLeave = false;
private Point _mouseDownPoint;
private double _mouseLastChangePositionX;
private Rect _parentAnchorableTabPanelScreenArea;
private List<Rect> _otherTabsScreenArea = null;
private List<TabItem> _otherTabs = null;
private AnchorablePaneTabPanel _parentAnchorableTabPanel;
private double _dragBuffer = MinDragBuffer;

#endregion

Expand Down Expand Up @@ -136,98 +146,127 @@ protected override void OnMouseLeftButtonDown( System.Windows.Input.MouseButtonE
base.OnMouseLeftButtonDown( e );

_isMouseDown = true;
_draggingItem = this;
_mouseDownPoint = e.GetPosition( this );
}

protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )
{
base.OnMouseMove( e );

if( e.LeftButton != MouseButtonState.Pressed )
var ptMouseMove = e.GetPosition( this );

if( _isMouseDown )
{
_isMouseDown = false;
_draggingItem = null;
if( Math.Abs( ptMouseMove.X - _mouseDownPoint.X ) > SystemParameters.MinimumHorizontalDragDistance ||
Math.Abs( ptMouseMove.Y - _mouseDownPoint.Y ) > SystemParameters.MinimumVerticalDragDistance )
{
this.UpdateDragDetails();
this.CaptureMouse();
_isMouseDown = false;
}
}
else

if( this.IsMouseCaptured )
{
_cancelMouseLeave = false;
var mousePosInScreenCoord = this.PointToScreenDPI( ptMouseMove );

if( !_parentAnchorableTabPanelScreenArea.Contains( mousePosInScreenCoord ) )
{
var contentModel = this.Model as LayoutAnchorable;
var manager = contentModel.Root.Manager;
this.ReleaseMouseCapture();
manager.StartDraggingFloatingWindowForContent( contentModel );
}
else
{
int indexOfTabItemWithMouseOver = _otherTabsScreenArea.FindIndex( r => r.Contains( mousePosInScreenCoord ) );
if( indexOfTabItemWithMouseOver >= 0 )
{
var targetModel = _otherTabs[ indexOfTabItemWithMouseOver ].Content as LayoutContent;
var container = this.Model.Parent as ILayoutContainer;
var containerPane = this.Model.Parent as ILayoutPane;
var currentTabScreenArea = this.FindLogicalAncestor<TabItem>().GetScreenArea();

// Inside current TabItem, do not care about _mouseLastChangePosition for next change position.
if( targetModel == this.Model )
{
_mouseLastChangePositionX = currentTabScreenArea.Left + ( currentTabScreenArea.Width / 2 );
}

if( ( containerPane is LayoutAnchorablePane ) && !( (LayoutAnchorablePane)containerPane ).CanRepositionItems )
return;
if( ( containerPane.Parent != null ) && ( containerPane.Parent is LayoutAnchorablePaneGroup ) && !( (LayoutAnchorablePaneGroup)containerPane.Parent ).CanRepositionItems )
return;

var childrenList = container.Children.ToList();
var currentIndex = childrenList.IndexOf( this.Model );
var newIndex = childrenList.IndexOf( targetModel );

if( currentIndex != newIndex )
{
// Moving left when cursor leave tabItem or moving left past last change position.
// Or, moving right cursor leave tabItem or moving right past last change position.
if( ( ( mousePosInScreenCoord.X < currentTabScreenArea.Left ) && ( mousePosInScreenCoord.X < _mouseLastChangePositionX ) )
|| ( ( mousePosInScreenCoord.X > ( currentTabScreenArea.Left + currentTabScreenArea.Width ) ) && ( mousePosInScreenCoord.X > _mouseLastChangePositionX ) ) )
{
containerPane.MoveChild( currentIndex, newIndex );
_dragBuffer = MaxDragBuffer;
_parentAnchorableTabPanel.UpdateLayout();
this.UpdateDragDetails();
_mouseLastChangePositionX = mousePosInScreenCoord.X;
}
}
}
}
}
}

protected override void OnMouseLeftButtonUp( System.Windows.Input.MouseButtonEventArgs e )
{
if( this.IsMouseCaptured )
{
this.ReleaseMouseCapture();
}
_isMouseDown = false;
_dragBuffer = MinDragBuffer;

base.OnMouseLeftButtonUp( e );

Model.IsActive = true;
this.Model.IsActive = true;
}

protected override void OnMouseLeave( System.Windows.Input.MouseEventArgs e )
{
base.OnMouseLeave( e );

if( _isMouseDown && e.LeftButton == MouseButtonState.Pressed )
{
// drag the item if the mouse leave is not canceled.
// Mouse leave should be canceled when selecting a new tab to prevent automatic undock when Panel size is Auto.
_draggingItem = !_cancelMouseLeave ? this : null;
}

_isMouseDown = false;
_cancelMouseLeave = false;
}

protected override void OnMouseEnter( MouseEventArgs e )
{
base.OnMouseEnter( e );

if( _draggingItem != null
&& _draggingItem != this
&& e.LeftButton == MouseButtonState.Pressed )
{
var model = Model;
var container = model.Parent as ILayoutContainer;
var containerPane = model.Parent as ILayoutPane;

if( ( containerPane is LayoutAnchorablePane ) && !( ( LayoutAnchorablePane )containerPane ).CanRepositionItems )
return;
if( ( containerPane.Parent != null ) && ( containerPane.Parent is LayoutAnchorablePaneGroup ) && !( ( LayoutAnchorablePaneGroup )containerPane.Parent ).CanRepositionItems )
return;

var childrenList = container.Children.ToList();
containerPane.MoveChild( childrenList.IndexOf( _draggingItem.Model ), childrenList.IndexOf( model ) );
}
}

protected override void OnPreviewGotKeyboardFocus( KeyboardFocusChangedEventArgs e )
{
base.OnPreviewGotKeyboardFocus( e );

_isMouseDown = false;
}

#endregion

#region Internal Methods

internal static bool IsDraggingItem()
{
return _draggingItem != null;
}
#region Private Methods

internal static LayoutAnchorableTabItem GetDraggingItem()
private void UpdateDragDetails()
{
return _draggingItem;
}
internal static void ResetDraggingItem()
{
_draggingItem = null;
}
internal static void CancelMouseLeave()
{
_cancelMouseLeave = true;
_parentAnchorableTabPanel = this.FindLogicalAncestor<AnchorablePaneTabPanel>();
_parentAnchorableTabPanelScreenArea = _parentAnchorableTabPanel.GetScreenArea();
_parentAnchorableTabPanelScreenArea.Inflate( 0, _dragBuffer );
_otherTabs = _parentAnchorableTabPanel.Children.Cast<TabItem>().Where( ch => ch.Visibility != System.Windows.Visibility.Collapsed ).ToList();
var currentTabScreenArea = this.FindLogicalAncestor<TabItem>().GetScreenArea();
_otherTabsScreenArea = _otherTabs.Select( ti =>
{
var screenArea = ti.GetScreenArea();
var rect = new Rect( screenArea.Left, screenArea.Top, screenArea.Width, screenArea.Height );
rect.Inflate( 0, _dragBuffer );
return rect;
} ).ToList();
}

#endregion
}
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ public class LayoutDocumentTabItem : Control
{
#region Members

private static double MinDragBuffer = 5d;
private static double MaxDragBuffer = 50d;

private List<Rect> _otherTabsScreenArea = null;
private List<TabItem> _otherTabs = null;
private Rect _parentDocumentTabPanelScreenArea;
private DocumentPaneTabPanel _parentDocumentTabPanel;
private bool _isMouseDown = false;
private Point _mouseDownPoint;
private double _mouseLastChangePositionX;
private double _dragBuffer = MinDragBuffer;

#endregion

Expand Down Expand Up @@ -159,10 +164,10 @@ protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )
{
base.OnMouseMove( e );

var ptMouseMove = e.GetPosition( this );

if( _isMouseDown )
{
Point ptMouseMove = e.GetPosition( this );

if( Math.Abs( ptMouseMove.X - _mouseDownPoint.X ) > SystemParameters.MinimumHorizontalDragDistance ||
Math.Abs( ptMouseMove.Y - _mouseDownPoint.Y ) > SystemParameters.MinimumVerticalDragDistance )
{
Expand All @@ -174,7 +179,8 @@ protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )

if( this.IsMouseCaptured )
{
var mousePosInScreenCoord = this.PointToScreenDPI( e.GetPosition( this ) );
var mousePosInScreenCoord = this.PointToScreenDPI( ptMouseMove );

if( !_parentDocumentTabPanelScreenArea.Contains( mousePosInScreenCoord ) )
{
this.StartDraggingFloatingWindowForContent();
Expand All @@ -187,17 +193,38 @@ protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )
var targetModel = _otherTabs[ indexOfTabItemWithMouseOver ].Content as LayoutContent;
var container = this.Model.Parent as ILayoutContainer;
var containerPane = this.Model.Parent as ILayoutPane;
var currentTabScreenArea = this.FindLogicalAncestor<TabItem>().GetScreenArea();

if( ( containerPane is LayoutDocumentPane ) && !( ( LayoutDocumentPane )containerPane ).CanRepositionItems )
// Inside current TabItem, do not care about _mouseLastChangePosition for next change position.
if( targetModel == this.Model )
{
_mouseLastChangePositionX = currentTabScreenArea.Left + ( currentTabScreenArea.Width / 2 );
}

if( ( containerPane is LayoutDocumentPane ) && !( (LayoutDocumentPane)containerPane ).CanRepositionItems )
return;
if( ( containerPane.Parent != null ) && ( containerPane.Parent is LayoutDocumentPaneGroup ) && !( ( LayoutDocumentPaneGroup )containerPane.Parent ).CanRepositionItems )
if( ( containerPane.Parent != null ) && ( containerPane.Parent is LayoutDocumentPaneGroup ) && !( (LayoutDocumentPaneGroup)containerPane.Parent ).CanRepositionItems )
return;

var childrenList = container.Children.ToList();
containerPane.MoveChild( childrenList.IndexOf( Model ), childrenList.IndexOf( targetModel ) );
this.Model.IsActive = true;
_parentDocumentTabPanel.UpdateLayout();
this.UpdateDragDetails();
var currentIndex = childrenList.IndexOf( this.Model );
var newIndex = childrenList.IndexOf( targetModel );

if( currentIndex != newIndex )
{
// Moving left when cursor leave tabItem or moving left past last change position.
// Or, moving right cursor leave tabItem or moving right past last change position.
if( ( ( mousePosInScreenCoord.X < currentTabScreenArea.Left ) && ( mousePosInScreenCoord.X < _mouseLastChangePositionX ) )
|| ( ( mousePosInScreenCoord.X > ( currentTabScreenArea.Left + currentTabScreenArea.Width ) ) && ( mousePosInScreenCoord.X > _mouseLastChangePositionX ) ) )
{
containerPane.MoveChild( currentIndex, newIndex );
_dragBuffer = MaxDragBuffer;
this.Model.IsActive = true;
_parentDocumentTabPanel.UpdateLayout();
this.UpdateDragDetails();
_mouseLastChangePositionX = mousePosInScreenCoord.X;
}
}
}
}
}
Expand All @@ -206,8 +233,11 @@ protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )
protected override void OnMouseLeftButtonUp( System.Windows.Input.MouseButtonEventArgs e )
{
if( IsMouseCaptured )
ReleaseMouseCapture();
{
this.ReleaseMouseCapture();
}
_isMouseDown = false;
_dragBuffer = MinDragBuffer;

base.OnMouseLeftButtonUp( e );
}
Expand Down Expand Up @@ -243,13 +273,15 @@ private void UpdateDragDetails()
{
_parentDocumentTabPanel = this.FindLogicalAncestor<DocumentPaneTabPanel>();
_parentDocumentTabPanelScreenArea = _parentDocumentTabPanel.GetScreenArea();
_otherTabs = _parentDocumentTabPanel.Children.Cast<TabItem>().Where( ch =>
ch.Visibility != System.Windows.Visibility.Collapsed ).ToList();
Rect currentTabScreenArea = this.FindLogicalAncestor<TabItem>().GetScreenArea();
_parentDocumentTabPanelScreenArea.Inflate( 0, _dragBuffer );
_otherTabs = _parentDocumentTabPanel.Children.Cast<TabItem>().Where( ch => ch.Visibility != System.Windows.Visibility.Collapsed ).ToList();
var currentTabScreenArea = this.FindLogicalAncestor<TabItem>().GetScreenArea();
_otherTabsScreenArea = _otherTabs.Select( ti =>
{
var screenArea = ti.GetScreenArea();
return new Rect( screenArea.Left, screenArea.Top, currentTabScreenArea.Width, screenArea.Height );
var rect = new Rect( screenArea.Left, screenArea.Top, screenArea.Width, screenArea.Height );
rect.Inflate( 0, _dragBuffer );
return rect;
} ).ToList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1181,9 +1181,9 @@ protected virtual void SetDefaultBindings()
this.SetCurrentValue( LayoutItem.MoveToPreviousTabGroupCommandProperty, _defaultMoveToPreviousTabGroupCommand );


IsSelected = LayoutElement.IsSelected;
IsActive = LayoutElement.IsActive;
CanClose = LayoutElement.CanClose;
this.SetCurrentValue( LayoutItem.IsSelectedProperty, LayoutElement.IsSelected );
this.SetCurrentValue( LayoutItem.IsActiveProperty, LayoutElement.IsActive );
this.SetCurrentValue( LayoutItem.CanCloseProperty, LayoutElement.CanClose );
}

protected virtual void OnVisibilityChanged()
Expand Down
Loading

0 comments on commit 5a8bbe7

Please sign in to comment.