-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'wizard/master' into upstream-sync
- Loading branch information
Showing
70 changed files
with
1,197 additions
and
419 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
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,55 @@ | ||
using System.Numerics; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
|
||
namespace Content.Client.UserInterface.Controls; | ||
|
||
/// <summary> | ||
/// Pretends to child controls that there's infinite space. | ||
/// This can be used to make something like a <see cref="RichTextLabel"/> clip instead of wrapping. | ||
/// </summary> | ||
public sealed class ClipControl : Control | ||
{ | ||
private bool _clipHorizontal = true; | ||
private bool _clipVertical = true; | ||
|
||
public bool ClipHorizontal | ||
{ | ||
get => _clipHorizontal; | ||
set | ||
{ | ||
_clipHorizontal = value; | ||
InvalidateMeasure(); | ||
} | ||
} | ||
|
||
public bool ClipVertical | ||
{ | ||
get => _clipVertical; | ||
set | ||
{ | ||
_clipVertical = value; | ||
InvalidateMeasure(); | ||
} | ||
} | ||
|
||
protected override Vector2 MeasureOverride(Vector2 availableSize) | ||
{ | ||
if (ClipHorizontal) | ||
availableSize = availableSize with { X = float.PositiveInfinity }; | ||
if (ClipVertical) | ||
availableSize = availableSize with { Y = float.PositiveInfinity }; | ||
|
||
return base.MeasureOverride(availableSize); | ||
} | ||
|
||
protected override Vector2 ArrangeOverride(Vector2 finalSize) | ||
{ | ||
foreach (var child in Children) | ||
{ | ||
child.Arrange(UIBox2.FromDimensions(Vector2.Zero, child.DesiredSize)); | ||
} | ||
|
||
return finalSize; | ||
} | ||
} |
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
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
Oops, something went wrong.