Git Product home page Git Product logo

lcui's Introduction

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

Related projects

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.
  • LCUI Quick Start - A minimal LCUI application.
  • LCUI Router App - A very simple browser-like application to show the LCUI and LCUI Router features.
  • LC Design App - A minimal LCUI application for preview LC Design component library.

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

Use LCUI CLI

LCUI CLI is a command line tool, you need to install Node.js before using it, and then run the following command to quickly experience it:

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

# Create an LCUI project named myapp
lcui create myapp

# Go into project directory
cd myapp

# set up the development environment for this project
lcui setup

# Build project
lcui build

# run project
lcui run

Manual compilation and installation

Windows

  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.win32.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 want to 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
    • 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.

lcui's People

Contributors

anshulxyz avatar arcticlampyrid avatar campbellowen avatar coderobe avatar dependabot[bot] avatar fakeguru avatar frankhb avatar gitter-badger avatar hyugabokko avatar jduo avatar lc-soft avatar maximelkin avatar michaellrowley avatar odknt avatar piamancini avatar reinforce-ii avatar timgates42 avatar toluschr avatar vbalyasnyy avatar whoatedacake avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lcui's Issues

Error occurs when building LCUI on GNU/Linux

I'm trying to build LCUI on my Fedora box but make fails, here is the error message in short:

catch_screen.c: In function 'catch_screen':
catch_screen.c:79:3: error: incompatible type for argument 1 of 'LCUIScreen_CatchGraph'
   LCUIScreen_CatchGraph( area, &graph );

and here is the full ouput

➜  LCUI git:(master) ✗ ./configure
...
Build with tslib support ........... : yes
Build with libpng support .......... : yes
Build with libjpeg support ......... : yes
Build with libiconv support ........ : no
Build with font-engine support ..... : none
Build with thread support .......... : pthread
Build with video support ........... : framebuffer

➜  LCUI git:(master) ✗ make
Making all in src
make[1]: Entering directory `/home/xcy/workspace/LCUI/src'
Making all in bmp
make[2]: Entering directory `/home/xcy/workspace/LCUI/src/bmp'
  CC       bmp.lo
  CC       jpeg.lo
  CC       png.lo
png.c: In function 'Graph_WritePNG':
png.c:124:29: warning: variable 'pos' set but not used [-Wunused-but-set-variable]
         int x, y, row_size, pos;
                             ^
  CC       load_image.lo
  CCLD     libbmp.la
make[2]: Leaving directory `/home/xcy/workspace/LCUI/src/bmp'
Making all in misc
make[2]: Entering directory `/home/xcy/workspace/LCUI/src/misc'
  CC       catch_screen.lo
catch_screen.c: In function 'catch_screen':
catch_screen.c:79:3: error: incompatible type for argument 1 of 'LCUIScreen_CatchGraph'
   LCUIScreen_CatchGraph( area, &graph );
   ^
In file included from catch_screen.c:46:0:
/home/xcy/workspace/LCUI/include/LCUI/LCUI_Display.h:82:14: note: expected 'struct LCUI_Graph *' but argument is of type 'LCUI_Rect'
 LCUI_API int LCUIScreen_CatchGraph( LCUI_Graph *graph, LCUI_Rect rect );
              ^
catch_screen.c:79:3: error: incompatible type for argument 2 of 'LCUIScreen_CatchGraph'
   LCUIScreen_CatchGraph( area, &graph );
   ^
In file included from catch_screen.c:46:0:
/home/xcy/workspace/LCUI/include/LCUI/LCUI_Display.h:82:14: note: expected 'LCUI_Rect' but argument is of type 'struct LCUI_Graph *'
 LCUI_API int LCUIScreen_CatchGraph( LCUI_Graph *graph, LCUI_Rect rect );
              ^
make[2]: *** [catch_screen.lo] Error 1
make[2]: Leaving directory `/home/xcy/workspace/LCUI/src/misc'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/xcy/workspace/LCUI/src'
make: *** [all-recursive] Error 1
➜  LCUI git:(master) ✗ uname -a                  
Linux fedora 3.14.7-200.fc20.x86_64 #1 SMP Wed Jun 11 22:38:05 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

If you want to know more details please let me know.

需为部件补充缺省样式

当部件添加新样式类然后删除该样式类时,部件已计算的样式依然是拥有样式类时的样式,因为移除样式类后,部件样式表里的一些样式属性已经失效,而计算样式时会忽略这些无效的样式属性,导致部分样式在计算后并未刷新。

MFC dependency in .rc file

There is #include "afxres.h" in LCUI.rc, which fails to build in VS without MFC installed. Is it intended?

需减少样式表的内存占用

一张样式表的固定内存占用大约为1000字节,而通常实际数据只占其中的一小部分,有些浪费,可考虑改用 Dict 结构存储。

Improve input method support for windows [$20]

Issuehunt badges

Problem

  • The top left of the screen will display an input box.
  • The candidate box is positioned at the top left of the screen.

image

Expected effect

  • No additional controls will be displayed.
  • The candidate box should be positioned at the text caret, like this:

image


IssueHunt Summary

1354092549 1354092549 has been rewarded.

Backers (Total: $20.00)

Submitted pull Requests


Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

Improve bitmap scaling quality

The currently used image scaling algorithm is nearest neighbor interpolation, and the scaled image is jagged and needs improvement.

textview 不支持透明色

使用 rgba(255,255,255,0.4) 这类值时,textview 上绘制的文本颜色并没有变化,但设置成 #fff 这类颜色时又有效果。

部件样式的更新有延迟现象

正常情况下,在修改几个部件的样式后应该会在一两帧内得到应用,然而实际测试发现有时会需要近1秒的时间才应用新样式,能感到明显的延迟现象。

有没有考虑过做脚本语言绑定?

恩,就是不知道你的学习机的速度能不能跑脚本……介绍一下Lua:

编译以后总大小140K左右,占运行内存大概400K左右,速度上,大概比C慢50倍左右。

如果你的学习机跑的是linux,可以将你的LCUI编译为Lua的一个so库,在Lua中载入,可以支持所有功能。

脚本语言优势:

  1. 快速开发:可以很快实现一个Demo,修改代码十分容易
  2. 编写简单:代码量比C/C++等静态语言少,写起来快
  3. 原型设计:很快能设计最终产品的一个原型
  4. 效率评估:脚本语言比C慢,很容易显示出效率瓶颈的位置,可以在该位置用C优化
  5. 架构评估:可以根据绑定时遇到的问题,判断架构本身是否良好。

恩,有兴趣可以去看看:www.lua.org

An error occured when compiling a LCUI's sample on CentOS

I successfully compiled and installed LCUI library on CentOS 6.4 x86_64 (in the Oracle VirtualBox), but an error occured when compiling the "helloworld" sample (./test/helloworld.c).

LCUI version is the latest release: 0.15.

[root@bogon test]# gcc helloworld.c -l LCUI
/usr/local/lib/libLCUI.so: undefined reference to `clock_gettime'
collect2: ld 返回 1

