Liu e533853908 feat: update css library
feat(css): add css value definition parser

refactor(css): change the parameter types of css_parse_* functions

refactor(css): migrate to new data types

refactor(css): migrate to new data types (2)

refactor(css): migrate to new data types (3)

test: add valdef test

feat(css): add css_valdef_parser_finish()

refactor(css): split css_library.c

refactor(css): css_data_type.c -> css_data_types.c

fix(css): the parsing error message of sign is not truncated

fix(css): correct initialization of data type library

fix(css): error message should not be empty

feat(css): add css_valdef_to_string()

feat(css): add double bar combinator

feat(css): add double ampersand combinator

feat(css): add curly braces multiplier

feat(css): add brackets combinator parser

docs: update css value matcher section

feat(css): add question mark multiplier

test(css): add test for brackets combinator

docs(css): update libcss_css_value.md

docs: update directory structure

refactor: numberic -> numeric

refactor(css): delete style property parser

refactor: migrate to css property API

docs(css): add css value converter section

feat(css): add css_computed_style_t

refactor(css): rename `css_style` associated identifiers

feat(css): add css_cascade_style()

refactor(css): change type of css_value_matcher_t::value

refactor(css): update args of css_register_property()

refactor(css): move css_computed_style_t

feat(css): update opacity property

feat(css): update z-index property

feat(css): update display property

feat(css): update pointer-events property

feat(css): update flex-wrap property

feat(css): update flex-direction property

feat(css): update flex-grow property

feat(css): update flex-shrink property

feat(css): update align-items property

feat(css): update justify-content property

feat(css): update position property

feat(css): update box-sizing property

feat(css): update align-content property

feat(css): update white-space property

feat(css): update content property

feat(css): update text-align property

feat(css): automatically register new keywords

feat(css): update font-style property

feat(css): update visibility property

feat(css): update border-*-style property

refactor: update css_unit_t definition

feat(css): update border-*-*-radius properties

refactor(css): delete CSS_PERCENTAGE_VALUE

refactor(css): css_cascade_length() -> css_cascade_length_auto()

refactor(css): update enum definitions

feat(css): update border-*-width properties

feat(css): update border-*-color properties

feat(css): add css_array_value_get_length()

feat(css): add border-width shorthand property

feat(css): add border-style shorthand property

feat(css): add border-radius shorthand property

feat(css): add border-color shorthand property

feat(css): add border shorthand property

feat(css): add margin shorthand property

feat(css): add padding shorthand property

feat(css): update size related properties

feat(css): update top, right, bottom, left properties

feat(css): update flex-basis property

feat(css): update line-height property

feat(css): update color property

refactor(css): add css_cascade_bg_border_color()

refactor(css): bits -> keyword_bits

refactor(css): flag -> keyword

refactor(css): update css_color_value_t definition

feat(css): add CSS_COLOR_TRANSPARENT

refactor(css): remove transparent keyword

feat(css): update font-size property

feat(css): update font-family property

feat(css): update background shorthand property

feat(css): update vertical-align property

feat(css): update box-shadow property

feat(css): update the computing of the box-shadow property

 feat(css): update the computing of the background property

feat(css): update the computing of the border property

refactor(css): keyword_bits -> type_bits

refactor(css): enum css_*_e -> uint8_t

feat(css): add absolute size computing

feat(css): add absolute padding computing

feat(css): add absolute margin computing

style(css): format code

feat(css): add top, right, bottom, and left absolute value computing

feat(css): add flex-basis absolute value computing

refactor(ui): replace data type of computed style

feat(ui): update widget background style computing

feat(ui): update widget box-shadow style computing

feat(ui): update widget border style computing

feat(ui): update widget box computing

feat(ui): use tabindex instead of focusable

feat(css): remove focusable property

feat(css): update font-weight property

fix(css): clear compile errors

refactor(ui): adapt to new computed style data structure

refactor(ui): delete ui_widget_box_model_t

fix: clear some compiler warnings

refactor(ui): ui_font_style.c -> ui_text_style.c

feat(ui): remove unnecessary helper functions

fix: clear some compiler warnings

fix(font): correct bitmap cache access

fix(css): correct the key assignment of keywords

