@papercraftgames/estragon 0.1.0-beta.36 → 0.1.0-beta.37
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.
|
@@ -20,11 +20,16 @@ static func tracks(specs: Array, items: Array, placements: Array, axis: int, ref
|
|
|
20
20
|
var occupied := gap*(span-1)
|
|
21
21
|
var eligible: Array = []
|
|
22
22
|
var fractions_only := true
|
|
23
|
+
var intrinsic_track := false
|
|
23
24
|
for index in range(start,start+span):
|
|
24
25
|
occupied += sizes[index]
|
|
25
26
|
if specs[index].unit in ["auto","fr"]: eligible.append(index)
|
|
26
27
|
if specs[index].unit!="fr": fractions_only = false
|
|
28
|
+
if specs[index].unit=="auto": intrinsic_track = true
|
|
27
29
|
var contribution: float = items[i].get("contribution",items[i].preferred)[axis]
|
|
30
|
+
# Auto tracks request the natural preferred extent. The smaller
|
|
31
|
+
# unbreakable Wrap floor belongs to distributable fraction tracks.
|
|
32
|
+
if intrinsic_track: contribution = items[i].preferred[axis]
|
|
28
33
|
var viewport_floor: float = items[i].get("scroll_floor",Vector3(-1,-1,-1))[axis]
|
|
29
34
|
# A definite fraction cell assigns a scrolling viewport. Its hidden
|
|
30
35
|
# content is not a minimum viewport size; auto rows remain intrinsic.
|
|
@@ -80,6 +80,7 @@ var arrange_count: int = 0
|
|
|
80
80
|
var _measure_dirty: bool = true
|
|
81
81
|
var _arrange_dirty: bool = true
|
|
82
82
|
var _parent: WeakRef
|
|
83
|
+
var _parent_index := -1
|
|
83
84
|
|
|
84
85
|
var default_padding := Vector4.ZERO
|
|
85
86
|
|
|
@@ -269,10 +270,12 @@ func set_children(values: Array) -> Error:
|
|
|
269
270
|
for child in children:
|
|
270
271
|
if not values.has(child):
|
|
271
272
|
child._parent = null
|
|
273
|
+
child._parent_index = -1
|
|
272
274
|
children = values.duplicate()
|
|
273
275
|
grid_definition = {}
|
|
274
|
-
for
|
|
275
|
-
|
|
276
|
+
for index in range(children.size()):
|
|
277
|
+
children[index]._parent = weakref(self)
|
|
278
|
+
children[index]._parent_index = index
|
|
276
279
|
invalidate()
|
|
277
280
|
return OK
|
|
278
281
|
|
|
@@ -301,6 +304,16 @@ func track_contribution() -> Vector3:
|
|
|
301
304
|
result[axis] = intrinsic[axis]
|
|
302
305
|
for child in children: result[axis] = maxf(result[axis],maxf(child.measured[axis],child.minimum()[axis])+child.outer_extent()[axis])
|
|
303
306
|
result[axis] += leading(padding+border)[axis]+trailing(padding+border)[axis]
|
|
307
|
+
elif strategy=="stack" and not children.is_empty():
|
|
308
|
+
var natural := Vector3.ZERO
|
|
309
|
+
for child in children:
|
|
310
|
+
var contribution: Vector3 = child.track_contribution()+child.outer_extent()
|
|
311
|
+
for index in range(3):
|
|
312
|
+
if index==axis: natural[index] += contribution[index]
|
|
313
|
+
else: natural[index] = maxf(natural[index],contribution[index])
|
|
314
|
+
natural[axis] += _main_gap()*maxi(0,children.size()-1)
|
|
315
|
+
for index in range(3):
|
|
316
|
+
if requested[index]<0 and (index>1 or scroll_axes[index]==0): result[index] = maxf(intrinsic[index],natural[index])+leading(padding+border)[index]+trailing(padding+border)[index]
|
|
304
317
|
return constrain(result)
|
|
305
318
|
|
|
306
319
|
func _items() -> Array:
|
|
@@ -362,18 +375,45 @@ func _grid(items: Array, content: Vector3) -> Dictionary:
|
|
|
362
375
|
|
|
363
376
|
# Allocation-dependent measurement is a bounded second pass in this same core.
|
|
364
377
|
# Only independently assigned axes may supply a basis; auto cycles stay absent.
|
|
378
|
+
func _uses_capacity(index: int) -> bool:
|
|
379
|
+
if requested[index]>=0 or index<2 and scroll_axes[index]>0: return false
|
|
380
|
+
if strategy=="wrap" and index==axis: return true
|
|
381
|
+
for child in children:
|
|
382
|
+
if child._uses_capacity(index): return true
|
|
383
|
+
return false
|
|
384
|
+
|
|
365
385
|
func set_capacity(value: Vector3) -> void:
|
|
366
386
|
if not transparent:
|
|
367
|
-
if strategy
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
387
|
+
if strategy=="wrap":
|
|
388
|
+
if requested[axis]>=0: return
|
|
389
|
+
var main: float = value[axis]
|
|
390
|
+
value = Vector3(-1,-1,-1)
|
|
391
|
+
value[axis] = main
|
|
392
|
+
elif children.is_empty(): return
|
|
393
|
+
else:
|
|
394
|
+
for index in range(3):
|
|
395
|
+
if requested[index]>=0: value[index] = -1
|
|
371
396
|
if available_capacity==value: return
|
|
397
|
+
var dependent := false
|
|
398
|
+
for index in range(2):
|
|
399
|
+
if available_capacity[index]!=value[index] and measurement_allocation[index]<0 and _uses_capacity(index): dependent = true
|
|
372
400
|
available_capacity = value
|
|
373
|
-
|
|
374
|
-
|
|
401
|
+
if dependent:
|
|
402
|
+
_measure_dirty = true
|
|
403
|
+
_arrange_dirty = true
|
|
375
404
|
if transparent and children.size()==1: children[0].set_capacity(value)
|
|
376
405
|
|
|
406
|
+
func _capacity_basis(basis: Vector3) -> Vector3:
|
|
407
|
+
# A natural wrapper forwards a ceiling without making its auto dimensions
|
|
408
|
+
# percentage/grow references. Scrolling leaves its content axis unbounded.
|
|
409
|
+
var ceiling := constrain(available_capacity)-leading(padding+border)-trailing(padding+border)
|
|
410
|
+
var inner := Vector2(ceiling.x if available_capacity.x>=0 else -1,ceiling.y if available_capacity.y>=0 else -1)
|
|
411
|
+
var strips := ScrollbarGeometry.thickness(inner,scroll_axes,length_specs,viewport_size)
|
|
412
|
+
for index in range(2):
|
|
413
|
+
if scroll_axes[index]>0: basis[index] = -1
|
|
414
|
+
elif basis[index]<0 and available_capacity[index]>=0: basis[index] = maxf(0,ceiling[index]-strips[index])
|
|
415
|
+
return basis
|
|
416
|
+
|
|
377
417
|
func _wrap_basis() -> Vector3:
|
|
378
418
|
var basis := _content_basis()
|
|
379
419
|
if axis<2 and scroll_axes[axis]>0: basis[axis] = -1
|
|
@@ -387,13 +427,15 @@ func _wrap_basis() -> Vector3:
|
|
|
387
427
|
|
|
388
428
|
func measure_allocated(extent: Vector3, authority: Vector3) -> void:
|
|
389
429
|
if transparent and children.size()==1:
|
|
430
|
+
set_capacity(extent)
|
|
390
431
|
children[0].measure_allocated(extent,authority)
|
|
391
432
|
_measure_dirty = true
|
|
392
433
|
elif strategy in ["wrap","grid"] or scroll_axes!=Vector2.ZERO or dimension_budget_enabled and not children.is_empty():
|
|
393
|
-
|
|
434
|
+
set_capacity(extent)
|
|
435
|
+
var next := Vector3(-1,-1,-1)
|
|
394
436
|
for index in range(2):
|
|
395
437
|
if requested[index]<0 and authority[index]>0: next[index] = extent[index]
|
|
396
|
-
if next==measurement_allocation: return
|
|
438
|
+
if next==measurement_allocation and not _measure_dirty: return
|
|
397
439
|
measurement_allocation = next
|
|
398
440
|
_measure_dirty = true
|
|
399
441
|
else: return
|
|
@@ -405,6 +447,18 @@ func measure_allocated(extent: Vector3, authority: Vector3) -> void:
|
|
|
405
447
|
for index in range(2):
|
|
406
448
|
if requested[index]<0 and authority[index]>0: measured[index] = preferred[index]
|
|
407
449
|
|
|
450
|
+
func _clear_allocation(authority: Vector3) -> void:
|
|
451
|
+
# Remove lost track/stretch authority before natural measurement chooses
|
|
452
|
+
# new slots; otherwise an old slot can become its own auto-track floor.
|
|
453
|
+
if transparent and children.size()==1:
|
|
454
|
+
children[0]._clear_allocation(authority)
|
|
455
|
+
if children[0]._measure_dirty: _measure_dirty = true
|
|
456
|
+
for index in range(2):
|
|
457
|
+
if authority[index]==0 and measurement_allocation[index]>=0:
|
|
458
|
+
measurement_allocation[index] = -1
|
|
459
|
+
_measure_dirty = true
|
|
460
|
+
_arrange_dirty = true
|
|
461
|
+
|
|
408
462
|
func overflow_extent() -> Vector3:
|
|
409
463
|
# Ancestors see the clipped participant's viewport, not its hidden content.
|
|
410
464
|
if clips_content or scroll_axes!=Vector2.ZERO: return size
|
|
@@ -420,12 +474,30 @@ func _slots(items: Array, content: Vector3, definite: Vector3) -> Array:
|
|
|
420
474
|
if strategy=="wrap": return WrapPolicy.layout(items,content,axis,physical_gaps,alignment,align_content,Vector2(definite.x,definite.y)).slots
|
|
421
475
|
return StackPolicy.slots(items,content,axis,_main_gap(),alignment)
|
|
422
476
|
|
|
423
|
-
func
|
|
477
|
+
func _grid_track_definite(item_index: int, axis_index: int, basis: Vector3) -> bool:
|
|
478
|
+
# measure()/arrange() refresh placements once before walking child slots.
|
|
479
|
+
# Do not rescan every sibling for each child's two authority checks.
|
|
480
|
+
if grid_definition.is_empty(): _prepare_grid()
|
|
481
|
+
if grid_definition.has("error") or item_index<0 or item_index>=grid_definition.placements.size(): return false
|
|
482
|
+
var rect: Dictionary = grid_definition.placements[item_index]
|
|
483
|
+
var tracks: Array = grid_definition.columns if axis_index==0 else grid_definition.rows
|
|
484
|
+
var start: int = rect.column if axis_index==0 else rect.row
|
|
485
|
+
var span: int = rect.column_span if axis_index==0 else rect.row_span
|
|
486
|
+
for index in range(start,start+span):
|
|
487
|
+
var unit: String = tracks[index].unit
|
|
488
|
+
if unit=="auto" or unit in ["fr","%"] and basis[axis_index]<0: return false
|
|
489
|
+
return true
|
|
490
|
+
|
|
491
|
+
func _authority(child, item: Dictionary, basis: Vector3, item_index: int = -1) -> Vector3:
|
|
424
492
|
var authority := Vector3.ZERO
|
|
425
493
|
for index in range(3):
|
|
426
|
-
if
|
|
494
|
+
if child.requested[index]>=0 or index<2 and scroll_axes[index]>0: continue
|
|
427
495
|
if strategy=="grid":
|
|
428
|
-
|
|
496
|
+
# A fixed track is definite even in an auto Grid. Conversely, an
|
|
497
|
+
# auto track remains content-derived inside a definite-height Grid;
|
|
498
|
+
# its dependent cross contribution must survive remeasurement.
|
|
499
|
+
if index<2 and alignment[index]=="stretch" and _grid_track_definite(item_index,index,basis): authority[index] = 1
|
|
500
|
+
elif basis[index]<0: continue
|
|
429
501
|
elif index==axis:
|
|
430
502
|
if child.grow>0 or child.fill[index]>0: authority[index] = 1
|
|
431
503
|
elif StackPolicy.cross_alignment(item,alignment[index],index)=="stretch": authority[index] = 1
|
|
@@ -452,19 +524,21 @@ func measure() -> Vector3:
|
|
|
452
524
|
if not transparent:
|
|
453
525
|
var basis := _content_basis()
|
|
454
526
|
var budget := dimension_budget(basis)
|
|
455
|
-
for
|
|
527
|
+
for child_index in range(children.size()):
|
|
528
|
+
var child = children[child_index]
|
|
456
529
|
child.prepare(basis,viewport_size,budget)
|
|
457
|
-
var capacity := basis
|
|
530
|
+
var capacity := _capacity_basis(basis)
|
|
458
531
|
for index in range(3):
|
|
459
532
|
if capacity[index]>=0: capacity[index] = maxf(0,capacity[index]-child.outer_extent()[index])
|
|
460
533
|
child.set_capacity(capacity)
|
|
534
|
+
child._clear_allocation(_authority(child,{"align_self":child.align_self,"stretch":child.stretch,"fill":child.fill},basis,child_index))
|
|
461
535
|
child.measure()
|
|
462
|
-
if basis.x>=0 or basis.y>=0:
|
|
536
|
+
if basis.x>=0 or basis.y>=0 or strategy=="grid":
|
|
463
537
|
var items := _items()
|
|
464
538
|
var definite := Vector3(1 if basis.x>=0 else 0,1 if basis.y>=0 else 0,1 if basis.z>=0 else 0)
|
|
465
539
|
var allocations := _slots(items,basis,definite)
|
|
466
540
|
if allocations.size()==children.size():
|
|
467
|
-
for index in range(children.size()): children[index].measure_allocated(allocations[index].extent,_authority(children[index],items[index],basis))
|
|
541
|
+
for index in range(children.size()): children[index].measure_allocated(allocations[index].extent,_authority(children[index],items[index],basis,index))
|
|
468
542
|
var natural := Vector3.ZERO
|
|
469
543
|
for child in children:
|
|
470
544
|
var child_size: Vector3 = child.measure()
|
|
@@ -499,7 +573,8 @@ func independent_axis(index: int) -> bool:
|
|
|
499
573
|
var allocated := grow>0 or fill[index]>0
|
|
500
574
|
if index!=parent.axis: allocated = StackPolicy.cross_alignment({"align_self":align_self,"stretch":stretch,"fill":fill},parent.alignment[index],index)=="stretch"
|
|
501
575
|
if index<2 and parent.scroll_axes[index]>0: return false
|
|
502
|
-
if parent.strategy=="grid" and index<2:
|
|
576
|
+
if parent.strategy=="grid" and index<2:
|
|
577
|
+
return parent.alignment[index]=="stretch" and parent._grid_track_definite(_parent_index,index,parent.content_reference)
|
|
503
578
|
return parent.independent_axis(index) if requested[index] < 0 and allocated else false
|
|
504
579
|
|
|
505
580
|
func arrange(available: Vector3, external_axes: Vector3 = Vector3.ZERO) -> void:
|
|
@@ -585,7 +660,7 @@ func arrange(available: Vector3, external_axes: Vector3 = Vector3.ZERO) -> void:
|
|
|
585
660
|
child.placed.emit(next)
|
|
586
661
|
var authority := Vector3.ZERO
|
|
587
662
|
for cross in range(3):
|
|
588
|
-
if strategy=="grid" and cross<2 and policy[cross]=="stretch" and child.requested[cross]<0 and
|
|
663
|
+
if strategy=="grid" and cross<2 and policy[cross]=="stretch" and child.requested[cross]<0 and _grid_track_definite(index,cross,reference): authority[cross] = 1
|
|
589
664
|
elif strategy!="grid" and cross!=axis and StackPolicy.cross_alignment(items[index],policy[cross],cross)=="stretch" and child.requested[cross]<0 and independent_axis(cross): authority[cross] = 1
|
|
590
665
|
for scrolling_axis in range(2):
|
|
591
666
|
if scroll_axes[scrolling_axis]>0:
|
package/package.json
CHANGED