3859 Commits
Author SHA1 Message Date
Liu fa35037c1a fix(ptk): handler self-removal during dispatch should not cause crash 2026-08-05 22:42:12 +08:00
Liu 31c6f199c0 fix: UI display mode should be reset after destruction 2026-08-05 22:42:11 +08:00
Liu e716f48233 fix: Consola -> Consolas 2026-08-05 22:42:10 +08:00
Liu eec69ba56a chore: update header files 2026-08-05 22:42:10 +08:00
Copilot cc0b79fccb feat: update settings APIs and add persistent configuration support (#329)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-08-05 22:42:03 +08:00
Liu 2d17001076 chore: remove unused debug log 2026-08-05 22:41:32 +08:00
Liu 65022e9437 test(flex-layout): add gap example to preview fixture
Add a new "(18) gap" example block in tests/fixtures/test_flex_layout.xml
that exercises the gap shorthand and longhand variants:

- gap: 10px
- gap: 10px 5px with flex-wrap: wrap
- row-gap: 10px with flex-direction: column
- column-gap: 10px with justify-content: space-between

Define the corresponding utility classes (.gap-2, .gap-2-1, .row-gap-2,
.column-gap-2) in test_flex_layout.css so the example renders in
`xmake run preview-flex-layout`. The new block is appended after the
existing Browser Layout example to preserve the indices used by the
flex-layout integration tests.
2026-08-05 22:41:31 +08:00
Liu f54cd12539 feat(css): add gap, row-gap and column-gap support
Add the CSS gap shorthand and its row-gap/column-gap longhands for flex
containers.

- Register row-gap/column-gap as longhand properties and gap as a
  shorthand accepting [ normal | <length-percentage> ]{1,2}.
- Add css_gap_t (CSS_GAP_INHERIT/SET/NORMAL) and corresponding
  type/unit/value fields on css_computed_style_t.
- Implement cascade logic in lib/css/src/properties/gap.c, resolving
  normal to zero and rejecting auto.
- Apply gaps in ui_flexbox_layout: main-axis gap participates in line
  size, wrap detection, justify-content space and per-item positioning;
  cross-axis gap participates in cross-size accumulation and line
  positioning. The last item/line never gets a trailing gap. Percentage
  gaps resolve against the container content-box on the corresponding
  axis.
- Cover gap parsing/cascading in lib/css/tests (single/two values,
  axis-only, normal, percentage) and add a flex layout integration test
  exercising column-gap, row-gap, wrapped two-value gap and normal.
2026-08-05 22:41:30 +08:00
Liu 3d2a8dc35a fix(css): reset parse target on '}' to avoid stale property name
When parsing a value-less declaration that ended with '}' (e.g. inside
`.gap-2 { gap: 8px }` where `gap` is not yet a supported property),
the parser stayed in CSS_PARSER_TARGET_VALUE state. The next rule was
then fed into the value parser with style_parser.property already
cleared, producing misleading "unsupported property" errors and
corrupting subsequent parsing.

Switch target to CSS_PARSER_TARGET_NONE on '}' and to
CSS_PARSER_TARGET_KEY on ';' inside the switch, mirroring the
end-of-block / end-of-declaration semantics. Add an assert to catch any
future regression where css_parser_commit is reached without a
property name.
2026-08-05 22:41:30 +08:00
CopilotandLiu 45f16a95d7 refactor(pandagl): unify rounded border and crop corner rendering (#327)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Liu <lc-soft@live.cn>
2026-08-05 22:41:29 +08:00
Liu a55c60da24 ci: avoid duplicate builds on PR branch push 2026-08-05 22:41:28 +08:00
CopilotandLiu 01a0d11be3 refactor(ui): consolidate flexbox row/column axis logic
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Liu <lc-soft@live.cn>
2026-08-05 22:41:27 +08:00
Liu 926b7252d1 fix(ptk): handle window creation failures on win32 2026-08-05 22:41:26 +08:00
Liu 7952ff2508 fix(ui-server): correct inverted strcmp for update_visible flag
The visible property check was missing '== 0', so any non-visible property change incorrectly set update_visible to true, while actual visible mutations were ignored. This caused the window to never receive ptk_window_show on Windows.
2026-08-05 22:41:25 +08:00
Liu 3f49931cb6 fix(ui): avoid mbstowcs assertion in ui_print_tree on Windows
The %ls format in logger_error went through UCRT's wide-to-multibyte path, which triggered a debug assertion in mbstowcs.cpp under non-UTF-8 locales and also produced unreadable output when the console code page was GBK.

Switch the tree drawing to UTF-8 byte literals so the log path stays purely narrow, and temporarily set the console output code page to CP_UTF8 around the dump so the box-drawing characters render correctly.
2026-08-05 22:41:24 +08:00
Liu 3a867040d1 build(xmake): fix package name, target naming and example install
- Remove per-lib set_project() calls that overrode the global lcui
  project name; xmake show now correctly reports the project as lcui.
- Move per-lib set_version() into the corresponding target() block so
  each sub-library keeps an independent version usable for standalone
  packaging.
- Add set_default(false) and set_group(examples) to all pandagl
  examples so they are no longer picked up by xmake package.
- Rename targets to use dashes for consistency:
    pandagl_cairo_example  -> pandagl-cairo-example
    preview_block_layout   -> preview-block-layout
    preview_flex_layout    -> preview-flex-layout
    preview_scrollbar      -> preview-scrollbar
    preview_widget_opacity -> preview-widget-opacity
- Bump yutil submodule to drop its set_project() call as well.
2026-08-05 22:41:23 +08:00
Liu 9040684246 ci: add pre-commit formatting via lint-staged and clang-format 2026-08-05 22:41:22 +08:00
Liu 296c62240e refactor(pandagl): split text.c and rename caret/text-IO API
Split lib/pandagl/src/text/text.c into four cohesive units backed
by a library-private header:

- text.c           : type lifecycle, line storage, geometry,
                     dirty-rect bookkeeping, top-level update
- text_typeset.c   : line breaking, merging, autowrap, alignment
- text_render.c    : per-char bitmap refresh and drawing
- text_edit.c      : caret, insert/delete/backspace, text I/O
- text_internal.h  : library-private cross-file helpers
                     (not installed)

Drop the 'insert' overload that conflated 'cursor' with 'insertion
point' and align the field/API names with the cursor concept used
in mainstream GUI toolkits:

  insert_x, insert_y                -> caret.x, caret.y
                                       (new pd_text_caret_t sub-struct)
  pd_text_set_insert_position       -> pd_text_set_caret
  pd_text_set_insert_pixel_position -> pd_text_set_caret_pixel
  pd_text_get_insert_pixel_position -> pd_text_get_caret_pixel
  pd_text_get_char_pixel_position   -> pd_text_get_char_pixel

Make text I/O symmetric and intent-revealing:

  pd_text_dump                       -> pd_text_read
                                        (mirrors pd_text_write)
  pd_text_empty                      -> pd_text_clear
                                        (the previous static helper
                                        is renamed to pd_text_reset_lines)
  pd_text_set_typeset_task           -> pd_text_request_typeset

Add pd_text_to_wcs(text), which allocates and returns the full
buffer contents including line endings. It complements the
range-based pd_text_read for callers that just want the whole
text as a wide string.

Fix the mulitiline_enabled -> multiline_enabled typo while at it.

All call sites in lib/pandagl, src/widgets and the tests are
updated. test_text_edit.c gains two cases for pd_text_to_wcs
covering full-text round-trip and the empty-text edge case.
2026-08-05 22:41:21 +08:00
Liu 0ac4b46b19 refactor(pandagl): flatten glyph bitmap cache to hash + lru
The previous bitmap cache was a three-level rbtree keyed by
(wchar_t, font_id, size), which had two problems:

1. The wchar_t key collapses Unicode codepoints that map to the
   same glyph in a given face into separate cache slots, missing
   real reuse opportunities and bloating memory under text-heavy
   workloads.
2. There was no upper bound; long-running apps would grow the
   cache without limit until pd_font_library_destroy.

Replace it with a flat hash table keyed by a packed 64-bit
(face_id, glyph_index, size) tuple, plus a doubly-linked LRU list
for O(1) eviction.

- pd_font_engine gets a new get_glyph_index hook; FreeType maps
  via FT_Get_Char_Index, the in-core engine treats codepoints as
  identity (no cmap).
- pd_font_cache_add_bitmap / pd_font_cache_get_bitmap now resolve
  the glyph index via the engine before keying the cache, so the
  same glyph reused across composed sequences hits the same entry.
- pd_font_cache_set_capacity / pd_font_cache_count expose the LRU
  bound (default 8192 entries, 0 = unlimited) for runtime tuning
  and tests. Shrinking the capacity evicts immediately.
- list_t is used with append at tail / evict from head so the
  yutil tail.prev pointer stays consistent (list_link does not
  update it).

Adds lib/pandagl/tests/test_font_cache.c covering hit identity,
size differentiation, unknown-codepoint fallback, and LRU eviction.
2026-08-05 22:41:20 +08:00
Liu d64fe6202b refactor(pandagl): rename font API to align with typeface/glyph concepts
The previous naming conflated multiple levels of the font model:
pd_font_t actually owned a single typeface resource (FT_Face), while
pd_font_bitmap_t represented a per-glyph bitmap. The pd_font_library_*
prefix was redundant under the pd_font_ namespace and resulted in
verbose call sites (up to 34 chars).

Type renames
- pd_font_t          -> pd_font_face_t
- pd_font_bitmap_t   -> pd_glyph_bitmap_t
- font_engine_t      -> pd_font_engine_t
- struct tags updated to match the typedef names.

API renames (grouped by sub-object)
- Face lifecycle:    pd_font_create/destroy -> pd_font_face_create/destroy
- Face registry:     pd_font_library_add_font     -> pd_font_register
                     pd_font_library_get_font     -> pd_font_get
                     pd_font_library_get_font_id  -> pd_font_get_id
                     pd_font_library_query        -> pd_font_query
                     pd_font_library_load_file    -> pd_font_load_file
                     pd_font_library_get_font_path-> pd_font_find_path
                     pd_font_library_get_default_font -> pd_font_get_default
                     pd_font_library_set_default_font -> pd_font_set_default
                     pd_font_library_set_font_family_alias
                                                  -> pd_font_family_set_alias
                     pd_font_library_update_font_weight
                                                  -> pd_font_replace_weight
                     pd_font_library_update_font_style
                                                  -> pd_font_replace_style
- Parsing helpers:   pd_font_library_detect_weight -> pd_font_parse_weight
                     pd_font_library_detect_style  -> pd_font_parse_style
- Glyph rendering:   pd_font_library_render_bitmap -> pd_font_render_glyph
                     pd_canvas_mix_font_bitmap     -> pd_canvas_mix_glyph_bitmap
                     pd_font_bitmap_init/destroy   -> pd_glyph_bitmap_init/destroy
- Glyph cache:       pd_font_library_add_bitmap    -> pd_font_cache_add_bitmap
                     pd_font_library_get_bitmap    -> pd_font_cache_get_bitmap

pd_font_library_init/destroy are kept as the module lifecycle entry
points, matching the FT_Init_FreeType / FT_Done_FreeType convention.

All call sites in lib/pandagl, lib/ui, lib/ui-xml, src/, tests/ and
examples/ are updated accordingly.
2026-08-05 22:41:19 +08:00
Liu 18a98e5bd6 fix(pandagl): text deletion crashes and pd_text_dump missing line breaks
pd_text_delete_ex
- Use-after-free: in same-line branch, pd_text_delete_line(end_y) was
  followed by pd_text_line_set_length / pd_text_update_line_size on the
  freed line. Now returns immediately after delete_line in that path.
- Off-by-one: cross-line merge used j = end_x + 1, dropping one char
  when end_x is mid-line. Now j = end_x, and the line-tail special
  case resets end_x to 0 explicitly.
- OOB read: prev_line = text->lines[char_y - 1] without bounds check.
  Now guarded with char_y > 0 ? ... : NULL.
- Memory leak: chars in the deleted range were never freed and
  ownership transfer between lines could double-free on delete_line.

pd_text_line_set_length
- realloc-grown slots were not zeroed, leaving uninitialized pointer
  values that could be misread as live pd_char_t *.

pd_text_dump
- col was not reset when advancing to the next line, so output was
  truncated at the first line's length.
- Did not emit the line-ending characters recorded in line->eol, so
  multi-line text was concatenated without separators.

Helpers
- Extract pd_text_line_erase / pd_text_line_move to centralize char
  ownership transfer; reused in pd_text_merge_line.

Tests
- Add lib/pandagl/tests/test_text_edit.c with 11 cases covering the
  original crash scenarios (backspace at last empty line, delete at
  line end), boundary cases, and dump behavior.

Closes #270
2026-08-05 22:41:18 +08:00
Liu bcd87fbc74 ci: remove yutil tests 2026-08-05 22:41:17 +08:00
Liu 03e7849296 ci: add xvfb and codecov-action 2026-08-05 22:41:16 +08:00
Liu 890fb49536 fix(pandagl): implicit declaration of function ‘pd_rect’ 2026-08-05 22:41:16 +08:00
Liu a56361db75 ci: cache xmake packages and bump action versions
Add actions/cache step covering xmake package and repository directories on both Linux and Windows runners. Cache key is keyed by runner OS, build mode (coverage on Linux, release on Windows) and the hashes of root and examples xmake-requires.lock so coverage and release artifacts do not pollute each other and examples deps share the same cache.

Bump actions/checkout to v4 with submodules: recursive (replacing the manual submodule update step), upload-artifact to v4 and download-artifact to v4.
2026-08-05 22:41:15 +08:00
Liu fa3a7b6e0c build(yutil): bump submodule for tests rundir fix
Pulls in yutil c91be801 which sets the yutil-tests rundir to scriptdir, fixing the Windows execv error 267 reported by xmake run yutil-tests.
2026-08-05 22:41:14 +08:00
Liu 2404c535f3 refactor(ui-router): extract router widgets into a new lib
Create lib/ui-router/ as a thin UI binding layer between libui and librouter, exposing the router-link and router-view widgets under <ui_router/...>.

* Move src/widgets/router_{link,view}.c and the matching public headers into lib/ui-router/src and lib/ui-router/include.

* Drop include/LCUI/widgets/router_{link,view}.h and the corresponding entries in include/LCUI/widgets.h; src/lcui_widgets.c now pulls registrations from <ui_router.h>.

* Wire libui-router into the root xmake.lua add_includedirs and lcui add_deps chain; libui-router depends on yutil + libui + librouter only.

* tests/integration/test_router.c stays at the integration layer (router widgets exercise text inheritance and other libui internals); only its #include set is updated to use <ui_router.h>.

* Bump CHANGELOG and add bilingual lib/ui-router/README.
2026-08-05 22:41:13 +08:00
Liu 75dbca815d test: reorganize test suite with xmake test integration
Restructure the test infrastructure with these changes:

* Extend libctest with ctest_suite_t, ctest_parse_args, ctest_run_suites and CTEST_MAIN macro to standardize test entry points; support --grep / --grep= / --list / --interactive flags; add ctest-tests for self-tests.

* Regroup tests by lib boundary: sink unit tests into lib/<name>/tests/ with <lib>_<topic> entry function names, move fixtures into lib/<name>/tests/fixtures/, rename top-level tests/cases/ to tests/integration/ for cross-lib integration tests.

* Add tests/scenes/ for reusable widget tree builders shared by integration cases and visual preview binaries; add tests/previews/ with 4 diagnostic binaries (flex_layout, block_layout, widget_opacity, scrollbar).

* Rewrite all describe/equal description strings using 'should ...' style or noun topic names; drop redundant lcui_quit/lcui_main calls from integration cases.

* Integrate xmake test via add_tests(\default\) and a shared tests.runnable rule defined in the root xmake.lua; the rule wraps the test binary with drmemory (Windows) or valgrind (Linux) when option memcheck=y.

* Drop the lcui-tests aggregation: lcui-tests now contains only integration cases and scenes, not the union of lib tests. Use xmake test to run everything across libs.

* Fix .clang-format: InsertNewlineAtEndOfFile -> InsertNewlineAtEOF (correct key for clang-format 16+).

* Update AGENTS.md with the new test layout, naming rules, description style and run commands.

* Update CI to use xmake test and xmake f --memcheck=y instead of per-lib runs.
2026-08-05 22:41:12 +08:00
Liu c6cb7da777 feat(ctest): add suite filter, list and CTEST_MAIN macro
Introduce ctest_suite_t, ctest_parse_args, ctest_run_suites and CTEST_MAIN macro to standardize test binary entry points. Support --grep / --grep= / --list / --interactive / --help. Add lib/ctest/tests/ for self-tests covering str converters and grep filter logic.
2026-08-05 22:41:10 +08:00
Liu 4ce84484e4 build(yutil): update submodule to renamed tests/ layout 2026-08-05 22:41:09 +08:00
OrbisAI Security 259c6ad696 fix(css): stack buffer overflow in selector fullname construction
Multiple unbounded strcpy() calls in lib/css/src/selector
2026-08-05 22:41:08 +08:00
Liu 20b24cb9fc refactor(app): drop app_ prefix from public API
BREAKING CHANGE: lcui_app_get_fps -> lcui_get_fps,
lcui_app_set_frame_rate_cap -> lcui_set_fps_cap,
settings.frame_rate_cap -> settings.fps_cap.
lcui_app_init, lcui_app_destroy, lcui_app_process_events
removed from public header — use lcui_init, lcui_destroy,
lcui_run instead.
2026-08-05 22:41:07 +08:00
Liu 4a014fe6eb docs: add AGENTS.md 2026-08-05 22:41:06 +08:00
Liu e6506fca90 feat(app): add lcui_request_frame and animation timer driver 2026-08-05 22:40:07 +08:00
Liu d6fdae1feb fix(app): replace steptimer-based render throttle with interval gate
Fullscreen transitions and other prolonged pauses caused left_over_time
to accumulate in StepTimer's fixed-step catch-up loop, triggering
dozens of render+present calls in a single event dispatch and freezing
the UI for seconds.

Replace the StepTimer with a simple minimum-interval gate so that
two consecutive renders are always at least 1000/rate_cap ms apart.
FPS is now counted from actually rendered frames rather than tick
calls. The lcui_app_set_frame_rate_cap and lcui_app_get_fps
signatures are unchanged.
2026-05-20 22:32:59 +08:00
Liu a0a1669176 fix(ptk): initialize steptimer last_time to wall clock
The first call to ptk_steptimer_tick observed a huge delta because
last_time was zero-initialized. In fixed-step mode this caused the
handler to be invoked hundreds of times in a single tick.

- Set last_time to get_time_ms() in ptk_steptimer_init.
- Remove the duplicate is_fixed_time_step assignment.
- Drop the unused frequency field; LCUI uses millisecond time base
  and never read it.
- Document in the header that StepTimer is intended for
  animation/simulation timing, not render throttling.
- Add test_steptimer covering init timing, variable-step,
  fixed-step catch-up, and max_delta clamping.
2026-05-20 22:32:52 +08:00
copilot-swe-agent[bot]andlc-soft 1beafdfd5b refactor: convert pd_image_readers to fixed-index array, O(1) get_methods
Agent-Logs-Url: https://github.com/lc-soft/LCUI/sessions/31fedd8b-88fb-48dd-b055-303325c02c73

Co-authored-by: lc-soft <1730073+lc-soft@users.noreply.github.com>
2026-04-29 22:25:53 +08:00
Liu e873c47216 refactor(ui): change image event listener return types to bool 2026-03-31 21:20:28 +08:00
Liu ded5f84022 fix(ui): memory leak and division by zero error 2026-03-31 21:20:28 +08:00
Liu c4895a3efb fix(ui): cannot set css shorthand property 2026-03-31 21:20:28 +08:00
Liu f07b06d154 refactor(css): const css_propdef_t * 2026-03-31 21:20:28 +08:00
rewine cf23a967bb fix(ptk): fix window size constraints mapping 2026-03-31 21:20:02 +08:00
Liu db2aaf8e26 build(deps): update xmake-requires.lock 2025-08-16 12:29:26 +08:00
Liu 06a958eda4 fix(ui): clear implicit conversion warnings 2025-08-16 11:22:29 +08:00
Liu a69f2b1bd7 feat(ptk): add Windows implemention for clipboard 2025-08-16 11:18:51 +08:00
Liu d3197db425 fix(ptk): ignore special characters entered with Ctrl key combination 2025-08-16 11:18:51 +08:00
Liu a9ab79a338 fix(ptk): request text failed when clipboard content is empty (#318) 2025-08-16 11:18:51 +08:00
Liu ae9b228f48 fix(ptk): incorrect window minmaxinfo 2025-04-30 18:54:20 +08:00
Liu 1de2dfd62c fix: delay refresh window to use the latest size of widget 2025-04-16 00:16:38 +08:00
Liu aa3326b448 ci: update configure step 2025-04-16 00:16:30 +08:00