Skip to content

Commit cdb04e1

Browse files
committed
refactor: update LCUI's dependencies on ui-widgets and ui-router
1 parent ee68772 commit cdb04e1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1799
-1656
lines changed

.github/workflows/ccpp.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ jobs:
5757
xmake build yutil_test
5858
xmake build pandagl_tests
5959
xmake build libcss_tests
60-
xmake build libui-router-tests
61-
xmake build libi18n-tests
60+
xmake build librouter_tests
61+
xmake build libi18n_tests
6262
xmake build lcui_tests
6363
6464
- name: Run tests for libraries with memcheck
@@ -67,8 +67,8 @@ jobs:
6767
xmake run pandagl_tests
6868
xmake run yutil_test --memcheck
6969
xmake run libcss_tests --memcheck
70-
xmake run libui-router-tests --memcheck
71-
xmake run libi18n-tests --memcheck
70+
xmake run librouter_tests --memcheck
71+
xmake run libi18n_tests --memcheck
7272
7373
- name: Run tests for lcui with memcheck
7474
if: runner.os == 'Linux'
@@ -81,8 +81,8 @@ jobs:
8181
xmake run pandagl_tests
8282
xmake run yutil_test
8383
xmake run libcss_tests
84-
xmake run libui-router-tests
85-
xmake run libi18n-tests
84+
xmake run librouter_tests
85+
xmake run libi18n_tests
8686
xmake run lcui_tests
8787
8888
- name: Upload reports to Codecov

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ vendor/lib
6767
build/*.png
6868
build/*.jpg
6969
config.h
70-
!lib/ui-router/include/ui_router/config.h
7170
test/build
72-
lcpkg/*
73-
!lcpkg/ports
7471
vsxmake*
7572
compile_commands.json

include/LCUI.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@
1313
#include <css.h>
1414
#include <pandagl.h>
1515
#include <ui.h>
16-
#include <ui_widgets.h>
1716
#include <ui_cursor.h>
1817
#include <ui_server.h>
1918
#include <ui_xml.h>
2019
#include <thread.h>
2120
#include <ptk.h>
2221
#include <worker.h>
22+
#include <LCUI/worker.h>
2323
#include <LCUI/app.h>
24+
#include <LCUI/ui.h>
25+
#include <LCUI/widgets.h>
26+
#include <LCUI/settings.h>
27+
#include <LCUI/base.h>

include/LCUI/app.h

+6-87
Original file line numberDiff line numberDiff line change
@@ -13,96 +13,15 @@
1313
#define LCUI_INCLUDE_LCUI_APP_H
1414

1515
#include "common.h"
16-
#include <ptk.h>
17-
#include <worker.h>
18-
19-
#define LCUI_MAX_FRAMES_PER_SEC 120
20-
#define LCUI_MAX_FRAME_MSEC ((int)(1000.0 / LCUI_MAX_FRAMES_PER_SEC + 0.5))
16+
#include <ptk/types.h>
2117

2218
LCUI_BEGIN_HEADER
2319

24-
// Settings
25-
26-
typedef struct lcui_settings {
27-
int frame_rate_cap;
28-
int parallel_rendering_threads;
29-
bool paint_flashing;
30-
} lcui_settings_t;
31-
32-
/* Initialize settings with the current global settings. */
33-
LCUI_API void lcui_get_settings(lcui_settings_t *settings);
34-
35-
/* Update global settings with the given input. */
36-
LCUI_API void lcui_apply_settings(lcui_settings_t *settings);
37-
38-
/* Reset global settings to their defaults. */
39-
LCUI_API void lcui_reset_settings(void);
40-
41-
// Tasks
42-
43-
LCUI_API worker_task_t *lcui_post_task(void *data, worker_task_cb task_cb,
44-
worker_task_cb after_task_cb);
45-
LCUI_API worker_task_t *lcui_post_async_task(void *data, worker_task_cb task_cb,
46-
worker_task_cb after_task_cb);
47-
48-
bool lcui_cancel_async_task(worker_task_t *task);
49-
bool lcui_cancel_task(worker_task_t *task);
50-
51-
// UI
52-
53-
typedef enum lcui_display_mode_t {
54-
LCUI_DISPLAY_MODE_DEFAULT,
55-
LCUI_DISPLAY_MODE_WINDOWED,
56-
LCUI_DISPLAY_MODE_FULLSCREEN,
57-
LCUI_DISPLAY_MODE_SEAMLESS,
58-
} lcui_display_mode_t;
59-
60-
LCUI_API void lcui_init_ui(void);
61-
LCUI_API void lcui_destroy_ui(void);
62-
LCUI_API void lcui_update_ui(void);
63-
LCUI_API size_t lcui_render_ui(void);
64-
LCUI_API void lcui_preset_ui(void);
65-
LCUI_API void lcui_dispatch_ui_event(ptk_event_t *app_event);
66-
LCUI_API void lcui_set_ui_display_mode(lcui_display_mode_t mode);
67-
68-
// Event
69-
70-
LCUI_API int lcui_get_event(ptk_event_t *e);
71-
LCUI_API int lcui_process_event(ptk_event_t *e);
72-
LCUI_API int lcui_process_events(ptk_process_events_option_t option);
73-
74-
INLINE int lcui_process_all_events(void)
75-
{
76-
return lcui_process_events(PTK_PROCESS_EVENTS_ALL_IF_PRESENT);
77-
}
78-
79-
// Base
80-
81-
LCUI_API uint32_t lcui_get_fps(void);
82-
83-
LCUI_API void lcui_set_frame_rate_cap(unsigned rate_cap);
84-
85-
LCUI_API void lcui_init_app(void);
86-
LCUI_API void lcui_destroy_app(void);
87-
88-
/** 初始化 LCUI 各项功能 */
89-
LCUI_API void lcui_init(void);
90-
91-
LCUI_API int lcui_main(void);
92-
93-
LCUI_API int lcui_run(void);
94-
95-
/** 获取LCUI的版本 */
96-
LCUI_API const char *lcui_get_version(void);
97-
98-
/** 释放LCUI占用的资源 */
99-
LCUI_API void lcui_destroy(void);
100-
101-
/** 退出LCUI,释放LCUI占用的资源 */
102-
LCUI_API void lcui_quit(void);
103-
104-
/** 退出 LCUI,并设置退出码 */
105-
LCUI_API void lcui_exit(int code);
20+
LCUI_API uint32_t lcui_app_get_fps(void);
21+
LCUI_API void lcui_app_set_frame_rate_cap(unsigned rate_cap);
22+
LCUI_API int lcui_app_process_events(ptk_process_events_option_t option);
23+
LCUI_API void lcui_app_init(void);
24+
LCUI_API void lcui_app_destroy(void);
10625