GCC VERSION: 4.4.7

Thank you for the LCUI project and I wonder if you can help me.

触屏的问题

如题,在LCUI初始化时检测触摸屏并启用触摸屏支持后,程序出现段错误后终止。

Copying permission statement at the beginning of the files

Some files like LCUI_Font.h and LCUI_Input.h have redundant "\n" at the end of lines of copying permission statement. What is worse, they use horizontal tab to align, so the "\n" are often unaligned when the text editor configuration varies.
In some files like LCUI_InputMethod.h it is just missing.

x64转换警告

使用VC++ x64编译出现大量warning C4267:

warning C4267: “=”: 从“size_t”转换到“int”,可能丢失数据
warning C4267: “return”: 从“size_t”转换到“int”,可能丢失数据
warning C4267: “=”: 从“size_t”转换到“unsigned int”,可能丢失数据
warning C4267: “=”: 从“size_t”转换到“int”,可能丢失数据
warning C4267: “初始化”: 从“size_t”转换到“int”,可能丢失数据
warning C4267: “函数”: 从“size_t”转换到“int”,可能丢失数据
warning C4267: “=”: 从“size_t”转换到“uint_t”,可能丢失数据

虽然x64看来没有被正式支持,不过还是暴露出一些可移植性问题。

需更改链表的遍历方式

当前是直接使用 LinkedList_ForEach() 宏来遍历链表的,但在 VisualStudio 中会把它当成函数定义,导致它所在的函数无法被索引。

qq 20160813135755

改进部件的排序

当部件数量达到上万级别的时候排序操作会非常耗时,在当前版本中,每个部件都会排序一次,排序算法为插入排序,一万个部件会排序一万次,而每次排序都要遍历一次部件列表,总计遍历一亿次。

Possible name clash

According to ISO C11 7.31.6, macros that begin with LC_ and an uppercase letter may be used by the implementation. Though they are not explicitly reserved by ISO C(e.g. as identifiers containing double underscores), there are risks.
Furthermore, POSIX.1-2013 explicitly states that the names with prefix LC_[A-Z] are reserved once the header <locale.h> is included. That means if the client code uses both <locale.h> and LCUI, it could never be conforming to POSIX.

malloc(): memory corruption (fast): 0x00007f5efe9e1710

#include <LCUI_Build.h>
#include LC_LCUI_H
#include LC_WIDGET_H 
#include LC_WINDOW_H
#include LC_BUTTON_H

static void
destroy( LCUI_Widget *widget, LCUI_WidgetEvent *unused )
{
    LCUI_MainLoop_Quit(NULL);
}

int main(void) 
{
    LCUI_Widget *window, *button;

    setenv( "LCUI_FONTFILE", "/home/zhuzx/NetBeansProjects/CGUI/fonts/simfang.ttf", FALSE );
    LCUI_Init();
    window  = Widget_New("window");
    button  = Widget_New("button");

    /* 设定窗口标题的文本 */
    Window_SetTitleText(window, "测试按钮"); 
    /* 改变窗口的尺寸 */
    Widget_Resize( window, Size(320, 240) );
    /* 将窗口客户区作为按钮的容器添加进去 */
    Window_ClientArea_Add( window, button );
    /* 居中显示按钮 */
    Widget_SetAlign( button, ALIGN_MIDDLE_CENTER, Pos(0, 0) );
    /* 禁用部件的自动尺寸调整 */
    Widget_SetAutoSize( button, FALSE, 0 );
    /* 自定义按钮的尺寸 */
    Widget_Resize( button, Size(180, 70) );

    /* 设定按钮上显示的文本内容,和label部件的用法一样,支持样式标签 */
    Button_Text( button, 
        "<size=30px><color=255,0,0>彩</color>"
        "<color=0,255,0>色</color>"
        "<color=0,0,255>的</color>"
        "<color=255,255,0>按</color>"
        "<color=255,255,255>钮</color></size>");

    /* 显示部件 */
    Widget_Show( button );
    Widget_Show( window ); 
    Widget_Event_Connect( Window_GetCloseButton(window), EVENT_CLICKED, destroy );
    return LCUI_Main(); /* 进入主循环 */
}

编译不了

github中的代码编译不了,代码不全?第一个错误是LCUI_ScreenInfo没定义,搜索了所有文件都没有该定义

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.