Skip to content

Commit

Permalink
refactor: update header files and xmake.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Apr 29, 2023
1 parent d4ea54a commit f5d0d12
Show file tree
Hide file tree
Showing 107 changed files with 2,239 additions and 2,089 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PointerAlignment: Right
ReflowComments: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 4
SpacesInAngles: false
Expand All @@ -32,4 +32,4 @@ SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SortIncludes: false
UseTab: ForContinuationAndIndentation
UseTab: Never
8 changes: 0 additions & 8 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
const fs = require("fs");
const path = require("path");

module.exports = {
extends: ["@commitlint/config-conventional"],
rules: {
"header-min-length": [2, "always", 1],
"header-max-length": [2, "always", 72],
"subject-case": [0],
"scope-enum": [
2,
"always",
[...fs.readdirSync(path.resolve(__dirname, "lib")), "docs"],
],
},
};
46 changes: 36 additions & 10 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
- name: Build
run: |
xmake config -m coverage -y -v
xmake build headers
xmake -w
- name: Run PandaGL tests
Expand All @@ -45,15 +44,29 @@ jobs:
- name: Package
run: |
xmake clean
xmake config -m release -y -c -v
xmake -w
xmake config -m release -y -k shared -c -v
xmake package
xmake install -o dist/ubuntu
- name: Package exmaples
run: |
cd examples
xmake -P . -v
xmake install -P . -o ../dist/ubuntu-examples
mv ../dist/ubuntu-examples/bin/* ../dist/ubuntu-examples/
rm -r ../dist/ubuntu-examples/bin
- uses: actions/upload-artifact@master
with:
name: ubuntu-dist
path: |
dist/ubuntu
- uses: actions/upload-artifact@master
with:
name: ubuntu-pacakges
name: ubuntu-examples
path: |
build/packages
dist/ubuntu-examples
windows_build:
timeout-minutes: 10
Expand All @@ -77,8 +90,7 @@ jobs:
- name: Build
run: |
xmake config -y -v --ci-env=y
xmake build headers
xmake config -y -v -k shared --ci-env=y
xmake -w
- name: Run PandaGL tests
Expand All @@ -97,14 +109,28 @@ jobs:
- name: Package
run: |
xmake -v
xmake package
xmake install -o dist/windows
- name: Package exmaples
run: |
cd examples
xmake -P . -v
xmake install -P . -o ../dist/windows-examples
mv ../dist/windows-examples/bin/* ../dist/windows-examples/
rm ../dist/windows-examples/bin
- uses: actions/upload-artifact@master
with:
name: windows-dist
path: |
dist/windows
- uses: actions/upload-artifact@master
with:
name: ubuntu-pacakges
name: windows-examples
path: |
build/packages
dist/windows-examples
release:
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ test/build
lcpkg/*
!lcpkg/ports
vsxmake*
compile_commands.json
26 changes: 0 additions & 26 deletions .vscode/c_cpp_properties.json

This file was deleted.

31 changes: 0 additions & 31 deletions .vscode/settings.json

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<lcui-app>
<resource type="text/css" src="style.css"/>
<resource type="text/css" src="hello.css"/>
<ui>
<textview id="text-hello" type="textview" class="text-hello">
[i][color=#f00]Hello[/color][/i], [b][color=#fff][bgcolor=#f00]World![/bgcolor][/color][/b]
Expand Down
4 changes: 2 additions & 2 deletions examples/hello/src/main.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <LCUI.h>
#include <platform/main.h>
#include <ui_builder.h>
#include <ui_widgets/textview.h>
#include <ui_widgets/textedit.h>
#include <ui_xml.h>

static void on_btn_click(ui_widget_t* self, ui_event_t* e, void *arg)
{
Expand All @@ -19,7 +19,7 @@ int main(int argc, char **argv)
ui_widget_t *pack, *btn;

lcui_init();
pack = ui_load_xml_file("main.xml");
pack = ui_load_xml_file("hello.xml");
if (!pack) {
return -1;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/hello/xmake.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
target("hello")
set_default(false)
add_installfiles("app/*")
set_kind("binary")
set_rundir("app")
add_deps("lcui")
add_packages("lcui")
add_files("src/*.c")
6 changes: 6 additions & 0 deletions examples/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
add_repositories("lcui-repo ../build")
add_requires("lcui")
if is_plat("windows") then
add_rules("win.sdk.application")
end
includes("*/xmake.lua")
5 changes: 3 additions & 2 deletions include/LCUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#include <ui_widgets.h>
#include <ui_cursor.h>
#include <ui_server.h>
#include <ui_builder.h>
#include <ui_xml.h>
#include <platform.h>
#include <LCUI/timer.h>
#include <worker.h>
#include <timer.h>
#include <LCUI/app.h>
58 changes: 19 additions & 39 deletions include/LCUI/app.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef LCUI_H
#define LCUI_H
#ifndef LCUI_INCLUDE_LCUI_APP_H
#define LCUI_INCLUDE_LCUI_APP_H