10726
LCUI_END_HEADER
10827

include/LCUI/base.h

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* include/LCUI/base.h
3+
*
4+
* Copyright (c) 2024, Liu Chao <i@lc-soft.io> All rights reserved.
5+
*
6+
* SPDX-License-Identifier: MIT
7+
*
8+
* This file is part of LCUI, distributed under the MIT License found in the
9+
* LICENSE.TXT file in the root directory of this source tree.
10+
*/
11+
12+
#ifndef LCUI_INCLUDE_LCUI_BASE_H
13+
#define LCUI_INCLUDE_LCUI_BASE_H
14+
15+
#include "common.h"
16+
17+
LCUI_BEGIN_HEADER
18+
19+
LCUI_API const char *lcui_get_version(void);
20+
21+
LCUI_API void lcui_init(void);
22+
23+
LCUI_API void lcui_destroy(void);
24+
25+
LCUI_API int lcui_run(void);
26+
27+
LCUI_API int lcui_main(void);
28+
29+
LCUI_API void lcui_exit(int code);
30+
31+
LCUI_API void lcui_quit(void);
32+
33+
LCUI_END_HEADER
34+
35+
#endif

include/LCUI/common.h

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#ifndef LCUI_INCLUDE_LCUI_COMMON_H
1313
#define LCUI_INCLUDE_LCUI_COMMON_H
1414

15+
#include <stddef.h>
1516
#include "config.h"
1617

1718
#ifndef LCUI_API

include/LCUI/settings.h

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* include/LCUI/settings.h
3+
*
4+
* Copyright (c) 2024, Liu Chao <i@lc-soft.io> All rights reserved.
5+
*
6+
* SPDX-License-Identifier: MIT
7+
*
8+
* This file is part of LCUI, distributed under the MIT License found in the
9+
* LICENSE.TXT file in the root directory of this source tree.
10+
*/
11+
12+
#ifndef LCUI_INCLUDE_LCUI_SETTINGS_H
13+
#define LCUI_INCLUDE_LCUI_SETTINGS_H
14+
15+
#include "common.h"
16+
17+
#define LCUI_MAX_FRAMES_PER_SEC 120
18+
#define LCUI_MAX_FRAME_MSEC ((int)(1000.0 / LCUI_MAX_FRAMES_PER_SEC + 0.5))
19+
20+
LCUI_BEGIN_HEADER
21+
22+
typedef struct lcui_settings {
23+
int frame_rate_cap;
24+
int parallel_rendering_threads;
25+
bool paint_flashing;
26+
} lcui_settings_t;
27+
28+
/* Initialize settings with the current global settings. */
29+
LCUI_API void lcui_get_settings(lcui_settings_t *settings);
30+
31+
/* Update global settings with the given input. */
32+
LCUI_API void lcui_apply_settings(lcui_settings_t *settings);
33+
34+
/* Reset global settings to their defaults. */
35+
LCUI_API void lcui_reset_settings(void);
36+
37+
#endif

