LCUI

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

Github星跟蹤圖

Table of contents

Introduction

LCUI is a freely available software library for building user interfaces. It is written in C and supports the use of XML and CSS to describe the graphical interface of simple desktop apps.

中文版说明文档

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: Support the use of XML and CSS to describe the GUI layout and style, saving interface development time and maintenance costs.
  • 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.
  • Simple image reading: Provide jpg, png and bmp image read APIs.
  • Touch: Supports multi-touch, but currently only on Windows platforms.

Missing features

LCUI is a personal project, its main purpose is to allow the author to easily develop simple GUI applications.

What is "simple"? It means fewer features, for example:

  • No hardware acceleration, graphics rendering is inefficient.
  • Cannot select text and copy it on user interface.
  • Cannot use CTRL+C to copy content, and cannot use CTRL+V to paste content to input boxes.
  • Cannot use the Input Method Engine to input non-ASCII characters, like Chinese, Japanese, etc.
  • Layout system is simple. Grid and table layouts are not supported.
  • No English documentation, it is hard to use.

There are many similar open source projects(E.g: SDL, imgui) that can be referenced today, most of the missing features in LCUI can find relevant implementations from these projects, so the development cost of LCUI is also reduced a lot. One of the reasons for open source this project is to conduct technical exchanges. If you have research experience in similar projects, please consider providing improvements to this project.

Want to know what LCUI can do? You can view the following projects:

  • LCUI CLI - Command line interface for rapid LCUI development.
  • LCUI Router - The official router for LCUI. It provides a similar development experience to the Vue Router and make building multiple views applications with LCUI a breeze.
  • LC Design - A UI component framework for building LCUI application.
  • LC Finder - An image manager, it uses most of the features of LCUI, and you can use it as a reference to evaluate whether LCUI's performance and development complexity meets your needs.
  • Trad - A language based on JavaScript syntax that can be compiled into C, it preset LCUI bindings, provides React like development experience, makes it painless to create interactive UIs based on LCUI.

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

Quick start

Windows

Quickly create an LCUI project using lcui-cli:

# Install lcui-cli
npm install -g @lcui/cli

# Create an LCUI project named myapp
lcui create myapp

# Go into project directory
cd myapp

# Run it
npm run start

Or, you can clone and run the lc-ui/lcui-quick-start repository to see a minimal LCUI app in action:

# Clone repository
git clone https://github.com/lc-ui/lcui-quick-start

# Go into the repository
cd lcui-quick-start

# Install NodeJS dependencies
npm install

# Install C/C++ dependencies for x64 CPU architecture
lcpkg install --arch x64

# Run the app with debug mode
lcpkg run start --mode debug

Want to write an LCUI application from scratch? you can use lcpkg to quick install LCUI in your project directory:

# Initialize the lcpkg configuration file to tell lcpkg about your project
lcpkg init

# Download and install the compiled LCUI library from GitHub
lcpkg install github.com/lc-soft/LCUI

After successful installation, follow the help documentation output by lcpkg to configure your project's build configuration.

If you want to manually compile LCUI from source code:

  1. Open CMD window, and run following command in the LCUI source directory to install the dependency libraries:
    lcpkg install
    # If you want compile for x64 CPU architecture
    lcpkg install --arch x64
    # If you want compile for Universal Windows Platform (UWP)
    lcpkg install --platform uwp
    lcpkg install --arch x64 --platform uwp
    
  2. Rename config.win.h.in in the include directory to config.h.
  3. Open the build/windows/LCUI.sln file with Visual Studio, and then build LCUI.

Ubuntu

# Install the dependencies
sudo apt-get install libpng-dev libjpeg-dev libxml2-dev libfreetype6-dev libx11-dev

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

# Go into the repository
cd LCUI

# Generate automake configure script
./autogen.sh

# Check the build environment and configure automake scripts
./configure

# Build
make

# If you wnat install LCUI
sudo make install

# Go into test directory
cd test

# Run helloworld application
./helloworld

Note: If you want to customize the compiler, compile flags, install location, and other configuration items, read the INSTALL file.

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
    • Leave a proof of existence in the world
    • Get more better jobs and 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. 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.

  4. 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.。
  5. 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.

    • 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
      • visiblility
      • display
        • none
        • inline-block
        • block
        • 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-evnets
      • font-face
      • font-family
      • font-size
      • font-style
      • justify-content
        • flex-start
        • center
        • flex-end
      • float
      • transition
      • transform
      • flex
      • ...

License

The LCUI Project is released under the MIT License.

主要指標

概覽
名稱與所有者lc-soft/LCUI
主編程語言C
編程語言Shell (語言數: 6)
平台
許可證MIT License
所有者活动
創建於2012-08-04 07:09:40
推送於2025-04-30 10:54:31
最后一次提交2025-01-10 23:42:12
發布數33
最新版本名稱v3.0.0-alpha.0 (發布於 )
第一版名稱v0.12.4 (發布於 2012-08-10 11:06:16)
用户参与
星數4.2k
關注者數152
派生數364
提交數3.6k
已啟用問題?
問題數219
打開的問題數3
拉請求數71
打開的拉請求數0
關閉的拉請求數12
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?