@geastack/engine 0.1.6 → 0.1.7

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.
@@ -29,6 +29,7 @@
29
29
 
30
30
  namespace gea::embedded::ui {
31
31
 
32
+ #if GEA_CSS_SCROLLING
32
33
  namespace {
33
34
 
34
35
  bool hasTransformState(const Node &node)
@@ -107,8 +108,8 @@ bool isSlotRepositionCandidate(const TreeState &state, int node, int scrollNode)
107
108
  if (n.style.position != 1) return false;
108
109
  // Anchored via top/bottom (the windowed axis); refresh() recomputes y from
109
110
  // these offsets directly.
110
- if (n.style.pos_offsets[0] == kUnset && n.style.pos_offset_percent[0] == kUnset &&
111
- n.style.pos_offsets[2] == kUnset && n.style.pos_offset_percent[2] == kUnset)
111
+ if (GEA_CSS_POSITION_PX_0(n.style) == kUnset && GEA_CSS_POSITION_PERCENT_0(n.style) == kUnset &&
112
+ GEA_CSS_POSITION_PX_2(n.style) == kUnset && GEA_CSS_POSITION_PERCENT_2(n.style) == kUnset)
112
113
  return false;
113
114
  if (hasTransformState(n)) return false;
114
115
  // The reconcile translates the slot box; a pending size change needs layout.
@@ -117,10 +118,11 @@ bool isSlotRepositionCandidate(const TreeState &state, int node, int scrollNode)
117
118
  return true;
118
119
  }
119
120
 
120
- int resolvedSlotOffset(const Node &slot, int side, int basis)
121
+ template <int side>
122
+ int resolvedSlotOffset(const Node &slot, int basis)
121
123
  {
122
- int offset = slot.style.pos_offsets[side] != kUnset ? slot.style.pos_offsets[side] : 0;
123
- const int percent = slot.style.pos_offset_percent[side];
124
+ int offset = GEA_CSS_POSITION_PX(slot.style, side) != kUnset ? GEA_CSS_POSITION_PX(slot.style, side) : 0;
125
+ const int percent = GEA_CSS_POSITION_PERCENT(slot.style, side);
124
126
  if (percent != kUnset) {
125
127
  const int numerator = basis * percent;
126
128
  offset += (numerator + (numerator >= 0 ? 500 : -500)) / 1000;
@@ -333,7 +335,10 @@ int RootScrollOnlyRefresh::refreshNode(int root,
333
335
  if (hasTransformState(*n)) return -1;
334
336
  if (n->style.opacity != 255 || hasAnyBorder(n->style)) return -1;
335
337
  for (int r = 0; r < 4; r++) {
336
- if (n->style.border_radius[r] != 0 || n->style.border_radius_percent[r] != kUnset) return -1;
338
+ if (n->style.border_radius[GEA_CSS_RADIUS_INDEX(r)] != 0) return -1;
339
+ #if GEA_CSS_PERCENT_RADIUS
340
+ if (n->style.border_radius_percent[GEA_CSS_RADIUS_INDEX(r)] != kUnset) return -1;
341
+ #endif
337
342
  }
338
343
  foundNode = i;
339
344
  continue;
@@ -537,18 +542,18 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
537
542
  if (slot.style.display == 1) continue; // display:none — erase old rect only
538
543
 
539
544
  int newX = slot.layout.x;
540
- if (slot.style.pos_offsets[3] != kUnset || slot.style.pos_offset_percent[3] != kUnset)
541
- newX = n->layout.x + resolvedSlotOffset(slot, 3, n->layout.width);
542
- else if (slot.style.pos_offsets[1] != kUnset || slot.style.pos_offset_percent[1] != kUnset)
545
+ if (GEA_CSS_POSITION_PX_3(slot.style) != kUnset || GEA_CSS_POSITION_PERCENT_3(slot.style) != kUnset)
546
+ newX = n->layout.x + resolvedSlotOffset<3>(slot, n->layout.width);
547
+ else if (GEA_CSS_POSITION_PX_1(slot.style) != kUnset || GEA_CSS_POSITION_PERCENT_1(slot.style) != kUnset)
543
548
  newX = n->layout.x + n->layout.width - slot.layout.width -
544
- resolvedSlotOffset(slot, 1, n->layout.width);
549
+ resolvedSlotOffset<1>(slot, n->layout.width);
545
550
 
546
551
  int newY = slot.layout.y;
547
- if (slot.style.pos_offsets[0] != kUnset || slot.style.pos_offset_percent[0] != kUnset)
548
- newY = n->layout.y - n->layout.scroll_y + resolvedSlotOffset(slot, 0, n->layout.height);
549
- else if (slot.style.pos_offsets[2] != kUnset || slot.style.pos_offset_percent[2] != kUnset)
552
+ if (GEA_CSS_POSITION_PX_0(slot.style) != kUnset || GEA_CSS_POSITION_PERCENT_0(slot.style) != kUnset)
553
+ newY = n->layout.y - n->layout.scroll_y + resolvedSlotOffset<0>(slot, n->layout.height);
554
+ else if (GEA_CSS_POSITION_PX_2(slot.style) != kUnset || GEA_CSS_POSITION_PERCENT_2(slot.style) != kUnset)
550
555
  newY = n->layout.y - n->layout.scroll_y + n->layout.height - slot.layout.height -
551
- resolvedSlotOffset(slot, 2, n->layout.height);
556
+ resolvedSlotOffset<2>(slot, n->layout.height);
552
557
 
553
558
  const int dx = newX - slot.layout.x;
554
559
  const int dy = newY - slot.layout.y;
@@ -858,7 +863,19 @@ void rootScrollImageHoldTick()
858
863
  if (state.mountedRoot < 0) return;
859
864
  Tree::instance().markDisplayListDirty();
860
865
  state.nodes[state.mountedRoot].render.dirty = 1;
866
+ #if GEA_CSS_SCROLLING
861
867
  state.nodes[state.mountedRoot].render.non_scroll_dirty = 1;
868
+ #endif
869
+ }
870
+
871
+ #else
872
+ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
873
+ {
874
+ (void)root; (void)width; (void)height;
875
+ return 0;
862
876
  }
863
877
 
878
+ void rootScrollImageHoldTick() {}
879
+ #endif
880
+
864
881
  } // namespace gea::embedded::ui