├── .clang-format ├── .codecov.yml ├── .editorconfig ├── .github ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── FUNDING.yml ├── ISSUE_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md ├── scripts │ ├── get_release_notes.py │ └── get_release_version.py ├── stale.yml └── workflows │ └── ccpp.yml ├── .gitignore ├── .gitmodules ├── AUTHORS ├── CHANGELOG.md ├── CHANGELOG.zh-cn.md ├── CODE_OF_CONDUCT.md ├── CODE_OF_CONDUCT.zh-cn.md ├── LICENSE.TXT ├── README ├── README.md ├── README.zh-cn.md ├── debian ├── changelog ├── compat ├── control ├── copyright ├── lcui-docs.docs ├── liblcui2-dev.dirs ├── liblcui2-dev.install ├── liblcui2.dirs ├── liblcui2.install ├── rules └── source │ └── format ├── examples ├── browser.jpg ├── fabric.jpg ├── fabric │ ├── README.md │ ├── src │ │ ├── fabric.c │ │ ├── fabric.h │ │ └── main.c │ └── xmake.lua ├── hello │ ├── app │ │ ├── hello.css │ │ └── hello.xml │ ├── src │ │ └── main.c │ └── xmake.lua ├── kantu.jpg ├── todolist.jpg ├── todolist │ ├── app │ │ ├── check.png │ │ ├── delete.png │ │ ├── todolist.css │ │ └── todolist.xml │ ├── src │ │ └── main.c │ └── xmake.lua └── xmake.lua ├── include ├── LCUI.h └── LCUI │ ├── app.h │ ├── base.h │ ├── common.h │ ├── fonts.h │ ├── main.h │ ├── settings.h │ ├── ui.h │ ├── widgets.h │ ├── widgets │ ├── anchor.h │ ├── button.h │ ├── canvas.h │ ├── router_link.h │ ├── router_view.h │ ├── scrollarea.h │ ├── scrollbar.h │ ├── text.h │ ├── textcaret.h │ └── textinput.h │ └── worker.h ├── lib ├── css │ ├── README.md │ ├── include │ │ ├── css.h │ │ └── css │ │ │ ├── common.h │ │ │ ├── computed.h │ │ │ ├── data_types.h │ │ │ ├── keywords.h │ │ │ ├── library.h │ │ │ ├── parser.h │ │ │ ├── properties.h │ │ │ ├── selector.h │ │ │ ├── style_decl.h │ │ │ ├── style_value.h │ │ │ ├── types.h │ │ │ ├── utils.h │ │ │ └── value.h │ ├── src │ │ ├── computed.c │ │ ├── config.h.in │ │ ├── data_types.c │ │ ├── debug.h │ │ ├── dump.c │ │ ├── dump.h │ │ ├── font_face_parser.c │ │ ├── keywords.c │ │ ├── library.c │ │ ├── main.c │ │ ├── parser.c │ │ ├── parser.h │ │ ├── properties.c │ │ ├── properties.h │ │ ├── properties │ │ │ ├── align_content.c │ │ │ ├── align_items.c │ │ │ ├── background.c │ │ │ ├── border.c │ │ │ ├── bottom.c │ │ │ ├── box_shadow.c │ │ │ ├── box_sizing.c │ │ │ ├── color.c │ │ │ ├── content.c │ │ │ ├── display.c │ │ │ ├── flex.c │ │ │ ├── font_family.c │ │ │ ├── font_size.c │ │ │ ├── font_style.c │ │ │ ├── font_weight.c │ │ │ ├── height.c │ │ │ ├── helpers.c │ │ │ ├── helpers.h │ │ │ ├── justify_content.c │ │ │ ├── left.c │ │ │ ├── line_height.c │ │ │ ├── margin.c │ │ │ ├── max_height.c │ │ │ ├── max_width.c │ │ │ ├── min_height.c │ │ │ ├── min_width.c │ │ │ ├── opacity.c │ │ │ ├── padding.c │ │ │ ├── pointer_events.c │ │ │ ├── position.c │ │ │ ├── right.c │ │ │ ├── text_align.c │ │ │ ├── top.c │ │ │ ├── vertical_align.c │ │ │ ├── visibility.c │ │ │ ├── white_space.c │ │ │ ├── width.c │ │ │ ├── word_break.c │ │ │ └── z_index.c │ │ ├── selector.c │ │ ├── style_decl.c │ │ ├── style_parser.c │ │ ├── style_value.c │ │ ├── utils.c │ │ └── value.c │ ├── tests │ │ ├── test.c │ │ ├── test.h │ │ ├── test_css_computed.c │ │ ├── test_css_computed.css │ │ ├── test_css_keywords.c │ │ └── test_css_value.c │ └── xmake.lua ├── ctest │ ├── include │ │ └── ctest.h │ ├── src │ │ └── ctest.c │ └── xmake.lua ├── i18n │ ├── include │ │ └── i18n.h │ ├── src │ │ ├── i18n-dict.c │ │ ├── i18n-private.h │ │ ├── i18n.c │ │ ├── i18n.h.in │ │ └── yaml.c │ ├── tests │ │ ├── locales │ │ │ ├── en.yml │ │ │ └── zh-CN.yml │ │ └── test.c │ └── xmake.lua ├── pandagl │ ├── README.md │ ├── examples │ │ └── cairo │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── README.zh-cn.md │ │ │ ├── output.png │ │ │ ├── src │ │ │ └── main.c │ │ │ └── xmake.lua │ ├── include │ │ ├── pandagl.h │ │ └── pandagl │ │ │ ├── background.h │ │ │ ├── border.h │ │ │ ├── boxshadow.h │ │ │ ├── canvas.h │ │ │ ├── color.h │ │ │ ├── common.h │ │ │ ├── context.h │ │ │ ├── file_reader.h │ │ │ ├── font.h │ │ │ ├── image.h │ │ │ ├── line.h │ │ │ ├── pixel.h │ │ │ ├── rect.h │ │ │ ├── text.h │ │ │ └── types.h │ ├── src │ │ ├── background.c │ │ ├── border.c │ │ ├── boxshadow.c │ │ ├── canvas.c │ │ ├── config.h.in │ │ ├── context.c │ │ ├── file_reader.c │ │ ├── flip.c │ │ ├── font │ │ │ ├── bitmap.c │ │ │ ├── bitmap.h │ │ │ ├── freetype.c │ │ │ ├── freetype.h │ │ │ ├── inconsolata.c │ │ │ ├── inconsolata.h │ │ │ ├── incore.c │ │ │ ├── incore.h │ │ │ ├── library.c │ │ │ └── library.h │ │ ├── image │ │ │ ├── bmp.c │ │ │ ├── bmp_private.h │ │ │ ├── jpeg.c │ │ │ ├── jpeg_private.h │ │ │ ├── png.c │ │ │ ├── png_private.h │ │ │ └── reader.c │ │ ├── line.c │ │ ├── pixel.c │ │ ├── rect.c │ │ ├── text │ │ │ ├── style.c │ │ │ ├── style_tag.c │ │ │ └── text.c │ │ ├── tile.c │ │ └── zoom.c │ ├── test │ │ ├── test.c │ │ ├── test.h │ │ └── test_canvas_mix.c │ └── xmake.lua ├── ptk │ ├── include │ │ ├── ptk.h │ │ └── ptk │ │ │ ├── app.h │ │ │ ├── clipboard.h │ │ │ ├── common.h │ │ │ ├── events.h │ │ │ ├── ime.h │ │ │ ├── main.h │ │ │ ├── steptimer.h │ │ │ ├── types.h │ │ │ ├── win32_main.h │ │ │ └── window.h │ ├── src │ │ ├── app.c │ │ ├── clipboard.c │ │ ├── clipboard.h │ │ ├── config.h.in │ │ ├── events.c │ │ ├── events.h │ │ ├── ime.c │ │ ├── ime.h │ │ ├── linux │ │ │ ├── app.c │ │ │ ├── fbapp.c │ │ │ ├── fbapp.h │ │ │ ├── ime.c │ │ │ ├── keyboard.c │ │ │ ├── keyboard.h │ │ │ ├── mouse.c │ │ │ ├── mouse.h │ │ │ ├── uri.c │ │ │ ├── x11app.c │ │ │ ├── x11app.h │ │ │ ├── x11clipboard.c │ │ │ └── x11clipboard.h │ │ ├── steptimer.c │ │ └── windows │ │ │ ├── uri.c │ │ │ ├── win32_app.c │ │ │ └── win32_ime.c │ └── xmake.lua ├── router │ ├── .gitignore │ ├── README.md │ ├── README.zh-cn.md │ ├── include │ │ ├── router.h │ │ └── router │ │ │ ├── common.h │ │ │ ├── config.h │ │ │ ├── history.h │ │ │ ├── location.h │ │ │ ├── matcher.h │ │ │ ├── route.h │ │ │ ├── route_record.h │ │ │ ├── router.h │ │ │ ├── strmap.h │ │ │ ├── types.h │ │ │ ├── utils.h │ │ │ └── version.h │ ├── src │ │ ├── config.c │ │ ├── history.c │ │ ├── location.c │ │ ├── matcher.c │ │ ├── private.h │ │ ├── route.c │ │ ├── route_record.c │ │ ├── router.c │ │ ├── strmap.c │ │ ├── utils.c │ │ └── version.h.in │ ├── tests │ │ └── test.c │ └── xmake.lua ├── thread │ ├── include │ │ └── thread.h │ ├── src │ │ ├── pthread.c │ │ ├── thread.h.in │ │ └── windows.c │ └── xmake.lua ├── ui-cursor │ ├── include │ │ ├── ui_cursor.h │ │ └── ui_cursor │ │ │ └── common.h │ ├── src │ │ ├── config.h.in │ │ └── cursor.c │ └── xmake.lua ├── ui-server │ ├── include │ │ ├── ui_server.h │ │ └── ui_server │ │ │ └── common.h │ ├── src │ │ ├── config.h.in │ │ └── server.c │ └── xmake.lua ├── ui-xml │ ├── include │ │ ├── ui_xml.h │ │ └── ui_xml │ │ │ └── common.h │ ├── src │ │ ├── config.h.in │ │ └── ui_xml.c │ └── xmake.lua ├── ui │ ├── include │ │ ├── ui.h │ │ └── ui │ │ │ ├── base.h │ │ │ ├── common.h │ │ │ ├── css.h │ │ │ ├── events.h │ │ │ ├── hash.h │ │ │ ├── image.h │ │ │ ├── logger.h │ │ │ ├── metrics.h │ │ │ ├── mutation_observer.h │ │ │ ├── prototype.h │ │ │ ├── rect.h │ │ │ ├── style.h │ │ │ ├── text_style.h │ │ │ ├── types.h │ │ │ └── updater.h │ ├── src │ │ ├── config.h.in │ │ ├── ui.c │ │ ├── ui_block_layout.c │ │ ├── ui_block_layout.h │ │ ├── ui_css.c │ │ ├── ui_css.h │ │ ├── ui_debug.c │ │ ├── ui_debug.h │ │ ├── ui_diff.c │ │ ├── ui_diff.h │ │ ├── ui_events.c │ │ ├── ui_events.h │ │ ├── ui_flexbox_layout.c │ │ ├── ui_flexbox_layout.h │ │ ├── ui_image.c │ │ ├── ui_image.h │ │ ├── ui_logger.c │ │ ├── ui_metrics.c │ │ ├── ui_mutation_observer.c │ │ ├── ui_mutation_observer.h │ │ ├── ui_rect.c │ │ ├── ui_renderer.c │ │ ├── ui_resizer.c │ │ ├── ui_resizer.h │ │ ├── ui_root.c │ │ ├── ui_root.h │ │ ├── ui_text_style.c │ │ ├── ui_tree.c │ │ ├── ui_updater.c │ │ ├── ui_updater.h │ │ ├── ui_widget.c │ │ ├── ui_widget.h │ │ ├── ui_widget_attributes.c │ │ ├── ui_widget_attributes.h │ │ ├── ui_widget_background.c │ │ ├── ui_widget_background.h │ │ ├── ui_widget_border.c │ │ ├── ui_widget_border.h │ │ ├── ui_widget_box_shadow.c │ │ ├── ui_widget_box_shadow.h │ │ ├── ui_widget_classes.c │ │ ├── ui_widget_classes.h │ │ ├── ui_widget_hash.c │ │ ├── ui_widget_helper.c │ │ ├── ui_widget_id.c │ │ ├── ui_widget_id.h │ │ ├── ui_widget_layout.c │ │ ├── ui_widget_layout.h │ │ ├── ui_widget_observer.c │ │ ├── ui_widget_observer.h │ │ ├── ui_widget_prototype.c │ │ ├── ui_widget_prototype.h │ │ ├── ui_widget_status.c │ │ ├── ui_widget_status.h │ │ ├── ui_widget_style.c │ │ └── ui_widget_style.h │ └── xmake.lua └── worker │ ├── include │ ├── worker.h │ └── worker │ │ └── common.h │ ├── src │ ├── config.h.in │ └── worker.c │ └── xmake.lua ├── package.json ├── preview.png ├── scripts └── add-copyright.js ├── src ├── config.h.in ├── lcui.c ├── lcui_app.c ├── lcui_fonts.c ├── lcui_settings.c ├── lcui_ui.c ├── lcui_widgets.c ├── lcui_worker.c └── widgets │ ├── anchor.c │ ├── button.c │ ├── canvas.c │ ├── router_link.c │ ├── router_view.c │ ├── scrollarea.c │ ├── scrollbar.c │ ├── text.c │ ├── textcaret.c │ ├── textinput.c │ ├── textstyle.c │ └── textstyle.h ├── tests ├── cases │ ├── test_block_layout.c │ ├── test_clipboard.c │ ├── test_flex_layout.c │ ├── test_font_load.c │ ├── test_image_reader.c │ ├── test_mainloop.c │ ├── test_router.c │ ├── test_scrollbar.c │ ├── test_settings.c │ ├── test_text_resize.c │ ├── test_textinput.c │ ├── test_thread.c │ ├── test_widget_event.c │ ├── test_widget_opacity.c │ ├── test_widget_rect.c │ └── test_xml_parser.c ├── dog.jpg ├── helloworld_uwp │ ├── App.cpp │ ├── Assets │ │ ├── LockScreenLogo.scale-200.png │ │ ├── SplashScreen.scale-200.png │ │ ├── Square150x150Logo.scale-200.png │ │ ├── Square44x44Logo.scale-200.png │ │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ │ ├── StoreLogo.png │ │ └── Wide310x150Logo.scale-200.png │ ├── LCUIApp.vcxproj │ ├── LCUIApp.vcxproj.filters │ ├── Package.appxmanifest │ ├── pch.cpp │ └── pch.h ├── include │ └── ctest-custom.h ├── run_tests.c ├── run_tests.h ├── test_block_layout.c ├── test_block_layout.css ├── test_block_layout.html ├── test_block_layout.xml ├── test_border.c ├── test_border.css ├── test_border.html ├── test_border.xml ├── test_box_shadow.c ├── test_box_shadow.css ├── test_box_shadow.html ├── test_box_shadow.xml ├── test_char_render.c ├── test_css_parser.css ├── test_css_parser.xml ├── test_fill_rect.c ├── test_fill_rect_with_rgba.c ├── test_flex_layout.c ├── test_flex_layout.css ├── test_flex_layout.html ├── test_flex_layout.xml ├── test_font_load.css ├── test_font_load.ttf ├── test_image_reader.bmp ├── test_image_reader.jpg ├── test_image_reader.png ├── test_image_scaling_bench.c ├── test_mix_rect_with_opacity.c ├── test_paint_background.c ├── test_paint_border.c ├── test_paint_boxshadow.c ├── test_pixel_manipulation.c ├── test_render.c ├── test_scaling_support.c ├── test_scaling_support.css ├── test_scaling_support.xml ├── test_scrollbar.c ├── test_scrollbar.xml ├── test_string_render.c ├── test_text_resize.c ├── test_touch.c ├── test_widget.c ├── test_widget_opacity.c ├── test_widget_opacity.css ├── test_widget_opacity.xml ├── test_widget_render.c ├── test_xml_parser.nested.xml ├── test_xml_parser.xml └── xmake.lua ├── xmake-requires.lock └── xmake.lua /.clang-format: -------------------------------------------------------------------------------- 1 | Language: Cpp 2 | BasedOnStyle: Google 3 | IndentWidth: 8 4 | AlignAfterOpenBracket: Align 5 | AlignOperands: true 6 | AlignTrailingComments: true 7 | AllowAllParametersOfDeclarationOnNextLine: false 8 | AllowShortIfStatementsOnASingleLine: false 9 | AlwaysBreakBeforeMultilineStrings: false 10 | AllowShortFunctionsOnASingleLine: None 11 | BinPackArguments: true 12 | BinPackParameters: true 13 | BreakBeforeBraces: Linux 14 | ColumnLimit: 80 15 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 16 | ConstructorInitializerIndentWidth: 72 17 | Cpp11BracedListStyle: false 18 | IndentCaseLabels: false 19 | IndentWrappedFunctionNames: false 20 | MaxEmptyLinesToKeep: 1 21 | NamespaceIndentation: All 22 | PointerAlignment: Right 23 | ReflowComments: true 24 | SpaceAfterCStyleCast: false 25 | SpaceBeforeAssignmentOperators: true 26 | SpaceBeforeParens: ControlStatements 27 | SpaceInEmptyParentheses: false 28 | SpacesBeforeTrailingComments: 4 29 | SpacesInAngles: false 30 | SpacesInCStyleCastParentheses: false 31 | SpacesInContainerLiterals: false 32 | SpacesInParentheses: false 33 | SpacesInSquareBrackets: false 34 | SortIncludes: false 35 | UseTab: Never 36 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - test 3 | - include 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | indent_style=space 2 | indent_style=8 3 | tab_width=8 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | open_collective: LCUI 4 | custom: https://afdian.net/@lc-soft 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | If you are submitting bug reports, you need this template: 2 | 3 | [Short description of problem here] 4 | 5 | **Reproduction Steps:** 6 | 7 | 1. [First Step] 8 | 2. [Second Step] 9 | 3. [Other Steps...] 10 | 11 | **Screenshots and GIFs** 12 | 13 | ![Screenshots and GIFs which follow reproduction steps to demonstrate the problem](url) 14 | 15 | **LCUI version:** [Enter LCUI version here] 16 | **OS and version:** [Enter OS name and version here, E.g: WinXP/Win7/Win10/Linux/Mac OS] 17 | **Build tools:** [Enter build tools name and version here, E.g: gcc/clang/VisualStudio 201X] 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. [First Step] 13 | 2. [Second Step] 14 | 3. [Other Steps...] 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Screenshots** 20 | If applicable, add screenshots to help explain your problem. 21 | 22 | **Environment (please complete the following information):** 23 | - LCUI version: [Enter LCUI version here] 24 | - Build tools: [Enter build tools name and version here, E.g: gcc/clang/VisualStudio 201X] 25 | - OS and version: [Enter OS name and version here, E.g: WinXP/Win7/Win10/Ubuntu/Mac OS] 26 | 27 | **Additional context** 28 | Add any other context about the problem here. 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Fixes #???. 2 | 3 | Changes proposed in this pull request: 4 | - 5 | - 6 | - 7 | 8 | @lc-soft 9 | -------------------------------------------------------------------------------- /.github/scripts/get_release_notes.py: -------------------------------------------------------------------------------- 1 | # coding=utf8 2 | import re 3 | 4 | # Assumes last entry is the version we want to release 5 | def release_text(filename): 6 | with open(filename, "r") as rel_file: 7 | # First line will be the header and padding, we don't need it 8 | lines = rel_file.read().split("\n")[2:] 9 | for i, row in enumerate(lines): 10 | if row.startswith("# ["): 11 | return "\n".join(lines[0:i]) 12 | 13 | with open("RELEASE_NOTES.md", "w") as rel_notes: 14 | content = [ 15 | "# Changelog", 16 | release_text("CHANGELOG.md"), 17 | "# 更新日志", 18 | release_text("CHANGELOG.zh-cn.md") 19 | ] 20 | rel_notes.write("\n".join(content)) -------------------------------------------------------------------------------- /.github/scripts/get_release_version.py: -------------------------------------------------------------------------------- 1 | 2 | # ------------------------------------------------------------ 3 | # Copyright (c) Microsoft Corporation and Dapr Contributors. 4 | # Licensed under the MIT License. 5 | # ------------------------------------------------------------ 6 | 7 | # This script parses release version from Git tag and set the parsed version to 8 | # environment variable, REL_VERSION. If the tag is the final version, it sets 9 | 10 | import os 11 | import sys 12 | 13 | gitRef = os.getenv("GITHUB_REF") 14 | tagRefPrefix = "refs/tags/v" 15 | 16 | with open(os.getenv("GITHUB_ENV"), "a") as githubEnv: 17 | 18 | if gitRef is None or not gitRef.startswith(tagRefPrefix): 19 | githubEnv.write("REL_VERSION=latest\n") 20 | print ("This is daily build from {}...".format(gitRef)) 21 | sys.exit(0) 22 | 23 | releaseVersion = gitRef[len(tagRefPrefix):] 24 | githubEnv.write("REL_VERSION={}\n".format(releaseVersion)) -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 90 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 30 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - pinned 8 | - help wanted 9 | - needs milestone 10 | - bug 11 | # Label to use when marking an issue as stale 12 | staleLabel: stale 13 | # Comment to post when marking an issue as stale. Set to `false` to disable 14 | markComment: > 15 | This issue has been automatically marked as stale because it has not had 16 | recent activity. It will be closed in 30 days if no further activity occurs. 17 | Thank you for your contributions. 18 | # Comment to post when closing a stale issue. Set to `false` to disable 19 | closeComment: false 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.lo 2 | *.o 3 | *.dll 4 | *.lib 5 | *.db 6 | *.opendb 7 | *.dirstamp 8 | *.zip 9 | *.pfx 10 | *.lastbuildstate 11 | *.unsuccessfulbuild 12 | *.pdb 13 | *.idb 14 | *.tlog 15 | *.log 16 | *.obj 17 | *.aps 18 | *.psess 19 | *.sbr 20 | .deps 21 | .libs 22 | *.la 23 | *.txt 24 | *.gcda 25 | *.vspx 26 | *.vs 27 | *.res 28 | *.vcxproj.user 29 | *.gcno 30 | *.gcov 31 | build 32 | *~ 33 | *.intermediate 34 | .vscode 35 | .xmake 36 | dist 37 | node_modules 38 | Debug 39 | Release 40 | aclocal.m4 41 | Makefile 42 | Makefile.in 43 | configure 44 | autom4te.cache 45 | compile 46 | install-sh 47 | missing 48 | depcomp 49 | lcui2.pc 50 | libtool 51 | ltmain.sh 52 | config.log 53 | config.status 54 | config.guess 55 | config.sub 56 | stamp-h1 57 | Thumbs.db 58 | m4/ 59 | bin/ 60 | build/packages 61 | build/debian 62 | build/*/*.sdf 63 | build/*/*.opensdf 64 | build/*/*.suo 65 | vendor/include 66 | vendor/lib 67 | build/*.png 68 | build/*.jpg 69 | config.h 70 | test/build 71 | vsxmake* 72 | compile_commands.json -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/yutil"] 2 | path = lib/yutil 3 | url = https://gitee.com/lcui-dev/yutil.git 4 | branch = main 5 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Main Developers 2 | --------------- 3 | 4 | Liu Chao 5 | 6 | 7 | Helping Developers 8 | ------------------ 9 | 10 | 11 | 12 | See also "Thanks To" section in README. 13 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.zh-cn.md: -------------------------------------------------------------------------------- 1 | # 参与者公约 2 | 3 | ## 我们的保证 4 | 5 | 为了促进一个开放透明且友好的环境,我们作为贡献者和维护者保证:无论年龄、种族、民族、性别认同和表达(方式)、体型、身体健全与否、经验水平、国籍、个人表现、宗教或性别取向,参与者在我们项目和社区中都免于骚扰。 6 | 7 | ## 我们的标准 8 | 9 | 有助于创造正面环境的行为包括但不限于: 10 | 11 | * 使用友好和包容性语言 12 | * 尊重不同的观点和经历 13 | * 耐心地接受建设性批评 14 | * 关注对社区最有利的事情 15 | * 友善对待其他社区成员 16 | 17 | 身为参与者不能接受的行为包括但不限于: 18 | 19 | * 使用与性有关的言语或是图像,以及不受欢迎的性骚扰 20 | * 捣乱/煽动/造谣的行为或进行侮辱/贬损的评论,人身攻击及政治攻击 21 | * 公开或私下的骚扰 22 | * 未经许可地发布他人的个人资料,例如住址或是电子地址 23 | * 其他可以被合理地认定为不恰当或者违反职业操守的行为 24 | 25 | ## 我们的责任 26 | 27 | 项目维护者有责任为「可接受的行为」标准做出诠释,以及对已发生的不被接受的行为采取恰当且公平的纠正措施。 28 | 29 | 项目维护者有权利及责任去删除、编辑、拒绝与本行为标准有所违背的评论 (comments)、提交 (commits)、代码、wiki 编辑、问题 (issues) 和其他贡献,以及项目维护者可暂时或永久性的禁止任何他们认为有不适当、威胁、冒犯、有害行为的贡献者。 30 | 31 | ## 使用范围 32 | 33 | 当一个人代表该项目或是其社区时,本行为标准适用于其项目平台和公共平台。 34 | 35 | 代表项目或是社区的情况,举例来说包括使用官方项目的电子邮件地址、通过官方的社区媒体账号发布或线上或线下事件中担任指定代表。 36 | 37 | 该项目的呈现方式可由其项目维护者进行进一步的定义及解释。 38 | 39 | ## 强制执行 40 | 41 | 可以通过 root@lc-soft.io,来联系项目团队来举报滥用、骚扰或其他不被接受的行为。 42 | 43 | 任何维护团队认为有必要且适合的所有投诉都将进行审查及调查,并做出相对应的回应。项目小组有对事件回报者有保密的义务。具体执行的方针近一步细节可能会单独公布。 44 | 45 | 没有切实地遵守或是执行本行为标准的项目维护人员,可能会因项目领导人或是其他成员的决定,暂时或是永久地取消其参与资格。 46 | 47 | ## 来源 48 | 49 | 本行为标准改编自[贡献者公约][homepage], 版本 1.4 可参阅:https://www.contributor-covenant.org/zh-cn/version/1/4/code-of-conduct.html 50 | 51 | [homepage]: https://www.contributor-covenant.org 52 | 53 | 有关此行为准则的常见问题的答案,请参阅:https://www.contributor-covenant.org/faq 54 | -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Liu Chao 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Please read the file `README.md`. 2 | 3 | 请阅读中文版的README文件:`README.zh-cn.md`. 4 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | lcui (2.2.0-1) stable; urgency=medium 2 | 3 | * Release note: https://github.com/lc-soft/LCUI/releases/tag/v2.2.0 4 | 5 | lcui (2.1.0-1) stable; urgency=medium 6 | 7 | * Release note: https://github.com/lc-soft/LCUI/releases/tag/v2.1.0 8 | 9 | -- lc Sun, 05 Jul 2020 22:27:35 +0800 10 | 11 | lcui (2.0.0-1) stable; urgency=medium 12 | 13 | * Release note: https://github.com/lc-soft/LCUI/releases/tag/v2.0.0 14 | 15 | -- lc Sat, 11 Apr 2020 15:42:14 +0800 16 | 17 | lcui (1.3.0-1) unstable; urgency=medium 18 | 19 | * Initial release 20 | 21 | -- lc Thu, 19 Sep 2019 11:32:16 +0800 22 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: lcui 2 | Priority: optional 3 | Maintainer: lc-soft 4 | Build-Depends: debhelper (>= 10), autotools-dev 5 | Standards-Version: 4.1.2 6 | Section: libs 7 | Homepage: https://lcui.org 8 | Vcs-Git: https://github.com/lc-soft/LCUI.git 9 | Vcs-Browser: https://github.com/lc-soft/LCUI 10 | 11 | Package: liblcui2-dev 12 | Section: libdevel 13 | Architecture: any 14 | Multi-Arch: same 15 | Depends: lcui (= ${binary:Version}), ${misc:Depends} 16 | Description: A small C library for building user interfaces. 17 | 18 | Package: liblcui2 19 | Architecture: any 20 | Multi-Arch: same 21 | Depends: libpng, libjpeg, libxml2, libfreetype6, libx11 22 | Description: A small C library for building user interfaces. 23 | 24 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: lcui 3 | Source: https://lcui.org 4 | 5 | Files: * 6 | Copyright: 2020 Liu Chao 7 | License: MIT 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | -------------------------------------------------------------------------------- /debian/lcui-docs.docs: -------------------------------------------------------------------------------- 1 | README 2 | -------------------------------------------------------------------------------- /debian/liblcui2-dev.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | usr/include 3 | -------------------------------------------------------------------------------- /debian/liblcui2-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/* 2 | usr/lib/*/lib*.so 3 | usr/lib/*/lib*.a 4 | usr/lib/*/pkgconfig/* 5 | -------------------------------------------------------------------------------- /debian/liblcui2.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | -------------------------------------------------------------------------------- /debian/liblcui2.install: -------------------------------------------------------------------------------- 1 | usr/lib/*/lib*.so.* 2 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # See debhelper(7) (uncomment to enable) 3 | # output every command that modifies files on the build system. 4 | #export DH_VERBOSE = 1 5 | 6 | 7 | # see FEATURE AREAS in dpkg-buildflags(1) 8 | #export DEB_BUILD_MAINT_OPTIONS = hardening=+all 9 | 10 | # see ENVIRONMENT in dpkg-buildflags(1) 11 | # package maintainers to append CFLAGS 12 | #export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic 13 | # package maintainers to append LDFLAGS 14 | #export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed 15 | 16 | 17 | %: 18 | dh $@ 19 | 20 | 21 | # dh_make generated override targets 22 | # This is example for Cmake (See https://bugs.debian.org/641051 ) 23 | #override_dh_auto_configure: 24 | # dh_auto_configure -- # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) 25 | 26 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /examples/browser.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/examples/browser.jpg -------------------------------------------------------------------------------- /examples/fabric.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/examples/fabric.jpg -------------------------------------------------------------------------------- /examples/fabric/README.md: -------------------------------------------------------------------------------- 1 | # Fabric 2 | 3 | 基于 LCUI 和 Cario 实现的布料模拟程序。 4 | -------------------------------------------------------------------------------- /examples/fabric/src/fabric.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | typedef struct PointRec_ { 4 | double cx; 5 | double cy; 6 | double px; 7 | double py; 8 | bool pinned; 9 | bool grabbed; 10 | double mxd; 11 | double myd; 12 | int id; 13 | } PointRec, *Point; 14 | 15 | typedef struct SpanRec_ { 16 | Point p1; 17 | Point p2; 18 | double l; 19 | } SpanRec, *Span; 20 | 21 | void Fabric_getSpans(Span **outSpans, int *count); 22 | 23 | void Fabric_getPoints(Point **outPoints, int *count); 24 | 25 | void Fabric_resize(double width, double height); 26 | 27 | void Fabric_update(void); 28 | 29 | // grabs fabric on click 30 | void Fabric_grab(double mouseCanvasX, double mouseCanvasY); 31 | 32 | // moves fabric 33 | void Fabric_move(double mouseCanvasX, double mouseCanvasY); 34 | 35 | // drops fabric 36 | void Fabric_drop(void); 37 | 38 | /** 39 | * @brief init fabirc 40 | * 41 | * @param fw fabric width (as percentage of canvas width) 42 | * @param fh fabric height (as percentage of canvas height) 43 | */ 44 | void Fabric_init(int fw, int fh, int canvaswidth, int canvasHeight); 45 | -------------------------------------------------------------------------------- /examples/fabric/xmake.lua: -------------------------------------------------------------------------------- 1 | add_requires("cairo", { optional = true }) 2 | 3 | target("fabric") 4 | set_kind("binary") 5 | add_files("src/*.c") 6 | add_packages("cairo", "lcui") 7 | if has_package("cairo") then 8 | add_defines("HAS_CAIRO") 9 | end 10 | -------------------------------------------------------------------------------- /examples/hello/app/hello.css: -------------------------------------------------------------------------------- 1 | text.text-hello { 2 | font-size: 18px; 3 | font-family: "Segoe UI"; 4 | text-align: center; 5 | padding: 25px; 6 | margin: 25px; 7 | border: 1px solid #eee; 8 | background-color: #f8f9fa; 9 | } 10 | #btn, #edit { 11 | margin: 0 0 0 25px; 12 | } 13 | -------------------------------------------------------------------------------- /examples/hello/app/hello.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | [i][color=#f00]Hello[/color][/i], [b][color=#fff][bgcolor=#f00]World![/bgcolor][/color][/b] 7 | 8 | [i][color=#f00]Hello[/color][/i], [b][color=#fff][bgcolor=#f00]World![/bgcolor][/color][/b] 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /examples/hello/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static void on_btn_click(ui_widget_t *self, ui_event_t *e, void *arg) 5 | { 6 | wchar_t str[256]; 7 | ui_widget_t *edit = ui_get_widget("edit"); 8 | ui_widget_t *txt = ui_get_widget("text-hello"); 9 | 10 | ui_textinput_get_text_w(edit, 0, 255, str); 11 | ui_text_set_content_w(txt, str); 12 | } 13 | 14 | int main(int argc, char **argv) 15 | { 16 | ui_widget_t *pack; 17 | 18 | lcui_init(); 19 | pack = ui_load_xml_file("hello.xml"); 20 | if (!pack) { 21 | return -1; 22 | } 23 | ui_root_append(pack); 24 | ui_widget_unwrap(pack); 25 | ui_widget_on(ui_get_widget("btn"), "click", on_btn_click, NULL); 26 | return lcui_main(); 27 | } 28 | -------------------------------------------------------------------------------- /examples/hello/xmake.lua: -------------------------------------------------------------------------------- 1 | target("hello") 2 | add_installfiles("app/*") 3 | set_kind("binary") 4 | set_rundir("app") 5 | add_packages("lcui") 6 | add_files("src/*.c") 7 | -------------------------------------------------------------------------------- /examples/kantu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/examples/kantu.jpg -------------------------------------------------------------------------------- /examples/todolist.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/examples/todolist.jpg -------------------------------------------------------------------------------- /examples/todolist/app/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/examples/todolist/app/check.png -------------------------------------------------------------------------------- /examples/todolist/app/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/examples/todolist/app/delete.png -------------------------------------------------------------------------------- /examples/todolist/app/todolist.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Todo list 8 | 9 | 10 | 11 | All 12 | Active 13 | Completed 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/todolist/xmake.lua: -------------------------------------------------------------------------------- 1 | target("todolist") 2 | add_installfiles("app/*") 3 | set_kind("binary") 4 | set_rundir("app") 5 | add_packages("lcui") 6 | add_files("src/*.c") 7 | -------------------------------------------------------------------------------- /examples/xmake.lua: -------------------------------------------------------------------------------- 1 | add_repositories("lcui-repo ../build") 2 | add_requires("lcui") 3 | add_rules("mode.debug", "mode.release") 4 | if is_plat("windows") then 5 | add_rules("win.sdk.application") 6 | end 7 | includes("*/xmake.lua") 8 | -------------------------------------------------------------------------------- /include/LCUI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/LCUI.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | -------------------------------------------------------------------------------- /include/LCUI/app.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/LCUI/app.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LCUI_INCLUDE_LCUI_APP_H 13 | #define LCUI_INCLUDE_LCUI_APP_H 14 | 15 | #include "common.h" 16 | #include 17 | 18 | LCUI_BEGIN_HEADER 19 | 20 | LCUI_API uint32_t lcui_app_get_fps(void); 21 | LCUI_API void lcui_app_set_frame_rate_cap(unsigned rate_cap); 22 | LCUI_API int lcui_app_process_events(ptk_process_events_option_t option); 23 | LCUI_API void lcui_app_init(void); 24 | LCUI_API void lcui_app_destroy(void); 25 | 26 | LCUI_END_HEADER 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/LCUI/base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/LCUI/base.h 3 | * 4 | * Copyright (c) 2024-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LCUI_INCLUDE_LCUI_BASE_H 13 | #define LCUI_INCLUDE_LCUI_BASE_H 14 | 15 | #include "common.h" 16 | 17 | LCUI_BEGIN_HEADER 18 | 19 | LCUI_API const char *lcui_get_version(void); 20 | 21 | LCUI_API void lcui_init(void); 22 | 23 | LCUI_API void lcui_destroy(void); 24 | 25 | LCUI_API int lcui_run(void); 26 | 27 | LCUI_API int lcui_main(void); 28 | 29 | LCUI_API void lcui_exit(int code); 30 | 31 | LCUI_API void lcui_quit(void); 32 | 33 | LCUI_END_HEADER 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /include/LCUI/fonts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/LCUI/fonts.h 3 | * 4 | * Copyright (c) 2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LCUI_INCLUDE_LCUI_FONTS_H 13 | #define LCUI_INCLUDE_LCUI_FONTS_H 14 | 15 | #include "common.h" 16 | 17 | LCUI_BEGIN_HEADER 18 | 19 | LCUI_API bool lcui_fonts_set_default(const char *family_name); 20 | 21 | #define lcui_set_default_font lcui_fonts_set_default 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /include/LCUI/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/LCUI/main.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | -------------------------------------------------------------------------------- /include/LCUI/settings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/LCUI/settings.h 3 | * 4 | * Copyright (c) 2024-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LCUI_INCLUDE_LCUI_SETTINGS_H 13 | #define LCUI_INCLUDE_LCUI_SETTINGS_H 14 | 15 | #include "common.h" 16 | 17 | #define LCUI_MAX_FRAMES_PER_SEC 120 18 | #define LCUI_MAX_FRAME_MSEC ((int)(1000.0 / LCUI_MAX_FRAMES_PER_SEC + 0.5)) 19 | 20 | LCUI_BEGIN_HEADER 21 | 22 | typedef struct lcui_settings { 23 | int frame_rate_cap; 24 | int parallel_rendering_threads; 25 | bool paint_flashing; 26 | } lcui_settings_t; 27 | 28 | /* Initialize settings with the current global settings. */ 29 | LCUI_API void lcui_get_settings(lcui_settings_t *settings); 30 | 31 | /* Update global settings with the given input. */ 32 | LCUI_API void lcui_apply_settings(lcui_settings_t *settings); 33 | 34 | /* Reset global settings to their defaults. */ 35 | LCUI_API void lcui_reset_settings(void); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/LCUI/ui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/LCUI/ui.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LCUI_INCLUDE_UI_H 13 | #define LCUI_INCLUDE_UI_H 14 | 15 | #include "common.h" 16 | 17 | LCUI_BEGIN_HEADER 18 | 19 | typedef enum { 20 | LCUI_DISPLAY_DEFAULT, 21 | LCUI_DISPLAY_WINDOWED, 22 | LCUI_DISPLAY_FULLSCREEN, 23 | LCUI_DISPLAY_SEAMLESS, 24 | } lcui_display_t; 25 | 26 | LCUI_API size_t lcui_ui_render(void); 27 | 28 | LCUI_API void lcui_ui_update(void); 29 | 30 | LCUI_API void lcui_ui_set_display(lcui_display_t mode); 31 | 32 | LCUI_API void lcui_ui_init(void); 33 | 34 | LCUI_API void lcui_ui_destroy(void); 35 | 36 | LCUI_END_HEADER 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /include/LCUI/widgets.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/LCUI/widgets.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "widgets/text.h" 13 | #include "widgets/button.h" 14 | #include "widgets/anchor.h" 15 | #include "widgets/canvas.h" 16 | #include "widgets/scrollarea.h" 17 | #include "widgets/scrollbar.h" 18 | #include "widgets/textinput.h" 19 | #include "widgets/textcaret.h" 20 | #include "widgets/router_link.h" 21 | #include "widgets/router_view.h" 22 | -------------------------------------------------------------------------------- /include/LCUI/widgets/anchor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/LCUI/widgets/anchor.h: to element in HTML. 3 | * 4 | * Copyright (c) 2018-2025, Liu chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LCUI_INCLUDE_WIDGETS_ANCHOR_H 13 | #define LCUI_INCLUDE_WIDGETS_ANCHOR_H 14 | 15 | #include 16 | #include 17 | 18 | LCUI_BEGIN_HEADER 19 | 20 | LCUI_API void ui_anchor_open(ui_widget_t* w); 21 | 22 | LCUI_API void ui_register_anchor(void); 23 | 24 | LCUI_API void ui_unregister_anchor(void); 25 | 26 | LCUI_END_HEADER 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/LCUI/widgets/button.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/LCUI/widgets/button.h: -- LCUI‘s Button widget 3 | * 4 | * Copyright (c) 2018-2025, Liu chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LCUI_INCLUDE_WIDGETS_BUTTON_H 13 | #define LCUI_INCLUDE_WIDGETS_BUTTON_H 14 | 15 | #include 16 | #include 17 | 18 | LCUI_BEGIN_HEADER 19 | 20 | LCUI_API void ui_button_set_text_w(ui_widget_t* w, const wchar_t *wstr); 21 | 22 | LCUI_API void ui_button_set_text(ui_widget_t* w, const char *str); 23 | 24 | LCUI_API void ui_register_button(void); 25 | 26 | LCUI_END_HEADER 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/LCUI/widgets/router_link.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/LCUI/widgets/router_link.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LCUI_INCOIDE_ROUTER_LINK_H 13 | #define LCUI_INCOIDE_ROUTER_LINK_H 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | LCUI_BEGIN_HEADER 20 | 21 | LCUI_API void ui_router_link_set_location( 22 | ui_widget_t *w, router_location_t *location); 23 | 24 | LCUI_API void ui_router_link_set_exact(ui_widget_t *w, bool exact); 25 | 26 | LCUI_API void ui_register_router_link(void); 27 | 28 | LCUI_END_HEADER 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/LCUI/widgets/router_view.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/LCUI/widgets/router_view.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LCUI_INCOIDE_ROUTER_VIEW_H 13 | #define LCUI_INCOIDE_ROUTER_VIEW_H 14 | 15 | #include 16 | #include 17 | 18 | LCUI_BEGIN_HEADER 19 | 20 | LCUI_API ui_widget_t *ui_router_view_get_matched_widget( 21 | ui_widget_t *w); 22 | 23 | LCUI_API void ui_register_router_view(void); 24 | 25 | LCUI_END_HEADER 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /include/LCUI/widgets/scrollbar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/LCUI/widgets/scrollbar.h: -- LCUI's scrollbar widget 3 | * 4 | * Copyright (c) 2018-2025, Liu chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LCUI_INCLUDE_WIDGETS_SCROLLBAR_H 13 | #define LCUI_INCLUDE_WIDGETS_SCROLLBAR_H 14 | 15 | #include 16 | #include 17 | 18 | LCUI_BEGIN_HEADER 19 | 20 | typedef enum { 21 | UI_SCROLLBAR_HORIZONTAL, 22 | UI_SCROLLBAR_VERTICAL 23 | } ui_scrollbar_orientation_t; 24 | 25 | LCUI_API void ui_scrollbar_update(ui_widget_t *w); 26 | 27 | LCUI_API void ui_scrollbar_set_orientation(ui_widget_t* w, 28 | ui_scrollbar_orientation_t orientation); 29 | 30 | LCUI_API ui_widget_t *ui_create_scrollbar(void); 31 | 32 | LCUI_API void ui_register_scrollbar(void); 33 | 34 | LCUI_END_HEADER 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /include/LCUI/widgets/text.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/LCUI/widgets/text.h: -- TextView widget for display 3 | * 4 | * Copyright (c) 2018-2025, Liu chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LCUI_INCLUDE_WIDGETS_TEXT_H 13 | #define LCUI_INCLUDE_WIDGETS_TEXT_H 14 | 15 | #include 16 | #include 17 | 18 | LCUI_BEGIN_HEADER 19 | 20 | LCUI_API int ui_text_set_content_w(ui_widget_t *w, 21 | const wchar_t *text); 22 | 23 | LCUI_API size_t ui_text_get_content_w(ui_widget_t *w, wchar_t *buf, 24 | size_t size); 25 | 26 | LCUI_API int ui_text_set_content(ui_widget_t *w, 27 | const char *utf8_text); 28 | 29 | LCUI_API void ui_text_set_multiline(ui_widget_t *w, bool enable); 30 | 31 | LCUI_API void ui_register_text(void); 32 | 33 | LCUI_API void ui_unregister_text(void); 34 | 35 | LCUI_END_HEADER 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/LCUI/widgets/textcaret.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/LCUI/widgets/textcaret.h: -- textcaret widget, used in textinput. 3 | * 4 | * Copyright (c) 2018-2025, Liu chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LCUI_INCLUDE_WIDGETS_TEXTCARET_H 13 | #define LCUI_INCLUDE_WIDGETS_TEXTCARET_H 14 | 15 | #include 16 | #include 17 | 18 | LCUI_API void ui_textcaret_refresh(ui_widget_t* widget); 19 | 20 | LCUI_API void ui_textcaret_set_visible(ui_widget_t* widget, bool visible); 21 | 22 | /** 设置闪烁的时间间隔 */ 23 | LCUI_API void ui_textcaret_set_blink_time(ui_widget_t* widget, unsigned int n_ms); 24 | 25 | LCUI_API void ui_register_textcaret(void); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /include/LCUI/worker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/LCUI/worker.h 3 | * 4 | * Copyright (c) 2024-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LCUI_INCLUDE_LCUI_WORKER_H 13 | #define LCUI_INCLUDE_LCUI_WORKER_H 14 | 15 | #include "common.h" 16 | #include 17 | 18 | LCUI_BEGIN_HEADER 19 | 20 | LCUI_API worker_task_t *lcui_worker_post_task(void *data, 21 | worker_task_cb task_cb, 22 | worker_task_cb after_task_cb); 23 | 24 | LCUI_API worker_task_t *lcui_worker_post_async_task( 25 | void *data, worker_task_cb task_cb, worker_task_cb after_task_cb); 26 | 27 | LCUI_API bool lcui_worker_cancel_async_task(worker_task_t *task); 28 | 29 | LCUI_API bool lcui_worker_cancel_task(worker_task_t *task); 30 | 31 | LCUI_API void lcui_worker_run(void); 32 | 33 | LCUI_API void lcui_worker_init(void); 34 | 35 | LCUI_API void lcui_worker_destroy(void); 36 | 37 | LCUI_END_HEADER 38 | 39 | #define lcui_post_task lcui_worker_post_task 40 | #define lcui_post_async_task lcui_worker_post_async_task 41 | #define lcui_cancel_task lcui_worker_cancel_task 42 | #define lcui_cancel_async_task lcui_worker_cancel_async_task 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /lib/css/README.md: -------------------------------------------------------------------------------- 1 | # libCSS 2 | 3 | CSS (Cascading Style Sheet) parser and selection engine, providing CSS parsing and selection capabilities. 4 | -------------------------------------------------------------------------------- /lib/css/include/css.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/include/css.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIBCSS_INCLUDE_CSS_H 13 | #define LIBCSS_INCLUDE_CSS_H 14 | 15 | #include "css/common.h" 16 | #include "css/types.h" 17 | #include "css/selector.h" 18 | #include "css/keywords.h" 19 | #include "css/style_value.h" 20 | #include "css/style_decl.h" 21 | #include "css/data_types.h" 22 | #include "css/computed.h" 23 | #include "css/properties.h" 24 | #include "css/library.h" 25 | #include "css/parser.h" 26 | #include "css/utils.h" 27 | #include "css/value.h" 28 | 29 | LIBCSS_PUBLIC void css_init(void); 30 | LIBCSS_PUBLIC void css_destroy(void); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /lib/css/include/css/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/include/css/common.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "config.h" 13 | #ifdef __cplusplus 14 | #define LIBCSS_BEGIN_DECLS extern "C" { 15 | #define LIBCSS_END_DECLS } 16 | #else 17 | #define LIBCSS_BEGIN_DECLS 18 | #define LIBCSS_END_DECLS 19 | #endif 20 | 21 | #ifndef LIBCSS_PUBLIC 22 | #if defined(_MSC_VER) && !defined(LIBCSS_STATIC_BUILD) 23 | #ifdef LIBCSS_DLL_EXPORT 24 | #define LIBCSS_PUBLIC __declspec(dllexport) 25 | #else 26 | #define LIBCSS_PUBLIC __declspec(dllimport) 27 | #endif 28 | #elif __GNUC__ >= 4 29 | #define LIBCSS_PUBLIC extern __attribute__((visibility("default"))) 30 | #else 31 | #define LIBCSS_PUBLIC extern 32 | #endif 33 | #endif 34 | 35 | #if defined(_WIN32) && !defined(__cplusplus) 36 | #define LIBCSS_INLINE __inline 37 | #else 38 | #define LIBCSS_INLINE static inline 39 | #endif 40 | -------------------------------------------------------------------------------- /lib/css/include/css/data_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/include/css/data_types.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIBCSS_INCLUDE_CSS_DATA_TYPES_H 13 | #define LIBCSS_INCLUDE_CSS_DATA_TYPES_H 14 | 15 | #include "common.h" 16 | #include "types.h" 17 | 18 | LIBCSS_BEGIN_DECLS 19 | 20 | LIBCSS_PUBLIC bool css_parse_numeric_value(css_style_value_t *s, 21 | const char *str); 22 | LIBCSS_PUBLIC bool css_parse_unit_value(css_style_value_t *s, const char *str); 23 | LIBCSS_PUBLIC bool css_parse_string_value(css_style_value_t *val, 24 | const char *str); 25 | LIBCSS_PUBLIC bool css_parse_url_value(css_style_value_t *s, const char *str); 26 | LIBCSS_PUBLIC bool css_parse_color_value(css_style_value_t *val, 27 | const char *str); 28 | LIBCSS_PUBLIC void css_init_data_types(void); 29 | 30 | LIBCSS_END_DECLS 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /lib/css/include/css/keywords.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/include/css/keywords.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIBCSS_INCLUDE_CSS_KEYWORDS_H 13 | #define LIBCSS_INCLUDE_CSS_KEYWORDS_H 14 | 15 | #include "common.h" 16 | #include "types.h" 17 | 18 | LIBCSS_BEGIN_DECLS 19 | 20 | LIBCSS_INLINE bool css_check_keyword(css_style_value_t *sv, css_keyword_value_t kv) 21 | { 22 | return sv->type == CSS_KEYWORD_VALUE && sv->keyword_value == kv; 23 | } 24 | 25 | LIBCSS_PUBLIC int css_register_keyword(const char *name); 26 | LIBCSS_PUBLIC int css_get_keyword_key(const char *name); 27 | LIBCSS_PUBLIC const char *css_get_keyword_name(int val); 28 | LIBCSS_PUBLIC void css_init_keywords(void); 29 | LIBCSS_PUBLIC void css_destroy_keywords(void); 30 | 31 | LIBCSS_END_DECLS 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /lib/css/include/css/properties.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/include/css/properties.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIBCSS_INCLUDE_CSS_PROPERTIES_H 13 | #define LIBCSS_INCLUDE_CSS_PROPERTIES_H 14 | 15 | #include "common.h" 16 | #include "types.h" 17 | 18 | LIBCSS_BEGIN_DECLS 19 | 20 | LIBCSS_PUBLIC int css_register_property(const char *name, const char *syntax, 21 | const char *initial_value, 22 | int (*cascade)(const css_style_array_value_t, 23 | css_computed_style_t *)); 24 | 25 | LIBCSS_PUBLIC int css_register_shorthand_property( 26 | const char *name, const char *syntax, 27 | int (*parse)(css_propdef_t *, const char *, css_style_decl_t *)); 28 | 29 | LIBCSS_PUBLIC void css_init_properties(void); 30 | 31 | LIBCSS_PUBLIC void css_destroy_properties(void); 32 | 33 | LIBCSS_PUBLIC css_propdef_t *css_get_propdef_by_name(const char *name); 34 | 35 | LIBCSS_PUBLIC css_propdef_t *css_get_propdef(int key); 36 | 37 | LIBCSS_PUBLIC unsigned css_get_prop_count(void); 38 | 39 | LIBCSS_END_DECLS 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /lib/css/include/css/style_decl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/include/css/style_decl.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIBCSS_INCLUDE_CSS_STYLE_DECL_H 13 | #define LIBCSS_INCLUDE_CSS_STYLE_DECL_H 14 | 15 | #include "common.h" 16 | #include "types.h" 17 | 18 | LIBCSS_BEGIN_DECLS 19 | 20 | LIBCSS_PUBLIC css_style_decl_t *css_style_decl_create(void); 21 | 22 | LIBCSS_PUBLIC void css_style_decl_destroy(css_style_decl_t *list); 23 | 24 | LIBCSS_PUBLIC css_prop_t *css_style_decl_alloc(css_style_decl_t *list, int key); 25 | 26 | LIBCSS_PUBLIC void css_style_decl_add(css_style_decl_t *list, int key, 27 | const css_style_value_t *value); 28 | 29 | LIBCSS_PUBLIC void css_style_decl_set(css_style_decl_t *list, int key, 30 | const css_style_value_t *value); 31 | 32 | LIBCSS_PUBLIC int css_style_decl_remove(css_style_decl_t *list, int key); 33 | 34 | LIBCSS_PUBLIC void css_style_decl_merge(css_style_decl_t *dst, 35 | const css_style_decl_t *src); 36 | 37 | LIBCSS_PUBLIC css_prop_t *css_style_decl_find(css_style_decl_t *list, int key); 38 | 39 | LIBCSS_PUBLIC size_t css_print_style_decl(const css_style_decl_t *s); 40 | 41 | LIBCSS_PUBLIC size_t css_style_decl_to_string(const css_style_decl_t *list, 42 | char *str, size_t max_len); 43 | LIBCSS_END_DECLS 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /lib/css/include/css/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/include/css/utils.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIBCSS_INCLUDE_CSS_UTILS_H 13 | #define LIBCSS_INCLUDE_CSS_UTILS_H 14 | 15 | #include "common.h" 16 | #include "types.h" 17 | 18 | LIBCSS_BEGIN_DECLS 19 | 20 | 21 | LIBCSS_INLINE float css_metrics_actual_scale(css_metrics_t *metrics) 22 | { 23 | return metrics->dpi / 96.0f * metrics->scale; 24 | } 25 | 26 | LIBCSS_PUBLIC bool css_parse_font_weight(const char *str, int *weight); 27 | 28 | LIBCSS_PUBLIC bool css_parse_font_style(const char *str, int *style); 29 | 30 | LIBCSS_END_DECLS 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /lib/css/src/config.h.in: -------------------------------------------------------------------------------- 1 | #define LIBCSS_VERSION "${VERSION}" 2 | #define LIBCSS_VERSION_MAJOR ${VERSION_MAJOR} 3 | #define LIBCSS_VERSION_MINOR ${VERSION_MINOR} 4 | #define LIBCSS_VERSION_ALTER ${VERSION_ALTER} 5 | ${define LIBCSS_STATIC_BUILD} 6 | -------------------------------------------------------------------------------- /lib/css/src/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/debug.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifdef DEBUG 13 | #define DEBUG_MSG _DEBUG_MSG 14 | #else 15 | #define DEBUG_MSG(format, ...) 16 | #endif 17 | 18 | #define _DEBUG_MSG(format, ...) \ 19 | logger_log(LOGGER_LEVEL_DEBUG, __FILE__ ":%d: %s(): " format, \ 20 | __LINE__, __FUNCTION__, ##__VA_ARGS__) 21 | -------------------------------------------------------------------------------- /lib/css/src/dump.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/dump.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include "dump.h" 15 | 16 | size_t css_dump_to_stdout(css_dump_context_t *ctx, const char *fmt, ...) 17 | { 18 | va_list args; 19 | size_t n; 20 | 21 | va_start(args, fmt); 22 | n = vprintf(fmt, args); 23 | ctx->len += n; 24 | va_end(args); 25 | return n; 26 | } 27 | 28 | size_t css_dump_to_buffer(css_dump_context_t *ctx, const char *fmt, ...) 29 | { 30 | va_list args; 31 | size_t n; 32 | 33 | if (ctx->len >= ctx->max_len) { 34 | return 0; 35 | } 36 | va_start(args, fmt); 37 | n = vsnprintf(ctx->data + ctx->len, ctx->max_len - ctx->len, fmt, args); 38 | ctx->len += n; 39 | va_end(args); 40 | return n; 41 | } 42 | -------------------------------------------------------------------------------- /lib/css/src/dump.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/dump.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIBCSS_INCLUDE_CSS_DUMP_H 13 | #define LIBCSS_INCLUDE_CSS_DUMP_H 14 | 15 | #include 16 | #include 17 | 18 | typedef struct css_dump_context css_dump_context_t; 19 | 20 | struct css_dump_context { 21 | char *data; 22 | size_t len; 23 | size_t max_len; 24 | size_t (*func)(css_dump_context_t *, const char *, ...); 25 | }; 26 | 27 | #define DUMP(_STR) ctx->func(ctx, "%s", _STR); 28 | 29 | #define DUMPF(_FMT, ...) ctx->func(ctx, _FMT, ##__VA_ARGS__); 30 | 31 | size_t css_dump_to_stdout(css_dump_context_t *ctx, const char *fmt, ...); 32 | size_t css_dump_to_buffer(css_dump_context_t *ctx, const char *fmt, ...); 33 | 34 | void css_dump_style_value(const css_style_value_t *s, css_dump_context_t *ctx); 35 | void css_dump_style_decl(const css_style_decl_t *list, css_dump_context_t *ctx); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /lib/css/src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/main.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../include/css.h" 13 | 14 | void css_init(void) 15 | { 16 | css_init_value_definitons(); 17 | css_init_data_types(); 18 | css_init_library(); 19 | css_init_keywords(); 20 | css_init_properties(); 21 | } 22 | 23 | void css_destroy(void) 24 | { 25 | css_destroy_properties(); 26 | css_destroy_keywords(); 27 | css_destroy_library(); 28 | css_destroy_value_definitons(); 29 | } 30 | -------------------------------------------------------------------------------- /lib/css/src/parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/parser.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #define CASE_WHITE_SPACE \ 13 | case ' ': \ 14 | case '\n': \ 15 | case '\r': \ 16 | case '\t' 17 | -------------------------------------------------------------------------------- /lib/css/src/properties.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | -------------------------------------------------------------------------------- /lib/css/src/properties/align_content.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/align_content.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | 14 | int css_cascade_align_content(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | uint8_t value = CSS_ALIGN_CONTENT_FLEX_START; 18 | 19 | switch (input[0].keyword_value) { 20 | case CSS_KEYWORD_CENTER: 21 | value = CSS_ALIGN_CONTENT_CENTER; 22 | break; 23 | case CSS_KEYWORD_FLEX_START: 24 | value = CSS_ALIGN_CONTENT_FLEX_START; 25 | break; 26 | case CSS_KEYWORD_FLEX_END: 27 | value = CSS_ALIGN_CONTENT_FLEX_END; 28 | break; 29 | case CSS_KEYWORD_SPACE_AROUND: 30 | value = CSS_ALIGN_CONTENT_SPACE_AROUND; 31 | break; 32 | case CSS_KEYWORD_SPACE_BETWEEN: 33 | value = CSS_ALIGN_CONTENT_SPACE_BETWEEN; 34 | break; 35 | case CSS_KEYWORD_SPACE_EVENLY: 36 | value = CSS_ALIGN_CONTENT_SPACE_EVENLY; 37 | break; 38 | default: 39 | break; 40 | } 41 | computed->type_bits.align_content = value; 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /lib/css/src/properties/align_items.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/align_items.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | 14 | int css_cascade_align_items(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | uint8_t value = CSS_ALIGN_ITEMS_STRETCH; 18 | 19 | switch (input[0].keyword_value) { 20 | case CSS_KEYWORD_CENTER: 21 | value = CSS_ALIGN_ITEMS_CENTER; 22 | break; 23 | case CSS_KEYWORD_FLEX_START: 24 | value = CSS_ALIGN_ITEMS_FLEX_START; 25 | break; 26 | case CSS_KEYWORD_FLEX_END: 27 | value = CSS_ALIGN_ITEMS_FLEX_END; 28 | break; 29 | default: 30 | break; 31 | } 32 | computed->type_bits.align_items = value; 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /lib/css/src/properties/bottom.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/bottom.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | #include "./helpers.h" 14 | 15 | static void set_bottom(css_computed_style_t* computed, uint8_t keyword, 16 | css_numeric_value_t value, css_unit_t unit) 17 | { 18 | computed->bottom = value; 19 | computed->unit_bits.bottom = unit; 20 | computed->type_bits.bottom = keyword; 21 | } 22 | 23 | int css_cascade_bottom(const css_style_array_value_t input, 24 | css_computed_style_t* computed) 25 | { 26 | return css_cascade_length_auto(input, computed, set_bottom); 27 | } 28 | -------------------------------------------------------------------------------- /lib/css/src/properties/box_sizing.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/box_sizing.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | 14 | int css_cascade_box_sizing(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | uint8_t value = CSS_BOX_SIZING_CONTENT_BOX; 18 | 19 | switch (input[0].keyword_value) { 20 | case CSS_KEYWORD_BORDER_BOX: 21 | value = CSS_BOX_SIZING_BORDER_BOX; 22 | break; 23 | default: 24 | break; 25 | } 26 | computed->type_bits.box_sizing = value; 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /lib/css/src/properties/color.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/color.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "./helpers.h" 13 | 14 | int css_cascade_color(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | switch (input[0].type) { 18 | case CSS_COLOR_VALUE: 19 | computed->color = input[0].color_value; 20 | computed->type_bits.color = CSS_COLOR_COLOR; 21 | break; 22 | default: 23 | return -1; 24 | } 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /lib/css/src/properties/content.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/content.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | 14 | int css_cascade_content(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | if (input[0].type == CSS_STRING_VALUE && input[0].string_value) { 18 | computed->content = strdup2(input[0].string_value); 19 | computed->type_bits.content = CSS_CONTENT_SET; 20 | } else { 21 | computed->content = NULL; 22 | computed->type_bits.content = CSS_CONTENT_NONE; 23 | } 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /lib/css/src/properties/display.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/display.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | 14 | int css_cascade_display(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | uint8_t value = CSS_DISPLAY_BLOCK; 18 | 19 | switch (input[0].keyword_value) { 20 | case CSS_KEYWORD_NONE: 21 | value = CSS_DISPLAY_NONE; 22 | break; 23 | case CSS_KEYWORD_BLOCK: 24 | value = CSS_DISPLAY_BLOCK; 25 | break; 26 | case CSS_KEYWORD_INLINE_BLOCK: 27 | value = CSS_DISPLAY_INLINE_BLOCK; 28 | break; 29 | case CSS_KEYWORD_FLEX: 30 | value = CSS_DISPLAY_FLEX; 31 | break; 32 | case CSS_KEYWORD_INLINE_FLEX: 33 | value = CSS_DISPLAY_INLINE_FLEX; 34 | break; 35 | default: 36 | break; 37 | } 38 | computed->type_bits.display = value; 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /lib/css/src/properties/font_size.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/font_size.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | #include "./helpers.h" 14 | 15 | int css_cascade_font_size(const css_style_array_value_t input, 16 | css_computed_style_t* computed) 17 | { 18 | computed->type_bits.font_size = CSS_FONT_SIZE_MEDIUM; 19 | switch (input[0].type) { 20 | case CSS_UNIT_VALUE: 21 | computed->font_size = input[0].unit_value.value; 22 | computed->unit_bits.font_size = input[0].unit_value.unit; 23 | computed->type_bits.font_size = CSS_FONT_SIZE_DIMENSION; 24 | break; 25 | case CSS_KEYWORD_VALUE: 26 | switch (input[0].keyword_value) { 27 | case CSS_KEYWORD_SMALL: 28 | computed->type_bits.font_size = CSS_FONT_SIZE_SMALL; 29 | break; 30 | case CSS_KEYWORD_LARGE: 31 | computed->type_bits.font_size = CSS_FONT_SIZE_LARGE; 32 | break; 33 | default: 34 | break; 35 | } 36 | break; 37 | default: 38 | return -1; 39 | } 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /lib/css/src/properties/font_style.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/font_style.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | 14 | int css_cascade_font_style(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | uint8_t value = CSS_FONT_STYLE_NORMAL; 18 | 19 | switch (input[0].keyword_value) { 20 | case CSS_KEYWORD_OBLIQUE: 21 | value = CSS_FONT_STYLE_OBLIQUE; 22 | break; 23 | case CSS_KEYWORD_ITALIC: 24 | value = CSS_FONT_STYLE_ITALIC; 25 | break; 26 | default: 27 | break; 28 | } 29 | computed->type_bits.font_style = value; 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /lib/css/src/properties/height.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/height.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | #include "./helpers.h" 14 | 15 | static void set_height(css_computed_style_t* computed, uint8_t keyword, 16 | css_numeric_value_t value, css_unit_t unit) 17 | { 18 | computed->height = value; 19 | computed->unit_bits.height = unit; 20 | computed->type_bits.height = keyword; 21 | } 22 | 23 | int css_cascade_height(const css_style_array_value_t input, 24 | css_computed_style_t* computed) 25 | { 26 | return css_cascade_length_auto(input, computed, set_height); 27 | } 28 | -------------------------------------------------------------------------------- /lib/css/src/properties/helpers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/helpers.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_CSS_SRC_PROPERTIES_HELPERS_H 13 | #define LIB_CSS_SRC_PROPERTIES_HELPERS_H 14 | 15 | #include 16 | 17 | int css_cascade_length_auto(const css_style_array_value_t input, 18 | css_computed_style_t* computed, 19 | void (*setter)(css_computed_style_t*, uint8_t, 20 | css_numeric_value_t, css_unit_t)); 21 | 22 | int css_cascade_bg_border_color(const css_style_array_value_t input, 23 | css_computed_style_t* computed, 24 | void (*setter)(css_computed_style_t*, uint8_t, 25 | css_color_value_t)); 26 | #endif 27 | -------------------------------------------------------------------------------- /lib/css/src/properties/justify_content.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/justify_content.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | 14 | int css_cascade_justify_content(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | uint8_t value = CSS_JUSTIFY_CONTENT_FLEX_START; 18 | 19 | switch (input[0].keyword_value) { 20 | case CSS_KEYWORD_CENTER: 21 | value = CSS_JUSTIFY_CONTENT_CENTER; 22 | break; 23 | case CSS_KEYWORD_LEFT: 24 | case CSS_KEYWORD_FLEX_START: 25 | value = CSS_JUSTIFY_CONTENT_FLEX_START; 26 | break; 27 | case CSS_KEYWORD_RIGHT: 28 | case CSS_KEYWORD_FLEX_END: 29 | value = CSS_JUSTIFY_CONTENT_FLEX_END; 30 | break; 31 | case CSS_KEYWORD_SPACE_AROUND: 32 | value = CSS_JUSTIFY_CONTENT_SPACE_AROUND; 33 | break; 34 | case CSS_KEYWORD_SPACE_BETWEEN: 35 | value = CSS_JUSTIFY_CONTENT_SPACE_BETWEEN; 36 | break; 37 | case CSS_KEYWORD_SPACE_EVENLY: 38 | value = CSS_JUSTIFY_CONTENT_SPACE_EVENLY; 39 | break; 40 | default: 41 | break; 42 | } 43 | computed->type_bits.justify_content = value; 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /lib/css/src/properties/left.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/left.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | #include "./helpers.h" 14 | 15 | static void set_left(css_computed_style_t* computed, uint8_t keyword, 16 | css_numeric_value_t value, css_unit_t unit) 17 | { 18 | computed->left = value; 19 | computed->unit_bits.left = unit; 20 | computed->type_bits.left = keyword; 21 | } 22 | 23 | int css_cascade_left(const css_style_array_value_t input, 24 | css_computed_style_t* computed) 25 | { 26 | return css_cascade_length_auto(input, computed, set_left); 27 | } 28 | -------------------------------------------------------------------------------- /lib/css/src/properties/line_height.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/line_height.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | #include "./helpers.h" 14 | 15 | int css_cascade_line_height(const css_style_array_value_t input, 16 | css_computed_style_t* computed) 17 | { 18 | switch (input[0].type) { 19 | case CSS_UNIT_VALUE: 20 | computed->line_height = input[0].unit_value.value; 21 | computed->unit_bits.line_height = input[0].unit_value.unit; 22 | computed->type_bits.line_height = CSS_LINE_HEIGHT_DIMENSION; 23 | break; 24 | case CSS_NUMERIC_VALUE: 25 | computed->line_height = input[0].numeric_value; 26 | computed->type_bits.line_height = CSS_LINE_HEIGHT_NUMBER; 27 | break; 28 | case CSS_KEYWORD_VALUE: 29 | if (input[0].keyword_value == CSS_KEYWORD_NORMAL) { 30 | computed->type_bits.line_height = CSS_LINE_HEIGHT_NORMAL; 31 | break; 32 | } 33 | default: 34 | return -1; 35 | } 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /lib/css/src/properties/max_height.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/max_height.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | #include "./helpers.h" 14 | 15 | static void set_max_height(css_computed_style_t* computed, 16 | uint8_t keyword, css_numeric_value_t value, 17 | css_unit_t unit) 18 | { 19 | computed->max_height = value; 20 | computed->unit_bits.max_height = unit; 21 | computed->type_bits.max_height = keyword; 22 | } 23 | 24 | int css_cascade_max_height(const css_style_array_value_t input, 25 | css_computed_style_t* computed) 26 | { 27 | return css_cascade_length_auto(input, computed, set_max_height); 28 | } 29 | -------------------------------------------------------------------------------- /lib/css/src/properties/max_width.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/max_width.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | #include "./helpers.h" 14 | 15 | static void set_max_width(css_computed_style_t* computed, uint8_t keyword, 16 | css_numeric_value_t value, css_unit_t unit) 17 | { 18 | computed->max_width = value; 19 | computed->unit_bits.max_width = unit; 20 | computed->type_bits.max_width = keyword; 21 | } 22 | 23 | int css_cascade_max_width(const css_style_array_value_t input, 24 | css_computed_style_t* computed) 25 | { 26 | return css_cascade_length_auto(input, computed, set_max_width); 27 | } 28 | -------------------------------------------------------------------------------- /lib/css/src/properties/min_height.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/min_height.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | #include "./helpers.h" 14 | 15 | static void set_min_height(css_computed_style_t* computed, 16 | uint8_t keyword, css_numeric_value_t value, 17 | css_unit_t unit) 18 | { 19 | computed->min_height = value; 20 | computed->unit_bits.min_height = unit; 21 | computed->type_bits.min_height = keyword; 22 | } 23 | 24 | int css_cascade_min_height(const css_style_array_value_t input, 25 | css_computed_style_t* computed) 26 | { 27 | if (input[0].type == CSS_KEYWORD_VALUE && 28 | input[0].keyword_value == CSS_KEYWORD_MIN_CONTENT) { 29 | set_min_height(computed, CSS_MIN_WIDTH_MIN_CONTENT, 0, CSS_UNIT_PX); 30 | return 0; 31 | } 32 | return css_cascade_length_auto(input, computed, set_min_height); 33 | } 34 | -------------------------------------------------------------------------------- /lib/css/src/properties/min_width.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/min_width.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | #include "./helpers.h" 14 | 15 | static void set_min_width(css_computed_style_t* computed, uint8_t keyword, 16 | css_numeric_value_t value, css_unit_t unit) 17 | { 18 | computed->min_width = value; 19 | computed->unit_bits.min_width = unit; 20 | computed->type_bits.min_width = keyword; 21 | } 22 | 23 | int css_cascade_min_width(const css_style_array_value_t input, 24 | css_computed_style_t* computed) 25 | { 26 | if (input[0].type == CSS_KEYWORD_VALUE && 27 | input[0].keyword_value == CSS_KEYWORD_MIN_CONTENT) { 28 | set_min_width(computed, CSS_MIN_WIDTH_MIN_CONTENT, 0, CSS_UNIT_PX); 29 | return 0; 30 | } 31 | return css_cascade_length_auto(input, computed, set_min_width); 32 | } 33 | -------------------------------------------------------------------------------- /lib/css/src/properties/opacity.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/opacity.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | 14 | int css_cascade_opacity(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | computed->opacity = input[0].numeric_value; 18 | computed->type_bits.opacity = CSS_OPACITY_SET; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /lib/css/src/properties/pointer_events.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/pointer_events.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | 14 | int css_cascade_pointer_events(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | uint8_t value = CSS_POINTER_EVENTS_AUTO; 18 | 19 | switch (input[0].keyword_value) { 20 | case CSS_KEYWORD_NONE: 21 | value = CSS_POINTER_EVENTS_NONE; 22 | default: 23 | break; 24 | } 25 | computed->type_bits.pointer_events = value; 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /lib/css/src/properties/position.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/position.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | 14 | int css_cascade_position(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | uint8_t value = CSS_POSITION_STATIC; 18 | 19 | switch (input[0].keyword_value) { 20 | case CSS_KEYWORD_ABSOLUTE: 21 | value = CSS_POSITION_ABSOLUTE; 22 | break; 23 | case CSS_KEYWORD_RELATIVE: 24 | value = CSS_POSITION_RELATIVE; 25 | break; 26 | default: 27 | break; 28 | } 29 | computed->type_bits.position = value; 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /lib/css/src/properties/right.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/right.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | #include "./helpers.h" 14 | 15 | static void set_right(css_computed_style_t* computed, uint8_t keyword, 16 | css_numeric_value_t value, css_unit_t unit) 17 | { 18 | computed->right = value; 19 | computed->unit_bits.right = unit; 20 | computed->type_bits.right = keyword; 21 | } 22 | 23 | int css_cascade_right(const css_style_array_value_t input, 24 | css_computed_style_t* computed) 25 | { 26 | return css_cascade_length_auto(input, computed, set_right); 27 | } 28 | -------------------------------------------------------------------------------- /lib/css/src/properties/text_align.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/text_align.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | 14 | int css_cascade_text_align(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | uint8_t value = CSS_TEXT_ALIGN_LEFT; 18 | 19 | switch (input[0].keyword_value) { 20 | case CSS_KEYWORD_CENTER: 21 | value = CSS_TEXT_ALIGN_CENTER; 22 | break; 23 | case CSS_KEYWORD_RIGHT: 24 | value = CSS_TEXT_ALIGN_RIGHT; 25 | break; 26 | default: 27 | break; 28 | } 29 | computed->type_bits.text_align = value; 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /lib/css/src/properties/top.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/top.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | #include "./helpers.h" 14 | 15 | static void set_top(css_computed_style_t* computed, uint8_t keyword, 16 | css_numeric_value_t value, css_unit_t unit) 17 | { 18 | computed->top = value; 19 | computed->unit_bits.top = unit; 20 | computed->type_bits.top = keyword; 21 | } 22 | 23 | int css_cascade_top(const css_style_array_value_t input, 24 | css_computed_style_t* computed) 25 | { 26 | return css_cascade_length_auto(input, computed, set_top); 27 | } 28 | -------------------------------------------------------------------------------- /lib/css/src/properties/vertical_align.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/vertical_align.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | 14 | int css_cascade_vertical_align(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | css_vertical_align_t value; 18 | 19 | switch (input[0].keyword_value) { 20 | case CSS_KEYWORD_MIDDLE: 21 | value = CSS_VERTICAL_ALIGN_MIDDLE; 22 | break; 23 | case CSS_KEYWORD_BOTTOM: 24 | value = CSS_VERTICAL_ALIGN_BOTTOM; 25 | break; 26 | case CSS_KEYWORD_TOP: 27 | default: 28 | value = CSS_VERTICAL_ALIGN_TOP; 29 | break; 30 | } 31 | computed->type_bits.vertical_align = value; 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /lib/css/src/properties/visibility.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/visibility.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | 14 | int css_cascade_visibility(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | uint8_t value = CSS_VISIBILITY_VISIBLE; 18 | 19 | switch (input[0].keyword_value) { 20 | case CSS_KEYWORD_HIDDEN: 21 | value = CSS_VISIBILITY_HIDDEN; 22 | break; 23 | default: 24 | break; 25 | } 26 | computed->type_bits.visibility = value; 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /lib/css/src/properties/white_space.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/white_space.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | 14 | int css_cascade_white_space(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | computed->type_bits.white_space = CSS_WHITE_SPACE_NORMAL; 18 | switch (input[0].keyword_value) { 19 | case CSS_KEYWORD_NOWRAP: 20 | computed->type_bits.white_space = CSS_WHITE_SPACE_NOWRAP; 21 | break; 22 | default: 23 | break; 24 | } 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /lib/css/src/properties/width.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/width.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | #include "./helpers.h" 14 | 15 | static void set_width(css_computed_style_t* computed, uint8_t keyword, 16 | css_numeric_value_t value, css_unit_t unit) 17 | { 18 | computed->width = value; 19 | computed->unit_bits.width = unit; 20 | computed->type_bits.width = keyword; 21 | } 22 | 23 | int css_cascade_width(const css_style_array_value_t input, 24 | css_computed_style_t* computed) 25 | { 26 | return css_cascade_length_auto(input, computed, set_width); 27 | } 28 | -------------------------------------------------------------------------------- /lib/css/src/properties/word_break.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/word_break.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | 14 | int css_cascade_word_break(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | computed->type_bits.word_break = CSS_WORD_BREAK_NORMAL; 18 | switch (input[0].keyword_value) { 19 | case CSS_KEYWORD_BREAK_ALL: 20 | computed->type_bits.word_break = CSS_WORD_BREAK_BREAK_ALL; 21 | break; 22 | default: 23 | break; 24 | } 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /lib/css/src/properties/z_index.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/properties/z_index.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "../properties.h" 13 | 14 | int css_cascade_z_index(const css_style_array_value_t input, 15 | css_computed_style_t* computed) 16 | { 17 | if (input[0].type == CSS_NUMERIC_VALUE) { 18 | computed->z_index = input[0].numeric_value; 19 | } else { 20 | computed->z_index = 0; 21 | } 22 | computed->type_bits.z_index = CSS_Z_INDEX_SET; 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /lib/css/src/utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/src/utils.c: -- Parse data from string 3 | * 4 | * Copyright (c) 2018-2025, Liu chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | bool css_parse_font_weight(const char *str, int *weight) 19 | { 20 | int value; 21 | // TODO 22 | if (strcmp(str, "normal") == 0) { 23 | *weight = CSS_FONT_WEIGHT_NORMAL; 24 | return true; 25 | } 26 | if (strcmp(str, "bold") == 0) { 27 | *weight = CSS_FONT_WEIGHT_BOLD; 28 | return true; 29 | } 30 | if (sscanf(str, "%d", &value) != 1) { 31 | *weight = CSS_FONT_WEIGHT_NORMAL; 32 | return false; 33 | } 34 | if (value < 100) { 35 | *weight = CSS_FONT_WEIGHT_100; 36 | return true; 37 | } 38 | *weight = y_iround(value / 100.0) * 100; 39 | return true; 40 | } 41 | 42 | bool css_parse_font_style(const char *str, int *style) 43 | { 44 | char value[64] = ""; 45 | // TODO 46 | strtrim(value, str, NULL); 47 | if (strcmp(value, "normal") == 0) { 48 | *style = CSS_FONT_STYLE_NORMAL; 49 | } else if (strcmp(value, "italic") == 0) { 50 | *style = CSS_FONT_STYLE_ITALIC; 51 | } else if (strcmp(value, "oblique") == 0) { 52 | *style = CSS_FONT_STYLE_OBLIQUE; 53 | } else { 54 | return false; 55 | } 56 | return true; 57 | } 58 | -------------------------------------------------------------------------------- /lib/css/tests/test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/tests/test.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include "test.h" 15 | 16 | int main() 17 | { 18 | logger_set_level(LOGGER_LEVEL_ALL); 19 | ctest_describe("test_css_keywords", test_css_keywords); 20 | ctest_describe("test_css_value", test_css_value); 21 | ctest_describe("test_css_computed", test_css_computed); 22 | return ctest_finish(); 23 | } 24 | -------------------------------------------------------------------------------- /lib/css/tests/test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/tests/test.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void test_css_keywords(void); 13 | 14 | void test_css_value(void); 15 | 16 | void test_css_computed(void); 17 | -------------------------------------------------------------------------------- /lib/css/tests/test_css_computed.css: -------------------------------------------------------------------------------- 1 | * { 2 | font-size: 16px; 3 | box-sizing: border-box; 4 | } 5 | 6 | .container { 7 | max-width: 800px; 8 | margin: 24px auto; 9 | } 10 | 11 | .button { 12 | padding: 4px 8px; 13 | min-width: 80px; 14 | text-align: center; 15 | border: 1px solid #eee; 16 | border-radius: 4px; 17 | background-color: #fff; 18 | content: "submit"; 19 | } 20 | 21 | .button:focus { 22 | box-shadow: 0 0 0 2px rgba(0, 0, 200, 0.5); 23 | } 24 | 25 | .primary.button { 26 | color: #fff; 27 | background: #0050c9; 28 | } 29 | 30 | .button.borderless { 31 | border: none; 32 | } 33 | 34 | .w-\[360px\] { 35 | width: 360px; 36 | } 37 | -------------------------------------------------------------------------------- /lib/css/tests/test_css_keywords.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/css/tests/test_css_keywords.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include "test.h" 15 | #include "ctest.h" 16 | 17 | static void test_keyword_value(const char *name, int value) 18 | { 19 | char str[256] = { 0 }; 20 | 21 | snprintf(str, 255, "keyword('%s').value", name); 22 | ctest_equal_int(str, css_get_keyword_key(name), value); 23 | } 24 | 25 | static void test_keyword_register(const char *name) 26 | { 27 | char str[256] = { 0 }; 28 | int a = css_register_keyword(name); 29 | int b = css_get_keyword_key(name); 30 | 31 | snprintf(str, 255, "keyword('%s')", name); 32 | ctest_equal_int(str, a, b); 33 | } 34 | 35 | void test_css_keywords(void) 36 | { 37 | css_init_keywords(); 38 | 39 | test_keyword_value("inherit", CSS_KEYWORD_INHERIT); 40 | test_keyword_value("none", CSS_KEYWORD_NONE); 41 | test_keyword_value("auto", CSS_KEYWORD_AUTO); 42 | test_keyword_value("center", CSS_KEYWORD_CENTER); 43 | test_keyword_value("inline-block", CSS_KEYWORD_INLINE_BLOCK); 44 | test_keyword_register("custom-keyword"); 45 | 46 | css_destroy_keywords(); 47 | } 48 | -------------------------------------------------------------------------------- /lib/css/xmake.lua: -------------------------------------------------------------------------------- 1 | set_project("libcss") 2 | set_version("0.1.0-a") 3 | 4 | target("libcss") 5 | set_kind("$(kind)") 6 | add_files("src/**.c") 7 | set_configdir("include/css") 8 | add_configfiles("src/config.h.in") 9 | add_headerfiles("include/css.h", "include/(css/*.h)") 10 | add_deps("yutil") 11 | if is_kind("static") then 12 | set_configvar("LIBCSS_STATIC_BUILD", 1) 13 | elseif is_plat("windows") then 14 | add_defines("LIBCSS_DLL_EXPORT") 15 | end 16 | 17 | target("libcss_tests") 18 | set_default(false) 19 | set_kind("binary") 20 | set_rundir("tests") 21 | add_files("tests/*.c") 22 | add_deps("ctest", "libcss") 23 | on_run(function (target) 24 | import("core.base.option") 25 | local argv = {} 26 | local options = {{nil, "memcheck", "k", nil, "enable memory check."}} 27 | local args = option.raw_parse(option.get("arguments") or {}, options) 28 | os.cd("$(scriptdir)/tests") 29 | if args.memcheck then 30 | if is_plat("windows") then 31 | table.insert(argv, target:targetfile()) 32 | os.execv("drmemory", argv) 33 | else 34 | table.insert(argv, "--leak-check=full") 35 | table.insert(argv, "--error-exitcode=42") 36 | table.insert(argv, target:targetfile()) 37 | os.execv("valgrind", argv) 38 | end 39 | else 40 | os.execv(target:targetfile()) 41 | end 42 | end) 43 | -------------------------------------------------------------------------------- /lib/ctest/xmake.lua: -------------------------------------------------------------------------------- 1 | add_rules("mode.debug", "mode.release") 2 | add_includedirs("include") 3 | 4 | target("ctest") 5 | set_kind("static") 6 | add_files("src/*.c") 7 | add_deps("yutil") 8 | add_headerfiles("include/ctest.h") 9 | -------------------------------------------------------------------------------- /lib/i18n/src/i18n-private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/i18n/src/i18n-private.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include "i18n.h" 16 | 17 | typedef enum { NONE, STRING, DICT } dict_value_type_t; 18 | 19 | typedef struct dict_string_value { 20 | wchar_t *data; 21 | size_t length; 22 | } dict_string_value_t; 23 | 24 | typedef struct dict_value dict_value_t; 25 | 26 | struct dict_value { 27 | dict_value_type_t type; 28 | union { 29 | dict_string_value_t string; 30 | dict_t *dict; 31 | }; 32 | wchar_t *key; 33 | dict_t *parent_dict; 34 | dict_value_t *parent_value; 35 | }; 36 | 37 | /** dict_t */ 38 | dict_t *i18n_dict_create(void); 39 | 40 | bool i18n_dict_add_dict(dict_t *dict, const wchar_t *key, dict_t *child_dict); 41 | 42 | dict_t *i18n_load_yaml_file(const char *path); 43 | -------------------------------------------------------------------------------- /lib/i18n/tests/locales/en.yml: -------------------------------------------------------------------------------- 1 | name: English 2 | button: 3 | ok: Ok 4 | cancel: Cancel 5 | -------------------------------------------------------------------------------- /lib/i18n/tests/locales/zh-CN.yml: -------------------------------------------------------------------------------- 1 | name: 中文 2 | button: 3 | ok: 确定 4 | cancel: 取消 5 | -------------------------------------------------------------------------------- /lib/pandagl/README.md: -------------------------------------------------------------------------------- 1 | # PandaGL 2 | 3 | PandaGL (Panda Graphics Library) is a 2D graph library to draw some basic graphics. 4 | -------------------------------------------------------------------------------- /lib/pandagl/examples/cairo/.gitignore: -------------------------------------------------------------------------------- 1 | # Xmake cache 2 | .xmake/ 3 | build/ 4 | 5 | # MacOS Cache 6 | .DS_Store 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/pandagl/examples/cairo/README.md: -------------------------------------------------------------------------------- 1 | # Cairo Example 2 | 3 | (**English**/[中文](./README.zh-cn.md)) 4 | 5 | An example of drawing with PandaGL and Cairo graphics libraries. It creates a canvas using PandaGL, then creates a Surface based on the canvas for Cairo to draw complex shapes, fills simple shapes with PandaGL, and outputs the results as a PNG image file using Cairo. 6 | 7 | ```bash 8 | # Build PandaGL 9 | xmake build pandagl 10 | 11 | # Package PandaGL 12 | xmake package pandagl 13 | 14 | # Build example project 15 | xmake -P . 16 | 17 | # Run example project 18 | xmake run -P . -w . 19 | ``` 20 | 21 | Open the output.png file and you'll see something like this: 22 | 23 | ![output](./output.png) 24 | -------------------------------------------------------------------------------- /lib/pandagl/examples/cairo/README.zh-cn.md: -------------------------------------------------------------------------------- 1 | # Cairo Example 2 | 3 | ([English](./README.md)/**中文**) 4 | 5 | PandaGL 和 Cairo 图形库混用的例子。大致流程是先用 PandaGL 创建画布,然后基于画布创建一个 Surface 供 Cairo 绘制复杂图形,之后用 PandaGL 填充简单的图形,最后用 Cairo 将绘制结果输出为 png 图片文件。 6 | 7 | ```bash 8 | # 构建 PandaGL 库 9 | xmake build pandagl 10 | 11 | # 打包 PandaGL 库 12 | xmake package pandagl 13 | 14 | # 构建当前目录下的示例 15 | xmake -P . 16 | 17 | # 运行当前目录下的示例项目 18 | xmake run -P . -w . 19 | ``` 20 | 21 | 输出的 output.png 图片内容如下: 22 | 23 | ![output](./output.png) 24 | -------------------------------------------------------------------------------- /lib/pandagl/examples/cairo/output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/lib/pandagl/examples/cairo/output.png -------------------------------------------------------------------------------- /lib/pandagl/include/pandagl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/include/pandagl.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "pandagl/common.h" 13 | #include "pandagl/types.h" 14 | #include "pandagl/rect.h" 15 | #include "pandagl/color.h" 16 | #include "pandagl/pixel.h" 17 | #include "pandagl/canvas.h" 18 | #include "pandagl/context.h" 19 | #include "pandagl/line.h" 20 | #include "pandagl/background.h" 21 | #include "pandagl/border.h" 22 | #include "pandagl/boxshadow.h" 23 | #include "pandagl/file_reader.h" 24 | #include "pandagl/font.h" 25 | #include "pandagl/text.h" 26 | #include "pandagl/image.h" 27 | -------------------------------------------------------------------------------- /lib/pandagl/include/pandagl/background.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/include/pandagl/background.h: -- Background image draw support. 3 | * 4 | * Copyright (c) 2018-2025, Liu chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_PANDAGL_INCLUDE_PANDAGL_BACKGROUND_H 13 | #define LIB_PANDAGL_INCLUDE_PANDAGL_BACKGROUND_H 14 | 15 | #include "common.h" 16 | #include "types.h" 17 | 18 | PD_BEGIN_DECLS 19 | 20 | /** 21 | * 绘制背景 22 | * @param ctx 绘制器的上下文句柄 23 | * @param[in] box 背景区域 24 | * @param[in] bg 背景样式参数 25 | */ 26 | PD_PUBLIC void pd_paint_background(pd_context_t *ctx, const pd_background_t *bg, 27 | const pd_rect_t *box); 28 | 29 | PD_END_DECLS 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /lib/pandagl/include/pandagl/border.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/include/pandagl/border.h: -- Border drawing 3 | * 4 | * Copyright (c) 2018-2025, Liu chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_PANDAGL_INCLUDE_PANDAGL_BORDER_H 13 | #define LIB_PANDAGL_INCLUDE_PANDAGL_BORDER_H 14 | 15 | #include "common.h" 16 | #include "types.h" 17 | 18 | PD_BEGIN_DECLS 19 | 20 | PD_PUBLIC int pd_crop_border_content(pd_context_t *ctx, 21 | const pd_border_t *border, 22 | const pd_rect_t *box); 23 | 24 | PD_PUBLIC int pd_paint_border(pd_context_t *ctx, const pd_border_t *border, 25 | const pd_rect_t *box); 26 | 27 | PD_END_DECLS 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /lib/pandagl/include/pandagl/boxshadow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/include/pandagl/boxshadow.h: -- Box shadow drawing 3 | * 4 | * Copyright (c) 2018-2025, Liu chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_PANDAGL_INCLUDE_PANDAGL_BOXSHADOW_H 13 | #define LIB_PANDAGL_INCLUDE_PANDAGL_BOXSHADOW_H 14 | 15 | #include "common.h" 16 | #include "types.h" 17 | 18 | PD_BEGIN_DECLS 19 | 20 | PD_PUBLIC void pd_get_boxshadow_canvas_rect(const pd_boxshadow_t *shadow, 21 | const pd_rect_t *box_rect, 22 | pd_rect_t *canvas_rect); 23 | 24 | PD_PUBLIC int pd_paint_boxshadow(pd_context_t *ctx, const pd_boxshadow_t *shadow, 25 | const pd_rect_t *box, int content_width, 26 | int content_height); 27 | 28 | PD_END_DECLS 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /lib/pandagl/include/pandagl/color.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/include/pandagl/color.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_PANDAGL_INCLUDE_PANDAGL_COLOR_H 13 | #define LIB_PANDAGL_INCLUDE_PANDAGL_COLOR_H 14 | 15 | #include "common.h" 16 | #include "types.h" 17 | 18 | PD_INLINE pd_color_t pd_color(uint8_t a, uint8_t r, uint8_t g, uint8_t b) 19 | { 20 | pd_color_t color = { .a = a, .r = r, .g = g, .b = b }; 21 | return color; 22 | } 23 | 24 | #define pd_argb pd_color 25 | #define pd_rgb(R, G, B) pd_color(255, R, G, B) 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /lib/pandagl/include/pandagl/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/include/pandagl/common.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "config.h" 13 | #ifdef __cplusplus 14 | #define PD_BEGIN_DECLS extern "C" { 15 | #define PD_END_DECLS } 16 | #else 17 | #define PD_BEGIN_DECLS 18 | #define PD_END_DECLS 19 | #endif 20 | 21 | #ifndef PD_PUBLIC 22 | #if defined(_MSC_VER) && !defined(PANDAGL_STATIC_BUILD) 23 | #ifdef PANDAGL_DLL_EXPORT 24 | #define PD_PUBLIC __declspec(dllexport) 25 | #else 26 | #define PD_PUBLIC __declspec(dllimport) 27 | #endif 28 | #elif __GNUC__ >= 4 29 | #define PD_PUBLIC extern __attribute__((visibility("default"))) 30 | #else 31 | #define PD_PUBLIC extern 32 | #endif 33 | #endif 34 | 35 | #if defined(_WIN32) && !defined(__cplusplus) 36 | #define PD_INLINE __inline 37 | #else 38 | #define PD_INLINE static inline 39 | #endif 40 | -------------------------------------------------------------------------------- /lib/pandagl/include/pandagl/context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/include/pandagl/context.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_PANDAGL_INCLUDE_PANDAGL_CONTEXT_H 13 | #define LIB_PANDAGL_INCLUDE_PANDAGL_CONTEXT_H 14 | 15 | #include "common.h" 16 | #include "types.h" 17 | 18 | PD_BEGIN_DECLS 19 | 20 | PD_PUBLIC pd_context_t* pd_context_create(pd_canvas_t *canvas, pd_rect_t *rect); 21 | 22 | PD_PUBLIC void pd_context_destroy(pd_context_t* paint); 23 | 24 | PD_END_DECLS 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /lib/pandagl/include/pandagl/line.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/include/pandagl/line.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_PANDAGL_INCLUDE_PANDAGL_LINE_H 13 | #define LIB_PANDAGL_INCLUDE_PANDAGL_LINE_H 14 | 15 | #include "common.h" 16 | #include "types.h" 17 | 18 | PD_BEGIN_DECLS 19 | 20 | PD_PUBLIC void pd_canvas_draw_horizontal_line(pd_canvas_t *canvas, 21 | pd_color_t color, int size, 22 | pd_pos_t start, int end_x); 23 | 24 | PD_PUBLIC void pd_canvas_draw_vertical_line(pd_canvas_t *canvas, 25 | pd_color_t color, int size, 26 | pd_pos_t start, int end_y); 27 | 28 | PD_INLINE void pd_canvas_draw_hline(pd_canvas_t *canvas, pd_color_t color, 29 | int size, pd_pos_t start, int end_x) 30 | { 31 | pd_canvas_draw_horizontal_line(canvas, color, size, start, end_x); 32 | } 33 | 34 | PD_INLINE void pd_canvas_draw_vline(pd_canvas_t *canvas, pd_color_t color, int size, 35 | pd_pos_t start, int end_y) 36 | { 37 | pd_canvas_draw_vertical_line(canvas, color, size, start, end_y); 38 | } 39 | 40 | PD_END_DECLS 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /lib/pandagl/src/config.h.in: -------------------------------------------------------------------------------- 1 | #define PANDAGL_VERSION "${VERSION}" 2 | #define PANDAGL_VERSION_MAJOR ${VERSION_MAJOR} 3 | #define PANDAGL_VERSION_MINOR ${VERSION_MINOR} 4 | #define PANDAGL_VERSION_ALTER ${VERSION_ALTER} 5 | ${define PANDAGL_STATIC_BUILD} 6 | ${define PANDAGL_HAS_TEXT} 7 | ${define PANDAGL_HAS_FONT} 8 | ${define PANDAGL_HAS_FREETYPE} 9 | ${define PANDAGL_HAS_FONTCONFIG} 10 | ${define PANDAGL_HAS_IMAGE} 11 | ${define PANDAGL_HAS_LIBPNG} 12 | ${define PANDAGL_HAS_LIBJPEG} 13 | -------------------------------------------------------------------------------- /lib/pandagl/src/context.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/src/context.c: -- The PandaGL drawing context 3 | * 4 | * Copyright (c) 2022-2025, Liu chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | pd_context_t* pd_context_create(pd_canvas_t *canvas, pd_rect_t *rect) 16 | { 17 | pd_context_t* paint = (pd_context_t*)malloc(sizeof(pd_context_t)); 18 | paint->rect = *rect; 19 | paint->with_alpha = false; 20 | pd_canvas_init(&paint->canvas); 21 | pd_canvas_quote(&paint->canvas, canvas, &paint->rect); 22 | return paint; 23 | } 24 | 25 | void pd_context_destroy(pd_context_t* paint) 26 | { 27 | free(paint); 28 | } 29 | -------------------------------------------------------------------------------- /lib/pandagl/src/font/bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/src/font/bitmap.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | /** 初始化字体位图 */ 13 | void pd_font_bitmap_init(pd_font_bitmap_t *bitmap); 14 | 15 | /** 释放字体位图占用的资源 */ 16 | void pd_font_bitmap_destroy(pd_font_bitmap_t *bitmap); 17 | -------------------------------------------------------------------------------- /lib/pandagl/src/font/freetype.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/src/font/freetype.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | int pd_freetype_engine_init(font_engine_t *engine); 13 | int pd_freetype_engine_destroy(void); 14 | -------------------------------------------------------------------------------- /lib/pandagl/src/font/inconsolata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/src/font/inconsolata.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | int pd_render_inconsolata_font_bitmap(pd_font_bitmap_t *bmp, unsigned ch, int size); 13 | -------------------------------------------------------------------------------- /lib/pandagl/src/font/incore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/src/font/incore.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | int pd_incore_font_create(font_engine_t *engine); 13 | int pd_incore_font_destroy(void); 14 | -------------------------------------------------------------------------------- /lib/pandagl/src/font/library.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/src/font/library.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | pd_font_t *pd_font_create(const char *family_name, const char *style_name); 13 | 14 | void pd_font_destroy(pd_font_t *font); 15 | -------------------------------------------------------------------------------- /lib/pandagl/src/image/bmp_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/src/image/bmp_private.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void pd_bmp_reader_create(pd_image_reader_t *reader); 13 | void pd_bmp_reader_destroy(pd_image_reader_t *reader); 14 | jmp_buf *pd_bmp_reader_jmpbuf(pd_image_reader_t *reader); 15 | pd_error_t pd_bmp_reader_read_header(pd_image_reader_t *reader); 16 | void pd_bmp_reader_start(pd_image_reader_t *reader); 17 | void pd_bmp_reader_read_row(pd_image_reader_t *reader, pd_canvas_t *graph); 18 | void pd_bmp_reader_finish(pd_image_reader_t *reader); 19 | -------------------------------------------------------------------------------- /lib/pandagl/src/image/jpeg_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/src/image/jpeg_private.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void pd_jpeg_reader_create(pd_image_reader_t *reader); 13 | void pd_jpeg_reader_destroy(pd_image_reader_t *reader); 14 | jmp_buf *pd_jpeg_reader_jmpbuf(pd_image_reader_t *reader); 15 | pd_error_t pd_jpeg_reader_read_header(pd_image_reader_t *reader); 16 | void pd_jpeg_reader_start(pd_image_reader_t *reader); 17 | void pd_jpeg_reader_read_row(pd_image_reader_t *reader, pd_canvas_t *graph); 18 | void pd_jpeg_reader_finish(pd_image_reader_t *reader); 19 | -------------------------------------------------------------------------------- /lib/pandagl/src/image/png_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/src/image/png_private.h 3 | * 4 | * Copyright (c) 2024-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void pd_png_reader_create(pd_image_reader_t *reader); 13 | void pd_png_reader_destroy(pd_image_reader_t *reader); 14 | jmp_buf *pd_png_reader_jmpbuf(pd_image_reader_t *reader); 15 | pd_error_t pd_png_reader_read_header(pd_image_reader_t *reader); 16 | void pd_png_reader_start(pd_image_reader_t *reader); 17 | void pd_png_reader_read_row(pd_image_reader_t *reader, pd_canvas_t *graph); 18 | void pd_png_reader_finish(pd_image_reader_t *reader); 19 | -------------------------------------------------------------------------------- /lib/pandagl/src/tile.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/src/tile.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | 14 | int pd_canvas_tile(pd_canvas_t *buff, const pd_canvas_t *canvas, 15 | bool replace, bool with_alpha) 16 | { 17 | int ret = 0; 18 | unsigned x, y; 19 | 20 | if (!pd_canvas_is_valid(canvas) || !pd_canvas_is_valid(buff)) { 21 | return -1; 22 | } 23 | for (y = 0; y < buff->height; y += canvas->height) { 24 | for (x = 0; x < buff->width; x += canvas->width) { 25 | if (replace) { 26 | ret += pd_canvas_replace(buff, canvas, y, x); 27 | continue; 28 | } 29 | ret += pd_canvas_mix(buff, canvas, y, x, with_alpha); 30 | } 31 | } 32 | return ret; 33 | } 34 | -------------------------------------------------------------------------------- /lib/pandagl/test/test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/test/test.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "test.h" 13 | #include "ctest.h" 14 | 15 | int main() 16 | { 17 | ctest_describe("test_canvas_mix", test_canvas_mix); 18 | return ctest_finish(); 19 | } 20 | -------------------------------------------------------------------------------- /lib/pandagl/test/test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/pandagl/test/test.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void test_canvas_mix(void); 13 | -------------------------------------------------------------------------------- /lib/ptk/include/ptk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/include/ptk.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef PTK_INCLUDE_PLATFORM_H 13 | #define PTK_INCLUDE_PLATFORM_H 14 | 15 | #include "ptk/common.h" 16 | #include "ptk/types.h" 17 | #include "ptk/app.h" 18 | #include "ptk/window.h" 19 | #include "ptk/events.h" 20 | #include "ptk/clipboard.h" 21 | #include "ptk/steptimer.h" 22 | #include "ptk/ime.h" 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /lib/ptk/include/ptk/app.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/include/ptk/app.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef PTK_INCLUDE_PLATFORM_APP_H 13 | #define PTK_INCLUDE_PLATFORM_APP_H 14 | 15 | #include "ptk/types.h" 16 | #include "ptk/common.h" 17 | 18 | PTK_BEGIN_DECLS 19 | 20 | PTK_PUBLIC int ptk_open_uri(const char *uri); 21 | 22 | PTK_PUBLIC int ptk_app_init(const wchar_t *name); 23 | PTK_PUBLIC int ptk_app_destroy(void); 24 | PTK_PUBLIC void ptk_set_instance(void *instance); 25 | PTK_PUBLIC ptk_app_id_t ptk_get_app_id(void); 26 | PTK_PUBLIC void ptk_app_present(void); 27 | PTK_PUBLIC int ptk_init(const wchar_t *name); 28 | PTK_PUBLIC int ptk_run(void); 29 | PTK_PUBLIC void ptk_app_exit(int exit_code); 30 | PTK_PUBLIC void ptk_destroy(void); 31 | 32 | PTK_END_DECLS 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /lib/ptk/include/ptk/clipboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/include/ptk/clipboard.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef PTK_INCLUDE_PLATFORM_CLIPBOARD_H 13 | #define PTK_INCLUDE_PLATFORM_CLIPBOARD_H 14 | 15 | #include "types.h" 16 | #include "common.h" 17 | 18 | PTK_BEGIN_DECLS 19 | 20 | /** 21 | * Clipboard 22 | * References: https://docs.gtk.org/gtk3/class.Clipboard.html 23 | */ 24 | 25 | typedef struct ptk_clipboard { 26 | pd_canvas_t *image; 27 | wchar_t *text; 28 | size_t len; 29 | } ptk_clipboard_t; 30 | 31 | typedef void (*ptk_clipboard_callback_t)(ptk_clipboard_t *, void *); 32 | 33 | PTK_PUBLIC int ptk_clipboard_request_text(ptk_clipboard_callback_t action, void *arg); 34 | PTK_PUBLIC int ptk_clipboard_set_text(const wchar_t *text, size_t len); 35 | 36 | PTK_END_DECLS 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /lib/ptk/include/ptk/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/include/ptk/common.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "config.h" 13 | #ifdef __cplusplus 14 | #define PTK_BEGIN_DECLS extern "C" { 15 | #define PTK_END_DECLS } 16 | #else 17 | #define PTK_BEGIN_DECLS 18 | #define PTK_END_DECLS 19 | #endif 20 | 21 | #ifndef PTK_PUBLIC 22 | #if defined(_MSC_VER) && !defined(PTK_STATIC_BUILD) 23 | #ifdef PTK_DLL_EXPORT 24 | #define PTK_PUBLIC __declspec(dllexport) 25 | #else 26 | #define PTK_PUBLIC __declspec(dllimport) 27 | #endif 28 | #elif __GNUC__ >= 4 29 | #define PTK_PUBLIC extern __attribute__((visibility("default"))) 30 | #else 31 | #define PTK_PUBLIC extern 32 | #endif 33 | #endif 34 | 35 | #if defined(_WIN32) && !defined(__cplusplus) 36 | #define PTK_INLINE __inline 37 | #else 38 | #define PTK_INLINE static inline 39 | #endif 40 | 41 | #ifdef _WIN32 42 | #define PTK_WIN32 43 | #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) 44 | #define PTK_UWP 45 | #else 46 | #define PTK_WIN_DESKTOP 47 | #endif 48 | #else 49 | #define PTK_LINUX 50 | #endif 51 | -------------------------------------------------------------------------------- /lib/ptk/include/ptk/ime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/include/ptk/ime.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef PTK_INCLUDE_PLATFORM_IME_H 13 | #define PTK_INCLUDE_PLATFORM_IME_H 14 | 15 | #include "types.h" 16 | #include "common.h" 17 | 18 | PTK_BEGIN_DECLS 19 | 20 | typedef struct ptk_ime_handler { 21 | bool (*prockey)(int, bool); 22 | void (*totext)(int); 23 | bool (*open)(void); 24 | bool (*close)(void); 25 | void (*setcaret)(int, int); 26 | } ptk_ime_handler_t; 27 | 28 | PTK_PUBLIC int ptk_ime_add(const char *ime_name, ptk_ime_handler_t *handler); 29 | 30 | /** 选定输入法 */ 31 | PTK_PUBLIC bool ptk_ime_select(int ptk_ime_id); 32 | 33 | PTK_PUBLIC bool ptk_ime_select_by_name(const char *name); 34 | 35 | /** 检测键值是否为字符键值 */ 36 | PTK_PUBLIC bool ptk_ime_check_char_key(int key); 37 | 38 | /** 切换至下一个输入法 */ 39 | PTK_PUBLIC void ptk_ime_switch(void); 40 | 41 | /** 检测输入法是否要处理按键事件 */ 42 | PTK_PUBLIC bool ptk_ime_process_key(ptk_event_t *e); 43 | 44 | /** 提交输入法输入的内容至目标 */ 45 | PTK_PUBLIC int ptk_ime_commit(const wchar_t *str, size_t len); 46 | 47 | PTK_PUBLIC void ptk_ime_set_caret(int x, int y); 48 | 49 | PTK_END_DECLS 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /lib/ptk/include/ptk/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/include/ptk/main.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifdef _WIN32 13 | #include "win32_main.h" 14 | #endif 15 | -------------------------------------------------------------------------------- /lib/ptk/include/ptk/win32_main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/include/ptk/win32_main.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIBPLATFORM_INCLUDE_PLATFORM_MAIN_H 13 | #define LIBPLATFORM_INCLUDE_PLATFORM_MAIN_H 14 | 15 | #include 16 | #include 17 | 18 | #ifdef PTK_WIN_DESKTOP 19 | #include 20 | #include 21 | 22 | extern int main(int argc, char *argv[]); 23 | 24 | int APIENTRY WinMain(_In_ HINSTANCE hInstance, 25 | _In_opt_ HINSTANCE hPrevInstance, 26 | _In_ LPSTR lpCmdLine, 27 | _In_ int nCmdShow) 28 | { 29 | char *cmdline; 30 | int ret, argc = 0; 31 | char **argv = NULL; 32 | UNREFERENCED_PARAMETER(hPrevInstance); 33 | UNREFERENCED_PARAMETER(lpCmdLine); 34 | ptk_set_instance(hInstance); 35 | cmdline = GetCommandLineA(); 36 | argc = cmdsplit(cmdline, &argv); 37 | ret = main(argc, (char**)argv); 38 | while (argc-- > 0) { 39 | free(argv[argc]); 40 | } 41 | free(argv); 42 | return ret; 43 | } 44 | 45 | #endif 46 | #endif 47 | -------------------------------------------------------------------------------- /lib/ptk/src/app.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/src/app.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "ptk/app.h" 13 | #include "ptk/events.h" 14 | #include "ime.h" 15 | #include "events.h" 16 | #include "clipboard.h" 17 | 18 | int ptk_init(const wchar_t *name) 19 | { 20 | if (ptk_app_init(name) != 0) { 21 | return -1; 22 | } 23 | ptk_ime_init(); 24 | ptk_events_init(); 25 | ptk_clipboard_init(); 26 | return 0; 27 | } 28 | 29 | int ptk_run(void) 30 | { 31 | return ptk_process_native_events(PTK_PROCESS_EVENTS_UNTIL_QUIT); 32 | } 33 | 34 | void ptk_destroy(void) 35 | { 36 | ptk_clipboard_destroy(); 37 | ptk_events_destroy(); 38 | ptk_ime_destroy(); 39 | ptk_app_destroy(); 40 | } 41 | -------------------------------------------------------------------------------- /lib/ptk/src/clipboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/src/clipboard.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "ptk/clipboard.h" 13 | 14 | void ptk_clipboard_init(void); 15 | void ptk_clipboard_destroy(void); 16 | -------------------------------------------------------------------------------- /lib/ptk/src/config.h.in: -------------------------------------------------------------------------------- 1 | #define PTK_VERSION "${VERSION}" 2 | #define PTK_VERSION_MAJOR ${VERSION_MAJOR} 3 | #define PTK_VERSION_MINOR ${VERSION_MINOR} 4 | #define PTK_VERSION_ALTER ${VERSION_ALTER} 5 | ${define PTK_STATIC_BUILD} 6 | ${define PTK_HAS_LIBX11} 7 | -------------------------------------------------------------------------------- /lib/ptk/src/events.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/src/events.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "ptk/events.h" 13 | 14 | void ptk_events_init(void); 15 | void ptk_events_destroy(void); 16 | -------------------------------------------------------------------------------- /lib/ptk/src/ime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/src/ime.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "ptk/ime.h" 13 | 14 | int ptk_ime_add_win32(void); 15 | int ptk_ime_add_linux(void); 16 | void ptk_ime_destroy(void); 17 | void ptk_ime_init(void); 18 | -------------------------------------------------------------------------------- /lib/ptk/src/linux/fbapp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/src/linux/fbapp.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "ptk.h" 13 | 14 | void ptk_fbapp_driver_init(ptk_app_driver_t *driver); 15 | 16 | void ptk_fbwindow_driver_init(ptk_window_driver_t *driver); 17 | -------------------------------------------------------------------------------- /lib/ptk/src/linux/keyboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/src/linux/keyboard.h 3 | * 4 | * Copyright (c) 2024-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | int ptk_linux_keyboard_init(void); 13 | int ptk_linux_keyboard_destroy(void); 14 | -------------------------------------------------------------------------------- /lib/ptk/src/linux/mouse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/src/linux/mouse.h 3 | * 4 | * Copyright (c) 2024-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | int ptk_linux_mouse_init(void); 13 | int ptk_linux_mouse_destroy(void); 14 | 15 | -------------------------------------------------------------------------------- /lib/ptk/src/linux/uri.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/src/linux/uri.c: -- uri processing 3 | * 4 | * Copyright (c) 2018-2025, Liu chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include "ptk.h" 16 | 17 | #ifdef PTK_LINUX 18 | 19 | int ptk_open_uri(const char *uri) 20 | { 21 | char cmd[512] = { 0 }; 22 | snprintf(cmd, 511, "xdg-open %s", uri); 23 | return system(cmd); 24 | } 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /lib/ptk/src/linux/x11app.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/src/linux/x11app.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include "ptk/app.h" 14 | 15 | Display *ptk_x11_get_display(void); 16 | Window ptk_x11_get_main_window(void); 17 | 18 | void ptk_x11app_driver_init(ptk_app_driver_t *driver); 19 | void ptk_x11window_driver_init(ptk_window_driver_t *driver); 20 | -------------------------------------------------------------------------------- /lib/ptk/src/linux/x11clipboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/src/linux/x11clipboard.h 3 | * 4 | * Copyright (c) 2024-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "ptk/clipboard.h" 13 | 14 | int ptk_x11clipboard_request_text(ptk_clipboard_callback_t callback, void *arg); 15 | int ptk_x11clipboard_set_text(const wchar_t *text, size_t len); 16 | void ptk_x11clipboard_init(void); 17 | void ptk_x11clipboard_destroy(void); 18 | -------------------------------------------------------------------------------- /lib/ptk/src/windows/uri.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ptk/src/windows/uri.c: -- uri processing 3 | * 4 | * Copyright (c) 2018-2025, Liu chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include "ptk/app.h" 16 | 17 | #if defined(PTK_WIN32) && !defined(WINAPI_PARTITION_APP) 18 | #pragma warning(disable:4091) 19 | #include 20 | #include 21 | 22 | int ptk_open_uri(const char *uri) 23 | { 24 | ShellExecuteA(NULL, "open", uri, NULL, NULL, SW_SHOW); 25 | return 0; 26 | } 27 | 28 | #else 29 | 30 | int ptk_open_uri(const char *uri) 31 | { 32 | return -1; 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /lib/ptk/xmake.lua: -------------------------------------------------------------------------------- 1 | if is_plat("linux") then 2 | add_requires("libx11", {optional = true}) 3 | end 4 | 5 | option("enable-touch") 6 | set_showmenu(true) 7 | set_default(true) 8 | set_configvar("PTK_TOUCH_ENABLED", 1) 9 | 10 | target("libptk") 11 | set_version("0.1.0-a") 12 | set_kind("$(kind)") 13 | add_files("src/*.c") 14 | set_configdir("include/ptk") 15 | add_configfiles("src/config.h.in") 16 | add_deps("yutil", "pandagl") 17 | add_headerfiles("include/ptk.h", "include/(ptk/*.h)") 18 | if is_kind("static") then 19 | set_configvar("PTK_STATIC_BUILD", 1) 20 | elseif is_plat("windows") then 21 | add_defines("PTK_DLL_EXPORT") 22 | end 23 | if is_plat("windows") then 24 | add_options("enable-touch") 25 | add_files("src/windows/*.c") 26 | add_links("Shell32") 27 | else 28 | add_files("src/linux/*.c") 29 | add_packages("libx11") 30 | if has_package("libx11") then 31 | set_configvar("PTK_HAS_LIBX11", 1) 32 | end 33 | add_syslinks("pthread", "dl") 34 | end 35 | -------------------------------------------------------------------------------- /lib/router/.gitignore: -------------------------------------------------------------------------------- 1 | !config.h -------------------------------------------------------------------------------- /lib/router/include/router.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/router/include/router.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | -------------------------------------------------------------------------------- /lib/router/include/router/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/router/include/router/common.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "version.h" 13 | #ifdef __cplusplus 14 | #define LIBROUTER_BEGIN_DECLS extern "C" { 15 | #define LIBROUTER_END_DECLS } 16 | #else 17 | #define LIBROUTER_BEGIN_DECLS 18 | #define LIBROUTER_END_DECLS 19 | #endif 20 | 21 | #ifndef LIBROUTER_PUBLIC 22 | #if defined(_MSC_VER) && !defined(LIBROUTER_STATIC_BUILD) 23 | #ifdef LIBROUTER_DLL_EXPORT 24 | #define LIBROUTER_PUBLIC __declspec(dllexport) 25 | #else 26 | #define LIBROUTER_PUBLIC __declspec(dllimport) 27 | #endif 28 | #elif __GNUC__ >= 4 29 | #define LIBROUTER_PUBLIC extern __attribute__((visibility("default"))) 30 | #else 31 | #define LIBROUTER_PUBLIC extern 32 | #endif 33 | #endif 34 | -------------------------------------------------------------------------------- /lib/router/include/router/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/router/include/router/config.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_ROUTER_INCLUDE_ROUTER_CONFIG_H 13 | #define LIB_ROUTER_INCLUDE_ROUTER_CONFIG_H 14 | 15 | #include 16 | #include 17 | 18 | LIBROUTER_BEGIN_DECLS 19 | 20 | LIBROUTER_PUBLIC router_config_t *router_config_create(void); 21 | 22 | LIBROUTER_PUBLIC void router_config_destroy(router_config_t *config); 23 | 24 | LIBROUTER_PUBLIC void router_config_set_name(router_config_t *config, 25 | const char *name); 26 | 27 | LIBROUTER_PUBLIC void router_config_set_path(router_config_t *config, 28 | const char *path); 29 | 30 | LIBROUTER_PUBLIC void router_config_set_component(router_config_t *config, 31 | const char *name, 32 | const char *component); 33 | 34 | LIBROUTER_END_DECLS 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /lib/router/include/router/matcher.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/router/include/router/matcher.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_ROUTER_INCLUDE_ROUTER_MATCHER_H 13 | #define LIB_ROUTER_INCLUDE_ROUTER_MATCHER_H 14 | 15 | #include 16 | #include 17 | 18 | LIBROUTER_BEGIN_DECLS 19 | 20 | LIBROUTER_PUBLIC router_matcher_t *router_matcher_create(void); 21 | 22 | LIBROUTER_PUBLIC void router_matcher_destroy(router_matcher_t *matcher); 23 | 24 | LIBROUTER_PUBLIC router_route_t *router_matcher_match( 25 | router_matcher_t *matcher, const router_location_t *raw_location, 26 | const router_route_t *current_route); 27 | 28 | LIBROUTER_PUBLIC router_route_record_t *router_matcher_add_route_record( 29 | router_matcher_t *matcher, const router_config_t *config, 30 | const router_route_record_t *parent); 31 | 32 | LIBROUTER_END_DECLS 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /lib/router/include/router/route.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/router/include/router/route.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_ROUTER_INCLUDE_ROUTER_ROUTE_H 13 | #define LIB_ROUTER_INCLUDE_ROUTER_ROUTE_H 14 | 15 | #include 16 | #include 17 | 18 | LIBROUTER_BEGIN_DECLS 19 | 20 | LIBROUTER_PUBLIC router_route_t *router_route_create( 21 | const router_route_record_t *record, const router_location_t *location); 22 | 23 | LIBROUTER_PUBLIC void router_route_destroy(router_route_t *route); 24 | 25 | LIBROUTER_PUBLIC const router_route_record_t * 26 | router_route_get_matched_record(const router_route_t *route, size_t index); 27 | 28 | LIBROUTER_PUBLIC const char *router_route_get_full_path( 29 | const router_route_t *route); 30 | 31 | LIBROUTER_PUBLIC const char *router_route_get_path( 32 | const router_route_t *route); 33 | 34 | LIBROUTER_PUBLIC const char *router_route_get_hash( 35 | const router_route_t *route); 36 | 37 | LIBROUTER_PUBLIC const char *router_route_get_param( 38 | const router_route_t *route, const char *key); 39 | 40 | LIBROUTER_PUBLIC const char *router_route_get_query( 41 | const router_route_t *route, const char *key); 42 | 43 | LIBROUTER_END_DECLS 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /lib/router/include/router/route_record.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/router/include/router/route_record.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_ROUTER_INCLUDE_ROUTER_ROUTE_RECORD_H 13 | #define LIB_ROUTER_INCLUDE_ROUTER_ROUTE_RECORD_H 14 | 15 | #include 16 | #include 17 | 18 | LIBROUTER_BEGIN_DECLS 19 | 20 | LIBROUTER_PUBLIC router_route_record_t *router_route_record_create(void); 21 | 22 | LIBROUTER_PUBLIC void router_route_record_destroy( 23 | router_route_record_t *record); 24 | 25 | LIBROUTER_PUBLIC void router_route_record_set_path( 26 | router_route_record_t *record, const char *path); 27 | 28 | LIBROUTER_PUBLIC const char *router_route_record_get_component( 29 | const router_route_record_t *record, const char *key); 30 | 31 | LIBROUTER_END_DECLS 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /lib/router/include/router/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/router/include/router/types.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_ROUTER_INCLUDE_ROUTER_TYPES_H 13 | #define LIB_ROUTER_INCLUDE_ROUTER_TYPES_H 14 | 15 | #include 16 | #include 17 | 18 | typedef struct strmap strmap_t; 19 | 20 | typedef struct strmap_item { 21 | char *key; 22 | char *value; 23 | list_node_t node; 24 | } strmap_item_t; 25 | 26 | typedef struct strmap_iterator { 27 | size_t index; 28 | strmap_item_t *item, *next_item; 29 | } strmap_iterator_t; 30 | 31 | typedef list_t router_linkedlist_t; 32 | typedef list_node_t router_linkedlist_node_t; 33 | typedef struct router router_t; 34 | typedef struct router_location router_location_t; 35 | typedef struct router_config router_config_t; 36 | typedef struct router_route router_route_t; 37 | typedef struct router_route_record router_route_record_t; 38 | typedef struct router_history router_history_t; 39 | typedef struct router_watcher router_watcher_t; 40 | typedef struct router_matcher router_matcher_t; 41 | typedef struct router_resolved router_resolved_t; 42 | typedef void (*router_callback_t)(void *, const router_route_t *, 43 | const router_route_t *); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /lib/router/include/router/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/router/include/router/version.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #define LIBROUTER_VERSION "0.1.0-a" 13 | #define LIBROUTER_VERSION_MAJOR 0 14 | #define LIBROUTER_VERSION_MINOR 1 15 | #define LIBROUTER_VERSION_ALTER 0 16 | #define LIBROUTER_STATIC_BUILD 1 17 | -------------------------------------------------------------------------------- /lib/router/src/config.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/router/src/config.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "private.h" 13 | #include 14 | 15 | router_config_t *router_config_create(void) 16 | { 17 | router_config_t *config; 18 | 19 | config = malloc(sizeof(router_config_t)); 20 | config->components = strmap_create(); 21 | config->name = NULL; 22 | config->path = NULL; 23 | return config; 24 | } 25 | 26 | void router_config_destroy(router_config_t *config) 27 | { 28 | router_mem_free(config->name); 29 | router_mem_free(config->path); 30 | strmap_destroy(config->components); 31 | config->components = NULL; 32 | free(config); 33 | } 34 | 35 | void router_config_set_name(router_config_t *config, const char *name) 36 | { 37 | router_mem_free(config->name); 38 | if (name) { 39 | config->name = strdup(name); 40 | } 41 | } 42 | 43 | void router_config_set_path(router_config_t *config, const char *path) 44 | { 45 | router_mem_free(config->path); 46 | if (path) { 47 | config->path = strdup(path); 48 | } 49 | } 50 | 51 | void router_config_set_component(router_config_t *config, const char *name, 52 | const char *component) 53 | { 54 | if (!name) { 55 | name = "default"; 56 | } 57 | strmap_set(config->components, name, component); 58 | } 59 | -------------------------------------------------------------------------------- /lib/router/src/version.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/router/include/router/version.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #define LIBROUTER_VERSION "${VERSION}" 13 | #define LIBROUTER_VERSION_MAJOR ${VERSION_MAJOR} 14 | #define LIBROUTER_VERSION_MINOR ${VERSION_MINOR} 15 | #define LIBROUTER_VERSION_ALTER ${VERSION_ALTER} 16 | ${define LIBROUTER_STATIC_BUILD} 17 | -------------------------------------------------------------------------------- /lib/thread/xmake.lua: -------------------------------------------------------------------------------- 1 | set_version("0.1.0-a") 2 | 3 | target("libthread") 4 | set_kind("$(kind)") 5 | add_files("src/*.c") 6 | set_configdir("include") 7 | add_configfiles("src/thread.h.in") 8 | add_headerfiles("include/thread.h") 9 | if not is_plat("windows") then 10 | add_syslinks("pthread", "dl") 11 | end 12 | add_deps("yutil") 13 | if is_kind("static") then 14 | set_configvar("LIBTHREAD_STATIC_BUILD", 1) 15 | elseif is_plat("windows") then 16 | add_defines("LIBTHREAD_DLL_EXPORT") 17 | end 18 | -------------------------------------------------------------------------------- /lib/ui-cursor/include/ui_cursor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui-cursor/include/ui_cursor.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_UI_CURSOR_INCLUDE_UI_CURSOR_H 13 | #define LIB_UI_CURSOR_INCLUDE_UI_CURSOR_H 14 | 15 | #include "ui_cursor/common.h" 16 | #include 17 | #include 18 | #include 19 | 20 | LIBUI_CURSOR_BEGIN_DECLS 21 | 22 | LIBUI_CURSOR_PUBLIC void ui_cursor_refresh(void); 23 | LIBUI_CURSOR_PUBLIC bool ui_cursor_is_visible(void); 24 | LIBUI_CURSOR_PUBLIC void ui_cursor_show(void); 25 | LIBUI_CURSOR_PUBLIC void ui_cursor_hide(void); 26 | LIBUI_CURSOR_PUBLIC void ui_cursor_set_position(int x, int y); 27 | LIBUI_CURSOR_PUBLIC int ui_cursor_set_image(pd_canvas_t *image); 28 | LIBUI_CURSOR_PUBLIC void ui_cursor_get_position(int *x, int *y); 29 | LIBUI_CURSOR_PUBLIC int ui_cursor_paint(ptk_window_t *w, ptk_window_paint_t* paint); 30 | LIBUI_CURSOR_PUBLIC void ui_cursor_init(void); 31 | LIBUI_CURSOR_PUBLIC void ui_cursor_destroy(void); 32 | 33 | LIBUI_CURSOR_END_DECLS 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /lib/ui-cursor/include/ui_cursor/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui-cursor/include/ui_cursor/common.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "config.h" 13 | #ifdef __cplusplus 14 | #define LIBUI_CURSOR_BEGIN_DECLS extern "C" { 15 | #define LIBUI_CURSOR_END_DECLS } 16 | #else 17 | #define LIBUI_CURSOR_BEGIN_DECLS 18 | #define LIBUI_CURSOR_END_DECLS 19 | #endif 20 | 21 | #ifndef LIBUI_CURSOR_PUBLIC 22 | #if defined(_MSC_VER) && !defined(LIBUI_CURSOR_STATIC_BUILD) 23 | #ifdef LIBUI_CURSOR_DLL_EXPORT 24 | #define LIBUI_CURSOR_PUBLIC __declspec(dllexport) 25 | #else 26 | #define LIBUI_CURSOR_PUBLIC __declspec(dllimport) 27 | #endif 28 | #elif __GNUC__ >= 4 29 | #define LIBUI_CURSOR_PUBLIC extern __attribute__((visibility("default"))) 30 | #else 31 | #define LIBUI_CURSOR_PUBLIC extern 32 | #endif 33 | #endif 34 | -------------------------------------------------------------------------------- /lib/ui-cursor/src/config.h.in: -------------------------------------------------------------------------------- 1 | #define LIBUI_CURSOR_VERSION "${VERSION}" 2 | #define LIBUI_CURSOR_VERSION_MAJOR ${VERSION_MAJOR} 3 | #define LIBUI_CURSOR_VERSION_MINOR ${VERSION_MINOR} 4 | #define LIBUI_CURSOR_VERSION_ALTER ${VERSION_ALTER} 5 | ${define LIBUI_CURSOR_STATIC_BUILD} 6 | -------------------------------------------------------------------------------- /lib/ui-cursor/xmake.lua: -------------------------------------------------------------------------------- 1 | set_project("libui-cursor") 2 | set_version("0.1.0-a") 3 | 4 | target("libui-cursor") 5 | set_kind("$(kind)") 6 | add_files("src/**.c") 7 | add_deps("yutil", "pandagl", "libptk") 8 | set_configdir("include/ui_cursor") 9 | add_configfiles("src/config.h.in") 10 | add_headerfiles("include/ui_cursor.h", "include/(ui_cursor/*.h)") 11 | if is_kind("static") then 12 | set_configvar("LIBUI_CURSOR_STATIC_BUILD", 1) 13 | elseif is_plat("windows") then 14 | add_defines("LIBUI_CURSOR_DLL_EXPORT") 15 | end 16 | -------------------------------------------------------------------------------- /lib/ui-server/include/ui_server.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui-server/include/ui_server.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_UI_SERVER_INCLUDE_UI_SERVER_H 13 | #define LIB_UI_SERVER_INCLUDE_UI_SERVER_H 14 | 15 | #include "ui_server/common.h" 16 | #include 17 | #include 18 | 19 | LIBUI_SERVER_BEGIN_DECLS 20 | 21 | LIBUI_SERVER_PUBLIC ui_widget_t *ui_server_get_widget(ptk_window_t *window); 22 | LIBUI_SERVER_PUBLIC ptk_window_t *ui_server_get_window(ui_widget_t *widget); 23 | LIBUI_SERVER_PUBLIC float ui_server_get_window_scale(ptk_window_t *window); 24 | LIBUI_SERVER_PUBLIC int ui_server_disconnect(ui_widget_t *widget, ptk_window_t *window); 25 | LIBUI_SERVER_PUBLIC void ui_server_connect(ui_widget_t *widget, ptk_window_t *window); 26 | LIBUI_SERVER_PUBLIC size_t ui_server_render(void); 27 | LIBUI_SERVER_PUBLIC void ui_server_present(void); 28 | LIBUI_SERVER_PUBLIC void ui_server_update(void); 29 | LIBUI_SERVER_PUBLIC void ui_server_init(void); 30 | LIBUI_SERVER_PUBLIC void ui_server_set_threads(int threads); 31 | LIBUI_SERVER_PUBLIC void ui_server_set_paint_flashing_enabled(bool enabled); 32 | LIBUI_SERVER_PUBLIC void ui_server_destroy(void); 33 | 34 | LIBUI_SERVER_END_DECLS 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /lib/ui-server/include/ui_server/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui-server/include/ui_server/common.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "config.h" 13 | #ifdef __cplusplus 14 | #define LIBUI_SERVER_BEGIN_DECLS extern "C" { 15 | #define LIBUI_SERVER_END_DECLS } 16 | #else 17 | #define LIBUI_SERVER_BEGIN_DECLS 18 | #define LIBUI_SERVER_END_DECLS 19 | #endif 20 | 21 | #ifndef LIBUI_SERVER_PUBLIC 22 | #if defined(_MSC_VER) && !defined(LIBUI_SERVER_STATIC_BUILD) 23 | #ifdef LIBUI_SERVER_DLL_EXPORT 24 | #define LIBUI_SERVER_PUBLIC __declspec(dllexport) 25 | #else 26 | #define LIBUI_SERVER_PUBLIC __declspec(dllimport) 27 | #endif 28 | #elif __GNUC__ >= 4 29 | #define LIBUI_SERVER_PUBLIC extern __attribute__((visibility("default"))) 30 | #else 31 | #define LIBUI_SERVER_PUBLIC extern 32 | #endif 33 | #endif 34 | -------------------------------------------------------------------------------- /lib/ui-server/src/config.h.in: -------------------------------------------------------------------------------- 1 | #define LIBUI_SERVER_VERSION "${VERSION}" 2 | #define LIBUI_SERVER_VERSION_MAJOR ${VERSION_MAJOR} 3 | #define LIBUI_SERVER_VERSION_MINOR ${VERSION_MINOR} 4 | #define LIBUI_SERVER_VERSION_ALTER ${VERSION_ALTER} 5 | ${define LIBUI_SERVER_STATIC_BUILD} 6 | ${define LIBUI_SERVER_HAS_OPENMP} 7 | -------------------------------------------------------------------------------- /lib/ui-server/xmake.lua: -------------------------------------------------------------------------------- 1 | set_project("libui-server") 2 | set_version("0.1.0-a") 3 | add_requires("libomp", {optional = true}) 4 | 5 | option("with-openmp", {showmenu = true, default = true}) 6 | 7 | target("libui-server") 8 | set_kind("$(kind)") 9 | add_files("src/**.c") 10 | add_packages("libomp") 11 | add_options("with-openmp") 12 | add_deps("yutil", "pandagl", "libptk", "libui", "libui-cursor") 13 | set_configdir("include/ui_server") 14 | add_configfiles("src/config.h.in") 15 | add_headerfiles("include/ui_server.h", "include/(ui_server/*.h)") 16 | if is_kind("static") then 17 | set_configvar("LIBUI_SERVER_STATIC_BUILD", 1) 18 | elseif is_plat("windows") then 19 | add_defines("LIBUI_SERVER_DLL_EXPORT") 20 | end 21 | if has_package("libomp") and has_config("with-openmp") then 22 | set_configvar("LIBUI_SERVER_HAS_OPENMP", 1) 23 | end 24 | -------------------------------------------------------------------------------- /lib/ui-xml/include/ui_xml.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui-xml/include/ui_xml.h: -- The GUI build module, parse UI config code and build UI. 3 | * 4 | * Copyright (c) 2018-2025, Liu chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_UI_XML_INCLUDE_XML_H 13 | #define LIB_UI_XML_INCLUDE_XML_H 14 | 15 | #include "ui_xml/common.h" 16 | #include 17 | 18 | LIBUI_XML_BEGIN_DECLS 19 | 20 | /** 21 | * 从字符串中载入界面配置代码,解析并生成相应的图形界面(元素) 22 | * @param[in] str 包含界面配置代码的字符串 23 | * @return 正常解析会返回一个部件,出现错误则返回 NULL 24 | */ 25 | LIBUI_XML_PUBLIC ui_widget_t* ui_load_xml_string(const char *str, int size); 26 | 27 | /** 28 | * 从文件中载入界面配置代码,解析并生成相应的图形界面(元素) 29 | * @param[in] filepath 文件路径 30 | * @return 正常解析会返回一个部件,出现错误则返回 NULL 31 | */ 32 | LIBUI_XML_PUBLIC ui_widget_t* ui_load_xml_file(const char *filepath); 33 | 34 | LIBUI_XML_END_DECLS 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /lib/ui-xml/include/ui_xml/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui-xml/include/ui_xml/common.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "config.h" 13 | #ifdef __cplusplus 14 | #define LIBUI_XML_BEGIN_DECLS extern "C" { 15 | #define LIBUI_XML_END_DECLS } 16 | #else 17 | #define LIBUI_XML_BEGIN_DECLS 18 | #define LIBUI_XML_END_DECLS 19 | #endif 20 | 21 | #ifndef LIBUI_XML_PUBLIC 22 | #if defined(_MSC_VER) && !defined(LIBUI_XML_STATIC_BUILD) 23 | #ifdef LIBUI_XML_DLL_EXPORT 24 | #define LIBUI_XML_PUBLIC __declspec(dllexport) 25 | #else 26 | #define LIBUI_XML_PUBLIC __declspec(dllimport) 27 | #endif 28 | #elif __GNUC__ >= 4 29 | #define LIBUI_XML_PUBLIC extern __attribute__((visibility("default"))) 30 | #else 31 | #define LIBUI_XML_PUBLIC extern 32 | #endif 33 | #endif 34 | -------------------------------------------------------------------------------- /lib/ui-xml/src/config.h.in: -------------------------------------------------------------------------------- 1 | #define LIBUI_XML_VERSION "${VERSION}" 2 | #define LIBUI_XML_VERSION_MAJOR ${VERSION_MAJOR} 3 | #define LIBUI_XML_VERSION_MINOR ${VERSION_MINOR} 4 | #define LIBUI_XML_VERSION_ALTER ${VERSION_ALTER} 5 | ${define LIBUI_XML_STATIC_BUILD} 6 | ${define LIBUI_XML_HAS_LIBXML2} 7 | -------------------------------------------------------------------------------- /lib/ui-xml/xmake.lua: -------------------------------------------------------------------------------- 1 | set_project("libui-xml") 2 | set_version("0.1.0-a") 3 | add_requires("libxml2", {optional = true}) 4 | 5 | target("libui-xml") 6 | add_packages("libxml2") 7 | if has_package("libxml2") then 8 | set_configvar("LIBUI_XML_HAS_LIBXML2", 1) 9 | end 10 | set_kind("$(kind)") 11 | add_files("src/**.c") 12 | add_deps("yutil", "libui", "libcss", "pandagl") 13 | set_configdir("include/ui_xml") 14 | add_configfiles("src/config.h.in") 15 | add_headerfiles("include/ui_xml.h", "include/(ui_xml/*.h)") 16 | if is_kind("static") then 17 | set_configvar("LIBUI_XML_STATIC_BUILD", 1) 18 | elseif is_plat("windows") then 19 | add_defines("LIBUI_XML_DLL_EXPORT") 20 | end 21 | -------------------------------------------------------------------------------- /lib/ui/include/ui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/include/ui.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_UI_INCLUDE_UI_H 13 | #define LIB_UI_INCLUDE_UI_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /lib/ui/include/ui/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/include/ui/common.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_UI_INCLUDE_UI_COMMON_H 13 | #define LIB_UI_INCLUDE_UI_COMMON_H 14 | 15 | #include "config.h" 16 | 17 | #ifdef __cplusplus 18 | #define LIBUI_BEGIN_DECLS extern "C" { 19 | #define LIBUI_END_DECLS } 20 | #else 21 | #define LIBUI_BEGIN_DECLS 22 | #define LIBUI_END_DECLS 23 | #endif 24 | 25 | #ifndef LIBUI_PUBLIC 26 | #if defined(_MSC_VER) && !defined(LIBUI_STATIC_BUILD) 27 | #ifdef LIBUI_DLL_EXPORT 28 | #define LIBUI_PUBLIC __declspec(dllexport) 29 | #else 30 | #define LIBUI_PUBLIC __declspec(dllimport) 31 | #endif 32 | #elif __GNUC__ >= 4 33 | #define LIBUI_PUBLIC extern __attribute__((visibility("default"))) 34 | #else 35 | #define LIBUI_PUBLIC extern 36 | #endif 37 | #endif 38 | 39 | #if defined(_WIN32) && !defined(__cplusplus) 40 | #define LIBUI_INLINE __inline 41 | #else 42 | #define LIBUI_INLINE static inline 43 | #endif 44 | 45 | #ifdef DEBUG 46 | #define DEBUG_MSG _DEBUG_MSG 47 | #else 48 | #define DEBUG_MSG(format, ...) 49 | #endif 50 | 51 | #define _DEBUG_MSG(format, ...) \ 52 | logger_log(LOGGER_LEVEL_DEBUG, __FILE__ ":%d: %s(): " format, \ 53 | __LINE__, __FUNCTION__, ##__VA_ARGS__) 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /lib/ui/include/ui/css.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/include/ui/css.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_UI_INCLUDE_UI_CSS_H 13 | #define LIB_UI_INCLUDE_UI_CSS_H 14 | 15 | #include "common.h" 16 | 17 | LIBUI_END_DECLS 18 | 19 | LIBUI_PUBLIC int ui_load_css_file(const char *filepath); 20 | LIBUI_PUBLIC size_t ui_load_css_string(const char *str, const char *space); 21 | 22 | LIBUI_END_DECLS 23 | #endif 24 | -------------------------------------------------------------------------------- /lib/ui/include/ui/hash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/include/ui/hash.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_UI_INCLUDE_UI_HASH_H 13 | #define LIB_UI_INCLUDE_UI_HASH_H 14 | 15 | #include "common.h" 16 | #include "types.h" 17 | 18 | LIBUI_BEGIN_DECLS 19 | 20 | LIBUI_PUBLIC void ui_widget_generate_self_hash(ui_widget_t *widget); 21 | LIBUI_PUBLIC void ui_widget_generate_hash(ui_widget_t *w); 22 | LIBUI_PUBLIC size_t ui_widget_export_hash(ui_widget_t *w, unsigned *hash_list, 23 | size_t len); 24 | LIBUI_PUBLIC size_t ui_widget_import_hash(ui_widget_t *w, unsigned *hash_list, 25 | size_t maxlen); 26 | 27 | LIBUI_END_DECLS 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /lib/ui/include/ui/logger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/include/ui/logger.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_UI_INCLUDE_UI_LOGGER_H 13 | #define LIB_UI_INCLUDE_UI_LOGGER_H 14 | 15 | #include "common.h" 16 | #include "types.h" 17 | 18 | LIBUI_BEGIN_DECLS 19 | 20 | LIBUI_PUBLIC int ui_logger_log(logger_level_e level, ui_widget_t *w, 21 | const char *fmt, ...); 22 | 23 | #define ui_debug(W, ...) ui_logger_log(LOGGER_LEVEL_DEBUG, W, ##__VA_ARGS__) 24 | 25 | LIBUI_END_DECLS 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /lib/ui/include/ui/prototype.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/include/ui/prototype.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_UI_INCLUDE_UI_PROTOTYPE_H 13 | #define LIB_UI_INCLUDE_UI_PROTOTYPE_H 14 | 15 | #include "common.h" 16 | #include "types.h" 17 | 18 | #define UI_WDIGET_ADD_DATA(WIDGET, PROTO_NAME) \ 19 | ui_widget_add_data(WIDGET, PROTO_NAME##_proto, sizeof(PROTO_NAME##_t)) 20 | 21 | LIBUI_BEGIN_DECLS 22 | 23 | LIBUI_PUBLIC ui_widget_prototype_t *ui_create_widget_prototype( 24 | const char *name, const char *parent_name); 25 | LIBUI_PUBLIC ui_widget_prototype_t *ui_get_widget_prototype(const char *name); 26 | LIBUI_PUBLIC bool ui_check_widget_type(ui_widget_t *w, const char *type); 27 | LIBUI_PUBLIC bool ui_check_widget_prototype(ui_widget_t *w, 28 | const ui_widget_prototype_t *proto); 29 | LIBUI_PUBLIC void *ui_widget_get_data(ui_widget_t *widget, 30 | ui_widget_prototype_t *proto); 31 | LIBUI_PUBLIC void *ui_widget_add_data(ui_widget_t *widget, 32 | ui_widget_prototype_t *proto, 33 | size_t data_size); 34 | 35 | LIBUI_END_DECLS 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /lib/ui/include/ui/text_style.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/include/ui/text_style.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_UI_INCLUDE_UI_TEXT_STYLE_H 13 | #define LIB_UI_INCLUDE_UI_TEXT_STYLE_H 14 | 15 | #include "common.h" 16 | #include "types.h" 17 | 18 | #include 19 | 20 | LIBUI_BEGIN_DECLS 21 | 22 | #define UI_DEFAULT_FONT_SIZE 14 23 | #define UI_DEFAULT_FONT_COLOR 0xff333333 24 | #define UI_MIN_FONT_SIZE 12 25 | #define UI_LINE_HEIGHT_SCALE 1.42857143 26 | 27 | typedef struct ui_text_style { 28 | int font_size; 29 | int line_height; 30 | int *font_ids; 31 | wchar_t *content; 32 | pd_color_t color; 33 | uint8_t font_style; 34 | uint8_t font_weight; 35 | uint8_t text_align; 36 | uint8_t white_space; 37 | uint8_t word_break; 38 | } ui_text_style_t; 39 | 40 | LIBUI_PUBLIC void ui_text_style_init(ui_text_style_t *fs); 41 | 42 | LIBUI_PUBLIC void ui_text_style_destroy(ui_text_style_t *fs); 43 | 44 | LIBUI_PUBLIC bool ui_text_style_is_equal(const ui_text_style_t *a, 45 | const ui_text_style_t *b); 46 | 47 | LIBUI_PUBLIC void ui_compute_text_style(ui_text_style_t *fs, 48 | const css_computed_style_t *ss); 49 | 50 | LIBUI_END_DECLS 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /lib/ui/include/ui/updater.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/include/ui/updater.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_UI_INCLUDE_UI_UPDATER_H 13 | #define LIB_UI_INCLUDE_UI_UPDATER_H 14 | 15 | #include "common.h" 16 | #include "types.h" 17 | 18 | #include 19 | 20 | LIBUI_BEGIN_DECLS 21 | 22 | typedef struct ui_updater { 23 | list_node_t node; 24 | ui_metrics_t metrics; 25 | bool refresh_all; 26 | } ui_updater_t; 27 | 28 | ui_updater_t *ui_updater_create(void); 29 | void ui_updater_destroy(ui_updater_t *updater); 30 | void ui_updater_update(ui_updater_t *updater, ui_widget_t *root); 31 | size_t ui_updater_update_widget(ui_updater_t *updater, ui_widget_t *w); 32 | 33 | LIBUI_END_DECLS 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /lib/ui/src/config.h.in: -------------------------------------------------------------------------------- 1 | #define LIBUI_VERSION "${VERSION}" 2 | #define LIBUI_VERSION_MAJOR ${VERSION_MAJOR} 3 | #define LIBUI_VERSION_MINOR ${VERSION_MINOR} 4 | #define LIBUI_VERSION_ALTER ${VERSION_ALTER} 5 | ${define LIBUI_STATIC_BUILD} 6 | -------------------------------------------------------------------------------- /lib/ui/src/ui.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include "ui/base.h" 15 | #include "ui_root.h" 16 | #include "ui_events.h" 17 | #include "ui_image.h" 18 | #include "ui_widget_id.h" 19 | #include "ui_widget_prototype.h" 20 | #include "ui_css.h" 21 | #include "ui_updater.h" 22 | 23 | void ui_init(void) 24 | { 25 | pd_font_library_init(); 26 | ui_init_widget_id(); 27 | ui_init_widget_prototype(); 28 | ui_init_updater(); 29 | ui_init_root(); 30 | ui_init_events(); 31 | ui_init_css(); 32 | ui_init_image_loader(); 33 | } 34 | 35 | void ui_destroy(void) 36 | { 37 | pd_font_library_destroy(); 38 | ui_clear_trash(); 39 | ui_destroy_root(); 40 | ui_destroy_events(); 41 | ui_destroy_image_loader(); 42 | ui_destroy_widget_id(); 43 | ui_destroy_widget_prototype(); 44 | ui_destroy_css(); 45 | ui_destroy_updater(); 46 | } 47 | -------------------------------------------------------------------------------- /lib/ui/src/ui_block_layout.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_block_layout.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_block_layout_reflow(ui_widget_t *w, ui_resizer_t *resizer); 13 | 14 | -------------------------------------------------------------------------------- /lib/ui/src/ui_css.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_css.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_init_css(void); 13 | void ui_destroy_css(void); 14 | -------------------------------------------------------------------------------- /lib/ui/src/ui_debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_debug.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_widget_to_string(ui_widget_t *w, char *str); 13 | void ui_widget_size_to_string(ui_widget_t *w, char str[40]); 14 | void ui_widget_min_size_to_string(ui_widget_t *w, char str[40]); 15 | 16 | #define UI_WIDGET_STR(W, STR) \ 17 | char STR[256]; \ 18 | ui_widget_to_string(W, STR); 19 | 20 | #define UI_WIDGET_SIZE_STR(W, STR) \ 21 | char STR[32]; \ 22 | ui_widget_size_to_string(W, STR); 23 | 24 | #define UI_WIDGET_MIN_SIZE_STR(W, STR) \ 25 | char STR[32]; \ 26 | ui_widget_min_size_to_string(W, STR); 27 | 28 | #ifdef UI_DEBUG_ENABLED 29 | extern int ui_debug_msg_indent; 30 | 31 | #define UI_DEBUG_MSG(FMT, ...) \ 32 | logger_log(LOGGER_LEVEL_DEBUG, "%*s" FMT "\n", ui_debug_msg_indent * 4, \ 33 | "", ##__VA_ARGS__) 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /lib/ui/src/ui_diff.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_diff.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | typedef struct ui_diff_item { 13 | ui_widget_t *widget; 14 | ui_rect_t border_box; 15 | ui_rect_t canvas_box; 16 | bool visible; 17 | bool should_add_dirty_rect; 18 | } ui_diff_item_t; 19 | 20 | /** for check widget difference */ 21 | typedef struct ui_widget_style_diff_t_ { 22 | css_computed_style_t style; 23 | ui_rect_t padding_box; 24 | ui_rect_t canvas_box; 25 | bool visible; 26 | bool should_add_dirty_rect; 27 | } ui_style_diff_t; 28 | 29 | void ui_style_diff_init(ui_style_diff_t *diff, ui_widget_t *w); 30 | void ui_style_diff_begin(ui_style_diff_t *diff, ui_widget_t *w); 31 | void ui_style_diff_end(ui_style_diff_t *diff, ui_widget_t *w); 32 | -------------------------------------------------------------------------------- /lib/ui/src/ui_events.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_events.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_widget_destroy_listeners(ui_widget_t *w); 13 | 14 | /** 初始化 LCUI 部件的事件系统 */ 15 | void ui_init_events(void); 16 | 17 | /** 销毁(释放) LCUI 部件的事件系统的相关资源 */ 18 | void ui_destroy_events(void); 19 | -------------------------------------------------------------------------------- /lib/ui/src/ui_flexbox_layout.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_flexbox_layout.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_flexbox_layout_reflow(ui_widget_t *w, ui_resizer_t *resizer); 13 | -------------------------------------------------------------------------------- /lib/ui/src/ui_image.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_image.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_init_image_loader(void); 13 | void ui_destroy_image_loader(void); 14 | -------------------------------------------------------------------------------- /lib/ui/src/ui_logger.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_logger.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #define LOG_BUFFER_SIZE 1024 19 | #define WIDGET_STR_SIZE 256 20 | 21 | int ui_logger_log(logger_level_e level, ui_widget_t *w, const char *fmt, ...) 22 | { 23 | va_list args; 24 | css_selector_node_t *node; 25 | char buffer[LOG_BUFFER_SIZE]; 26 | 27 | va_start(args, fmt); 28 | vsnprintf(buffer, LOG_BUFFER_SIZE, fmt, args); 29 | va_end(args); 30 | if (w) { 31 | node = ui_widget_create_selector_node(w); 32 | strreplace(buffer, LOG_BUFFER_SIZE, "${widget}", node->fullname); 33 | css_selector_node_destroy(node); 34 | } else { 35 | strreplace(buffer, LOG_BUFFER_SIZE, "${widget}", "(null)"); 36 | } 37 | return logger_log(level, buffer); 38 | } 39 | -------------------------------------------------------------------------------- /lib/ui/src/ui_mutation_observer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_mutation_observer.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | typedef struct ui_mutation_connection { 13 | ui_widget_t *widget; 14 | ui_mutation_observer_t *observer; 15 | ui_mutation_observer_init_t options; 16 | list_node_t node; 17 | } ui_mutation_connection_t; 18 | -------------------------------------------------------------------------------- /lib/ui/src/ui_root.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_root.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include "ui_root.h" 14 | 15 | static ui_widget_t *ui_root_widget; 16 | 17 | ui_widget_t *ui_root(void) 18 | { 19 | return ui_root_widget; 20 | } 21 | 22 | int ui_root_append(ui_widget_t *w) 23 | { 24 | return ui_widget_append(ui_root_widget, w); 25 | } 26 | 27 | void ui_init_root(void) 28 | { 29 | ui_root_widget = ui_create_widget("root"); 30 | ui_widget_set_title(ui_root_widget, L"LCUI Display"); 31 | } 32 | 33 | void ui_destroy_root(void) 34 | { 35 | ui_widget_destroy(ui_root_widget); 36 | } 37 | -------------------------------------------------------------------------------- /lib/ui/src/ui_root.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_root.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_init_root(void); 13 | void ui_destroy_root(void); 14 | -------------------------------------------------------------------------------- /lib/ui/src/ui_updater.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_updater.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_init_updater(void); 13 | void ui_destroy_updater(void); 14 | -------------------------------------------------------------------------------- /lib/ui/src/ui_widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_widget.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_widget_add_state(ui_widget_t *w, ui_widget_state_t state); 13 | 14 | void ui_widget_set_content_width(ui_widget_t *w, float width); 15 | 16 | void ui_widget_set_content_height(ui_widget_t *w, float height); 17 | 18 | void ui_widget_update_box_position(ui_widget_t *w); 19 | 20 | void ui_widget_update_box_size(ui_widget_t *w); 21 | void ui_widget_update_box_width(ui_widget_t *w); 22 | void ui_widget_update_box_height(ui_widget_t *w); 23 | -------------------------------------------------------------------------------- /lib/ui/src/ui_widget_attributes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_widget_attributes.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_widget_destroy_attrs(ui_widget_t *w); 13 | -------------------------------------------------------------------------------- /lib/ui/src/ui_widget_background.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_widget_background.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_widget_paint_background(ui_widget_t *w, pd_context_t *paint, 13 | ui_widget_actual_style_t *style); 14 | -------------------------------------------------------------------------------- /lib/ui/src/ui_widget_border.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_widget_border.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_widget_paint_border(ui_widget_t *w, pd_context_t *paint, 13 | ui_widget_actual_style_t *style); 14 | void ui_widget_crop_content(ui_widget_t *w, pd_context_t *paint, 15 | ui_widget_actual_style_t *style); 16 | -------------------------------------------------------------------------------- /lib/ui/src/ui_widget_box_shadow.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_widget_box_shadow.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include "ui_widget_box_shadow.h" 16 | 17 | void ui_widget_paint_box_shadow(ui_widget_t* w, pd_context_t* ctx, 18 | ui_widget_actual_style_t* style) 19 | { 20 | pd_rect_t box; 21 | pd_boxshadow_t bs; 22 | css_computed_style_t* s = &w->computed_style; 23 | 24 | if (s->type_bits.box_shadow == CSS_BOX_SHADOW_NONE || 25 | s->box_shadow_color < 1) { 26 | return; 27 | } 28 | bs.x = ui_compute(s->box_shadow_x); 29 | bs.y = ui_compute(s->box_shadow_y); 30 | bs.blur = ui_compute(s->box_shadow_blur); 31 | bs.spread = ui_compute(s->box_shadow_spread); 32 | bs.color.value = s->box_shadow_color; 33 | bs.top_left_radius = ui_compute(s->border_top_left_radius); 34 | bs.top_right_radius = ui_compute(s->border_top_right_radius); 35 | bs.bottom_left_radius = ui_compute(s->border_bottom_left_radius); 36 | bs.bottom_right_radius = ui_compute(s->border_bottom_right_radius); 37 | box.x = box.y = 0; 38 | box.width = style->canvas_box.width; 39 | box.height = style->canvas_box.height; 40 | pd_paint_boxshadow(ctx, &bs, &box, style->border_box.width, 41 | style->border_box.height); 42 | } 43 | -------------------------------------------------------------------------------- /lib/ui/src/ui_widget_box_shadow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_widget_box_shadow.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_widget_paint_box_shadow(ui_widget_t *w, pd_context_t *paint, 13 | ui_widget_actual_style_t *style); 14 | -------------------------------------------------------------------------------- /lib/ui/src/ui_widget_classes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_widget_classes.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_widget_destroy_classes(ui_widget_t *w); 13 | -------------------------------------------------------------------------------- /lib/ui/src/ui_widget_id.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_widget_id.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | int ui_widget_destroy_id(ui_widget_t *w); 13 | void ui_init_widget_id(void); 14 | void ui_destroy_widget_id(void); 15 | -------------------------------------------------------------------------------- /lib/ui/src/ui_widget_layout.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_widget_layout.h 3 | * 4 | * Copyright (c) 2024-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_widget_reflow_with_resizer(ui_widget_t *w, ui_resizer_t *resizer); 13 | -------------------------------------------------------------------------------- /lib/ui/src/ui_widget_observer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_widget_observer.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | bool ui_widget_has_observer(ui_widget_t *widget, 13 | ui_mutation_record_type_t type); 14 | 15 | int ui_widget_add_mutation_record(ui_widget_t *widget, 16 | ui_mutation_record_t *record); 17 | -------------------------------------------------------------------------------- /lib/ui/src/ui_widget_prototype.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_widget_prototype.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_init_widget_prototype(void); 13 | void ui_destroy_widget_prototype(void); 14 | void ui_widget_destroy_prototype(ui_widget_t *widget); 15 | -------------------------------------------------------------------------------- /lib/ui/src/ui_widget_status.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/ui/src/ui_widget_status.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void ui_widget_destroy_status(ui_widget_t *w); 13 | -------------------------------------------------------------------------------- /lib/ui/xmake.lua: -------------------------------------------------------------------------------- 1 | set_project("libui") 2 | set_version("0.1.0-a") 3 | 4 | target("libui") 5 | set_kind("$(kind)") 6 | add_files("src/**.c") 7 | add_deps("yutil", "pandagl", "libcss") 8 | set_configdir("include/ui") 9 | add_configfiles("src/config.h.in") 10 | add_headerfiles("include/ui.h", "include/(ui/*.h)") 11 | if is_kind("static") then 12 | set_configvar("LIBUI_STATIC_BUILD", 1) 13 | elseif is_plat("windows") then 14 | add_defines("LIBUI_DLL_EXPORT") 15 | end 16 | -------------------------------------------------------------------------------- /lib/worker/include/worker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/worker/include/worker.h: -- worker threading and task 3 | * 4 | * Copyright (c) 2018-2025, Liu chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #ifndef LIB_WORKER_INCLULDE_WORKER_H 13 | #define LIB_WORKER_INCLULDE_WORKER_H 14 | 15 | #include 16 | #include "worker/common.h" 17 | 18 | LIBWORKER_BEGIN_DECLS 19 | 20 | typedef void (*worker_task_cb)(void *); 21 | typedef struct worker worker_t; 22 | typedef struct worker_task worker_task_t; 23 | 24 | LIBWORKER_PUBLIC worker_t *worker_create(void); 25 | 26 | LIBWORKER_PUBLIC worker_task_t *worker_post_task(worker_t *worker, void *data, 27 | worker_task_cb task_cb, 28 | worker_task_cb after_task_cb); 29 | 30 | LIBWORKER_PUBLIC bool worker_cancel_task(worker_t *worker, worker_task_t *task); 31 | 32 | LIBWORKER_PUBLIC bool worker_run(worker_t *worker); 33 | 34 | LIBWORKER_PUBLIC int worker_run_async(worker_t *worker); 35 | 36 | LIBWORKER_PUBLIC void worker_destroy(worker_t *worker); 37 | 38 | LIBWORKER_END_DECLS 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /lib/worker/include/worker/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/worker/include/worker/common.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "config.h" 13 | #ifdef __cplusplus 14 | #define LIBWORKER_BEGIN_DECLS extern "C" { 15 | #define LIBWORKER_END_DECLS } 16 | #else 17 | #define LIBWORKER_BEGIN_DECLS 18 | #define LIBWORKER_END_DECLS 19 | #endif 20 | 21 | #ifndef LIBWORKER_PUBLIC 22 | #if defined(_MSC_VER) && !defined(LIBWORKER_STATIC_BUILD) 23 | #ifdef LIBWORKER_DLL_EXPORT 24 | #define LIBWORKER_PUBLIC __declspec(dllexport) 25 | #else 26 | #define LIBWORKER_PUBLIC __declspec(dllimport) 27 | #endif 28 | #elif __GNUC__ >= 4 29 | #define LIBWORKER_PUBLIC extern __attribute__((visibility("default"))) 30 | #else 31 | #define LIBWORKER_PUBLIC extern 32 | #endif 33 | #endif 34 | -------------------------------------------------------------------------------- /lib/worker/src/config.h.in: -------------------------------------------------------------------------------- 1 | #define LIBWORKER_VERSION "${VERSION}" 2 | #define LIBWORKER_VERSION_MAJOR ${VERSION_MAJOR} 3 | #define LIBWORKER_VERSION_MINOR ${VERSION_MINOR} 4 | #define LIBWORKER_VERSION_ALTER ${VERSION_ALTER} 5 | ${define LIBWORKER_STATIC_BUILD} 6 | -------------------------------------------------------------------------------- /lib/worker/xmake.lua: -------------------------------------------------------------------------------- 1 | target("libworker") 2 | set_kind("$(kind)") 3 | add_files("src/**.c") 4 | add_deps("yutil", "libthread") 5 | set_configdir("include/worker") 6 | add_configfiles("src/config.h.in") 7 | add_headerfiles("include/worker.h", "include/(worker/*.h)") 8 | if is_kind("static") then 9 | set_configvar("LIBWORKER_STATIC_BUILD", 1) 10 | elseif is_plat("windows") then 11 | add_defines("LIBWORKER_DLL_EXPORT") 12 | end 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lcui", 3 | "version": "3.0.0-alpha.0", 4 | "description": "The C library for building user interfaces.", 5 | "main": "index.js", 6 | "directories": { 7 | "doc": "docs", 8 | "test": "test" 9 | }, 10 | "scripts": { 11 | "build-changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0", 12 | "update-changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", 13 | "update-copyright": "node scripts/add-copyright.js" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/lc-soft/LCUI.git" 18 | }, 19 | "keywords": [ 20 | "C", 21 | "gui", 22 | "framework" 23 | ], 24 | "author": "Liu Chao (https://lc-soft.io/)", 25 | "license": "MIT", 26 | "bugs": { 27 | "url": "https://github.com/lc-soft/LCUI/issues" 28 | }, 29 | "homepage": "https://github.com/lc-soft/LCUI#readme" 30 | } 31 | -------------------------------------------------------------------------------- /preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/preview.png -------------------------------------------------------------------------------- /src/config.h.in: -------------------------------------------------------------------------------- 1 | #define PACKAGE_VERSION "${VERSION}-${GIT_COMMIT}" 2 | ${define LCUI_STATIC_BUILD} 3 | -------------------------------------------------------------------------------- /src/lcui_widgets.c: -------------------------------------------------------------------------------- 1 | /* 2 | * src/lcui_widgets.c 3 | * 4 | * Copyright (c) 2024-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | 14 | void lcui_widgets_init(void) 15 | { 16 | ui_register_text(); 17 | ui_register_canvas(); 18 | ui_register_anchor(); 19 | ui_register_button(); 20 | ui_register_scrollarea(); 21 | ui_register_scrollbar(); 22 | ui_register_textcaret(); 23 | ui_register_textinput(); 24 | ui_register_router_link(); 25 | ui_register_router_view(); 26 | } 27 | 28 | void lcui_widgets_destroy(void) 29 | { 30 | ui_unregister_text(); 31 | ui_unregister_anchor(); 32 | } 33 | -------------------------------------------------------------------------------- /src/widgets/textstyle.c: -------------------------------------------------------------------------------- 1 | /* 2 | * src/widgets/textstyle.c 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include "textstyle.h" 13 | 14 | void convert_font_style_to_text_style(ui_text_style_t *fs, pd_text_style_t *ts) 15 | { 16 | size_t len; 17 | ts->font_ids = NULL; 18 | ts->has_style = true; 19 | ts->has_weight = true; 20 | ts->has_family = false; 21 | ts->has_back_color = false; 22 | ts->has_pixel_size = true; 23 | ts->has_fore_color = true; 24 | ts->fore_color = fs->color; 25 | ts->pixel_size = fs->font_size; 26 | ts->weight = fs->font_weight; 27 | ts->style = fs->font_style; 28 | if (fs->font_ids) { 29 | for (len = 0; fs->font_ids[len]; ++len) 30 | ; 31 | ts->font_ids = malloc(sizeof(int) * ++len); 32 | memcpy(ts->font_ids, fs->font_ids, len * sizeof(int)); 33 | ts->has_family = true; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/widgets/textstyle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * src/widgets/textstyle.h 3 | * 4 | * Copyright (c) 2023-2025, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | void convert_font_style_to_text_style(ui_text_style_t *fs, pd_text_style_t *ts); 16 | -------------------------------------------------------------------------------- /tests/cases/test_image_reader.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/cases/test_image_reader.c 3 | * 4 | * Copyright (c) 2023, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | void test_image_reader(void) 17 | { 18 | pd_canvas_t img; 19 | int i; 20 | char file[256], *formats[] = { "png", "bmp", "jpg" }; 21 | 22 | for (i = 0; i < 3; ++i) { 23 | pd_canvas_init(&img); 24 | snprintf(file, 255, "test_image_reader.%s", formats[i]); 25 | logger_debug("image file: %s\n", file); 26 | ctest_equal_int("check pd_read_image_from_file", 27 | pd_read_image_from_file(file, &img), 0); 28 | ctest_equal_int("check image width with ReadImageFile", 29 | img.width, 91); 30 | ctest_equal_int("check image height with ReadImageFile", 31 | img.height, 69); 32 | pd_canvas_destroy(&img); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tests/dog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/tests/dog.jpg -------------------------------------------------------------------------------- /tests/helloworld_uwp/App.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include LCUI_APP_H 9 | 10 | class App : public LCUI::Application 11 | { 12 | void Load(Platform::String ^ entryPoint); 13 | }; 14 | 15 | static void OnBtnClick(ui_widget_t* self, ui_event_t* e, void *arg) 16 | { 17 | wchar_t str[256]; 18 | ui_widget_t* edit = ui_get_widget("edit"); 19 | ui_widget_t* txt = ui_get_widget("text-hello"); 20 | ui_textinput_get_text_w(edit, 0, 255, str); 21 | ui_text_set_content_w(txt, str); 22 | } 23 | 24 | void App::Load(Platform::String ^ entryPoint) 25 | { 26 | ui_widget_t* btn, root, pack; 27 | root = ui_root(); 28 | pack = ui_load_xml_file("helloworld.xml"); 29 | if (!pack) { 30 | return; 31 | } 32 | ui_widget_append(root, pack); 33 | ui_widget_unwrap(pack); 34 | btn = ui_get_widget("btn"); 35 | ui_widget_on(btn, "click", OnBtnClick, NULL); 36 | } 37 | 38 | [Platform::MTAThread] int main(Platform::Array ^) { 39 | App app; 40 | LCUI::Initialize(); 41 | LCUI::Run(app); 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /tests/helloworld_uwp/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/tests/helloworld_uwp/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /tests/helloworld_uwp/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/tests/helloworld_uwp/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /tests/helloworld_uwp/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/tests/helloworld_uwp/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /tests/helloworld_uwp/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/tests/helloworld_uwp/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /tests/helloworld_uwp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/tests/helloworld_uwp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /tests/helloworld_uwp/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/tests/helloworld_uwp/Assets/StoreLogo.png -------------------------------------------------------------------------------- /tests/helloworld_uwp/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/tests/helloworld_uwp/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /tests/helloworld_uwp/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /tests/helloworld_uwp/pch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/helloworld_uwp/pch.h 3 | * 4 | * Copyright (c) 2023, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #pragma once 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | -------------------------------------------------------------------------------- /tests/include/ctest-custom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/include/ctest-custom.h 3 | * 4 | * Copyright (c) 2023, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | static inline bool ctest_equal_pd_rect(const char *name, pd_rect_t *actual, 18 | pd_rect_t *expected) 19 | { 20 | return ctest_equal(name, (ctest_to_str_func_t)pd_rect_to_str, actual, expected); 21 | } 22 | 23 | static inline bool ctest_equal_ui_rect(const char *name, ui_rect_t *actual, 24 | ui_rect_t *expected) 25 | { 26 | return ctest_equal(name, (ctest_to_str_func_t)ui_rect_to_str, actual, expected); 27 | } 28 | -------------------------------------------------------------------------------- /tests/run_tests.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/run_tests.h 3 | * 4 | * Copyright (c) 2023, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | void test_settings(void); 13 | void test_thread(void); 14 | void test_font_load(void); 15 | void test_xml_parser(void); 16 | void test_widget_opacity(void); 17 | void test_widget_event(void); 18 | void test_text_resize(void); 19 | void test_textinput(void); 20 | void test_scrollbar(void); 21 | void test_image_reader(void); 22 | void test_mainloop(void); 23 | void test_block_layout(void); 24 | void test_flex_layout(void); 25 | void test_widget_rect(void); 26 | void test_clipboard(void); 27 | void test_router_components(void); 28 | -------------------------------------------------------------------------------- /tests/test_block_layout.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/test_block_layout.c 3 | * 4 | * Copyright (c) 2023, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #define PREVIEW_MODE 13 | #include "./cases/test_block_layout.c" 14 | #include 15 | 16 | int main(int argc, char **argv) 17 | { 18 | logger_set_level(LOGGER_LEVEL_ALL); 19 | test_block_layout(); 20 | return lcui_main(); 21 | } 22 | -------------------------------------------------------------------------------- /tests/test_border.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/test_border.c 3 | * 4 | * Copyright (c) 2023, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | int main(void) 18 | { 19 | int ret = 0; 20 | ui_widget_t *root, *box; 21 | 22 | lcui_init(); 23 | box = ui_load_xml_file("test_border.xml"); 24 | if (!box) { 25 | lcui_destroy(); 26 | return ret; 27 | } 28 | root = ui_root(); 29 | ui_widget_append(root, box); 30 | ui_widget_unwrap(box); 31 | return lcui_main(); 32 | } 33 | -------------------------------------------------------------------------------- /tests/test_border.css: -------------------------------------------------------------------------------- 1 | .box { 2 | width: 100px; 3 | height: 80px; 4 | background-color: #eee; 5 | margin: 10px; 6 | box-sizing: border-box; 7 | display: inline-block; 8 | } 9 | .box-content { 10 | background-color: #fff; 11 | border: 1px solid #888; 12 | } 13 | .rounded.box { 14 | border-radius: 20px; 15 | } 16 | .square.box { 17 | width: 80px; 18 | height: 80px; 19 | border: 40px solid #000; 20 | border-left-color: #f00; 21 | border-right-color: #00f; 22 | } 23 | .rounded-2.box { 24 | border-radius: 40px; 25 | } 26 | .box-1 { 27 | border: 1px solid #000; 28 | } 29 | .box-2 { 30 | border: 10px solid #000; 31 | } 32 | .box-3 { 33 | border: 10px solid #000; 34 | border-left: 20px solid #f00; 35 | } 36 | .box-4 { 37 | border: 10px solid #000; 38 | border-top: 20px solid #f00; 39 | } 40 | .box-5 { 41 | border: 10px solid #000; 42 | border-right: 20px solid #f00; 43 | } 44 | .box-6 { 45 | border: 10px solid #000; 46 | border-bottom: 20px solid #f00; 47 | } 48 | -------------------------------------------------------------------------------- /tests/test_border.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | border 4 | 5 | 6 | 7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /tests/test_box_shadow.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/test_box_shadow.c 3 | * 4 | * Copyright (c) 2023, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | int main(void) 17 | { 18 | int ret = 0; 19 | ui_widget_t *box; 20 | 21 | lcui_init(); 22 | box = ui_load_xml_file("test_box_shadow.xml"); 23 | if (!box) { 24 | lcui_destroy(); 25 | return ret; 26 | } 27 | ui_root_append(box); 28 | ui_widget_unwrap(box); 29 | return lcui_main(); 30 | } 31 | -------------------------------------------------------------------------------- /tests/test_box_shadow.css: -------------------------------------------------------------------------------- 1 | 2 | .box { 3 | width: 100px; 4 | height: 80px; 5 | margin: 10px; 6 | box-sizing: border-box; 7 | display: inline-block; 8 | background-color: #eee; 9 | border: 1px solid #f00; 10 | box-shadow: 0 0 8px rgba(0, 0, 0, 0.8); 11 | } 12 | .box-content { 13 | background-color: #fff; 14 | border: 1px solid #888; 15 | } 16 | .shadow-container { 17 | padding: 0 0 30px 0; 18 | } 19 | .shadow-2 .box { 20 | box-shadow: 15px 15px 8px rgba(0, 0, 0, 0.8); 21 | } 22 | .shadow-3 .box { 23 | box-shadow: 30px 30px 8px rgba(0, 0, 0, 0.8); 24 | } 25 | .rounded.box { 26 | border-radius: 20px; 27 | } 28 | .rounded-2.box { 29 | border-radius: 40px; 30 | } 31 | .rounded-3.box { 32 | border-top-left-radius: 40px; 33 | border-top-right-radius: 30px; 34 | border-bottom-right-radius: 20px; 35 | border-bottom-left-radius: 10px; 36 | } 37 | .rounded-4.box { 38 | border-top-left-radius: 10px; 39 | border-top-right-radius: 40px; 40 | border-bottom-right-radius: 10px; 41 | border-bottom-left-radius: 40px; 42 | } 43 | .square.box { 44 | width: 80px; 45 | height: 80px; 46 | } 47 | -------------------------------------------------------------------------------- /tests/test_box_shadow.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | border 4 | 5 | 6 | 7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /tests/test_box_shadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /tests/test_char_render.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/test_char_render.c 3 | * 4 | * Copyright (c) 2023, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | int main(void) 16 | { 17 | int ret, fid; 18 | pd_canvas_t img; 19 | pd_font_bitmap_t bmp; 20 | pd_pos_t pos = { 25, 25 }; 21 | pd_color_t bg = pd_rgb(240, 240, 240); 22 | pd_color_t color = pd_rgb(255, 0, 0); 23 | 24 | /* 初始化字体处理功能 */ 25 | pd_font_library_init(); 26 | 27 | /* 创建一个画布,并填充背景为灰色 */ 28 | pd_canvas_init(&img); 29 | pd_canvas_create(&img, 100, 100); 30 | pd_canvas_fill(&img, bg); 31 | 32 | /* 载入字体文件 */ 33 | ret = pd_font_library_load_file("C:/Windows/fonts/simsun.ttc"); 34 | while (ret == 0) { 35 | /* 获取字体ID */ 36 | fid = pd_font_library_get_font_id("SimSun", 0, 0); 37 | if (fid < 0) { 38 | break; 39 | } 40 | /* 渲染对应的文字位图,大小为 48 像素 */ 41 | ret = pd_font_library_render_bitmap(&bmp, L'字', fid, 48); 42 | if (ret != 0) { 43 | break; 44 | } 45 | /* 绘制红色文字到图像上 */ 46 | pd_canvas_mix_font_bitmap(&img, pos, &bmp, color); 47 | pd_write_png_file("test_char_render.png", &img); 48 | /* 释放内存资源 */ 49 | pd_font_bitmap_destroy(&bmp); 50 | pd_canvas_destroy(&img); 51 | break; 52 | } 53 | 54 | /* 释放字体处理功能相关资源 */ 55 | pd_font_library_destroy(); 56 | return ret; 57 | } 58 | -------------------------------------------------------------------------------- /tests/test_css_parser.css: -------------------------------------------------------------------------------- 1 | .window .content .btn text { 2 | width: 100px; 3 | } 4 | .window .content .btn .text { 5 | height: 60px; 6 | } 7 | .window text { 8 | position: absolute; 9 | } 10 | #test-text { 11 | top: 12px; 12 | } 13 | .text { 14 | left: 20px; 15 | } 16 | .window .content .btn:hover text { 17 | background-color: #f00; 18 | } 19 | .window .content .btn:hover .text { 20 | background-size: contain; 21 | } 22 | 23 | #test-flex-auto { 24 | flex: auto; 25 | } 26 | 27 | #test-flex-none { 28 | flex: none; 29 | } 30 | 31 | #test-flex-initial { 32 | flex: initial; 33 | } 34 | 35 | #test-flex-1 { 36 | flex: 1; 37 | } 38 | 39 | #test-flex-100px { 40 | flex: 100px; 41 | } 42 | 43 | #test-flex-1-100px { 44 | flex: 1 100px; 45 | } 46 | 47 | #test-flex-0-0-100px { 48 | flex: 0 0 100px; 49 | } 50 | 51 | #test-flex-box { 52 | flex: 0 0 auto; 53 | flex-flow: column nowrap; 54 | justify-content: center; 55 | justify-items: center; 56 | align-items: flex-end; 57 | align-content: flex-end; 58 | } 59 | -------------------------------------------------------------------------------- /tests/test_css_parser.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | test 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /tests/test_fill_rect.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/test_fill_rect.c 3 | * 4 | * Copyright (c) 2023, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | int main(void) 16 | { 17 | int i, j; 18 | pd_canvas_t canvas; 19 | pd_color_t color; 20 | pd_rect_t rect; 21 | 22 | pd_canvas_init(&canvas); 23 | pd_canvas_create(&canvas, 150, 150); 24 | for (i = 0; i < 6; ++i) { 25 | for (j = 0; j < 6; ++j) { 26 | color.red = (unsigned char)(255 - 42.5 * i); 27 | color.green = (unsigned char)(255 - 42.5 * j); 28 | color.blue = 0; 29 | rect.x = j * 25; 30 | rect.y = i * 25; 31 | rect.width = 25; 32 | rect.height = 25; 33 | pd_canvas_fill_rect(&canvas, color, rect); 34 | } 35 | } 36 | pd_write_png_file("test_fill_rect.png", &canvas); 37 | pd_canvas_destroy(&canvas); 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /tests/test_flex_layout.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/test_flex_layout.c 3 | * 4 | * Copyright (c) 2023, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #define PREVIEW_MODE 13 | #include "./cases/test_flex_layout.c" 14 | #include 15 | 16 | int main(int argc, char **argv) 17 | { 18 | logger_set_level(LOGGER_LEVEL_ALL); 19 | test_flex_layout(); 20 | return lcui_main(); 21 | } 22 | -------------------------------------------------------------------------------- /tests/test_font_load.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: icomoon; 3 | font-weight: normal; 4 | font-style: normal; 5 | src: url("test_font_load.ttf"); 6 | } 7 | -------------------------------------------------------------------------------- /tests/test_font_load.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/tests/test_font_load.ttf -------------------------------------------------------------------------------- /tests/test_image_reader.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/tests/test_image_reader.bmp -------------------------------------------------------------------------------- /tests/test_image_reader.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/tests/test_image_reader.jpg -------------------------------------------------------------------------------- /tests/test_image_reader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lc-soft/LCUI/ae9b228f48e2e6f9fd449400d78a244ba56b506d/tests/test_image_reader.png -------------------------------------------------------------------------------- /tests/test_scaling_support.css: -------------------------------------------------------------------------------- 1 | .text-box { 2 | border: 1px solid #eee; 3 | background: #f0f0f0; 4 | display: inline-block; 5 | margin-right: 10px; 6 | padding: 5px 10px; 7 | white-space: nowrap; 8 | } 9 | .image { 10 | width: 91px; 11 | height: 69px; 12 | border: 1px solid #eee; 13 | background-image: url(test_image_reader.png); 14 | background-size: contain; 15 | margin: 5px 0; 16 | } 17 | .container { 18 | padding: 5px 0; 19 | } 20 | .text-sp { 21 | font-size: 18sp; 22 | } 23 | .box-px { 24 | width:80px; 25 | text-align: center; 26 | } 27 | .box-dp { 28 | width: 80dp; 29 | border-width: 5dp; 30 | text-align: center; 31 | } 32 | .text-px { 33 | font-size: 18px; 34 | } 35 | .text-pt { 36 | font-size: 12pt; 37 | } 38 | .p { 39 | display: block; 40 | font-size: 14px; 41 | margin: 10px 0; 42 | } 43 | button { 44 | margin-right: 10px; 45 | } 46 | root { 47 | padding: 20px; 48 | box-sizing: border-box; 49 | } 50 | -------------------------------------------------------------------------------- /tests/test_scrollbar.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/test_scrollbar.c 3 | * 4 | * Copyright (c) 2023, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #define PREVIEW_MODE 13 | #include "./cases/test_scrollbar.c" 14 | #include 15 | 16 | int main(int argc, char **argv) 17 | { 18 | lcui_init(); 19 | ui_widget_resize(ui_root(), 800, 640); 20 | ui_load_css_string(test_css, __FILE__); 21 | /* We have two ways to build content view */ 22 | build_content_view_from_xml(); 23 | build_content_view(); 24 | return lcui_main(); 25 | } 26 | -------------------------------------------------------------------------------- /tests/test_string_render.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/test_string_render.c 3 | * 4 | * Copyright (c) 2023, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | int main(void) 16 | { 17 | int ret; 18 | pd_canvas_t img; 19 | pd_pos_t pos = { 0, 80 }; 20 | pd_rect_t area = { 0, 0, 320, 240 }; 21 | pd_text_t* txt = pd_text_create(); 22 | pd_text_style_t txtstyle; 23 | 24 | /* 初始化字体处理功能 */ 25 | pd_font_library_init(); 26 | 27 | /* 创建一个图像,并使用灰色填充 */ 28 | pd_canvas_init(&img); 29 | pd_canvas_create(&img, 320, 240); 30 | pd_canvas_fill(&img, pd_rgb(240, 240, 240)); 31 | 32 | /* 设置文本的字体大小 */ 33 | pd_text_style_Init(&txtstyle); 34 | txtstyle.pixel_size = 24; 35 | txtstyle.has_pixel_size = true; 36 | 37 | /* 设置文本图层的固定尺寸、文本样式、文本内容、对齐方式 */ 38 | pd_text_set_fixed_size(txt, 320, 240); 39 | pd_text_set_style(txt, &txtstyle); 40 | pd_text_set_align(txt, PD_TEXT_ALIGN_CENTER); 41 | pd_text_write(txt, L"这是一段测试文本\nHello, World!", NULL); 42 | pd_text_update(txt, NULL); 43 | 44 | /* 将文本图层绘制到图像中,然后将图像写入至 png 文件中 */ 45 | pd_text_render_to(txt, area, pos, &img); 46 | ret = pd_write_png_file("test_string_render.png", &img); 47 | pd_canvas_destroy(&img); 48 | 49 | /* 释放字体处理功能相关资源 */ 50 | pd_font_library_destroy(); 51 | return ret; 52 | } 53 | -------------------------------------------------------------------------------- /tests/test_text_resize.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/test_text_resize.c 3 | * 4 | * Copyright (c) 2023, Liu Chao All rights reserved. 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | * This file is part of LCUI, distributed under the MIT License found in the 9 | * LICENSE.TXT file in the root directory of this source tree. 10 | */ 11 | 12 | #define PREVIEW_MODE 13 | #include "./cases/test_text_resize.c" 14 | #include 15 | 16 | int main(int argc, char *argv[]) 17 | { 18 | lcui_init(); 19 | 20 | build(); 21 | ptk_set_timeout(2000, test_text_set_content, NULL); 22 | ptk_set_timeout(3000, test_text_set_short_content_css, NULL); 23 | ptk_set_timeout(4000, test_text_set_long_content_css, NULL); 24 | 25 | return lcui_main(); 26 | } 27 | -------------------------------------------------------------------------------- /tests/test_widget_opacity.css: -------------------------------------------------------------------------------- 1 | .container { 2 | padding: 10px; 3 | background-color: #fbfbfb; 4 | } 5 | 6 | .list { 7 | padding: 20px; 8 | margin: 20px; 9 | background-color: #f00; 10 | border: 20px solid #000; 11 | box-sizing: border-box; 12 | } 13 | 14 | .list-item { 15 | width: 150px; 16 | height: 100px; 17 | margin: 5px; 18 | position: relative; 19 | display: inline-block; 20 | background-color: #0f0; 21 | } 22 | 23 | .list-item:hover { 24 | top: -3px; 25 | } 26 | 27 | .list-item:active, 28 | .list-item.active { 29 | top: 0; 30 | opacity: 0.5; 31 | } 32 | 33 | .list-item text { 34 | text-align: center; 35 | } 36 | 37 | .list-item-footer { 38 | width: 100%; 39 | bottom: 0; 40 | position: absolute; 41 | padding: 10px 0; 42 | line-height: 20px; 43 | text-align: center; 44 | background-color: #fff; 45 | } 46 | 47 | .buttons { 48 | display: flex; 49 | justify-content: center; 50 | } 51 | 52 | .buttons button { 53 | margin: 10px 5px; 54 | } 55 | 56 | .buttons text { 57 | width: 30px; 58 | margin: 10px 5px; 59 | text-align: center; 60 | line-height: 32px; 61 | display: inline-block; 62 | } 63 | -------------------------------------------------------------------------------- /tests/test_widget_opacity.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | item 1 content 9 | footer 10 | 11 | 12 | item 2 content 13 | footer 14 | 15 | 16 | item 3 content 17 | footer 18 | 19 | 20 | item 4 content 21 | footer 22 | 23 | 24 | 25 | 26 | -- 27 | 1.0 28 | ++ 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /tests/test_xml_parser.nested.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Element 1 from nested xml file 5 | 6 | Element 2 from nested xml file 7 | Element 3 from nested xml file 8 | Element 4 from nested xml file 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/test_xml_parser.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Disabed element 1 5 | Disabed element 2 6 | Disabed element 3 7 | 8 | Normal element 4 9 | 10 | 11 | --------------------------------------------------------------------------------