include/LCUI/ui.h

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* include/LCUI/ui.h
3+
*
4+
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
5+
*
6+
* SPDX-License-Identifier: MIT
7+
*
8+
* This file is part of LCUI, distributed under the MIT License found in the
9+
* LICENSE.TXT file in the root directory of this source tree.
10+
*/
11+
12+
#ifndef LCUI_INCLUDE_UI_H
13+
#define LCUI_INCLUDE_UI_H
14+
15+
#include "common.h"
16+
17+
LCUI_BEGIN_HEADER
18+
19+
typedef enum {
20+
LCUI_DISPLAY_DEFAULT,
21+
LCUI_DISPLAY_WINDOWED,
22+
LCUI_DISPLAY_FULLSCREEN,
23+
LCUI_DISPLAY_SEAMLESS,
24+
} lcui_display_t;
25+
26+
LCUI_API size_t lcui_ui_render(void);
27+
28+
LCUI_API void lcui_ui_update(void);
29+
30+
LCUI_API void lcui_ui_set_display(lcui_display_t mode);
31+
32+
LCUI_API void lcui_ui_init(void);
33+
34+
LCUI_API void lcui_ui_destroy(void);
35+
36+
LCUI_END_HEADER
37+
38+
#endif

include/LCUI/widgets.h

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* include/LCUI/widgets.h
3+
*
4+
* Copyright (c) 2023-2024, Liu Chao <i@lc-soft.io> All rights reserved.
5+
*
6+
* SPDX-License-Identifier: MIT
7+
*
8+
* This file is part of LCUI, distributed under the MIT License found in the
9+
* LICENSE.TXT file in the root directory of this source tree.
10+
*/
11+
12+
#include "widgets/text.h"
13+
#include "widgets/button.h"
14+
#include "widgets/anchor.h"
15+
#include "widgets/canvas.h"
16+
#include "widgets/scrollarea.h"
17+
#include "widgets/scrollbar.h"
18+
#include "widgets/textinput.h"
19+
#include "widgets/textcaret.h"
20+
#include "widgets/router_link.h"
21+
#include "widgets/router_view.h"

include/LCUI/widgets/anchor.h

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* include/LCUI/widgets/anchor.h: to <a> element in HTML.
3+
*
4+
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
5+
*
6+
* SPDX-License-Identifier: MIT
7+
*
8+
* This file is part of LCUI, distributed under the MIT License found in the
9+
* LICENSE.TXT file in the root directory of this source tree.
10+
*/
11+
12+
#ifndef LCUI_INCLUDE_WIDGETS_ANCHOR_H
13+
#define LCUI_INCLUDE_WIDGETS_ANCHOR_H
14+
15+
#include <LCUI/common.h>
16+
#include <ui.h>
17+
18+
LCUI_BEGIN_HEADER
19+
20+
LCUI_API void ui_anchor_open(ui_widget_t* w);
21+
22+
LCUI_API void ui_register_anchor(void);
23+
24+
LCUI_API void ui_unregister_anchor(void);
25+
26+
LCUI_END_HEADER
27+
28+
#endif

include/LCUI/widgets/button.h

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* include/LCUI/widgets/button.h: -- LCUI‘s Button widget
3+
*
4+
* Copyright (c) 2018-2024, Liu chao <lc-soft@live.cn> All rights reserved.
5+
*
6+
* SPDX-License-Identifier: MIT
7+
*
8+
* This file is part of LCUI, distributed under the MIT License found in the
9+
* LICENSE.TXT file in the root directory of this source tree.
10+
*/
11+
12+
#ifndef LCUI_INCLUDE_WIDGETS_BUTTON_H
13+
#define LCUI_INCLUDE_WIDGETS_BUTTON_H
14+
15+
#include <LCUI/common.h>
16+
#include <ui.h>
17+
18+
LCUI_BEGIN_HEADER
19+
20+
LCUI_API void ui_button_set_text_w(ui_widget_t* w, const wchar_t *wstr);
21+
22+
LCUI_API void ui_button_set_text(ui_widget_t* w, const char *str);
23+
24+
LCUI_API void ui_register_button(void);
25+
26+
LCUI_END_HEADER
27+
28+
#endif

0 commit comments

Comments
 (0)