Skip to content

Commit

Permalink
bugfix Dirkster99#73 (fixed dock sizes) use code from xceedsoftware/w…
Browse files Browse the repository at this point in the history
  • Loading branch information
jogibear9988 committed Sep 24, 2019
1 parent a709b9a commit 2c6afd7
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected override void OnFixChildrenDockLengths()
for( int i = 0; i < _model.Children.Count; i++ )
{
var childModel = _model.Children[ i ] as ILayoutPositionableElement;
if( !childModel.DockWidth.IsStar )
if( childModel.ForceFixedDockSize && !childModel.DockWidth.IsStar )
{
childModel.DockWidth = new GridLength( 1.0, GridUnitType.Star );
}
Expand All @@ -59,7 +59,7 @@ protected override void OnFixChildrenDockLengths()
for( int i = 0; i < _model.Children.Count; i++ )
{
var childModel = _model.Children[ i ] as ILayoutPositionableElement;
if( !childModel.DockHeight.IsStar )
if( childModel.ForceFixedDockSize && !childModel.DockHeight.IsStar )
{
childModel.DockHeight = new GridLength( 1.0, GridUnitType.Star );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected override void OnFixChildrenDockLengths()
for( int i = 0; i < _model.Children.Count; i++ )
{
var childModel = _model.Children[ i ] as ILayoutPositionableElement;
if( !childModel.DockWidth.IsStar )
if( childModel.ForceFixedDockSize && !childModel.DockWidth.IsStar )
{
childModel.DockWidth = new GridLength( 1.0, GridUnitType.Star );
}
Expand All @@ -59,7 +59,7 @@ protected override void OnFixChildrenDockLengths()
for( int i = 0; i < _model.Children.Count; i++ )
{
var childModel = _model.Children[ i ] as ILayoutPositionableElement;
if( !childModel.DockHeight.IsStar )
if( childModel.ForceFixedDockSize && !childModel.DockHeight.IsStar )
{
childModel.DockHeight = new GridLength( 1.0, GridUnitType.Star );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,27 @@ protected override void OnFixChildrenDockLengths()
var childContainerModel = _model.Children[ i ] as ILayoutContainer;
var childPositionableModel = _model.Children[ i ] as ILayoutPositionableElement;

if( childContainerModel != null &&
( childContainerModel.IsOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>() ||
childContainerModel.ContainsChildOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>() ) )
if (childPositionableModel.ForceFixedDockSize)
{
childPositionableModel.DockWidth = new GridLength( 1.0, GridUnitType.Star );
}
else if( childPositionableModel != null && childPositionableModel.DockWidth.IsStar )
{
var childPositionableModelWidthActualSize = childPositionableModel as ILayoutPositionableElementWithActualSize;
var childDockMinWidth = childPositionableModel.CalculatedDockMinWidth();
var widthToSet = Math.Max( childPositionableModelWidthActualSize.ActualWidth, childDockMinWidth );

widthToSet = Math.Min( widthToSet, ActualWidth / 2.0 );
widthToSet = Math.Max( widthToSet, childDockMinWidth );

childPositionableModel.DockWidth = new GridLength(
widthToSet,
GridUnitType.Pixel );
if (childContainerModel != null &&
(childContainerModel.IsOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>() ||
childContainerModel.ContainsChildOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>()))
{
childPositionableModel.DockWidth = new GridLength(1.0, GridUnitType.Star);
}
else if (childPositionableModel != null && childPositionableModel.DockWidth.IsStar)
{
var childPositionableModelWidthActualSize = childPositionableModel as ILayoutPositionableElementWithActualSize;
var childDockMinWidth = childPositionableModel.CalculatedDockMinWidth();
var widthToSet = Math.Max(childPositionableModelWidthActualSize.ActualWidth, childDockMinWidth);

widthToSet = Math.Min(widthToSet, ActualWidth / 2.0);
widthToSet = Math.Max(widthToSet, childDockMinWidth);

childPositionableModel.DockWidth = new GridLength(
widthToSet,
GridUnitType.Pixel);
}
}
}
}
Expand All @@ -85,7 +88,7 @@ protected override void OnFixChildrenDockLengths()
for( int i = 0; i < _model.Children.Count; i++ )
{
var childPositionableModel = _model.Children[ i ] as ILayoutPositionableElement;
if( !childPositionableModel.DockWidth.IsStar )
if( childPositionableModel.ForceFixedDockSize && !childPositionableModel.DockWidth.IsStar )
{
childPositionableModel.DockWidth = new GridLength( 1.0, GridUnitType.Star );
}
Expand All @@ -101,21 +104,24 @@ protected override void OnFixChildrenDockLengths()
var childContainerModel = _model.Children[ i ] as ILayoutContainer;
var childPositionableModel = _model.Children[ i ] as ILayoutPositionableElement;

if( childContainerModel != null &&
( childContainerModel.IsOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>() ||
childContainerModel.ContainsChildOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>() ) )
if (childPositionableModel.ForceFixedDockSize)
{
childPositionableModel.DockHeight = new GridLength( 1.0, GridUnitType.Star );
}
else if( childPositionableModel != null && childPositionableModel.DockHeight.IsStar )
{
var childPositionableModelWidthActualSize = childPositionableModel as ILayoutPositionableElementWithActualSize;
var childDockMinHeight = childPositionableModel.CalculatedDockMinHeight();
var heightToSet = Math.Max( childPositionableModelWidthActualSize.ActualHeight, childDockMinHeight );
heightToSet = Math.Min( heightToSet, ActualHeight / 2.0 );
heightToSet = Math.Max( heightToSet, childDockMinHeight );

childPositionableModel.DockHeight = new GridLength( heightToSet, GridUnitType.Pixel );
if (childContainerModel != null &&
(childContainerModel.IsOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>() ||
childContainerModel.ContainsChildOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>()))
{
childPositionableModel.DockHeight = new GridLength(1.0, GridUnitType.Star);
}
else if (childPositionableModel != null && childPositionableModel.DockHeight.IsStar)
{
var childPositionableModelWidthActualSize = childPositionableModel as ILayoutPositionableElementWithActualSize;
var childDockMinHeight = childPositionableModel.CalculatedDockMinHeight();
var heightToSet = Math.Max(childPositionableModelWidthActualSize.ActualHeight, childDockMinHeight);
heightToSet = Math.Min(heightToSet, ActualHeight / 2.0);
heightToSet = Math.Max(heightToSet, childDockMinHeight);

childPositionableModel.DockHeight = new GridLength(heightToSet, GridUnitType.Pixel);
}
}
}
}
Expand All @@ -124,7 +130,7 @@ protected override void OnFixChildrenDockLengths()
for( int i = 0; i < _model.Children.Count; i++ )
{
var childPositionableModel = _model.Children[ i ] as ILayoutPositionableElement;
if( !childPositionableModel.DockHeight.IsStar )
if( childPositionableModel.ForceFixedDockSize && !childPositionableModel.DockHeight.IsStar )
{
childPositionableModel.DockHeight = new GridLength( 1.0, GridUnitType.Star );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ bool IsVisible
{
get;
}

bool ForceFixedDockSize
{
get;
}
}


Expand Down
Loading

0 comments on commit 2c6afd7

Please sign in to comment.