fix(css): some memory access errors

fix: missing NULL at the end of font names

fix: clear gcc errors

refactor: clear gcc warnings

fix(css): array subscript is above array bounds

fix(css): incorrect property name memory allocation

fix(css): style parser memory leak

fix(css): prop->valdef memory leak

refactor(css): logger_debug -> DEBUG_MSG

refactor(ui-builder): clear warnings

fix(css): css_properties.list memory leak

fix(css): css_style_link_group_create() memory leak

fix(css): incorrect keyword storage

test(css): correct color_value comparison

test: clear compiler errors

fix(css): correct the return value of css_register_keyword()

fix(css): correct integer type value parsing

chore(css): _DEBUG -> DEBUG

feat(css): add string value parsing

fix(css): correct font-family initial value

test(css): add test_css_computed.c

fix(css): value read error in css_cascade_background()

fix(css): add some missing properties

feat(css): add flex shorthand property

build: update rundir of lcui-css-test

fix(css): font-family parsing error

feat(css): style array value to string

chore(vscode): add compileCommands

fix(css): string value parsing error

fix(css): correct content property initial value

fix(css): the parsed style data is not stored correctly

fix(css): correct cascading of some properties

fix(css): percentage value parsing inccorect

fix(css): <length> should not contain <percentage>

fix(css): css_array_value_duplicate() did not copy the last value

feat(css): add visible keyword

feat(css): cascade each property in order

refactor(css): add style_decl.c

refactor(css): use css_style_decl_t instead of css_style_t

fix(css): incorrect number of resolved values

refactor(css): add css_style.c

feat(css): parse shorthand properties in the parsing phase

refactor(css): add background property parser

refactor(css): add border property parser

refactor(css): css_select_style_decl -> css_find_style_store

refactor(css): add css_select_style_with_cache()

refactor(css): add margin property parser

refactor(css): add padding property parser

refactor(css): add flex property parser

fix(ui): incorrect widget style cascading order

refactor(css): const css_propdef_t* -> css_propdef_t*

refactor(css): update arguments of shorthand property parser

fix(css): incorrect value parsing of shorthand property

fix(css): unexpected truncation while parsing color value

fix(css): correct value matching and style computing

fix(ui): correct css style operation

fix(platform): crash when closing window

refactor(css): delete file prefix

refactor(css): delete style.c

refactor(css): clear compiler warnings

refactor: update directory structure and build configuration

feat(css): add dump functions

fix(css): correct valdef parser cursor operation

fix(css): correct the definition of margin and padding

fix(css): correct flex property parsing and definition

refactor(ui): adjust the use of calculated styles in the layout engine

chore: tests/helloword -> examples/hello

fix(ui): some bugs in block layout

fix(css): correct flex property definition

refactor(ui): simplify the naming of widget style and layout diff API

refactor(ui): update reflow trigger rules

refactor(ui): ui_widget_auto_reflow -> ui_widget_reflow

feat(ui): allow multiple observers to connect to the same widget

refactor(ui): simplify widget update process

refactor(ui): adjust row processing in block layout

refactor(ui): adjust the data structure used in the flexbox layout

fix(ui): correct flex layout algorithm

build: update config
2023-04-01 22:36:07 +08:00
2023-04-01 22:36:07 +08:00
2023-04-01 22:36:04 +08:00
2023-04-01 22:36:07 +08:00
2021-05-31 23:28:36 +08:00
2023-04-01 22:36:07 +08:00
2023-04-01 22:36:07 +08:00
2023-04-01 22:36:07 +08:00
2023-04-01 22:36:07 +08:00
2023-04-01 22:32:21 +08:00
2023-04-01 22:36:07 +08:00
2023-04-01 22:36:07 +08:00
2018-05-05 13:36:08 +08:00
2020-04-11 17:51:02 +08:00
2012-08-04 15:17:11 +08:00
2021-05-31 23:28:36 +08:00
2021-05-31 23:28:36 +08:00
2021-05-31 23:28:36 +08:00
2023-04-01 22:36:04 +08:00
2018-05-06 16:10:22 +08:00
2023-04-01 22:35:20 +08:00
2023-04-01 22:35:20 +08:00
2023-04-01 22:36:07 +08:00

