-
Notifications
You must be signed in to change notification settings - Fork 134
[RangeSelector] Add support for vertical orientation #756
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
Merged
Arlodotexe
merged 24 commits into
CommunityToolkit:main
from
Illustar0:feat/allow-vertical-rangeselector
Feb 10, 2026
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
8713493
feat: add vertical orientation support for RangeSelector control
Illustar0 b7d3028
fix: add missing sample
Illustar0 c701fee
fix: correct vertical normalized position calculation logic
Illustar0 dbdd1ea
refactor: simplify orientation check using ternary expression
Illustar0 db727ca
fix: prevent multiple subscriptions to Loaded event
Illustar0 fbd0f46
feat: implement vertical tooltip placement for RangeSelector control
Illustar0 a853889
fix: use DesiredSize.Height for tooltip measurement
Illustar0 a8b61fc
fix: prevent tooltip from showing when vertical placement is not set
Illustar0 b540174
fix: correct keyboard navigation for RTL contexts
Illustar0 3c9e8fe
feat: add orientation toggle and fix vertical mode layout issues
Illustar0 05c3b66
refactor: remove separate vertical RangeSelector sample
Illustar0 282b30f
fix: set vertical RangeSelector sample Minimum to 0
Illustar0 9074b65
refactor: introduce UVPoint helper to eliminate orientation-dependent…
Illustar0 b403a0f
feat: add UVCoord helper struct for orientation-aware coordinates
Illustar0 3983082
refactor: migrate from UVPoint to UVCoord for coordinate handling
Illustar0 391838e
refactor: remove deprecated UVPoint helper
Illustar0 30d83e1
docs: add comments explaining vertical drag logic
Illustar0 8036bca
fix: replace null suppression with null checks in DragWidth
Illustar0 54ddd70
Ran xaml styler
Arlodotexe fbd8884
Merge branch 'main' into feat/allow-vertical-rangeselector
Arlodotexe 3b334d3
feat: implement IEquatable for UVCoord
Illustar0 6df2913
Fixed nullability error on Equals method
Arlodotexe 7248ea7
Added missing XMLDoc comments
Arlodotexe fbae157
Fixed "'HashCode' does not exist" error on uap
Arlodotexe 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
152 changes: 152 additions & 0 deletions
152
components/RangeSelector/src/RangeSelector.Helpers.UVCoord.cs
This file contains hidden or 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,152 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| namespace CommunityToolkit.WinUI.Controls; | ||
|
|
||
| /// <summary> | ||
| /// A struct representing a coordinate in UV adjusted space. | ||
| /// </summary> | ||
| [DebuggerDisplay("({U}u,{V}v)")] | ||
| public struct UVCoord: IEquatable<UVCoord> | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="UVCoord"/> struct. | ||
| /// </summary> | ||
| public UVCoord(Orientation orientation) | ||
| { | ||
| Orientation = orientation; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="UVCoord"/> struct. | ||
| /// </summary> | ||
| public UVCoord(double x, double y, Orientation orientation) | ||
| { | ||
| X = x; | ||
| Y = y; | ||
| Orientation = orientation; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="UVCoord"/> struct. | ||
| /// </summary> | ||
| public UVCoord(Point point, Orientation orientation) : this(point.X, point.Y, orientation) | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="UVCoord"/> struct. | ||
| /// </summary> | ||
| public UVCoord(Size size, Orientation orientation) : this(size.Width, size.Height, orientation) | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the X coordinate. | ||
| /// </summary> | ||
| public double X { readonly get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the Y coordinate. | ||
| /// </summary> | ||
| public double Y { readonly get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the orientation for translation between the XY and UV coordinate systems. | ||
| /// </summary> | ||
| public Orientation Orientation { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the U coordinate. | ||
| /// </summary> | ||
| public double U | ||
| { | ||
| readonly get => Orientation is Orientation.Horizontal ? X : Y; | ||
| set | ||
| { | ||
| if (Orientation is Orientation.Horizontal) | ||
| { | ||
| X = value; | ||
| } | ||
| else | ||
| { | ||
| Y = value; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the V coordinate. | ||
| /// </summary> | ||
| public double V | ||
| { | ||
| readonly get => Orientation is Orientation.Vertical ? X : Y; | ||
| set | ||
| { | ||
| if (Orientation is Orientation.Vertical) | ||
| { | ||
| X = value; | ||
| } | ||
| else | ||
| { | ||
| Y = value; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Implicitly casts a <see cref="UVCoord"/> to a <see cref="Point"/>. | ||
| /// </summary> | ||
| public static implicit operator Point(UVCoord uv) => new(uv.X, uv.Y); | ||
|
|
||
| /// <summary> | ||
| /// Implicitly casts a <see cref="UVCoord"/> to a <see cref="Size"/>. | ||
| /// </summary> | ||
| public static implicit operator Size(UVCoord uv) => new(uv.X, uv.Y); | ||
|
|
||
| /// <inheritdoc/> | ||
| public static UVCoord operator +(UVCoord addend1, UVCoord addend2) | ||
| { | ||
| if (addend1.Orientation != addend2.Orientation) | ||
| { | ||
| throw new InvalidOperationException($"Cannot add {nameof(UVCoord)} with mismatched {nameof(Orientation)}."); | ||
| } | ||
|
|
||
| var xSum = addend1.X + addend2.X; | ||
| var ySum = addend1.Y + addend2.Y; | ||
| var orientation = addend1.Orientation; | ||
| return new UVCoord(xSum, ySum, orientation); | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| public static bool operator ==(UVCoord coord1, UVCoord coord2) | ||
| { | ||
| return coord1.U == coord2.U && coord1.V == coord2.V; | ||
| } | ||
|
|
||
|
|
||
| /// <inheritdoc/> | ||
| public static bool operator !=(UVCoord measure1, UVCoord measure2) | ||
| { | ||
| return !(measure1 == measure2); | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override bool Equals(object? obj) | ||
| { | ||
| return obj is UVCoord other && Equals(other); | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| public bool Equals(UVCoord other) | ||
| { | ||
| return this == other; | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override int GetHashCode() | ||
| { | ||
| return HashCode.Combine(U, V); | ||
| } | ||
| } |
This file contains hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.