Skip to content

Commit

Permalink
refactor: update LCUI's dependencies on ui-widgets and ui-router
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Dec 28, 2024
1 parent ee68772 commit bfb81d8
Show file tree
Hide file tree
Showing 113 changed files with 1,798 additions and 1,655 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand All @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion include/LCUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
93 changes: 6 additions & 87 deletions include/LCUI/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
35 changes: 35 additions & 0 deletions include/LCUI/base.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* include/LCUI/base.h
*
* Copyright (c) 2024, Liu Chao <[email protected]> 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
1 change: 1 addition & 0 deletions include/LCUI/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions include/LCUI/settings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* include/LCUI/settings.h
*
* Copyright (c) 2024, Liu Chao <[email protected]> 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
38 changes: 38 additions & 0 deletions include/LCUI/ui.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* include/LCUI/ui.h
*
* Copyright (c) 2023-2024, Liu Chao <[email protected]> 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
21 changes: 21 additions & 0 deletions include/LCUI/widgets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* include/LCUI/widgets.h
*
* Copyright (c) 2023-2024, Liu Chao <[email protected]> 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"
28 changes: 28 additions & 0 deletions include/LCUI/widgets/anchor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* include/LCUI/widgets/anchor.h: to <a> element in HTML.
*
* Copyright (c) 2018-2024, Liu chao <[email protected]> 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
28 changes: 28 additions & 0 deletions include/LCUI/widgets/button.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* include/LCUI/widgets/button.h: -- LCUI‘s Button widget
*
* Copyright (c) 2018-2024, Liu chao <[email protected]> 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
Loading

0 comments on commit bfb81d8

Please sign in to comment.