LCUI

A small C library for building user interfaces with C, XML and CSS.

GitHub Actions License Github Release Github All Releases Repo size Code size

Table of contents

Introduction

LCUI (LC's UI Library) is a small C library for building user interfaces.

中文版说明文档

Features

  • Written in C: Suitable for small applications written primarily in C.language designed for LCUI, it makes it easier to create interactive UIs.
  • Cross platform: Support for Windows and Linux, you can write Windows Desktop apps and Universal Windows Platform apps, as well as Linux Desktop apps.
  • XML + CSS: Includes XML and CSS parsers, you can use XML and CSS to describe interface structure and style.
  • Web-like development experience: Since the design and implementation of LCUI's functions, including layout, CSS, and renderer, are mostly referenced from MDN documents and some popular web front-end development libraries, its development experience and interface effects will have some similarities to web pages. If you already have experience writing web pages with HTML and CSS, it will be easier to get started.
  • Flexible: Support for adapting the interface to screens of different pixel densities by setting global scaling. Support for using screen density related sp and dp units to describe position and size of the elements.

Screenshots

Hello App LC Finder
LCUI Router App LC Design

Architecture

Over time LCUI has been built up to be based on various libraries, as shown below:

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                               ┃
┃                        LCUI Application                       ┃
┃                                                               ┃
┃        ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓        ┃
┃        ┃                    LCUI 3                   ┃        ┃
┃      ┏━┻━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━┻━┓      ┃
┃      ┃ ui-server ┃ ui-widgets ┃ ui-builder ┃ ui-anchor ┃      ┃
┃    ┏━┻━━━━━━━━━━━┻━━━━━━━━━━━━┻━━━━━━━━━━━━┻━━━━━━━━━━━┻━┓    ┃
┃    ┃ platform ┃    ui    ┃  worker  ┃  timer  ┃  cursor  ┃    ┃
┣━━━━┻━━━━━━━━━━┻━━━━━━━━━━┻━━━━━━━━━━┻━━━━━━━━━┻━━━━━━━━━━┻━━━━┫
┃ thread ┃ yutil  ┃ image  ┃   css   ┃ paint  ┃  font  ┃  text  ┃
┗━━━━━━━━┻━━━━━━━━┻━━━━━━━━┻━━━━━━━━━┻━━━━━━━━┻━━━━━━━━┻━━━━━━━━┛
  • lib/css: CSS (Cascading Style Sheet) parser and selection engine, providing CSS parsing and selection capabilities.
  • lib/image: Image file manipulation library, provides BMP, JPG, PNG image file reading ability and PNG write ability.
  • lib/paint: 2D graphics library.
  • lib/platform: Platform library, provides cross-platform unified system related API, including message loop, window management, input method, etc.
  • lib/text: Text typesetting library, provides text typesetting capabilities.
  • lib/thread: Thread library, providing cross-platform multithreading capabilities.
  • lib/timer: Timer library, provides the ability to perform operations on a scheduled basis.
  • lib/ui: Graphical interface core library, providing UI component management, event queue, style calculation, drawing and other necessary UI capabilities.
  • lib/ui-anchor: Anchor widget, provide capabilities similar to hyperlinks.
  • lib/ui-builder: UI Builder, provides the ability to create a UI from the content of an XML file.
  • lib/ui-cursor: Cursor, provides cursor drawing capability.
  • lib/ui-server: UI Server, provides the ability to map UI widgets to system Windows.
  • lib/ui-widgets: UI widget library, provides basic UI components like text, buttons, scrollbars, and so on.
  • lib/worker: Worker thread library, provides simple worker thread communication and management capabilities.
  • lib/yutil: Utility library, provides linked list, hash table, red black tree, string and other related common functions.

Design references

  • SDL — X11 driver code reference
  • FreeType — Data structure naming style reference
  • LevelDB — Function naming style reference
  • jQuery — Widget operation method naming style reference
  • MDN — CSS standard reference

Compilation

Install XMake and run the following command:

# Clone repository
git clone https://github.com/lc-soft/LCUI.git

# Go into the repository
cd LCUI

# Build
xmake

If you want to experience the results of the test program:

# Package the built files for building the test program
xmake package

# Go into test directory
cd test

# Build
xmake -P .

# Run
xmake run -P . -w . helloworld

Installation

xmake install

# Or install it in your custom directory
xmake install -o /path/to/your/custom/installdir

Contribution

Think LCUI is slow to update? there are many ways to contribute to LCUI.

LCUI has adopted the code of conduct defined by the Contributor Covenant. This document is used across many open source communities, and we think it articulates our values well. For more, see the Code of Conduct.

Documentation

The English version of the documentation is not available, because the author does not have time to write the English version, please read the files in the test directory and related projects to learn how to use LCUI.

FAQ

  1. Why develop it?

    • Explore and experiment new GUI development way
    • Let other developers share about how to write better code
    • Make it easier for me to find better jobs to make more money
    • Pass the time
  2. Is this a browser kernel? Or a development library like Electron that integrates the browser environment?

    No, you can think of it as a traditional GUI development library that applied some Web technologies.

  3. What do I need to pay attention to if I'm going to use it?

    We recommend that your project meet the following requirements:

    • The user interface is simple and does not require advanced features such as tables, animations, and transformations.
    • The code design is reasonable, and the core function code and UI logic code are independent of each other. Even if you find that the requirements are not met after using LCUI, you can easily migrate to other GUI libraries.
  4. Why do I choose the LCUI instead of Electron?

    In contrast to fully functional Electron, these features of LCUI, such as small binary file size and low memory usage, are not worth mentioning, except for technical research and share, you have no reason to use LCUI.

  5. Is it the same as writing a web page?

    Not exactly, there are the following differences need to be noted:

    • The interface description file format is XML, slightly different from HTML.
    • You need to implement all the features of your application in C code, which is much less development efficiency than JavaScript.
    • No <script> tag, you can't embed JavaScript or C code like HTML.
    • The widget is the basic layout element, not the text, and there is no inline display type.
    • The scrollbar is a widget, and the overflow: scroll; style doesn't show scrollbars automatically, you need to create it and specify the container and scroll layer.
    • All text is rendered by the TextView widget, which has a display type of block instead of inline.
    • The widget does not overflow the bounding box of the parent widget, and the effect is similar to the applied style: overflow: hidden;.
    • An absolutely positioned widget is always relative to its parent widget, not the first non-statically positioned widget of the parent.
    • There are no tools like Chrome Devtools to debug graphical interfaces, you need to rely on your own imagination and development experience to verify that the bug is from your code or LCUI.。
  6. How about CSS support?

    The following is a list of supported CSS features. Checked is supported (But does not mean full support). Unlisted properties are not supported by default.

    CSS feature coverage
    • at rules
      • @font-face
      • @keyframes
      • @media
    • keywords
      • !important
    • selectors
      • *
      • type
      • #id
      • .class
      • :hover
      • :focus
      • :active
      • :first-child
      • :last-child
      • [attr="value"]
      • :not()
      • :nth-child()
      • parent > child
      • a ~ b
      • ::after
      • ::before
      • ...
    • units
      • px
      • dp
      • sp
      • pt
      • %
      • rem
      • vh
      • vw
    • properties
      • top, right, bottom, left
      • width, height
      • visibility
      • display
        • none
        • inline-block
        • block
        • flex
        • inline-flex
        • inline
        • grid
        • table
        • table-cell
        • table-row
        • table-column
        • ...
      • position
        • static
        • relative
        • absolute
        • fixed
      • box-sizing
        • border-box
        • content-box
      • border
      • border-radius
      • background-color
      • background-image
      • background-position
      • background-cover
      • background
      • pointer-events
      • font-face
      • font-family
      • font-size
      • font-style
      • flex
      • flex-shrink
      • flex-grow
      • flex-basis
      • flex-wrap
      • flex-direction
      • justify-content
        • flex-start
        • center
        • flex-end
      • align-items
        • flex-start
        • center
        • flex-end
        • stretch
      • float
      • transition
      • transform
      • ...

License

The LCUI Project is released under the MIT License.

S
Description
Lustro github.com/lc-soft/LCUI
Readme
30 MiB
Languages
C 94.4%
CSS 4.2%
JavaScript 1%
Lua 0.4%