#include <LCUI/def.h>
#include "common.h"
#include <platform.h>
#include <LCUI/worker.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))
Expand All @@ -13,11 +13,11 @@ LCUI_BEGIN_HEADER
// Settings

typedef struct lcui_settings_t {
int frame_rate_cap;
int parallel_rendering_threads;
LCUI_BOOL record_profile;
LCUI_BOOL fps_meter;
LCUI_BOOL paint_flashing;
int frame_rate_cap;
int parallel_rendering_threads;
bool record_profile;
bool fps_meter;
bool paint_flashing;
} lcui_settings_t;

/* Initialize settings with the current global settings. */
Expand All @@ -29,52 +29,32 @@ LCUI_API void lcui_apply_settings(lcui_settings_t *settings);
/* Reset global settings to their defaults. */
LCUI_API void lcui_reset_settings(void);

// Timers

LCUI_API int lcui_destroy_timer(int timer_id);
LCUI_API int lcui_pause_timer(int timer_id);
LCUI_API int lcui_continue_timer(int timer_id);
LCUI_API int lcui_reset_timer(int timer_id, long int n_ms);
LCUI_API int lcui_set_timeout(long int n_ms, void (*callback)(void *),
void *arg);
LCUI_API int lcui_set_interval(long int n_ms, void (*callback)(void *),
void *arg);

// Tasks

typedef void (*LCUI_AppTaskFunc)(void *, void *);

/**
* 添加任务
* 该任务将会添加至主线程中执行
*/
LCUI_API LCUI_BOOL lcui_post_task(LCUI_Task task);
LCUI_API bool lcui_post_task(worker_task_t *task);

/**
* 添加异步任务
* 该任务将会添加至指定 id 的工作线程中执行
* @param[in] task 任务数据
* @param[in] target_worker_id 目标工作线程的编号
*/
LCUI_API void lcui_post_async_task(LCUI_Task task, int target_worker_id);

/** lcui_post_task 的简化版本 */
#define lcui_post_simple_task(FUNC, ARG1, ARG2) \
do { \
LCUI_TaskRec _ui_task = { 0 }; \
_ui_task.arg[0] = (void *)ARG1; \
_ui_task.arg[1] = (void *)ARG2; \
_ui_task.func = (LCUI_AppTaskFunc)(FUNC); \
lcui_post_task(&_ui_task); \
} while (0);
LCUI_API void lcui_post_async_task(worker_task_t *task, int target_worker_id);

LCUI_API bool lcui_post_simple_task(worker_callback_t callback, void *arg1,
void *arg2);

// 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_DEFAULT,
LCUI_DISPLAY_MODE_WINDOWED,
LCUI_DISPLAY_MODE_FULLSCREEN,
LCUI_DISPLAY_MODE_SEAMLESS,
} lcui_display_mode_t;

LCUI_API void lcui_init_ui(void);
Expand All @@ -93,7 +73,7 @@ LCUI_API int lcui_process_events(app_process_events_option_t option);

INLINE int lcui_process_all_events(void)
{
return lcui_process_events(APP_PROCESS_EVENTS_ALL_IF_PRESENT);
return lcui_process_events(APP_PROCESS_EVENTS_ALL_IF_PRESENT);
}

// Base
Expand Down
Loading

0 comments on commit f5d0d12

Please sign in to comment.