@opentui/core 0.7.0 → 0.8.0
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/NativeScene.d.ts +9 -3
- package/Renderable.d.ts +20 -2
- package/animation/Timeline.d.ts +9 -0
- package/buffer.d.ts +6 -2
- package/{chunk-bun-zevtbcf6.js → chunk-bun-6kxdhkdc.js} +407 -259
- package/chunk-bun-6kxdhkdc.js.map +70 -0
- package/{chunk-bun-qkpm62w1.js → chunk-bun-x6cz4jyg.js} +263 -21
- package/chunk-bun-x6cz4jyg.js.map +35 -0
- package/{chunk-node-7bcmqh18.js → chunk-node-q5ccgbk5.js} +407 -259
- package/{chunk-bun-zevtbcf6.js.map → chunk-node-q5ccgbk5.js.map} +15 -15
- package/{chunk-node-mzgnr3sw.js → chunk-node-y0w0hq5m.js} +263 -21
- package/chunk-node-y0w0hq5m.js.map +34 -0
- package/edit-buffer.d.ts +4 -0
- package/index.bun.js +788 -473
- package/index.bun.js.map +11 -10
- package/index.d.ts +1 -1
- package/index.node.js +788 -473
- package/index.node.js.map +11 -9
- package/lib/extmarks.d.ts +3 -1
- package/lib/stdin-parser-native.d.ts +2 -0
- package/lib/stdin-parser.d.ts +2 -0
- package/lib/terminal-capability-detection.d.ts +6 -1
- package/native-abi.generated.d.ts +307 -3
- package/package.json +9 -9
- package/renderables/FrameBuffer.d.ts +1 -0
- package/renderables/ScrollBar.d.ts +6 -0
- package/renderables/ScrollBox.d.ts +83 -43
- package/renderables/ScrollBoxParts.d.ts +165 -0
- package/renderables/index.d.ts +1 -1
- package/renderer-theme-mode.d.ts +1 -6
- package/renderer.d.ts +22 -3
- package/testing/test-renderer.d.ts +2 -0
- package/testing.bun.js +7 -6
- package/testing.bun.js.map +3 -3
- package/testing.js +7 -6
- package/testing.js.map +3 -3
- package/types.d.ts +11 -0
- package/yoga.bun.js +1 -1
- package/yoga.internal.d.ts +3 -3
- package/yoga.js +1 -1
- package/zig-structs.d.ts +1 -0
- package/zig.d.ts +78 -8
- package/chunk-bun-qkpm62w1.js.map +0 -35
- package/chunk-node-7bcmqh18.js.map +0 -70
- package/chunk-node-mzgnr3sw.js.map +0 -34
package/index.bun.js
CHANGED
|
@@ -67,6 +67,12 @@ import {
|
|
|
67
67
|
bg2,
|
|
68
68
|
link2,
|
|
69
69
|
t2,
|
|
70
|
+
YogaEnumKind,
|
|
71
|
+
YogaFloatKind,
|
|
72
|
+
YogaValueKind,
|
|
73
|
+
sceneSetEnum,
|
|
74
|
+
sceneSetFloat,
|
|
75
|
+
sceneSetValue,
|
|
70
76
|
SpanInfoStruct,
|
|
71
77
|
NativeAudioStreamFormat2,
|
|
72
78
|
NativeAudioStreamState2,
|
|
@@ -85,11 +91,13 @@ import {
|
|
|
85
91
|
NativeEditorSelectionOperation2,
|
|
86
92
|
NativeEditorPositionQuery2,
|
|
87
93
|
NativeEditEvent2,
|
|
94
|
+
NativeStyleFlags,
|
|
88
95
|
NATIVE_EDGE_NONE2,
|
|
89
96
|
NativeBorder2,
|
|
90
97
|
NativeSceneHook2,
|
|
91
98
|
NativeSceneFrame2,
|
|
92
99
|
NativeScenePaintPhase2,
|
|
100
|
+
emptySceneScrollState,
|
|
93
101
|
NATIVE_BUFFER_TEXT_BYTES_MAX2,
|
|
94
102
|
NativeSessionState2,
|
|
95
103
|
NativeSessionRenderStatus2,
|
|
@@ -108,9 +116,12 @@ import {
|
|
|
108
116
|
FFIRenderLib2,
|
|
109
117
|
setRenderLibPath2,
|
|
110
118
|
resolveRenderLib2,
|
|
119
|
+
Edge2,
|
|
120
|
+
FlexDirection2,
|
|
121
|
+
Gutter2,
|
|
111
122
|
MeasureMode2,
|
|
112
123
|
exports_yoga
|
|
113
|
-
} from "./chunk-bun-
|
|
124
|
+
} from "./chunk-bun-x6cz4jyg.js";
|
|
114
125
|
import {
|
|
115
126
|
isValidBorderStyle2,
|
|
116
127
|
parseBorderStyle2,
|
|
@@ -242,7 +253,7 @@ import {
|
|
|
242
253
|
CliRenderEvents2,
|
|
243
254
|
RendererControlState2,
|
|
244
255
|
CliRenderer2
|
|
245
|
-
} from "./chunk-bun-
|
|
256
|
+
} from "./chunk-bun-6kxdhkdc.js";
|
|
246
257
|
// src/syntax-style.ts
|
|
247
258
|
function cloneStyle(style) {
|
|
248
259
|
return {
|
|
@@ -6506,10 +6517,10 @@ class LineNumberRenderable extends Renderable2 {
|
|
|
6506
6517
|
renderSelf(buffer) {
|
|
6507
6518
|
if (!this.target || !this.gutter || this._lineColorsContent.size === 0)
|
|
6508
6519
|
return;
|
|
6509
|
-
const y =
|
|
6520
|
+
const [x, y] = this._paintOrigin(buffer);
|
|
6510
6521
|
const start = Math.max(0, -y);
|
|
6511
6522
|
const end = Math.min(this.height, buffer.height - y);
|
|
6512
|
-
if (end <= start ||
|
|
6523
|
+
if (end <= start || x >= buffer.width || x + this.width <= 0)
|
|
6513
6524
|
return;
|
|
6514
6525
|
const sources = getLineSources(this.target, Math.trunc(this.target.scrollY) + start, end - start);
|
|
6515
6526
|
const gutterWidth = this.gutter.visible ? this.gutter.width : 0;
|
|
@@ -6518,7 +6529,7 @@ class LineNumberRenderable extends Renderable2 {
|
|
|
6518
6529
|
const logicalLine = sources[i];
|
|
6519
6530
|
const lineBg = this._lineColorsContent.get(logicalLine);
|
|
6520
6531
|
if (lineBg) {
|
|
6521
|
-
buffer.fillRect(
|
|
6532
|
+
buffer.fillRect(x + gutterWidth, y + start + i, contentWidth, 1, lineBg);
|
|
6522
6533
|
}
|
|
6523
6534
|
}
|
|
6524
6535
|
}
|
|
@@ -12108,7 +12119,7 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12108
12119
|
}
|
|
12109
12120
|
}
|
|
12110
12121
|
applyListItemRenderable(row, input, previousItem) {
|
|
12111
|
-
this.applyListItemMarker(row, input);
|
|
12122
|
+
this.applyListItemMarker(row, input, previousItem);
|
|
12112
12123
|
const content = row.getChildren()[1];
|
|
12113
12124
|
if (!(content instanceof BoxRenderable2))
|
|
12114
12125
|
return false;
|
|
@@ -12175,6 +12186,10 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12175
12186
|
this.applyCodeBlockRenderable(renderable, token, 0);
|
|
12176
12187
|
return true;
|
|
12177
12188
|
}
|
|
12189
|
+
if (token.type === "blockquote" && renderable instanceof BoxRenderable2) {
|
|
12190
|
+
this.applyBlockquoteRenderable(renderable, token, 0);
|
|
12191
|
+
return true;
|
|
12192
|
+
}
|
|
12178
12193
|
return previousToken?.raw === token.raw;
|
|
12179
12194
|
}
|
|
12180
12195
|
destroyListItemChildrenAfter(content, index) {
|
|
@@ -12183,7 +12198,7 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12183
12198
|
children[i]?.destroyRecursively();
|
|
12184
12199
|
}
|
|
12185
12200
|
}
|
|
12186
|
-
applyListItemMarker(row, input) {
|
|
12201
|
+
applyListItemMarker(row, input, previousItem) {
|
|
12187
12202
|
const marker = row.getChildren()[0];
|
|
12188
12203
|
if (!(marker instanceof TextRenderable2))
|
|
12189
12204
|
return;
|
|
@@ -12194,7 +12209,7 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12194
12209
|
row.marginBottom = marginBottom;
|
|
12195
12210
|
if (marker.width !== markerWidth)
|
|
12196
12211
|
marker.width = markerWidth;
|
|
12197
|
-
if (marker.chunks[0]?.text !== markerText) {
|
|
12212
|
+
if (!previousItem || marker.chunks[0]?.text !== markerText) {
|
|
12198
12213
|
marker.content = new StyledText2([this.createChunk(markerText, "markup.list")]);
|
|
12199
12214
|
}
|
|
12200
12215
|
}
|
|
@@ -12775,7 +12790,7 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12775
12790
|
return;
|
|
12776
12791
|
renderable.destroyRecursively();
|
|
12777
12792
|
}
|
|
12778
|
-
updateBlockRenderable(state, token, index, nextToken,
|
|
12793
|
+
updateBlockRenderable(state, token, index, nextToken, forceRefresh = false) {
|
|
12779
12794
|
const marginBottom = this.getInterBlockMargin(token, nextToken);
|
|
12780
12795
|
if (token.type === "code") {
|
|
12781
12796
|
this.applyCodeBlockRenderable(state.renderable, token, marginBottom);
|
|
@@ -12786,7 +12801,7 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12786
12801
|
return;
|
|
12787
12802
|
}
|
|
12788
12803
|
if (token.type === "list") {
|
|
12789
|
-
if (!this.applyListRenderable(state.renderable, token,
|
|
12804
|
+
if (!this.applyListRenderable(state.renderable, token, forceRefresh ? undefined : state.token, `${this.id}-block-${index}`, marginBottom)) {
|
|
12790
12805
|
state.renderable.destroyRecursively();
|
|
12791
12806
|
state.renderable = this.createListRenderable(token, `${this.id}-block-${index}`, marginBottom);
|
|
12792
12807
|
this.add(state.renderable, index);
|
|
@@ -12799,7 +12814,7 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12799
12814
|
}
|
|
12800
12815
|
if (token.type === "table") {
|
|
12801
12816
|
const tableToken = token;
|
|
12802
|
-
const { cache, changed } = this.buildTableContentCache(tableToken, state.tableContentCache);
|
|
12817
|
+
const { cache, changed } = this.buildTableContentCache(tableToken, state.tableContentCache, forceRefresh);
|
|
12803
12818
|
if (!cache) {
|
|
12804
12819
|
if (state.renderable instanceof CodeRenderable2) {
|
|
12805
12820
|
this.applyMarkdownCodeRenderable(state.renderable, tableToken.raw, marginBottom);
|
|
@@ -12884,7 +12899,7 @@ class MarkdownRenderable extends Renderable2 {
|
|
|
12884
12899
|
}
|
|
12885
12900
|
this.destroyUnusedDefaultRenderable(custom.renderable);
|
|
12886
12901
|
}
|
|
12887
|
-
this.updateBlockRenderable(existing, block.token, blockIndex, blocks[i + 1]?.token);
|
|
12902
|
+
this.updateBlockRenderable(existing, block.token, blockIndex, blocks[i + 1]?.token, forceTableRefresh);
|
|
12888
12903
|
existing.renderable.marginBottom = 0;
|
|
12889
12904
|
if (existing.marginTop !== block.marginTop) {
|
|
12890
12905
|
this.applyMargins(existing.renderable, block.marginTop, 0);
|
|
@@ -13404,56 +13419,7 @@ class SliderRenderable extends Renderable2 {
|
|
|
13404
13419
|
}
|
|
13405
13420
|
}
|
|
13406
13421
|
renderSelf(buffer) {
|
|
13407
|
-
|
|
13408
|
-
const y = this.y;
|
|
13409
|
-
const width = this.width;
|
|
13410
|
-
const height = this.height;
|
|
13411
|
-
const bufferWidth = buffer.width;
|
|
13412
|
-
const bufferHeight = buffer.height;
|
|
13413
|
-
const left = Math.max(0, Math.trunc(x));
|
|
13414
|
-
const top = Math.max(0, Math.trunc(y));
|
|
13415
|
-
const right = Math.min(bufferWidth, Math.trunc(x) + Math.trunc(width));
|
|
13416
|
-
const bottom = Math.min(bufferHeight, Math.trunc(y) + Math.trunc(height));
|
|
13417
|
-
if (right > left && bottom > top) {
|
|
13418
|
-
buffer.fillRect(left, top, right - left, bottom - top, this._backgroundColor);
|
|
13419
|
-
}
|
|
13420
|
-
const horizontal = this.orientation === "horizontal";
|
|
13421
|
-
const origin = horizontal ? x : y;
|
|
13422
|
-
const crossOrigin = horizontal ? y : x;
|
|
13423
|
-
const length = horizontal ? width : height;
|
|
13424
|
-
const crossLength = horizontal ? height : width;
|
|
13425
|
-
const limit = horizontal ? bufferWidth : bufferHeight;
|
|
13426
|
-
const crossLimit = horizontal ? bufferHeight : bufferWidth;
|
|
13427
|
-
const thumb = this._ctx.nativeScene.getSliderThumb(this);
|
|
13428
|
-
const virtualThumbSize = thumb.size;
|
|
13429
|
-
const virtualThumbStart = thumb.start;
|
|
13430
|
-
const virtualThumbEnd = virtualThumbStart + virtualThumbSize;
|
|
13431
|
-
const start = Math.max(0, Math.floor(virtualThumbStart / 2), Math.floor(-1 - origin));
|
|
13432
|
-
const end = Math.min(Math.floor(length), Math.ceil(virtualThumbEnd / 2), Math.ceil(limit - origin) + 1);
|
|
13433
|
-
const crossStart = Math.max(0, Math.floor(-1 - crossOrigin));
|
|
13434
|
-
const crossEnd = Math.min(Math.ceil(crossLength), Math.ceil(crossLimit - crossOrigin) + 1);
|
|
13435
|
-
for (let along = start;along < end; along++) {
|
|
13436
|
-
const cell = Math.trunc(origin + along);
|
|
13437
|
-
if (cell < 0 || cell >= limit)
|
|
13438
|
-
continue;
|
|
13439
|
-
const virtualCellStart = along * 2;
|
|
13440
|
-
const thumbStartInCell = Math.max(virtualThumbStart, virtualCellStart);
|
|
13441
|
-
const coverage = Math.min(virtualThumbEnd, virtualCellStart + 2) - thumbStartInCell;
|
|
13442
|
-
let char = " ";
|
|
13443
|
-
if (coverage >= 2) {
|
|
13444
|
-
char = "\u2588";
|
|
13445
|
-
} else if (horizontal) {
|
|
13446
|
-
char = thumbStartInCell === virtualCellStart ? "\u258C" : "\u2590";
|
|
13447
|
-
} else if (coverage > 0) {
|
|
13448
|
-
char = thumbStartInCell === virtualCellStart ? "\u2580" : "\u2584";
|
|
13449
|
-
}
|
|
13450
|
-
for (let across = crossStart;across < crossEnd; across++) {
|
|
13451
|
-
const crossCell = Math.trunc(crossOrigin + across);
|
|
13452
|
-
if (crossCell < 0 || crossCell >= crossLimit)
|
|
13453
|
-
continue;
|
|
13454
|
-
buffer.setCellWithAlphaBlending(horizontal ? cell : crossCell, horizontal ? crossCell : cell, char, this._foregroundColor, this._backgroundColor);
|
|
13455
|
-
}
|
|
13456
|
-
}
|
|
13422
|
+
this._drawNativeBody(buffer);
|
|
13457
13423
|
}
|
|
13458
13424
|
}
|
|
13459
13425
|
|
|
@@ -13719,9 +13685,7 @@ class ScrollBarRenderable extends Renderable2 {
|
|
|
13719
13685
|
this.slider.value = Math.min(this._scrollPosition, scrollRange);
|
|
13720
13686
|
}
|
|
13721
13687
|
scrollBy(delta, unit = "absolute") {
|
|
13722
|
-
|
|
13723
|
-
const resolvedDelta = multiplier * delta;
|
|
13724
|
-
this.scrollPosition += resolvedDelta;
|
|
13688
|
+
this.scrollPosition += scrollUnitSize(this, unit) * delta;
|
|
13725
13689
|
}
|
|
13726
13690
|
recalculateVisibility() {
|
|
13727
13691
|
if (!this._manualVisibility) {
|
|
@@ -13867,8 +13831,7 @@ class ArrowRenderable extends Renderable2 {
|
|
|
13867
13831
|
});
|
|
13868
13832
|
}
|
|
13869
13833
|
renderSelf(buffer) {
|
|
13870
|
-
|
|
13871
|
-
buffer.drawText(char, this.x, this.y, this._foregroundColor, this._backgroundColor, this._attributes);
|
|
13834
|
+
this._drawNativeBody(buffer);
|
|
13872
13835
|
}
|
|
13873
13836
|
defaultDimension(kind) {
|
|
13874
13837
|
return kind === "width" ? this.glyphWidth() : super.defaultDimension(kind);
|
|
@@ -13886,31 +13849,428 @@ class ArrowRenderable extends Renderable2 {
|
|
|
13886
13849
|
return this._arrowChars[this._direction];
|
|
13887
13850
|
}
|
|
13888
13851
|
}
|
|
13889
|
-
|
|
13890
|
-
|
|
13891
|
-
|
|
13892
|
-
|
|
13893
|
-
|
|
13894
|
-
|
|
13895
|
-
|
|
13896
|
-
|
|
13897
|
-
|
|
13898
|
-
|
|
13899
|
-
|
|
13900
|
-
|
|
13901
|
-
|
|
13852
|
+
function scrollUnitSize(bar, unit) {
|
|
13853
|
+
if (unit === "viewport")
|
|
13854
|
+
return bar.viewportSize;
|
|
13855
|
+
if (unit === "content")
|
|
13856
|
+
return bar.scrollSize;
|
|
13857
|
+
return unit === "step" ? bar.scrollStep ?? 1 : 1;
|
|
13858
|
+
}
|
|
13859
|
+
// src/renderables/ScrollBoxParts.ts
|
|
13860
|
+
import { EventEmitter as EventEmitter2 } from "events";
|
|
13861
|
+
class ScrollBoxPart extends EventEmitter2 {
|
|
13862
|
+
box;
|
|
13863
|
+
constructor(box, event) {
|
|
13864
|
+
super();
|
|
13865
|
+
this.box = box;
|
|
13866
|
+
this.on("newListener", (name) => name === event && box._refreshScrollHook(true));
|
|
13867
|
+
this.on("removeListener", (name) => name === event && box._refreshScrollHook());
|
|
13868
|
+
}
|
|
13869
|
+
get isDestroyed() {
|
|
13870
|
+
return this.box.isDestroyed;
|
|
13871
|
+
}
|
|
13872
|
+
get x() {
|
|
13873
|
+
return this.rect().x;
|
|
13874
|
+
}
|
|
13875
|
+
get y() {
|
|
13876
|
+
return this.rect().y;
|
|
13877
|
+
}
|
|
13878
|
+
get screenX() {
|
|
13879
|
+
return this.rect().x;
|
|
13880
|
+
}
|
|
13881
|
+
get screenY() {
|
|
13882
|
+
return this.rect().y;
|
|
13883
|
+
}
|
|
13884
|
+
get width() {
|
|
13885
|
+
return this.rect().width;
|
|
13886
|
+
}
|
|
13887
|
+
get height() {
|
|
13888
|
+
return this.rect().height;
|
|
13889
|
+
}
|
|
13890
|
+
removeAllListeners(event) {
|
|
13891
|
+
for (const name of event === undefined ? this.eventNames() : [event]) {
|
|
13892
|
+
if (name !== "newListener" && name !== "removeListener")
|
|
13893
|
+
super.removeAllListeners(name);
|
|
13894
|
+
}
|
|
13895
|
+
return this;
|
|
13896
|
+
}
|
|
13897
|
+
_assign(options, keys) {
|
|
13898
|
+
if (options == null)
|
|
13899
|
+
return;
|
|
13900
|
+
for (const key of Reflect.ownKeys(options)) {
|
|
13901
|
+
if (typeof key !== "string" || !keys.includes(key))
|
|
13902
|
+
continue;
|
|
13903
|
+
if (!Object.getOwnPropertyDescriptor(options, key)?.enumerable)
|
|
13904
|
+
continue;
|
|
13905
|
+
this[key] = Reflect.get(options, key);
|
|
13906
|
+
if (this.box.isDestroyed)
|
|
13907
|
+
return;
|
|
13908
|
+
}
|
|
13909
|
+
}
|
|
13910
|
+
}
|
|
13911
|
+
|
|
13912
|
+
class ScrollBoxFilledPart extends ScrollBoxPart {
|
|
13913
|
+
_backgroundColor;
|
|
13914
|
+
get backgroundColor() {
|
|
13915
|
+
return RGBA2.clone(this._backgroundColor ?? RGBA2.fromValues(0, 0, 0, 0));
|
|
13916
|
+
}
|
|
13917
|
+
set backgroundColor(value) {
|
|
13918
|
+
this._backgroundColor = value == null ? undefined : RGBA2.clone(parseColor2(value));
|
|
13919
|
+
this.box._applyScrollOptions();
|
|
13920
|
+
}
|
|
13921
|
+
_fill() {
|
|
13922
|
+
return this._backgroundColor;
|
|
13923
|
+
}
|
|
13924
|
+
}
|
|
13925
|
+
|
|
13926
|
+
class ScrollBoxSizedPart extends ScrollBoxFilledPart {
|
|
13927
|
+
_onSizeChange;
|
|
13928
|
+
constructor(box) {
|
|
13929
|
+
super(box, "resize");
|
|
13930
|
+
}
|
|
13931
|
+
get onSizeChange() {
|
|
13932
|
+
return this._onSizeChange;
|
|
13933
|
+
}
|
|
13934
|
+
set onSizeChange(handler) {
|
|
13935
|
+
this._onSizeChange = handler ?? undefined;
|
|
13936
|
+
this.box._refreshScrollHook();
|
|
13937
|
+
}
|
|
13938
|
+
_listening() {
|
|
13939
|
+
return this._onSizeChange !== undefined || this.listenerCount("resize") > 0;
|
|
13940
|
+
}
|
|
13941
|
+
_emitResize() {
|
|
13942
|
+
this._onSizeChange?.();
|
|
13943
|
+
if (!this.box.isDestroyed)
|
|
13944
|
+
this.emit("resize");
|
|
13945
|
+
}
|
|
13946
|
+
}
|
|
13947
|
+
|
|
13948
|
+
class ScrollBoxWrapper extends ScrollBoxFilledPart {
|
|
13949
|
+
static keys = ["backgroundColor"];
|
|
13950
|
+
_listening() {
|
|
13951
|
+
return false;
|
|
13952
|
+
}
|
|
13953
|
+
rect() {
|
|
13954
|
+
return this.box._wrapperRect();
|
|
13955
|
+
}
|
|
13956
|
+
}
|
|
13957
|
+
var paddingKeys = ["padding", "paddingX", "paddingY", "paddingLeft", "paddingTop", "paddingRight", "paddingBottom"];
|
|
13958
|
+
|
|
13959
|
+
class ScrollBoxViewport extends ScrollBoxSizedPart {
|
|
13960
|
+
static keys = ["backgroundColor", "onSizeChange", ...paddingKeys];
|
|
13961
|
+
paddings = {};
|
|
13962
|
+
constructor(box) {
|
|
13963
|
+
super(box);
|
|
13964
|
+
paddingKeys.forEach((key, index) => Object.defineProperty(this, key, {
|
|
13965
|
+
configurable: true,
|
|
13966
|
+
get: index < 3 ? undefined : () => this._edges()[index - 3],
|
|
13967
|
+
set: (value) => this.setPadding(key, value)
|
|
13968
|
+
}));
|
|
13969
|
+
}
|
|
13970
|
+
rect() {
|
|
13971
|
+
return this.box._scrollState().viewport;
|
|
13972
|
+
}
|
|
13973
|
+
setPadding(key, value) {
|
|
13974
|
+
if (value != null && (typeof value !== "number" || !Number.isInteger(value) || value < 0 || value > 65535)) {
|
|
13975
|
+
throw new RangeError("ScrollBox viewport padding must be a whole number of cells");
|
|
13976
|
+
}
|
|
13977
|
+
if (value == null)
|
|
13978
|
+
delete this.paddings[key];
|
|
13979
|
+
else
|
|
13980
|
+
this.paddings[key] = value;
|
|
13981
|
+
this.box._applyScrollOptions();
|
|
13982
|
+
}
|
|
13983
|
+
_edges() {
|
|
13984
|
+
const p = this.paddings;
|
|
13985
|
+
const all = p.padding ?? 0;
|
|
13986
|
+
const x = p.paddingX ?? all;
|
|
13987
|
+
const y = p.paddingY ?? all;
|
|
13988
|
+
return [p.paddingLeft ?? x, p.paddingTop ?? y, p.paddingRight ?? x, p.paddingBottom ?? y];
|
|
13989
|
+
}
|
|
13990
|
+
}
|
|
13991
|
+
var content = NativeStyleFlags.Content;
|
|
13992
|
+
var contentStyles = {};
|
|
13993
|
+
{
|
|
13994
|
+
const value = (kind, edge = NATIVE_EDGE_NONE2) => (scene, node, input) => sceneSetValue(scene, node, kind, edge, input ?? undefined, content);
|
|
13995
|
+
const enums = [
|
|
13996
|
+
["flexDirection", YogaEnumKind.FlexDirection, parseFlexDirection2],
|
|
13997
|
+
["flexWrap", YogaEnumKind.FlexWrap, parseWrap2],
|
|
13998
|
+
["alignItems", YogaEnumKind.AlignItems, parseAlignItems2],
|
|
13999
|
+
["justifyContent", YogaEnumKind.JustifyContent, parseJustify2],
|
|
14000
|
+
["alignSelf", YogaEnumKind.AlignSelf, parseAlign2]
|
|
14001
|
+
];
|
|
14002
|
+
for (const [key, kind, parse] of enums) {
|
|
14003
|
+
contentStyles[key] = (scene, node, input) => sceneSetEnum(scene, node, kind, parse(input ?? undefined), content);
|
|
14004
|
+
}
|
|
14005
|
+
contentStyles.flexGrow = (scene, node, input) => sceneSetFloat(scene, node, YogaFloatKind.FlexGrow, input ?? 0, content);
|
|
14006
|
+
contentStyles.flexShrink = (scene, node, input) => sceneSetFloat(scene, node, YogaFloatKind.FlexShrink, input ?? 0, content);
|
|
14007
|
+
for (const [key, kind] of [
|
|
14008
|
+
["width", YogaValueKind.Width],
|
|
14009
|
+
["height", YogaValueKind.Height],
|
|
14010
|
+
["flexBasis", YogaValueKind.FlexBasis],
|
|
14011
|
+
["minWidth", YogaValueKind.MinWidth],
|
|
14012
|
+
["minHeight", YogaValueKind.MinHeight],
|
|
14013
|
+
["maxWidth", YogaValueKind.MaxWidth],
|
|
14014
|
+
["maxHeight", YogaValueKind.MaxHeight]
|
|
14015
|
+
]) {
|
|
14016
|
+
contentStyles[key] = value(kind);
|
|
14017
|
+
}
|
|
14018
|
+
for (const [suffix, edge] of [
|
|
14019
|
+
["", Edge2.All],
|
|
14020
|
+
["X", Edge2.Horizontal],
|
|
14021
|
+
["Y", Edge2.Vertical],
|
|
14022
|
+
["Top", Edge2.Top],
|
|
14023
|
+
["Right", Edge2.Right],
|
|
14024
|
+
["Bottom", Edge2.Bottom],
|
|
14025
|
+
["Left", Edge2.Left]
|
|
14026
|
+
]) {
|
|
14027
|
+
contentStyles[`padding${suffix}`] = value(YogaValueKind.Padding, edge);
|
|
14028
|
+
contentStyles[`margin${suffix}`] = value(YogaValueKind.Margin, edge);
|
|
14029
|
+
}
|
|
14030
|
+
contentStyles.gap = value(YogaValueKind.Gap, Gutter2.All);
|
|
14031
|
+
contentStyles.rowGap = value(YogaValueKind.Gap, Gutter2.Row);
|
|
14032
|
+
contentStyles.columnGap = value(YogaValueKind.Gap, Gutter2.Column);
|
|
14033
|
+
}
|
|
14034
|
+
|
|
14035
|
+
class ScrollBoxContent extends ScrollBoxSizedPart {
|
|
14036
|
+
static keys = ["backgroundColor", "onSizeChange", "viewportCulling", ...Object.keys(contentStyles)];
|
|
14037
|
+
styles = new Map;
|
|
14038
|
+
constructor(box) {
|
|
14039
|
+
super(box);
|
|
14040
|
+
for (const key of Object.keys(contentStyles)) {
|
|
14041
|
+
const size = key === "width" || key === "height";
|
|
14042
|
+
Object.defineProperty(this, key, {
|
|
14043
|
+
configurable: true,
|
|
14044
|
+
enumerable: false,
|
|
14045
|
+
get: () => size ? this.rect()[key] : this.styles.get(key),
|
|
14046
|
+
set: (input) => this.setStyle(key, input)
|
|
14047
|
+
});
|
|
13902
14048
|
}
|
|
13903
14049
|
}
|
|
14050
|
+
rect() {
|
|
14051
|
+
const { content, offset } = this.box._scrollState();
|
|
14052
|
+
return {
|
|
14053
|
+
x: this.box.screenX + content.x - offset[0],
|
|
14054
|
+
y: this.box.screenY + content.y - offset[1],
|
|
14055
|
+
width: content.width,
|
|
14056
|
+
height: content.height
|
|
14057
|
+
};
|
|
14058
|
+
}
|
|
14059
|
+
setStyle(key, input) {
|
|
14060
|
+
this.box._setContentStyle((scene, node) => contentStyles[key](scene, node, input));
|
|
14061
|
+
if (input == null)
|
|
14062
|
+
this.styles.delete(key);
|
|
14063
|
+
else
|
|
14064
|
+
this.styles.set(key, input);
|
|
14065
|
+
}
|
|
14066
|
+
get _row() {
|
|
14067
|
+
const direction = parseFlexDirection2(this.styles.get("flexDirection"));
|
|
14068
|
+
return direction === FlexDirection2.Row || direction === FlexDirection2.RowReverse;
|
|
14069
|
+
}
|
|
13904
14070
|
get viewportCulling() {
|
|
13905
|
-
return this.
|
|
14071
|
+
return this.box.viewportCulling;
|
|
13906
14072
|
}
|
|
13907
14073
|
set viewportCulling(value) {
|
|
13908
|
-
|
|
14074
|
+
this.box.viewportCulling = value;
|
|
14075
|
+
}
|
|
14076
|
+
add(obj, index) {
|
|
14077
|
+
return this.box.add(obj, index);
|
|
14078
|
+
}
|
|
14079
|
+
insertBefore(obj, anchor) {
|
|
14080
|
+
return this.box.insertBefore(obj, anchor);
|
|
14081
|
+
}
|
|
14082
|
+
remove(child) {
|
|
14083
|
+
this.box.remove(child);
|
|
14084
|
+
}
|
|
14085
|
+
getChildren() {
|
|
14086
|
+
return this.box.getChildren();
|
|
14087
|
+
}
|
|
14088
|
+
getChildrenCount() {
|
|
14089
|
+
return this.box.getChildrenCount();
|
|
14090
|
+
}
|
|
14091
|
+
getRenderable(id) {
|
|
14092
|
+
return this.box.getRenderable(id);
|
|
14093
|
+
}
|
|
14094
|
+
findDescendantById(id) {
|
|
14095
|
+
return this.box.findDescendantById(id);
|
|
14096
|
+
}
|
|
14097
|
+
}
|
|
14098
|
+
var defaultTrack = RGBA2.fromHex("#252527");
|
|
14099
|
+
var defaultThumb = RGBA2.fromHex("#9a9ea3");
|
|
14100
|
+
var defaultArrowForeground2 = RGBA2.fromValues(1, 1, 1, 1);
|
|
14101
|
+
var defaultArrowBackground2 = RGBA2.fromValues(0, 0, 0, 0);
|
|
14102
|
+
|
|
14103
|
+
class ScrollBoxBar extends ScrollBoxPart {
|
|
14104
|
+
static keys = [
|
|
14105
|
+
"visible",
|
|
14106
|
+
"showArrows",
|
|
14107
|
+
"arrowOptions",
|
|
14108
|
+
"trackOptions",
|
|
14109
|
+
"onChange",
|
|
14110
|
+
"width",
|
|
14111
|
+
"height",
|
|
14112
|
+
"paddingLeft",
|
|
14113
|
+
"paddingTop",
|
|
14114
|
+
"position",
|
|
14115
|
+
"scrollStep"
|
|
14116
|
+
];
|
|
14117
|
+
orientation;
|
|
14118
|
+
scrollStep = null;
|
|
14119
|
+
axis;
|
|
14120
|
+
policy = "auto";
|
|
14121
|
+
_showArrows = false;
|
|
14122
|
+
_arrowOptions = {};
|
|
14123
|
+
trackForeground = defaultThumb;
|
|
14124
|
+
trackBackground = defaultTrack;
|
|
14125
|
+
thickness = 1;
|
|
14126
|
+
gap = 0;
|
|
14127
|
+
overlay = false;
|
|
14128
|
+
_onChange;
|
|
14129
|
+
constructor(box, orientation) {
|
|
14130
|
+
super(box, "change");
|
|
14131
|
+
this.orientation = orientation;
|
|
14132
|
+
this.axis = orientation === "vertical" ? 1 : 0;
|
|
14133
|
+
}
|
|
14134
|
+
rect() {
|
|
14135
|
+
const bar = this.box._scrollState().bars[this.axis];
|
|
14136
|
+
const arrows = this._showArrows ? 1 : 0;
|
|
14137
|
+
return this.axis === 1 ? {
|
|
14138
|
+
x: bar.track.x - this.gap,
|
|
14139
|
+
y: bar.track.y - arrows,
|
|
14140
|
+
width: bar.track.width + this.gap,
|
|
14141
|
+
height: bar.track.height + 2 * arrows
|
|
14142
|
+
} : {
|
|
14143
|
+
x: bar.track.x - arrows,
|
|
14144
|
+
y: bar.track.y - this.gap,
|
|
14145
|
+
width: bar.track.width + 2 * arrows,
|
|
14146
|
+
height: bar.track.height + this.gap
|
|
14147
|
+
};
|
|
14148
|
+
}
|
|
14149
|
+
_listening() {
|
|
14150
|
+
return this._onChange !== undefined || this.listenerCount("change") > 0;
|
|
14151
|
+
}
|
|
14152
|
+
_native() {
|
|
14153
|
+
return {
|
|
14154
|
+
policy: this.policy,
|
|
14155
|
+
overlay: this.overlay,
|
|
14156
|
+
thickness: this.thickness,
|
|
14157
|
+
gap: this.gap,
|
|
14158
|
+
arrows: this._showArrows,
|
|
14159
|
+
foregroundColor: this.trackForeground,
|
|
14160
|
+
backgroundColor: this.trackBackground
|
|
14161
|
+
};
|
|
14162
|
+
}
|
|
14163
|
+
_arrows() {
|
|
14164
|
+
const options = this._arrowOptions;
|
|
14165
|
+
const background = options.backgroundColor ?? undefined;
|
|
14166
|
+
const foreground = options.foregroundColor ?? background;
|
|
14167
|
+
const chars = options.arrowChars ?? {};
|
|
14168
|
+
return (this.axis === 1 ? ["up", "down"] : ["left", "right"]).map((direction) => ({
|
|
14169
|
+
attributes: options.attributes ?? 0,
|
|
14170
|
+
foregroundColor: RGBA2.clone(parseColor2(foreground || defaultArrowForeground2)),
|
|
14171
|
+
backgroundColor: RGBA2.clone(parseColor2(background || defaultArrowBackground2)),
|
|
14172
|
+
text: chars[direction]
|
|
14173
|
+
}));
|
|
14174
|
+
}
|
|
14175
|
+
_emitChange(position) {
|
|
14176
|
+
this._onChange?.(position);
|
|
14177
|
+
if (!this.box.isDestroyed)
|
|
14178
|
+
this.emit("change", { position });
|
|
14179
|
+
}
|
|
14180
|
+
get visible() {
|
|
14181
|
+
return this.box._scrollState().bars[this.axis].visible;
|
|
14182
|
+
}
|
|
14183
|
+
set visible(value) {
|
|
14184
|
+
this.setOption(() => this.policy = value == null ? "auto" : value ? "always" : "never");
|
|
14185
|
+
}
|
|
14186
|
+
resetVisibilityControl() {
|
|
14187
|
+
this.visible = null;
|
|
14188
|
+
}
|
|
14189
|
+
get onChange() {
|
|
14190
|
+
return this._onChange;
|
|
14191
|
+
}
|
|
14192
|
+
set onChange(handler) {
|
|
14193
|
+
this._onChange = handler ?? undefined;
|
|
14194
|
+
this.box._refreshScrollHook();
|
|
14195
|
+
}
|
|
14196
|
+
get showArrows() {
|
|
14197
|
+
return this._showArrows;
|
|
14198
|
+
}
|
|
14199
|
+
set showArrows(value) {
|
|
14200
|
+
this.setOption(() => this._showArrows = value ?? false);
|
|
14201
|
+
}
|
|
14202
|
+
set arrowOptions(options) {
|
|
14203
|
+
this._arrowOptions = { ...this._arrowOptions, ...options };
|
|
14204
|
+
if (!this.box.isDestroyed)
|
|
14205
|
+
this.box._applyScrollArrows(this.axis);
|
|
14206
|
+
}
|
|
14207
|
+
set trackOptions(options) {
|
|
14208
|
+
this.setOption(() => {
|
|
14209
|
+
if (options && "foregroundColor" in options) {
|
|
14210
|
+
this.trackForeground = RGBA2.clone(parseColor2(options.foregroundColor ?? defaultThumb));
|
|
14211
|
+
}
|
|
14212
|
+
if (options && "backgroundColor" in options) {
|
|
14213
|
+
this.trackBackground = RGBA2.clone(parseColor2(options.backgroundColor ?? defaultTrack));
|
|
14214
|
+
}
|
|
14215
|
+
});
|
|
14216
|
+
}
|
|
14217
|
+
get width() {
|
|
14218
|
+
return super.width;
|
|
14219
|
+
}
|
|
14220
|
+
set width(value) {
|
|
14221
|
+
if (this.axis === 1)
|
|
14222
|
+
this.setOption(() => this.thickness = Math.max(1, cells(value, 1)));
|
|
14223
|
+
}
|
|
14224
|
+
get height() {
|
|
14225
|
+
return super.height;
|
|
14226
|
+
}
|
|
14227
|
+
set height(value) {
|
|
14228
|
+
if (this.axis === 0)
|
|
14229
|
+
this.setOption(() => this.thickness = Math.max(1, cells(value, 1)));
|
|
14230
|
+
}
|
|
14231
|
+
set paddingLeft(value) {
|
|
14232
|
+
if (this.axis === 1)
|
|
14233
|
+
this.setOption(() => this.gap = cells(value, 0));
|
|
14234
|
+
}
|
|
14235
|
+
set paddingTop(value) {
|
|
14236
|
+
if (this.axis === 0)
|
|
14237
|
+
this.setOption(() => this.gap = cells(value, 0));
|
|
14238
|
+
}
|
|
14239
|
+
set position(value) {
|
|
14240
|
+
this.setOption(() => this.overlay = value === "absolute");
|
|
14241
|
+
}
|
|
14242
|
+
setOption(change) {
|
|
14243
|
+
if (this.box.isDestroyed)
|
|
13909
14244
|
return;
|
|
13910
|
-
|
|
13911
|
-
this.
|
|
14245
|
+
change();
|
|
14246
|
+
this.box._applyScrollOptions();
|
|
14247
|
+
}
|
|
14248
|
+
get scrollSize() {
|
|
14249
|
+
const { content } = this.box._scrollState();
|
|
14250
|
+
return this.axis === 1 ? content.height : content.width;
|
|
14251
|
+
}
|
|
14252
|
+
get viewportSize() {
|
|
14253
|
+
const { viewport } = this.box._scrollState();
|
|
14254
|
+
return this.axis === 1 ? viewport.height : viewport.width;
|
|
13912
14255
|
}
|
|
14256
|
+
get scrollPosition() {
|
|
14257
|
+
return this.box._scrollState().offset[this.axis];
|
|
14258
|
+
}
|
|
14259
|
+
set scrollPosition(value) {
|
|
14260
|
+
this.box._scrollAxis(this.axis, value, false);
|
|
14261
|
+
}
|
|
14262
|
+
scrollBy(delta, unit = "absolute") {
|
|
14263
|
+
this.box._scrollAxis(this.axis, scrollUnitSize(this, unit) * delta, true, true);
|
|
14264
|
+
}
|
|
14265
|
+
handleKeyPress(key) {
|
|
14266
|
+
return ScrollBarRenderable.prototype.handleKeyPress.call(this, key);
|
|
14267
|
+
}
|
|
14268
|
+
}
|
|
14269
|
+
function cells(value, fallback) {
|
|
14270
|
+
return typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.min(255, Math.trunc(value))) : fallback;
|
|
13913
14271
|
}
|
|
14272
|
+
|
|
14273
|
+
// src/renderables/ScrollBox.ts
|
|
13914
14274
|
var SCROLLBOX_PADDING_KEYS = [
|
|
13915
14275
|
"padding",
|
|
13916
14276
|
"paddingX",
|
|
@@ -13947,11 +14307,13 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
13947
14307
|
update: {
|
|
13948
14308
|
idle: this.prototype.onUpdate,
|
|
13949
14309
|
active: (renderable) => renderable["isAutoScrolling"]
|
|
14310
|
+
},
|
|
14311
|
+
scroll: {
|
|
14312
|
+
active: (renderable) => renderable.scrollHook,
|
|
14313
|
+
notify: (renderable) => renderable.notifyScroll()
|
|
13950
14314
|
}
|
|
13951
14315
|
}
|
|
13952
14316
|
};
|
|
13953
|
-
static idCounter = 0;
|
|
13954
|
-
internalId = 0;
|
|
13955
14317
|
wrapper;
|
|
13956
14318
|
viewport;
|
|
13957
14319
|
content;
|
|
@@ -13973,126 +14335,70 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
13973
14335
|
scrollAccumulatorX = 0;
|
|
13974
14336
|
scrollAccumulatorY = 0;
|
|
13975
14337
|
_stickyScroll;
|
|
13976
|
-
_stickyScrollTop = false;
|
|
13977
|
-
_stickyScrollBottom = false;
|
|
13978
|
-
_stickyScrollLeft = false;
|
|
13979
|
-
_stickyScrollRight = false;
|
|
13980
14338
|
_stickyStart;
|
|
13981
|
-
_hasManualScroll = false;
|
|
13982
|
-
_isApplyingStickyScroll = false;
|
|
13983
14339
|
scrollAccel;
|
|
14340
|
+
axes;
|
|
14341
|
+
_viewportCulling;
|
|
14342
|
+
state = emptySceneScrollState();
|
|
14343
|
+
stateRevision;
|
|
14344
|
+
scrollHook = false;
|
|
14345
|
+
configured = false;
|
|
14346
|
+
barPress;
|
|
14347
|
+
layoutCallbacks = [];
|
|
14348
|
+
anchorToken;
|
|
13984
14349
|
get stickyScroll() {
|
|
13985
14350
|
return this._stickyScroll;
|
|
13986
14351
|
}
|
|
13987
14352
|
set stickyScroll(value) {
|
|
13988
|
-
this._stickyScroll = value;
|
|
13989
|
-
this.updateStickyState();
|
|
14353
|
+
this.setScrollOption(() => this._stickyScroll = value);
|
|
13990
14354
|
}
|
|
13991
14355
|
get stickyStart() {
|
|
13992
14356
|
return this._stickyStart;
|
|
13993
14357
|
}
|
|
13994
14358
|
set stickyStart(value) {
|
|
13995
|
-
this._stickyStart = value;
|
|
13996
|
-
|
|
14359
|
+
this.setScrollOption(() => this._stickyStart = value);
|
|
14360
|
+
}
|
|
14361
|
+
setScrollOption(change) {
|
|
14362
|
+
const previous = [this._stickyScroll, this._stickyStart, this._viewportCulling];
|
|
14363
|
+
change();
|
|
14364
|
+
try {
|
|
14365
|
+
this._applyScrollOptions();
|
|
14366
|
+
} catch (error) {
|
|
14367
|
+
[this._stickyScroll, this._stickyStart, this._viewportCulling] = previous;
|
|
14368
|
+
throw error;
|
|
14369
|
+
}
|
|
14370
|
+
}
|
|
14371
|
+
get scrollX() {
|
|
14372
|
+
return this.axes.x;
|
|
14373
|
+
}
|
|
14374
|
+
set scrollX(value) {
|
|
14375
|
+
this.axes.x = value ?? false;
|
|
14376
|
+
this._applyScrollOptions();
|
|
14377
|
+
}
|
|
14378
|
+
get scrollY() {
|
|
14379
|
+
return this.axes.y;
|
|
14380
|
+
}
|
|
14381
|
+
set scrollY(value) {
|
|
14382
|
+
this.axes.y = value ?? true;
|
|
14383
|
+
this._applyScrollOptions();
|
|
13997
14384
|
}
|
|
13998
14385
|
get scrollTop() {
|
|
13999
|
-
return this.
|
|
14386
|
+
return this._scrollState().offset[1];
|
|
14000
14387
|
}
|
|
14001
14388
|
set scrollTop(value) {
|
|
14002
|
-
this.
|
|
14003
|
-
this.updateStickyState();
|
|
14389
|
+
this._scrollAxis(1, value, false);
|
|
14004
14390
|
}
|
|
14005
14391
|
get scrollLeft() {
|
|
14006
|
-
return this.
|
|
14392
|
+
return this._scrollState().offset[0];
|
|
14007
14393
|
}
|
|
14008
14394
|
set scrollLeft(value) {
|
|
14009
|
-
this.
|
|
14010
|
-
this.updateStickyState();
|
|
14395
|
+
this._scrollAxis(0, value, false);
|
|
14011
14396
|
}
|
|
14012
14397
|
get scrollWidth() {
|
|
14013
|
-
return this.
|
|
14398
|
+
return this._scrollState().content.width;
|
|
14014
14399
|
}
|
|
14015
14400
|
get scrollHeight() {
|
|
14016
|
-
return this.
|
|
14017
|
-
}
|
|
14018
|
-
updateStickyState() {
|
|
14019
|
-
if (this.isDestroyed)
|
|
14020
|
-
return;
|
|
14021
|
-
if (!this._stickyScroll) {
|
|
14022
|
-
this.syncManualScrollState();
|
|
14023
|
-
return;
|
|
14024
|
-
}
|
|
14025
|
-
const maxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
|
|
14026
|
-
const maxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
|
|
14027
|
-
if (this.scrollTop <= 0) {
|
|
14028
|
-
this._stickyScrollTop = true;
|
|
14029
|
-
this._stickyScrollBottom = false;
|
|
14030
|
-
} else if (this.scrollTop >= maxScrollTop) {
|
|
14031
|
-
this._stickyScrollTop = false;
|
|
14032
|
-
this._stickyScrollBottom = true;
|
|
14033
|
-
} else {
|
|
14034
|
-
this._stickyScrollTop = false;
|
|
14035
|
-
this._stickyScrollBottom = false;
|
|
14036
|
-
}
|
|
14037
|
-
if (this.scrollLeft <= 0) {
|
|
14038
|
-
this._stickyScrollLeft = true;
|
|
14039
|
-
this._stickyScrollRight = false;
|
|
14040
|
-
} else if (this.scrollLeft >= maxScrollLeft) {
|
|
14041
|
-
this._stickyScrollLeft = false;
|
|
14042
|
-
this._stickyScrollRight = true;
|
|
14043
|
-
} else {
|
|
14044
|
-
this._stickyScrollLeft = false;
|
|
14045
|
-
this._stickyScrollRight = false;
|
|
14046
|
-
}
|
|
14047
|
-
this.syncManualScrollState();
|
|
14048
|
-
}
|
|
14049
|
-
syncManualScrollState() {
|
|
14050
|
-
if (this.isDestroyed)
|
|
14051
|
-
return;
|
|
14052
|
-
if (!this._stickyScroll) {
|
|
14053
|
-
this._hasManualScroll = false;
|
|
14054
|
-
return;
|
|
14055
|
-
}
|
|
14056
|
-
const maxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
|
|
14057
|
-
const maxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
|
|
14058
|
-
const hasScrollableContent = maxScrollTop > 1 || maxScrollLeft > 1;
|
|
14059
|
-
if (this._isApplyingStickyScroll) {
|
|
14060
|
-
if (this._hasManualScroll && hasScrollableContent && this.isAtStickyPosition()) {
|
|
14061
|
-
this._hasManualScroll = false;
|
|
14062
|
-
}
|
|
14063
|
-
return;
|
|
14064
|
-
}
|
|
14065
|
-
this._hasManualScroll = hasScrollableContent && !this.isAtStickyPosition();
|
|
14066
|
-
}
|
|
14067
|
-
applyStickyStart(stickyStart) {
|
|
14068
|
-
const wasApplyingStickyScroll = this._isApplyingStickyScroll;
|
|
14069
|
-
this._isApplyingStickyScroll = true;
|
|
14070
|
-
try {
|
|
14071
|
-
switch (stickyStart) {
|
|
14072
|
-
case "top":
|
|
14073
|
-
this._stickyScrollTop = true;
|
|
14074
|
-
this._stickyScrollBottom = false;
|
|
14075
|
-
this.verticalScrollBar.scrollPosition = 0;
|
|
14076
|
-
break;
|
|
14077
|
-
case "bottom":
|
|
14078
|
-
this._stickyScrollTop = false;
|
|
14079
|
-
this._stickyScrollBottom = true;
|
|
14080
|
-
this.verticalScrollBar.scrollPosition = Math.max(0, this.scrollHeight - this.viewport.height);
|
|
14081
|
-
break;
|
|
14082
|
-
case "left":
|
|
14083
|
-
this._stickyScrollLeft = true;
|
|
14084
|
-
this._stickyScrollRight = false;
|
|
14085
|
-
this.horizontalScrollBar.scrollPosition = 0;
|
|
14086
|
-
break;
|
|
14087
|
-
case "right":
|
|
14088
|
-
this._stickyScrollLeft = false;
|
|
14089
|
-
this._stickyScrollRight = true;
|
|
14090
|
-
this.horizontalScrollBar.scrollPosition = Math.max(0, this.scrollWidth - this.viewport.width);
|
|
14091
|
-
break;
|
|
14092
|
-
}
|
|
14093
|
-
} finally {
|
|
14094
|
-
this._isApplyingStickyScroll = wasApplyingStickyScroll;
|
|
14095
|
-
}
|
|
14401
|
+
return this._scrollState().content.height;
|
|
14096
14402
|
}
|
|
14097
14403
|
constructor(ctx, options) {
|
|
14098
14404
|
const {
|
|
@@ -14117,95 +14423,38 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14117
14423
|
};
|
|
14118
14424
|
const sanitizedRootBoxOptions = stripScrollBoxPadding(rootBoxOptions);
|
|
14119
14425
|
const sanitizedRootOptions = rootOptions ? stripScrollBoxPadding(rootOptions) : undefined;
|
|
14120
|
-
const mergedContentOptions = {
|
|
14121
|
-
...forwardedContentPadding,
|
|
14122
|
-
...contentOptions
|
|
14123
|
-
};
|
|
14124
14426
|
super(ctx, {
|
|
14125
14427
|
flexDirection: "row",
|
|
14126
14428
|
alignItems: "stretch",
|
|
14127
14429
|
...sanitizedRootBoxOptions,
|
|
14128
|
-
...sanitizedRootOptions
|
|
14430
|
+
...sanitizedRootOptions,
|
|
14431
|
+
overflow: "hidden"
|
|
14129
14432
|
});
|
|
14130
|
-
const children = [];
|
|
14131
14433
|
try {
|
|
14132
|
-
this.internalId = ScrollBoxRenderable.idCounter++;
|
|
14133
14434
|
this._stickyScroll = stickyScroll;
|
|
14134
14435
|
this._stickyStart = stickyStart;
|
|
14135
14436
|
this.scrollAccel = scrollAcceleration ?? new LinearScrollAccel2;
|
|
14136
|
-
this.
|
|
14137
|
-
|
|
14138
|
-
|
|
14139
|
-
|
|
14140
|
-
|
|
14141
|
-
|
|
14142
|
-
|
|
14143
|
-
|
|
14144
|
-
this.viewport
|
|
14145
|
-
|
|
14146
|
-
|
|
14147
|
-
|
|
14148
|
-
|
|
14149
|
-
|
|
14150
|
-
|
|
14151
|
-
|
|
14152
|
-
|
|
14153
|
-
|
|
14154
|
-
|
|
14155
|
-
this.
|
|
14156
|
-
this.
|
|
14157
|
-
alignSelf: "flex-start",
|
|
14158
|
-
flexShrink: 0,
|
|
14159
|
-
...scrollX ? { minWidth: "100%" } : { minWidth: "100%", maxWidth: "100%" },
|
|
14160
|
-
...scrollY ? { minHeight: "100%" } : { minHeight: "100%", maxHeight: "100%" },
|
|
14161
|
-
onSizeChange: () => {
|
|
14162
|
-
this.recalculateBarProps();
|
|
14163
|
-
},
|
|
14164
|
-
...mergedContentOptions,
|
|
14165
|
-
id: `scroll-box-content-${this.internalId}`
|
|
14166
|
-
});
|
|
14167
|
-
children.push(this.content);
|
|
14168
|
-
this.viewport.add(this.content);
|
|
14169
|
-
this.verticalScrollBar = new ScrollBarRenderable(ctx, {
|
|
14170
|
-
...scrollbarOptions,
|
|
14171
|
-
...verticalScrollbarOptions,
|
|
14172
|
-
arrowOptions: {
|
|
14173
|
-
...scrollbarOptions?.arrowOptions,
|
|
14174
|
-
...verticalScrollbarOptions?.arrowOptions
|
|
14175
|
-
},
|
|
14176
|
-
id: `scroll-box-vertical-scrollbar-${this.internalId}`,
|
|
14177
|
-
orientation: "vertical",
|
|
14178
|
-
onChange: (position) => {
|
|
14179
|
-
if (this.isDestroyed)
|
|
14180
|
-
return;
|
|
14181
|
-
this.content.translateY = -position;
|
|
14182
|
-
this.updateStickyState();
|
|
14183
|
-
}
|
|
14184
|
-
});
|
|
14185
|
-
children.push(this.verticalScrollBar);
|
|
14186
|
-
super.add(this.verticalScrollBar);
|
|
14187
|
-
this.horizontalScrollBar = new ScrollBarRenderable(ctx, {
|
|
14188
|
-
...scrollbarOptions,
|
|
14189
|
-
...horizontalScrollbarOptions,
|
|
14190
|
-
arrowOptions: {
|
|
14191
|
-
...scrollbarOptions?.arrowOptions,
|
|
14192
|
-
...horizontalScrollbarOptions?.arrowOptions
|
|
14193
|
-
},
|
|
14194
|
-
id: `scroll-box-horizontal-scrollbar-${this.internalId}`,
|
|
14195
|
-
orientation: "horizontal",
|
|
14196
|
-
onChange: (position) => {
|
|
14197
|
-
if (this.isDestroyed)
|
|
14198
|
-
return;
|
|
14199
|
-
this.content.translateX = -position;
|
|
14200
|
-
this.updateStickyState();
|
|
14201
|
-
}
|
|
14202
|
-
});
|
|
14203
|
-
children.push(this.horizontalScrollBar);
|
|
14204
|
-
this.wrapper.add(this.horizontalScrollBar);
|
|
14205
|
-
this.recalculateBarProps();
|
|
14206
|
-
if (stickyStart && stickyScroll) {
|
|
14207
|
-
this.applyStickyStart(stickyStart);
|
|
14208
|
-
}
|
|
14437
|
+
this.axes = { x: scrollX, y: scrollY };
|
|
14438
|
+
this._viewportCulling = viewportCulling;
|
|
14439
|
+
this.wrapper = new ScrollBoxWrapper(this);
|
|
14440
|
+
this.viewport = new ScrollBoxViewport(this);
|
|
14441
|
+
this.content = new ScrollBoxContent(this);
|
|
14442
|
+
this.verticalScrollBar = new ScrollBoxBar(this, "vertical");
|
|
14443
|
+
this.horizontalScrollBar = new ScrollBoxBar(this, "horizontal");
|
|
14444
|
+
this.wrapper._assign(wrapperOptions, ScrollBoxWrapper.keys);
|
|
14445
|
+
this.viewport._assign(viewportOptions, ScrollBoxViewport.keys);
|
|
14446
|
+
for (const [bar, own] of [
|
|
14447
|
+
[this.verticalScrollBar, verticalScrollbarOptions],
|
|
14448
|
+
[this.horizontalScrollBar, horizontalScrollbarOptions]
|
|
14449
|
+
]) {
|
|
14450
|
+
bar._assign({ ...scrollbarOptions, ...own, arrowOptions: { ...scrollbarOptions?.arrowOptions, ...own?.arrowOptions } }, ScrollBoxBar.keys);
|
|
14451
|
+
}
|
|
14452
|
+
this.configured = true;
|
|
14453
|
+
this._applyScrollOptions();
|
|
14454
|
+
this._applyScrollArrows(0);
|
|
14455
|
+
this._applyScrollArrows(1);
|
|
14456
|
+
this.content._assign({ ...forwardedContentPadding, ...contentOptions }, ScrollBoxContent.keys);
|
|
14457
|
+
this._refreshScrollHook();
|
|
14209
14458
|
this.selectionListener = () => {
|
|
14210
14459
|
if (this.isDestroyed)
|
|
14211
14460
|
return;
|
|
@@ -14217,14 +14466,149 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14217
14466
|
this._ctx.on("selection", this.selectionListener);
|
|
14218
14467
|
this.setNativeScenePaint();
|
|
14219
14468
|
} catch (error) {
|
|
14220
|
-
this.abortConstruction(error, (run) =>
|
|
14221
|
-
run(() => this.destroySelf());
|
|
14222
|
-
for (let index = children.length - 1;index >= 0; index--) {
|
|
14223
|
-
run(() => children[index].destroyRecursively());
|
|
14224
|
-
}
|
|
14225
|
-
});
|
|
14469
|
+
this.abortConstruction(error, (run) => run(() => this.destroySelf()));
|
|
14226
14470
|
}
|
|
14227
14471
|
}
|
|
14472
|
+
_applyScrollOptions() {
|
|
14473
|
+
if (!this.configured || this.isFreed())
|
|
14474
|
+
return;
|
|
14475
|
+
const sticky = this._stickyScroll && this._stickyStart;
|
|
14476
|
+
this._ctx.nativeScene.setScroll(this, {
|
|
14477
|
+
scrollX: this.axes.x,
|
|
14478
|
+
scrollY: this.axes.y,
|
|
14479
|
+
follow: sticky ? this._stickyStart : "none",
|
|
14480
|
+
culling: this._viewportCulling,
|
|
14481
|
+
padding: this.viewport._edges(),
|
|
14482
|
+
fills: [this.wrapper._fill(), this.viewport._fill(), this.content._fill()],
|
|
14483
|
+
bars: [this.horizontalScrollBar._native(), this.verticalScrollBar._native()]
|
|
14484
|
+
});
|
|
14485
|
+
this.requestRender();
|
|
14486
|
+
}
|
|
14487
|
+
_applyScrollArrows(axis) {
|
|
14488
|
+
if (!this.configured || this.isFreed())
|
|
14489
|
+
return;
|
|
14490
|
+
const bar = axis === 1 ? this.verticalScrollBar : this.horizontalScrollBar;
|
|
14491
|
+
bar._arrows().forEach((arrow, end) => this._ctx.nativeScene.setScrollArrow(this, axis, end, arrow));
|
|
14492
|
+
this.requestRender();
|
|
14493
|
+
}
|
|
14494
|
+
_setContentStyle(apply) {
|
|
14495
|
+
if (this.isFreed())
|
|
14496
|
+
return;
|
|
14497
|
+
apply(this._ctx.nativeScene, this);
|
|
14498
|
+
this.requestRender();
|
|
14499
|
+
}
|
|
14500
|
+
_scrollState() {
|
|
14501
|
+
if (this.isFreed())
|
|
14502
|
+
return this.state;
|
|
14503
|
+
const revision = this._ctx.nativeScene.observedLayoutRevision;
|
|
14504
|
+
if (revision !== undefined && revision === this.stateRevision)
|
|
14505
|
+
return this.state;
|
|
14506
|
+
this.state = this._ctx.nativeScene.getScroll(this);
|
|
14507
|
+
this.stateRevision = revision;
|
|
14508
|
+
return this.state;
|
|
14509
|
+
}
|
|
14510
|
+
_wrapperRect() {
|
|
14511
|
+
const { viewport, bars } = this._scrollState();
|
|
14512
|
+
const horizontal = bars[0];
|
|
14513
|
+
const gutter = horizontal.visible ? horizontal.track.y + horizontal.track.height - viewport.y - viewport.height : 0;
|
|
14514
|
+
return { ...viewport, height: viewport.height + Math.max(0, gutter) };
|
|
14515
|
+
}
|
|
14516
|
+
_scrollAxis(axis, value, relative, reapply = false) {
|
|
14517
|
+
if (this.isFreed())
|
|
14518
|
+
return;
|
|
14519
|
+
this.assertMutable();
|
|
14520
|
+
value ??= 0;
|
|
14521
|
+
if (Number.isNaN(value))
|
|
14522
|
+
throw new RangeError("Scene scroll positions must be finite numbers");
|
|
14523
|
+
const x = axis === 0 ? value : 0;
|
|
14524
|
+
const y = axis === 1 ? value : 0;
|
|
14525
|
+
this.commitScroll(() => this._ctx.nativeScene.scrollTo(this, x, y, axis !== 0 || relative, axis !== 1 || relative, reapply));
|
|
14526
|
+
}
|
|
14527
|
+
commitScroll(scroll) {
|
|
14528
|
+
const before = this._scrollState().offset;
|
|
14529
|
+
const state = scroll();
|
|
14530
|
+
this.state = state;
|
|
14531
|
+
this.stateRevision = this._ctx.nativeScene.observedLayoutRevision;
|
|
14532
|
+
const moved = (state.offset[0] !== before[0] ? 1 : 0) | (state.offset[1] !== before[1] ? 2 : 0);
|
|
14533
|
+
if (moved)
|
|
14534
|
+
this.requestRender();
|
|
14535
|
+
this.notifyOffsets(state, moved);
|
|
14536
|
+
}
|
|
14537
|
+
notifyOffsets(state, moved) {
|
|
14538
|
+
for (const axis of [1, 0]) {
|
|
14539
|
+
if ((moved & axis + 1) === 0)
|
|
14540
|
+
continue;
|
|
14541
|
+
(axis === 1 ? this.verticalScrollBar : this.horizontalScrollBar)._emitChange(state.offset[axis]);
|
|
14542
|
+
if (this.isDestroyed)
|
|
14543
|
+
return;
|
|
14544
|
+
}
|
|
14545
|
+
}
|
|
14546
|
+
listening() {
|
|
14547
|
+
return this.verticalScrollBar?._listening() || this.horizontalScrollBar?._listening() || this.content?._listening() || this.viewport?._listening() || this.layoutCallbacks.length > 0;
|
|
14548
|
+
}
|
|
14549
|
+
_refreshScrollHook(adding = false) {
|
|
14550
|
+
if (!this.configured || this.isFreed())
|
|
14551
|
+
return;
|
|
14552
|
+
const listening = adding || this.listening();
|
|
14553
|
+
if (listening === this.scrollHook)
|
|
14554
|
+
return;
|
|
14555
|
+
this.scrollHook = listening;
|
|
14556
|
+
this.refreshNativeSceneHooks();
|
|
14557
|
+
}
|
|
14558
|
+
notifyScroll() {
|
|
14559
|
+
const state = this._scrollState();
|
|
14560
|
+
this.notifyOffsets(state, state.changes);
|
|
14561
|
+
if (!this.isDestroyed && state.changes & 8)
|
|
14562
|
+
this.viewport._emitResize();
|
|
14563
|
+
if (!this.isDestroyed && state.changes & 4)
|
|
14564
|
+
this.content._emitResize();
|
|
14565
|
+
if (this.isDestroyed || !(state.changes & 16))
|
|
14566
|
+
return;
|
|
14567
|
+
const frame = this._ctx.frameId;
|
|
14568
|
+
const due = this.layoutCallbacks.filter((entry) => entry.frame < frame);
|
|
14569
|
+
this.layoutCallbacks = this.layoutCallbacks.filter((entry) => entry.frame >= frame);
|
|
14570
|
+
if (this.layoutCallbacks.length > 0)
|
|
14571
|
+
this._ctx.nativeScene.scrollRequest(this, "layout", null);
|
|
14572
|
+
let failure;
|
|
14573
|
+
for (const { callback } of due) {
|
|
14574
|
+
if (this.isDestroyed)
|
|
14575
|
+
break;
|
|
14576
|
+
try {
|
|
14577
|
+
callback();
|
|
14578
|
+
} catch (error) {
|
|
14579
|
+
failure ??= { error };
|
|
14580
|
+
}
|
|
14581
|
+
}
|
|
14582
|
+
this._refreshScrollHook();
|
|
14583
|
+
if (failure)
|
|
14584
|
+
throw failure.error;
|
|
14585
|
+
}
|
|
14586
|
+
afterLayout(callback) {
|
|
14587
|
+
if (this.isFreed())
|
|
14588
|
+
return;
|
|
14589
|
+
this.assertMutable();
|
|
14590
|
+
this.layoutCallbacks.push({ frame: this._ctx.frameId, callback });
|
|
14591
|
+
this._refreshScrollHook();
|
|
14592
|
+
this._ctx.nativeScene.scrollRequest(this, "layout", null);
|
|
14593
|
+
this.requestRender();
|
|
14594
|
+
}
|
|
14595
|
+
anchor(node) {
|
|
14596
|
+
if (this.isFreed())
|
|
14597
|
+
return () => {};
|
|
14598
|
+
this.assertMutable();
|
|
14599
|
+
this._ctx.nativeScene.scrollRequest(this, "anchor", node);
|
|
14600
|
+
const token = {};
|
|
14601
|
+
this.anchorToken = token;
|
|
14602
|
+
return () => {
|
|
14603
|
+
if (this.anchorToken !== token || this.isFreed())
|
|
14604
|
+
return;
|
|
14605
|
+
this._ctx.nativeScene.scrollRequest(this, "anchor", null);
|
|
14606
|
+
this.anchorToken = undefined;
|
|
14607
|
+
};
|
|
14608
|
+
}
|
|
14609
|
+
get primaryAxis() {
|
|
14610
|
+
return this.content._row ? "row" : "column";
|
|
14611
|
+
}
|
|
14228
14612
|
onUpdate(deltaTime) {
|
|
14229
14613
|
this.handleAutoScroll(deltaTime);
|
|
14230
14614
|
}
|
|
@@ -14238,120 +14622,42 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14238
14622
|
this.horizontalScrollBar.scrollBy(delta.x, unit);
|
|
14239
14623
|
}
|
|
14240
14624
|
}
|
|
14241
|
-
scrollChildIntoView(
|
|
14242
|
-
const
|
|
14243
|
-
if (!
|
|
14625
|
+
scrollChildIntoView(child, options = {}) {
|
|
14626
|
+
const node = typeof child === "string" ? this.findDescendantById(child) : child;
|
|
14627
|
+
if (!node || this.isFreed())
|
|
14244
14628
|
return;
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
const viewportSize = viewportEnd - viewportStart;
|
|
14248
|
-
const elementStartOutside = elementStart < viewportStart;
|
|
14249
|
-
const elementEndOutside = elementEnd > viewportEnd;
|
|
14250
|
-
if (elementStartOutside && elementEndOutside) {
|
|
14251
|
-
return 0;
|
|
14252
|
-
}
|
|
14253
|
-
if (elementStartOutside && elementSize < viewportSize || elementEndOutside && elementSize > viewportSize) {
|
|
14254
|
-
return elementStart - viewportStart;
|
|
14255
|
-
}
|
|
14256
|
-
if (elementStartOutside && elementSize > viewportSize || elementEndOutside && elementSize < viewportSize) {
|
|
14257
|
-
return elementEnd - viewportEnd;
|
|
14258
|
-
}
|
|
14259
|
-
return 0;
|
|
14260
|
-
};
|
|
14261
|
-
const childTop = child.y;
|
|
14262
|
-
const childBottom = child.y + child.height;
|
|
14263
|
-
const viewportTop = this.viewport.y;
|
|
14264
|
-
const viewportBottom = this.viewport.y + this.viewport.height;
|
|
14265
|
-
const dy = getNearestDelta(childTop, childBottom, viewportTop, viewportBottom);
|
|
14266
|
-
const childLeft = child.x;
|
|
14267
|
-
const childRight = child.x + child.width;
|
|
14268
|
-
const viewportLeft = this.viewport.x;
|
|
14269
|
-
const viewportRight = this.viewport.x + this.viewport.width;
|
|
14270
|
-
const dx = getNearestDelta(childLeft, childRight, viewportLeft, viewportRight);
|
|
14271
|
-
if (dx !== 0 || dy !== 0) {
|
|
14272
|
-
this.scrollBy({ x: dx, y: dy });
|
|
14273
|
-
}
|
|
14629
|
+
this.assertMutable();
|
|
14630
|
+
this.commitScroll(() => this._ctx.nativeScene.scrollRequest(this, "into-view", node, options.align, options.inset));
|
|
14274
14631
|
}
|
|
14275
14632
|
scrollTo(position) {
|
|
14276
14633
|
if (typeof position === "number") {
|
|
14277
|
-
this.
|
|
14634
|
+
this._scrollAxis(1, position, false, true);
|
|
14278
14635
|
} else {
|
|
14279
|
-
this.
|
|
14636
|
+
this._scrollAxis(1, position.y, false, true);
|
|
14280
14637
|
if (this.isDestroyed)
|
|
14281
14638
|
return;
|
|
14282
|
-
this.
|
|
14283
|
-
}
|
|
14284
|
-
}
|
|
14285
|
-
isAtStickyPosition() {
|
|
14286
|
-
if (!this._stickyScroll || !this._stickyStart) {
|
|
14287
|
-
return false;
|
|
14288
|
-
}
|
|
14289
|
-
const maxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
|
|
14290
|
-
const maxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
|
|
14291
|
-
switch (this._stickyStart) {
|
|
14292
|
-
case "top":
|
|
14293
|
-
return this.scrollTop === 0;
|
|
14294
|
-
case "bottom":
|
|
14295
|
-
return this.scrollTop >= maxScrollTop;
|
|
14296
|
-
case "left":
|
|
14297
|
-
return this.scrollLeft === 0;
|
|
14298
|
-
case "right":
|
|
14299
|
-
return this.scrollLeft >= maxScrollLeft;
|
|
14300
|
-
default:
|
|
14301
|
-
return false;
|
|
14302
|
-
}
|
|
14303
|
-
}
|
|
14304
|
-
isAtStickyReengagePoint(stickyStart, maxScrollTop, maxScrollLeft) {
|
|
14305
|
-
switch (stickyStart) {
|
|
14306
|
-
case "top":
|
|
14307
|
-
return maxScrollTop > 0 && this.scrollTop <= 0;
|
|
14308
|
-
case "bottom":
|
|
14309
|
-
return maxScrollTop > 0 && this.scrollTop >= maxScrollTop - 1;
|
|
14310
|
-
case "left":
|
|
14311
|
-
return maxScrollLeft > 0 && this.scrollLeft <= 0;
|
|
14312
|
-
case "right":
|
|
14313
|
-
return maxScrollLeft > 0 && this.scrollLeft >= maxScrollLeft - 1;
|
|
14639
|
+
this._scrollAxis(0, position.x, false, true);
|
|
14314
14640
|
}
|
|
14315
14641
|
}
|
|
14316
|
-
add(obj, index) {
|
|
14317
|
-
return this.content.add(obj, index);
|
|
14318
|
-
}
|
|
14319
|
-
insertBefore(obj, anchor) {
|
|
14320
|
-
return this.content.insertBefore(obj, anchor);
|
|
14321
|
-
}
|
|
14322
|
-
remove(child) {
|
|
14323
|
-
if (child.parent === this) {
|
|
14324
|
-
super.remove(child);
|
|
14325
|
-
return;
|
|
14326
|
-
}
|
|
14327
|
-
this.content.remove(child);
|
|
14328
|
-
}
|
|
14329
|
-
getChildren() {
|
|
14330
|
-
return this.content.getChildren();
|
|
14331
|
-
}
|
|
14332
|
-
getRenderable(id) {
|
|
14333
|
-
return this.content.getRenderable(id);
|
|
14334
|
-
}
|
|
14335
14642
|
scrollByWheel(event) {
|
|
14336
14643
|
const dir = wheelDirection(event);
|
|
14337
14644
|
const vertical = dir === "up" || dir === "down";
|
|
14338
14645
|
if (!vertical && dir !== "left" && dir !== "right")
|
|
14339
14646
|
return false;
|
|
14340
|
-
const
|
|
14647
|
+
const axis = vertical ? 1 : 0;
|
|
14341
14648
|
const sign = dir === "up" || dir === "left" ? -1 : 1;
|
|
14342
|
-
const
|
|
14343
|
-
|
|
14649
|
+
const { offset, max } = this._scrollState();
|
|
14650
|
+
const position = offset[axis];
|
|
14651
|
+
if (sign < 0 ? position <= 0 : position >= max[axis])
|
|
14344
14652
|
return false;
|
|
14345
14653
|
let remainder = vertical ? this.scrollAccumulatorY : this.scrollAccumulatorX;
|
|
14346
14654
|
if (remainder * sign < 0)
|
|
14347
14655
|
remainder = 0;
|
|
14348
14656
|
remainder += sign * (event.scroll?.delta ?? 0) * this.scrollAccel.tick(Date.now());
|
|
14349
14657
|
const step = Math.trunc(remainder);
|
|
14350
|
-
if (step !== 0
|
|
14351
|
-
this.
|
|
14352
|
-
|
|
14353
|
-
this.scrollLeft = position + step;
|
|
14354
|
-
remainder = bar.scrollPosition - position === step ? remainder - step : 0;
|
|
14658
|
+
if (step !== 0)
|
|
14659
|
+
this._scrollAxis(axis, position + step, false);
|
|
14660
|
+
remainder = this._scrollState().offset[axis] - position === step ? remainder - step : 0;
|
|
14355
14661
|
if (vertical)
|
|
14356
14662
|
this.scrollAccumulatorY = remainder;
|
|
14357
14663
|
else
|
|
@@ -14361,23 +14667,97 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14361
14667
|
onMouseEvent(event) {
|
|
14362
14668
|
if (event.type === "scroll")
|
|
14363
14669
|
scrollOnce(event, this, () => this.scrollByWheel(event));
|
|
14670
|
+
if (this.handleBarMouse(event))
|
|
14671
|
+
return;
|
|
14364
14672
|
if (event.type === "drag" && event.isDragging) {
|
|
14365
14673
|
this.updateAutoScroll(event.x, event.y);
|
|
14366
14674
|
} else if (event.type === "up") {
|
|
14367
14675
|
this.stopAutoScroll();
|
|
14368
14676
|
}
|
|
14369
14677
|
}
|
|
14370
|
-
|
|
14371
|
-
|
|
14372
|
-
|
|
14373
|
-
|
|
14374
|
-
|
|
14678
|
+
handleBarMouse(event) {
|
|
14679
|
+
const press = this.barPress;
|
|
14680
|
+
if (press && (event.type === "drag" || event.type === "up" || event.type === "drag-end")) {
|
|
14681
|
+
if ("offset" in press && event.type !== "drag-end")
|
|
14682
|
+
this.dragThumb(press, event);
|
|
14683
|
+
if (event.type === "up")
|
|
14684
|
+
this.endBarPress();
|
|
14685
|
+
event.stopPropagation();
|
|
14686
|
+
return true;
|
|
14687
|
+
}
|
|
14688
|
+
if (event.type !== "down" || event.button !== 0 || event.target !== this)
|
|
14689
|
+
return false;
|
|
14690
|
+
const { bars } = this._scrollState();
|
|
14691
|
+
for (const axis of [1, 0]) {
|
|
14692
|
+
const bar = bars[axis];
|
|
14693
|
+
if (!bar.visible)
|
|
14694
|
+
continue;
|
|
14695
|
+
const part = axis === 1 ? this.verticalScrollBar : this.horizontalScrollBar;
|
|
14696
|
+
const inside = (rect) => event.x >= rect.x && event.x < rect.x + rect.width && event.y >= rect.y && event.y < rect.y + rect.height;
|
|
14697
|
+
const arrow = part.showArrows ? inside(bar.startArrow) ? -1 : inside(bar.endArrow) ? 1 : 0 : 0;
|
|
14698
|
+
if (arrow === 0 && !inside(bar.track))
|
|
14699
|
+
continue;
|
|
14700
|
+
event.stopPropagation();
|
|
14701
|
+
event.preventDefault();
|
|
14702
|
+
this.endBarPress();
|
|
14703
|
+
if (arrow !== 0)
|
|
14704
|
+
this.pressArrow(axis, arrow, part);
|
|
14705
|
+
else
|
|
14706
|
+
this.pressTrack(axis, event);
|
|
14375
14707
|
return true;
|
|
14376
14708
|
}
|
|
14377
|
-
|
|
14709
|
+
return false;
|
|
14710
|
+
}
|
|
14711
|
+
pressArrow(axis, arrow, part) {
|
|
14712
|
+
const press = { axis, arrow, timer: undefined };
|
|
14713
|
+
this.barPress = press;
|
|
14714
|
+
const step = (amount, delay) => {
|
|
14715
|
+
part.scrollBy(arrow * amount, "viewport");
|
|
14716
|
+
if (this.barPress !== press)
|
|
14717
|
+
return;
|
|
14718
|
+
press.timer = this._ctx.clock.setTimeout(() => step(delay === 500 ? 0.5 : 0.2, 200), delay);
|
|
14719
|
+
};
|
|
14720
|
+
step(0.5, 500);
|
|
14721
|
+
}
|
|
14722
|
+
thumbPointer(axis, event) {
|
|
14723
|
+
const bar = this._scrollState().bars[axis];
|
|
14724
|
+
const along = axis === 1 ? event.y - bar.track.y : event.x - bar.track.x;
|
|
14725
|
+
const length = axis === 1 ? bar.track.height : bar.track.width;
|
|
14726
|
+
return {
|
|
14727
|
+
at: Math.max(0, Math.min(length, along)) * 2,
|
|
14728
|
+
length: length * 2,
|
|
14729
|
+
start: bar.thumbStart,
|
|
14730
|
+
size: bar.thumbSize
|
|
14731
|
+
};
|
|
14732
|
+
}
|
|
14733
|
+
pressTrack(axis, event) {
|
|
14734
|
+
let thumb = this.thumbPointer(axis, event);
|
|
14735
|
+
const inThumb = thumb.at >= Math.floor(thumb.start / 2) * 2 && thumb.at < Math.ceil((thumb.start + thumb.size) / 2) * 2;
|
|
14736
|
+
if (!inThumb) {
|
|
14737
|
+
const max = this._scrollState().max[axis];
|
|
14738
|
+
this._scrollAxis(axis, thumb.length === 0 ? 0 : thumb.at / thumb.length * max, false);
|
|
14739
|
+
if (this.isDestroyed)
|
|
14740
|
+
return;
|
|
14741
|
+
thumb = this.thumbPointer(axis, event);
|
|
14742
|
+
}
|
|
14743
|
+
this.barPress = { axis, offset: Math.max(0, Math.min(thumb.size, thumb.at - thumb.start)) };
|
|
14744
|
+
}
|
|
14745
|
+
dragThumb(press, event) {
|
|
14746
|
+
const thumb = this.thumbPointer(press.axis, event);
|
|
14747
|
+
const span = Math.max(0, thumb.length - thumb.size);
|
|
14748
|
+
const start = Math.max(0, Math.min(span, thumb.at - press.offset));
|
|
14749
|
+
this._scrollAxis(press.axis, span === 0 ? 0 : start / span * this._scrollState().max[press.axis], false);
|
|
14750
|
+
}
|
|
14751
|
+
endBarPress() {
|
|
14752
|
+
const press = this.barPress;
|
|
14753
|
+
this.barPress = undefined;
|
|
14754
|
+
if (press && "timer" in press && press.timer !== undefined)
|
|
14755
|
+
this._ctx.clock.clearTimeout(press.timer);
|
|
14756
|
+
}
|
|
14757
|
+
handleKeyPress(key) {
|
|
14758
|
+
if (this.verticalScrollBar.handleKeyPress(key) || this.horizontalScrollBar.handleKeyPress(key)) {
|
|
14378
14759
|
this.scrollAccel.reset();
|
|
14379
14760
|
this.resetScrollAccumulators();
|
|
14380
|
-
this.syncManualScrollState();
|
|
14381
14761
|
return true;
|
|
14382
14762
|
}
|
|
14383
14763
|
return false;
|
|
@@ -14460,8 +14840,7 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14460
14840
|
if (distToLeft <= this.autoScrollThresholdHorizontal) {
|
|
14461
14841
|
return this.scrollLeft > 0 ? -1 : 0;
|
|
14462
14842
|
} else if (distToRight <= this.autoScrollThresholdHorizontal) {
|
|
14463
|
-
|
|
14464
|
-
return this.scrollLeft < maxScrollLeft ? 1 : 0;
|
|
14843
|
+
return this.scrollLeft < this._scrollState().max[0] ? 1 : 0;
|
|
14465
14844
|
}
|
|
14466
14845
|
return 0;
|
|
14467
14846
|
}
|
|
@@ -14472,8 +14851,7 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14472
14851
|
if (distToTop <= this.autoScrollThresholdVertical) {
|
|
14473
14852
|
return this.scrollTop > 0 ? -1 : 0;
|
|
14474
14853
|
} else if (distToBottom <= this.autoScrollThresholdVertical) {
|
|
14475
|
-
|
|
14476
|
-
return this.scrollTop < maxScrollTop ? 1 : 0;
|
|
14854
|
+
return this.scrollTop < this._scrollState().max[1] ? 1 : 0;
|
|
14477
14855
|
}
|
|
14478
14856
|
return 0;
|
|
14479
14857
|
}
|
|
@@ -14493,115 +14871,31 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14493
14871
|
return this.autoScrollSpeedSlow;
|
|
14494
14872
|
}
|
|
14495
14873
|
}
|
|
14496
|
-
recalculateBarProps() {
|
|
14497
|
-
if (this.isDestroyed)
|
|
14498
|
-
return;
|
|
14499
|
-
const wasApplyingStickyScroll = this._isApplyingStickyScroll;
|
|
14500
|
-
this._isApplyingStickyScroll = true;
|
|
14501
|
-
try {
|
|
14502
|
-
this.verticalScrollBar.scrollSize = this.content.height;
|
|
14503
|
-
if (this.isDestroyed)
|
|
14504
|
-
return;
|
|
14505
|
-
this.verticalScrollBar.viewportSize = this.viewport.height;
|
|
14506
|
-
if (this.isDestroyed)
|
|
14507
|
-
return;
|
|
14508
|
-
this.horizontalScrollBar.scrollSize = this.content.width;
|
|
14509
|
-
if (this.isDestroyed)
|
|
14510
|
-
return;
|
|
14511
|
-
this.horizontalScrollBar.viewportSize = this.viewport.width;
|
|
14512
|
-
if (this.isDestroyed)
|
|
14513
|
-
return;
|
|
14514
|
-
if (this._stickyScroll) {
|
|
14515
|
-
const newMaxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
|
|
14516
|
-
const newMaxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
|
|
14517
|
-
const stickyStart = this._stickyStart;
|
|
14518
|
-
if (stickyStart && !this._hasManualScroll) {
|
|
14519
|
-
this.applyStickyStart(stickyStart);
|
|
14520
|
-
} else if (stickyStart && this._hasManualScroll && this.isAtStickyReengagePoint(stickyStart, newMaxScrollTop, newMaxScrollLeft)) {
|
|
14521
|
-
this._hasManualScroll = false;
|
|
14522
|
-
this.applyStickyStart(stickyStart);
|
|
14523
|
-
} else if (!this._hasManualScroll) {
|
|
14524
|
-
if (this._stickyScrollTop) {
|
|
14525
|
-
this.scrollTop = 0;
|
|
14526
|
-
} else if (this._stickyScrollBottom && newMaxScrollTop > 0) {
|
|
14527
|
-
this.scrollTop = newMaxScrollTop;
|
|
14528
|
-
}
|
|
14529
|
-
if (this.isDestroyed)
|
|
14530
|
-
return;
|
|
14531
|
-
if (this._stickyScrollLeft) {
|
|
14532
|
-
this.scrollLeft = 0;
|
|
14533
|
-
} else if (this._stickyScrollRight && newMaxScrollLeft > 0) {
|
|
14534
|
-
this.scrollLeft = newMaxScrollLeft;
|
|
14535
|
-
}
|
|
14536
|
-
}
|
|
14537
|
-
}
|
|
14538
|
-
} finally {
|
|
14539
|
-
this._isApplyingStickyScroll = wasApplyingStickyScroll;
|
|
14540
|
-
}
|
|
14541
|
-
}
|
|
14542
|
-
set padding(value) {
|
|
14543
|
-
this.content.padding = value;
|
|
14544
|
-
this.requestRender();
|
|
14545
|
-
}
|
|
14546
|
-
set paddingX(value) {
|
|
14547
|
-
this.content.paddingX = value;
|
|
14548
|
-
this.requestRender();
|
|
14549
|
-
}
|
|
14550
|
-
set paddingY(value) {
|
|
14551
|
-
this.content.paddingY = value;
|
|
14552
|
-
this.requestRender();
|
|
14553
|
-
}
|
|
14554
|
-
set paddingTop(value) {
|
|
14555
|
-
this.content.paddingTop = value;
|
|
14556
|
-
this.requestRender();
|
|
14557
|
-
}
|
|
14558
|
-
set paddingRight(value) {
|
|
14559
|
-
this.content.paddingRight = value;
|
|
14560
|
-
this.requestRender();
|
|
14561
|
-
}
|
|
14562
|
-
set paddingBottom(value) {
|
|
14563
|
-
this.content.paddingBottom = value;
|
|
14564
|
-
this.requestRender();
|
|
14565
|
-
}
|
|
14566
|
-
set paddingLeft(value) {
|
|
14567
|
-
this.content.paddingLeft = value;
|
|
14568
|
-
this.requestRender();
|
|
14569
|
-
}
|
|
14570
14874
|
set rootOptions(options) {
|
|
14571
|
-
this.assignOptions(this, options);
|
|
14875
|
+
this.assignOptions(this, options && stripScrollBoxPadding(options));
|
|
14876
|
+
if (options)
|
|
14877
|
+
this.content._assign(pickScrollBoxPadding(options), ScrollBoxContent.keys);
|
|
14572
14878
|
if (!this.isDestroyed)
|
|
14573
14879
|
this.requestRender();
|
|
14574
14880
|
}
|
|
14575
14881
|
set wrapperOptions(options) {
|
|
14576
|
-
this.
|
|
14577
|
-
if (!this.isDestroyed)
|
|
14578
|
-
this.requestRender();
|
|
14882
|
+
this.wrapper._assign(options, ScrollBoxWrapper.keys);
|
|
14579
14883
|
}
|
|
14580
14884
|
set viewportOptions(options) {
|
|
14581
|
-
this.
|
|
14582
|
-
if (!this.isDestroyed)
|
|
14583
|
-
this.requestRender();
|
|
14885
|
+
this.viewport._assign(options, ScrollBoxViewport.keys);
|
|
14584
14886
|
}
|
|
14585
14887
|
set contentOptions(options) {
|
|
14586
|
-
this.
|
|
14587
|
-
if (!this.isDestroyed)
|
|
14588
|
-
this.requestRender();
|
|
14888
|
+
this.content._assign(options, ScrollBoxContent.keys);
|
|
14589
14889
|
}
|
|
14590
14890
|
set scrollbarOptions(options) {
|
|
14591
|
-
this.
|
|
14592
|
-
this.
|
|
14593
|
-
if (!this.isDestroyed)
|
|
14594
|
-
this.requestRender();
|
|
14891
|
+
this.verticalScrollBar._assign(options ?? { onChange: undefined }, ScrollBoxBar.keys);
|
|
14892
|
+
this.horizontalScrollBar._assign(options ?? { onChange: undefined }, ScrollBoxBar.keys);
|
|
14595
14893
|
}
|
|
14596
14894
|
set verticalScrollbarOptions(options) {
|
|
14597
|
-
this.
|
|
14598
|
-
if (!this.isDestroyed)
|
|
14599
|
-
this.requestRender();
|
|
14895
|
+
this.verticalScrollBar._assign(options ?? { onChange: undefined }, ScrollBoxBar.keys);
|
|
14600
14896
|
}
|
|
14601
14897
|
set horizontalScrollbarOptions(options) {
|
|
14602
|
-
this.
|
|
14603
|
-
if (!this.isDestroyed)
|
|
14604
|
-
this.requestRender();
|
|
14898
|
+
this.horizontalScrollBar._assign(options ?? { onChange: undefined }, ScrollBoxBar.keys);
|
|
14605
14899
|
}
|
|
14606
14900
|
get scrollAcceleration() {
|
|
14607
14901
|
return this.scrollAccel;
|
|
@@ -14610,15 +14904,22 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14610
14904
|
this.scrollAccel = value;
|
|
14611
14905
|
}
|
|
14612
14906
|
get viewportCulling() {
|
|
14613
|
-
return this.
|
|
14907
|
+
return this._viewportCulling;
|
|
14614
14908
|
}
|
|
14615
14909
|
set viewportCulling(value) {
|
|
14616
|
-
this.
|
|
14617
|
-
|
|
14910
|
+
this.setScrollOption(() => this._viewportCulling = value ?? true);
|
|
14911
|
+
}
|
|
14912
|
+
get overflow() {
|
|
14913
|
+
return "hidden";
|
|
14618
14914
|
}
|
|
14915
|
+
set overflow(_value) {}
|
|
14619
14916
|
destroySelf() {
|
|
14917
|
+
if (!this.isFreed())
|
|
14918
|
+
this._scrollState();
|
|
14620
14919
|
const selectionListener = this.selectionListener;
|
|
14621
14920
|
this.selectionListener = undefined;
|
|
14921
|
+
this.layoutCallbacks = [];
|
|
14922
|
+
this.endBarPress();
|
|
14622
14923
|
this.runCleanup((run) => {
|
|
14623
14924
|
if (selectionListener)
|
|
14624
14925
|
run(() => this._ctx.off("selection", selectionListener));
|
|
@@ -14626,6 +14927,14 @@ class ScrollBoxRenderable extends BoxRenderable2 {
|
|
|
14626
14927
|
});
|
|
14627
14928
|
}
|
|
14628
14929
|
}
|
|
14930
|
+
for (const key of SCROLLBOX_PADDING_KEYS) {
|
|
14931
|
+
Object.defineProperty(ScrollBoxRenderable.prototype, key, {
|
|
14932
|
+
configurable: true,
|
|
14933
|
+
set(value) {
|
|
14934
|
+
this.content[key] = value;
|
|
14935
|
+
}
|
|
14936
|
+
});
|
|
14937
|
+
}
|
|
14629
14938
|
// src/renderables/Select.ts
|
|
14630
14939
|
var defaultSelectKeybindings = [
|
|
14631
14940
|
{ name: "up", action: "move-up" },
|
|
@@ -15405,8 +15714,9 @@ class TimeToFirstDrawRenderable extends Renderable2 {
|
|
|
15405
15714
|
const content = `${this.label}: ${this._runtimeMs.toFixed(this.precision)}ms`;
|
|
15406
15715
|
const maxWidth = Math.max(this.width, 1);
|
|
15407
15716
|
const visibleContent = truncateToCellWidth(buffer, content, maxWidth);
|
|
15408
|
-
const
|
|
15409
|
-
|
|
15717
|
+
const [x, y] = this._paintOrigin(buffer);
|
|
15718
|
+
const centeredX = x + Math.max(0, Math.floor((maxWidth - visibleContent.width) / 2));
|
|
15719
|
+
buffer.drawText(visibleContent.text, centeredX, y, this.textColor);
|
|
15410
15720
|
}
|
|
15411
15721
|
normalizePrecision(value) {
|
|
15412
15722
|
if (!Number.isFinite(value)) {
|
|
@@ -15538,7 +15848,11 @@ export {
|
|
|
15538
15848
|
SYNTHWAVE_MATRIX,
|
|
15539
15849
|
ScrollBarRenderable,
|
|
15540
15850
|
ScrollBox,
|
|
15851
|
+
ScrollBoxBar,
|
|
15852
|
+
ScrollBoxContent,
|
|
15541
15853
|
ScrollBoxRenderable,
|
|
15854
|
+
ScrollBoxViewport,
|
|
15855
|
+
ScrollBoxWrapper,
|
|
15542
15856
|
Select,
|
|
15543
15857
|
SelectRenderable,
|
|
15544
15858
|
SelectRenderableEvents,
|
|
@@ -15706,6 +16020,7 @@ export {
|
|
|
15706
16020
|
resolveRenderLib2 as resolveRenderLib,
|
|
15707
16021
|
reverse2 as reverse,
|
|
15708
16022
|
rgbToHex2 as rgbToHex,
|
|
16023
|
+
scrollUnitSize,
|
|
15709
16024
|
setRenderLibPath2 as setRenderLibPath,
|
|
15710
16025
|
setupAudio,
|
|
15711
16026
|
strikethrough2 as strikethrough,
|
|
@@ -15723,5 +16038,5 @@ export {
|
|
|
15723
16038
|
yellow2 as yellow
|
|
15724
16039
|
};
|
|
15725
16040
|
|
|
15726
|
-
//# debugId=
|
|
16041
|
+
//# debugId=B48247C5EAE62C3D64756E2164756E21
|
|
15727
16042
|
//# sourceMappingURL=index.bun.js.map
|