react-native-nitro-input 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +87 -0
- package/README.md +132 -2
- package/android/CMakeLists.txt +4 -0
- package/android/gradle.properties +1 -1
- package/android/src/main/cpp/JReflowEngine.cpp +32 -0
- package/android/src/main/cpp/JReflowEngine.hpp +13 -0
- package/android/src/main/cpp/JRollingEngine.cpp +43 -2
- package/android/src/main/cpp/JRollingEngine.hpp +9 -1
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +20 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberFormatPlatform.kt +284 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberView.kt +113 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroTextMeasure.kt +25 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroTextView.kt +140 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputPackage.kt +2 -1
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +69 -10
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroNumberView.kt +522 -130
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroTextView.kt +868 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/ReflowEngine.kt +21 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/RollingEngine.kt +14 -2
- package/cpp/RollingEngine.cpp +102 -8
- package/cpp/RollingEngine.hpp +44 -3
- package/cpp/numberformat/HybridNitroNumberFormat.cpp +498 -0
- package/cpp/numberformat/HybridNitroNumberFormat.hpp +74 -0
- package/cpp/numberformat/HybridNitroNumberFormatFactory.hpp +11 -0
- package/cpp/numberformat/NumberFormatCore.cpp +629 -0
- package/cpp/numberformat/NumberFormatCore.hpp +154 -0
- package/cpp/numberformat/NumberFormatProbe.cpp +354 -0
- package/cpp/numberformat/NumberFormatProbe.hpp +63 -0
- package/ios/HybridNitroInputView.swift +15 -0
- package/ios/HybridNitroNumberFormatPlatform.swift +426 -0
- package/ios/HybridNitroNumberView.swift +101 -1
- package/ios/HybridNitroTextView.swift +134 -0
- package/ios/NitroInputView.swift +79 -19
- package/ios/NitroNumberView.swift +520 -147
- package/ios/NitroTextView.swift +583 -0
- package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
- package/lib/commonjs/nitrogen/generated/shared/json/NitroNumberViewConfig.json +26 -0
- package/lib/commonjs/nitrogen/generated/shared/json/NitroTextViewConfig.json +30 -0
- package/lib/commonjs/src/NitroInput.js +8 -6
- package/lib/commonjs/src/NitroNumber.js +54 -3
- package/lib/commonjs/src/NitroText.js +138 -0
- package/lib/commonjs/src/NitroTime.js +65 -0
- package/lib/commonjs/src/NumberFormat.js +525 -0
- package/lib/commonjs/src/formatProps.js +108 -0
- package/lib/commonjs/src/index.js +8 -1
- package/lib/commonjs/src/specs/NitroText.nitro.js +2 -0
- package/lib/commonjs/src/specs/NumberFormat.nitro.js +2 -0
- package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
- package/lib/module/nitrogen/generated/shared/json/NitroNumberViewConfig.json +26 -0
- package/lib/module/nitrogen/generated/shared/json/NitroTextViewConfig.json +30 -0
- package/lib/module/src/NitroInput.js +8 -6
- package/lib/module/src/NitroNumber.js +54 -3
- package/lib/module/src/NitroText.js +98 -0
- package/lib/module/src/NitroTime.js +29 -0
- package/lib/module/src/NumberFormat.js +521 -0
- package/lib/module/src/formatProps.js +104 -0
- package/lib/module/src/index.js +3 -0
- package/lib/module/src/specs/NitroText.nitro.js +1 -0
- package/lib/module/src/specs/NumberFormat.nitro.js +1 -0
- package/lib/typescript/src/NitroInput.d.ts +22 -0
- package/lib/typescript/src/NitroNumber.d.ts +115 -2
- package/lib/typescript/src/NitroText.d.ts +67 -0
- package/lib/typescript/src/NitroTime.d.ts +19 -0
- package/lib/typescript/src/NumberFormat.d.ts +47 -0
- package/lib/typescript/src/formatProps.d.ts +47 -0
- package/lib/typescript/src/index.d.ts +6 -1
- package/lib/typescript/src/specs/NitroInput.nitro.d.ts +10 -0
- package/lib/typescript/src/specs/NitroNumber.nitro.d.ts +80 -1
- package/lib/typescript/src/specs/NitroText.nitro.d.ts +60 -0
- package/lib/typescript/src/specs/NumberFormat.nitro.d.ts +139 -0
- package/nitro.json +36 -0
- package/nitrogen/generated/android/NitroInput+autolinking.cmake +12 -0
- package/nitrogen/generated/android/NitroInputOnLoad.cpp +62 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +45 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +10 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberFormatPlatformSpec.cpp +118 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberFormatPlatformSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.cpp +297 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.hpp +52 -0
- package/nitrogen/generated/android/c++/JHybridNitroPlatformNumberFormatterSpec.cpp +65 -0
- package/nitrogen/generated/android/c++/JHybridNitroPlatformNumberFormatterSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JHybridNitroTextMeasureSpec.cpp +58 -0
- package/nitrogen/generated/android/c++/JHybridNitroTextMeasureSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.cpp +253 -0
- package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.hpp +104 -0
- package/nitrogen/generated/android/c++/JNitroNumberDirection.hpp +3 -0
- package/nitrogen/generated/android/c++/JNitroNumberShimmerDirection.hpp +61 -0
- package/nitrogen/generated/android/c++/JNitroNumberSignDisplay.hpp +67 -0
- package/nitrogen/generated/android/c++/JNumberFormatCompactDisplay.hpp +58 -0
- package/nitrogen/generated/android/c++/JNumberFormatCurrencyDisplay.hpp +64 -0
- package/nitrogen/generated/android/c++/JNumberFormatCurrencySign.hpp +58 -0
- package/nitrogen/generated/android/c++/JNumberFormatNotation.hpp +64 -0
- package/nitrogen/generated/android/c++/JNumberFormatPlatformOptions.hpp +161 -0
- package/nitrogen/generated/android/c++/JNumberFormatPlatformSymbols.hpp +89 -0
- package/nitrogen/generated/android/c++/JNumberFormatRoundingMode.hpp +79 -0
- package/nitrogen/generated/android/c++/JNumberFormatSignDisplay.hpp +67 -0
- package/nitrogen/generated/android/c++/JNumberFormatStyle.hpp +64 -0
- package/nitrogen/generated/android/c++/JNumberFormatUnitDisplay.hpp +61 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +25 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.cpp +130 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroTextViewStateUpdater.cpp +174 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroTextViewStateUpdater.hpp +54 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberFormatPlatformSpec.kt +60 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberViewSpec.kt +172 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroPlatformNumberFormatterSpec.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroTextMeasureSpec.kt +60 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroTextViewSpec.kt +179 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberDirection.kt +2 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberShimmerDirection.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberSignDisplay.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCompactDisplay.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCurrencyDisplay.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCurrencySign.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatNotation.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatPlatformOptions.kt +136 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatPlatformSymbols.kt +91 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatRoundingMode.kt +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatSignDisplay.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatStyle.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatUnitDisplay.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/views/HybridNitroTextViewManager.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/views/HybridNitroTextViewStateUpdater.kt +23 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.cpp +68 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +184 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +56 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.mm +34 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.swift +36 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +30 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberFormatPlatformSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberFormatPlatformSpecSwift.hpp +122 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.hpp +188 -0
- package/nitrogen/generated/ios/c++/HybridNitroPlatformNumberFormatterSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroPlatformNumberFormatterSpecSwift.hpp +94 -0
- package/nitrogen/generated/ios/c++/HybridNitroTextMeasureSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroTextMeasureSpecSwift.hpp +90 -0
- package/nitrogen/generated/ios/c++/HybridNitroTextViewSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroTextViewSpecSwift.hpp +233 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +30 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroNumberViewComponent.mm +156 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroTextViewComponent.mm +264 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +5 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +55 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberFormatPlatformSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberFormatPlatformSpec_cxx.swift +159 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec.swift +26 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec_cxx.swift +658 -21
- package/nitrogen/generated/ios/swift/HybridNitroPlatformNumberFormatterSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridNitroPlatformNumberFormatterSpec_cxx.swift +155 -0
- package/nitrogen/generated/ios/swift/HybridNitroTextMeasureSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridNitroTextMeasureSpec_cxx.swift +150 -0
- package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec.swift +75 -0
- package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec_cxx.swift +608 -0
- package/nitrogen/generated/ios/swift/NitroNumberDirection.swift +4 -0
- package/nitrogen/generated/ios/swift/NitroNumberShimmerDirection.swift +44 -0
- package/nitrogen/generated/ios/swift/NitroNumberSignDisplay.swift +52 -0
- package/nitrogen/generated/ios/swift/NumberFormatCompactDisplay.swift +40 -0
- package/nitrogen/generated/ios/swift/NumberFormatCurrencyDisplay.swift +48 -0
- package/nitrogen/generated/ios/swift/NumberFormatCurrencySign.swift +40 -0
- package/nitrogen/generated/ios/swift/NumberFormatNotation.swift +48 -0
- package/nitrogen/generated/ios/swift/NumberFormatPlatformOptions.swift +159 -0
- package/nitrogen/generated/ios/swift/NumberFormatPlatformSymbols.swift +69 -0
- package/nitrogen/generated/ios/swift/NumberFormatRoundingMode.swift +68 -0
- package/nitrogen/generated/ios/swift/NumberFormatSignDisplay.swift +52 -0
- package/nitrogen/generated/ios/swift/NumberFormatStyle.swift +48 -0
- package/nitrogen/generated/ios/swift/NumberFormatUnitDisplay.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +10 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +10 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatFactorySpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatFactorySpec.hpp +70 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatPlatformSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatPlatformSpec.hpp +70 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatSpec.hpp +71 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.cpp +52 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.hpp +58 -0
- package/nitrogen/generated/shared/c++/HybridNitroPlatformNumberFormatterSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridNitroPlatformNumberFormatterSpec.hpp +65 -0
- package/nitrogen/generated/shared/c++/HybridNitroTextMeasureSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridNitroTextMeasureSpec.hpp +63 -0
- package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.cpp +62 -0
- package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.hpp +115 -0
- package/nitrogen/generated/shared/c++/NitroNumberDirection.hpp +4 -0
- package/nitrogen/generated/shared/c++/NitroNumberShimmerDirection.hpp +80 -0
- package/nitrogen/generated/shared/c++/NitroNumberSignDisplay.hpp +88 -0
- package/nitrogen/generated/shared/c++/NumberFormatCompactDisplay.hpp +76 -0
- package/nitrogen/generated/shared/c++/NumberFormatCurrencyDisplay.hpp +84 -0
- package/nitrogen/generated/shared/c++/NumberFormatCurrencySign.hpp +76 -0
- package/nitrogen/generated/shared/c++/NumberFormatGrouping.hpp +80 -0
- package/nitrogen/generated/shared/c++/NumberFormatNotation.hpp +84 -0
- package/nitrogen/generated/shared/c++/NumberFormatOptions.hpp +193 -0
- package/nitrogen/generated/shared/c++/NumberFormatPart.hpp +87 -0
- package/nitrogen/generated/shared/c++/NumberFormatPlatformOptions.hpp +176 -0
- package/nitrogen/generated/shared/c++/NumberFormatPlatformSymbols.hpp +115 -0
- package/nitrogen/generated/shared/c++/NumberFormatRoundingMode.hpp +104 -0
- package/nitrogen/generated/shared/c++/NumberFormatRoundingPriority.hpp +80 -0
- package/nitrogen/generated/shared/c++/NumberFormatSignDisplay.hpp +88 -0
- package/nitrogen/generated/shared/c++/NumberFormatStyle.hpp +84 -0
- package/nitrogen/generated/shared/c++/NumberFormatTrailingZeroDisplay.hpp +76 -0
- package/nitrogen/generated/shared/c++/NumberFormatUnitDisplay.hpp +80 -0
- package/nitrogen/generated/shared/c++/ResolvedNumberFormatOptions.hpp +197 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +10 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +15 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.cpp +52 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.hpp +80 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.cpp +74 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.hpp +149 -0
- package/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
- package/nitrogen/generated/shared/json/NitroNumberViewConfig.json +26 -0
- package/nitrogen/generated/shared/json/NitroTextViewConfig.json +30 -0
- package/package.json +2 -2
- package/src/NitroInput.tsx +42 -7
- package/src/NitroNumber.tsx +236 -12
- package/src/NitroText.tsx +166 -0
- package/src/NitroTime.tsx +68 -0
- package/src/NumberFormat.ts +563 -0
- package/src/formatProps.ts +149 -0
- package/src/index.ts +23 -0
- package/src/specs/NitroInput.nitro.ts +10 -0
- package/src/specs/NitroNumber.nitro.ts +82 -1
- package/src/specs/NitroText.nitro.ts +65 -0
- package/src/specs/NumberFormat.nitro.ts +145 -0
|
@@ -44,4 +44,25 @@ class ReflowEngine {
|
|
|
44
44
|
* and returns the number of doubles written, or -1 if [out] is too small.
|
|
45
45
|
*/
|
|
46
46
|
external fun frameInto(out: DoubleArray): Int
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A whole line in one JNI crossing instead of one per character:
|
|
50
|
+
* `setReduceMotion`, `beginText`, an `addGlyph` per character (all in
|
|
51
|
+
* [role], none a placeholder) and `commitText`. Returns [needsFrames].
|
|
52
|
+
*/
|
|
53
|
+
external fun commitLine(
|
|
54
|
+
characters: IntArray, kinds: IntArray, widths: DoubleArray, count: Int,
|
|
55
|
+
role: Int, reduceMotion: Boolean, caret: Int, now: Double,
|
|
56
|
+
): Boolean
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* [tick] and [frameInto] in one crossing: the doubles written (or -1 when
|
|
60
|
+
* [out] is too small, after ticking), with [MORE_FRAMES] set while the
|
|
61
|
+
* engine still needs frames.
|
|
62
|
+
*/
|
|
63
|
+
external fun tickInto(now: Double, out: DoubleArray): Int
|
|
64
|
+
|
|
65
|
+
companion object {
|
|
66
|
+
const val MORE_FRAMES = 1 shl 30
|
|
67
|
+
}
|
|
47
68
|
}
|
|
@@ -23,7 +23,18 @@ class RollingEngine {
|
|
|
23
23
|
external fun setFlash(seconds: Double)
|
|
24
24
|
external fun setPopOnChange(overshoot: Double)
|
|
25
25
|
external fun setReduceMotion(reduceMotion: Boolean)
|
|
26
|
-
|
|
26
|
+
external fun setContinuous(continuous: Boolean)
|
|
27
|
+
/** The highest digit the wheel at integer [power] shows before it wraps (a clock's 5); see `RollingEngine::setDigitMax`. */
|
|
28
|
+
external fun setDigitMax(power: Int, max: Int)
|
|
29
|
+
external fun clearDigitMax()
|
|
30
|
+
/** Places the wheel at [index] wraps after: 10, or `max + 1`. [frameInto] carries it per wheel too. */
|
|
31
|
+
external fun wheelModulus(index: Int): Int
|
|
32
|
+
/** ECMA-402's signDisplay: 0 auto, 1 always, 2 exceptZero, 3 negative, 4 never. */
|
|
33
|
+
external fun setSignDisplay(mode: Int)
|
|
34
|
+
/** True when the sign shown (or last shown) is a plus. */
|
|
35
|
+
external fun signPositive(): Boolean
|
|
36
|
+
external fun signFactor(): Double
|
|
37
|
+
/** A text slot (0 prefix, 1 suffix, 2 grouping, 3 decimal, 4 sign) changed; see `RollingEngine::changeText`. */
|
|
27
38
|
external fun changeText(slot: Int, now: Double)
|
|
28
39
|
/** `setFormat`, the change played; see `RollingEngine::changeFormat`. */
|
|
29
40
|
external fun changeFormat(fractionDigits: Int, minimumIntegerDigits: Int, now: Double)
|
|
@@ -46,7 +57,8 @@ class RollingEngine {
|
|
|
46
57
|
external fun revealMilestoneValue(index: Int): Double
|
|
47
58
|
/**
|
|
48
59
|
* Fills [out] with the render state without allocating:
|
|
49
|
-
* `[signFactor, loadingProgress, revealScale, wheelCount, (position, width, linear, blankZero, fromGlyph, toGlyph, blend, fromAbove, flash, flashUp)…]
|
|
60
|
+
* `[signFactor, loadingProgress, revealScale, wheelCount, (position, width, linear, blankZero, fromGlyph, toGlyph, blend, fromAbove, flash, flashUp, focus, grow, blurOut, progress, modulus)…]`,
|
|
61
|
+
* then each text slot's swap and the decimal columns.
|
|
50
62
|
* Returns the number of doubles written, or -1 if [out] is too small.
|
|
51
63
|
*/
|
|
52
64
|
external fun frameInto(out: DoubleArray): Int
|
package/cpp/RollingEngine.cpp
CHANGED
|
@@ -116,6 +116,41 @@ double RollingEngine::wrap(double x) {
|
|
|
116
116
|
return r < 0 ? r + 10.0 : r;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
double RollingEngine::wrapTo(double x, int modulus) {
|
|
120
|
+
const double m = static_cast<double>(modulus);
|
|
121
|
+
double r = std::fmod(x, m);
|
|
122
|
+
return r < 0 ? r + m : r;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
int RollingEngine::modulusAtPower(int power) const {
|
|
126
|
+
const int integerPower = power - fractionDigits_;
|
|
127
|
+
return integerPower >= 0 && integerPower < 20 ? modulus_[integerPower] : 10;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
int RollingEngine::wheelModulus(int index) const {
|
|
131
|
+
return modulusAtPower(index - trailingPad_);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
bool RollingEngine::signShown(double value, uint64_t magnitude) const {
|
|
135
|
+
switch (signDisplay_) {
|
|
136
|
+
case 1:
|
|
137
|
+
return true;
|
|
138
|
+
case 2:
|
|
139
|
+
return magnitude > 0;
|
|
140
|
+
case 4:
|
|
141
|
+
return false;
|
|
142
|
+
default:
|
|
143
|
+
// auto and negative: a negative that does not round to zero.
|
|
144
|
+
return value < 0 && magnitude > 0;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
void RollingEngine::noteSign(const Target& target) {
|
|
149
|
+
if (target.negative) {
|
|
150
|
+
signPositive_ = target.positive;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
119
154
|
RollingEngine::Target RollingEngine::makeTarget(double value) const {
|
|
120
155
|
double scaled = std::round(std::fabs(value) * static_cast<double>(kPow10[fractionDigits_]));
|
|
121
156
|
if (!std::isfinite(scaled)) {
|
|
@@ -124,7 +159,9 @@ RollingEngine::Target RollingEngine::makeTarget(double value) const {
|
|
|
124
159
|
uint64_t magnitude = static_cast<uint64_t>(std::min(scaled, kMaxMagnitude));
|
|
125
160
|
uint64_t integerPart = magnitude / kPow10[fractionDigits_];
|
|
126
161
|
int intDigits = std::max(minimumIntegerDigits_, digitCount(integerPart));
|
|
127
|
-
|
|
162
|
+
Target target{magnitude, signShown(value, magnitude), std::min(kMaxPowerCount, intDigits + fractionDigits_)};
|
|
163
|
+
target.positive = !(value < 0 && magnitude > 0);
|
|
164
|
+
return target;
|
|
128
165
|
}
|
|
129
166
|
|
|
130
167
|
void RollingEngine::settle(const Target& target) {
|
|
@@ -149,7 +186,9 @@ void RollingEngine::setFormat(int fractionDigits, int minimumIntegerDigits) {
|
|
|
149
186
|
if (reveal_.holding) {
|
|
150
187
|
holdReveal(targetValue_);
|
|
151
188
|
} else {
|
|
152
|
-
|
|
189
|
+
const Target target = makeTarget(targetValue_);
|
|
190
|
+
noteSign(target);
|
|
191
|
+
snap(target);
|
|
153
192
|
}
|
|
154
193
|
}
|
|
155
194
|
}
|
|
@@ -222,6 +261,27 @@ void RollingEngine::setReduceMotion(bool reduceMotion) {
|
|
|
222
261
|
reduceMotion_ = reduceMotion;
|
|
223
262
|
}
|
|
224
263
|
|
|
264
|
+
void RollingEngine::setContinuous(bool continuous) {
|
|
265
|
+
continuous_ = continuous;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
void RollingEngine::setDigitMax(int power, int max) {
|
|
269
|
+
if (power < 0 || power >= 20) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
modulus_[power] = std::max(1, std::min(9, max)) + 1;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
void RollingEngine::clearDigitMax() {
|
|
276
|
+
for (int& m : modulus_) {
|
|
277
|
+
m = 10;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
void RollingEngine::setSignDisplay(int mode) {
|
|
282
|
+
signDisplay_ = std::max(0, std::min(4, mode));
|
|
283
|
+
}
|
|
284
|
+
|
|
225
285
|
// MARK: - Commands
|
|
226
286
|
|
|
227
287
|
void RollingEngine::endTransition() {
|
|
@@ -268,10 +328,12 @@ void RollingEngine::setValue(double value) {
|
|
|
268
328
|
wheels_.push_back(Wheel{digit + carry, 1.0, false, false});
|
|
269
329
|
}
|
|
270
330
|
}
|
|
271
|
-
signFactor_ = value < 0 ? std::min(1.0, scaled) : 0.0;
|
|
272
331
|
Target target = makeTarget(value);
|
|
273
332
|
target.powerCount = static_cast<int>(wheels_.size());
|
|
274
|
-
|
|
333
|
+
// Between two values the sign fades in with the first hundredth of a negative.
|
|
334
|
+
target.negative = signDisplay_ == 0 || signDisplay_ == 3 ? value < 0 : signShown(value, static_cast<uint64_t>(std::round(scaled)));
|
|
335
|
+
signFactor_ = target.negative ? (value < 0 && (signDisplay_ == 0 || signDisplay_ == 3) ? std::min(1.0, scaled) : 1.0) : 0.0;
|
|
336
|
+
noteSign(target);
|
|
275
337
|
settle(target);
|
|
276
338
|
}
|
|
277
339
|
|
|
@@ -280,6 +342,7 @@ void RollingEngine::animateTo(double value, double now) {
|
|
|
280
342
|
const double previous = targetValue_;
|
|
281
343
|
targetValue_ = value;
|
|
282
344
|
const Target target = makeTarget(value);
|
|
345
|
+
noteSign(target);
|
|
283
346
|
bool increasing;
|
|
284
347
|
switch (direction_) {
|
|
285
348
|
case 1:
|
|
@@ -406,6 +469,19 @@ void RollingEngine::planRoll(Transition& next, const Target& target, bool increa
|
|
|
406
469
|
const int currentCount = static_cast<int>(wheels_.size());
|
|
407
470
|
// Below `pad`: decimal columns the format dropped (`changeFormat`).
|
|
408
471
|
const int pad = trailingPad_;
|
|
472
|
+
// `continuous`: the wheels below the highest one that changes turn a full
|
|
473
|
+
// turn too. A wheel that is new, or leaving, counts as a change.
|
|
474
|
+
int highestChange = -1;
|
|
475
|
+
if (continuous_) {
|
|
476
|
+
for (int power = count - 1; power >= 0; power--) {
|
|
477
|
+
const bool inTarget = power >= pad && power - pad < target.powerCount;
|
|
478
|
+
const int shown = power < currentCount ? shownGlyph(wheels_[static_cast<size_t>(power)]) : -1;
|
|
479
|
+
if (!inTarget || shown != target.digit(power - pad)) {
|
|
480
|
+
highestChange = power;
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
409
485
|
for (int power = 0; power < count; power++) {
|
|
410
486
|
const Wheel current = power < currentCount ? wheels_[static_cast<size_t>(power)] : Wheel{-1.0, 0.0, true, false};
|
|
411
487
|
Wheel from = current;
|
|
@@ -422,19 +498,26 @@ void RollingEngine::planRoll(Transition& next, const Target& target, bool increa
|
|
|
422
498
|
// column `changeFormat` opened (blank and closed, below the mandatory ones).
|
|
423
499
|
const bool opening = from.linear && current.width < 1.0;
|
|
424
500
|
const bool isEdge = opening || (power - pad >= mandatory && (power >= currentCount || current.width < 1.0 || from.linear || current.blankZero));
|
|
501
|
+
const int modulus = modulusAtPower(power - pad);
|
|
425
502
|
if (isEdge) {
|
|
426
503
|
// Appearing (or still appearing) wheel: linear strip blank → digit.
|
|
427
504
|
if (!from.linear) {
|
|
428
|
-
from.position =
|
|
505
|
+
from.position = wrapTo(from.position, modulus);
|
|
429
506
|
}
|
|
430
507
|
from.linear = true;
|
|
431
508
|
to = Wheel{digit, 1.0, true, current.blankZero};
|
|
432
509
|
} else {
|
|
433
|
-
// Interior wheel: shortest roll in the direction of the change
|
|
434
|
-
|
|
510
|
+
// Interior wheel: shortest roll in the direction of the change, or
|
|
511
|
+
// with `shortest` the shorter way round for this wheel alone (8 → 2
|
|
512
|
+
// rolls back through 5), a tie (five apart) going with the change.
|
|
513
|
+
const double base = wrapTo(from.position, modulus);
|
|
435
514
|
from.position = base;
|
|
436
515
|
from.linear = false;
|
|
437
|
-
const double
|
|
516
|
+
const double up = wrapTo(digit - base, modulus);
|
|
517
|
+
const double down = wrapTo(base - digit, modulus);
|
|
518
|
+
double delta = increasing ? up : -down;
|
|
519
|
+
if (direction_ == 3 && up != down) delta = up < down ? up : -down;
|
|
520
|
+
if (delta == 0 && power < highestChange) delta = increasing ? modulus : -modulus;
|
|
438
521
|
to = Wheel{base + delta, 1.0, false, false};
|
|
439
522
|
}
|
|
440
523
|
next.finals.push_back(Wheel{digit, 1.0, false, false});
|
|
@@ -647,6 +730,7 @@ void RollingEngine::holdReveal(double value) {
|
|
|
647
730
|
reveal_.milestoneTimes.clear();
|
|
648
731
|
reveal_.milestoneMagnitudes.clear();
|
|
649
732
|
reveal_.target = makeTarget(value);
|
|
733
|
+
noteSign(reveal_.target);
|
|
650
734
|
reveal_.start = 0;
|
|
651
735
|
applyReveal(0);
|
|
652
736
|
settle(reveal_.target);
|
|
@@ -656,6 +740,7 @@ void RollingEngine::reveal(double value, double now) {
|
|
|
656
740
|
endTransition();
|
|
657
741
|
targetValue_ = value;
|
|
658
742
|
const Target target = makeTarget(value);
|
|
743
|
+
noteSign(target);
|
|
659
744
|
if (revealDuration_ <= 0 || reduceMotion_) {
|
|
660
745
|
snap(target);
|
|
661
746
|
return;
|
|
@@ -897,6 +982,7 @@ void RollingEngine::apply(double elapsed) {
|
|
|
897
982
|
w.blend = 1;
|
|
898
983
|
w.focus = 1;
|
|
899
984
|
w.grow = 1;
|
|
985
|
+
w.progress = 1;
|
|
900
986
|
} else if (tr.style == 2) {
|
|
901
987
|
// Scramble: a different digit every step until the wheel locks.
|
|
902
988
|
const int from = static_cast<int>(wt.from.fromGlyph);
|
|
@@ -922,6 +1008,7 @@ void RollingEngine::apply(double elapsed) {
|
|
|
922
1008
|
w.blend = 1;
|
|
923
1009
|
w.focus = 1;
|
|
924
1010
|
w.grow = 1;
|
|
1011
|
+
w.progress = clamp01(t);
|
|
925
1012
|
} else if (tr.numeric) {
|
|
926
1013
|
// Numeric: the glyphs swap in place; the position is the digit
|
|
927
1014
|
// arriving and the three clocks say how far the swap is (see the header).
|
|
@@ -943,6 +1030,8 @@ void RollingEngine::apply(double elapsed) {
|
|
|
943
1030
|
w.focus = damped(local, kNumericFocusZeta, kNumericFocusSettle * d);
|
|
944
1031
|
w.blurOut = damped(local, 1.0, kNumericBlurOutSettle * d);
|
|
945
1032
|
}
|
|
1033
|
+
// The grow clock is critically damped, so a column never rings.
|
|
1034
|
+
w.progress = clamp01(w.grow);
|
|
946
1035
|
} else {
|
|
947
1036
|
w.position = wt.from.position + (wt.to.position - wt.from.position) * t;
|
|
948
1037
|
w.fromGlyph = -1;
|
|
@@ -950,6 +1039,7 @@ void RollingEngine::apply(double elapsed) {
|
|
|
950
1039
|
w.blend = 1;
|
|
951
1040
|
w.focus = 1;
|
|
952
1041
|
w.grow = 1;
|
|
1042
|
+
w.progress = clamp01(t);
|
|
953
1043
|
}
|
|
954
1044
|
}
|
|
955
1045
|
const double signRaw = tr.duration > 0 ? clamp01(elapsed / tr.duration) : 1.0;
|
|
@@ -1184,6 +1274,10 @@ void RollingEngine::reset() {
|
|
|
1184
1274
|
transitionStyle_ = 0;
|
|
1185
1275
|
flashSeconds_ = 0;
|
|
1186
1276
|
popOnChange_ = 0;
|
|
1277
|
+
continuous_ = false;
|
|
1278
|
+
signDisplay_ = 0;
|
|
1279
|
+
signPositive_ = false;
|
|
1280
|
+
clearDigitMax();
|
|
1187
1281
|
flashes_.clear();
|
|
1188
1282
|
popStart_ = -1;
|
|
1189
1283
|
popScale_ = 1;
|
package/cpp/RollingEngine.hpp
CHANGED
|
@@ -64,6 +64,12 @@ public:
|
|
|
64
64
|
/// or the down colour by this much. `flashUp`: the value grew.
|
|
65
65
|
double flash = 0;
|
|
66
66
|
bool flashUp = true;
|
|
67
|
+
/// How far this wheel is through its change, 0 → 1: the roll's easing, or
|
|
68
|
+
/// a swap's `grow` clock. 1 while settled or not part of the change. A
|
|
69
|
+
/// renderer that sizes a column by its digit (proportional figures) eases
|
|
70
|
+
/// the width from where it was to the target digit's on this, rather than
|
|
71
|
+
/// following the digits the wheel passes (which made the number pulse).
|
|
72
|
+
double progress = 1;
|
|
67
73
|
};
|
|
68
74
|
|
|
69
75
|
// The numeric transition as the renderers draw it, in line heights, so all
|
|
@@ -111,7 +117,8 @@ public:
|
|
|
111
117
|
static constexpr double kScrambleStepSeconds = 0.045;
|
|
112
118
|
|
|
113
119
|
// Easing: 0 linear, 1 easeIn, 2 easeOut, 3 easeInOut, 4 spring.
|
|
114
|
-
// Direction: 0 auto (sign of the change), 1 up, 2 down
|
|
120
|
+
// Direction: 0 auto (sign of the change), 1 up, 2 down, 3 shortest (each
|
|
121
|
+
// interior wheel its own shorter way round; a tie goes with the change).
|
|
115
122
|
// Transition: 0 roll (the odometer), 1 numeric (glyphs swap in place),
|
|
116
123
|
// 2 scramble.
|
|
117
124
|
|
|
@@ -160,6 +167,26 @@ public:
|
|
|
160
167
|
void setPopOnChange(double overshoot);
|
|
161
168
|
/// Reduce Motion / "remove animations": rolls snap and the shimmer freezes.
|
|
162
169
|
void setReduceMotion(bool reduceMotion);
|
|
170
|
+
/// A roll turns the wheels below the highest one that changes a full turn
|
|
171
|
+
/// too, in the direction of the change, so the figure seems to pass
|
|
172
|
+
/// through every value between (NumberFlow's `continuous`). Rolls only.
|
|
173
|
+
void setContinuous(bool continuous);
|
|
174
|
+
/// The highest digit the wheel at `power` (0 = the least significant
|
|
175
|
+
/// integer digit) shows before it wraps to 0: 5 for the tens of minutes on
|
|
176
|
+
/// a clock, so 59 → 00 turns the tens one step, 5 → 0. 9 (the default)
|
|
177
|
+
/// clears it. A renderer draws that wheel from a strip 0…max then 0 and
|
|
178
|
+
/// wraps its position modulo `wheelModulus`.
|
|
179
|
+
void setDigitMax(int power, int max);
|
|
180
|
+
void clearDigitMax();
|
|
181
|
+
/// Places each wheel wraps after (10, or max + 1).
|
|
182
|
+
int wheelModulus(int index) const;
|
|
183
|
+
/// Which values carry a sign (ECMA-402's signDisplay): 0 auto (negatives,
|
|
184
|
+
/// -0 included), 1 always, 2 exceptZero (not on a value that rounds to
|
|
185
|
+
/// zero), 3 negative (negatives that do not round to zero), 4 never.
|
|
186
|
+
/// `signFactor` is the sign's presence; `signPositive` which sign it is.
|
|
187
|
+
void setSignDisplay(int mode);
|
|
188
|
+
/// True when the sign shown (or last shown) is a plus.
|
|
189
|
+
bool signPositive() const { return signPositive_; }
|
|
163
190
|
|
|
164
191
|
// MARK: Commands
|
|
165
192
|
|
|
@@ -249,8 +276,8 @@ public:
|
|
|
249
276
|
// engine runs each slot's clocks so every renderer agrees; a renderer keeps
|
|
250
277
|
// the text that is leaving.
|
|
251
278
|
|
|
252
|
-
enum TextSlot : int { PrefixText = 0, SuffixText = 1, GroupingText = 2, DecimalText = 3 };
|
|
253
|
-
static constexpr int kTextSlots =
|
|
279
|
+
enum TextSlot : int { PrefixText = 0, SuffixText = 1, GroupingText = 2, DecimalText = 3, SignText = 4 };
|
|
280
|
+
static constexpr int kTextSlots = 5;
|
|
254
281
|
struct TextChange {
|
|
255
282
|
/// Opacity of the arriving text and of the leaving one's complement, and
|
|
256
283
|
/// how far the slot's width has gone from the old text's to the new one's.
|
|
@@ -299,9 +326,12 @@ public:
|
|
|
299
326
|
private:
|
|
300
327
|
struct Target {
|
|
301
328
|
uint64_t magnitude; // |value| * 10^fractionDigits, rounded
|
|
329
|
+
/// Carries a sign (see `setSignDisplay`); named for the default, where only negatives do.
|
|
302
330
|
bool negative;
|
|
303
331
|
int powerCount;
|
|
304
332
|
int digit(int power) const;
|
|
333
|
+
/// The sign it carries is a plus.
|
|
334
|
+
bool positive = false;
|
|
305
335
|
};
|
|
306
336
|
struct WheelTransition {
|
|
307
337
|
Wheel from;
|
|
@@ -402,6 +432,7 @@ private:
|
|
|
402
432
|
/// has settled (within 2 %) at t == `settle`; 0 at t <= 0.
|
|
403
433
|
static double damped(double t, double zeta, double settle);
|
|
404
434
|
static double wrap(double x);
|
|
435
|
+
static double wrapTo(double x, int modulus);
|
|
405
436
|
static int digitCount(uint64_t n);
|
|
406
437
|
|
|
407
438
|
// configuration
|
|
@@ -419,6 +450,16 @@ private:
|
|
|
419
450
|
double flashSeconds_ = 0;
|
|
420
451
|
double popOnChange_ = 0;
|
|
421
452
|
bool reduceMotion_ = false;
|
|
453
|
+
bool continuous_ = false;
|
|
454
|
+
int signDisplay_ = 0;
|
|
455
|
+
bool signPositive_ = false;
|
|
456
|
+
/// Per integer power: the places its wheel wraps after (10 unless `setDigitMax`).
|
|
457
|
+
int modulus_[20] = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10};
|
|
458
|
+
int modulusAtPower(int power) const;
|
|
459
|
+
/// Whether `value` carries a sign under `signDisplay_`, and which.
|
|
460
|
+
bool signShown(double value, uint64_t magnitude) const;
|
|
461
|
+
/// Keeps the sign's glyph for a target that shows one (one that shows none keeps the last).
|
|
462
|
+
void noteSign(const Target& target);
|
|
422
463
|
double revealDuration_ = 2.2;
|
|
423
464
|
double revealBounce_ = 0.12;
|
|
424
465
|
int revealStyle_ = 0;
|