Skip to content

Commit

Permalink
Improve content position on Left/RightChromeWindow.
Browse files Browse the repository at this point in the history
  • Loading branch information
mntone committed Aug 30, 2020
1 parent eee8f11 commit be67283
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 14 deletions.
11 changes: 11 additions & 0 deletions samples/MetroRadiance.Showcase/UI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@

<chrome:WindowChrome.Instance>
<chrome:WindowChrome x:Name="WindowChrome">
<chrome:WindowChrome.Left>
<Border Background="DarkBlue"
Padding="24,3"
VerticalAlignment="Bottom">
<Border.LayoutTransform>
<RotateTransform Angle="90" />
</Border.LayoutTransform>
<TextBlock Text="UI element on Left"
Foreground="White" />
</Border>
</chrome:WindowChrome.Left>
<chrome:WindowChrome.Top>
<Border Background="DarkRed"
Padding="24,3"
Expand Down
13 changes: 10 additions & 3 deletions source/MetroRadiance.Chrome/Chrome/Primitives/ChromeWindow.Left.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@ static LeftChromeWindow()
new FrameworkPropertyMetadata(nameof(LeftChromeWindow)));
}

private int _topScaledBorderThickness = 0;
private int _bottomScaledBorderThickness = 0;

public LeftChromeWindow()
{
this.SizeToContent = SizeToContent.Width;
}

protected override void UpdateDpiResources() { }
protected override void UpdateDpiResources()
{
this._topScaledBorderThickness = this.BorderThickness.Top.DpiRoundX(this.CurrentDpi);
this._bottomScaledBorderThickness = this.BorderThickness.Bottom.DpiRoundX(this.CurrentDpi);
}

protected override int GetLeft(RECT owner)
{
Expand All @@ -31,7 +38,7 @@ protected override int GetLeft(RECT owner)

protected override int GetTop(RECT owner)
{
return owner.Top;
return owner.Top - this._topScaledBorderThickness;
}

protected override int GetWidth(RECT owner)
Expand All @@ -41,7 +48,7 @@ protected override int GetWidth(RECT owner)

protected override int GetHeight(RECT owner)
{
return owner.Height;
return owner.Height + this._topScaledBorderThickness + this._bottomScaledBorderThickness;
}

protected override void OwnerSizeChangedCallback(object sender, EventArgs eventArgs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,28 @@ static RightChromeWindow()
new FrameworkPropertyMetadata(nameof(RightChromeWindow)));
}

private int _topScaledBorderThickness = 0;
private int _bottomScaledBorderThickness = 0;

public RightChromeWindow()
{
this.SizeToContent = SizeToContent.Width;
}

protected override void UpdateDpiResources() { }

protected override void UpdateDpiResources()
{
this._topScaledBorderThickness = this.BorderThickness.Top.DpiRoundX(this.CurrentDpi);
this._bottomScaledBorderThickness = this.BorderThickness.Bottom.DpiRoundX(this.CurrentDpi);
}

protected override int GetLeft(RECT owner)
{
return owner.Right;
}

protected override int GetTop(RECT owner)
{
return owner.Top;
return owner.Top - this._topScaledBorderThickness;
}

protected override int GetWidth(RECT owner)
Expand All @@ -41,7 +48,7 @@ protected override int GetWidth(RECT owner)

protected override int GetHeight(RECT owner)
{
return owner.Height;
return owner.Height + this._topScaledBorderThickness + this._bottomScaledBorderThickness;
}
}
}
2 changes: 1 addition & 1 deletion source/MetroRadiance.Chrome/Chrome/WindowChrome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ public void Attach(Window window)
this.Detach();

this._top.Attach(window);
this._bottom.Attach(window);
this._left.Attach(window);
this._right.Attach(window);
this._bottom.Attach(window);

this.CanResize = true;
}
Expand Down
10 changes: 7 additions & 3 deletions source/MetroRadiance.Chrome/Themes/Generic.GlowingEdge.Left.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@
<ControlTemplate TargetType="{x:Type chrome:LeftGlowingEdge}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Top, Mode=OneTime}" />
<RowDefinition Height="{StaticResource TiltedCursorMarginKey}" />
<RowDefinition />
<RowDefinition Height="{StaticResource TiltedCursorMarginKey}" />
<RowDefinition Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Bottom, Mode=OneTime}" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{x:Static chrome:GlowingEdge.__Thickness}" />
<ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Left, Mode=OneTime}" />
</Grid.ColumnDefinitions>

<Rectangle Grid.Column="1"
Grid.Row="1"
Grid.RowSpan="3"
Fill="{TemplateBinding BorderBrush}" />
<Rectangle Grid.Column="0"
Grid.Row="1"
Grid.RowSpan="3">
<Rectangle.Fill>
<LinearGradientBrush x:Name="PART_GradientBrush"
Expand All @@ -35,19 +39,19 @@
</Rectangle>

<Rectangle x:Name="PART_TopLeftThumb"
Grid.Row="0"
Grid.Row="1"
Grid.ColumnSpan="2"
IsEnabled="{TemplateBinding CanResize}"
Cursor="SizeNWSE"
Fill="Transparent" />
<Rectangle x:Name="PART_LeftThumb"
Grid.Row="1"
Grid.Row="2"
Grid.ColumnSpan="2"
IsEnabled="{TemplateBinding CanResize}"
Cursor="SizeWE"
Fill="Transparent" />
<Rectangle x:Name="PART_BottomLeftThumb"
Grid.Row="2"
Grid.Row="3"
Grid.ColumnSpan="2"
IsEnabled="{TemplateBinding CanResize}"
Cursor="SizeNESW"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@
<ControlTemplate TargetType="{x:Type chrome:RightGlowingEdge}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Top, Mode=OneTime}" />
<RowDefinition Height="{StaticResource TiltedCursorMarginKey}" />
<RowDefinition />
<RowDefinition Height="{StaticResource TiltedCursorMarginKey}" />
<RowDefinition Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Bottom, Mode=OneTime}" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Right, Mode=OneTime}" />
<ColumnDefinition Width="{x:Static chrome:GlowingEdge.__Thickness}" />
</Grid.ColumnDefinitions>

<Rectangle Grid.Column="0"
Grid.Row="1"
Grid.RowSpan="3"
Fill="{TemplateBinding BorderBrush}" />
<Rectangle Grid.Column="1"
Grid.Row="1"
Grid.RowSpan="3">
<Rectangle.Fill>
<LinearGradientBrush x:Name="PART_GradientBrush"
Expand All @@ -35,19 +39,19 @@
</Rectangle>

<Rectangle x:Name="PART_TopRightThumb"
Grid.Row="0"
Grid.Row="1"
Grid.ColumnSpan="2"
IsEnabled="{TemplateBinding CanResize}"
Cursor="SizeNESW"
Fill="Transparent" />
<Rectangle x:Name="PART_RightThumb"
Grid.Row="1"
Grid.Row="2"
Grid.ColumnSpan="2"
IsEnabled="{TemplateBinding CanResize}"
Cursor="SizeWE"
Fill="Transparent" />
<Rectangle x:Name="PART_BottomRightThumb"
Grid.Row="2"
Grid.Row="3"
Grid.ColumnSpan="2"
IsEnabled="{TemplateBinding CanResize}"
Cursor="SizeNWSE"
Expand Down

0 comments on commit be67283

Please sign in to comment.