@geastack/engine 0.1.20 → 0.1.22
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/canvas.cpp +150 -27
- package/image_store.cpp +308 -1
- package/package.json +1 -1
- package/ui/CSS_FEATURES.md +51 -0
- package/ui/canvas_element.cpp +12 -16
- package/ui/core.cpp +10 -7
- package/ui/document.cpp +25 -0
- package/ui/input.cpp +341 -11
- package/ui/input_render.cpp +62 -17
- package/ui/input_retirement.h +3 -0
- package/ui/internal.h +38 -1
- package/ui/layout.cpp +68 -16
- package/ui/layout_snapshot.cpp +119 -70
- package/ui/layout_snapshot.h +1 -0
- package/ui/node_features.h +6 -0
- package/ui/node_model.h +23 -2
- package/ui/render.cpp +1154 -64
- package/ui/root_scroll_refresh.cpp +372 -66
- package/ui/root_scroll_refresh.h +4 -0
- package/ui/style.cpp +74 -21
- package/ui/style.h +18 -1
- package/ui/svg_element.h +98 -0
- package/ui/svg_element_impl.h +1589 -0
- package/ui/svg_geometry.h +1767 -0
- package/ui/text.cpp +7 -6
- package/ui/tree_events.cpp +15 -0
- package/ui/tree_internal.h +12 -0
- package/ui/tree_nodes.cpp +37 -2
- package/ui/tree_render.cpp +290 -22
- package/ui/tree_state.h +9 -0
- package/ui/tree_style.cpp +32 -0
- package/ui/view.cpp +27 -9
- package/ui/viewport_region.cpp +53 -0
- package/ui/viewport_region.h +3 -0
- package/ui/virtual_keyboard.cpp +279 -23
- package/ui/virtual_keyboard_icons.h +114 -0
package/ui/text.cpp
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
#include "internal.h"
|
|
3
3
|
#include "display.h"
|
|
4
|
+
#include "memory.h"
|
|
4
5
|
#include "graphics/font.h"
|
|
5
6
|
#include "refresh_perf.h"
|
|
6
7
|
#include "tree_state.h"
|
|
@@ -134,7 +135,7 @@ struct LineBreakCacheEntry {
|
|
|
134
135
|
std::uint16_t lineWidths[kMaxCachedLines];
|
|
135
136
|
};
|
|
136
137
|
|
|
137
|
-
LineBreakCacheEntry gLineBreakCache[kLineBreakCacheSlots];
|
|
138
|
+
GEA_EXT_BSS LineBreakCacheEntry gLineBreakCache[kLineBreakCacheSlots];
|
|
138
139
|
|
|
139
140
|
inline std::uint32_t hashTextPrefix(const char *text)
|
|
140
141
|
{
|
|
@@ -1072,7 +1073,7 @@ struct TextCoverageSink {
|
|
|
1072
1073
|
}
|
|
1073
1074
|
};
|
|
1074
1075
|
|
|
1075
|
-
static void drawStyledTextFontFamily(const char *text,int x,int y,
|
|
1076
|
+
static void drawStyledTextFontFamily(const char *text,int x,int y,gea::framework::graphics::pixel::native_t color,int family,int size,int weight=400,int stretch=1000) {
|
|
1076
1077
|
#if GEA_EMBEDDED_TTF_FREETYPE
|
|
1077
1078
|
gea::platform::display::Display::drawTextFontFamily(text,x,y,color,family,size,weight,stretch);
|
|
1078
1079
|
#else
|
|
@@ -1210,7 +1211,7 @@ public:
|
|
|
1210
1211
|
|
|
1211
1212
|
private:
|
|
1212
1213
|
#ifdef GEA_EMBEDDED_HAS_GENERATED_FONTS
|
|
1213
|
-
static void drawRasterizedWrapped(const char *text, int x, int y, int maxWidth,
|
|
1214
|
+
static void drawRasterizedWrapped(const char *text, int x, int y, int maxWidth, gea::framework::graphics::pixel::native_t color, int textAlign, int containerWidth, int fontId, int fontSize, int lineHeight, int clipX0, int clipY0, int clipX1, int clipY1, int ellipsisMaxHeight = 0, int firstLineIndent = 0, const TextCoverageSink *coverageSink = nullptr, int fontWeight = 400, int fontStretch = 1000)
|
|
1214
1215
|
{
|
|
1215
1216
|
// Inline continuation: the run's first line starts `firstLineIndent` px in
|
|
1216
1217
|
// from the box's left edge (the pen position it inherited from the box
|
|
@@ -1357,7 +1358,7 @@ private:
|
|
|
1357
1358
|
// appending an ASCII "..." when text-overflow: ellipsis is set, or hard-
|
|
1358
1359
|
// clipping at the box edge otherwise. The truncated run always fits within
|
|
1359
1360
|
// maxWidth, so it never wraps and never spills past the content box.
|
|
1360
|
-
static void drawRasterizedSingleLine(const char *text, int x, int y, int maxWidth,
|
|
1361
|
+
static void drawRasterizedSingleLine(const char *text, int x, int y, int maxWidth, gea::framework::graphics::pixel::native_t color, int textAlign, int containerWidth, int fontId, int fontSize, int lineHeight, bool ellipsis, int clipX0, int clipY0, int clipX1, int clipY1, const TextCoverageSink *coverageSink = nullptr, int fontWeight = 400, int fontStretch = 1000)
|
|
1361
1362
|
{
|
|
1362
1363
|
gea::framework::graphics::RasterizedFont font = gea::framework::graphics::FontRegistry::rasterizedFamily(fontId, fontSize, fontWeight, fontStretch);
|
|
1363
1364
|
if (!font.valid()) return;
|
|
@@ -1444,7 +1445,7 @@ private:
|
|
|
1444
1445
|
}
|
|
1445
1446
|
#endif
|
|
1446
1447
|
|
|
1447
|
-
static void drawBitmapWrapped(const char *text, int x, int y, int maxWidth,
|
|
1448
|
+
static void drawBitmapWrapped(const char *text, int x, int y, int maxWidth, gea::framework::graphics::pixel::native_t color, float scale, int textAlign, int containerWidth, int lineHeight, int clipX0, int clipY0, int clipX1, int clipY1, int firstLineIndent = 0, const TextCoverageSink *coverageSink = nullptr, int fontWeight = 400, int fontStretch = 1000)
|
|
1448
1449
|
{
|
|
1449
1450
|
if (scale < 0.1f) scale = 1.0f;
|
|
1450
1451
|
int glyphWidth = static_cast<int>(kBitmapFontWidth * scale + 0.5f);
|
|
@@ -1495,7 +1496,7 @@ private:
|
|
|
1495
1496
|
// that is what `measureBitmap` charges for, so counting bytes here put the
|
|
1496
1497
|
// truncation, the ellipsis budget and the alignment offset in different units
|
|
1497
1498
|
// from the layout that placed the text.
|
|
1498
|
-
static void drawBitmapSingleLine(const char *text, int x, int y, int maxWidth,
|
|
1499
|
+
static void drawBitmapSingleLine(const char *text, int x, int y, int maxWidth, gea::framework::graphics::pixel::native_t color, float scale, int textAlign, int containerWidth, int lineHeight, bool ellipsis, int clipX0, int clipY0, int clipX1, int clipY1, const TextCoverageSink *coverageSink = nullptr, int fontWeight = 400, int fontStretch = 1000)
|
|
1499
1500
|
{
|
|
1500
1501
|
(void)lineHeight;
|
|
1501
1502
|
if (scale < 0.1f) scale = 1.0f;
|
package/ui/tree_events.cpp
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
#include "internal.h"
|
|
7
7
|
#include "tree_internal.h"
|
|
8
8
|
#include "tree_state.h"
|
|
9
|
+
#include "svg_element.h"
|
|
9
10
|
#include <stdexcept>
|
|
10
11
|
|
|
11
12
|
#include <algorithm>
|
|
@@ -913,6 +914,11 @@ void Tree::setAttribute(int node, const char *name, const char *value)
|
|
|
913
914
|
return;
|
|
914
915
|
}
|
|
915
916
|
ensureRareData(node).attributes.set(name, value);
|
|
917
|
+
#if GEA_UI_SVG
|
|
918
|
+
// SVG geometry/paint attributes keep their full value (path data easily
|
|
919
|
+
// exceeds the generic store's bound) and repaint the owning <svg>.
|
|
920
|
+
if (svg::noteAttribute(node, name, value ? value : "")) return;
|
|
921
|
+
#endif
|
|
916
922
|
if (state.nodes[node].type == NodeType::Image && sameName(name, "src")) {
|
|
917
923
|
const auto &style = state.nodes[node].computedStyle();
|
|
918
924
|
const bool fixedBox = (style.width != kUnset || style.width_percent != kUnset) &&
|
|
@@ -985,6 +991,9 @@ void Tree::removeAttribute(int node, const char *name)
|
|
|
985
991
|
setClassName(node, "");
|
|
986
992
|
return;
|
|
987
993
|
}
|
|
994
|
+
#if GEA_UI_SVG
|
|
995
|
+
svg::noteAttribute(node, name, nullptr);
|
|
996
|
+
#endif
|
|
988
997
|
NodeRareData *rd = rareDataFor(node);
|
|
989
998
|
if (!rd) return; // no rare-data block → no attributes to remove
|
|
990
999
|
const bool hadAttribute = rd->attributes.remove(name);
|
|
@@ -1033,6 +1042,9 @@ const char *Tree::getAttribute(int node, const char *name) const
|
|
|
1033
1042
|
classBuf = className(node);
|
|
1034
1043
|
return classBuf.c_str();
|
|
1035
1044
|
}
|
|
1045
|
+
#if GEA_UI_SVG
|
|
1046
|
+
if (const char *full = svg::attribute(node, name)) return full;
|
|
1047
|
+
#endif
|
|
1036
1048
|
const NodeRareData *rd = rareDataFor(node);
|
|
1037
1049
|
return rd ? rd->attributes.get(name) : "";
|
|
1038
1050
|
}
|
|
@@ -1042,6 +1054,9 @@ bool Tree::hasAttribute(int node, const char *name) const
|
|
|
1042
1054
|
const auto &state = treeState();
|
|
1043
1055
|
if (node < 0 || node >= state.nodeCount) return false;
|
|
1044
1056
|
if (sameName(name, "class")) return !className(node).empty();
|
|
1057
|
+
#if GEA_UI_SVG
|
|
1058
|
+
if (svg::attribute(node, name)) return true;
|
|
1059
|
+
#endif
|
|
1045
1060
|
const NodeRareData *rd = rareDataFor(node);
|
|
1046
1061
|
return rd && rd->attributes.has(name);
|
|
1047
1062
|
}
|
package/ui/tree_internal.h
CHANGED
|
@@ -140,6 +140,10 @@ public:
|
|
|
140
140
|
int scrollTop(int node) const;
|
|
141
141
|
void setScrollTop(int node, int scrollTop);
|
|
142
142
|
void scrollIntoView(int node);
|
|
143
|
+
// scrollIntoView, but the target ends up inside the scroller's padding
|
|
144
|
+
// box rather than flush with its edge -- how LVGL scrolls a focused
|
|
145
|
+
// widget into view.
|
|
146
|
+
void scrollIntoViewKeepingPadding(int node);
|
|
143
147
|
void applyPendingScrollIntoView();
|
|
144
148
|
|
|
145
149
|
// Active focus for `<input>` elements. Pixel-only targets can paint the
|
|
@@ -154,6 +158,14 @@ public:
|
|
|
154
158
|
void commitActiveInput();
|
|
155
159
|
bool activeInputCaretVisible() const;
|
|
156
160
|
void tickInputCaret(int timestampMs);
|
|
161
|
+
// Caret byte index in the active input's value, clamped to it.
|
|
162
|
+
int activeInputCaret() const;
|
|
163
|
+
// Moves the caret and restarts its blink (shown), as lv_textarea does.
|
|
164
|
+
void setActiveInputCaret(int pos);
|
|
165
|
+
// Characters [from, to) were just typed into the active (password) input.
|
|
166
|
+
void noteActiveInputTyped(int from, int to);
|
|
167
|
+
// The span of a password input's value still shown in clear, if any.
|
|
168
|
+
bool inputPasswordReveal(int id, int *from, int *to) const;
|
|
157
169
|
|
|
158
170
|
void markDisplayListDirty();
|
|
159
171
|
void markDisplayListContentDirty();
|
package/ui/tree_nodes.cpp
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
#include "internal.h"
|
|
3
|
+
#include "svg_element.h"
|
|
3
4
|
#include "node.h"
|
|
4
5
|
#include "input_retirement.h"
|
|
5
6
|
#include <stdexcept>
|
|
@@ -127,6 +128,9 @@ void resetNodeSlot(TreeState &state, int id)
|
|
|
127
128
|
#endif
|
|
128
129
|
state.classLists[id].clear();
|
|
129
130
|
state.canvases.remove(id);
|
|
131
|
+
#if GEA_UI_SVG
|
|
132
|
+
svg::releaseNode(id);
|
|
133
|
+
#endif
|
|
130
134
|
state.nodeCommandDirty[id] = 0;
|
|
131
135
|
state.nodeCommandDirtyBoundsValid[id] = 0;
|
|
132
136
|
state.nodeCommandDirtyCanOverpaint[id] = 0;
|
|
@@ -148,6 +152,10 @@ void trimInactiveTail(TreeState &state)
|
|
|
148
152
|
bool localAbsoluteLeafTreeMutation(const TreeState &state, int child)
|
|
149
153
|
{
|
|
150
154
|
if (child < 0 || child >= state.nodeCount) return false;
|
|
155
|
+
#if GEA_UI_SVG
|
|
156
|
+
// SVG shapes paint through their svg's scene; validateScenes repaints it.
|
|
157
|
+
if (svg::isShape(child)) return true;
|
|
158
|
+
#endif
|
|
151
159
|
const Node &node = state.nodes[child];
|
|
152
160
|
if (node.computedStyle().display == kDisplayNone) return false;
|
|
153
161
|
if (node.computedStyle().position != 1) return false;
|
|
@@ -177,6 +185,9 @@ void Tree::clear()
|
|
|
177
185
|
}
|
|
178
186
|
resetRareStylePool(); // drop all cold-style entries; node handles reset by the Node{} loop below
|
|
179
187
|
state.canvases.clear();
|
|
188
|
+
#if GEA_UI_SVG
|
|
189
|
+
svg::clearAll();
|
|
190
|
+
#endif
|
|
180
191
|
std::memset(state.nodeActive, 0, sizeof(state.nodeActive));
|
|
181
192
|
// Reset EVERY slot of state.nodes[], not just [0, nodeCount). If the
|
|
182
193
|
// next app's tree has fewer nodes than the previous app's tree, the
|
|
@@ -211,6 +222,7 @@ void Tree::clear()
|
|
|
211
222
|
std::memset(state.scrollDirtyNodes, 0, sizeof(state.scrollDirtyNodes));
|
|
212
223
|
state.scrollDirtyAny = false;
|
|
213
224
|
state.pendingScrollIntoViewNode = -1;
|
|
225
|
+
state.pendingScrollIntoViewKeepsPadding = false;
|
|
214
226
|
#endif
|
|
215
227
|
// Drop display-list commands and growable render scratch from the previous app.
|
|
216
228
|
// Per-frame DisplayList::clear() keeps capacity for reuse; app/tree reset is the
|
|
@@ -247,13 +259,29 @@ int Tree::createNode(NodeType type)
|
|
|
247
259
|
break;
|
|
248
260
|
}
|
|
249
261
|
if (id < 0) {
|
|
250
|
-
if (state.nodeCount >= kMaxNodes)
|
|
262
|
+
if (state.nodeCount >= kMaxNodes) {
|
|
263
|
+
// Callers drop the -1, so the element and everything that would
|
|
264
|
+
// hang under it are never attached, laid out or drawn: without
|
|
265
|
+
// this line a view just disappears. Reported once per process.
|
|
266
|
+
static bool reported = false;
|
|
267
|
+
if (!reported) {
|
|
268
|
+
reported = true;
|
|
269
|
+
std::printf("[tree] node pool full (%d nodes, GEA_EMBEDDED_MAX_NODES): new elements are not created "
|
|
270
|
+
"and the views they belong to are not drawn; raise GEA_EMBEDDED_MAX_NODES for this target\n",
|
|
271
|
+
kMaxNodes);
|
|
272
|
+
std::fflush(stdout);
|
|
273
|
+
}
|
|
274
|
+
return -1;
|
|
275
|
+
}
|
|
251
276
|
id = state.nodeCount++;
|
|
252
277
|
}
|
|
253
278
|
gea::framework::identity::activate(id);
|
|
254
279
|
const auto allocatedOwner = gea::framework::identity::node(id);
|
|
255
280
|
state.nodeActive[id] = 1;
|
|
256
281
|
releaseRareData(id); // free any block from a prior occupant before reinit
|
|
282
|
+
#if GEA_UI_SVG
|
|
283
|
+
svg::releaseNode(id);
|
|
284
|
+
#endif
|
|
257
285
|
if (!gea::framework::identity::current(id, allocatedOwner)) return -1;
|
|
258
286
|
NodeLifecycle::init(&state.nodes[id], type);
|
|
259
287
|
LayoutEngine::instance().resetNodeLayoutState(id);
|
|
@@ -854,7 +882,14 @@ void Tree::removeNode(int id)
|
|
|
854
882
|
!gea::framework::identity::current(id, removingOwner)) return;
|
|
855
883
|
}
|
|
856
884
|
Node *n = &state.nodes[id];
|
|
857
|
-
|
|
885
|
+
#if GEA_UI_SVG
|
|
886
|
+
// A shape draws nothing of its own: its svg repaints (validateScenes sees
|
|
887
|
+
// the subtree change), so the viewport needs no structural repaint.
|
|
888
|
+
if (svg::isShape(id))
|
|
889
|
+
markDisplayListContentDirty();
|
|
890
|
+
else
|
|
891
|
+
#endif
|
|
892
|
+
markDisplayListDirty();
|
|
858
893
|
n->render.dirty = 1;
|
|
859
894
|
n->render.layout_dirty = 1;
|
|
860
895
|
#if GEA_CSS_SCROLLING
|