@geastack/engine 0.1.19 → 0.1.20
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/package.json +1 -1
- package/touch_runtime.cpp +10 -8
- package/ui/input.cpp +52 -18
- package/ui/internal.h +2 -0
- package/ui/layout.cpp +51 -2
- package/ui/render.cpp +79 -1
- package/ui/root_scroll_refresh.cpp +10 -1
- package/ui/style.cpp +16 -0
- package/ui/text.cpp +6 -0
- package/ui/tree_events.cpp +9 -1
package/package.json
CHANGED
package/touch_runtime.cpp
CHANGED
|
@@ -121,6 +121,15 @@ public:
|
|
|
121
121
|
if (picker.consume(event.touchPhase, x, y, event.pointerId)) return true;
|
|
122
122
|
}
|
|
123
123
|
#endif
|
|
124
|
+
// A primary move marker holds the controller's queued-move flag: every
|
|
125
|
+
// path below must drain it, or the controller stops reporting moves and
|
|
126
|
+
// every later drag is dead while taps still work.
|
|
127
|
+
int tx = event.x;
|
|
128
|
+
int ty = event.y;
|
|
129
|
+
if (event.touchPhase == TouchPhase::Move && event.pointerId == 0) {
|
|
130
|
+
gea::platform::touch::Touchscreen::consumeLatestMove(&tx, &ty);
|
|
131
|
+
TouchRuntime::transformTouchToLogical(&tx, &ty);
|
|
132
|
+
}
|
|
124
133
|
// Immediate-mode apps (Display.ctx games) mount no UI tree: hitTestNode
|
|
125
134
|
// returns -1 and there is no root to bind document listeners onto, so the
|
|
126
135
|
// tree dispatch below can never reach the app. Deliver pointer events
|
|
@@ -140,21 +149,14 @@ public:
|
|
|
140
149
|
|
|
141
150
|
if (retireInvalidPrimary(!event.touching && event.touchPhase == TouchPhase::Up)) return false;
|
|
142
151
|
if(primaryQuarantined_){
|
|
143
|
-
if(event.touchPhase==TouchPhase::Move) gea::platform::touch::Touchscreen::consumeLatestMove(nullptr,nullptr);
|
|
144
152
|
if(!event.touching && event.touchPhase==TouchPhase::Up)primaryQuarantined_=false;
|
|
145
153
|
return false;
|
|
146
154
|
}
|
|
147
155
|
auto dispatchTicket=primaryTicket_;bool primaryBegan=false;
|
|
148
156
|
bool changed = false;
|
|
149
157
|
|
|
150
|
-
int tx = event.x;
|
|
151
|
-
int ty = event.y;
|
|
152
158
|
bool touching = event.touching;
|
|
153
|
-
if (event.touchPhase == TouchPhase::Move)
|
|
154
|
-
gea::platform::touch::Touchscreen::consumeLatestMove(&tx, &ty);
|
|
155
|
-
TouchRuntime::transformTouchToLogical(&tx, &ty);
|
|
156
|
-
touching = true;
|
|
157
|
-
}
|
|
159
|
+
if (event.touchPhase == TouchPhase::Move) touching = true;
|
|
158
160
|
// Up callbacks inherit the last consumed move, while tx/ty retain the
|
|
159
161
|
// consumed edge coordinates. Expose both without changing routing.
|
|
160
162
|
recordConsumed(event, touching, tx, ty, !touching && wasActive_ ? lastX_ : tx,
|
package/ui/input.cpp
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
#define GEA_SCROLL_MOMENTUM_MAX_VELOCITY 24.0f
|
|
28
28
|
#endif
|
|
29
29
|
#ifndef GEA_SCROLL_MOMENTUM_MIN_VELOCITY
|
|
30
|
-
#define GEA_SCROLL_MOMENTUM_MIN_VELOCITY 0.
|
|
30
|
+
#define GEA_SCROLL_MOMENTUM_MIN_VELOCITY 0.2f
|
|
31
31
|
#endif
|
|
32
32
|
#ifndef GEA_SCROLL_MOMENTUM_DECAY_MS
|
|
33
33
|
#define GEA_SCROLL_MOMENTUM_DECAY_MS 680.0f
|
|
@@ -106,6 +106,7 @@ public:
|
|
|
106
106
|
carryOverVelocity_ = momentumVelocity_;
|
|
107
107
|
carryOverAxis_ = momentumAxis_;
|
|
108
108
|
cancelMomentum();
|
|
109
|
+
pointerDownMs_ = gea::framework::services::FrameScheduler::nowMs();
|
|
109
110
|
activeScrollNode_ = tree.nodeCount() == 0 ? -1 : findScrollNodeId(0, x, y);
|
|
110
111
|
activeScrollOwner_=NodeHandle(activeScrollNode_);
|
|
111
112
|
snapAccumDy_ = 0;
|
|
@@ -766,27 +767,53 @@ private:
|
|
|
766
767
|
if (scrollNode < 0 || scrollNode >= tree.nodeCount()) return;
|
|
767
768
|
if (!nodeCanScrollAxis(scrollNode, tree.node(scrollNode), axis)) return;
|
|
768
769
|
|
|
769
|
-
//
|
|
770
|
-
//
|
|
771
|
-
//
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
770
|
+
// Release velocity is the finger's speed over the last
|
|
771
|
+
// kVelocityWindowMs before lift-off, not over the whole ring: a flick
|
|
772
|
+
// that started fast and slowed before release must launch at the slow
|
|
773
|
+
// speed. The newest sample is the lift itself (pushed at pointer up),
|
|
774
|
+
// so a pause before lifting counts as standing still. The window start
|
|
775
|
+
// is interpolated between the two samples that straddle it, which
|
|
776
|
+
// keeps the estimate independent of the touch report rate.
|
|
777
|
+
auto sampleAt = [this](int back) -> const VelocitySample & {
|
|
778
|
+
return velocitySamples_[(velocitySampleNext_ + kVelocitySampleCount - 1 - back) %
|
|
779
|
+
kVelocitySampleCount];
|
|
780
|
+
};
|
|
781
|
+
auto along = [axis](const VelocitySample &s) {
|
|
782
|
+
return static_cast<float>(axis == ScrollAxis::X ? s.x : s.y);
|
|
783
|
+
};
|
|
784
|
+
const VelocitySample &newest = sampleAt(0);
|
|
785
|
+
const int windowStartMs = newest.timestampMs - kVelocityWindowMs;
|
|
786
|
+
int dtMs = 0;
|
|
787
|
+
float deltaF = 0.0f;
|
|
788
|
+
for (int back = 1; back < velocitySampleCount_; back++) {
|
|
789
|
+
const VelocitySample &older = sampleAt(back);
|
|
790
|
+
if (older.timestampMs > windowStartMs && back + 1 < velocitySampleCount_) continue;
|
|
791
|
+
if (older.timestampMs >= windowStartMs) {
|
|
792
|
+
// The ring does not reach back a whole window: use what it holds.
|
|
793
|
+
dtMs = newest.timestampMs - older.timestampMs;
|
|
794
|
+
deltaF = along(newest) - along(older);
|
|
795
|
+
break;
|
|
796
|
+
}
|
|
797
|
+
const VelocitySample &newer = sampleAt(back - 1);
|
|
798
|
+
const int span = newer.timestampMs - older.timestampMs;
|
|
799
|
+
const float t = span > 0
|
|
800
|
+
? static_cast<float>(windowStartMs - older.timestampMs) / span
|
|
801
|
+
: 1.0f;
|
|
802
|
+
const float startPos = along(older) + (along(newer) - along(older)) * t;
|
|
803
|
+
dtMs = kVelocityWindowMs;
|
|
804
|
+
deltaF = along(newest) - startPos;
|
|
805
|
+
break;
|
|
806
|
+
}
|
|
781
807
|
if (dtMs <= 0) return;
|
|
782
808
|
|
|
783
809
|
const int nowMs = gea::framework::services::FrameScheduler::nowMs();
|
|
784
810
|
|
|
785
|
-
const int delta =
|
|
786
|
-
float velocityPxPerMs =
|
|
811
|
+
const int delta = static_cast<int>(deltaF);
|
|
812
|
+
float velocityPxPerMs = deltaF / static_cast<float>(dtMs);
|
|
787
813
|
|
|
788
|
-
// Below ~0.
|
|
789
|
-
//
|
|
814
|
+
// Below ~0.2 px/ms = 200 px/sec over the release window the finger was
|
|
815
|
+
// not flicking: a finger that stopped still rolls a few px as it lifts,
|
|
816
|
+
// and launching that roll reads as the list moving on by itself.
|
|
790
817
|
// A tap (no drag, weak velocity) also lands here, which is what we
|
|
791
818
|
// want: a tap should NOT resume a stashed fling.
|
|
792
819
|
if (std::fabs(velocityPxPerMs) < kMinFlingVelocity) {
|
|
@@ -805,7 +832,11 @@ private:
|
|
|
805
832
|
// the new flick goes in the same direction, add the leftover
|
|
806
833
|
// velocity to the new one. Opposite direction → user is reversing
|
|
807
834
|
// course, drop the stash.
|
|
835
|
+
// Only a quick re-flick carries: a finger that caught the fling and held
|
|
836
|
+
// or dragged slowly before lifting would otherwise launch faster than
|
|
837
|
+
// it moved.
|
|
808
838
|
if (carryOverAxis_ == axis && carryOverVelocity_ != 0.0f &&
|
|
839
|
+
nowMs - pointerDownMs_ <= kCarryOverWindowMs &&
|
|
809
840
|
(carryOverVelocity_ > 0.0f) == (velocityPxPerMs > 0.0f)) {
|
|
810
841
|
velocityPxPerMs += carryOverVelocity_ * kCarryOverBoost;
|
|
811
842
|
}
|
|
@@ -843,9 +874,11 @@ private:
|
|
|
843
874
|
int x;
|
|
844
875
|
int y;
|
|
845
876
|
};
|
|
846
|
-
static constexpr int kVelocitySampleCount =
|
|
877
|
+
static constexpr int kVelocitySampleCount = 8;
|
|
878
|
+
static constexpr int kVelocityWindowMs = 50;
|
|
847
879
|
static constexpr float kLaunchVelocityBoost = GEA_SCROLL_MOMENTUM_LAUNCH_BOOST;
|
|
848
880
|
static constexpr float kCarryOverBoost = GEA_SCROLL_MOMENTUM_CARRY_BOOST;
|
|
881
|
+
static constexpr int kCarryOverWindowMs = 250;
|
|
849
882
|
static constexpr float kMaxMomentumVelocity = GEA_SCROLL_MOMENTUM_MAX_VELOCITY; // px/ms
|
|
850
883
|
static constexpr float kMinFlingVelocity = GEA_SCROLL_MOMENTUM_MIN_VELOCITY; // px/ms
|
|
851
884
|
static constexpr float kMomentumDecayMs = GEA_SCROLL_MOMENTUM_DECAY_MS;
|
|
@@ -877,6 +910,7 @@ private:
|
|
|
877
910
|
// Folded into the next flick if same-direction so successive flicks
|
|
878
911
|
// accelerate (iOS-style).
|
|
879
912
|
float carryOverVelocity_ = 0.0f;
|
|
913
|
+
int pointerDownMs_ = 0;
|
|
880
914
|
ScrollAxis carryOverAxis_ = ScrollAxis::None;
|
|
881
915
|
};
|
|
882
916
|
|
package/ui/internal.h
CHANGED
|
@@ -578,6 +578,8 @@ void rootScrollImageHoldTick();
|
|
|
578
578
|
static int measureWidth(const char *text, int fontId, int fontSize, int textTransform = 0);
|
|
579
579
|
static int firstUnbreakableWidth(const Node &node);
|
|
580
580
|
static int minContentWidth(const Node &node, int *pendingWord = nullptr);
|
|
581
|
+
// The run laid out on one line (no soft wraps): CSS max-content width.
|
|
582
|
+
static int maxContentWidth(const Node &node);
|
|
581
583
|
static int measureHeight(const char *text, int fontId, int fontSize, int textTransform = 0, int lineHeight = 0);
|
|
582
584
|
// In-place box re-measure for a rebound text node on refresh paths that
|
|
583
585
|
// skip the layout pass (root-scroll fast path): record() wraps and clips
|
package/ui/layout.cpp
CHANGED
|
@@ -324,6 +324,15 @@ bool hasFlexBasis(const Node &node)
|
|
|
324
324
|
return node.computedStyle().flex_basis != kUnset || rstyle(node.computedStyle()).flex_basis_expression >= 0;
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
+
// CSS 2 10.3.7/10.6.4: an out-of-flow box with both insets on an axis and an
|
|
328
|
+
// auto size there takes its used size from the containing block. That size is
|
|
329
|
+
// definite before the box's content is laid out, so size the box up front:
|
|
330
|
+
// shrinking it to its content and stretching it afterwards laid every
|
|
331
|
+
// positioned descendant out against the content-sized box and then again
|
|
332
|
+
// against the stretched one -- twice per nesting level of `inset: 0` panels.
|
|
333
|
+
bool insetStretched(const Node &node, bool horizontal);
|
|
334
|
+
int insetStretchedBorderSize(const Node &node, bool horizontal, int basis);
|
|
335
|
+
|
|
327
336
|
bool hasExplicitWidth(const Node &node)
|
|
328
337
|
{
|
|
329
338
|
if (const auto *basis = flexBasisScope(node, true)) return basis->value != kUnset;
|
|
@@ -333,6 +342,7 @@ bool hasExplicitWidth(const Node &node)
|
|
|
333
342
|
return scope && scope->constraint == 0;
|
|
334
343
|
}
|
|
335
344
|
if (node.computedStyle().width != kUnset) return true;
|
|
345
|
+
if (insetStretched(node, true)) return true;
|
|
336
346
|
if (intrinsicWidthConstraint(node)) return false;
|
|
337
347
|
return node.computedStyle().width_expression >= 0 || node.computedStyle().width_percent != kUnset;
|
|
338
348
|
}
|
|
@@ -373,6 +383,7 @@ bool hasExplicitHeight(const Node &node)
|
|
|
373
383
|
if (const auto *basis = flexBasisScope(node, false)) return basis->value != kUnset;
|
|
374
384
|
if (const auto *scope = intrinsicSizeScope(node, false); scope && scope->constraint == 0) return true;
|
|
375
385
|
if (node.computedStyle().height != kUnset) return true;
|
|
386
|
+
if (insetStretched(node, false)) return true;
|
|
376
387
|
if (intrinsicSizeConstraint(node, false)) return false;
|
|
377
388
|
if (node.computedStyle().height_expression < 0 && node.computedStyle().height_percent == kUnset) return false;
|
|
378
389
|
if (!percentageHeightDependsOnIntrinsicSize(node)) return true;
|
|
@@ -386,6 +397,8 @@ int resolvedStyleWidth(const Node &node, int basis)
|
|
|
386
397
|
if (const auto *scope = intrinsicSizeScope(node, true); scope && scope->constraint == 0)
|
|
387
398
|
return std::max(0, scope->borderSize - (node.computedStyle().box_sizing == 0 ? boxInsets(node.computedStyle(), true) : 0));
|
|
388
399
|
if (!hasExplicitWidth(node)) return basis;
|
|
400
|
+
if (insetStretched(node, true))
|
|
401
|
+
return insetStretchedBorderSize(node, true, basis) - (node.computedStyle().box_sizing == 0 ? boxInsets(node.computedStyle(), true) : 0);
|
|
389
402
|
if (node.computedStyle().width_expression >= 0) return resolveLayoutSizeExpression(static_cast<int>(&node - Tree::instance().nodes()), node.computedStyle().width_expression, true);
|
|
390
403
|
if (node.computedStyle().width != kUnset) return node.computedStyle().width;
|
|
391
404
|
if (node.computedStyle().width_percent != kUnset) return resolvePercentSize(basis, node.computedStyle().width_percent);
|
|
@@ -398,6 +411,8 @@ int resolvedStyleHeight(const Node &node, int basis)
|
|
|
398
411
|
if (const auto *scope = intrinsicSizeScope(node, false); scope && scope->constraint == 0)
|
|
399
412
|
return std::max(0, scope->borderSize - (node.computedStyle().box_sizing == 0 ? boxInsets(node.computedStyle(), false) : 0));
|
|
400
413
|
if (!hasExplicitHeight(node)) return basis;
|
|
414
|
+
if (insetStretched(node, false))
|
|
415
|
+
return insetStretchedBorderSize(node, false, basis) - (node.computedStyle().box_sizing == 0 ? boxInsets(node.computedStyle(), false) : 0);
|
|
401
416
|
if (node.computedStyle().height_expression >= 0) return resolveLayoutSizeExpression(static_cast<int>(&node - Tree::instance().nodes()), node.computedStyle().height_expression, false);
|
|
402
417
|
if (node.computedStyle().height != kUnset) return node.computedStyle().height;
|
|
403
418
|
if (node.computedStyle().height_percent != kUnset && !percentageHeightDependsOnIntrinsicSize(node))
|
|
@@ -1770,9 +1785,18 @@ private:
|
|
|
1770
1785
|
const Node &grand = nodes[c];
|
|
1771
1786
|
if (isLayoutExcluded(grand) || isOutOfFlowPosition(grand.computedStyle().position)) continue;
|
|
1772
1787
|
// layout.{x,y} are still parent-relative here: resolveAbsoluteCoords runs
|
|
1773
|
-
// after the whole layout pass.
|
|
1788
|
+
// after the whole layout pass. A text run's laid-out box is its line box,
|
|
1789
|
+
// as wide as the space it was offered (and offset by text-align), so it
|
|
1790
|
+
// would floor the item at the whole row -- `<div>BACK</div>` beside a
|
|
1791
|
+
// title never shrank and three `flex: 1` buttons each grew to the full
|
|
1792
|
+
// row. Its contribution is its fit-content width: max-content, capped at
|
|
1793
|
+
// that line box. Min-content alone is too small for a run that wraps --
|
|
1794
|
+
// "AV AV" offered 22px measures its widest line, 18px, while CSS keeps
|
|
1795
|
+
// the item at the 22px it shrank to from its max-content basis.
|
|
1774
1796
|
const int end = isRow_
|
|
1775
|
-
? grand.
|
|
1797
|
+
? (grand.type == NodeType::Text
|
|
1798
|
+
? boxInset(childNode.computedStyle(), 3) + std::min<int>(TextRenderer::maxContentWidth(grand), grand.layout.width)
|
|
1799
|
+
: grand.layout.x + grand.layout.width + grand.computedStyle().margin[1])
|
|
1776
1800
|
: grand.layout.y + grand.layout.height + grand.computedStyle().margin[2];
|
|
1777
1801
|
if (end > extent) extent = end;
|
|
1778
1802
|
}
|
|
@@ -3638,6 +3662,30 @@ int resolvedPositionOffsetForBasis(const Node &node, int percentBasis)
|
|
|
3638
3662
|
return offset;
|
|
3639
3663
|
}
|
|
3640
3664
|
|
|
3665
|
+
bool insetStretched(const Node &node, bool horizontal)
|
|
3666
|
+
{
|
|
3667
|
+
const ComputedStyle &style = node.computedStyle();
|
|
3668
|
+
if (node.type != NodeType::View || !isOutOfFlowPosition(style.position) || isLayoutExcluded(node)) return false;
|
|
3669
|
+
if (horizontal ? style.width != kUnset || style.width_expression >= 0 || style.width_percent != kUnset ||
|
|
3670
|
+
isIntrinsicSizeExpression(style.width_expression)
|
|
3671
|
+
: style.height != kUnset || style.height_expression >= 0 || style.height_percent != kUnset ||
|
|
3672
|
+
isIntrinsicSizeExpression(style.height_expression)) return false;
|
|
3673
|
+
if (intrinsicSizeScope(node, horizontal) || flexBasisScope(node, horizontal) || preferredRatio(node) > 0) return false;
|
|
3674
|
+
return horizontal ? hasPositionOffsetValue<3>(node) && hasPositionOffsetValue<1>(node)
|
|
3675
|
+
: hasPositionOffsetValue<0>(node) && hasPositionOffsetValue<2>(node);
|
|
3676
|
+
}
|
|
3677
|
+
|
|
3678
|
+
// Border-box size of an inset-stretched box in a containing block `basis` wide
|
|
3679
|
+
// (or tall); the same arithmetic as stretchAbsoluteNodeToContainingBlock.
|
|
3680
|
+
int insetStretchedBorderSize(const Node &node, bool horizontal, int basis)
|
|
3681
|
+
{
|
|
3682
|
+
const ComputedStyle &style = node.computedStyle();
|
|
3683
|
+
const int size = horizontal
|
|
3684
|
+
? basis - resolvedPositionOffsetForBasis<3>(node, basis) - resolvedPositionOffsetForBasis<1>(node, basis) - style.margin[1] - style.margin[3]
|
|
3685
|
+
: basis - resolvedPositionOffsetForBasis<0>(node, basis) - resolvedPositionOffsetForBasis<2>(node, basis) - style.margin[0] - style.margin[2];
|
|
3686
|
+
return std::max(size, boxInsets(style, horizontal));
|
|
3687
|
+
}
|
|
3688
|
+
|
|
3641
3689
|
void offsetFromAncestorToNode(int ancestor, int node, Node *nodes, int *outX, int *outY)
|
|
3642
3690
|
{
|
|
3643
3691
|
int x = 0;
|
|
@@ -4131,6 +4179,7 @@ static_assert(sizeof(LayoutPassMemo) == 10);
|
|
|
4131
4179
|
LayoutPassMemo *gLayoutMemo = nullptr;
|
|
4132
4180
|
int gLayoutMemoCapacity = 0;
|
|
4133
4181
|
std::size_t gLayoutMemoPeakBytes = 0;
|
|
4182
|
+
|
|
4134
4183
|
} // namespace
|
|
4135
4184
|
|
|
4136
4185
|
void LayoutEngine::beginLayoutPass()
|
package/ui/render.cpp
CHANGED
|
@@ -4880,6 +4880,60 @@ int gLastScrollUiFrame = -1000;
|
|
|
4880
4880
|
return coverage;
|
|
4881
4881
|
}
|
|
4882
4882
|
|
|
4883
|
+
// Where a rounded-rect contour's left and right edges run across the pixel
|
|
4884
|
+
// row [y, y + 1): each edge is monotone within a corner, so its extremes
|
|
4885
|
+
// over the row sit at the row's ends or where a corner meets a straight
|
|
4886
|
+
// side. Mirrors roundedRectContainsFast's corner order (tl before bl, tr
|
|
4887
|
+
// before br).
|
|
4888
|
+
struct RoundedRowEdges
|
|
4889
|
+
{
|
|
4890
|
+
bool any = false; // the contour reaches into the row
|
|
4891
|
+
bool whole = false; // the row lies wholly within its vertical extent
|
|
4892
|
+
float lMin = 0, lMax = 0, rMin = 0, rMax = 0;
|
|
4893
|
+
};
|
|
4894
|
+
|
|
4895
|
+
RoundedRowEdges roundedRectRowEdges(const TransformedRoundedRectCommand &r, int y)
|
|
4896
|
+
{
|
|
4897
|
+
RoundedRowEdges e;
|
|
4898
|
+
if (r.lw <= 0 || r.lh <= 0)
|
|
4899
|
+
return e;
|
|
4900
|
+
const float left = static_cast<float>(r.lx), top = static_cast<float>(r.ly);
|
|
4901
|
+
const float right = left + static_cast<float>(r.lw), bottom = top + static_cast<float>(r.lh);
|
|
4902
|
+
const float y0 = std::max(static_cast<float>(y), top), y1 = std::min(static_cast<float>(y + 1), bottom);
|
|
4903
|
+
if (y1 <= y0)
|
|
4904
|
+
return e;
|
|
4905
|
+
e.any = true;
|
|
4906
|
+
e.whole = static_cast<float>(y) >= top && static_cast<float>(y + 1) <= bottom;
|
|
4907
|
+
const auto radius = [](int16_t r8) { return static_cast<float>(std::max(0, static_cast<int>(r8))) * 0.125f; };
|
|
4908
|
+
const float tlRx = radius(r.tlRx8), tlRy = radius(r.tlRy8), trRx = radius(r.trRx8), trRy = radius(r.trRy8);
|
|
4909
|
+
const float brRx = radius(r.brRx8), brRy = radius(r.brRy8), blRx = radius(r.blRx8), blRy = radius(r.blRy8);
|
|
4910
|
+
const auto inset = [](float rx, float ry, float dy) {
|
|
4911
|
+
const float t = dy / ry;
|
|
4912
|
+
return rx - rx * std::sqrt(std::max(0.0f, 1.0f - t * t));
|
|
4913
|
+
};
|
|
4914
|
+
const auto leftAt = [&](float sy) {
|
|
4915
|
+
if (tlRx > 0 && tlRy > 0 && sy < top + tlRy) return left + inset(tlRx, tlRy, top + tlRy - sy);
|
|
4916
|
+
if (blRx > 0 && blRy > 0 && sy >= bottom - blRy) return left + inset(blRx, blRy, sy - (bottom - blRy));
|
|
4917
|
+
return left;
|
|
4918
|
+
};
|
|
4919
|
+
const auto rightAt = [&](float sy) {
|
|
4920
|
+
if (trRx > 0 && trRy > 0 && sy < top + trRy) return right - inset(trRx, trRy, top + trRy - sy);
|
|
4921
|
+
if (brRx > 0 && brRy > 0 && sy >= bottom - brRy) return right - inset(brRx, brRy, sy - (bottom - brRy));
|
|
4922
|
+
return right;
|
|
4923
|
+
};
|
|
4924
|
+
const float probes[6] = {y0, y1, top + tlRy, bottom - blRy, top + trRy, bottom - brRy};
|
|
4925
|
+
e.lMin = e.rMin = 1e9f;
|
|
4926
|
+
e.lMax = e.rMax = -1e9f;
|
|
4927
|
+
for (int i = 0; i < 6; ++i)
|
|
4928
|
+
{
|
|
4929
|
+
const float sy = std::clamp(probes[i], y0, y1);
|
|
4930
|
+
const float l = leftAt(sy), rr = rightAt(sy);
|
|
4931
|
+
e.lMin = std::min(e.lMin, l); e.lMax = std::max(e.lMax, l);
|
|
4932
|
+
e.rMin = std::min(e.rMin, rr); e.rMax = std::max(e.rMax, rr);
|
|
4933
|
+
}
|
|
4934
|
+
return e;
|
|
4935
|
+
}
|
|
4936
|
+
|
|
4883
4937
|
void drawCssRoundedBorder(const DisplayCommand &command)
|
|
4884
4938
|
{
|
|
4885
4939
|
const auto &s = command.strokeRoundedRect;
|
|
@@ -4923,7 +4977,31 @@ int gLastScrollUiFrame = -1000;
|
|
|
4923
4977
|
for (int x = std::max(x0, innerX1); x <= x1; ++x) paintCoveragePixel(row[x], s.color, alpha, full, full);
|
|
4924
4978
|
continue;
|
|
4925
4979
|
}
|
|
4926
|
-
|
|
4980
|
+
// Only pixels within a pixel of a contour edge need the per-pixel
|
|
4981
|
+
// test; the rest of the row is plainly outside the ring, inside the
|
|
4982
|
+
// border, or inside the hole. A large ellipse is all corner box, so
|
|
4983
|
+
// testing every pixel of it costs a frame per pass.
|
|
4984
|
+
const RoundedRowEdges oe = roundedRectRowEdges(outer, y), ie = roundedRectRowEdges(inner, y);
|
|
4985
|
+
if (!oe.any)
|
|
4986
|
+
continue;
|
|
4987
|
+
const int oL0 = static_cast<int>(std::floor(oe.lMin)) - 1, oL1 = static_cast<int>(std::ceil(oe.lMax)) + 1;
|
|
4988
|
+
const int oR0 = static_cast<int>(std::floor(oe.rMin)) - 1, oR1 = static_cast<int>(std::ceil(oe.rMax)) + 1;
|
|
4989
|
+
const int iL0 = static_cast<int>(std::floor(ie.lMin)) - 1, iL1 = static_cast<int>(std::ceil(ie.lMax)) + 1;
|
|
4990
|
+
const int iR0 = static_cast<int>(std::floor(ie.rMin)) - 1, iR1 = static_cast<int>(std::ceil(ie.rMax)) + 1;
|
|
4991
|
+
for (int x = std::max(x0, oL0); x <= std::min(x1, oR1); ++x) {
|
|
4992
|
+
if (oe.whole && x > oL1 && x < oR0 && (!ie.any || ie.whole))
|
|
4993
|
+
{
|
|
4994
|
+
if (!ie.any || x < iL0 || x > iR1)
|
|
4995
|
+
{
|
|
4996
|
+
paintCoveragePixel(row[x], s.color, alpha, full, full);
|
|
4997
|
+
continue;
|
|
4998
|
+
}
|
|
4999
|
+
if (x > iL1 && x < iR0)
|
|
5000
|
+
{
|
|
5001
|
+
x = iR0 - 1; // inside the hole: nothing to paint
|
|
5002
|
+
continue;
|
|
5003
|
+
}
|
|
5004
|
+
}
|
|
4927
5005
|
int coverage;
|
|
4928
5006
|
if (cornerRow && (x < cornerX0 || x >= cornerX1))
|
|
4929
5007
|
{
|
|
@@ -721,9 +721,18 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
721
721
|
// the post-shift positions, so for a masked scroller we skip the blit and
|
|
722
722
|
// re-rasterize the whole viewport from that list — the fade stays anchored.
|
|
723
723
|
const bool contentHasRightFadeMask = hasRightFadeMask(state, scroll_node);
|
|
724
|
+
// A software-rotated canvas (e.g. a 172x640 panel driven as 640x172)
|
|
725
|
+
// stores logical rows as framebuffer columns; neither the scroll-register
|
|
726
|
+
// row remap nor the pixel blit shifts it correctly, and the stale pixels
|
|
727
|
+
// left behind showed as content drawn over itself. Re-rasterize the whole
|
|
728
|
+
// viewport from the rebuilt display list instead.
|
|
729
|
+
bool blitScroll = !contentHasRightFadeMask;
|
|
730
|
+
#if GEA_EMBEDDED_DISPLAY_ROTATE_LANDSCAPE
|
|
731
|
+
if (auto *canvas = gea::platform::display::Display::canvas(); canvas && canvas->isLandscapeRotated()) blitScroll = false;
|
|
732
|
+
#endif
|
|
724
733
|
|
|
725
734
|
const int viewportExtent = horizontal ? vw : vh;
|
|
726
|
-
if (
|
|
735
|
+
if (blitScroll && abs_move > 0 && abs_move < viewportExtent) {
|
|
727
736
|
const std::int64_t scrollRectStartUs = refreshPerfNowUs();
|
|
728
737
|
gea::platform::display::Display::scrollRect(vx, vy, vw, vh, horizontal ? move : 0, horizontal ? 0 : move);
|
|
729
738
|
GEA_REFRESH_PERF(perf.rootScrollScrollRectUs += refreshPerfNowUs() - scrollRectStartUs);
|
package/ui/style.cpp
CHANGED
|
@@ -17818,6 +17818,22 @@ void endStyleMountBatch()
|
|
|
17818
17818
|
if (!covered) topRoots.push_back(node);
|
|
17819
17819
|
}
|
|
17820
17820
|
|
|
17821
|
+
// `:root` matches the tree root, and mount() hangs the app under a tagless,
|
|
17822
|
+
// classless wrapper that no class change ever queues. Left unstyled, its
|
|
17823
|
+
// `:root { --x: ... }` declarations never land, every var() below it falls
|
|
17824
|
+
// back to nothing (no backgrounds, default text colour), and repaints then
|
|
17825
|
+
// draw over stale pixels. Style each pending subtree's tree root first so
|
|
17826
|
+
// its custom properties exist before descendants resolve them.
|
|
17827
|
+
std::vector<int> styledTreeRoots;
|
|
17828
|
+
for (const int node : topRoots) {
|
|
17829
|
+
int treeRoot = node;
|
|
17830
|
+
while (state.nodes[treeRoot].parent >= 0) treeRoot = state.nodes[treeRoot].parent;
|
|
17831
|
+
if (treeRoot == node || g_pendingRecomputeMark.contains(treeRoot)) continue;
|
|
17832
|
+
if (std::find(styledTreeRoots.begin(), styledTreeRoots.end(), treeRoot) != styledTreeRoots.end()) continue;
|
|
17833
|
+
styledTreeRoots.push_back(treeRoot);
|
|
17834
|
+
recomputeNodeClassStyles(treeRoot);
|
|
17835
|
+
}
|
|
17836
|
+
|
|
17821
17837
|
// Incremental recompute: a near-root class change (e.g. a theme switch) only
|
|
17822
17838
|
// re-styles nodes that actually depend on what changed; the rest keep their
|
|
17823
17839
|
// already-correct computed style. Equivalent to recomputeSubtreeClassStyles but
|
package/ui/text.cpp
CHANGED
|
@@ -1895,6 +1895,12 @@ int TextRenderer::minContentWidth(const Node &node, int *pendingWord)
|
|
|
1895
1895
|
return width;
|
|
1896
1896
|
}
|
|
1897
1897
|
|
|
1898
|
+
int TextRenderer::maxContentWidth(const Node &node)
|
|
1899
|
+
{
|
|
1900
|
+
// The same unbounded measure remeasureContentBox gives natural-width text.
|
|
1901
|
+
return measureTextLayoutForNode(node, node.text.c_str(), 0x4000).width;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1898
1904
|
const char *TextRenderer::prepareText(const char *text, int textTransform, int whiteSpace, std::string &storage)
|
|
1899
1905
|
{
|
|
1900
1906
|
return textWithTransform(text, textTransform, storage, whiteSpace);
|
package/ui/tree_events.cpp
CHANGED
|
@@ -366,7 +366,15 @@ bool dispatchRootKeyEvent(gea::framework::events::PointerEvent &event, bool lega
|
|
|
366
366
|
using gea::framework::events::PointerEventType;
|
|
367
367
|
if (event.type != PointerEventType::KeyDown && event.type != PointerEventType::KeyUp) return false;
|
|
368
368
|
auto &tree = Tree::instance();
|
|
369
|
-
|
|
369
|
+
// With no focused input a hardware key belongs to the app: target its top
|
|
370
|
+
// element (the mount container's first child), so the event bubbles through
|
|
371
|
+
// the app root -- where apps bind onKeyDown -- and then the container. Aiming
|
|
372
|
+
// at the container itself skipped every app-level key handler.
|
|
373
|
+
if (event.targetId < 0) {
|
|
374
|
+
const int root = tree.mountedRoot();
|
|
375
|
+
const int app = tree.firstChildOf(root);
|
|
376
|
+
event.targetId = app >= 0 ? app : root;
|
|
377
|
+
}
|
|
370
378
|
event.target = gea::framework::events::EventTarget(event.targetId);
|
|
371
379
|
const auto path = captureEventPath(tree, event.targetId);
|
|
372
380
|
bool dispatched = dispatchWindowEvent(event, true);
|