-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fancy server info link buttons (#125)
- Loading branch information
Showing
3 changed files
with
119 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
|
||
namespace SS14.Launcher.Views; | ||
|
||
public sealed class RowSideAlignedPanel : Panel | ||
{ | ||
protected override Size MeasureOverride(Size availableSize) | ||
{ | ||
if (Children.Count < 2) | ||
return base.MeasureOverride(availableSize); | ||
|
||
var left = Children[0]; | ||
var right = Children[1]; | ||
|
||
left.Measure(availableSize); | ||
right.Measure(availableSize); | ||
|
||
var leftSize = left.DesiredSize; | ||
var rightSize = right.DesiredSize; | ||
|
||
if (leftSize.Width + rightSize.Width <= availableSize.Width) | ||
{ | ||
// They both fit on one row, easy. | ||
return new Size(leftSize.Width + rightSize.Width, Math.Max(leftSize.Height, rightSize.Height)); | ||
} | ||
else | ||
{ | ||
// They don't fit on the same row, make two rows. | ||
return new Size(Math.Max(leftSize.Width, rightSize.Width), leftSize.Height + rightSize.Height); | ||
} | ||
} | ||
|
||
protected override Size ArrangeOverride(Size finalSize) | ||
{ | ||
if (Children.Count < 2) | ||
return base.MeasureOverride(finalSize); | ||
|
||
var left = Children[0]; | ||
var right = Children[1]; | ||
|
||
var leftSize = left.DesiredSize; | ||
var rightSize = right.DesiredSize; | ||
|
||
if (leftSize.Width + rightSize.Width <= finalSize.Width) | ||
{ | ||
// They both fit on one row, easy. | ||
left.Arrange(new Rect(0, 0, leftSize.Width, finalSize.Height)); | ||
right.Arrange(new Rect(finalSize.Width - rightSize.Width, 0, rightSize.Width, finalSize.Height)); | ||
|
||
return finalSize; | ||
} | ||
else | ||
{ | ||
// They don't fit on the same row, make two rows. | ||
left.Arrange(new Rect(0, 0, leftSize.Width, leftSize.Height)); | ||
right.Arrange(new Rect(finalSize.Width - rightSize.Width, leftSize.Height, rightSize.Width, finalSize.Height - leftSize.Height)); | ||
|
||
return finalSize; | ||
} | ||
} | ||
} |