Skip to content
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

Improved Settings UI, consistent visibility and usability of SymbolBrowser, some refactoring #194

Merged
merged 3 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Core/Resource/CollectionUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Core.Resource
{
public static class CollectionUtils
{
/// <summary>
/// A simple method to get a new index by "jumping" from a startIndex
/// When the jump would make the index exceed the valid range of the collection,
/// it will return an index that "wraps" around the other side
/// </summary>
/// <param name="startIndex">Index to jump from</param>
/// <param name="jumpAmount">How far to jump (usually 1 or -1 for forward and backward respectively)</param>
/// <param name="collection">The collection whose Count (Length for arrays) will be referenced</param>
/// <param name="realWrap">If false, this will default to making every wrap result in the first or last index of the collection.
/// If true, it will be a "real" wrap, where if you jump in excess of X, you will wrap to the index X distance from the other side. </param>
/// <returns></returns>
public static int WrapIndex(int startIndex, int jumpAmount, System.Collections.IList collection, bool realWrap = false)
{
int index = startIndex + jumpAmount;
index %= collection.Count;

bool newIndexIsNegative = index < 0;
int negativeWrapIndex = realWrap ? collection.Count + index : collection.Count - 1;

return newIndexIsNegative ? negativeWrapIndex : index;
}
}
}
1 change: 0 additions & 1 deletion Core/Resource/MathUtils.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Numerics;
using T3.Core.Animation;
using T3.Core.Operator;

namespace T3.Core
{
Expand Down
Loading