mirror of
https://github.com/lc-soft/LCUI.git
synced 2026-11-30 16:48:21 +01:00
refactor: update LCUI's dependencies on ui-widgets and ui-router
This commit is contained in:
@@ -57,8 +57,8 @@ jobs:
|
||||
xmake build yutil_test
|
||||
xmake build pandagl_tests
|
||||
xmake build libcss_tests
|
||||
xmake build libui-router-tests
|
||||
xmake build libi18n-tests
|
||||
xmake build librouter_tests
|
||||
xmake build libi18n_tests
|
||||
xmake build lcui_tests
|
||||
|
||||
- name: Run tests for libraries with memcheck
|
||||
@@ -67,8 +67,8 @@ jobs:
|
||||
xmake run pandagl_tests
|
||||
xmake run yutil_test --memcheck
|
||||
xmake run libcss_tests --memcheck
|
||||
xmake run libui-router-tests --memcheck
|
||||
xmake run libi18n-tests --memcheck
|
||||
xmake run librouter_tests --memcheck
|
||||
xmake run libi18n_tests --memcheck
|
||||
|
||||
- name: Run tests for lcui with memcheck
|
||||
if: runner.os == 'Linux'
|
||||
@@ -81,8 +81,8 @@ jobs:
|
||||
xmake run pandagl_tests
|
||||
xmake run yutil_test
|
||||
xmake run libcss_tests
|
||||
xmake run libui-router-tests
|
||||
xmake run libi18n-tests
|
||||
xmake run librouter_tests
|
||||
xmake run libi18n_tests
|
||||
xmake run lcui_tests
|
||||
|
||||
- name: Upload reports to Codecov
|
||||
|
||||
@@ -67,9 +67,6 @@ vendor/lib
|
||||
build/*.png
|
||||
build/*.jpg
|
||||
config.h
|
||||
!lib/ui-router/include/ui_router/config.h
|
||||
test/build
|
||||
lcpkg/*
|
||||
!lcpkg/ports
|
||||
vsxmake*
|
||||
compile_commands.json
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
- [Table of contents](#table-of-contents)
|
||||
- [Introduction](#introduction)
|
||||
- [Main Features](#main-features)
|
||||
- [Overview of Features](#overview-of-features)
|
||||
- [Key Features](#key-features)
|
||||
- [Development Experience Preview](#development-experience-preview)
|
||||
- [Architecture](#architecture)
|
||||
- [Quick Start](#quick-start)
|
||||
- [Documentation](#documentation)
|
||||
@@ -42,13 +42,13 @@ LCUI is a library written in C for building graphical user interfaces. Its goal
|
||||
|
||||
**LC** originates from the initials of the author's name. The library was initially designed to help the author develop small projects and gain development experience. However, the author did not gain a competitive advantage in the job market, which is crowded with C/C++ experts, and thus had to work in web front-end development. As a result, LCUI now leans towards integrating technologies from the web front-end domain.
|
||||
|
||||
### Key Features
|
||||
### Key Features
|
||||
|
||||
- **Cross-platform:** Supports Windows and Linux.
|
||||
- **Fully custom-drawn components:** Ensures consistent appearance and behavior of components across platforms.
|
||||
- **DPI awareness:** Automatically scales the UI on high-resolution screens to maintain a clear display.
|
||||
- **Built-in CSS engine:** Enables the use of CSS for defining UI styles and layouts, making it easier for developers with web development experience to get started.
|
||||
- **Modern development tools:** Includes tools that allow you to build user interfaces using [TypeScript](https://lcui-dev.github.io/docs/guide/typescript) with JSX syntax, the React library, and other web frontend technologies.
|
||||
- **Cross-platform:** Supports Windows and Linux.
|
||||
- **Fully custom-drawn components:** Ensures consistent appearance and behavior of components across platforms.
|
||||
- **DPI awareness:** Automatically scales the UI on high-resolution screens to maintain a clear display.
|
||||
- **Built-in CSS engine:** Enables the use of CSS for defining UI styles and layouts, making it easier for developers with web development experience to get started.
|
||||
- **Modern development tools:** Includes tools that allow you to build user interfaces using [TypeScript](https://lcui-dev.github.io/docs/guide/typescript) with JSX syntax, the React library, and other web frontend technologies.
|
||||
|
||||
### Development Experience Preview
|
||||
|
||||
@@ -56,7 +56,7 @@ You can get an overview of the development experience for LCUI applications from
|
||||
|
||||

|
||||
|
||||
- **Component Development in React-like Style:** Writing UI configuration files using TypeScript. With the combined advantages of TypeScript, JSX syntax, and the LCUI React library, you can succinctly describe interface structure, resource dependencies, component states, data binding, and event binding.
|
||||
- **Component Development in React-like Style:** Writing UI configuration files using TypeScript. With the combined advantages of TypeScript, JSX syntax, and the LCUI React library, you can succinctly describe UI structure, resource dependencies, component states, data binding, and event binding.
|
||||
- **Various Stylesheet Writing Methods:** [Tailwind CSS](https://tailwindcss.com/), [CSS Modules](https://github.com/css-modules/css-modules), [Sass](https://sass-lang.com/), and global CSS.
|
||||
- **File-system based router:** Organize application pages in directory form, with each page corresponding to a directory. The path of the directory serves as the route for that page. With the built-in application router, you can easily implement page switching and navigation without manual route configuration.
|
||||
- **User-friendly and Modern Icon Library:** Icons are sourced from the [fluentui-system-icons](https://github.com/microsoft/fluentui-system-icons) library, with partial customization to fit LCUI's characteristics, offering similar usage patterns.
|
||||
@@ -66,18 +66,26 @@ You can get an overview of the development experience for LCUI applications from
|
||||
|
||||
Over time LCUI has been built up to be based on various libraries:
|
||||
|
||||
- [lib/yutil](./lib/yutil): Utility library providing common data structures and functions.
|
||||
- [lib/pandagl](./lib/pandagl): PandaGL (Panda Graphics Library), a graphics library offering font management, text layout, image processing, and rendering capabilities.
|
||||
- [lib/css](./lib/css): CSS parser and selector engine, enabling CSS parsing and selection functionalities.
|
||||
- [lib/ptk](./lib/ptk): Platform Toolkit library offering cross-platform unified system-related APIs, including message loops, window management, timers, worker threads, and input methods.
|
||||
- [lib/thread](./lib/thread): Thread library offering cross-platform multithreading capabilities.
|
||||
- [lib/ui](./lib/ui): Core UI library that manages UI components, event queues, style computation, drawing, and other essential UI functionalities.
|
||||
- [lib/ui-xml](./lib/ui-xml): XML parsing library enabling the creation of UI components from XML file content.
|
||||
- [lib/ui-cursor](./lib/ui-cursor): Cursor library providing cursor rendering capabilities.
|
||||
- [lib/ui-server](./lib/ui-server): UI server that maps UI components to system windows.
|
||||
- [lib/ui-router](./lib/ui-router): Router manager offering routing and navigation functionalities.
|
||||
- [lib/ui-widgets](./lib/ui/widgets): Predefined basic component library offering essential UI components such as text, buttons, and scrollbars.
|
||||
- [lib/worker](./lib/worker): Worker thread library providing simple communication and management for worker threads.
|
||||
- [lib/yutil](./lib/yutil): Utility library providing common data structures and functions.
|
||||
- [lib/pandagl](./lib/pandagl): PandaGL (Panda Graphics Library), a graphics library offering font management, text layout, image processing, and rendering capabilities.
|
||||
- [lib/css](./lib/css): CSS parser and selector engine, enabling CSS parsing and selection functionalities.
|
||||
- [lib/ptk](./lib/ptk): Platform Toolkit library offering cross-platform unified system-related APIs, including message loops, window management, timers, worker threads, and input methods.
|
||||
- [lib/thread](./lib/thread): Thread library offering cross-platform multithreading capabilities.
|
||||
- [lib/router](./lib/ui-router): Router manager offering routing and navigation functionalities.
|
||||
- [lib/worker](./lib/worker): Worker thread library providing simple communication and management for worker threads.
|
||||
- [lib/ui](./lib/ui): Core UI library that manages UI components, event queues, style computation, drawing, and other essential UI functionalities.
|
||||
- [lib/ui-xml](./lib/ui-xml): XML parsing library enabling the creation of UI components from XML file content.
|
||||
- [lib/ui-cursor](./lib/ui-cursor): Cursor library providing cursor rendering capabilities.
|
||||
- [lib/ui-server](./lib/ui-server): UI server that maps UI components to system windows.
|
||||
|
||||
The core source code of LCUI is located in the `src/` directory and is divided into the following modules:
|
||||
|
||||
- **app:** Application lifecycle, event, and UI management.
|
||||
- **fonts:** Default font settings.
|
||||
- **settings:** Global settings, providing switches and parameter configurations for certain features.
|
||||
- **ui:** UI and window management.
|
||||
- **widgets:** Predefined components.
|
||||
- **worker:** Asynchronous task management.
|
||||
|
||||
## Quick Start
|
||||
|
||||
@@ -108,9 +116,9 @@ Follow the prompts provided by the commands afterward.
|
||||
|
||||
### Tutorials
|
||||
|
||||
- [Todo List](https://lcui-dev.github.io/docs/next/tutorials/todolist): Learn the basic concepts and usage of LCUI, as well as how to use it to build interfaces and implement state management, interface updates, and interactions.
|
||||
- [Todo List](https://lcui-dev.github.io/docs/next/tutorials/todolist): Learn the basic concepts and usage of LCUI, as well as how to use it to build UI and implement state management, UI updates, and interactions.
|
||||
- [Rendering Fabric Animation](https://lcui-dev.github.io/docs/next/tutorials/render-fabric): Rewrite the existing fabric simulation program's JavaScript source code in C language, and use the cairo graphics library for fabric rendering. Then, apply LCUI to implement fabric animation playback and interaction.
|
||||
- [Browser](https://lcui-dev.github.io/docs/next/tutorials/browser): Referencing a web browser, use LCUI to implement similar interface structure, layout, style, and multi-tab management features. Utilize LCUI's routing management functionality to implement multi-tab page state management and navigation, as well as a simple file browsing page. **(This tutorial is outdated, contributions to update it are welcome)**
|
||||
- [Browser](https://lcui-dev.github.io/docs/next/tutorials/browser): Referencing a web browser, use LCUI to implement similar UI structure, layout, style, and multi-tab management features. Utilize LCUI's routing management functionality to implement multi-tab page state management and navigation, as well as a simple file browsing page. **(This tutorial is outdated, contributions to update it are welcome)**
|
||||
|
||||
### References
|
||||
|
||||
@@ -124,25 +132,27 @@ Some features of LCUI and related projects are inspired by other open-source pro
|
||||
|
||||
Below are the items for potential future development:
|
||||
|
||||
- **LCUI**
|
||||
- Improve API design.
|
||||
- Enhance the CSS engine to support `inherit` and `!important`.
|
||||
- Add an [SDL](https://www.libsdl.org/) backend to replace the lib/ptk library.
|
||||
- Adapt other open-source graphics libraries to achieve better rendering performance.
|
||||
- Optimize memory usage.
|
||||
- Improve performance.
|
||||
- **LCUI**
|
||||
|
||||
- **Command-Line Tools**
|
||||
- `lcui build --watch`: Continuously monitor file changes and automatically rebuild.
|
||||
- `lcui dev-server`: Similar to webpack-dev-server, build LCUI applications as websites to allow developers to preview interfaces in the browser.
|
||||
- Add build caching to rebuild only the modified files.
|
||||
- Improve API design.
|
||||
- Enhance the CSS engine to support `inherit` and `!important`.
|
||||
- Add an [SDL](https://www.libsdl.org/) backend to replace the lib/ptk library.
|
||||
- Adapt other open-source graphics libraries to achieve better rendering performance.
|
||||
- Optimize memory usage.
|
||||
- Improve performance.
|
||||
|
||||
- **Command-Line Tools**
|
||||
|
||||
- `lcui build --watch`: Continuously monitor file changes and automatically rebuild.
|
||||
- `lcui dev-server`: Similar to webpack-dev-server, build LCUI applications as websites to allow developers to preview UI in the browser.
|
||||
- Add build caching to rebuild only the modified files.
|
||||
|
||||
- **React Component Library**
|
||||
Develop a component library for LCUI applications using TypeScript + React, inspired by some web frontend component libraries (e.g., [radix](https://www.radix-ui.com/), [shadcn/ui](https://ui.shadcn.com/)), and reuse components from the [LC Design](https://github.com/lcui-dev/lc-design) library.
|
||||
Develop a component library for LCUI applications using TypeScript + React, inspired by some web frontend component libraries (e.g., [radix](https://www.radix-ui.com/), [shadcn/ui](https://ui.shadcn.com/)), and reuse components from the [LC Design](https://github.com/lcui-dev/lc-design) library.
|
||||
|
||||
- **Documentation**
|
||||
- Tutorials
|
||||
- Request for Comments (RFC)
|
||||
- **Documentation**
|
||||
- Tutorials
|
||||
- Request for Comments (RFC)
|
||||
|
||||
## Contribution
|
||||
|
||||
@@ -158,19 +168,20 @@ Think LCUI is slow to update? there are many ways to [contribute](.github/CONTRI
|
||||
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](CODE_OF_CONDUCT.md).
|
||||
|
||||
## FAQ
|
||||
**Is this a browser engine? Or a development library like Electron that integrates a browser environment?**
|
||||
|
||||
No, you can think of it as a traditional GUI development library that incorporates some web technologies.
|
||||
**Is this a browser engine? Or a development library like Electron that integrates a browser environment?**
|
||||
|
||||
**Why should I choose LCUI over other GUI libraries/frameworks?**
|
||||
No, you can think of it as a traditional GUI development library that incorporates some web technologies.
|
||||
|
||||
It's recommended to prioritize other GUI libraries/frameworks, as LCUI currently lacks:
|
||||
**Why should I choose LCUI over other GUI libraries/frameworks?**
|
||||
|
||||
- **A rich set of built-in components:** You will need to build almost all the components in your interface from scratch, leading to higher development costs.
|
||||
- **Efficient graphics rendering performance:** Interfaces with extensive and complex content may experience lag.
|
||||
- **An animation system:** The lack of visual feedback affects the user interaction experience.
|
||||
It's recommended to prioritize other GUI libraries/frameworks, as LCUI currently lacks:
|
||||
|
||||
Given its current state, LCUI is best suited for fulfilling the author's personal needs or developing simple tools with minimal interface content and interactions.
|
||||
- **A rich set of built-in components:** You will need to build almost all the components in your UI from scratch, leading to higher development costs.
|
||||
- **Efficient graphics rendering performance:** Interfaces with extensive and complex content may experience lag.
|
||||
- **An animation system:** The lack of visual feedback affects the user interaction experience.
|
||||
|
||||
Given its current state, LCUI is best suited for fulfilling the author's personal needs or developing simple tools with minimal UI content and interactions.
|
||||
|
||||
**Support development with TypeScript? If I know how to use it, why wouldn’t I just go with Electron?**
|
||||
|
||||
@@ -279,4 +290,4 @@ The following is a list of supported CSS features. Checked is supported (But doe
|
||||
|
||||
## License
|
||||
|
||||
The LCUI Project is released under [the MIT License]((https://opensource.org/licenses/MIT)).
|
||||
The LCUI Project is released under [the MIT License](<(https://opensource.org/licenses/MIT)>).
|
||||
|
||||
+11
-3
@@ -69,13 +69,21 @@ LCUI 建立在各种库的基础之上:
|
||||
- [lib/css](./lib/css): CSS 解析器和选择引擎,提供 CSS 解析和选择能力。
|
||||
- [lib/ptk](./lib/ptk): 平台库(**P**ing **T**ai **K**u),提供跨平台统一的系统相关 API,包括消息循环、窗口管理、定时器、工作线程、输入法等。
|
||||
- [lib/thread](./lib/thread): 线程库,提供跨平台的多线程能力。
|
||||
- [lib/router](./lib/ui-router): 路由管理器,提供路由映射和导航能力。
|
||||
- [lib/worker](./lib/worker): 工作线程库,提供基础的工作线程管理和异步任务管理能力。
|
||||
- [lib/ui](./lib/ui): UI 核心库,提供 UI 组件管理、事件队列、样式计算、绘制等 UI 必要能力。
|
||||
- [lib/ui-xml](./lib/anchor): XML 解析库,提供从 XML 文件内容创建 UI 的能力。
|
||||
- [lib/ui-cursor](./lib/ui-cursor): 光标,提供光标绘制能力。
|
||||
- [lib/ui-server](./lib/ui-server): UI 服务器,提供将 UI 组件映射至系统窗口的能力。
|
||||
- [lib/ui-router](./lib/ui-router): 路由管理器,提供路由映射和导航能力。
|
||||
- [lib/ui-widgets](./lib//ui/widgets): 预置的基础组件库,提供文本、按钮、滚动条等一些基础的 UI 组件。
|
||||
- [lib/worker](./lib/worker): 工作线程库,提供简单的工作线程通信和管理能力。
|
||||
|
||||
LCUI 的核心源码位于 `src/` 目录,划分为以下几个功能模块:
|
||||
|
||||
- **app:** 应用的生命周期、事件 和 UI 管理。
|
||||
- **fonts:** 默认字体设置。
|
||||
- **settings:** 全局设置,提供部分功能的开关和参数设置。
|
||||
- **ui:** UI 和窗口管理。
|
||||
- **widgets:** 预置的组件。
|
||||
- **worker:** 异步任务管理。
|
||||
|
||||
## 快速体验
|
||||
|
||||
|
||||
+5
-1
@@ -13,11 +13,15 @@
|
||||
#include <css.h>
|
||||
#include <pandagl.h>
|
||||
#include <ui.h>
|
||||
#include <ui_widgets.h>
|
||||
#include <ui_cursor.h>
|
||||
#include <ui_server.h>
|
||||
#include <ui_xml.h>
|
||||
#include <thread.h>
|
||||
#include <ptk.h>
|
||||
#include <worker.h>
|
||||
#include <LCUI/worker.h>
|
||||
#include <LCUI/app.h>
|
||||
#include <LCUI/ui.h>
|
||||
#include <LCUI/widgets.h>
|
||||
#include <LCUI/settings.h>
|
||||
#include <LCUI/base.h>
|
||||
|
||||
+6
-87
@@ -13,96 +13,15 @@
|
||||
#define LCUI_INCLUDE_LCUI_APP_H
|
||||
|
||||
#include "common.h"
|
||||
#include <ptk.h>
|
||||
#include <worker.h>
|
||||
|
||||
#define LCUI_MAX_FRAMES_PER_SEC 120
|
||||
#define LCUI_MAX_FRAME_MSEC ((int)(1000.0 / LCUI_MAX_FRAMES_PER_SEC + 0.5))
|
||||
#include <ptk/types.h>
|
||||
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
// Settings
|
||||
|
||||
typedef struct lcui_settings {
|
||||
int frame_rate_cap;
|
||||
int parallel_rendering_threads;
|
||||
bool paint_flashing;
|
||||
} lcui_settings_t;
|
||||
|
||||
/* Initialize settings with the current global settings. */
|
||||
LCUI_API void lcui_get_settings(lcui_settings_t *settings);
|
||||
|
||||
/* Update global settings with the given input. */
|
||||
LCUI_API void lcui_apply_settings(lcui_settings_t *settings);
|
||||
|
||||
/* Reset global settings to their defaults. */
|
||||
LCUI_API void lcui_reset_settings(void);
|
||||
|
||||
// Tasks
|
||||
|
||||
LCUI_API worker_task_t *lcui_post_task(void *data, worker_task_cb task_cb,
|
||||
worker_task_cb after_task_cb);
|
||||
LCUI_API worker_task_t *lcui_post_async_task(void *data, worker_task_cb task_cb,
|
||||
worker_task_cb after_task_cb);
|
||||
|
||||
bool lcui_cancel_async_task(worker_task_t *task);
|
||||
bool lcui_cancel_task(worker_task_t *task);
|
||||
|
||||
// UI
|
||||
|
||||
typedef enum lcui_display_mode_t {
|
||||
LCUI_DISPLAY_MODE_DEFAULT,
|
||||
LCUI_DISPLAY_MODE_WINDOWED,
|
||||
LCUI_DISPLAY_MODE_FULLSCREEN,
|
||||
LCUI_DISPLAY_MODE_SEAMLESS,
|
||||
} lcui_display_mode_t;
|
||||
|
||||
LCUI_API void lcui_init_ui(void);
|
||||
LCUI_API void lcui_destroy_ui(void);
|
||||
LCUI_API void lcui_update_ui(void);
|
||||
LCUI_API size_t lcui_render_ui(void);
|
||||
LCUI_API void lcui_preset_ui(void);
|
||||
LCUI_API void lcui_dispatch_ui_event(ptk_event_t *app_event);
|
||||
LCUI_API void lcui_set_ui_display_mode(lcui_display_mode_t mode);
|
||||
|
||||
// Event
|
||||
|
||||
LCUI_API int lcui_get_event(ptk_event_t *e);
|
||||
LCUI_API int lcui_process_event(ptk_event_t *e);
|
||||
LCUI_API int lcui_process_events(ptk_process_events_option_t option);
|
||||
|
||||
INLINE int lcui_process_all_events(void)
|
||||
{
|
||||
return lcui_process_events(PTK_PROCESS_EVENTS_ALL_IF_PRESENT);
|
||||
}
|
||||
|
||||
// Base
|
||||
|
||||
LCUI_API uint32_t lcui_get_fps(void);
|
||||
|
||||
LCUI_API void lcui_set_frame_rate_cap(unsigned rate_cap);
|
||||
|
||||
LCUI_API void lcui_init_app(void);
|
||||
LCUI_API void lcui_destroy_app(void);
|
||||
|
||||
/** 初始化 LCUI 各项功能 */
|
||||
LCUI_API void lcui_init(void);
|
||||
|
||||
LCUI_API int lcui_main(void);
|
||||
|
||||
LCUI_API int lcui_run(void);
|
||||
|
||||
/** 获取LCUI的版本 */
|
||||
LCUI_API const char *lcui_get_version(void);
|
||||
|
||||
/** 释放LCUI占用的资源 */
|
||||
LCUI_API void lcui_destroy(void);
|
||||
|
||||
/** 退出LCUI,释放LCUI占用的资源 */
|
||||
LCUI_API void lcui_quit(void);
|
||||
|
||||
/** 退出 LCUI,并设置退出码 */
|
||||
LCUI_API void lcui_exit(int code);
|
||||
LCUI_API uint32_t lcui_app_get_fps(void);
|
||||
LCUI_API void lcui_app_set_frame_rate_cap(unsigned rate_cap);
|
||||
LCUI_API int lcui_app_process_events(ptk_process_events_option_t option);
|
||||
LCUI_API void lcui_app_init(void);
|
||||
LCUI_API void lcui_app_destroy(void);
|
||||
|
||||
LCUI_END_HEADER
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* include/LCUI/base.h
|
||||
*
|
||||
* Copyright (c) 2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LCUI_INCLUDE_LCUI_BASE_H
|
||||
#define LCUI_INCLUDE_LCUI_BASE_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
LCUI_API const char *lcui_get_version(void);
|
||||
|
||||
LCUI_API void lcui_init(void);
|
||||
|
||||
LCUI_API void lcui_destroy(void);
|
||||
|
||||
LCUI_API int lcui_run(void);
|
||||
|
||||
LCUI_API int lcui_main(void);
|
||||
|
||||
LCUI_API void lcui_exit(int code);
|
||||
|
||||
LCUI_API void lcui_quit(void);
|
||||
|
||||
LCUI_END_HEADER
|
||||
|
||||
#endif
|
||||
@@ -12,6 +12,7 @@
|
||||
#ifndef LCUI_INCLUDE_LCUI_COMMON_H
|
||||
#define LCUI_INCLUDE_LCUI_COMMON_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "config.h"
|
||||
|
||||
#ifndef LCUI_API
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* include/LCUI/settings.h
|
||||
*
|
||||
* Copyright (c) 2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LCUI_INCLUDE_LCUI_SETTINGS_H
|
||||
#define LCUI_INCLUDE_LCUI_SETTINGS_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define LCUI_MAX_FRAMES_PER_SEC 120
|
||||
#define LCUI_MAX_FRAME_MSEC ((int)(1000.0 / LCUI_MAX_FRAMES_PER_SEC + 0.5))
|
||||
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
typedef struct lcui_settings {
|
||||
int frame_rate_cap;
|
||||
int parallel_rendering_threads;
|
||||
bool paint_flashing;
|
||||
} lcui_settings_t;
|
||||
|
||||
/* Initialize settings with the current global settings. */
|
||||
LCUI_API void lcui_get_settings(lcui_settings_t *settings);
|
||||
|
||||
/* Update global settings with the given input. */
|
||||
LCUI_API void lcui_apply_settings(lcui_settings_t *settings);
|
||||
|
||||
/* Reset global settings to their defaults. */
|
||||
LCUI_API void lcui_reset_settings(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* include/LCUI/ui.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LCUI_INCLUDE_UI_H
|
||||
#define LCUI_INCLUDE_UI_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
typedef enum {
|
||||
LCUI_DISPLAY_DEFAULT,
|
||||
LCUI_DISPLAY_WINDOWED,
|
||||
LCUI_DISPLAY_FULLSCREEN,
|
||||
LCUI_DISPLAY_SEAMLESS,
|
||||
} lcui_display_t;
|
||||
|
||||
LCUI_API size_t lcui_ui_render(void);
|
||||
|
||||
LCUI_API void lcui_ui_update(void);
|
||||
|
||||
LCUI_API void lcui_ui_set_display(lcui_display_t mode);
|
||||
|
||||
LCUI_API void lcui_ui_init(void);
|
||||
|
||||
LCUI_API void lcui_ui_destroy(void);
|
||||
|
||||
LCUI_END_HEADER
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* include/LCUI/widgets.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "widgets/text.h"
|
||||
#include "widgets/button.h"
|
||||
#include "widgets/anchor.h"
|
||||
#include "widgets/canvas.h"
|
||||
#include "widgets/scrollarea.h"
|
||||
#include "widgets/scrollbar.h"
|
||||
#include "widgets/textinput.h"
|
||||
#include "widgets/textcaret.h"
|
||||
#include "widgets/router_link.h"
|
||||
#include "widgets/router_view.h"
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* include/LCUI/widgets/anchor.h: to <a> element in HTML.
|
||||
*
|
||||
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LCUI_INCLUDE_WIDGETS_ANCHOR_H
|
||||
#define LCUI_INCLUDE_WIDGETS_ANCHOR_H
|
||||
|
||||
#include <LCUI/common.h>
|
||||
#include <ui.h>
|
||||
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
LCUI_API void ui_anchor_open(ui_widget_t* w);
|
||||
|
||||
LCUI_API void ui_register_anchor(void);
|
||||
|
||||
LCUI_API void ui_unregister_anchor(void);
|
||||
|
||||
LCUI_END_HEADER
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* include/LCUI/widgets/button.h: -- LCUI‘s Button widget
|
||||
*
|
||||
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LCUI_INCLUDE_WIDGETS_BUTTON_H
|
||||
#define LCUI_INCLUDE_WIDGETS_BUTTON_H
|
||||
|
||||
#include <LCUI/common.h>
|
||||
#include <ui.h>
|
||||
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
LCUI_API void ui_button_set_text_w(ui_widget_t* w, const wchar_t *wstr);
|
||||
|
||||
LCUI_API void ui_button_set_text(ui_widget_t* w, const char *str);
|
||||
|
||||
LCUI_API void ui_register_button(void);
|
||||
|
||||
LCUI_END_HEADER
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-widgets/include/ui_widgets/canvas.h: -- canvas, used to draw custom graphics
|
||||
* include/LCUI/widgets/canvas.h: -- canvas, used to draw custom graphics
|
||||
*
|
||||
* Copyright (c) 2019-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
@@ -9,13 +9,13 @@
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_WIDGETS_INCLUDE_CANVAS_H
|
||||
#define LIB_UI_WIDGETS_INCLUDE_CANVAS_H
|
||||
#ifndef LCUI_INCLUDE_WIDGETS_CANVAS_H
|
||||
#define LCUI_INCLUDE_WIDGETS_CANVAS_H
|
||||
|
||||
#include <LCUI/common.h>
|
||||
#include <ui.h>
|
||||
#include "ui_widgets/common.h"
|
||||
|
||||
LIBUI_WIDGETS_BEGIN_DECLS
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
/** @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas#attributes */
|
||||
|
||||
@@ -55,10 +55,10 @@ typedef struct ui_canvas_rendering_context {
|
||||
* Get a drawing context on the canvas
|
||||
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext
|
||||
*/
|
||||
LIBUI_WIDGETS_PUBLIC ui_canvas_context_t *ui_canvas_get_context(ui_widget_t* w);
|
||||
LCUI_API ui_canvas_context_t *ui_canvas_get_context(ui_widget_t* w);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_register_canvas(void);
|
||||
LCUI_API void ui_register_canvas(void);
|
||||
|
||||
LIBUI_WIDGETS_END_DECLS
|
||||
LCUI_END_HEADER
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* include/LCUI/widgets/router_link.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LCUI_INCOIDE_ROUTER_LINK_H
|
||||
#define LCUI_INCOIDE_ROUTER_LINK_H
|
||||
|
||||
#include <ui/types.h>
|
||||
#include <router/types.h>
|
||||
#include <LCUI/common.h>
|
||||
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
LCUI_API void ui_router_link_set_location(
|
||||
ui_widget_t *w, router_location_t *location);
|
||||
|
||||
LCUI_API void ui_router_link_set_exact(ui_widget_t *w, bool exact);
|
||||
|
||||
LCUI_API void ui_register_router_link(void);
|
||||
|
||||
LCUI_END_HEADER
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* include/LCUI/widgets/router_view.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LCUI_INCOIDE_ROUTER_VIEW_H
|
||||
#define LCUI_INCOIDE_ROUTER_VIEW_H
|
||||
|
||||
#include <ui/types.h>
|
||||
#include <LCUI/common.h>
|
||||
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
LCUI_API ui_widget_t *ui_router_view_get_matched_widget(
|
||||
ui_widget_t *w);
|
||||
|
||||
LCUI_API void ui_register_router_view(void);
|
||||
|
||||
LCUI_END_HEADER
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* include/LCUI/widgets/scrollarea.h
|
||||
*
|
||||
* Copyright (c) 2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LCUI_INCLUDE_WIDGETS_SCROLLAREA_H
|
||||
#define LCUI_INCLUDE_WIDGETS_SCROLLAREA_H
|
||||
|
||||
#include <LCUI/common.h>
|
||||
#include <ui.h>
|
||||
|
||||
typedef enum {
|
||||
UI_SCROLLAREA_AUTO,
|
||||
UI_SCROLLAREA_VERTICAL,
|
||||
UI_SCROLLAREA_HORIZONTAL,
|
||||
} ui_scrollarea_direction_t;
|
||||
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
LCUI_API void ui_scrollarea_set_wheel_scroll_direction(
|
||||
ui_widget_t *w, ui_scrollarea_direction_t direction);
|
||||
|
||||
LCUI_API void ui_scrollarea_update(ui_widget_t *w);
|
||||
|
||||
LCUI_API void ui_register_scrollarea(void);
|
||||
|
||||
LCUI_API ui_widget_t *ui_create_scrollarea(void);
|
||||
|
||||
LCUI_API ui_widget_t *ui_create_scrollarea_content(void);
|
||||
|
||||
LCUI_API void ui_scrollarea_set_scroll_top(ui_widget_t *w,
|
||||
float value);
|
||||
|
||||
LCUI_API void ui_scrollarea_set_scroll_left(ui_widget_t *w,
|
||||
float value);
|
||||
|
||||
LCUI_API float ui_scrollarea_get_scroll_top(ui_widget_t *w);
|
||||
|
||||
LCUI_API float ui_scrollarea_get_scroll_left(ui_widget_t *w);
|
||||
|
||||
LCUI_API float ui_scrollarea_get_scroll_width(ui_widget_t *w);
|
||||
|
||||
LCUI_API float ui_scrollarea_get_scroll_height(ui_widget_t *w);
|
||||
|
||||
LCUI_END_HEADER
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* include/LCUI/widgets/scrollbar.h: -- LCUI's scrollbar widget
|
||||
*
|
||||
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LCUI_INCLUDE_WIDGETS_SCROLLBAR_H
|
||||
#define LCUI_INCLUDE_WIDGETS_SCROLLBAR_H
|
||||
|
||||
#include <LCUI/common.h>
|
||||
#include <ui.h>
|
||||
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
typedef enum {
|
||||
UI_SCROLLBAR_HORIZONTAL,
|
||||
UI_SCROLLBAR_VERTICAL
|
||||
} ui_scrollbar_orientation_t;
|
||||
|
||||
LCUI_API void ui_scrollbar_update(ui_widget_t *w);
|
||||
|
||||
LCUI_API void ui_scrollbar_set_orientation(ui_widget_t* w,
|
||||
ui_scrollbar_orientation_t orientation);
|
||||
|
||||
LCUI_API ui_widget_t *ui_create_scrollbar(void);
|
||||
|
||||
LCUI_API void ui_register_scrollbar(void);
|
||||
|
||||
LCUI_END_HEADER
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* include/LCUI/widgets/text.h: -- TextView widget for display
|
||||
*
|
||||
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LCUI_INCLUDE_WIDGETS_TEXT_H
|
||||
#define LCUI_INCLUDE_WIDGETS_TEXT_H
|
||||
|
||||
#include <LCUI/common.h>
|
||||
#include <ui.h>
|
||||
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
LCUI_API int ui_text_set_content_w(ui_widget_t *w,
|
||||
const wchar_t *text);
|
||||
|
||||
LCUI_API size_t ui_text_get_content_w(ui_widget_t *w, wchar_t *buf,
|
||||
size_t size);
|
||||
|
||||
LCUI_API int ui_text_set_content(ui_widget_t *w,
|
||||
const char *utf8_text);
|
||||
|
||||
LCUI_API void ui_text_set_multiline(ui_widget_t *w, bool enable);
|
||||
|
||||
LCUI_API void ui_register_text(void);
|
||||
|
||||
LCUI_API void ui_unregister_text(void);
|
||||
|
||||
LCUI_END_HEADER
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* include/LCUI/widgets/textcaret.h: -- textcaret widget, used in textinput.
|
||||
*
|
||||
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LCUI_INCLUDE_WIDGETS_TEXTCARET_H
|
||||
#define LCUI_INCLUDE_WIDGETS_TEXTCARET_H
|
||||
|
||||
#include <LCUI/common.h>
|
||||
#include <ui.h>
|
||||
|
||||
LCUI_API void ui_textcaret_refresh(ui_widget_t* widget);
|
||||
|
||||
LCUI_API void ui_textcaret_set_visible(ui_widget_t* widget, bool visible);
|
||||
|
||||
/** 设置闪烁的时间间隔 */
|
||||
LCUI_API void ui_textcaret_set_blink_time(ui_widget_t* widget, unsigned int n_ms);
|
||||
|
||||
LCUI_API void ui_register_textcaret(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* include/LCUI/widgets/textinput.h: -- textinput widget, used to allow user edit text.
|
||||
*
|
||||
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LCUI_INCLUDE_WIDGETS_TEXTINPUT_H
|
||||
#define LCUI_INCLUDE_WIDGETS_TEXTINPUT_H
|
||||
|
||||
#include <LCUI/common.h>
|
||||
#include <ui.h>
|
||||
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
/** Enable style tag parser */
|
||||
LCUI_API void ui_textinput_enable_style_tag(ui_widget_t* widget, bool enable);
|
||||
|
||||
LCUI_API void ui_textinput_enable_multiline(ui_widget_t* widget, bool enable);
|
||||
|
||||
LCUI_API void ui_textinput_move_caret(ui_widget_t* widget, int row, int col);
|
||||
|
||||
/** 清空文本内容 */
|
||||
LCUI_API void ui_textinput_clear_text(ui_widget_t* widget);
|
||||
|
||||
/** 获取文本内容 */
|
||||
LCUI_API size_t ui_textinput_get_text_w(ui_widget_t* w, size_t start,
|
||||
size_t max_len, wchar_t *buf);
|
||||
|
||||
/** 获取文本长度 */
|
||||
LCUI_API size_t ui_textinput_get_text_length(ui_widget_t* w);
|
||||
|
||||
/** 设置文本编辑框内的光标,指定是否闪烁、闪烁时间间隔 */
|
||||
LCUI_API void ui_textinput_set_caret_blink(ui_widget_t* w, bool visible, int time);
|
||||
|
||||
/** 为文本框设置文本(宽字符版) */
|
||||
LCUI_API int ui_textinput_set_text_w(ui_widget_t* widget, const wchar_t *wstr);
|
||||
|
||||
LCUI_API int ui_textinput_set_text(ui_widget_t* widget, const char *utf8_str);
|
||||
|
||||
/** 为文本框追加文本(宽字符版) */
|
||||
LCUI_API int ui_textinput_append_text_w(ui_widget_t* widget, const wchar_t *wstr);
|
||||
|
||||
/** 为文本框插入文本(宽字符版) */
|
||||
LCUI_API int ui_textinput_insert_text_w(ui_widget_t* widget, const wchar_t *wstr);
|
||||
|
||||
/** 设置占位符,当文本编辑框内容为空时显示占位符 */
|
||||
LCUI_API int ui_textinput_set_placeholder_w(ui_widget_t* w, const wchar_t *wstr);
|
||||
|
||||
LCUI_API int ui_textinput_set_placeholder(ui_widget_t* w, const char *str);
|
||||
|
||||
/** 设置密码屏蔽符 */
|
||||
LCUI_API void ui_textinput_set_password_char(ui_widget_t* w, wchar_t ch);
|
||||
|
||||
LCUI_API void ui_register_textinput(void);
|
||||
|
||||
LCUI_END_HEADER
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* include/LCUI/worker.h
|
||||
*
|
||||
* Copyright (c) 2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LCUI_INCLUDE_LCUI_WORKER_H
|
||||
#define LCUI_INCLUDE_LCUI_WORKER_H
|
||||
|
||||
#include "common.h"
|
||||
#include <worker.h>
|
||||
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
LCUI_API worker_task_t *lcui_worker_post_task(void *data,
|
||||
worker_task_cb task_cb,
|
||||
worker_task_cb after_task_cb);
|
||||
|
||||
LCUI_API worker_task_t *lcui_worker_post_async_task(
|
||||
void *data, worker_task_cb task_cb, worker_task_cb after_task_cb);
|
||||
|
||||
LCUI_API bool lcui_worker_cancel_async_task(worker_task_t *task);
|
||||
|
||||
LCUI_API bool lcui_worker_cancel_task(worker_task_t *task);
|
||||
|
||||
LCUI_API void lcui_worker_run(void);
|
||||
|
||||
LCUI_API void lcui_worker_init(void);
|
||||
|
||||
LCUI_API void lcui_worker_destroy(void);
|
||||
|
||||
LCUI_END_HEADER
|
||||
|
||||
#define lcui_post_task lcui_worker_post_task
|
||||
#define lcui_post_async_task lcui_worker_post_async_task
|
||||
#define lcui_cancel_task lcui_worker_cancel_task
|
||||
#define lcui_cancel_async_task lcui_worker_cancel_async_task
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* lib/css/src/keywords.c
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ target("libi18n")
|
||||
add_defines("LIBI18N_DLL_EXPORT")
|
||||
end
|
||||
|
||||
target("libi18n-tests")
|
||||
target("libi18n_tests")
|
||||
set_default(false)
|
||||
set_kind("binary")
|
||||
add_files("tests/test.c")
|
||||
|
||||
@@ -23,10 +23,10 @@ PTK_PUBLIC int ptk_app_init(const wchar_t *name);
|
||||
PTK_PUBLIC int ptk_app_destroy(void);
|
||||
PTK_PUBLIC void ptk_set_instance(void *instance);
|
||||
PTK_PUBLIC ptk_app_id_t ptk_get_app_id(void);
|
||||
PTK_PUBLIC void app_present(void);
|
||||
PTK_PUBLIC void ptk_app_present(void);
|
||||
PTK_PUBLIC int ptk_init(const wchar_t *name);
|
||||
PTK_PUBLIC int ptk_run(void);
|
||||
PTK_PUBLIC void app_exit(int exit_code);
|
||||
PTK_PUBLIC void ptk_app_exit(int exit_code);
|
||||
PTK_PUBLIC void ptk_destroy(void);
|
||||
|
||||
PTK_END_DECLS
|
||||
|
||||
@@ -166,12 +166,12 @@ ptk_window_t *ptk_window_create(const wchar_t *title, int x, int y, int width,
|
||||
return linux_app.app.create_window(title, x, y, width, height, parent);
|
||||
}
|
||||
|
||||
void app_present(void)
|
||||
void ptk_app_present(void)
|
||||
{
|
||||
linux_app.app.present();
|
||||
}
|
||||
|
||||
void app_exit(int exit_code)
|
||||
void ptk_app_exit(int exit_code)
|
||||
{
|
||||
linux_app.app.exit(exit_code);
|
||||
}
|
||||
|
||||
@@ -698,7 +698,7 @@ ptk_app_id_t ptk_get_app_id(void)
|
||||
return PTK_APP_ID_WIN32;
|
||||
}
|
||||
|
||||
void app_present(void)
|
||||
void ptk_app_present(void)
|
||||
{
|
||||
list_node_t *node;
|
||||
|
||||
@@ -740,7 +740,7 @@ int ptk_app_init(const wchar_t *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void app_exit(int exit_code)
|
||||
void ptk_app_exit(int exit_code)
|
||||
{
|
||||
PostQuitMessage(exit_code);
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
!config.h
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* lib/router/include/router.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <router/route.h>
|
||||
#include <router/route_record.h>
|
||||
#include <router/utils.h>
|
||||
#include <router/config.h>
|
||||
#include <router/history.h>
|
||||
#include <router/location.h>
|
||||
#include <router/strmap.h>
|
||||
#include <router/matcher.h>
|
||||
#include <router/router.h>
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* lib/router/include/router/common.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "version.h"
|
||||
#ifdef __cplusplus
|
||||
#define LIBROUTER_BEGIN_DECLS extern "C" {
|
||||
#define LIBROUTER_END_DECLS }
|
||||
#else
|
||||
#define LIBROUTER_BEGIN_DECLS
|
||||
#define LIBROUTER_END_DECLS
|
||||
#endif
|
||||
|
||||
#ifndef LIBROUTER_PUBLIC
|
||||
#if defined(_MSC_VER) && !defined(LIBROUTER_STATIC_BUILD)
|
||||
#ifdef LIBROUTER_DLL_EXPORT
|
||||
#define LIBROUTER_PUBLIC __declspec(dllexport)
|
||||
#else
|
||||
#define LIBROUTER_PUBLIC __declspec(dllimport)
|
||||
#endif
|
||||
#elif __GNUC__ >= 4
|
||||
#define LIBROUTER_PUBLIC extern __attribute__((visibility("default")))
|
||||
#else
|
||||
#define LIBROUTER_PUBLIC extern
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* lib/router/include/router/config.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_ROUTER_INCLUDE_ROUTER_CONFIG_H
|
||||
#define LIB_ROUTER_INCLUDE_ROUTER_CONFIG_H
|
||||
|
||||
#include <router/common.h>
|
||||
#include <router/types.h>
|
||||
|
||||
LIBROUTER_BEGIN_DECLS
|
||||
|
||||
LIBROUTER_PUBLIC router_config_t *router_config_create(void);
|
||||
|
||||
LIBROUTER_PUBLIC void router_config_destroy(router_config_t *config);
|
||||
|
||||
LIBROUTER_PUBLIC void router_config_set_name(router_config_t *config,
|
||||
const char *name);
|
||||
|
||||
LIBROUTER_PUBLIC void router_config_set_path(router_config_t *config,
|
||||
const char *path);
|
||||
|
||||
LIBROUTER_PUBLIC void router_config_set_component(router_config_t *config,
|
||||
const char *name,
|
||||
const char *component);
|
||||
|
||||
LIBROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* lib/router/include/router/history.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_ROUTER_INCLUDE_ROUTER_HISTORY_H
|
||||
#define LIB_ROUTER_INCLUDE_ROUTER_HISTORY_H
|
||||
|
||||
#include <router/common.h>
|
||||
#include <router/types.h>
|
||||
|
||||
LIBROUTER_BEGIN_DECLS
|
||||
|
||||
LIBROUTER_PUBLIC router_history_t *router_history_create(void);
|
||||
|
||||
LIBROUTER_PUBLIC void router_history_destroy(router_history_t *history);
|
||||
|
||||
LIBROUTER_PUBLIC router_watcher_t *router_history_watch(
|
||||
router_history_t *history, router_callback_t callback, void *data);
|
||||
|
||||
LIBROUTER_PUBLIC void router_history_unwatch(router_history_t *history,
|
||||
router_watcher_t *watcher);
|
||||
|
||||
LIBROUTER_PUBLIC void router_history_push(router_history_t *history,
|
||||
router_route_t *route);
|
||||
|
||||
LIBROUTER_PUBLIC void router_history_replace(router_history_t *history,
|
||||
router_route_t *route);
|
||||
|
||||
LIBROUTER_PUBLIC void router_history_go(router_history_t *history,
|
||||
int delta);
|
||||
|
||||
LIBROUTER_PUBLIC size_t
|
||||
router_history_get_index(const router_history_t *history);
|
||||
|
||||
LIBROUTER_PUBLIC size_t
|
||||
router_history_get_length(const router_history_t *history);
|
||||
|
||||
LIBROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-router/include/ui_router/location.h
|
||||
* lib/router/include/router/location.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
@@ -9,48 +9,48 @@
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_ROUTER_INCLUDE_UI_ROUTER_LOCATION_H
|
||||
#define LIB_UI_ROUTER_INCLUDE_UI_ROUTER_LOCATION_H
|
||||
#ifndef LIB_ROUTER_INCLUDE_ROUTER_LOCATION_H
|
||||
#define LIB_ROUTER_INCLUDE_ROUTER_LOCATION_H
|
||||
|
||||
#include <ui_router/common.h>
|
||||
#include <ui_router/types.h>
|
||||
#include <router/common.h>
|
||||
#include <router/types.h>
|
||||
|
||||
LIBUI_ROUTER_BEGIN_DECLS
|
||||
LIBROUTER_BEGIN_DECLS
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_location_t *router_location_create(const char *name,
|
||||
LIBROUTER_PUBLIC router_location_t *router_location_create(const char *name,
|
||||
const char *path);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_location_destroy(router_location_t *location);
|
||||
LIBROUTER_PUBLIC void router_location_destroy(router_location_t *location);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_location_set_name(router_location_t *location,
|
||||
LIBROUTER_PUBLIC void router_location_set_name(router_location_t *location,
|
||||
const char *name);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_location_t *router_location_duplicate(
|
||||
LIBROUTER_PUBLIC router_location_t *router_location_duplicate(
|
||||
const router_location_t *location);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_location_t *router_location_normalize(
|
||||
LIBROUTER_PUBLIC router_location_t *router_location_normalize(
|
||||
const router_location_t *raw, const router_route_t *current, bool append);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC int router_location_set_param(router_location_t *location,
|
||||
LIBROUTER_PUBLIC int router_location_set_param(router_location_t *location,
|
||||
const char *key,
|
||||
const char *value);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC const char *router_location_get_param(
|
||||
LIBROUTER_PUBLIC const char *router_location_get_param(
|
||||
const router_location_t *location, const char *key);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC int router_location_set_query(router_location_t *location,
|
||||
LIBROUTER_PUBLIC int router_location_set_query(router_location_t *location,
|
||||
const char *key,
|
||||
const char *value);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC const char *router_location_get_query(
|
||||
LIBROUTER_PUBLIC const char *router_location_get_query(
|
||||
const router_location_t *location, const char *key);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC const char *router_location_get_path(
|
||||
LIBROUTER_PUBLIC const char *router_location_get_path(
|
||||
const router_location_t *location);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC char *router_location_stringify(
|
||||
LIBROUTER_PUBLIC char *router_location_stringify(
|
||||
const router_location_t *location);
|
||||
|
||||
LIBUI_ROUTER_END_DECLS
|
||||
LIBROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* lib/router/include/router/matcher.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_ROUTER_INCLUDE_ROUTER_MATCHER_H
|
||||
#define LIB_ROUTER_INCLUDE_ROUTER_MATCHER_H
|
||||
|
||||
#include <router/common.h>
|
||||
#include <router/types.h>
|
||||
|
||||
LIBROUTER_BEGIN_DECLS
|
||||
|
||||
LIBROUTER_PUBLIC router_matcher_t *router_matcher_create(void);
|
||||
|
||||
LIBROUTER_PUBLIC void router_matcher_destroy(router_matcher_t *matcher);
|
||||
|
||||
LIBROUTER_PUBLIC router_route_t *router_matcher_match(
|
||||
router_matcher_t *matcher, const router_location_t *raw_location,
|
||||
const router_route_t *current_route);
|
||||
|
||||
LIBROUTER_PUBLIC router_route_record_t *router_matcher_add_route_record(
|
||||
router_matcher_t *matcher, const router_config_t *config,
|
||||
const router_route_record_t *parent);
|
||||
|
||||
LIBROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* lib/router/include/router/route.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_ROUTER_INCLUDE_ROUTER_ROUTE_H
|
||||
#define LIB_ROUTER_INCLUDE_ROUTER_ROUTE_H
|
||||
|
||||
#include <router/common.h>
|
||||
#include <router/types.h>
|
||||
|
||||
LIBROUTER_BEGIN_DECLS
|
||||
|
||||
LIBROUTER_PUBLIC router_route_t *router_route_create(
|
||||
const router_route_record_t *record, const router_location_t *location);
|
||||
|
||||
LIBROUTER_PUBLIC void router_route_destroy(router_route_t *route);
|
||||
|
||||
LIBROUTER_PUBLIC const router_route_record_t *
|
||||
router_route_get_matched_record(const router_route_t *route, size_t index);
|
||||
|
||||
LIBROUTER_PUBLIC const char *router_route_get_full_path(
|
||||
const router_route_t *route);
|
||||
|
||||
LIBROUTER_PUBLIC const char *router_route_get_path(
|
||||
const router_route_t *route);
|
||||
|
||||
LIBROUTER_PUBLIC const char *router_route_get_hash(
|
||||
const router_route_t *route);
|
||||
|
||||
LIBROUTER_PUBLIC const char *router_route_get_param(
|
||||
const router_route_t *route, const char *key);
|
||||
|
||||
LIBROUTER_PUBLIC const char *router_route_get_query(
|
||||
const router_route_t *route, const char *key);
|
||||
|
||||
LIBROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* lib/router/include/router/route_record.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_ROUTER_INCLUDE_ROUTER_ROUTE_RECORD_H
|
||||
#define LIB_ROUTER_INCLUDE_ROUTER_ROUTE_RECORD_H
|
||||
|
||||
#include <router/common.h>
|
||||
#include <router/types.h>
|
||||
|
||||
LIBROUTER_BEGIN_DECLS
|
||||
|
||||
LIBROUTER_PUBLIC router_route_record_t *router_route_record_create(void);
|
||||
|
||||
LIBROUTER_PUBLIC void router_route_record_destroy(
|
||||
router_route_record_t *record);
|
||||
|
||||
LIBROUTER_PUBLIC void router_route_record_set_path(
|
||||
router_route_record_t *record, const char *path);
|
||||
|
||||
LIBROUTER_PUBLIC const char *router_route_record_get_component(
|
||||
const router_route_record_t *record, const char *key);
|
||||
|
||||
LIBROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* lib/router/include/router/router.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_ROUTER_INCLUDE_ROUTER_ROUTER_H
|
||||
#define LIB_ROUTER_INCLUDE_ROUTER_ROUTER_H
|
||||
|
||||
#include <router/common.h>
|
||||
#include <router/types.h>
|
||||
|
||||
LIBROUTER_BEGIN_DECLS
|
||||
|
||||
LIBROUTER_PUBLIC router_t *router_create(const char *name);
|
||||
|
||||
LIBROUTER_PUBLIC void router_destroy(router_t *router);
|
||||
|
||||
LIBROUTER_PUBLIC router_route_record_t *router_add_route_record(
|
||||
router_t *router, const router_config_t *config,
|
||||
const router_route_record_t *parent);
|
||||
|
||||
LIBROUTER_PUBLIC router_route_t *router_match(
|
||||
router_t *router, const router_location_t *raw_location,
|
||||
const router_route_t *current_route);
|
||||
|
||||
LIBROUTER_PUBLIC router_route_record_t *router_get_matched_route_record(
|
||||
router_t *router, size_t index);
|
||||
|
||||
LIBROUTER_PUBLIC router_history_t *router_get_history(router_t *router);
|
||||
|
||||
LIBROUTER_PUBLIC router_watcher_t *router_watch(router_t *router,
|
||||
router_callback_t callback,
|
||||
void *data);
|
||||
|
||||
LIBROUTER_PUBLIC void router_unwatch(router_t *router,
|
||||
router_watcher_t *watcher);
|
||||
|
||||
LIBROUTER_PUBLIC router_resolved_t *router_resolve(
|
||||
router_t *router, router_location_t *location, bool append);
|
||||
|
||||
LIBROUTER_PUBLIC router_location_t *router_resolved_get_location(
|
||||
router_resolved_t *resolved);
|
||||
|
||||
LIBROUTER_PUBLIC router_route_t *router_resolved_get_route(
|
||||
router_resolved_t *resolved);
|
||||
|
||||
LIBROUTER_PUBLIC void router_resolved_destroy(router_resolved_t *resolved);
|
||||
|
||||
LIBROUTER_PUBLIC const router_route_t *router_get_current_route(
|
||||
router_t *router);
|
||||
|
||||
LIBROUTER_PUBLIC void router_push(router_t *router,
|
||||
router_location_t *location);
|
||||
|
||||
LIBROUTER_PUBLIC void router_replace(router_t *router,
|
||||
router_location_t *location);
|
||||
|
||||
LIBROUTER_PUBLIC void router_go(router_t *router, int delta);
|
||||
|
||||
LIBROUTER_PUBLIC void router_back(router_t *router);
|
||||
|
||||
LIBROUTER_PUBLIC void router_forward(router_t *router);
|
||||
|
||||
LIBROUTER_PUBLIC router_t *router_get_by_name(const char *name);
|
||||
|
||||
LIBROUTER_PUBLIC const char *router_get_version(void);
|
||||
|
||||
LIBROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* lib/router/include/router/strmap.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_ROUTER_INCLUDE_ROUTER_STRMAP_H
|
||||
#define LIB_ROUTER_INCLUDE_ROUTER_STRMAP_H
|
||||
|
||||
#include <router/common.h>
|
||||
#include <router/types.h>
|
||||
|
||||
LIBROUTER_BEGIN_DECLS
|
||||
|
||||
LIBROUTER_PUBLIC strmap_t *strmap_create(void);
|
||||
|
||||
LIBROUTER_PUBLIC void strmap_destroy(strmap_t *dict);
|
||||
|
||||
LIBROUTER_PUBLIC void strmap_delete(strmap_t *dict, const char *key);
|
||||
|
||||
LIBROUTER_PUBLIC int strmap_set(strmap_t *dict, const char *key,
|
||||
const char *value);
|
||||
|
||||
LIBROUTER_PUBLIC const char *strmap_get(strmap_t *dict, const char *key);
|
||||
|
||||
LIBROUTER_PUBLIC size_t strmap_extend(strmap_t *target, strmap_t *other);
|
||||
|
||||
LIBROUTER_PUBLIC strmap_t *strmap_duplicate(strmap_t *target);
|
||||
|
||||
LIBROUTER_PUBLIC bool strmap_includes(strmap_t *a, strmap_t *b);
|
||||
|
||||
LIBROUTER_PUBLIC bool strmap_equal(strmap_t *a, strmap_t *b);
|
||||
|
||||
LIBROUTER_PUBLIC strmap_iterator_t *strmap_get_iterator(strmap_t *map);
|
||||
|
||||
LIBROUTER_PUBLIC void strmap_destroy_iterator(strmap_iterator_t *iter);
|
||||
|
||||
LIBROUTER_PUBLIC strmap_item_t *strmap_next(strmap_iterator_t *iter);
|
||||
|
||||
LIBROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-router/include/ui_router/types.h
|
||||
* lib/router/include/router/types.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
@@ -9,8 +9,8 @@
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_ROUTER_INCLUDE_UI_ROUTER_TYPES_H
|
||||
#define LIB_UI_ROUTER_INCLUDE_UI_ROUTER_TYPES_H
|
||||
#ifndef LIB_ROUTER_INCLUDE_ROUTER_TYPES_H
|
||||
#define LIB_ROUTER_INCLUDE_ROUTER_TYPES_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <yutil.h>
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* lib/router/include/router/utils.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_ROUTER_INCLUDE_ROUTER_UTILS_H
|
||||
#define LIB_ROUTER_INCLUDE_ROUTER_UTILS_H
|
||||
|
||||
#include <router/common.h>
|
||||
#include <router/types.h>
|
||||
|
||||
LIBROUTER_BEGIN_DECLS
|
||||
|
||||
LIBROUTER_PUBLIC char *router_path_fill_params(const char *path,
|
||||
strmap_t *params);
|
||||
|
||||
LIBROUTER_PUBLIC const char *router_path_parse_key(const char *path,
|
||||
char key[256],
|
||||
size_t *key_len);
|
||||
|
||||
LIBROUTER_PUBLIC size_t router_path_parse_keys(const char *path,
|
||||
router_linkedlist_t *keys);
|
||||
|
||||
LIBROUTER_PUBLIC char *router_path_resolve(const char *relative,
|
||||
const char *base, bool append);
|
||||
|
||||
LIBROUTER_PUBLIC strmap_t *router_parse_query(const char *query_str);
|
||||
|
||||
LIBROUTER_PUBLIC int router_string_compare(const char *a, const char *b);
|
||||
|
||||
LIBROUTER_PUBLIC int router_path_compare(const char *a, const char *b);
|
||||
|
||||
LIBROUTER_PUBLIC bool router_path_starts_with(const char *path,
|
||||
const char *subpath);
|
||||
|
||||
LIBROUTER_PUBLIC bool router_is_same_route(const router_route_t *a,
|
||||
const router_route_t *b);
|
||||
|
||||
LIBROUTER_PUBLIC bool router_is_included_route(const router_route_t *current,
|
||||
const router_route_t *target);
|
||||
|
||||
LIBROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-router/include/ui_router/version.h
|
||||
* lib/router/include/router/version.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
@@ -9,8 +9,8 @@
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#define LIBUI_ROUTER_VERSION "0.1.0-a"
|
||||
#define LIBUI_ROUTER_VERSION_MAJOR 0
|
||||
#define LIBUI_ROUTER_VERSION_MINOR 1
|
||||
#define LIBUI_ROUTER_VERSION_ALTER 0
|
||||
#define LIBUI_ROUTER_STATIC_BUILD 1
|
||||
#define LIBROUTER_VERSION "0.1.0-a"
|
||||
#define LIBROUTER_VERSION_MAJOR 0
|
||||
#define LIBROUTER_VERSION_MINOR 1
|
||||
#define LIBROUTER_VERSION_ALTER 0
|
||||
#define LIBROUTER_STATIC_BUILD 1
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-router/src/config.c
|
||||
* lib/router/src/config.c
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
#include "private.h"
|
||||
#include <ui_router/config.h>
|
||||
#include <router/config.h>
|
||||
|
||||
router_config_t *router_config_create(void)
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-router/src/history.c
|
||||
* lib/router/src/history.c
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
@@ -10,8 +10,8 @@
|
||||
*/
|
||||
|
||||
#include "private.h"
|
||||
#include <ui_router/route.h>
|
||||
#include <ui_router/history.h>
|
||||
#include <router/route.h>
|
||||
#include <router/history.h>
|
||||
|
||||
router_history_t *router_history_create(void)
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-router/src/location.c
|
||||
* lib/router/src/location.c
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
#include "private.h"
|
||||
#include <ui_router/location.h>
|
||||
#include <router/location.h>
|
||||
|
||||
router_location_t *router_location_create(const char *name, const char *path)
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-router/src/matcher.c
|
||||
* lib/router/src/matcher.c
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
@@ -10,10 +10,10 @@
|
||||
*/
|
||||
|
||||
#include "private.h"
|
||||
#include <ui_router/route.h>
|
||||
#include <ui_router/route_record.h>
|
||||
#include <ui_router/matcher.h>
|
||||
#include <ui_router/location.h>
|
||||
#include <router/route.h>
|
||||
#include <router/route_record.h>
|
||||
#include <router/matcher.h>
|
||||
#include <router/location.h>
|
||||
|
||||
router_matcher_t *router_matcher_create(void)
|
||||
{
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* lib/router/src/private.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef ROUTER_PRIVATE_H
|
||||
#define ROUTER_PRIVATE_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <router/types.h>
|
||||
#include <router/utils.h>
|
||||
#include <router/strmap.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
|
||||
#define router_mem_free(ptr) \
|
||||
do { \
|
||||
if (ptr) { \
|
||||
free(ptr); \
|
||||
} \
|
||||
ptr = NULL; \
|
||||
} while (0)
|
||||
|
||||
struct router_location {
|
||||
char *name;
|
||||
char *path;
|
||||
char *hash;
|
||||
strmap_t *params;
|
||||
strmap_t *query;
|
||||
bool normalized;
|
||||
};
|
||||
|
||||
struct router_route {
|
||||
char *name;
|
||||
char *path;
|
||||
char *full_path;
|
||||
char *hash;
|
||||
strmap_t *query;
|
||||
strmap_t *params;
|
||||
router_linkedlist_t matched;
|
||||
};
|
||||
|
||||
struct router_route_record {
|
||||
char *name;
|
||||
char *path;
|
||||
const router_route_record_t *parent;
|
||||
strmap_t *components;
|
||||
router_linkedlist_node_t node;
|
||||
};
|
||||
|
||||
struct router_history {
|
||||
int index;
|
||||
router_route_t *current;
|
||||
router_linkedlist_t routes;
|
||||
router_linkedlist_t watchers;
|
||||
};
|
||||
|
||||
struct router_config {
|
||||
char *name;
|
||||
char *path;
|
||||
strmap_t *components;
|
||||
};
|
||||
|
||||
struct router_matcher {
|
||||
dict_t *name_map;
|
||||
dict_t *path_map;
|
||||
router_linkedlist_t path_list;
|
||||
};
|
||||
|
||||
struct router_watcher {
|
||||
void *data;
|
||||
router_callback_t callback;
|
||||
router_linkedlist_node_t node;
|
||||
};
|
||||
|
||||
struct router_resolved {
|
||||
router_route_t *route;
|
||||
router_location_t *location;
|
||||
};
|
||||
|
||||
struct router {
|
||||
char *name;
|
||||
char *link_active_class;
|
||||
char *link_exact_active_class;
|
||||
router_matcher_t *matcher;
|
||||
router_history_t *history;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-router/src/route.c
|
||||
* lib/router/src/route.c
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
@@ -10,8 +10,8 @@
|
||||
*/
|
||||
|
||||
#include "private.h"
|
||||
#include <ui_router/route.h>
|
||||
#include <ui_router/location.h>
|
||||
#include <router/route.h>
|
||||
#include <router/location.h>
|
||||
|
||||
// https://github.com/vuejs/vue-router/blob/65de048ee9f0ebf899ae99c82b71ad397727e55d/dist/vue-router.esm.js#L266
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-router/src/route_record.c
|
||||
* lib/router/src/route_record.c
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
#include "private.h"
|
||||
#include <ui_router/route_record.h>
|
||||
#include <router/route_record.h>
|
||||
|
||||
router_route_record_t *router_route_record_create(void)
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-router/src/router.c
|
||||
* lib/router/src/router.c
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
#include "private.h"
|
||||
#include <ui_router.h>
|
||||
#include <router.h>
|
||||
|
||||
static dict_t *routers = NULL;
|
||||
static dict_type_t routers_dict_type;
|
||||
@@ -177,5 +177,5 @@ router_t *router_get_by_name(const char *name)
|
||||
|
||||
const char *router_get_version(void)
|
||||
{
|
||||
return LIBUI_ROUTER_VERSION;
|
||||
return LIBROUTER_VERSION;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-router/src/strmap.c
|
||||
* lib/router/src/strmap.c
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-router/src/utils.c
|
||||
* lib/router/src/utils.c
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* lib/router/include/router/version.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#define LIBROUTER_VERSION "${VERSION}"
|
||||
#define LIBROUTER_VERSION_MAJOR ${VERSION_MAJOR}
|
||||
#define LIBROUTER_VERSION_MINOR ${VERSION_MINOR}
|
||||
#define LIBROUTER_VERSION_ALTER ${VERSION_ALTER}
|
||||
${define LIBROUTER_STATIC_BUILD}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-router/tests/test.c
|
||||
* lib/router/tests/test.c
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
@@ -11,8 +11,7 @@
|
||||
|
||||
#include "../src/private.h"
|
||||
#include <ctest.h>
|
||||
#include <ui_router.h>
|
||||
#include <ui_widgets.h>
|
||||
#include <router.h>
|
||||
|
||||
void test_router_location(void)
|
||||
{
|
||||
@@ -565,106 +564,6 @@ void test_router_history(void)
|
||||
router_destroy(router);
|
||||
}
|
||||
|
||||
void test_router_components(void)
|
||||
{
|
||||
router_t *router;
|
||||
router_config_t *config;
|
||||
ui_widget_t *root;
|
||||
ui_widget_t *link_foo;
|
||||
ui_widget_t *link_foobar;
|
||||
ui_widget_t *link_bar;
|
||||
ui_widget_t *view;
|
||||
ui_widget_t *matched_widget;
|
||||
ui_event_t e;
|
||||
|
||||
router = router_create(NULL);
|
||||
config = router_config_create();
|
||||
router_config_set_path(config, "/foo");
|
||||
router_config_set_component(config, NULL, "foo");
|
||||
router_add_route_record(router, config, NULL);
|
||||
router_config_destroy(config);
|
||||
|
||||
config = router_config_create();
|
||||
router_config_set_path(config, "/foo/bar");
|
||||
router_config_set_component(config, NULL, "foobar");
|
||||
router_add_route_record(router, config, NULL);
|
||||
router_config_destroy(config);
|
||||
|
||||
config = router_config_create();
|
||||
router_config_set_path(config, "/bar");
|
||||
router_config_set_component(config, NULL, "bar");
|
||||
router_add_route_record(router, config, NULL);
|
||||
router_config_destroy(config);
|
||||
|
||||
ui_init();
|
||||
ui_register_text();
|
||||
ui_register_router_link();
|
||||
ui_register_router_view();
|
||||
ui_create_widget_prototype("foo", NULL);
|
||||
ui_create_widget_prototype("foobar", NULL);
|
||||
ui_create_widget_prototype("bar", NULL);
|
||||
root = ui_root();
|
||||
view = ui_create_widget("router-view");
|
||||
link_foo = ui_create_widget("router-link");
|
||||
link_foobar = ui_create_widget("router-link");
|
||||
link_bar = ui_create_widget("router-link");
|
||||
ui_widget_set_attr(link_foo, "to", "/foo");
|
||||
ui_widget_set_attr(link_foobar, "to", "/foo/bar");
|
||||
ui_widget_set_attr(link_bar, "to", "/bar");
|
||||
ui_widget_append(root, link_foo);
|
||||
ui_widget_append(root, link_foobar);
|
||||
ui_widget_append(root, link_bar);
|
||||
ui_widget_append(root, view);
|
||||
ui_update();
|
||||
|
||||
ui_event_init(&e, "click");
|
||||
ui_widget_emit_event(link_foo, e, NULL);
|
||||
// ui_update();
|
||||
matched_widget = ui_router_view_get_matched_widget(view);
|
||||
ctest_equal_bool("[/foo] <router-view> widget should load <foo> widget",
|
||||
strcmp(matched_widget->type, "foo") == 0, true);
|
||||
ctest_equal_bool(
|
||||
"[/foo] linkFoo should has active classes",
|
||||
(ui_widget_has_class(link_foo, "router-link-active") &&
|
||||
ui_widget_has_class(link_foo, "router-link-exact-active")),
|
||||
true);
|
||||
ui_widget_emit_event(link_bar, e, NULL);
|
||||
matched_widget = ui_router_view_get_matched_widget(view);
|
||||
ctest_equal_bool("[/bar] <router-view> widget should load <bar> widget",
|
||||
strcmp(matched_widget->type, "bar") == 0, true);
|
||||
ctest_equal_bool(
|
||||
"[/bar] linkFoo should not has active classes",
|
||||
(!ui_widget_has_class(link_foo, "router-link-exact-active") &&
|
||||
!ui_widget_has_class(link_foo, "router-link-active")),
|
||||
true);
|
||||
|
||||
ui_widget_emit_event(link_foobar, e, NULL);
|
||||
matched_widget = ui_router_view_get_matched_widget(view);
|
||||
ctest_equal_bool(
|
||||
"[/foo/bar] <router-view> widget should load <foobar> widget",
|
||||
strcmp(matched_widget->type, "foobar") == 0, true);
|
||||
ctest_equal_bool(
|
||||
"[/foo/bar] linkFooBar should has active classes",
|
||||
(ui_widget_has_class(link_foobar, "router-link-exact-active") &&
|
||||
ui_widget_has_class(link_foobar, "router-link-active")),
|
||||
true);
|
||||
ctest_equal_bool(
|
||||
"[/foo/bar] linkFoo should only has the exact active class",
|
||||
(!ui_widget_has_class(link_foo, "router-link-exact-active") &&
|
||||
ui_widget_has_class(link_foo, "router-link-active")),
|
||||
true);
|
||||
ui_widget_set_attr(link_foo, "exact", "exact");
|
||||
ui_widget_emit_event(link_foobar, e, NULL);
|
||||
ctest_equal_bool(
|
||||
"[/foo/bar] linkFoo should not has any active classes (exact)",
|
||||
(!ui_widget_has_class(link_foo, "router-link-exact-active") &&
|
||||
!ui_widget_has_class(link_foo, "router-link-active")),
|
||||
true);
|
||||
|
||||
ui_destroy();
|
||||
router_destroy(router);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
logger_set_level(LOGGER_LEVEL_OFF);
|
||||
@@ -673,6 +572,5 @@ int main(void)
|
||||
ctest_describe("router route", test_router_route);
|
||||
ctest_describe("router matcher", test_router_matcher);
|
||||
ctest_describe("router history", test_router_history);
|
||||
ctest_describe("router components", test_router_components);
|
||||
return ctest_finish();
|
||||
}
|
||||
@@ -1,24 +1,24 @@
|
||||
set_project("libui-router")
|
||||
set_project("librouter")
|
||||
set_version("0.1.0-a")
|
||||
|
||||
target("libui-router")
|
||||
target("librouter")
|
||||
set_kind("$(kind)")
|
||||
add_files("src/*.c")
|
||||
add_deps("yutil", "libui", "libui-widgets")
|
||||
set_configdir("include/ui_router")
|
||||
add_deps("yutil", "libui")
|
||||
set_configdir("include/router")
|
||||
add_configfiles("src/version.h.in")
|
||||
add_headerfiles("include/ui_router.h", "include/(ui_router/*.h)")
|
||||
add_headerfiles("include/router.h", "include/(router/*.h)")
|
||||
if is_kind("static") then
|
||||
set_configvar("LIBUI_ROUTER_STATIC_BUILD", 1)
|
||||
set_configvar("LIBROUTER_STATIC_BUILD", 1)
|
||||
elseif is_plat("windows") then
|
||||
add_defines("LIBUI_ROUTER_DLL_EXPORT")
|
||||
add_defines("LIBROUTER_DLL_EXPORT")
|
||||
end
|
||||
|
||||
target("libui-router-tests")
|
||||
target("librouter_tests")
|
||||
set_default(false)
|
||||
set_kind("binary")
|
||||
add_files("tests/test.c")
|
||||
add_deps("libui-router", "ctest")
|
||||
add_deps("librouter", "ctest")
|
||||
on_run(function (target)
|
||||
import("core.base.option")
|
||||
local argv = {}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* lib/ui-router/include/ui_router.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <ui_router/route.h>
|
||||
#include <ui_router/route_record.h>
|
||||
#include <ui_router/utils.h>
|
||||
#include <ui_router/config.h>
|
||||
#include <ui_router/history.h>
|
||||
#include <ui_router/location.h>
|
||||
#include <ui_router/strmap.h>
|
||||
#include <ui_router/matcher.h>
|
||||
#include <ui_router/router.h>
|
||||
#include <ui_router/view.h>
|
||||
#include <ui_router/link.h>
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* lib/ui-router/include/ui_router/common.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "version.h"
|
||||
#ifdef __cplusplus
|
||||
#define LIBUI_ROUTER_BEGIN_DECLS extern "C" {
|
||||
#define LIBUI_ROUTER_END_DECLS }
|
||||
#else
|
||||
#define LIBUI_ROUTER_BEGIN_DECLS
|
||||
#define LIBUI_ROUTER_END_DECLS
|
||||
#endif
|
||||
|
||||
#ifndef LIBUI_ROUTER_PUBLIC
|
||||
#if defined(_MSC_VER) && !defined(LIBUI_ROUTER_STATIC_BUILD)
|
||||
#ifdef LIBUI_ROUTER_DLL_EXPORT
|
||||
#define LIBUI_ROUTER_PUBLIC __declspec(dllexport)
|
||||
#else
|
||||
#define LIBUI_ROUTER_PUBLIC __declspec(dllimport)
|
||||
#endif
|
||||
#elif __GNUC__ >= 4
|
||||
#define LIBUI_ROUTER_PUBLIC extern __attribute__((visibility("default")))
|
||||
#else
|
||||
#define LIBUI_ROUTER_PUBLIC extern
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* lib/ui-router/include/ui_router/config.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_ROUTER_INCLUDE_UI_ROUTER_CONFIG_H
|
||||
#define LIB_UI_ROUTER_INCLUDE_UI_ROUTER_CONFIG_H
|
||||
|
||||
#include <ui_router/common.h>
|
||||
#include <ui_router/types.h>
|
||||
|
||||
LIBUI_ROUTER_BEGIN_DECLS
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_config_t *router_config_create(void);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_config_destroy(router_config_t *config);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_config_set_name(router_config_t *config,
|
||||
const char *name);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_config_set_path(router_config_t *config,
|
||||
const char *path);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_config_set_component(router_config_t *config,
|
||||
const char *name,
|
||||
const char *component);
|
||||
|
||||
LIBUI_ROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* lib/ui-router/include/ui_router/history.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_ROUTER_INCLUDE_UI_ROUTER_HISTORY_H
|
||||
#define LIB_UI_ROUTER_INCLUDE_UI_ROUTER_HISTORY_H
|
||||
|
||||
#include <ui_router/common.h>
|
||||
#include <ui_router/types.h>
|
||||
|
||||
LIBUI_ROUTER_BEGIN_DECLS
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_history_t *router_history_create(void);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_history_destroy(router_history_t *history);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_watcher_t *router_history_watch(
|
||||
router_history_t *history, router_callback_t callback, void *data);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_history_unwatch(router_history_t *history,
|
||||
router_watcher_t *watcher);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_history_push(router_history_t *history,
|
||||
router_route_t *route);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_history_replace(router_history_t *history,
|
||||
router_route_t *route);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_history_go(router_history_t *history,
|
||||
int delta);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC size_t
|
||||
router_history_get_index(const router_history_t *history);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC size_t
|
||||
router_history_get_length(const router_history_t *history);
|
||||
|
||||
LIBUI_ROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* lib/ui-router/include/ui_router/link.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_ROUTER_INCLUDE_UI_ROUTER_LINK_H
|
||||
#define LIB_UI_ROUTER_INCLUDE_UI_ROUTER_LINK_H
|
||||
|
||||
#include <ui.h>
|
||||
#include <ui_router/common.h>
|
||||
#include <ui_router/types.h>
|
||||
|
||||
LIBUI_ROUTER_BEGIN_DECLS
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void ui_router_link_set_location(
|
||||
ui_widget_t *w, router_location_t *location);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void ui_router_link_set_exact(ui_widget_t *w, bool exact);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void ui_register_router_link(void);
|
||||
|
||||
LIBUI_ROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* lib/ui-router/include/ui_router/matcher.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_ROUTER_INCLUDE_UI_ROUTER_MATCHER_H
|
||||
#define LIB_UI_ROUTER_INCLUDE_UI_ROUTER_MATCHER_H
|
||||
|
||||
#include <ui_router/common.h>
|
||||
#include <ui_router/types.h>
|
||||
|
||||
LIBUI_ROUTER_BEGIN_DECLS
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_matcher_t *router_matcher_create(void);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_matcher_destroy(router_matcher_t *matcher);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_route_t *router_matcher_match(
|
||||
router_matcher_t *matcher, const router_location_t *raw_location,
|
||||
const router_route_t *current_route);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_route_record_t *router_matcher_add_route_record(
|
||||
router_matcher_t *matcher, const router_config_t *config,
|
||||
const router_route_record_t *parent);
|
||||
|
||||
LIBUI_ROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* lib/ui-router/include/ui_router/route.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_ROUTER_INCLUDE_UI_ROUTER_ROUTE_H
|
||||
#define LIB_UI_ROUTER_INCLUDE_UI_ROUTER_ROUTE_H
|
||||
|
||||
#include <ui_router/common.h>
|
||||
#include <ui_router/types.h>
|
||||
|
||||
LIBUI_ROUTER_BEGIN_DECLS
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_route_t *router_route_create(
|
||||
const router_route_record_t *record, const router_location_t *location);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_route_destroy(router_route_t *route);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC const router_route_record_t *
|
||||
router_route_get_matched_record(const router_route_t *route, size_t index);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC const char *router_route_get_full_path(
|
||||
const router_route_t *route);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC const char *router_route_get_path(
|
||||
const router_route_t *route);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC const char *router_route_get_hash(
|
||||
const router_route_t *route);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC const char *router_route_get_param(
|
||||
const router_route_t *route, const char *key);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC const char *router_route_get_query(
|
||||
const router_route_t *route, const char *key);
|
||||
|
||||
LIBUI_ROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* lib/ui-router/include/ui_router/route_record.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_ROUTER_INCLUDE_UI_ROUTER_ROUTE_RECORD_H
|
||||
#define LIB_UI_ROUTER_INCLUDE_UI_ROUTER_ROUTE_RECORD_H
|
||||
|
||||
#include <ui_router/common.h>
|
||||
#include <ui_router/types.h>
|
||||
|
||||
LIBUI_ROUTER_BEGIN_DECLS
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_route_record_t *router_route_record_create(void);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_route_record_destroy(
|
||||
router_route_record_t *record);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_route_record_set_path(
|
||||
router_route_record_t *record, const char *path);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC const char *router_route_record_get_component(
|
||||
const router_route_record_t *record, const char *key);
|
||||
|
||||
LIBUI_ROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* lib/ui-router/include/ui_router/router.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_ROUTER_INCLUDE_UI_ROUTER_ROUTER_H
|
||||
#define LIB_UI_ROUTER_INCLUDE_UI_ROUTER_ROUTER_H
|
||||
|
||||
#include <ui_router/common.h>
|
||||
#include <ui_router/types.h>
|
||||
|
||||
LIBUI_ROUTER_BEGIN_DECLS
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_t *router_create(const char *name);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_destroy(router_t *router);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_route_record_t *router_add_route_record(
|
||||
router_t *router, const router_config_t *config,
|
||||
const router_route_record_t *parent);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_route_t *router_match(
|
||||
router_t *router, const router_location_t *raw_location,
|
||||
const router_route_t *current_route);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_route_record_t *router_get_matched_route_record(
|
||||
router_t *router, size_t index);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_history_t *router_get_history(router_t *router);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_watcher_t *router_watch(router_t *router,
|
||||
router_callback_t callback,
|
||||
void *data);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_unwatch(router_t *router,
|
||||
router_watcher_t *watcher);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_resolved_t *router_resolve(
|
||||
router_t *router, router_location_t *location, bool append);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_location_t *router_resolved_get_location(
|
||||
router_resolved_t *resolved);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_route_t *router_resolved_get_route(
|
||||
router_resolved_t *resolved);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_resolved_destroy(router_resolved_t *resolved);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC const router_route_t *router_get_current_route(
|
||||
router_t *router);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_push(router_t *router,
|
||||
router_location_t *location);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_replace(router_t *router,
|
||||
router_location_t *location);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_go(router_t *router, int delta);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_back(router_t *router);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void router_forward(router_t *router);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC router_t *router_get_by_name(const char *name);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC const char *router_get_version(void);
|
||||
|
||||
LIBUI_ROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* lib/ui-router/include/ui_router/strmap.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_ROUTER_INCLUDE_UI_ROUTER_STRMAP_H
|
||||
#define LIB_UI_ROUTER_INCLUDE_UI_ROUTER_STRMAP_H
|
||||
|
||||
#include <ui_router/common.h>
|
||||
#include <ui_router/types.h>
|
||||
|
||||
LIBUI_ROUTER_BEGIN_DECLS
|
||||
|
||||
LIBUI_ROUTER_PUBLIC strmap_t *strmap_create(void);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void strmap_destroy(strmap_t *dict);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void strmap_delete(strmap_t *dict, const char *key);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC int strmap_set(strmap_t *dict, const char *key,
|
||||
const char *value);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC const char *strmap_get(strmap_t *dict, const char *key);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC size_t strmap_extend(strmap_t *target, strmap_t *other);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC strmap_t *strmap_duplicate(strmap_t *target);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC bool strmap_includes(strmap_t *a, strmap_t *b);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC bool strmap_equal(strmap_t *a, strmap_t *b);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC strmap_iterator_t *strmap_get_iterator(strmap_t *map);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void strmap_destroy_iterator(strmap_iterator_t *iter);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC strmap_item_t *strmap_next(strmap_iterator_t *iter);
|
||||
|
||||
LIBUI_ROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* lib/ui-router/include/ui_router/utils.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_ROUTER_INCLUDE_UI_ROUTER_UTILS_H
|
||||
#define LIB_UI_ROUTER_INCLUDE_UI_ROUTER_UTILS_H
|
||||
|
||||
#include <ui_router/common.h>
|
||||
#include <ui_router/types.h>
|
||||
|
||||
LIBUI_ROUTER_BEGIN_DECLS
|
||||
|
||||
LIBUI_ROUTER_PUBLIC char *router_path_fill_params(const char *path,
|
||||
strmap_t *params);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC const char *router_path_parse_key(const char *path,
|
||||
char key[256],
|
||||
size_t *key_len);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC size_t router_path_parse_keys(const char *path,
|
||||
router_linkedlist_t *keys);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC char *router_path_resolve(const char *relative,
|
||||
const char *base, bool append);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC strmap_t *router_parse_query(const char *query_str);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC int router_string_compare(const char *a, const char *b);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC int router_path_compare(const char *a, const char *b);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC bool router_path_starts_with(const char *path,
|
||||
const char *subpath);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC bool router_is_same_route(const router_route_t *a,
|
||||
const router_route_t *b);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC bool router_is_included_route(const router_route_t *current,
|
||||
const router_route_t *target);
|
||||
|
||||
LIBUI_ROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* lib/ui-router/include/ui_router/view.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_ROUTER_INCLUDE_UI_ROUTER_VIEW_H
|
||||
#define LIB_UI_ROUTER_INCLUDE_UI_ROUTER_VIEW_H
|
||||
|
||||
#include <ui.h>
|
||||
#include <ui_router/common.h>
|
||||
#include <ui_router/types.h>
|
||||
|
||||
LIBUI_ROUTER_BEGIN_DECLS
|
||||
|
||||
LIBUI_ROUTER_PUBLIC ui_widget_t *ui_router_view_get_matched_widget(
|
||||
ui_widget_t *w);
|
||||
|
||||
LIBUI_ROUTER_PUBLIC void ui_register_router_view(void);
|
||||
|
||||
LIBUI_ROUTER_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* lib/ui-router/src/private.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef UI_ROUTER_PRIVATE_H
|
||||
#define UI_ROUTER_PRIVATE_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ui_router/types.h>
|
||||
#include <ui_router/utils.h>
|
||||
#include <ui_router/strmap.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable: 4996)
|
||||
#endif
|
||||
|
||||
#define router_mem_free(ptr) \
|
||||
do { \
|
||||
if (ptr) { \
|
||||
free(ptr); \
|
||||
} \
|
||||
ptr = NULL; \
|
||||
} while (0)
|
||||
|
||||
struct router_location {
|
||||
char *name;
|
||||
char *path;
|
||||
char *hash;
|
||||
strmap_t *params;
|
||||
strmap_t *query;
|
||||
bool normalized;
|
||||
};
|
||||
|
||||
struct router_route {
|
||||
char *name;
|
||||
char *path;
|
||||
char *full_path;
|
||||
char *hash;
|
||||
strmap_t *query;
|
||||
strmap_t *params;
|
||||
router_linkedlist_t matched;
|
||||
};
|
||||
|
||||
struct router_route_record {
|
||||
char *name;
|
||||
char *path;
|
||||
const router_route_record_t *parent;
|
||||
strmap_t *components;
|
||||
router_linkedlist_node_t node;
|
||||
};
|
||||
|
||||
struct router_history {
|
||||
int index;
|
||||
router_route_t *current;
|
||||
router_linkedlist_t routes;
|
||||
router_linkedlist_t watchers;
|
||||
};
|
||||
|
||||
struct router_config {
|
||||
char *name;
|
||||
char *path;
|
||||
strmap_t *components;
|
||||
};
|
||||
|
||||
struct router_matcher {
|
||||
dict_t *name_map;
|
||||
dict_t *path_map;
|
||||
router_linkedlist_t path_list;
|
||||
};
|
||||
|
||||
struct router_watcher {
|
||||
void *data;
|
||||
router_callback_t callback;
|
||||
router_linkedlist_node_t node;
|
||||
};
|
||||
|
||||
struct router_resolved {
|
||||
router_route_t *route;
|
||||
router_location_t *location;
|
||||
};
|
||||
|
||||
struct router {
|
||||
char *name;
|
||||
char *link_active_class;
|
||||
char *link_exact_active_class;
|
||||
router_matcher_t *matcher;
|
||||
router_history_t *history;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
* lib/ui-router/include/ui_router/version.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#define LIBUI_ROUTER_VERSION "${VERSION}"
|
||||
#define LIBUI_ROUTER_VERSION_MAJOR ${VERSION_MAJOR}
|
||||
#define LIBUI_ROUTER_VERSION_MINOR ${VERSION_MINOR}
|
||||
#define LIBUI_ROUTER_VERSION_ALTER ${VERSION_ALTER}
|
||||
${define LIBUI_ROUTER_STATIC_BUILD}
|
||||
@@ -735,6 +735,7 @@ void ui_server_update(void)
|
||||
void ui_server_init(void)
|
||||
{
|
||||
ui_cursor_init();
|
||||
ui_server.num_rendering_threads = 4;
|
||||
ui_server.observer =
|
||||
ui_mutation_observer_create(ui_server_on_widget_mutation, NULL);
|
||||
ptk_on_event(PTK_EVENT_VISIBILITY_CHANGE,
|
||||
@@ -760,6 +761,9 @@ void ui_server_init(void)
|
||||
|
||||
void ui_server_set_threads(int threads)
|
||||
{
|
||||
if (threads < 1) {
|
||||
return;
|
||||
}
|
||||
ui_server.num_rendering_threads = threads;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* lib/ui-widgets/include/ui_widgets.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "ui_widgets/common.h"
|
||||
#include "ui_widgets/text.h"
|
||||
#include "ui_widgets/button.h"
|
||||
#include "ui_widgets/anchor.h"
|
||||
#include "ui_widgets/canvas.h"
|
||||
#include "ui_widgets/scrollarea.h"
|
||||
#include "ui_widgets/scrollbar.h"
|
||||
#include "ui_widgets/textinput.h"
|
||||
#include "ui_widgets/textcaret.h"
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* lib/ui-widgets/include/ui_widgets/anchor.h: to <a> element in HTML.
|
||||
*
|
||||
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_WIDGETS_INCLUDE_ANCHOR_H
|
||||
#define LIB_UI_WIDGETS_INCLUDE_ANCHOR_H
|
||||
|
||||
#include <ui.h>
|
||||
#include "ui_widgets/common.h"
|
||||
|
||||
LIBUI_WIDGETS_BEGIN_DECLS
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_anchor_open(ui_widget_t* w);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_register_anchor(void);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_unregister_anchor(void);
|
||||
|
||||
LIBUI_WIDGETS_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* lib/ui-widgets/include/ui_widgets/button.h: -- LCUI‘s Button widget
|
||||
*
|
||||
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_WIDGETS_INCLUDE_BUTTON_H
|
||||
#define LIB_UI_WIDGETS_INCLUDE_BUTTON_H
|
||||
|
||||
#include <ui.h>
|
||||
#include "ui_widgets/common.h"
|
||||
|
||||
LIBUI_WIDGETS_BEGIN_DECLS
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_button_set_text_w(ui_widget_t* w, const wchar_t *wstr);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_button_set_text(ui_widget_t* w, const char *str);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_register_button(void);
|
||||
|
||||
LIBUI_WIDGETS_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* lib/ui-widgets/include/ui_widgets/common.h
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#ifdef __cplusplus
|
||||
#define LIBUI_WIDGETS_BEGIN_DECLS extern "C" {
|
||||
#define LIBUI_WIDGETS_END_DECLS }
|
||||
#else
|
||||
#define LIBUI_WIDGETS_BEGIN_DECLS
|
||||
#define LIBUI_WIDGETS_END_DECLS
|
||||
#endif
|
||||
|
||||
#ifndef LIBUI_WIDGETS_PUBLIC
|
||||
#if defined(_MSC_VER) && !defined(LIBUI_WIDGETS_STATIC_BUILD)
|
||||
#ifdef LIBUI_WIDGETS_DLL_EXPORT
|
||||
#define LIBUI_WIDGETS_PUBLIC __declspec(dllexport)
|
||||
#else
|
||||
#define LIBUI_WIDGETS_PUBLIC __declspec(dllimport)
|
||||
#endif
|
||||
#elif __GNUC__ >= 4
|
||||
#define LIBUI_WIDGETS_PUBLIC extern __attribute__((visibility("default")))
|
||||
#else
|
||||
#define LIBUI_WIDGETS_PUBLIC extern
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* lib/ui-widgets/include/ui_widgets/scrollarea.h
|
||||
*
|
||||
* Copyright (c) 2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_WIDGETS_INCLUDE_SCROLLAREA_H
|
||||
#define LIB_UI_WIDGETS_INCLUDE_SCROLLAREA_H
|
||||
|
||||
#include <ui.h>
|
||||
#include "ui_widgets/common.h"
|
||||
|
||||
typedef enum {
|
||||
UI_SCROLLAREA_AUTO,
|
||||
UI_SCROLLAREA_VERTICAL,
|
||||
UI_SCROLLAREA_HORIZONTAL,
|
||||
} ui_scrollarea_direction_t;
|
||||
|
||||
LIBUI_WIDGETS_BEGIN_DECLS
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_scrollarea_set_wheel_scroll_direction(
|
||||
ui_widget_t *w, ui_scrollarea_direction_t direction);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_scrollarea_update(ui_widget_t *w);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_register_scrollarea(void);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC ui_widget_t *ui_create_scrollarea(void);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC ui_widget_t *ui_create_scrollarea_content(void);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_scrollarea_set_scroll_top(ui_widget_t *w,
|
||||
float value);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_scrollarea_set_scroll_left(ui_widget_t *w,
|
||||
float value);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC float ui_scrollarea_get_scroll_top(ui_widget_t *w);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC float ui_scrollarea_get_scroll_left(ui_widget_t *w);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC float ui_scrollarea_get_scroll_width(ui_widget_t *w);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC float ui_scrollarea_get_scroll_height(ui_widget_t *w);
|
||||
|
||||
LIBUI_WIDGETS_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* lib/ui-widgets/include/ui_widgets/scrollbar.h: -- LCUI's scrollbar widget
|
||||
*
|
||||
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_WIDGETS_INCLUDE_SCROLLBAR_H
|
||||
#define LIB_UI_WIDGETS_INCLUDE_SCROLLBAR_H
|
||||
|
||||
#include <ui.h>
|
||||
#include "ui_widgets/common.h"
|
||||
|
||||
LIBUI_WIDGETS_BEGIN_DECLS
|
||||
|
||||
typedef enum {
|
||||
UI_SCROLLBAR_HORIZONTAL,
|
||||
UI_SCROLLBAR_VERTICAL
|
||||
} ui_scrollbar_orientation_t;
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_scrollbar_update(ui_widget_t *w);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_scrollbar_set_orientation(ui_widget_t* w,
|
||||
ui_scrollbar_orientation_t orientation);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC ui_widget_t *ui_create_scrollbar(void);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_register_scrollbar(void);
|
||||
|
||||
LIBUI_WIDGETS_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* lib/ui-widgets/include/ui_widgets/text.h: -- TextView widget for display
|
||||
* text.
|
||||
*
|
||||
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_WIDGETS_INCLUDE_TEXTVIEW_H
|
||||
#define LIB_UI_WIDGETS_INCLUDE_TEXTVIEW_H
|
||||
|
||||
#include <ui.h>
|
||||
#include "ui_widgets/common.h"
|
||||
|
||||
LIBUI_WIDGETS_BEGIN_DECLS
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC int ui_text_set_content_w(ui_widget_t *w,
|
||||
const wchar_t *text);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC size_t ui_text_get_content_w(ui_widget_t *w, wchar_t *buf,
|
||||
size_t size);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC int ui_text_set_content(ui_widget_t *w,
|
||||
const char *utf8_text);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_text_set_multiline(ui_widget_t *w, bool enable);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_register_text(void);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_unregister_text(void);
|
||||
|
||||
LIBUI_WIDGETS_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* lib/ui-widgets/include/ui_widgets/textcaret.h: -- textcaret widget, used in textinput.
|
||||
*
|
||||
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_WIDGETS_INCLUDE_TEXTCARET_H
|
||||
#define LIB_UI_WIDGETS_INCLUDE_TEXTCARET_H
|
||||
|
||||
#include <ui.h>
|
||||
#include "ui_widgets/common.h"
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_textcaret_refresh(ui_widget_t* widget);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_textcaret_set_visible(ui_widget_t* widget, bool visible);
|
||||
|
||||
/** 设置闪烁的时间间隔 */
|
||||
LIBUI_WIDGETS_PUBLIC void ui_textcaret_set_blink_time(ui_widget_t* widget, unsigned int n_ms);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_register_textcaret(void);
|
||||
|
||||
#endif
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* lib/ui-widgets/include/ui_widgets/textinput.h: -- textinput widget, used to allow user edit text.
|
||||
*
|
||||
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LIB_UI_WIDGETS_INCLUDE_TEXTEDIT_H
|
||||
#define LIB_UI_WIDGETS_INCLUDE_TEXTEDIT_H
|
||||
|
||||
#include <ui.h>
|
||||
#include "ui_widgets/common.h"
|
||||
|
||||
LIBUI_WIDGETS_BEGIN_DECLS
|
||||
|
||||
/** Enable style tag parser */
|
||||
LIBUI_WIDGETS_PUBLIC void ui_textinput_enable_style_tag(ui_widget_t* widget, bool enable);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_textinput_enable_multiline(ui_widget_t* widget, bool enable);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_textinput_move_caret(ui_widget_t* widget, int row, int col);
|
||||
|
||||
/** 清空文本内容 */
|
||||
LIBUI_WIDGETS_PUBLIC void ui_textinput_clear_text(ui_widget_t* widget);
|
||||
|
||||
/** 获取文本内容 */
|
||||
LIBUI_WIDGETS_PUBLIC size_t ui_textinput_get_text_w(ui_widget_t* w, size_t start,
|
||||
size_t max_len, wchar_t *buf);
|
||||
|
||||
/** 获取文本长度 */
|
||||
LIBUI_WIDGETS_PUBLIC size_t ui_textinput_get_text_length(ui_widget_t* w);
|
||||
|
||||
/** 设置文本编辑框内的光标,指定是否闪烁、闪烁时间间隔 */
|
||||
LIBUI_WIDGETS_PUBLIC void ui_textinput_set_caret_blink(ui_widget_t* w, bool visible, int time);
|
||||
|
||||
/** 为文本框设置文本(宽字符版) */
|
||||
LIBUI_WIDGETS_PUBLIC int ui_textinput_set_text_w(ui_widget_t* widget, const wchar_t *wstr);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC int ui_textinput_set_text(ui_widget_t* widget, const char *utf8_str);
|
||||
|
||||
/** 为文本框追加文本(宽字符版) */
|
||||
LIBUI_WIDGETS_PUBLIC int ui_textinput_append_text_w(ui_widget_t* widget, const wchar_t *wstr);
|
||||
|
||||
/** 为文本框插入文本(宽字符版) */
|
||||
LIBUI_WIDGETS_PUBLIC int ui_textinput_insert_text_w(ui_widget_t* widget, const wchar_t *wstr);
|
||||
|
||||
/** 设置占位符,当文本编辑框内容为空时显示占位符 */
|
||||
LIBUI_WIDGETS_PUBLIC int ui_textinput_set_placeholder_w(ui_widget_t* w, const wchar_t *wstr);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC int ui_textinput_set_placeholder(ui_widget_t* w, const char *str);
|
||||
|
||||
/** 设置密码屏蔽符 */
|
||||
LIBUI_WIDGETS_PUBLIC void ui_textinput_set_password_char(ui_widget_t* w, wchar_t ch);
|
||||
|
||||
LIBUI_WIDGETS_PUBLIC void ui_register_textinput(void);
|
||||
|
||||
LIBUI_WIDGETS_END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,5 +0,0 @@
|
||||
#define LIBUI_WIDGETS_VERSION "${VERSION}"
|
||||
#define LIBUI_WIDGETS_VERSION_MAJOR ${VERSION_MAJOR}
|
||||
#define LIBUI_WIDGETS_VERSION_MINOR ${VERSION_MINOR}
|
||||
#define LIBUI_WIDGETS_VERSION_ALTER ${VERSION_ALTER}
|
||||
${define LIBUI_WIDGETS_STATIC_BUILD}
|
||||
@@ -1,15 +0,0 @@
|
||||
set_project("libui-widgets")
|
||||
set_version("0.1.0-a")
|
||||
|
||||
target("libui-widgets")
|
||||
set_kind("$(kind)")
|
||||
add_files("src/**.c")
|
||||
add_deps("yutil", "libcss", "pandagl", "libthread", "libui", "libui-xml", "libworker", "libptk")
|
||||
set_configdir("include/ui_widgets")
|
||||
add_configfiles("src/config.h.in")
|
||||
add_headerfiles("include/ui_widgets.h", "include/(ui_widgets/*.h)")
|
||||
if is_kind("static") then
|
||||
set_configvar("LIBUI_WIDGETS_STATIC_BUILD", 1)
|
||||
elseif is_plat("windows") then
|
||||
add_defines("LIBUI_WIDGETS_DLL_EXPORT")
|
||||
end
|
||||
@@ -1,3 +1,14 @@
|
||||
/*
|
||||
* lib/ui/src/ui_resizer.c
|
||||
*
|
||||
* Copyright (c) 2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <ui.h>
|
||||
#include <css.h>
|
||||
#include "ui_widget_style.h"
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
/*
|
||||
* lib/ui/src/ui_resizer.h
|
||||
*
|
||||
* Copyright (c) 2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <ui.h>
|
||||
|
||||
typedef struct ui_resizer {
|
||||
|
||||
@@ -1 +1,12 @@
|
||||
/*
|
||||
* lib/ui/src/ui_widget_layout.h
|
||||
*
|
||||
* Copyright (c) 2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
void ui_widget_reflow_with_resizer(ui_widget_t *w, ui_resizer_t *resizer);
|
||||
|
||||
+14
-107
@@ -10,94 +10,22 @@
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <ptk.h>
|
||||
#include <LCUI/config.h>
|
||||
#include <LCUI/app.h>
|
||||
#include <ptk.h>
|
||||
#include <ui.h>
|
||||
#include <worker.h>
|
||||
#include <thread.h>
|
||||
#include <LCUI/widgets.h>
|
||||
#include <LCUI/settings.h>
|
||||
|
||||
/** LCUI 应用程序数据 */
|
||||
static struct lcui_app {
|
||||
ptk_steptimer_t timer;
|
||||
worker_t *main_worker;
|
||||
worker_t *async_worker;
|
||||
} lcui_app;
|
||||
extern void lcui_fonts_init(void);
|
||||
extern void lcui_widgets_init(void);
|
||||
extern void lcui_widgets_destroy(void);
|
||||
|
||||
const char *lcui_get_version(void)
|
||||
{
|
||||
return PACKAGE_VERSION;
|
||||
}
|
||||
|
||||
worker_task_t *lcui_post_task(void *data, worker_task_cb task_cb,
|
||||
worker_task_cb after_task_cb)
|
||||
{
|
||||
if (!lcui_app.main_worker) {
|
||||
return NULL;
|
||||
}
|
||||
return worker_post_task(lcui_app.main_worker, data, task_cb,
|
||||
after_task_cb);
|
||||
}
|
||||
worker_task_t *lcui_post_async_task(void *data, worker_task_cb task_cb,
|
||||
worker_task_cb after_task_cb)
|
||||
{
|
||||
return worker_post_task(lcui_app.async_worker, data, task_cb,
|
||||
after_task_cb);
|
||||
}
|
||||
|
||||
bool lcui_cancel_async_task(worker_task_t *task)
|
||||
{
|
||||
return worker_cancel_task(lcui_app.async_worker, task);
|
||||
}
|
||||
|
||||
bool lcui_cancel_task(worker_task_t *task)
|
||||
{
|
||||
return worker_cancel_task(lcui_app.async_worker, task);
|
||||
}
|
||||
|
||||
uint32_t lcui_get_fps(void)
|
||||
{
|
||||
return lcui_app.timer.frames_per_second;
|
||||
}
|
||||
|
||||
void lcui_set_frame_rate_cap(unsigned rate_cap)
|
||||
{
|
||||
if (rate_cap > 0) {
|
||||
lcui_app.timer.target_elapsed_time = 1000 / rate_cap;
|
||||
lcui_app.timer.is_fixed_time_step = true;
|
||||
} else {
|
||||
lcui_app.timer.is_fixed_time_step = false;
|
||||
}
|
||||
}
|
||||
|
||||
static void lcui_app_on_tick(ptk_steptimer_t *timer, void *data)
|
||||
{
|
||||
lcui_render_ui();
|
||||
app_present();
|
||||
}
|
||||
|
||||
static int lcui_dispatch_app_event(ptk_event_t *e)
|
||||
{
|
||||
if (e->type == PTK_EVENT_QUIT) {
|
||||
return 0;
|
||||
}
|
||||
lcui_dispatch_ui_event(e);
|
||||
lcui_update_ui();
|
||||
worker_run(lcui_app.main_worker);
|
||||
ptk_steptimer_tick(&lcui_app.timer, lcui_app_on_tick, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lcui_process_events(ptk_process_events_option_t option)
|
||||
{
|
||||
return ptk_process_native_events(option);
|
||||
}
|
||||
|
||||
void lcui_init_app(void)
|
||||
void lcui_init(void)
|
||||
{
|
||||
logger_log(LOGGER_LEVEL_INFO,
|
||||
"LCUI (LC's UI) version " PACKAGE_VERSION "\n"
|
||||
@@ -109,42 +37,21 @@ void lcui_init_app(void)
|
||||
"See source distribution for detailed copyright notices.\n"
|
||||
"To learn more, visit http://www.lcui.org.\n\n");
|
||||
|
||||
lcui_app_init();
|
||||
lcui_fonts_init();
|
||||
lcui_widgets_init();
|
||||
lcui_reset_settings();
|
||||
ptk_steptimer_init(&lcui_app.timer);
|
||||
lcui_app.main_worker = worker_create();
|
||||
lcui_app.async_worker = worker_create();
|
||||
lcui_app.timer.target_elapsed_time = 0;
|
||||
worker_run_async(lcui_app.async_worker);
|
||||
}
|
||||
|
||||
void lcui_destroy_app(void)
|
||||
{
|
||||
worker_destroy(lcui_app.main_worker);
|
||||
worker_destroy(lcui_app.async_worker);
|
||||
lcui_app.main_worker = NULL;
|
||||
lcui_app.async_worker = NULL;
|
||||
}
|
||||
|
||||
void lcui_init(void)
|
||||
{
|
||||
lcui_init_app();
|
||||
if (ptk_init(L"LCUI Application") != 0) {
|
||||
abort();
|
||||
}
|
||||
ptk_set_event_dispatcher(lcui_dispatch_app_event);
|
||||
lcui_init_ui();
|
||||
}
|
||||
|
||||
void lcui_destroy(void)
|
||||
{
|
||||
lcui_destroy_ui();
|
||||
lcui_destroy_app();
|
||||
ptk_destroy();
|
||||
lcui_widgets_destroy();
|
||||
lcui_app_destroy();
|
||||
}
|
||||
|
||||
void lcui_exit(int code)
|
||||
{
|
||||
app_exit(code);
|
||||
ptk_app_exit(code);
|
||||
}
|
||||
|
||||
void lcui_quit(void)
|
||||
@@ -154,7 +61,7 @@ void lcui_quit(void)
|
||||
|
||||
int lcui_run(void)
|
||||
{
|
||||
return lcui_process_events(PTK_PROCESS_EVENTS_UNTIL_QUIT);
|
||||
return lcui_app_process_events(PTK_PROCESS_EVENTS_UNTIL_QUIT);
|
||||
}
|
||||
|
||||
int lcui_main(void)
|
||||
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* src/lcui_app.c
|
||||
*
|
||||
* Copyright (c) 2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <ptk.h>
|
||||
#include <ui.h>
|
||||
#include <ui_server.h>
|
||||
#include <LCUI/ui.h>
|
||||
#include <LCUI/worker.h>
|
||||
#include <LCUI/app.h>
|
||||
|
||||
static struct lcui_app {
|
||||
ptk_steptimer_t timer;
|
||||
} lcui_app;
|
||||
|
||||
static void lcui_dispatch_ui_mouse_event(ui_event_type_t type,
|
||||
ptk_event_t *app_evt)
|
||||
{
|
||||
ui_event_t e = { 0 };
|
||||
float scale = ui_server_get_window_scale(app_evt->window);
|
||||
|
||||
e.type = type;
|
||||
e.mouse.y = (float)round(app_evt->mouse.y / scale);
|
||||
e.mouse.x = (float)round(app_evt->mouse.x / scale);
|
||||
ui_dispatch_event(&e);
|
||||
}
|
||||
|
||||
static void lcui_dispatch_ui_keyboard_event(ui_event_type_t type,
|
||||
ptk_event_t *app_evt)
|
||||
{
|
||||
ui_event_t e = { 0 };
|
||||
|
||||
e.type = type;
|
||||
e.key.code = app_evt->key.code;
|
||||
e.key.is_composing = app_evt->key.is_composing;
|
||||
e.key.alt_key = app_evt->key.alt_key;
|
||||
e.key.shift_key = app_evt->key.shift_key;
|
||||
e.key.ctrl_key = app_evt->key.ctrl_key;
|
||||
e.key.meta_key = app_evt->key.meta_key;
|
||||
ui_dispatch_event(&e);
|
||||
}
|
||||
|
||||
static void lcui_dispatch_ui_touch_event(ptk_event_t *app_event)
|
||||
{
|
||||
size_t i;
|
||||
ui_event_t e = { 0 };
|
||||
float scale = ui_server_get_window_scale(app_event->window);
|
||||
|
||||
e.type = UI_EVENT_TOUCH;
|
||||
e.touch.n_points = app_event->touch.n_points;
|
||||
e.touch.points = malloc(sizeof(ui_touch_point_t) * e.touch.n_points);
|
||||
for (i = 0; i < e.touch.n_points; ++i) {
|
||||
switch (app_event->touch.points[i].state) {
|
||||
case PTK_EVENT_TOUCHDOWN:
|
||||
e.touch.points[i].state = UI_EVENT_TOUCHDOWN;
|
||||
break;
|
||||
case PTK_EVENT_TOUCHUP:
|
||||
e.touch.points[i].state = UI_EVENT_TOUCHUP;
|
||||
break;
|
||||
case PTK_EVENT_TOUCHMOVE:
|
||||
e.touch.points[i].state = UI_EVENT_TOUCHMOVE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
e.touch.points[i].x =
|
||||
(float)round(app_event->touch.points[i].x / scale);
|
||||
e.touch.points[i].y =
|
||||
(float)round(app_event->touch.points[i].y / scale);
|
||||
}
|
||||
ui_dispatch_event(&e);
|
||||
ui_event_destroy(&e);
|
||||
}
|
||||
|
||||
static void lcui_dispatch_ui_textinput_event(ptk_event_t *app_evt)
|
||||
{
|
||||
ui_event_t e = { 0 };
|
||||
|
||||
e.type = UI_EVENT_TEXTINPUT;
|
||||
e.text.length = app_evt->text.length;
|
||||
e.text.text = wcsdup2(app_evt->text.text);
|
||||
ui_dispatch_event(&e);
|
||||
ui_event_destroy(&e);
|
||||
}
|
||||
|
||||
static void lcui_dispatch_ui_wheel_event(app_wheel_event_t *wheel)
|
||||
{
|
||||
ui_event_t e = { 0 };
|
||||
|
||||
// TODO:
|
||||
e.type = UI_EVENT_WHEEL;
|
||||
e.wheel.delta_mode = UI_WHEEL_DELTA_PIXEL;
|
||||
e.wheel.delta_y = wheel->delta_y;
|
||||
ui_dispatch_event(&e);
|
||||
}
|
||||
|
||||
static void lcui_dispatch_ui_event(ptk_event_t *app_event)
|
||||
{
|
||||
switch (app_event->type) {
|
||||
case PTK_EVENT_KEYDOWN:
|
||||
lcui_dispatch_ui_keyboard_event(UI_EVENT_KEYDOWN, app_event);
|
||||
break;
|
||||
case PTK_EVENT_KEYUP:
|
||||
lcui_dispatch_ui_keyboard_event(UI_EVENT_KEYUP, app_event);
|
||||
break;
|
||||
case PTK_EVENT_KEYPRESS:
|
||||
lcui_dispatch_ui_keyboard_event(UI_EVENT_KEYPRESS, app_event);
|
||||
break;
|
||||
case PTK_EVENT_MOUSEDOWN:
|
||||
lcui_dispatch_ui_mouse_event(UI_EVENT_MOUSEDOWN, app_event);
|
||||
break;
|
||||
case PTK_EVENT_MOUSEUP:
|
||||
lcui_dispatch_ui_mouse_event(UI_EVENT_MOUSEUP, app_event);
|
||||
break;
|
||||
case PTK_EVENT_MOUSEMOVE:
|
||||
lcui_dispatch_ui_mouse_event(UI_EVENT_MOUSEMOVE, app_event);
|
||||
break;
|
||||
case PTK_EVENT_TOUCH:
|
||||
lcui_dispatch_ui_touch_event(app_event);
|
||||
break;
|
||||
case PTK_EVENT_WHEEL:
|
||||
lcui_dispatch_ui_wheel_event(&app_event->wheel);
|
||||
break;
|
||||
case PTK_EVENT_COMPOSITION:
|
||||
lcui_dispatch_ui_textinput_event(app_event);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void lcui_app_on_tick(ptk_steptimer_t *timer, void *data)
|
||||
{
|
||||
lcui_ui_render();
|
||||
ptk_app_present();
|
||||
}
|
||||
|
||||
static int lcui_app_dispatch(ptk_event_t *e)
|
||||
{
|
||||
if (e->type == PTK_EVENT_QUIT) {
|
||||
return 0;
|
||||
}
|
||||
lcui_dispatch_ui_event(e);
|
||||
lcui_ui_update();
|
||||
lcui_worker_run();
|
||||
ptk_steptimer_tick(&lcui_app.timer, lcui_app_on_tick, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t lcui_app_get_fps(void)
|
||||
{
|
||||
return lcui_app.timer.frames_per_second;
|
||||
}
|
||||
|
||||
void lcui_app_set_frame_rate_cap(unsigned rate_cap)
|
||||
{
|
||||
if (rate_cap > 0) {
|
||||
lcui_app.timer.target_elapsed_time = 1000 / rate_cap;
|
||||
lcui_app.timer.is_fixed_time_step = true;
|
||||
} else {
|
||||
lcui_app.timer.is_fixed_time_step = false;
|
||||
}
|
||||
}
|
||||
|
||||
int lcui_app_process_events(ptk_process_events_option_t option)
|
||||
{
|
||||
return ptk_process_native_events(option);
|
||||
}
|
||||
|
||||
void lcui_app_init(void)
|
||||
{
|
||||
lcui_worker_init();
|
||||
ptk_steptimer_init(&lcui_app.timer);
|
||||
lcui_app.timer.target_elapsed_time = 0;
|
||||
if (ptk_init(L"LCUI Application") != 0) {
|
||||
abort();
|
||||
}
|
||||
ptk_set_event_dispatcher(lcui_app_dispatch);
|
||||
lcui_ui_init();
|
||||
}
|
||||
|
||||
void lcui_app_destroy(void)
|
||||
{
|
||||
lcui_ui_destroy();
|
||||
lcui_worker_destroy();
|
||||
ptk_destroy();
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* src/lcui_fonts.c
|
||||
*
|
||||
* Copyright (c) 2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <ui.h>
|
||||
#include <ptk.h>
|
||||
#include <pandagl.h>
|
||||
|
||||
#ifdef PTK_WIN32
|
||||
static void lcui_windows_fonts_init(void)
|
||||
{
|
||||
size_t i;
|
||||
int *ids = NULL;
|
||||
const char *names[] = { "Consola", "Simsun", "Microsoft YaHei", NULL };
|
||||
const char *fonts[] = { "C:/Windows/Fonts/consola.ttf",
|
||||
"C:/Windows/Fonts/simsun.ttc",
|
||||
"C:/Windows/Fonts/msyh.ttf",
|
||||
"C:/Windows/Fonts/msyh.ttc" };
|
||||
|
||||
for (i = 0; i < sizeof(fonts) / sizeof(char *); ++i) {
|
||||
pd_font_library_load_file(fonts[i]);
|
||||
}
|
||||
i = pd_font_library_query(&ids, PD_FONT_STYLE_NORMAL,
|
||||
PD_FONT_WEIGHT_NORMAL, names);
|
||||
if (i > 0) {
|
||||
pd_font_library_set_default_font(ids[i - 1]);
|
||||
}
|
||||
free(ids);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#ifdef HAVE_FONTCONFIG
|
||||
|
||||
static void lcui_fc_fonts_init(void)
|
||||
{
|
||||
size_t i;
|
||||
char *path;
|
||||
int *ids = NULL;
|
||||
const char *names[] = { "Noto Sans CJK", "Ubuntu",
|
||||
"WenQuanYi Micro Hei", NULL };
|
||||
const char *fonts[] = { "Ubuntu", "Noto Sans CJK SC",
|
||||
"WenQuanYi Micro Hei" };
|
||||
|
||||
for (i = 0; i < sizeof(fonts) / sizeof(char *); ++i) {
|
||||
path = pd_font_library_get_font_path(fonts[i]);
|
||||
pd_font_library_load_file(path);
|
||||
free(path);
|
||||
}
|
||||
i = pd_font_library_query(&ids, PD_FONT_STYLE_NORMAL,
|
||||
PD_FONT_WEIGHT_NORMAL, names);
|
||||
if (i > 0) {
|
||||
pd_font_library_set_default_font(ids[i - 1]);
|
||||
}
|
||||
free(ids);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void lcui_linux_fonts_init(void)
|
||||
{
|
||||
size_t i;
|
||||
int *ids = NULL;
|
||||
const char *names[] = { "Noto Sans CJK SC", "Ubuntu", "Ubuntu Mono",
|
||||
"WenQuanYi Micro Hei", NULL };
|
||||
const char *fonts[] = {
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-BI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-B.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-C.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-LI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-L.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-MI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/UbuntuMono-BI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/UbuntuMono-B.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/UbuntuMono-RI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/UbuntuMono-R.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-M.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-RI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-R.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-RI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-B.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-BI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-M.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-MI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-L.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-LI.ttf",
|
||||
"/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc",
|
||||
"/usr/share/fonts/opentype/noto/NotoSansCJK.ttc",
|
||||
"/usr/share/fonts/truetype/wqy/wqy-microhei.ttc"
|
||||
};
|
||||
|
||||
for (i = 0; i < sizeof(fonts) / sizeof(char *); ++i) {
|
||||
pd_font_library_load_file(fonts[i]);
|
||||
}
|
||||
i = pd_font_library_query(&ids, PD_FONT_STYLE_NORMAL,
|
||||
PD_FONT_WEIGHT_NORMAL, names);
|
||||
if (i > 0) {
|
||||
pd_font_library_set_default_font(ids[i - 1]);
|
||||
}
|
||||
free(ids);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
void lcui_fonts_init(void)
|
||||
{
|
||||
#ifdef PTK_WIN32
|
||||
lcui_windows_fonts_init();
|
||||
#elif defined(HAVE_FONTCONFIG)
|
||||
logger_debug("[font] fontconfig enabled\n");
|
||||
lcui_fc_fonts_init();
|
||||
#else
|
||||
lcui_linux_fonts_init();
|
||||
#endif
|
||||
}
|
||||
+2
-1
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <ui.h>
|
||||
#include <ui_server.h>
|
||||
#include <LCUI/settings.h>
|
||||
#include <LCUI/app.h>
|
||||
|
||||
static lcui_settings_t lcui_settings;
|
||||
@@ -32,7 +33,7 @@ void lcui_apply_settings(lcui_settings_t *settings)
|
||||
y_max(lcui_settings.parallel_rendering_threads, 1);
|
||||
ui_server_set_threads(lcui_settings.parallel_rendering_threads);
|
||||
ui_server_set_paint_flashing_enabled(lcui_settings.paint_flashing);
|
||||
lcui_set_frame_rate_cap(lcui_settings.frame_rate_cap);
|
||||
lcui_app_set_frame_rate_cap(lcui_settings.frame_rate_cap);
|
||||
}
|
||||
|
||||
/* Reset global settings to their defaults. */
|
||||
|
||||
+29
-277
@@ -15,8 +15,7 @@
|
||||
#include <ui.h>
|
||||
#include <thread.h>
|
||||
#include <ui_server.h>
|
||||
#include <ui_widgets.h>
|
||||
#include <LCUI/app.h>
|
||||
#include <LCUI/ui.h>
|
||||
|
||||
#define DEFAULT_WINDOW_WIDTH 800
|
||||
#define DEFAULT_WINDOW_HEIGHT 600
|
||||
@@ -31,135 +30,19 @@ typedef struct {
|
||||
static struct lcui_ui {
|
||||
bool quit_after_all_windows_closed;
|
||||
lcui_ui_image_loader_t image_loader;
|
||||
lcui_display_mode_t mode;
|
||||
lcui_display_t mode;
|
||||
ui_mutation_observer_t *observer;
|
||||
|
||||
/** list_t<ptk_window_t> */
|
||||
list_t windows;
|
||||
} lcui_ui;
|
||||
|
||||
static void lcui_dispatch_ui_mouse_event(ui_event_type_t type,
|
||||
ptk_event_t *app_evt)
|
||||
{
|
||||
ui_event_t e = { 0 };
|
||||
float scale = ui_server_get_window_scale(app_evt->window);
|
||||
|
||||
e.type = type;
|
||||
e.mouse.y = (float)round(app_evt->mouse.y / scale);
|
||||
e.mouse.x = (float)round(app_evt->mouse.x / scale);
|
||||
ui_dispatch_event(&e);
|
||||
}
|
||||
|
||||
static void lcui_dispatch_ui_keyboard_event(ui_event_type_t type,
|
||||
ptk_event_t *app_evt)
|
||||
{
|
||||
ui_event_t e = { 0 };
|
||||
|
||||
e.type = type;
|
||||
e.key.code = app_evt->key.code;
|
||||
e.key.is_composing = app_evt->key.is_composing;
|
||||
e.key.alt_key = app_evt->key.alt_key;
|
||||
e.key.shift_key = app_evt->key.shift_key;
|
||||
e.key.ctrl_key = app_evt->key.ctrl_key;
|
||||
e.key.meta_key = app_evt->key.meta_key;
|
||||
ui_dispatch_event(&e);
|
||||
}
|
||||
|
||||
static void lcui_dispatch_ui_touch_event(ptk_event_t *app_event)
|
||||
{
|
||||
size_t i;
|
||||
ui_event_t e = { 0 };
|
||||
float scale = ui_server_get_window_scale(app_event->window);
|
||||
|
||||
e.type = UI_EVENT_TOUCH;
|
||||
e.touch.n_points = app_event->touch.n_points;
|
||||
e.touch.points = malloc(sizeof(ui_touch_point_t) * e.touch.n_points);
|
||||
for (i = 0; i < e.touch.n_points; ++i) {
|
||||
switch (app_event->touch.points[i].state) {
|
||||
case PTK_EVENT_TOUCHDOWN:
|
||||
e.touch.points[i].state = UI_EVENT_TOUCHDOWN;
|
||||
break;
|
||||
case PTK_EVENT_TOUCHUP:
|
||||
e.touch.points[i].state = UI_EVENT_TOUCHUP;
|
||||
break;
|
||||
case PTK_EVENT_TOUCHMOVE:
|
||||
e.touch.points[i].state = UI_EVENT_TOUCHMOVE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
e.touch.points[i].x =
|
||||
(float)round(app_event->touch.points[i].x / scale);
|
||||
e.touch.points[i].y =
|
||||
(float)round(app_event->touch.points[i].y / scale);
|
||||
}
|
||||
ui_dispatch_event(&e);
|
||||
ui_event_destroy(&e);
|
||||
}
|
||||
|
||||
static void lcui_dispatch_ui_textinput_event(ptk_event_t *app_evt)
|
||||
{
|
||||
ui_event_t e = { 0 };
|
||||
|
||||
e.type = UI_EVENT_TEXTINPUT;
|
||||
e.text.length = app_evt->text.length;
|
||||
e.text.text = wcsdup2(app_evt->text.text);
|
||||
ui_dispatch_event(&e);
|
||||
ui_event_destroy(&e);
|
||||
}
|
||||
|
||||
static void lcui_dispatch_ui_wheel_event(app_wheel_event_t *wheel)
|
||||
{
|
||||
ui_event_t e = { 0 };
|
||||
|
||||
// TODO:
|
||||
e.type = UI_EVENT_WHEEL;
|
||||
e.wheel.delta_mode = UI_WHEEL_DELTA_PIXEL;
|
||||
e.wheel.delta_y = wheel->delta_y;
|
||||
ui_dispatch_event(&e);
|
||||
}
|
||||
|
||||
void lcui_dispatch_ui_event(ptk_event_t *app_event)
|
||||
{
|
||||
switch (app_event->type) {
|
||||
case PTK_EVENT_KEYDOWN:
|
||||
lcui_dispatch_ui_keyboard_event(UI_EVENT_KEYDOWN, app_event);
|
||||
break;
|
||||
case PTK_EVENT_KEYUP:
|
||||
lcui_dispatch_ui_keyboard_event(UI_EVENT_KEYUP, app_event);
|
||||
break;
|
||||
case PTK_EVENT_KEYPRESS:
|
||||
lcui_dispatch_ui_keyboard_event(UI_EVENT_KEYPRESS, app_event);
|
||||
break;
|
||||
case PTK_EVENT_MOUSEDOWN:
|
||||
lcui_dispatch_ui_mouse_event(UI_EVENT_MOUSEDOWN, app_event);
|
||||
break;
|
||||
case PTK_EVENT_MOUSEUP:
|
||||
lcui_dispatch_ui_mouse_event(UI_EVENT_MOUSEUP, app_event);
|
||||
break;
|
||||
case PTK_EVENT_MOUSEMOVE:
|
||||
lcui_dispatch_ui_mouse_event(UI_EVENT_MOUSEMOVE, app_event);
|
||||
break;
|
||||
case PTK_EVENT_TOUCH:
|
||||
lcui_dispatch_ui_touch_event(app_event);
|
||||
break;
|
||||
case PTK_EVENT_WHEEL:
|
||||
lcui_dispatch_ui_wheel_event(&app_event->wheel);
|
||||
break;
|
||||
case PTK_EVENT_COMPOSITION:
|
||||
lcui_dispatch_ui_textinput_event(app_event);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
size_t lcui_render_ui(void)
|
||||
size_t lcui_ui_render(void)
|
||||
{
|
||||
return ui_server_render();
|
||||
}
|
||||
|
||||
void lcui_update_ui(void)
|
||||
void lcui_ui_update(void)
|
||||
{
|
||||
ui_server_update();
|
||||
thread_mutex_lock(&lcui_ui.image_loader.mutex);
|
||||
@@ -167,12 +50,12 @@ void lcui_update_ui(void)
|
||||
thread_mutex_unlock(&lcui_ui.image_loader.mutex);
|
||||
}
|
||||
|
||||
static void lcui_process_ui_mutation(ui_mutation_record_t *mutation)
|
||||
static void lcui_ui_process_mutation(ui_mutation_record_t *mutation)
|
||||
{
|
||||
list_node_t *node;
|
||||
|
||||
if (mutation->type != UI_MUTATION_RECORD_TYPE_CHILD_LIST ||
|
||||
lcui_ui.mode != LCUI_DISPLAY_MODE_SEAMLESS) {
|
||||
lcui_ui.mode != LCUI_DISPLAY_SEAMLESS) {
|
||||
return;
|
||||
}
|
||||
for (list_each(node, &mutation->removed_widgets)) {
|
||||
@@ -183,17 +66,17 @@ static void lcui_process_ui_mutation(ui_mutation_record_t *mutation)
|
||||
}
|
||||
}
|
||||
|
||||
static void lcui_on_ui_mutation(ui_mutation_list_t *mutation_list,
|
||||
static void lcui_ui_on_mutation(ui_mutation_list_t *mutation_list,
|
||||
ui_mutation_observer_t *observer, void *arg)
|
||||
{
|
||||
list_node_t *node;
|
||||
|
||||
for (list_each(node, mutation_list)) {
|
||||
lcui_process_ui_mutation(node->data);
|
||||
lcui_ui_process_mutation(node->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void lcui_on_window_destroy(ptk_event_t *e, void *arg)
|
||||
static void lcui_ui_on_window_destroy(ptk_event_t *e, void *arg)
|
||||
{
|
||||
list_node_t *node;
|
||||
|
||||
@@ -205,35 +88,35 @@ static void lcui_on_window_destroy(ptk_event_t *e, void *arg)
|
||||
}
|
||||
if (lcui_ui.quit_after_all_windows_closed &&
|
||||
lcui_ui.windows.length == 0) {
|
||||
lcui_quit();
|
||||
ptk_app_exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
static void lcui_close_window(void *arg)
|
||||
static void lcui_ui_close_window(void *arg)
|
||||
{
|
||||
ptk_window_close(arg);
|
||||
}
|
||||
|
||||
void lcui_set_ui_display_mode(lcui_display_mode_t mode)
|
||||
void lcui_ui_set_display(lcui_display_t mode)
|
||||
{
|
||||
ptk_window_t *wnd;
|
||||
list_node_t *node;
|
||||
ui_mutation_observer_init_t options = { 0 };
|
||||
|
||||
if (mode == LCUI_DISPLAY_MODE_DEFAULT) {
|
||||
mode = LCUI_DISPLAY_MODE_WINDOWED;
|
||||
if (mode == LCUI_DISPLAY_DEFAULT) {
|
||||
mode = LCUI_DISPLAY_WINDOWED;
|
||||
}
|
||||
if (lcui_ui.mode == mode) {
|
||||
return;
|
||||
}
|
||||
if (lcui_ui.mode == LCUI_DISPLAY_MODE_FULLSCREEN ||
|
||||
lcui_ui.mode == LCUI_DISPLAY_MODE_WINDOWED) {
|
||||
if (lcui_ui.mode == LCUI_DISPLAY_FULLSCREEN ||
|
||||
lcui_ui.mode == LCUI_DISPLAY_WINDOWED) {
|
||||
wnd = ui_server_get_window(ui_root());
|
||||
if (mode == LCUI_DISPLAY_MODE_FULLSCREEN) {
|
||||
if (mode == LCUI_DISPLAY_FULLSCREEN) {
|
||||
ptk_window_set_fullscreen(wnd, true);
|
||||
lcui_ui.mode = mode;
|
||||
return;
|
||||
} else if (mode == LCUI_DISPLAY_MODE_WINDOWED) {
|
||||
} else if (mode == LCUI_DISPLAY_WINDOWED) {
|
||||
ptk_window_set_fullscreen(wnd, false);
|
||||
lcui_ui.mode = mode;
|
||||
return;
|
||||
@@ -245,19 +128,19 @@ void lcui_set_ui_display_mode(lcui_display_mode_t mode)
|
||||
lcui_ui.observer = NULL;
|
||||
}
|
||||
lcui_ui.quit_after_all_windows_closed = false;
|
||||
list_destroy(&lcui_ui.windows, lcui_close_window);
|
||||
list_destroy(&lcui_ui.windows, lcui_ui_close_window);
|
||||
switch (mode) {
|
||||
case LCUI_DISPLAY_MODE_FULLSCREEN:
|
||||
case LCUI_DISPLAY_FULLSCREEN:
|
||||
wnd = ptk_window_create(NULL, 0, 0, 0, 0, NULL);
|
||||
list_append(&lcui_ui.windows, wnd);
|
||||
ui_server_connect(ui_root(), wnd);
|
||||
ptk_window_set_fullscreen(wnd, true);
|
||||
ui_metrics.dpi = 1.f * ptk_window_get_dpi(wnd);
|
||||
break;
|
||||
case LCUI_DISPLAY_MODE_SEAMLESS:
|
||||
case LCUI_DISPLAY_SEAMLESS:
|
||||
options.child_list = true;
|
||||
lcui_ui.observer =
|
||||
ui_mutation_observer_create(lcui_on_ui_mutation, NULL);
|
||||
ui_mutation_observer_create(lcui_ui_on_mutation, NULL);
|
||||
ui_mutation_observer_observe(lcui_ui.observer, ui_root(),
|
||||
options);
|
||||
for (list_each(node, &ui_root()->children)) {
|
||||
@@ -265,7 +148,7 @@ void lcui_set_ui_display_mode(lcui_display_mode_t mode)
|
||||
ui_server_connect(node->data, wnd);
|
||||
}
|
||||
break;
|
||||
case LCUI_DISPLAY_MODE_WINDOWED:
|
||||
case LCUI_DISPLAY_WINDOWED:
|
||||
default:
|
||||
wnd = ptk_window_create(NULL, 0, 0, 0, 0, NULL);
|
||||
list_append(&lcui_ui.windows, wnd);
|
||||
@@ -277,134 +160,6 @@ void lcui_set_ui_display_mode(lcui_display_mode_t mode)
|
||||
lcui_ui.quit_after_all_windows_closed = true;
|
||||
}
|
||||
|
||||
void lcui_init_ui_preset_widgets(void)
|
||||
{
|
||||
ui_register_text();
|
||||
ui_register_canvas();
|
||||
ui_register_anchor();
|
||||
ui_register_button();
|
||||
ui_register_scrollarea();
|
||||
ui_register_scrollbar();
|
||||
ui_register_textcaret();
|
||||
ui_register_textinput();
|
||||
}
|
||||
|
||||
void lcui_destroy_ui_preset_widgets(void)
|
||||
{
|
||||
ui_unregister_text();
|
||||
ui_unregister_anchor();
|
||||
}
|
||||
|
||||
#ifdef PTK_WIN32
|
||||
static void lcui_load_fonts_for_windows(void)
|
||||
{
|
||||
size_t i;
|
||||
int *ids = NULL;
|
||||
const char *names[] = { "Consola", "Simsun", "Microsoft YaHei", NULL };
|
||||
const char *fonts[] = { "C:/Windows/Fonts/consola.ttf",
|
||||
"C:/Windows/Fonts/simsun.ttc",
|
||||
"C:/Windows/Fonts/msyh.ttf",
|
||||
"C:/Windows/Fonts/msyh.ttc" };
|
||||
|
||||
for (i = 0; i < sizeof(fonts) / sizeof(char *); ++i) {
|
||||
pd_font_library_load_file(fonts[i]);
|
||||
}
|
||||
i = pd_font_library_query(&ids, PD_FONT_STYLE_NORMAL,
|
||||
PD_FONT_WEIGHT_NORMAL, names);
|
||||
if (i > 0) {
|
||||
pd_font_library_set_default_font(ids[i - 1]);
|
||||
}
|
||||
free(ids);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#ifdef HAVE_FONTCONFIG
|
||||
|
||||
static void lcui_load_fonts_by_font_config(void)
|
||||
{
|
||||
size_t i;
|
||||
char *path;
|
||||
int *ids = NULL;
|
||||
const char *names[] = { "Noto Sans CJK", "Ubuntu",
|
||||
"WenQuanYi Micro Hei", NULL };
|
||||
const char *fonts[] = { "Ubuntu", "Noto Sans CJK SC",
|
||||
"WenQuanYi Micro Hei" };
|
||||
|
||||
for (i = 0; i < sizeof(fonts) / sizeof(char *); ++i) {
|
||||
path = pd_font_library_get_font_path(fonts[i]);
|
||||
pd_font_library_load_file(path);
|
||||
free(path);
|
||||
}
|
||||
i = pd_font_library_query(&ids, PD_FONT_STYLE_NORMAL,
|
||||
PD_FONT_WEIGHT_NORMAL, names);
|
||||
if (i > 0) {
|
||||
pd_font_library_set_default_font(ids[i - 1]);
|
||||
}
|
||||
free(ids);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void lcui_load_fonts_for_linux(void)
|
||||
{
|
||||
size_t i;
|
||||
int *ids = NULL;
|
||||
const char *names[] = { "Noto Sans CJK SC", "Ubuntu", "Ubuntu Mono",
|
||||
"WenQuanYi Micro Hei", NULL };
|
||||
const char *fonts[] = {
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-BI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-B.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-C.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-LI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-L.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-MI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/UbuntuMono-BI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/UbuntuMono-B.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/UbuntuMono-RI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/UbuntuMono-R.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-M.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-RI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu/Ubuntu-R.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-RI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-B.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-BI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-M.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-MI.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-L.ttf",
|
||||
"/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-LI.ttf",
|
||||
"/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc",
|
||||
"/usr/share/fonts/opentype/noto/NotoSansCJK.ttc",
|
||||
"/usr/share/fonts/truetype/wqy/wqy-microhei.ttc"
|
||||
};
|
||||
|
||||
for (i = 0; i < sizeof(fonts) / sizeof(char *); ++i) {
|
||||
pd_font_library_load_file(fonts[i]);
|
||||
}
|
||||
i = pd_font_library_query(&ids, PD_FONT_STYLE_NORMAL,
|
||||
PD_FONT_WEIGHT_NORMAL, names);
|
||||
if (i > 0) {
|
||||
pd_font_library_set_default_font(ids[i - 1]);
|
||||
}
|
||||
free(ids);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
static void lcui_load_default_fonts(void)
|
||||
{
|
||||
#ifdef PTK_WIN32
|
||||
lcui_load_fonts_for_windows();
|
||||
#elif defined(HAVE_FONTCONFIG)
|
||||
logger_debug("[font] fontconfig enabled\n");
|
||||
lcui_load_fonts_by_font_config();
|
||||
#else
|
||||
lcui_load_fonts_for_linux();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void lcui_ui_image_loader_refresh(void)
|
||||
{
|
||||
thread_mutex_lock(&lcui_ui.image_loader.mutex);
|
||||
@@ -429,7 +184,7 @@ static void lcui_ui_image_loader_thread(void *unused)
|
||||
thread_exit(NULL);
|
||||
}
|
||||
|
||||
void lcui_init_ui(void)
|
||||
void lcui_ui_init(void)
|
||||
{
|
||||
thread_cond_init(&lcui_ui.image_loader.cond);
|
||||
thread_mutex_init(&lcui_ui.image_loader.mutex);
|
||||
@@ -446,16 +201,14 @@ void lcui_init_ui(void)
|
||||
ui_widget_resize(ui_root(), DEFAULT_WINDOW_WIDTH,
|
||||
DEFAULT_WINDOW_HEIGHT);
|
||||
list_create(&lcui_ui.windows);
|
||||
lcui_set_ui_display_mode(LCUI_DISPLAY_MODE_DEFAULT);
|
||||
lcui_init_ui_preset_widgets();
|
||||
lcui_load_default_fonts();
|
||||
ptk_on_event(PTK_EVENT_CLOSE, lcui_on_window_destroy, NULL);
|
||||
lcui_ui_set_display(LCUI_DISPLAY_DEFAULT);
|
||||
ptk_on_event(PTK_EVENT_CLOSE, lcui_ui_on_window_destroy, NULL);
|
||||
}
|
||||
|
||||
void lcui_destroy_ui(void)
|
||||
void lcui_ui_destroy(void)
|
||||
{
|
||||
ptk_off_event(PTK_EVENT_CLOSE, lcui_on_window_destroy);
|
||||
list_destroy(&lcui_ui.windows, lcui_close_window);
|
||||
ptk_off_event(PTK_EVENT_CLOSE, lcui_ui_on_window_destroy);
|
||||
list_destroy(&lcui_ui.windows, lcui_ui_close_window);
|
||||
if (lcui_ui.observer) {
|
||||
ui_mutation_observer_disconnect(lcui_ui.observer);
|
||||
ui_mutation_observer_destroy(lcui_ui.observer);
|
||||
@@ -467,7 +220,6 @@ void lcui_destroy_ui(void)
|
||||
thread_join(lcui_ui.image_loader.thread, NULL);
|
||||
thread_mutex_destroy(&lcui_ui.image_loader.mutex);
|
||||
thread_cond_destroy(&lcui_ui.image_loader.cond);
|
||||
lcui_destroy_ui_preset_widgets();
|
||||
ui_server_destroy();
|
||||
ui_destroy();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* src/lcui_widgets.c
|
||||
*
|
||||
* Copyright (c) 2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <LCUI/widgets.h>
|
||||
|
||||
void lcui_widgets_init(void)
|
||||
{
|
||||
ui_register_text();
|
||||
ui_register_canvas();
|
||||
ui_register_anchor();
|
||||
ui_register_button();
|
||||
ui_register_scrollarea();
|
||||
ui_register_scrollbar();
|
||||
ui_register_textcaret();
|
||||
ui_register_textinput();
|
||||
ui_register_router_link();
|
||||
ui_register_router_view();
|
||||
}
|
||||
|
||||
void lcui_widgets_destroy(void)
|
||||
{
|
||||
ui_unregister_text();
|
||||
ui_unregister_anchor();
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* src/lcui_worker.c
|
||||
*
|
||||
* Copyright (c) 2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found in the
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <ptk.h>
|
||||
#include <yutil.h>
|
||||
#include <LCUI/config.h>
|
||||
#include <LCUI/worker.h>
|
||||
|
||||
static struct lcui_worker {
|
||||
worker_t *main_worker;
|
||||
worker_t *async_worker;
|
||||
} lcui_worker;
|
||||
|
||||
worker_task_t *lcui_worker_post_task(void *data, worker_task_cb task_cb,
|
||||
worker_task_cb after_task_cb)
|
||||
{
|
||||
if (!lcui_worker.main_worker) {
|
||||
return NULL;
|
||||
}
|
||||
return worker_post_task(lcui_worker.main_worker, data, task_cb,
|
||||
after_task_cb);
|
||||
}
|
||||
|
||||
worker_task_t *lcui_worker_post_async_task(void *data, worker_task_cb task_cb,
|
||||
worker_task_cb after_task_cb)
|
||||
{
|
||||
return worker_post_task(lcui_worker.async_worker, data, task_cb,
|
||||
after_task_cb);
|
||||
}
|
||||
|
||||
bool lcui_worker_cancel_async_task(worker_task_t *task)
|
||||
{
|
||||
return worker_cancel_task(lcui_worker.async_worker, task);
|
||||
}
|
||||
|
||||
bool lcui_worker_cancel_task(worker_task_t *task)
|
||||
{
|
||||
return worker_cancel_task(lcui_worker.async_worker, task);
|
||||
}
|
||||
|
||||
void lcui_worker_run(void)
|
||||
{
|
||||
worker_run(lcui_worker.main_worker);
|
||||
}
|
||||
|
||||
void lcui_worker_init(void)
|
||||
{
|
||||
lcui_worker.main_worker = worker_create();
|
||||
lcui_worker.async_worker = worker_create();
|
||||
worker_run_async(lcui_worker.async_worker);
|
||||
}
|
||||
|
||||
void lcui_worker_destroy(void)
|
||||
{
|
||||
worker_destroy(lcui_worker.main_worker);
|
||||
worker_destroy(lcui_worker.async_worker);
|
||||
lcui_worker.main_worker = NULL;
|
||||
lcui_worker.async_worker = NULL;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-widgets/src/anchor.c: to <a> element in HTML.
|
||||
* src/widgets/anchor.c: to <a> element in HTML.
|
||||
*
|
||||
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
@@ -13,9 +13,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ui_xml.h>
|
||||
#include <ui_widgets/anchor.h>
|
||||
#include <worker.h>
|
||||
#include <ptk.h>
|
||||
#include <LCUI/widgets/anchor.h>
|
||||
|
||||
typedef struct xml_loader {
|
||||
/** 键,作为在视图加载完后传给事件处理器的额外参数 */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-widgets/src/button.c: -- Button widget
|
||||
* src/widgets/button.c: -- Button widget
|
||||
*
|
||||
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
@@ -13,8 +13,8 @@
|
||||
#include <string.h>
|
||||
#include <ui.h>
|
||||
#include <css.h>
|
||||
#include <ui_widgets/button.h>
|
||||
#include <ui_widgets/text.h>
|
||||
#include <LCUI/widgets/button.h>
|
||||
#include <LCUI/widgets/text.h>
|
||||
|
||||
static ui_widget_prototype_t *ui_button_prototype = NULL;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-widgets/src/canvas.c: -- canvas, used to draw custom graphics
|
||||
* src/widgets/canvas.c: -- canvas, used to draw custom graphics
|
||||
*
|
||||
* Copyright (c) 2019-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <pandagl.h>
|
||||
#include <ui.h>
|
||||
#include <ui_widgets/canvas.h>
|
||||
#include <LCUI/widgets/canvas.h>
|
||||
|
||||
typedef struct ui_canvas {
|
||||
pd_canvas_t buffer;
|
||||
@@ -0,0 +1,5 @@
|
||||
#define LCUI_VERSION "${VERSION}"
|
||||
#define LCUI_VERSION_MAJOR ${VERSION_MAJOR}
|
||||
#define LCUI_VERSION_MINOR ${VERSION_MINOR}
|
||||
#define LCUI_VERSION_ALTER ${VERSION_ALTER}
|
||||
${define LCUI_STATIC_BUILD}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-router/src/link.c
|
||||
* src/widgets/router_link.c
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
@@ -9,8 +9,9 @@
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "private.h"
|
||||
#include <ui_router.h>
|
||||
#include <ui.h>
|
||||
#include <router.h>
|
||||
#include <LCUI/widgets/router_link.h>
|
||||
|
||||
// Refer: https://router.vuejs.org/api/#router-link-props
|
||||
|
||||
@@ -59,7 +60,7 @@ static void ui_router_link_refresh(ui_widget_t *w)
|
||||
ui_router_link_t *link = ui_widget_get_data(w, ui_router_link_proto);
|
||||
if (link->router) {
|
||||
ui_router_link_on_route_update(
|
||||
w, link->router->history->current, NULL);
|
||||
w, router_get_current_route(link->router), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,14 +96,14 @@ static void ui_router_link_on_set_attr(ui_widget_t *w, const char *name,
|
||||
ui_widget_remove_class(w, link->exact_active_class);
|
||||
free(link->exact_active_class);
|
||||
}
|
||||
link->exact_active_class = strdup(value);
|
||||
link->exact_active_class = strdup2(value);
|
||||
ui_router_link_refresh(w);
|
||||
} else if (strcmp(name, "active-class") == 0) {
|
||||
if (link->active_class) {
|
||||
ui_widget_remove_class(w, link->active_class);
|
||||
free(link->active_class);
|
||||
}
|
||||
link->active_class = strdup(value);
|
||||
link->active_class = strdup2(value);
|
||||
ui_router_link_refresh(w);
|
||||
} else {
|
||||
ui_router_link_proto->proto->setattr(w, name, value);
|
||||
@@ -138,8 +139,8 @@ static void ui_router_link_on_init(ui_widget_t *w)
|
||||
|
||||
link = ui_widget_add_data(w, ui_router_link_proto,
|
||||
sizeof(ui_router_link_t));
|
||||
link->active_class = strdup("router-link-active");
|
||||
link->exact_active_class = strdup("router-link-exact-active");
|
||||
link->active_class = strdup2("router-link-active");
|
||||
link->exact_active_class = strdup2("router-link-exact-active");
|
||||
link->to = NULL;
|
||||
link->replace = false;
|
||||
link->exact = false;
|
||||
@@ -159,8 +160,8 @@ static void ui_router_link_on_destroy(ui_widget_t *w)
|
||||
router_unwatch(link->router, link->watcher);
|
||||
}
|
||||
router_location_destroy(link->to);
|
||||
router_mem_free(link->active_class);
|
||||
router_mem_free(link->exact_active_class);
|
||||
free(link->active_class);
|
||||
free(link->exact_active_class);
|
||||
link->watcher = NULL;
|
||||
link->to = NULL;
|
||||
ui_router_link_proto->proto->destroy(w);
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-router/src/view.c
|
||||
* src/widgets/router_view.c
|
||||
*
|
||||
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
@@ -9,8 +9,9 @@
|
||||
* LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "private.h"
|
||||
#include <ui_router.h>
|
||||
#include <ui.h>
|
||||
#include <router.h>
|
||||
#include <LCUI/widgets/router_view.h>
|
||||
|
||||
typedef struct ui_router_view {
|
||||
size_t index;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-widgets/src/scrollarea.c
|
||||
* src/widgets/scrollarea.c
|
||||
*
|
||||
* Copyright (c) 2024, Liu Chao <i@lc-soft.io> All rights reserved.
|
||||
*
|
||||
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
#include <ui.h>
|
||||
#include <ui_widgets/scrollarea.h>
|
||||
#include <LCUI/widgets/scrollarea.h>
|
||||
|
||||
typedef struct ui_scrollarea {
|
||||
float scroll_top;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* lib/ui-widgets/src/scrollbar.c: -- Scrollbar widget
|
||||
* src/widgets/scrollbar.c: -- Scrollbar widget
|
||||
*
|
||||
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
|
||||
*
|
||||
@@ -14,8 +14,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <css.h>
|
||||
#include <ui.h>
|
||||
#include <ui_widgets/scrollbar.h>
|
||||
#include <ui_widgets/scrollarea.h>
|
||||
#include <LCUI/widgets/scrollbar.h>
|
||||
#include <LCUI/widgets/scrollarea.h>
|
||||
#include <ptk.h>
|
||||
|
||||
typedef struct ui_scrollbar {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user