-
-
Notifications
You must be signed in to change notification settings - Fork 977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Draft] Remove depth from Stride UI #2605
Draft
MechWarrior99
wants to merge
11
commits into
stride3d:master
Choose a base branch
from
MechWarrior99:ui-depth-removal
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1d81431
Remove depth from Stride UI
MechWarrior99 2231c7c
Remove Front and Back fields from Thickness PropertyTemplate
MechWarrior99 9b8f868
Change UI render Z size to 1 from 0
MechWarrior99 bb9fc7c
Change UI render Z size to 1 from 0 in ElementRenderer
MechWarrior99 3987e1c
Fix depth not offset not rendering on UIElements
MechWarrior99 212e65c
Fix UI depth offset apply incorrectly
MechWarrior99 5dc1a84
Remove un-needed cast method from Size2F
MechWarrior99 1bf0742
Add comments to new methods in Size2F
MechWarrior99 bb4788a
Fix UI border rendering
MechWarrior99 5c5c4dc
Change Canvas RelativeSize to use Size2F
MechWarrior99 c066dd5
Fix compile errors in first batch of UI tests
MechWarrior99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
// THE SOFTWARE. | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Stride.Core.Mathematics | ||
|
@@ -54,6 +55,16 @@ public Size2F(float width, float height) | |
Width = width; | ||
Height = height; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Size2F"/> struct. | ||
/// </summary> | ||
/// <param name="uniform">The width and height of the <see cref="Size2F"/>.</param> | ||
public Size2F(float uniform) | ||
{ | ||
Width = uniform; | ||
Height = uniform; | ||
} | ||
|
||
/// <summary> | ||
/// Width. | ||
|
@@ -67,6 +78,35 @@ public Size2F(float width, float height) | |
[DataMember(1)] | ||
public float Height; | ||
|
||
/// <summary> | ||
/// Gets or sets the component at the specified index. | ||
/// </summary> | ||
/// <value>The value of the Width or Height component, depending on the index.</value> | ||
/// <param name="index">The index of the component to access. Use 0 for the Width component and 1 for the Height component.</param> | ||
/// <returns>The value of the component at the specified index.</returns> | ||
/// <exception cref="System.ArgumentOutOfRangeException">Thrown when the <paramref name="index"/> is out of the range [0, 1].</exception> | ||
public float this[int index] | ||
{ | ||
get | ||
{ | ||
switch (index) | ||
{ | ||
case 0: return Width; | ||
case 1: return Height; | ||
default: throw new ArgumentOutOfRangeException(nameof(index), "Indices for Size2F run from 0 to 1, inclusive."); | ||
} | ||
} | ||
set | ||
{ | ||
switch (index) | ||
{ | ||
case 0: Width = value; break; | ||
case 1: Height = value; break; | ||
default: throw new ArgumentOutOfRangeException(nameof(index), "Indices for Size2F run from 0 to 1, inclusive."); | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Determines whether the specified <see cref="object"/> is equal to this instance. | ||
/// </summary> | ||
|
@@ -122,6 +162,124 @@ public override int GetHashCode() | |
return !left.Equals(right); | ||
} | ||
|
||
/// <summary> | ||
/// Implements the operator <c>/</c>, component wise. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Description of a method shouldn't explain what they implement but what they do. For instance: "Divides the first size by the second, component-wise". |
||
/// </summary> | ||
/// <param name="left">The left.</param> | ||
/// <param name="right">The right.</param> | ||
/// <returns> | ||
/// The result of the operator. | ||
/// </returns> | ||
public static Size2F operator /(Size2F left, Size2F right) | ||
{ | ||
return new Size2F(left.Width / right.Width, left.Height / right.Height); | ||
} | ||
|
||
/// <summary> | ||
/// Implements the operator <c>/</c>, component wise. | ||
/// </summary> | ||
/// <param name="left">The left.</param> | ||
/// <param name="right">The right.</param> | ||
/// <returns> | ||
/// The result of the operator. | ||
/// </returns> | ||
public static Size2F operator /(Size2F left, float right) | ||
{ | ||
return new Size2F(left.Width / right, left.Height / right); | ||
} | ||
|
||
/// <summary> | ||
/// Implements the operator <c>*</c>, component wise. | ||
/// </summary> | ||
/// <param name="left">The left.</param> | ||
/// <param name="right">The right.</param> | ||
/// <returns> | ||
/// The result of the operator. | ||
/// </returns> | ||
public static Size2F operator *(Size2F left, Size2F right) | ||
{ | ||
return new Size2F(left.Width * right.Width, left.Height * right.Height); | ||
} | ||
|
||
/// <summary> | ||
/// Implements the operator <c>*</c>, component wise. | ||
/// </summary> | ||
/// <param name="left">The left.</param> | ||
/// <param name="right">The right.</param> | ||
/// <returns> | ||
/// The result of the operator. | ||
/// </returns> | ||
public static Size2F operator *(Size2F left, float right) | ||
{ | ||
return new Size2F(left.Width * right, left.Height * right); | ||
} | ||
|
||
/// <summary> | ||
/// Implements the operator <c>+</c>, component wise. | ||
/// </summary> | ||
/// <param name="left">The left.</param> | ||
/// <param name="right">The right.</param> | ||
/// <returns> | ||
/// The result of the operator. | ||
/// </returns> | ||
public static Size2F operator +(Size2F left, Size2F right) | ||
{ | ||
return new Size2F(left.Width + right.Width, left.Height + right.Height); | ||
} | ||
|
||
/// <summary> | ||
/// Implements the operator <c>-</c>, component wise. | ||
/// </summary> | ||
/// <param name="left">The left.</param> | ||
/// <param name="right">The right.</param> | ||
/// <returns> | ||
/// The result of the operator. | ||
/// </returns> | ||
public static Size2F operator -(Size2F left, Size2F right) | ||
{ | ||
return new Size2F(left.Width + right.Width, left.Height + right.Height); | ||
} | ||
|
||
/// <summary> | ||
/// Returns a size containing the largest components of the specified sizes. | ||
/// </summary> | ||
/// <param name="left">The first source size.</param> | ||
/// <param name="right">The second source size.</param> | ||
/// <returns>A size containing the largest components of the source size.</returns> | ||
public static Size2F Max(Size2F left, Size2F right) | ||
{ | ||
return new Size2F(Math.Max(left.Width, right.Width), Math.Max(left.Height, right.Height)); | ||
} | ||
|
||
/// <summary> | ||
/// Returns a size containing the smallest components of the specified sizes. | ||
/// </summary> | ||
/// <param name="left">The first source size.</param> | ||
/// <param name="right">The second source size.</param> | ||
/// <returns>A size containing the smallest components of the source size.</returns> | ||
public static Size2F Min(Size2F left, Size2F right) | ||
{ | ||
return new Size2F(Math.Min(left.Width, right.Width), Math.Min(left.Height, right.Height)); | ||
} | ||
|
||
/// <summary> | ||
/// Casts from <see cref="Vector2"/> to <see cref="Size2F"/>. | ||
/// </summary> | ||
/// <param name="vector">Value to cast.</param> | ||
public static explicit operator Size2F(Vector2 vector) | ||
{ | ||
return Unsafe.BitCast<Vector2, Size2F>(vector); | ||
} | ||
|
||
/// <summary> | ||
/// Casts from <see cref="Size2F"/> to <see cref="Vector2"/>. | ||
/// </summary> | ||
/// <param name="size">Value to cast.</param> | ||
public static explicit operator Vector2(Size2F size) | ||
{ | ||
return Unsafe.BitCast<Size2F, Vector2>(size); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override string ToString() | ||
{ | ||
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the switch pattern here. It has a nicer syntax.