[deploy] Change source code charset to gb2312

This commit is contained in:
Nomango 2020-03-19 14:28:50 +08:00
parent 320bd9c8dc
commit a1e7e77c96
105 changed files with 2752 additions and 2751 deletions

View File

@ -11,7 +11,7 @@ insert_final_newline = true
# Matches multiple files with brace expansion notation
# Set default charset
[*.{h,hpp,cpp}]
charset = utf8
charset = gb2312
# 4 space indentation
indent_style = space

View File

@ -32,7 +32,7 @@ SHOW_NAMESPACES = YES
#---------------------------------------------------------------------------
INPUT = src/
INPUT_ENCODING = UTF-8
INPUT_ENCODING = GBK
FILE_PATTERNS = *.c \
*.cc \
*.cxx \

View File

@ -74,7 +74,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths>
</ClCompile>
<Link>
@ -94,7 +93,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths>
</ClCompile>
<Link>
@ -112,4 +110,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -73,7 +73,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths>
</ClCompile>
<Link>
@ -93,7 +92,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths>
</ClCompile>
<Link>
@ -114,4 +112,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -69,7 +69,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths>
</ClCompile>
<Link>
@ -89,7 +88,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths>
</ClCompile>
<Link>
@ -110,4 +108,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -80,7 +80,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths>
</ClCompile>
<Link>
@ -100,7 +99,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths>
</ClCompile>
<Link>
@ -121,4 +119,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -229,7 +229,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths>
</ClCompile>
<Link>
@ -249,7 +248,6 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>../../src;</AdditionalIncludeDirectories>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<UseFullPaths>false</UseFullPaths>
</ClCompile>
<Link>
@ -262,4 +260,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -32,7 +32,7 @@ namespace audio
/**
* \~chinese
* \defgroup Audio
* \defgroup Audio
*/
/**
@ -42,7 +42,7 @@ namespace audio
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API AudioModule
: public Singleton<AudioModule>
@ -52,15 +52,15 @@ class KGE_API AudioModule
public:
/// \~chinese
/// @brief 开启音频设备
/// @brief 开启音频设备
void Open();
/// \~chinese
/// @brief 关闭音频设备
/// @brief 关闭音频设备
void Close();
/// \~chinese
/// @brief 从解码器数据缓冲中创建音频对象
/// @brief 从解码器数据缓冲中创建音频对象
bool CreateSound(Sound& sound, const Transcoder::Buffer& buffer);
public:

View File

@ -40,7 +40,7 @@ KGE_DECLARE_SMART_PTR(Sound);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Sound : public ObjectBase
{
@ -48,13 +48,13 @@ class KGE_API Sound : public ObjectBase
public:
/// \~chinese
/// @brief 创建音频对象
/// @param res 本地音频文件路径
/// @brief 创建音频对象
/// @param res 本地音频文件路径
static SoundPtr Create(const String& file_path);
/// \~chinese
/// @brief 创建音频对象
/// @param res 音频资源
/// @brief 创建音频对象
/// @param res 音频资源
static SoundPtr Create(const Resource& res);
Sound();
@ -62,51 +62,51 @@ public:
virtual ~Sound();
/// \~chinese
/// @brief 打开本地音频文件
/// @param res 本地音频文件路径
/// @brief 打开本地音频文件
/// @param res 本地音频文件路径
bool Load(const String& file_path);
/// \~chinese
/// @brief 打开音频资源
/// @param res 音频资源
/// @brief 打开音频资源
/// @param res 音频资源
bool Load(const Resource& res);
/// \~chinese
/// @brief 是否有效
/// @brief 是否有效
bool IsValid() const;
/// \~chinese
/// @brief 播放
/// @param loop_count 播放循环次数,设置 -1 为循环播放
/// @brief 播放
/// @param loop_count 播放循环次数,设置 -1 为循环播放
void Play(int loop_count = 0);
/// \~chinese
/// @brief 暂停
/// @brief 暂停
void Pause();
/// \~chinese
/// @brief 继续
/// @brief 继续
void Resume();
/// \~chinese
/// @brief 停止
/// @brief 停止
void Stop();
/// \~chinese
/// @brief 关闭并销毁资源
/// @brief 关闭并销毁资源
void Close();
/// \~chinese
/// @brief 是否正在播放
/// @brief 是否正在播放
bool IsPlaying() const;
/// \~chinese
/// @brief 获取音量
/// @brief 获取音量
float GetVolume() const;
/// \~chinese
/// @brief 设置音量
/// @param volume 音量大小1.0 为原始音量, 大于 1 为放大音量, 0 为最小音量
/// @brief 设置音量
/// @param volume 音量大小1.0 为原始音量, 大于 1 为放大音量, 0 为最小音量
void SetVolume(float volume);
private:

View File

@ -35,13 +35,13 @@ KGE_DECLARE_SMART_PTR(SoundPlayer);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API SoundPlayer : public ObjectBase
{
public:
/// \~chinese
/// @brief 创建音频播放器
/// @brief 创建音频播放器
static SoundPlayerPtr Create();
SoundPlayer();
@ -49,66 +49,66 @@ public:
~SoundPlayer();
/// \~chinese
/// @brief 加载本地音频文件
/// @param file_path 本地音频文件路径
/// @return 音频标识符
/// @brief 加载本地音频文件
/// @param file_path 本地音频文件路径
/// @return 音频标识符
size_t Load(const String& file_path);
/// \~chinese
/// @brief 加载音频资源
/// @param res 音频资源
/// @return 音频标识符
/// @brief 加载音频资源
/// @param res 音频资源
/// @return 音频标识符
size_t Load(const Resource& res);
/// \~chinese
/// @brief 播放音频
/// @param id 音频标识符
/// @param loop_count 播放循环次数,设置 -1 为循环播放
/// @brief 播放音频
/// @param id 音频标识符
/// @param loop_count 播放循环次数,设置 -1 为循环播放
void Play(size_t id, int loop_count = 0);
/// \~chinese
/// @brief 暂停音频
/// @param id 音频标识符
/// @brief 暂停音频
/// @param id 音频标识符
void Pause(size_t id);
/// \~chinese
/// @brief 继续播放音频
/// @param id 音频标识符
/// @brief 继续播放音频
/// @param id 音频标识符
void Resume(size_t id);
/// \~chinese
/// @brief 停止音频
/// @param id 音频标识符
/// @brief 停止音频
/// @param id 音频标识符
void Stop(size_t id);
/// \~chinese
/// @brief 获取音频播放状态
/// @param id 音频标识符
/// @brief 获取音频播放状态
/// @param id 音频标识符
bool IsPlaying(size_t id);
/// \~chinese
/// @brief 获取音量
/// @brief 获取音量
float GetVolume() const;
/// \~chinese
/// @brief 设置音量
/// @param volume 音量大小1.0 为原始音量, 大于 1 为放大音量, 0 为最小音量
/// @brief 设置音量
/// @param volume 音量大小1.0 为原始音量, 大于 1 为放大音量, 0 为最小音量
void SetVolume(float volume);
/// \~chinese
/// @brief 暂停所有音频
/// @brief 暂停所有音频
void PauseAll();
/// \~chinese
/// @brief 继续播放所有音频
/// @brief 继续播放所有音频
void ResumeAll();
/// \~chinese
/// @brief 停止所有音频
/// @brief 停止所有音频
void StopAll();
/// \~chinese
/// @brief 清除缓存
/// @brief 清除缓存
void ClearCache();
private:

View File

@ -148,25 +148,25 @@ HRESULT Transcoder::ReadSource(IMFSourceReader* reader)
hr = partial_type->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_PCM);
}
// 设置 source reader 的媒体类型,它将使用合适的解码器去解码这个音频
// 设置 source reader 的媒体类型,它将使用合适的解码器去解码这个音频
if (SUCCEEDED(hr))
{
hr = reader->SetCurrentMediaType((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, partial_type.Get());
}
// 从 IMFMediaType 中获取 WAVEFORMAT 结构
// 从 IMFMediaType 中获取 WAVEFORMAT 结构
if (SUCCEEDED(hr))
{
hr = reader->GetCurrentMediaType((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, &uncompressed_type);
}
// 指定音频流
// 指定音频流
if (SUCCEEDED(hr))
{
hr = reader->SetStreamSelection((DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, true);
}
// 获取 WAVEFORMAT 数据
// 获取 WAVEFORMAT 数据
if (SUCCEEDED(hr))
{
uint32_t size = 0;
@ -174,7 +174,7 @@ HRESULT Transcoder::ReadSource(IMFSourceReader* reader)
uncompressed_type.Get(), &wave_format_, &size, (DWORD)MFWaveFormatExConvertFlag_Normal);
}
// 估算音频流大小
// 估算音频流大小
if (SUCCEEDED(hr))
{
PROPVARIANT prop;
@ -187,7 +187,7 @@ HRESULT Transcoder::ReadSource(IMFSourceReader* reader)
PropVariantClear(&prop);
}
// 读取音频数据
// 读取音频数据
if (SUCCEEDED(hr))
{
DWORD flags = 0;

View File

@ -37,7 +37,7 @@ class Sound;
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Transcoder
{
@ -46,13 +46,13 @@ class KGE_API Transcoder
public:
/**
* \~chinese
* @brief
* @brief
*/
struct Buffer
{
BYTE* data; ///< 音频数据
uint32_t size; ///< 音频数据大小
const WAVEFORMATEX* format; ///< 音频数据格式
BYTE* data; ///< 音频数据
uint32_t size; ///< 音频数据大小
const WAVEFORMATEX* format; ///< 音频数据格式
};
Transcoder();
@ -60,24 +60,24 @@ public:
~Transcoder();
/// \~chinese
/// @brief 获取数据缓冲
/// @brief 获取数据缓冲
Buffer GetBuffer() const;
/// \~chinese
/// @brief 清空数据缓冲
/// @brief 清空数据缓冲
void ClearBuffer();
private:
/// \~chinese
/// @brief 解码本地音频文件
/// @brief 解码本地音频文件
HRESULT LoadMediaFile(const String& file_path);
/// \~chinese
/// @brief 解码音频资源
/// @brief 解码音频资源
HRESULT LoadMediaResource(const Resource& res);
/// \~chinese
/// @brief 读取音频源数据
/// @brief 读取音频源数据
HRESULT ReadSource(IMFSourceReader* reader);
private:

View File

@ -28,24 +28,24 @@ namespace imgui
KGE_DECLARE_SMART_PTR(ImGuiLayer);
/// \~chinese
/// @brief ImGui管道
/// @brief ImGui管道
using ImGuiPipeline = Function<void()>;
/**
* \~chinese
* @brief ImGui图层
* @brief ImGui图层
*/
class ImGuiLayer : public LayerActor
{
public:
/// \~chinese
/// @brief 创建ImGui图层
/// @brief 创建ImGui图层
static ImGuiLayerPtr Create();
/// \~chinese
/// @brief 创建ImGui图层
/// @param name 元素名称
/// @param item 管道
/// @brief 创建ImGui图层
/// @param name 元素名称
/// @param item 管道
static ImGuiLayerPtr Create(const String& name, const ImGuiPipeline& item);
ImGuiLayer();
@ -53,19 +53,19 @@ public:
virtual ~ImGuiLayer();
/// \~chinese
/// @brief 添加 ImGui 元素
/// @param name 元素名称
/// @param item 管道
/// @brief 添加 ImGui 元素
/// @param name 元素名称
/// @param item 管道
void AddItem(const String& name, const ImGuiPipeline& item);
/// \~chinese
/// @brief 移除 ImGui 元素
/// @param name 元素名称
/// @brief 移除 ImGui 元素
/// @param name 元素名称
void RemoveItem(const String& name);
// 移除所有元素
// 移除所有元素
/// \~chinese
/// @brief 移除所有元素
/// @brief 移除所有元素
void RemoveAllItems();
public:

View File

@ -30,7 +30,7 @@ namespace imgui
/**
* \~chinese
* @brief ImGui模块
* @brief ImGuiдё©И
*/
class ImGuiModule
: public Singleton<ImGuiModule>

View File

@ -31,7 +31,7 @@ namespace network
{
/**
* \~chinese
* \defgroup Network
* \defgroup Network
*/
/**
@ -41,7 +41,7 @@ namespace network
/**
* \~chinese
* @brief HTTP模块
* @brief HTTP模块
*/
class KGE_API HttpModule
: public Singleton<HttpModule>
@ -51,33 +51,33 @@ class KGE_API HttpModule
public:
/// \~chinese
/// @brief 发送HTTP请求
/// @param[in] request HTTP请求
/// @details 发送请求后,无论结束或失败都将调用请求的响应回调函数
/// @brief 发送HTTP请求
/// @param[in] request HTTP请求
/// @details 发送请求后,无论结束或失败都将调用请求的响应回调函数
void Send(HttpRequestPtr request);
/// \~chinese
/// @brief 设置连接超时时长
/// @brief 设置连接超时时长
void SetTimeoutForConnect(Duration timeout);
/// \~chinese
/// @brief 获取连接超时时长
/// @brief 获取连接超时时长
Duration GetTimeoutForConnect() const;
/// \~chinese
/// @brief 设置读取超时时长
/// @brief 设置读取超时时长
void SetTimeoutForRead(Duration timeout);
/// \~chinese
/// @brief 获取读取超时时长
/// @brief 获取读取超时时长
Duration GetTimeoutForRead() const;
/// \~chinese
/// @brief 设置SSL证书地址
/// @brief 设置SSL证书地址
void SetSSLVerification(const String& root_certificate_path);
/// \~chinese
/// @brief 获取SSL证书地址
/// @brief 获取SSL证书地址
const String& GetSSLVerification() const;
public:

View File

@ -37,48 +37,48 @@ KGE_DECLARE_SMART_PTR(HttpRequest);
*/
/// \~chinese
/// @brief HTTP请求类型
/// @brief HTTP请求类型
enum class HttpType
{
Unknown, ///< 未知
Get, ///< HTTP GET请求
Post, ///< HTTP POST请求
Put, ///< HTTP PUT请求
Delete ///< HTTP DELETE请求
Unknown, ///< 未知
Get, ///< HTTP GET请求
Post, ///< HTTP POST请求
Put, ///< HTTP PUT请求
Delete ///< HTTP DELETE请求
};
/**
* \~chinese
* @brief HTTP请求
* @brief HTTP请求
*/
class KGE_API HttpRequest : public ObjectBase
{
public:
/// \~chinese
/// @brief 响应回调函数
/// @brief 响应回调函数
using ResponseCallback = Function<void(HttpRequest* /* request */, HttpResponse* /* response */)>;
/// \~chinese
/// @brief 创建HTTP请求
/// @param url 请求地址
/// @param type 请求类型
/// @param callback 响应回调函数
/// @brief 创建HTTP请求
/// @param url 请求地址
/// @param type 请求类型
/// @param callback 响应回调函数
static HttpRequestPtr Create(const String& url, HttpType type, const ResponseCallback& callback);
/// \~chinese
/// @brief 创建HTTP请求
/// @param url 请求地址
/// @param type 请求类型
/// @param data 请求数据
/// @param callback 响应回调函数
/// @brief 创建HTTP请求
/// @param url 请求地址
/// @param type 请求类型
/// @param data 请求数据
/// @param callback 响应回调函数
static HttpRequestPtr Create(const String& url, HttpType type, const String& data, const ResponseCallback& callback);
/// \~chinese
/// @brief 创建HTTP请求
/// @param url 请求地址
/// @param type 请求类型
/// @param json 请求的JSON数据
/// @param callback 响应回调函数
/// @brief 创建HTTP请求
/// @param url 请求地址
/// @param type 请求类型
/// @param json 请求的JSON数据
/// @param callback 响应回调函数
static HttpRequestPtr Create(const String& url, HttpType type, const Json& json, const ResponseCallback& callback);
HttpRequest();
@ -86,55 +86,55 @@ public:
HttpRequest(HttpType type);
/// \~chinese
/// @brief 设置请求地址
/// @brief 设置请求地址
void SetUrl(const String& url);
/// \~chinese
/// @brief 设置请求类型
/// @brief 设置请求类型
void SetType(HttpType type);
/// \~chinese
/// @brief 设置请求数据
/// @brief 设置请求数据
void SetData(const String& data);
/// \~chinese
/// @brief 设置请求的JSON数据
/// @brief 设置请求的JSON数据
void SetJsonData(const Json& json);
/// \~chinese
/// @brief 设置HTTP头
/// @brief 设置HTTP头
void SetHeaders(const Map<String, String>& headers);
/// \~chinese
/// @brief 设置HTTP头
/// @brief 设置HTTP头
void SetHeader(const String& field, const String& content);
/// \~chinese
/// @brief 设置响应回调函数
/// @brief 设置响应回调函数
void SetResponseCallback(const ResponseCallback& callback);
/// \~chinese
/// @brief 获取请求地址
/// @brief 获取请求地址
const String& GetUrl() const;
/// \~chinese
/// @brief 获取请求类型
/// @brief 获取请求类型
HttpType GetType() const;
/// \~chinese
/// @brief 获取请求数据
/// @brief 获取请求数据
const String& GetData() const;
/// \~chinese
/// @brief 获取HTTP头
/// @brief 获取HTTP头
Map<String, String>& GetHeaders();
/// \~chinese
/// @brief 获取HTTP头
/// @brief 获取HTTP头
const String& GetHeader(const String& header) const;
/// \~chinese
/// @brief 获取响应回调函数
/// @brief 获取响应回调函数
const ResponseCallback& GetResponseCallback() const;
private:

View File

@ -34,7 +34,7 @@ KGE_DECLARE_SMART_PTR(HttpResponse);
/**
* \~chinese
* @brief HTTP响应
* @brief HTTP响应
*/
class KGE_API HttpResponse : public ObjectBase
{
@ -42,47 +42,47 @@ public:
HttpResponse(HttpRequestPtr request);
/// \~chinese
/// @brief 获取对应的HTTP请求
/// @brief 获取对应的HTTP请求
HttpRequestPtr GetRequest() const;
/// \~chinese
/// @brief 获取响应状态
/// @brief 获取响应状态
bool IsSucceed() const;
/// \~chinese
/// @brief 获取HTTP状态码
/// @brief 获取HTTP状态码
long GetResponseCode() const;
/// \~chinese
/// @brief 获取响应头
/// @brief 获取响应头
String GetHeader() const;
/// \~chinese
/// @brief 获取响应数据
/// @brief 获取响应数据
const String& GetData() const;
/// \~chinese
/// @brief 获取错误信息
/// @brief 获取错误信息
const String& GetError() const;
/// \~chinese
/// @brief 设置响应状态
/// @brief 设置响应状态
void SetSucceed(bool succeed);
/// \~chinese
/// @brief 设置HTTP状态码
/// @brief 设置HTTP状态码
void SetResponseCode(long response_code);
/// \~chinese
/// @brief 设置响应头
/// @brief 设置响应头
void SetHeader(const String& response_header);
/// \~chinese
/// @brief 设置响应数据
/// @brief 设置响应数据
void SetData(const String& response_data);
/// \~chinese
/// @brief 设置错误信息
/// @brief 设置错误信息
void SetError(const String& error_buffer);
private:

View File

@ -32,78 +32,78 @@ namespace physics
*/
/// \~chinese
/// @brief 物理接触
/// @brief 物理接触
class KGE_API Contact
{
public:
Contact();
/// \~chinese
/// @brief 是否是接触
/// @brief 是否是接触
bool IsTouching() const;
/// \~chinese
/// @brief 启用或禁用 (仅作用于一个时间步)
/// @brief 启用或禁用 (仅作用于一个时间步)
void SetEnabled(bool flag);
/// \~chinese
/// @brief 是否启用
/// @brief 是否启用
bool IsEnabled() const;
/// \~chinese
/// @brief 获取物体A的夹具
/// @brief 获取物体A的夹具
Fixture* GetFixtureA() const;
/// \~chinese
/// @brief 获取物体B的夹具
/// @brief 获取物体B的夹具
Fixture* GetFixtureB() const;
/// \~chinese
/// @brief 获取物体A
/// @brief 获取物体A
PhysicBody* GetBodyA() const;
/// \~chinese
/// @brief 获取物体B
/// @brief 获取物体B
PhysicBody* GetBodyB() const;
/// \~chinese
/// @brief 设置摩擦力
/// @brief 设置摩擦力
void SetFriction(float friction);
/// \~chinese
/// @brief 获取摩擦力
/// @brief 获取摩擦力
float GetFriction() const;
/// \~chinese
/// @brief 重置摩擦力
/// @brief 重置摩擦力
void ResetFriction();
/// \~chinese
/// @brief 设置弹性恢复
/// @brief 设置弹性恢复
void SetRestitution(float restitution);
/// \~chinese
/// @brief 获取弹性恢复
/// @brief 获取弹性恢复
float GetRestitution() const;
/// \~chinese
/// @brief 重置弹性恢复
/// @brief 重置弹性恢复
void ResetRestitution();
/// \~chinese
/// @brief 设置切线速度
/// @brief 设置切线速度
void SetTangentSpeed(float speed);
/// \~chinese
/// @brief 获取切线速度
/// @brief 获取切线速度
float GetTangentSpeed() const;
/// \~chinese
/// @brief 获取b2Contact
/// @brief 获取b2Contact
b2Contact* GetB2Contact() const;
/// \~chinese
/// @brief 设置b2Contact
/// @brief 设置b2Contact
void SetB2Contact(b2Contact* contact);
bool operator==(const Contact& rhs) const;
@ -114,7 +114,7 @@ private:
};
/// \~chinese
/// @brief 物理接触列表
/// @brief 物理接触列表
class ContactList
{
template <typename _Ty>

View File

@ -31,26 +31,26 @@ namespace physics
*/
/// \~chinese
/// @brief 接触边
/// @brief 接触边
class KGE_API ContactEdge
{
public:
ContactEdge();
/// \~chinese
/// @brief 获取接触物体
/// @brief 获取接触物体
PhysicBody* GetOtherBody() const;
/// \~chinese
/// @brief 获取接触
/// @brief 获取接触
Contact GetContact() const;
/// \~chinese
/// @brief 获取b2ContactEdge
/// @brief 获取b2ContactEdge
b2ContactEdge* GetB2ContactEdge() const;
/// \~chinese
/// @brief 设置b2ContactEdge
/// @brief 设置b2ContactEdge
void SetB2ContactEdge(b2ContactEdge* edge);
bool operator==(const ContactEdge& rhs) const;
@ -61,7 +61,7 @@ private:
};
/// \~chinese
/// @brief 物理接触边列表
/// @brief 物理接触边列表
class ContactEdgeList
{
template <typename _Ty>

View File

@ -35,11 +35,11 @@ KGE_DECLARE_SMART_PTR(ContactEndEvent);
*/
/// \~chinese
/// @brief 物理接触开始事件
/// @brief 物理接触开始事件
class KGE_API ContactBeginEvent : public Event
{
public:
Contact contact; ///< 产生的接触
Contact contact; ///< 产生的接触
ContactBeginEvent();
@ -47,11 +47,11 @@ public:
};
/// \~chinese
/// @brief 物理接触结束事件
/// @brief 物理接触结束事件
class KGE_API ContactEndEvent : public Event
{
public:
Contact contact; ///< 产生的接触
Contact contact; ///< 产生的接触
ContactEndEvent();

View File

@ -35,18 +35,18 @@ KGE_DECLARE_SMART_PTR(Fixture);
*/
/// \~chinese
/// @brief 物理夹具
/// @brief 物理夹具
class KGE_API Fixture : public ObjectBase
{
public:
/// \~chinese
/// @brief 夹具参数
/// @brief 夹具参数
struct Param
{
float density = 0.0f; ///< 密度
float friction = 0.2f; ///< 摩擦力
float restitution = 0.0f; ///< 弹性恢复
bool is_sensor = false; ///< 是否是接触传感器
float density = 0.0f; ///< 密度
float friction = 0.2f; ///< 摩擦力
float restitution = 0.0f; ///< 弹性恢复
bool is_sensor = false; ///< 是否是接触传感器
Param() {}
@ -60,39 +60,39 @@ public:
};
/// \~chinese
/// @brief 创建圆形夹具
/// @param param 夹具参数
/// @param radius 圆形半径
/// @param offset 偏移量
/// @brief 创建圆形夹具
/// @param param 夹具参数
/// @param radius 圆形半径
/// @param offset 偏移量
static FixturePtr CreateCircle(const Param& param, float radius, const Point& offset = Point());
/// \~chinese
/// @brief 创建矩形夹具
/// @param param 夹具参数
/// @param size 矩形大小
/// @param offset 偏移量
/// @param rotation 旋转角度
/// @brief 创建矩形夹具
/// @param param 夹具参数
/// @param size 矩形大小
/// @param offset 偏移量
/// @param rotation 旋转角度
static FixturePtr CreateRect(const Param& param, const Size& size, const Point& offset = Point(),
float rotation = 0.f);
/// \~chinese
/// @brief 创建多边形夹具
/// @param param 夹具参数
/// @param vertexs 多边形顶点
/// @brief 创建多边形夹具
/// @param param 夹具参数
/// @param vertexs 多边形顶点
static FixturePtr CreatePolygon(const Param& param, const Vector<Point>& vertexs);
/// \~chinese
/// @brief 创建边夹具
/// @param param 夹具参数
/// @param p1 边的起点
/// @param p2 边的终点
/// @brief 创建边夹具
/// @param param 夹具参数
/// @param p1 边的起点
/// @param p2 边的终点
static FixturePtr CreateEdge(const Param& param, const Point& p1, const Point& p2);
/// \~chinese
/// @brief 创建链条夹具
/// @param param 夹具参数
/// @param vertexs 链条顶点
/// @param loop 是否连接链条的起点和终点
/// @brief 创建链条夹具
/// @param param 夹具参数
/// @param vertexs 链条顶点
/// @param loop 是否连接链条的起点和终点
static FixturePtr CreateChain(const Param& param, const Vector<Point>& vertices, bool loop = false);
Fixture();
@ -100,68 +100,68 @@ public:
virtual ~Fixture();
/// \~chinese
/// @brief 初始化夹具
/// @brief 初始化夹具
bool Init(PhysicBodyPtr body);
/// \~chinese
/// @brief 初始化夹具
/// @brief 初始化夹具
bool Init(PhysicBody* body);
/// \~chinese
/// @brief 获取夹具所在的物体
/// @brief 获取夹具所在的物体
PhysicBody* GetBody() const;
/// \~chinese
/// @brief 是否是接触传感器
/// @brief 是否是接触传感器
bool IsSensor() const;
/// \~chinese
/// @brief 设置夹具是否是接触传感器
/// @details 接触传感器只会产生物理接触,而不会影响物体运动
/// @brief 设置夹具是否是接触传感器
/// @details 接触传感器只会产生物理接触,而不会影响物体运动
void SetSensor(bool sensor);
/// \~chinese
/// @brief 获取夹具的质量数据
/// @brief 获取夹具的质量数据
void GetMassData(float* mass, Point* center, float* inertia) const;
/// \~chinese
/// @brief 获取密度
/// @brief 获取密度
float GetDensity() const;
/// \~chinese
/// @brief 设置密度
/// @brief 设置密度
void SetDensity(float density);
/// \~chinese
/// @brief 获取摩擦力 [N]
/// @brief 获取摩擦力 [N]
float GetFriction() const;
/// \~chinese
/// @brief 设置摩擦力 [N]
/// @brief 设置摩擦力 [N]
void SetFriction(float friction);
/// \~chinese
/// @brief 获取弹性恢复
/// @brief 获取弹性恢复
float GetRestitution() const;
/// \~chinese
/// @brief 设置弹性恢复
/// @brief 设置弹性恢复
void SetRestitution(float restitution);
/// \~chinese
/// @brief 点测试
/// @brief 点测试
bool TestPoint(const Point& p) const;
/// \~chinese
/// @brief 销毁夹具
/// @brief 销毁夹具
void Destroy();
/// \~chinese
/// @brief 获取b2Fixture
/// @brief 获取b2Fixture
b2Fixture* GetB2Fixture() const;
/// \~chinese
/// @brief 设置b2Fixture
/// @brief 设置b2Fixture
void SetB2Fixture(b2Fixture* fixture);
bool operator==(const Fixture& rhs) const;
@ -174,7 +174,7 @@ private:
};
/// \~chinese
/// @brief 物理夹具列表
/// @brief 物理夹具列表
class FixtureList
{
template <typename _Ty>

View File

@ -36,33 +36,33 @@ namespace global
{
/// \~chinese
/// @brief 获取全局缩放比例
/// @details 缩放比例是指由物理世界的单位米转换到屏幕像素的比例默认比例为1:100
/// @brief 获取全局缩放比例
/// @details 缩放比例是指由物理世界的单位米转换到屏幕像素的比例默认比例为1:100
float GetScale();
/// \~chinese
/// @brief 设置全局缩放比例
/// @details 缩放比例是指由物理世界的单位米转换到屏幕像素的比例默认比例为1:100
/// @brief 设置全局缩放比例
/// @details 缩放比例是指由物理世界的单位米转换到屏幕像素的比例默认比例为1:100
void SetScale(float scale);
/// \~chinese
/// @brief 游戏世界单位转换为物理世界单位
/// @details 根据全局缩放比例将物理世界的单位米转换为像素单位
/// @brief 游戏世界单位转换为物理世界单位
/// @details 根据全局缩放比例将物理世界的单位米转换为像素单位
float WorldToLocal(float value);
/// \~chinese
/// @brief 游戏世界单位转换为物理世界单位
/// @details 根据全局缩放比例将物理世界的单位米转换为像素单位
/// @brief 游戏世界单位转换为物理世界单位
/// @details 根据全局缩放比例将物理世界的单位米转换为像素单位
Vec2 WorldToLocal(const b2Vec2& pos);
/// \~chinese
/// @brief 物理世界单位转换为游戏世界单位
/// @details 根据全局缩放比例将像素单位转换为物理世界的单位米
/// @brief 物理世界单位转换为游戏世界单位
/// @details 根据全局缩放比例将像素单位转换为物理世界的单位米
float LocalToWorld(float value);
/// \~chinese
/// @brief 物理世界单位转换为游戏世界单位
/// @details 根据全局缩放比例将像素单位转换为物理世界的单位米
/// @brief 物理世界单位转换为游戏世界单位
/// @details 根据全局缩放比例将像素单位转换为物理世界的单位米
b2Vec2 LocalToWorld(const Vec2& pos);
} // namespace global

View File

@ -44,35 +44,35 @@ KGE_DECLARE_SMART_PTR(WheelJoint);
*/
/// \~chinese
/// @brief 关节
/// @brief 关节
class KGE_API Joint : public ObjectBase
{
public:
/// \~chinese
/// @brief 关节类型
/// @brief 关节类型
enum class Type
{
Unknown = 0, ///< 未知
Revolute, ///< 旋转关节
Prismatic, ///< 平移关节
Distance, ///< 固定距离关节
Pulley, ///< 滑轮关节
Mouse, ///< 鼠标关节
Gear, ///< 齿轮关节
Wheel, ///< 轮关节
Weld, ///< 焊接关节
Friction, ///< 摩擦关节
Rope, ///< 绳关节
Motor ///< 马达关节
Unknown = 0, ///< 未知
Revolute, ///< 旋转关节
Prismatic, ///< 平移关节
Distance, ///< 固定距离关节
Pulley, ///< 滑轮关节
Mouse, ///< 鼠标关节
Gear, ///< 齿轮关节
Wheel, ///< 轮关节
Weld, ///< 焊接关节
Friction, ///< 摩擦关节
Rope, ///< 绳关节
Motor ///< 马达关节
};
/// \~chinese
/// @brief 关节基础参数
/// @brief 关节基础参数
struct ParamBase
{
PhysicBody* body_a; ///< 关节连接的物体A
PhysicBody* body_b; ///< 关节连接的物体B
bool collide_connected; // 关节连接的物体是否允许碰撞
PhysicBody* body_a; ///< 关节连接的物体A
PhysicBody* body_b; ///< 关节连接的物体B
bool collide_connected; // 关节连接的物体是否允许碰撞
ParamBase(PhysicBody* body_a, PhysicBody* body_b)
: body_a(body_a)
@ -92,35 +92,35 @@ public:
virtual ~Joint();
/// \~chinese
/// @brief 初始化关节
/// @brief 初始化关节
virtual bool Init(PhysicWorld* world);
/// \~chinese
/// @brief 初始化关节
/// @brief 初始化关节
bool Init(PhysicWorld* world, b2JointDef* joint_def);
/// \~chinese
/// @brief 获取关节连接的物体A
/// @brief 获取关节连接的物体A
PhysicBodyPtr GetBodyA() const;
/// \~chinese
/// @brief 获取关节连接的物体B
/// @brief 获取关节连接的物体B
PhysicBodyPtr GetBodyB() const;
/// \~chinese
/// @brief 获取物理世界
/// @brief 获取物理世界
PhysicWorld* GetWorld() const;
/// \~chinese
/// @brief 销毁关节
/// @brief 销毁关节
void Destroy();
/// \~chinese
/// @brief 获取b2Joint
/// @brief 获取b2Joint
b2Joint* GetB2Joint() const;
/// \~chinese
/// @brief 设置b2Joint
/// @brief 设置b2Joint
void SetB2Joint(b2Joint* joint);
private:
@ -130,18 +130,18 @@ private:
};
/// \~chinese
/// @brief 固定距离关节
/// @brief 固定距离关节
class KGE_API DistanceJoint : public Joint
{
public:
/// \~chinese
/// @brief 固定距离关节参数
/// @brief 固定距离关节参数
struct Param : public Joint::ParamBase
{
Point anchor_a; ///< 关节在物体A上的连接点
Point anchor_b; ///< 关节在物体B上的连接点
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
Point anchor_a; ///< 关节在物体A上的连接点
Point anchor_b; ///< 关节在物体B上的连接点
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
Param()
: Param(nullptr, nullptr, Point(), Point())
@ -159,38 +159,38 @@ public:
};
/// \~chinese
/// @brief 创建固定距离关节
/// @param param 关节参数
/// @brief 创建固定距离关节
/// @param param 关节参数
static DistanceJointPtr Create(const Param& param);
DistanceJoint();
/// \~chinese
/// @brief 初始化关节
/// @brief 初始化关节
bool Init(PhysicWorld* world) override;
/// \~chinese
/// @brief 设置关节长度
/// @brief 设置关节长度
void SetLength(float length);
/// \~chinese
/// @brief 获取关节长度
/// @brief 获取关节长度
float GetLength() const;
/// \~chinese
/// @brief 设置弹簧响应速度 [赫兹]
/// @brief 设置弹簧响应速度 [赫兹]
void SetFrequency(float hz);
/// \~chinese
/// @brief 获取弹簧响应速度 [赫兹]
/// @brief 获取弹簧响应速度 [赫兹]
float GetFrequency() const;
/// \~chinese
/// @brief 设置阻尼率
/// @brief 设置阻尼率
void SetDampingRatio(float ratio);
/// \~chinese
/// @brief 获取阻尼率
/// @brief 获取阻尼率
float GetDampingRatio() const;
private:
@ -199,15 +199,15 @@ private:
};
/// \~chinese
/// @brief 摩擦关节
/// @brief 摩擦关节
class KGE_API FrictionJoint : public Joint
{
public:
struct Param : public Joint::ParamBase
{
Point anchor; ///< 摩擦作用点
float max_force; ///< 最大摩擦力
float max_torque; ///< 最大扭力
Point anchor; ///< 摩擦作用点
float max_force; ///< 最大摩擦力
float max_torque; ///< 最大扭力
Param()
: Param(nullptr, nullptr, Point())
@ -224,30 +224,30 @@ public:
};
/// \~chinese
/// @brief 创建摩擦关节
/// @param param 关节参数
/// @brief 创建摩擦关节
/// @param param 关节参数
static FrictionJointPtr Create(const Param& param);
FrictionJoint();
/// \~chinese
/// @brief 初始化关节
/// @brief 初始化关节
bool Init(PhysicWorld* world) override;
/// \~chinese
/// @brief 设置最大摩擦力
/// @brief 设置最大摩擦力
void SetMaxForce(float force);
/// \~chinese
/// @brief 获取最大摩擦力
/// @brief 获取最大摩擦力
float GetMaxForce() const;
/// \~chinese
/// @brief 设置最大转矩
/// @brief 设置最大转矩
void SetMaxTorque(float torque);
/// \~chinese
/// @brief 获取最大转矩
/// @brief 获取最大转矩
float GetMaxTorque() const;
private:
@ -256,17 +256,17 @@ private:
};
/// \~chinese
/// @brief 齿轮关节
/// @brief 齿轮关节
class KGE_API GearJoint : public Joint
{
public:
/// \~chinese
/// @brief 齿轮关节参数
/// @brief 齿轮关节参数
struct Param : public Joint::ParamBase
{
Joint* joint_a; ///< 关节A旋转关节/平移关节)
Joint* joint_b; ///< 关节B旋转关节/平移关节)
float ratio; ///< 齿轮传动比
Joint* joint_a; ///< 关节A旋转关节/平移关节)
Joint* joint_b; ///< 关节B旋转关节/平移关节)
float ratio; ///< 齿轮传动比
Param()
: Param(nullptr, nullptr)
@ -283,22 +283,22 @@ public:
};
/// \~chinese
/// @brief 创建齿轮关节
/// @param param 关节参数
/// @brief 创建齿轮关节
/// @param param 关节参数
static GearJointPtr Create(const Param& param);
GearJoint();
/// \~chinese
/// @brief 初始化关节
/// @brief 初始化关节
bool Init(PhysicWorld* world) override;
/// \~chinese
/// @brief 设定齿轮传动比
/// @brief 设定齿轮传动比
void SetRatio(float ratio);
/// \~chinese
/// @brief 获取齿轮传动比
/// @brief 获取齿轮传动比
float GetRatio() const;
private:
@ -307,17 +307,17 @@ private:
};
/// \~chinese
/// @brief 马达关节
/// @brief 马达关节
class KGE_API MotorJoint : public Joint
{
public:
/// \~chinese
/// @brief 马达关节参数
/// @brief 马达关节参数
struct Param : public Joint::ParamBase
{
float max_force; ///< 最大摩擦力
float max_torque; ///< 最大转矩
float correction_factor; ///< 位置矫正因子(范围 0-1
float max_force; ///< 最大摩擦力
float max_torque; ///< 最大转矩
float correction_factor; ///< 位置矫正因子(范围 0-1
Param()
: Param(nullptr, nullptr)
@ -334,30 +334,30 @@ public:
};
/// \~chinese
/// @brief 创建马达关节
/// @param param 关节参数
/// @brief 创建马达关节
/// @param param 关节参数
static MotorJointPtr Create(const Param& param);
MotorJoint();
/// \~chinese
/// @brief 初始化关节
/// @brief 初始化关节
bool Init(PhysicWorld* world) override;
/// \~chinese
/// @brief 设置最大摩擦力
/// @brief 设置最大摩擦力
void SetMaxForce(float force);
/// \~chinese
/// @brief 获取最大摩擦力
/// @brief 获取最大摩擦力
float GetMaxForce() const;
/// \~chinese
/// @brief 设置最大转矩
/// @brief 设置最大转矩
void SetMaxTorque(float torque);
/// \~chinese
/// @brief 获取最大转矩
/// @brief 获取最大转矩
float GetMaxTorque() const;
private:
@ -366,22 +366,22 @@ private:
};
/// \~chinese
/// @brief 平移关节
/// @brief 平移关节
class KGE_API PrismaticJoint : public Joint
{
public:
/// \~chinese
/// @brief 平移关节参数
/// @brief 平移关节参数
struct Param : public Joint::ParamBase
{
Point anchor; ///< 关节位置
Vec2 axis; ///< 物体A滑动的方向
bool enable_limit; ///< 是否启用限制
float lower_translation; ///< 移动的最小限制,与方向同向为正,反向为负,启用限制后才有效果
float upper_translation; ///< 移动的最大限制,与方向同向为正,反向为负,启用限制后才有效果
bool enable_motor; ///< 是否启用马达
float max_motor_force; ///< 最大马达力 [N]
float motor_speed; ///< 马达转速 [degree/s]
Point anchor; ///< 关节位置
Vec2 axis; ///< 物体A滑动的方向
bool enable_limit; ///< 是否启用限制
float lower_translation; ///< 移动的最小限制,与方向同向为正,反向为负,启用限制后才有效果
float upper_translation; ///< 移动的最大限制,与方向同向为正,反向为负,启用限制后才有效果
bool enable_motor; ///< 是否启用马达
float max_motor_force; ///< 最大马达力 [N]
float motor_speed; ///< 马达转速 [degree/s]
Param()
: Param(nullptr, nullptr, Point(), Vec2())
@ -403,70 +403,70 @@ public:
};
/// \~chinese
/// @brief 创建平移关节
/// @param param 关节参数
/// @brief 创建平移关节
/// @param param 关节参数
static PrismaticJointPtr Create(const Param& param);
PrismaticJoint();
/// \~chinese
/// @brief 初始化关节
/// @brief 初始化关节
bool Init(PhysicWorld* world) override;
/// \~chinese
/// @brief 获取参考角
/// @brief 获取参考角
float GetReferenceAngle() const;
/// \~chinese
/// @brief 获取关节转换
/// @brief 获取关节转换
float GetJointTranslation() const;
/// \~chinese
/// @brief 获取关节速度
/// @brief 获取关节速度
float GetJointSpeed() const;
/// \~chinese
/// @brief 是否启用关节限制
/// @brief 是否启用关节限制
bool IsLimitEnabled() const;
/// \~chinese
/// @brief 设置是否启用关节限制
/// @brief 设置是否启用关节限制
void EnableLimit(bool flag);
/// \~chinese
/// @brief 获取平移最小限制
/// @brief 获取平移最小限制
float GetLowerLimit() const;
/// \~chinese
/// @brief 获取平移最大限制
/// @brief 获取平移最大限制
float GetUpperLimit() const;
/// \~chinese
/// @brief 设置关节限制
/// @brief 设置关节限制
void SetLimits(float lower, float upper);
/// \~chinese
/// @brief 是否启用马达
/// @brief 是否启用马达
bool IsMotorEnabled() const;
/// \~chinese
/// @brief 设置是否启用马达
/// @brief 设置是否启用马达
void EnableMotor(bool flag);
/// \~chinese
/// @brief 设置马达转速 [degree/s]
/// @brief 设置马达转速 [degree/s]
void SetMotorSpeed(float speed);
/// \~chinese
/// @brief 获取马达转速 [degree/s]
/// @brief 获取马达转速 [degree/s]
float GetMotorSpeed() const;
/// \~chinese
/// @brief 设置最大马达力 [N]
/// @brief 设置最大马达力 [N]
void SetMaxMotorForce(float force);
/// \~chinese
/// @brief 获取最大马达力 [N]
/// @brief 获取最大马达力 [N]
float GetMaxMotorForce() const;
private:
@ -475,19 +475,19 @@ private:
};
/// \~chinese
/// @brief 滑轮关节
/// @brief 滑轮关节
class KGE_API PulleyJoint : public Joint
{
public:
/// \~chinese
/// @brief 滑轮关节参数
/// @brief 滑轮关节参数
struct Param : public Joint::ParamBase
{
Point anchor_a; ///< 关节在物体A上的作用点
Point anchor_b; ///< 关节在物体B上的作用点
Point ground_anchor_a; ///< 物体A对应的滑轮的位置
Point ground_anchor_b; ///< 物体B对应的滑轮的位置
float ratio; ///< 滑轮比,关节传动时,滑轮上升和下降的两头的位移比例
Point anchor_a; ///< 关节在物体A上的作用点
Point anchor_b; ///< 关节在物体B上的作用点
Point ground_anchor_a; ///< 物体A对应的滑轮的位置
Point ground_anchor_b; ///< 物体B对应的滑轮的位置
float ratio; ///< 滑轮比,关节传动时,滑轮上升和下降的两头的位移比例
Param()
: Param(nullptr, nullptr, Point(), Point(), Point(), Point())
@ -507,42 +507,42 @@ public:
};
/// \~chinese
/// @brief 创建滑轮关节
/// @param param 关节参数
/// @brief 创建滑轮关节
/// @param param 关节参数
static PulleyJointPtr Create(const Param& param);
PulleyJoint();
/// \~chinese
/// @brief 初始化关节
/// @brief 初始化关节
bool Init(PhysicWorld* world) override;
/// \~chinese
/// @brief 物体A对应的滑轮的位置
/// @brief 物体A对应的滑轮的位置
Point GetGroundAnchorA() const;
/// \~chinese
/// @brief 物体B对应的滑轮的位置
/// @brief 物体B对应的滑轮的位置
Point GetGroundAnchorB() const;
/// \~chinese
/// @brief 获取滑轮传动比
/// @brief 获取滑轮传动比
float GetRatio() const;
/// \~chinese
/// @brief 获取物体A与滑轮的距离
/// @brief 获取物体A与滑轮的距离
float GetLengthA() const;
/// \~chinese
/// @brief 获取物体B与滑轮的距离
/// @brief 获取物体B与滑轮的距离
float GetLengthB() const;
/// \~chinese
/// @brief 获取物体A与滑轮的当前距离
/// @brief 获取物体A与滑轮的当前距离
float GetCurrentLengthA() const;
/// \~chinese
/// @brief 获取物体B与滑轮的当前距离
/// @brief 获取物体B与滑轮的当前距离
float GetCurrentLengthB() const;
private:
@ -551,21 +551,21 @@ private:
};
/// \~chinese
/// @brief 旋转关节
/// @brief 旋转关节
class KGE_API RevoluteJoint : public Joint
{
public:
/// \~chinese
/// @brief 旋转关节参数
/// @brief 旋转关节参数
struct Param : public Joint::ParamBase
{
Point anchor; ///< 关节位置
bool enable_limit; ///< 是否启用限制
float lower_angle; ///< 移动的最小限制,与方向同向为正,反向为负,启用限制后才有效果
float upper_angle; ///< 移动的最大限制,与方向同向为正,反向为负,启用限制后才有效果
bool enable_motor; ///< 是否启用马达
float max_motor_torque; ///< 最大马达力 [N]
float motor_speed; ///< 马达转速 [degree/s]
Point anchor; ///< 关节位置
bool enable_limit; ///< 是否启用限制
float lower_angle; ///< 移动的最小限制,与方向同向为正,反向为负,启用限制后才有效果
float upper_angle; ///< 移动的最大限制,与方向同向为正,反向为负,启用限制后才有效果
bool enable_motor; ///< 是否启用马达
float max_motor_torque; ///< 最大马达力 [N]
float motor_speed; ///< 马达转速 [degree/s]
Param()
: Param(nullptr, nullptr, Point())
@ -586,70 +586,70 @@ public:
};
/// \~chinese
/// @brief 创建旋转关节
/// @param param 关节参数
/// @brief 创建旋转关节
/// @param param 关节参数
static RevoluteJointPtr Create(const Param& param);
RevoluteJoint();
/// \~chinese
/// @brief 初始化关节
/// @brief 初始化关节
bool Init(PhysicWorld* world) override;
/// \~chinese
/// @brief 获取参考角
/// @brief 获取参考角
float GetReferenceAngle() const;
/// \~chinese
/// @brief 获取关节角度
/// @brief 获取关节角度
float GetJointAngle() const;
/// \~chinese
/// @brief 获取关节速度
/// @brief 获取关节速度
float GetJointSpeed() const;
/// \~chinese
/// @brief 是否启用关节限制
/// @brief 是否启用关节限制
bool IsLimitEnabled() const;
/// \~chinese
/// @brief 设置是否启用关节限制
/// @brief 设置是否启用关节限制
void EnableLimit(bool flag);
/// \~chinese
/// @brief 获取平移最小限制
/// @brief 获取平移最小限制
float GetLowerLimit() const;
/// \~chinese
/// @brief 获取平移最大限制
/// @brief 获取平移最大限制
float GetUpperLimit() const;
/// \~chinese
/// @brief 设置关节限制
/// @brief 设置关节限制
void SetLimits(float lower, float upper);
/// \~chinese
/// @brief 是否启用马达
/// @brief 是否启用马达
bool IsMotorEnabled() const;
/// \~chinese
/// @brief 设置是否启用马达
/// @brief 设置是否启用马达
void EnableMotor(bool flag);
/// \~chinese
/// @brief 设置马达转速 [degree/s]
/// @brief 设置马达转速 [degree/s]
void SetMotorSpeed(float speed);
/// \~chinese
/// @brief 获取马达转速 [degree/s]
/// @brief 获取马达转速 [degree/s]
float GetMotorSpeed() const;
/// \~chinese
/// @brief 设置最大马达转矩 [N/m]
/// @brief 设置最大马达转矩 [N/m]
void SetMaxMotorTorque(float torque);
/// \~chinese
/// @brief 获取最大马达转矩 [N/m]
/// @brief 获取最大马达转矩 [N/m]
float GetMaxMotorTorque() const;
private:
@ -658,17 +658,17 @@ private:
};
/// \~chinese
/// @brief 绳关节
/// @brief 绳关节
class KGE_API RopeJoint : public Joint
{
public:
/// \~chinese
/// @brief 绳关节参数
/// @brief 绳关节参数
struct Param : public Joint::ParamBase
{
Point local_anchor_a; ///< 关节在物体A上的连接点
Point local_anchor_b; ///< 关节在物体B上的连接点
float max_length; ///< 绳索最大长度
Point local_anchor_a; ///< 关节在物体A上的连接点
Point local_anchor_b; ///< 关节在物体B上的连接点
float max_length; ///< 绳索最大长度
Param()
: Param(nullptr, nullptr, Point(), Point())
@ -685,22 +685,22 @@ public:
};
/// \~chinese
/// @brief 创建绳关节
/// @param param 关节参数
/// @brief 创建绳关节
/// @param param 关节参数
static RopeJointPtr Create(const Param& param);
RopeJoint();
/// \~chinese
/// @brief 初始化关节
/// @brief 初始化关节
bool Init(PhysicWorld* world) override;
/// \~chinese
/// @brief 设置关节最大长度
/// @brief 设置关节最大长度
void SetMaxLength(float length);
/// \~chinese
/// @brief 获取关节最大长度
/// @brief 获取关节最大长度
float GetMaxLength() const;
private:
@ -709,17 +709,17 @@ private:
};
/// \~chinese
/// @brief 焊接关节
/// @brief 焊接关节
class KGE_API WeldJoint : public Joint
{
public:
/// \~chinese
/// @brief 焊接关节参数
/// @brief 焊接关节参数
struct Param : public Joint::ParamBase
{
Point anchor; ///< 焊接位置
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
Point anchor; ///< 焊接位置
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
Param()
: Param(nullptr, nullptr, Point())
@ -736,34 +736,34 @@ public:
};
/// \~chinese
/// @brief 创建焊接关节
/// @param param 关节参数
/// @brief 创建焊接关节
/// @param param 关节参数
static WeldJointPtr Create(const Param& param);
WeldJoint();
/// \~chinese
/// @brief 初始化关节
/// @brief 初始化关节
bool Init(PhysicWorld* world) override;
/// \~chinese
/// @brief 获取物体B相对于物体A的角度
/// @brief 获取物体B相对于物体A的角度
float GetReferenceAngle() const;
/// \~chinese
/// @brief 设置弹簧响应速度 [赫兹]
/// @brief 设置弹簧响应速度 [赫兹]
void SetFrequency(float hz);
/// \~chinese
/// @brief 获取弹簧响应速度 [赫兹]
/// @brief 获取弹簧响应速度 [赫兹]
float GetFrequency() const;
/// \~chinese
/// @brief 设置阻尼率
/// @brief 设置阻尼率
void SetDampingRatio(float ratio);
/// \~chinese
/// @brief 获取阻尼率
/// @brief 获取阻尼率
float GetDampingRatio() const;
private:
@ -772,21 +772,21 @@ private:
};
/// \~chinese
/// @brief 轮关节
/// @brief 轮关节
class KGE_API WheelJoint : public Joint
{
public:
/// \~chinese
/// @brief 轮关节参数
/// @brief 轮关节参数
struct Param : public Joint::ParamBase
{
Point anchor; ///< 轮关节位置
Vec2 axis; ///< 物体A滑动方向
bool enable_motor; ///< 是否启用马达
float max_motor_torque; ///< 最大马达力 [N]
float motor_speed; ///< 马达转速 [degree/s]
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
float damping_ratio; ///< 弹簧阻尼率,值越大关节运动阻尼越大
Point anchor; ///< 轮关节位置
Vec2 axis; ///< 物体A滑动方向
bool enable_motor; ///< 是否启用马达
float max_motor_torque; ///< 最大马达力 [N]
float motor_speed; ///< 马达转速 [degree/s]
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
float damping_ratio; ///< 弹簧阻尼率,值越大关节运动阻尼越大
Param()
: Param(nullptr, nullptr, Point(), Vec2())
@ -807,70 +807,70 @@ public:
};
/// \~chinese
/// @brief 创建轮关节
/// @param param 关节参数
/// @brief 创建轮关节
/// @param param 关节参数
static WheelJointPtr Create(const Param& param);
WheelJoint();
/// \~chinese
/// @brief 初始化关节
/// @brief 初始化关节
bool Init(PhysicWorld* world) override;
/// \~chinese
/// @brief 获取关节当前的平移距离
/// @brief 获取关节当前的平移距离
float GetJointTranslation() const;
/// \~chinese
/// @brief 获取关节当前的线性速度
/// @brief 获取关节当前的线性速度
float GetJointLinearSpeed() const;
/// \~chinese
/// @brief 获取关节当前的角度
/// @brief 获取关节当前的角度
float GetJointAngle() const;
/// \~chinese
/// @brief 获取关节当前的旋转速度
/// @brief 获取关节当前的旋转速度
float GetJointAngularSpeed() const;
/// \~chinese
/// @brief 是否启用马达
/// @brief 是否启用马达
bool IsMotorEnabled() const;
/// \~chinese
/// @brief 设置是否启用马达
/// @brief 设置是否启用马达
void EnableMotor(bool flag);
/// \~chinese
/// @brief 设置马达转速 [degree/s]
/// @brief 设置马达转速 [degree/s]
void SetMotorSpeed(float speed);
/// \~chinese
/// @brief 获取马达转速 [degree/s]
/// @brief 获取马达转速 [degree/s]
float GetMotorSpeed() const;
/// \~chinese
/// @brief 设置最大马达转矩 [N/m]
/// @brief 设置最大马达转矩 [N/m]
void SetMaxMotorTorque(float torque);
/// \~chinese
/// @brief 获取最大马达转矩 [N/m]
/// @brief 获取最大马达转矩 [N/m]
float GetMaxMotorTorque() const;
/// \~chinese
/// @brief 设置弹簧响应速度
/// @brief 设置弹簧响应速度
void SetSpringFrequencyHz(float hz);
/// \~chinese
/// @brief 获取弹簧响应速度
/// @brief 获取弹簧响应速度
float GetSpringFrequencyHz() const;
/// \~chinese
/// @brief 设置弹簧阻尼率
/// @brief 设置弹簧阻尼率
void SetSpringDampingRatio(float ratio);
/// \~chinese
/// @brief 获取弹簧阻尼率
/// @brief 获取弹簧阻尼率
float GetSpringDampingRatio() const;
private:
@ -879,19 +879,19 @@ private:
};
/// \~chinese
/// @brief 鼠标关节
/// @details 用于使身体的某个点追踪世界上的指定点,例如让物体追踪鼠标位置
/// @brief 鼠标关节
/// @details 用于使身体的某个点追踪世界上的指定点,例如让物体追踪鼠标位置
class KGE_API MouseJoint : public Joint
{
public:
/// \~chinese
/// @brief 鼠标关节参数
/// @brief 鼠标关节参数
struct Param : public Joint::ParamBase
{
Point target; ///< 关节作用目标位置
float max_force; ///< 作用在物体A上的最大力
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
Point target; ///< 关节作用目标位置
float max_force; ///< 作用在物体A上的最大力
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
Param()
: Param(nullptr, nullptr, Point())
@ -909,38 +909,38 @@ public:
};
/// \~chinese
/// @brief 创建鼠标关节
/// @param param 关节参数
/// @brief 创建鼠标关节
/// @param param 关节参数
static MouseJointPtr Create(const Param& param);
MouseJoint();
/// \~chinese
/// @brief 初始化关节
/// @brief 初始化关节
bool Init(PhysicWorld* world) override;
/// \~chinese
/// @brief 设定最大摩擦力 [N]
/// @brief 设定最大摩擦力 [N]
void SetMaxForce(float force);
/// \~chinese
/// @brief 获取最大摩擦力 [N]
/// @brief 获取最大摩擦力 [N]
float GetMaxForce() const;
/// \~chinese
/// @brief 设置响应速度 [hz]
/// @brief 设置响应速度 [hz]
void SetFrequency(float hz);
/// \~chinese
/// @brief 获取响应速度 [hz]
/// @brief 获取响应速度 [hz]
float GetFrequency() const;
/// \~chinese
/// @brief 设置阻尼率
/// @brief 设置阻尼率
void SetDampingRatio(float ratio);
/// \~chinese
/// @brief 获取阻尼率
/// @brief 获取阻尼率
float GetDampingRatio() const;
private:

View File

@ -35,31 +35,31 @@ class PhysicWorld;
*/
/// \~chinese
/// @brief 物体
/// @brief 物体
class KGE_API PhysicBody : public Component
{
friend class PhysicWorld;
public:
/// \~chinese
/// @brief 物体类型
/// @brief 物体类型
enum class Type
{
Static = 0, ///< 静态物体
Kinematic, ///< 动力学物体
Dynamic, ///< 动态物体
Static = 0, ///< 静态物体
Kinematic, ///< 动力学物体
Dynamic, ///< 动态物体
};
/// \~chinese
/// @brief 初始化物体
/// @param world 物理世界
/// @param type 物体类型
/// @brief 初始化物体
/// @param world 物理世界
/// @param type 物体类型
static PhysicBodyPtr Create(PhysicWorldPtr world, Type type);
/// \~chinese
/// @brief 初始化物体
/// @param world 物理世界
/// @param type 物体类型
/// @brief 初始化物体
/// @param world 物理世界
/// @param type 物体类型
static PhysicBodyPtr Create(PhysicWorld* world, Type type);
PhysicBody();
@ -67,297 +67,297 @@ public:
virtual ~PhysicBody();
/// \~chinese
/// @brief 初始化物体
/// @param[in] world 物理世界
/// @brief 初始化物体
/// @param[in] world 物理世界
bool Init(PhysicWorldPtr world);
/// \~chinese
/// @brief 初始化物体
/// @param[in] world 物理世界
/// @brief 初始化物体
/// @param[in] world 物理世界
bool Init(PhysicWorld* world);
/// \~chinese
/// @brief 添加夹具
/// @brief 添加夹具
void AddFixture(FixturePtr fixture);
/// \~chinese
/// @brief 添加圆形夹具
/// @param radius 圆形半径
/// @param density 物体密度
/// @brief 添加圆形夹具
/// @param radius 圆形半径
/// @param density 物体密度
/// @param
Fixture* AddCircleShape(float radius, float density, float friction = 0.2f);
/// \~chinese
/// @brief 添加矩形夹具
/// @param size 矩形大小
/// @param density 物体密度
/// @brief 添加矩形夹具
/// @param size 矩形大小
/// @param density 物体密度
Fixture* AddRectShape(const Vec2& size, float density, float friction = 0.2f);
/// \~chinese
/// @brief 添加多边形夹具
/// @param vertexs 多边形端点
/// @param density 物体密度
/// @brief 添加多边形夹具
/// @param vertexs 多边形端点
/// @param density 物体密度
Fixture* AddPolygonShape(const Vector<Point>& vertexs, float density, float friction = 0.2f);
/// \~chinese
/// @brief 添加线段形夹具
/// @param p1 线段起点
/// @param p2 线段终点
/// @param density 物体密度
/// @brief 添加线段形夹具
/// @param p1 线段起点
/// @param p2 线段终点
/// @param density 物体密度
Fixture* AddEdgeShape(const Point& p1, const Point& p2, float density, float friction = 0.2f);
/// \~chinese
/// @brief 添加链条形夹具
/// @param vertexs 链条端点
/// @param loop 是否闭合
/// @param density 物体密度
/// @brief 添加链条形夹具
/// @param vertexs 链条端点
/// @param loop 是否闭合
/// @param density 物体密度
Fixture* AddChainShape(const Vector<Point>& vertices, bool loop, float density, float friction = 0.2f);
/// \~chinese
/// @brief 移除夹具
/// @brief 移除夹具
void RemoveFixture(FixturePtr fixture);
/// \~chinese
/// @brief 移除所有夹具
/// @brief 移除所有夹具
void RemoveAllFixtures();
/// \~chinese
/// @brief 获取夹具列表
/// @brief 获取夹具列表
FixtureList GetFixtureList() const;
/// \~chinese
/// @brief 获取接触边列表
/// @brief 获取接触边列表
ContactEdgeList GetContactList() const;
/// \~chinese
/// @brief 获取类别码
/// @brief 获取类别码
uint16_t GetCategoryBits() const;
/// \~chinese
/// @brief 设置类别码
/// @brief 设置类别码
void SetCategoryBits(uint16_t category_bits);
/// \~chinese
/// @brief 获取碰撞掩码
/// @brief 获取碰撞掩码
uint16_t GetMaskBits() const;
/// \~chinese
/// @brief 设置碰撞掩码
/// @brief 设置碰撞掩码
void SetMaskBits(uint16_t mask_bits);
/// \~chinese
/// @brief 获取组索引
/// @brief 获取组索引
int16_t GetGroupIndex() const;
/// \~chinese
/// @brief 设置组索引
/// @brief 设置组索引
void SetGroupIndex(int16_t index);
/// \~chinese
/// @brief 获取旋转角度
/// @brief 获取旋转角度
float GetRotation() const;
/// \~chinese
/// @brief 设置旋转角度
/// @brief 设置旋转角度
void SetRotation(float angle);
/// \~chinese
/// @brief 获取物体位置
/// @brief 获取物体位置
Point GetPosition() const;
/// \~chinese
/// @brief 设置物体位置
/// @brief 设置物体位置
void SetPosition(const Point& pos);
/// \~chinese
/// @brief 位置和旋转变换
/// @brief 位置和旋转变换
void SetTransform(const Point& pos, float angle);
/// \~chinese
/// @brief 获取质量 [kg]
/// @brief 获取质量 [kg]
float GetMass() const;
/// \~chinese
/// @brief 获取惯性
/// @brief 获取惯性
float GetInertia() const;
/// \~chinese
/// @brief 获取质量数据
/// @param[out] mass 物体质量 [kg]
/// @param[out] center 质心位置
/// @param[out] inertia 惯性
/// @brief 获取质量数据
/// @param[out] mass 物体质量 [kg]
/// @param[out] center 质心位置
/// @param[out] inertia 惯性
void GetMassData(float* mass, Point* center, float* inertia) const;
/// \~chinese
/// @brief 设置质量数据
/// @param mass 物体质量 [kg]
/// @param center 质心位置
/// @param inertia 惯性
/// @brief 设置质量数据
/// @param mass 物体质量 [kg]
/// @param center 质心位置
/// @param inertia 惯性
void SetMassData(float mass, const Point& center, float inertia);
/// \~chinese
/// @brief 重置质量数据
/// @brief 重置质量数据
void ResetMassData();
/// \~chinese
/// @brief 获取世界坐标系上的点在物体上的位置
/// @brief 获取世界坐标系上的点在物体上的位置
Point GetLocalPoint(const Point& world) const;
/// \~chinese
/// @brief 将世界坐标系中的向量转换到物体坐标系下
/// @brief 将世界坐标系中的向量转换到物体坐标系下
Vec2 GetLocalVector(const Vec2& world) const;
/// \~chinese
/// @brief 获取物体上的点在世界坐标系的位置
/// @brief 获取物体上的点在世界坐标系的位置
Point GetWorldPoint(const Point& local) const;
/// \~chinese
/// @brief 将物体坐标系中的向量转换到世界坐标系下
/// @brief 将物体坐标系中的向量转换到世界坐标系下
Vec2 GetWorldVector(const Vec2& local) const;
/// \~chinese
/// @brief 获取物体质心相对于物体的位置
/// @brief 获取物体质心相对于物体的位置
Point GetLocalCenter() const;
/// \~chinese
/// @brief 获取物体质心位置
/// @brief 获取物体质心位置
Point GetWorldCenter() const;
/// \~chinese
/// @brief 获取物体类型
/// @brief 获取物体类型
Type GetType() const;
/// \~chinese
/// @brief 设置物体类型
/// @brief 设置物体类型
void SetType(Type type);
/// \~chinese
/// @brief 获取物体受重力的比例
/// @brief 获取物体受重力的比例
float GetGravityScale() const;
/// \~chinese
/// @brief 设置物体受重力的比例
/// @brief 设置物体受重力的比例
void SetGravityScale(float scale);
/// \~chinese
/// @brief 获取线性阻尼
/// @brief 获取线性阻尼
float GetLinearDamping() const;
/// \~chinese
/// @brief 设置线性阻尼
/// @brief 设置线性阻尼
void SetLinearDamping(float damping);
/// \~chinese
/// @brief 获取旋转阻尼
/// @brief 获取旋转阻尼
float GetAngularDamping() const;
/// \~chinese
/// @brief 设置旋转阻尼
/// @brief 设置旋转阻尼
void SetAngularDamping(float damping);
/// \~chinese
/// @brief 施力
/// @param force 力的大小和方向
/// @param point 施力点
/// @param wake 是否唤醒物体
/// @brief 施力
/// @param force 力的大小和方向
/// @param point 施力点
/// @param wake 是否唤醒物体
void ApplyForce(const Vec2& force, const Point& point, bool wake = true);
/// \~chinese
/// @brief 给物体中心施力
/// @param force 力的大小和方向
/// @param wake 是否唤醒物体
/// @brief 给物体中心施力
/// @param force 力的大小和方向
/// @param wake 是否唤醒物体
void ApplyForceToCenter(const Vec2& force, bool wake = true);
/// \~chinese
/// @brief 施加扭矩
/// @param torque 扭矩
/// @param wake 是否唤醒物体
/// @brief 施加扭矩
/// @param torque 扭矩
/// @param wake 是否唤醒物体
void ApplyTorque(float torque, bool wake = false);
/// \~chinese
/// @brief 旋转角度是否固定
/// @brief 旋转角度是否固定
bool IsIgnoreRotation() const;
/// \~chinese
/// @brief 设置是否固定旋转角度
/// @brief 设置是否固定旋转角度
void SetIgnoreRotation(bool flag);
/// \~chinese
/// @brief 是否是子弹物体
/// @brief 是否是子弹物体
bool IsBullet() const;
/// \~chinese
/// @brief 设置物体是否是子弹物体
/// @brief 设置物体是否是子弹物体
void SetBullet(bool flag);
/// \~chinese
/// @brief 是否处于唤醒状态
/// @brief 是否处于唤醒状态
bool IsAwake() const;
/// \~chinese
/// @brief 设置唤醒状态
/// @brief 设置唤醒状态
void SetAwake(bool flag);
/// \~chinese
/// @brief 是否启用休眠
/// @brief 是否启用休眠
bool IsSleepingAllowed() const;
/// \~chinese
/// @brief 设置是否允许休眠
/// @brief 设置是否允许休眠
void SetSleepingAllowed(bool flag);
/// \~chinese
/// @brief 是否启用
/// @brief 是否启用
bool IsActive() const;
/// \~chinese
/// @brief 设置启用状态
/// @brief 设置启用状态
void SetActive(bool flag);
/// \~chinese
/// @brief 获取物体所在物理世界
/// @brief 获取物体所在物理世界
PhysicWorld* GetWorld() const;
/// \~chinese
/// @brief 销毁物体
/// @brief 销毁物体
void Destroy();
/// \~chinese
/// @brief 获取b2Body
/// @brief 获取b2Body
b2Body* GetB2Body() const;
/// \~chinese
/// @brief 设置b2Body
/// @brief 设置b2Body
void SetB2Body(b2Body* body);
protected:
/// \~chinese
/// @brief 初始化组件
/// @brief 初始化组件
void InitComponent(Actor* actor) override;
/// \~chinese
/// @brief 销毁组件
/// @brief 销毁组件
void DestroyComponent() override;
/// \~chinese
/// @brief 更新物体状态
/// @brief 更新物体状态
void UpdateFromActor(Actor* actor);
/// \~chinese
/// @brief 更新物体状态
/// @brief 更新物体状态
void UpdateFromActor(Actor* actor, const Matrix3x2& actor_to_world, float parent_rotation);
/// \~chinese
/// @brief 更新夹具过滤器
/// @brief 更新夹具过滤器
void UpdateFixtureFilter(b2Fixture* fixture);
/// \~chinese
/// @brief 更新物理身体前
/// @brief 更新物理身体前
void BeforeSimulation(Actor* actor, const Matrix3x2& parent_to_world, const Matrix3x2& actor_to_world,
float parent_rotation);
/// \~chinese
/// @brief 更新物理身体后
/// @brief 更新物理身体后
void AfterSimulation(Actor* actorconst, const Matrix3x2& parent_to_world, float parent_rotation);
private:

View File

@ -29,7 +29,7 @@ namespace physics
/**
* \~chinese
* \defgroup Physics
* \defgroup Physics
*/
/**
@ -39,7 +39,7 @@ namespace physics
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API PhysicWorld : public Component
{
@ -48,12 +48,12 @@ class KGE_API PhysicWorld : public Component
public:
/// \~chinese
/// @brief 创建物理世界
/// @brief 创建物理世界
static PhysicWorldPtr Create();
/// \~chinese
/// @brief 创建物理世界
/// @param gravity 重力
/// @brief 创建物理世界
/// @param gravity 重力
static PhysicWorldPtr Create(const Vec2& gravity);
PhysicWorld();
@ -61,96 +61,96 @@ public:
virtual ~PhysicWorld();
/// \~chinese
/// @brief 添加物体
/// @brief 添加物体
void AddBody(PhysicBodyPtr body);
/// \~chinese
/// @brief 移除物体
/// @brief 移除物体
void RemoveBody(PhysicBodyPtr body);
/// \~chinese
/// @brief 移除所有物体
/// @brief 移除所有物体
void RemoveAllBodies();
/// \~chinese
/// @brief 获取所有物体
/// @brief 获取所有物体
const List<PhysicBodyPtr>& GetAllBodies() const;
/// \~chinese
/// @brief 添加关节
/// @brief 添加关节
void AddJoint(JointPtr joint);
/// \~chinese
/// @brief 移除关节
/// @brief 移除关节
void RemoveJoint(JointPtr joint);
/// \~chinese
/// @brief 移除所有关节
/// @brief 移除所有关节
void RemoveAllJoints();
/// \~chinese
/// @brief 获取所有关节
/// @brief 获取所有关节
const List<JointPtr>& GetAllJoints() const;
/// \~chinese
/// @brief 获取重力 [N]
/// @brief 获取重力 [N]
Vec2 GetGravity() const;
/// \~chinese
/// @brief 设置重力 [N]
/// @brief 设置重力 [N]
void SetGravity(Vec2 gravity);
/// \~chinese
/// @brief 获取物理接触列表
/// @brief 获取物理接触列表
ContactList GetContactList();
/// \~chinese
/// @brief 设置速度迭代次数, 默认为 6
/// @brief 设置速度迭代次数, 默认为 6
void SetVelocityIterations(int vel_iter);
/// \~chinese
/// @brief 设置位置迭代次数, 默认为 2
/// @brief 设置位置迭代次数, 默认为 2
void SetPositionIterations(int pos_iter);
/// \~chinese
/// @brief 设置是否绘制调试信息
/// @brief 设置是否绘制调试信息
void ShowDebugInfo(bool show);
/// \~chinese
/// @brief 获取b2World
/// @brief 获取b2World
b2World* GetB2World();
/// \~chinese
/// @brief 获取b2World
/// @brief 获取b2World
const b2World* GetB2World() const;
protected:
/// \~chinese
/// @brief 初始化组件
/// @brief 初始化组件
void InitComponent(Actor* actor) override;
/// \~chinese
/// @brief 更新组件
/// @brief 更新组件
void OnUpdate(Duration dt) override;
/// \~chinese
/// @brief 渲染组件
/// @brief 渲染组件
void OnRender(RenderContext& ctx) override;
/// \~chinese
/// @brief 分发物理世界事件
/// @brief 分发物理世界事件
void DispatchEvent(Event* evt);
/// \~chinese
/// @brief 关节移除时的回调函数
/// @brief 关节移除时的回调函数
void JointRemoved(b2Joint* b2joint);
/// \~chinese
/// @brief 更新物理世界前
/// @brief 更新物理世界前
void BeforeSimulation(Actor* parent, const Matrix3x2& parent_to_world, float parent_rotation);
/// \~chinese
/// @brief 更新物理世界后
/// @brief 更新物理世界后
void AfterSimulation(Actor* parent, const Matrix3x2& parent_to_world, float parent_rotation);
private:

View File

@ -41,12 +41,12 @@ class PhysicBody;
KGE_DECLARE_SMART_PTR(Actor);
/// \~chinese
/// @brief 角色列表
/// @brief 角色列表
typedef IntrusiveList<ActorPtr> ActorList;
/**
* \~chinese
* \defgroup Actors
* \defgroup Actors
*/
/**
@ -56,9 +56,9 @@ typedef IntrusiveList<ActorPtr> ActorList;
/**
* \~chinese
* @brief
* @brief
* @details
*
*
*/
class KGE_API Actor
: public ObjectBase
@ -73,11 +73,11 @@ class KGE_API Actor
public:
/// \~chinese
/// @brief 角色更新回调函数
/// @brief 角色更新回调函数
typedef Function<void(Duration)> UpdateCallback;
/// \~chinese
/// @brief 创建角色
/// @brief 创建角色
static ActorPtr Create();
Actor();
@ -85,418 +85,418 @@ public:
virtual ~Actor();
/// \~chinese
/// @brief 更新角色
/// @details 每帧画面刷新前调用该函数,重载该函数以实现角色的更新处理
/// @param dt 距上一次更新的时间间隔
/// @brief 更新角色
/// @details 每帧画面刷新前调用该函数,重载该函数以实现角色的更新处理
/// @param dt 距上一次更新的时间间隔
virtual void OnUpdate(Duration dt);
/// \~chinese
/// @brief 渲染角色
/// @brief 渲染角色
/// @details
/// 每帧画面刷新时调用该函数,默认不进行渲染,重载该函数以实现具体渲染过程
/// @param ctx 渲染上下文
/// 每帧画面刷新时调用该函数,默认不进行渲染,重载该函数以实现具体渲染过程
/// @param ctx 渲染上下文
virtual void OnRender(RenderContext& ctx);
/// \~chinese
/// @brief 获取显示状态
/// @brief 获取显示状态
bool IsVisible() const;
/// \~chinese
/// @brief 获取响应状态
/// @brief 获取响应状态
bool IsResponsible() const;
/// \~chinese
/// @brief 是否启用级联透明度
/// @brief 是否启用级联透明度
bool IsCascadeOpacityEnabled() const;
/// \~chinese
/// @brief 获取名称的 Hash 值
/// @brief 获取名称的 Hash 值
size_t GetHashName() const;
/// \~chinese
/// @brief 获取 Z 轴顺序
/// @brief 获取 Z 轴顺序
int GetZOrder() const;
/// \~chinese
/// @brief 获取坐标
/// @brief 获取坐标
virtual Point GetPosition() const;
/// \~chinese
/// @brief 获取 x 坐标
/// @brief 获取 x 坐标
float GetPositionX() const;
/// \~chinese
/// @brief 获取 y 坐标
/// @brief 获取 y 坐标
float GetPositionY() const;
/// \~chinese
/// @brief 获取大小
/// @brief 获取大小
virtual Size GetSize() const;
/// \~chinese
/// @brief 获取宽度
/// @brief 获取宽度
float GetWidth() const;
/// \~chinese
/// @brief 获取高度
/// @brief 获取高度
float GetHeight() const;
/// \~chinese
/// @brief 获取缩放后的宽度
/// @brief 获取缩放后的宽度
float GetScaledWidth() const;
/// \~chinese
/// @brief 获取缩放后的高度
/// @brief 获取缩放后的高度
float GetScaledHeight() const;
/// \~chinese
/// @brief 获取缩放后的大小
/// @brief 获取缩放后的大小
Size GetScaledSize() const;
/// \~chinese
/// @brief 获取锚点
/// @brief 获取锚点
virtual Point GetAnchor() const;
/// \~chinese
/// @brief 获取 x 方向锚点
/// @brief 获取 x 方向锚点
float GetAnchorX() const;
/// \~chinese
/// @brief 获取 y 方向锚点
/// @brief 获取 y 方向锚点
float GetAnchorY() const;
/// \~chinese
/// @brief 获取透明度
/// @brief 获取透明度
virtual float GetOpacity() const;
/// \~chinese
/// @brief 获取显示透明度
/// @brief 获取显示透明度
float GetDisplayedOpacity() const;
/// \~chinese
/// @brief 获取旋转角度
/// @brief 获取旋转角度
virtual float GetRotation() const;
/// \~chinese
/// @brief 获取缩放比例
/// @brief 获取缩放比例
virtual Point GetScale() const;
/// \~chinese
/// @brief 获取横向缩放比例
/// @brief 获取横向缩放比例
float GetScaleX() const;
/// \~chinese
/// @brief 获取纵向缩放比例
/// @brief 获取纵向缩放比例
float GetScaleY() const;
/// \~chinese
/// @brief 获取错切角度
/// @brief 获取错切角度
virtual Point GetSkew() const;
/// \~chinese
/// @brief 获取横向错切角度
/// @brief 获取横向错切角度
float GetSkewX() const;
/// \~chinese
/// @brief 获取纵向错切角度
/// @brief 获取纵向错切角度
float GetSkewY() const;
/// \~chinese
/// @brief 获取变换
/// @brief 获取变换
Transform GetTransform() const;
/// \~chinese
/// @brief 获取父角色
/// @brief 获取父角色
Actor* GetParent() const;
/// \~chinese
/// @brief 获取所在舞台
/// @brief 获取所在舞台
Stage* GetStage() const;
/// \~chinese
/// @brief 获取边框
/// @brief 获取边框
virtual Rect GetBounds() const;
/// \~chinese
/// @brief 获取外切包围盒
/// @brief 获取外切包围盒
virtual Rect GetBoundingBox() const;
/// \~chinese
/// @brief 获取二维变换矩阵
/// @brief 获取二维变换矩阵
const Matrix3x2& GetTransformMatrix() const;
/// \~chinese
/// @brief 获取二维变换的逆矩阵
/// @brief 获取二维变换的逆矩阵
const Matrix3x2& GetTransformInverseMatrix() const;
/// \~chinese
/// @brief 获取变换到父角色的二维变换矩阵
/// @brief 获取变换到父角色的二维变换矩阵
const Matrix3x2& GetTransformMatrixToParent() const;
/// \~chinese
/// @brief 设置角色是否可见
/// @brief 设置角色是否可见
void SetVisible(bool val);
/// \~chinese
/// @brief 设置名称
/// @brief 设置名称
void SetName(const String& name);
/// \~chinese
/// @brief 设置坐标
/// @brief 设置坐标
virtual void SetPosition(const Point& point);
/// \~chinese
/// @brief 设置坐标
/// @brief 设置坐标
void SetPosition(float x, float y);
/// \~chinese
/// @brief 设置横坐标
/// @brief 设置横坐标
void SetPositionX(float x);
/// \~chinese
/// @brief 设置纵坐标
/// @brief 设置纵坐标
void SetPositionY(float y);
/// \~chinese
/// @brief 移动坐标
/// @brief 移动坐标
void Move(const Vec2& v);
/// \~chinese
/// @brief 移动坐标
/// @brief 移动坐标
void Move(float vx, float vy);
/// \~chinese
/// @brief 设置缩放比例,默认为 (1.0, 1.0)
/// @brief 设置缩放比例,默认为 (1.0, 1.0)
virtual void SetScale(const Vec2& scale);
/// \~chinese
/// @brief 设置缩放比例,默认为 (1.0, 1.0)
/// @brief 设置缩放比例,默认为 (1.0, 1.0)
void SetScale(float scalex, float scaley);
/// \~chinese
/// @brief 设置错切角度,默认为 (0, 0)
/// @brief 设置错切角度,默认为 (0, 0)
virtual void SetSkew(const Vec2& skew);
/// \~chinese
/// @brief 设置错切角度,默认为 (0, 0)
/// @brief 设置错切角度,默认为 (0, 0)
void SetSkew(float skewx, float skewy);
/// \~chinese
/// @brief 设置旋转角度,默认为 0
/// @brief 设置旋转角度,默认为 0
virtual void SetRotation(float rotation);
/// \~chinese
/// @brief 设置锚点位置,默认为 (0, 0), 范围 [0, 1]
/// @brief 设置锚点位置,默认为 (0, 0), 范围 [0, 1]
virtual void SetAnchor(const Vec2& anchor);
/// \~chinese
/// @brief 设置锚点位置,默认为 (0, 0), 范围 [0, 1]
/// @brief 设置锚点位置,默认为 (0, 0), 范围 [0, 1]
void SetAnchor(float anchorx, float anchory);
/// \~chinese
/// @brief 修改大小
/// @brief 修改大小
virtual void SetSize(const Size& size);
/// \~chinese
/// @brief 修改大小
/// @brief 修改大小
void SetSize(float width, float height);
/// \~chinese
/// @brief 修改宽度
/// @brief 修改宽度
void SetWidth(float width);
/// \~chinese
/// @brief 修改高度
/// @brief 修改高度
void SetHeight(float height);
/// \~chinese
/// @brief 设置透明度,默认为 1.0, 范围 [0, 1]
/// @brief 设置透明度,默认为 1.0, 范围 [0, 1]
virtual void SetOpacity(float opacity);
/// \~chinese
/// @brief 启用或禁用级联透明度
/// @brief 启用或禁用级联透明度
void SetCascadeOpacityEnabled(bool enabled);
/// \~chinese
/// @brief 设置二维仿射变换
/// @brief 设置二维仿射变换
void SetTransform(const Transform& transform);
/// \~chinese
/// @brief 设置 Z 轴顺序,默认为 0
/// @brief 设置 Z 轴顺序,默认为 0
void SetZOrder(int zorder);
/// \~chinese
/// @brief 设置角色是否可响应,默认为 false
/// @details 可响应的角色会收到鼠标的 Hover | Out | Click 消息
/// @brief 设置角色是否可响应,默认为 false
/// @details 可响应的角色会收到鼠标的 Hover | Out | Click 消息
void SetResponsible(bool enable);
/// \~chinese
/// @brief 添加子角色
/// @brief 添加子角色
void AddChild(ActorPtr child, int zorder = 0);
/// \~chinese
/// @brief 添加多个子角色
/// @brief 添加多个子角色
void AddChildren(const Vector<ActorPtr>& children);
/// \~chinese
/// @brief 获取名称相同的子角色
/// @brief 获取名称相同的子角色
ActorPtr GetChild(const String& name) const;
/// \~chinese
/// @brief 获取所有名称相同的子角色
/// @brief 获取所有名称相同的子角色
Vector<ActorPtr> GetChildren(const String& name) const;
/// \~chinese
/// @brief 获取全部子角色
/// @brief 获取全部子角色
ActorList& GetAllChildren();
/// \~chinese
/// @brief 获取全部子角色
/// @brief 获取全部子角色
const ActorList& GetAllChildren() const;
/// \~chinese
/// @brief 移除子角色
/// @brief 移除子角色
void RemoveChild(ActorPtr child);
/// \~chinese
/// @brief 移除所有名称相同的子角色
/// @brief 移除所有名称相同的子角色
void RemoveChildren(const String& child_name);
/// \~chinese
/// @brief 移除所有角色
/// @brief 移除所有角色
void RemoveAllChildren();
/// \~chinese
/// @brief 从父角色移除
/// @brief 从父角色移除
void RemoveFromParent();
/// \~chinese
/// @brief 添加组件
/// @param component 组件
/// @brief 添加组件
/// @param component 组件
Component* AddComponent(ComponentPtr component);
/// \~chinese
/// @brief 获取所有组件
/// @brief 获取所有组件
ComponentList& GetAllComponents();
/// \~chinese
/// @brief 获取所有组件
/// @brief 获取所有组件
const ComponentList& GetAllComponents() const;
/// \~chinese
/// @brief 移除组件
/// @brief 移除组件
void RemoveComponent(ComponentPtr component);
/// \~chinese
/// @brief 移除组件
/// @param name 组件名称
/// @brief 移除组件
/// @param name 组件名称
void RemoveComponents(const String& name);
/// \~chinese
/// @brief 移除所有组件
/// @brief 移除所有组件
void RemoveAllComponents();
/// \~chinese
/// @brief 暂停角色更新
/// @brief 暂停角色更新
void PauseUpdating();
/// \~chinese
/// @brief 继续角色更新
/// @brief 继续角色更新
void ResumeUpdating();
/// \~chinese
/// @brief 角色更新是否暂停
/// @brief 角色更新是否暂停
bool IsUpdatePausing() const;
/// \~chinese
/// @brief 设置更新时的回调函数
/// @brief 设置更新时的回调函数
void SetCallbackOnUpdate(const UpdateCallback& cb);
/// \~chinese
/// @brief 获取更新时的回调函数
/// @brief 获取更新时的回调函数
UpdateCallback GetCallbackOnUpdate() const;
/// \~chinese
/// @brief 获取物理身体仅当kiwano-physics包启用时生效
/// @brief 获取物理身体仅当kiwano-physics包启用时生效
physics::PhysicBody* GetPhysicBody() const;
/// \~chinese
/// @brief 设置物理身体仅当kiwano-physics包启用时生效
/// @brief 设置物理身体仅当kiwano-physics包启用时生效
void SetPhysicBody(physics::PhysicBody* body);
/// \~chinese
/// @brief 判断点是否在角色内
/// @brief 判断点是否在角色内
virtual bool ContainsPoint(const Point& point) const;
/// \~chinese
/// @brief 将世界坐标系点转换为局部坐标系点
/// @brief 将世界坐标系点转换为局部坐标系点
Point ConvertToLocal(const Point& point) const;
/// \~chinese
/// @brief 将局部坐标系点转换为世界坐标系点
/// @brief 将局部坐标系点转换为世界坐标系点
Point ConvertToWorld(const Point& point) const;
/// \~chinese
/// @brief 渲染角色边界
/// @brief 渲染角色边界
void ShowBorder(bool show);
/// \~chinese
/// @brief 分发事件
/// @param evt 事件
/// @return 是否继续分发该事件
/// @brief 分发事件
/// @param evt 事件
/// @return 是否继续分发该事件
virtual bool DispatchEvent(Event* evt);
/// \~chinese
/// @brief 设置默认锚点
/// @brief 设置默认锚点
static void SetDefaultAnchor(float anchor_x, float anchor_y);
protected:
/// \~chinese
/// @brief 更新自身和所有子角色
/// @brief 更新自身和所有子角色
virtual void Update(Duration dt);
/// \~chinese
/// @brief 渲染自身和所有子角色
/// @brief 渲染自身和所有子角色
virtual void Render(RenderContext& ctx);
/// \~chinese
/// @brief 绘制自身和所有子角色的边界
/// @brief 绘制自身和所有子角色的边界
virtual void RenderBorder(RenderContext& ctx);
/// \~chinese
/// @brief 检查是否在渲染上下文的视区内
/// @brief 检查是否在渲染上下文的视区内
virtual bool CheckVisibility(RenderContext& ctx) const;
/// \~chinese
/// @brief 渲染前初始化渲染上下文状态,仅当 CheckVisibility 返回真时调用该函数
/// @brief 渲染前初始化渲染上下文状态,仅当 CheckVisibility 返回真时调用该函数
virtual void PrepareToRender(RenderContext& ctx);
/// \~chinese
/// @brief 更新自己的二维变换,并通知所有子角色
/// @brief 更新自己的二维变换,并通知所有子角色
void UpdateTransform() const;
/// \~chinese
/// @brief 更新自己和所有子角色的透明度
/// @brief 更新自己和所有子角色的透明度
void UpdateOpacity();
/// \~chinese
/// @brief 将所有子角色按Z轴顺序排序
/// @brief 将所有子角色按Z轴顺序排序
void Reorder();
/// \~chinese
/// @brief 设置节点所在舞台
/// @brief 设置节点所在舞台
void SetStage(Stage* stage);
/// \~chinese
/// @brief 处理事件
/// @brief 处理事件
bool HandleEvent(Event* evt);
/// \~chinese
/// @brief 更新组件
/// @brief 更新组件
void UpdateComponents(Duration dt);
/// \~chinese
/// @brief 渲染组件
/// @brief 渲染组件
void RenderComponents(RenderContext& ctx);
private:

View File

@ -28,26 +28,26 @@ KGE_DECLARE_SMART_PTR(Button);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Button : public Component
{
public:
/// \~chinese
/// @brief 按钮回调函数
/// @brief 按钮回调函数
using Callback = Function<void(Button* /* self */, Actor* /* target */)>;
/// \~chinese
/// @brief 创建按钮
/// @param click 按钮点击回调函数
/// @brief 创建按钮
/// @param click 按钮点击回调函数
static ButtonPtr Create(const Callback& click);
/// \~chinese
/// @brief 创建按钮
/// @param click 按钮点击回调函数
/// @param pressed 按钮按下回调函数
/// @param mouse_over 按钮移入回调函数
/// @param mouse_out 按钮移出回调函数
/// @brief 创建按钮
/// @param click 按钮点击回调函数
/// @param pressed 按钮按下回调函数
/// @param mouse_over 按钮移入回调函数
/// @param mouse_out 按钮移出回调函数
static ButtonPtr Create(const Callback& click, const Callback& pressed, const Callback& mouse_over,
const Callback& mouse_out);
@ -56,49 +56,49 @@ public:
virtual ~Button();
/// \~chinese
/// @brief 设置按钮点击后的回调函数
/// @brief 设置按钮点击后的回调函数
void SetClickCallback(const Callback& func);
/// \~chinese
/// @brief 设置按钮被按下时的回调函数
/// @brief 设置按钮被按下时的回调函数
void SetPressedCallback(const Callback& func);
/// \~chinese
/// @brief 设置鼠标移入按钮时的回调函数
/// @brief 设置鼠标移入按钮时的回调函数
void SetMouseOverCallback(const Callback& func);
/// \~chinese
/// @brief 设置鼠标移出按钮时的回调函数
/// @brief 设置鼠标移出按钮时的回调函数
void SetMouseOutCallback(const Callback& func);
protected:
/// \~chinese
/// @brief 按钮状态
/// @brief 按钮状态
enum class Status
{
Normal, ///< 普通
Hover, ///< 鼠标在按钮内
Pressed ///< 被按下
Normal, ///< 普通
Hover, ///< 鼠标在按钮内
Pressed ///< 被按下
};
/// \~chinese
/// @brief 获取按钮状态
/// @brief 获取按钮状态
Status GetStatus() const;
/// \~chinese
/// @brief 设置按钮状态
/// @brief 设置按钮状态
void SetStatus(Status status);
/// \~chinese
/// @brief 初始化组件
/// @brief 初始化组件
void InitComponent(Actor* actor) override;
/// \~chinese
/// @brief 销毁组件
/// @brief 销毁组件
void DestroyComponent() override;
/// \~chinese
/// @brief 处理角色事件
/// @brief 处理角色事件
void HandleEvent(Event* evt) override;
private:

View File

@ -36,238 +36,238 @@ KGE_DECLARE_SMART_PTR(Canvas);
/**
* \~chinese
* @brief
* @details
* @brief
* @details
*/
class KGE_API Canvas : public Actor
{
public:
/// \~chinese
/// @brief 创建画布
/// @param size 画布大小
/// @brief 创建画布
/// @param size 画布大小
static CanvasPtr Create(const Size& size);
/// \~chinese
/// @brief 开始绘图
/// @brief 开始绘图
void BeginDraw();
/// \~chinese
/// @brief 结束绘图
/// @brief 结束绘图
void EndDraw();
/// \~chinese
/// @brief 画形状轮廓
/// @param shape 形状
/// @brief 画形状轮廓
/// @param shape 形状
void DrawShape(ShapePtr shape);
/// \~chinese
/// @brief 画线段
/// @param begin 线段起点
/// @param end 线段终点
/// @brief 画线段
/// @param begin 线段起点
/// @param end 线段终点
void DrawLine(const Point& begin, const Point& end);
/// \~chinese
/// @brief 画圆形边框
/// @param center 圆形原点
/// @param radius 圆形半径
/// @brief 画圆形边框
/// @param center 圆形原点
/// @param radius 圆形半径
void DrawCircle(const Point& center, float radius);
/// \~chinese
/// @brief 画椭圆形边框
/// @param center 椭圆原点
/// @param radius 椭圆半径
/// @brief 画椭圆形边框
/// @param center 椭圆原点
/// @param radius 椭圆半径
void DrawEllipse(const Point& center, const Vec2& radius);
/// \~chinese
/// @brief 画矩形边框
/// @param rect 矩形
/// @brief 画矩形边框
/// @param rect 矩形
void DrawRect(const Rect& rect);
/// \~chinese
/// @brief 画圆角矩形边框
/// @param rect 矩形
/// @param radius 矩形圆角半径
/// @brief 画圆角矩形边框
/// @param rect 矩形
/// @param radius 矩形圆角半径
void DrawRoundedRect(const Rect& rect, const Vec2& radius);
/// \~chinese
/// @brief 填充形状
/// @param shape 形状
/// @brief 填充形状
/// @param shape 形状
void FillShape(ShapePtr shape);
/// \~chinese
/// @brief 填充圆形
/// @param center 圆形原点
/// @param radius 圆形半径
/// @brief 填充圆形
/// @param center 圆形原点
/// @param radius 圆形半径
void FillCircle(const Point& center, float radius);
/// \~chinese
/// @brief 填充椭圆形
/// @param center 椭圆原点
/// @param radius 椭圆半径
/// @brief 填充椭圆形
/// @param center 椭圆原点
/// @param radius 椭圆半径
void FillEllipse(const Point& center, const Vec2& radius);
/// \~chinese
/// @brief 填充矩形
/// @param rect 矩形
/// @brief 填充矩形
/// @param rect 矩形
void FillRect(const Rect& rect);
/// \~chinese
/// @brief 填充圆角矩形
/// @param rect 矩形
/// @param radius 矩形圆角半径
/// @brief 填充圆角矩形
/// @param rect 矩形
/// @param radius 矩形圆角半径
void FillRoundedRect(const Rect& rect, const Vec2& radius);
/// \~chinese
/// @brief 绘制图像帧
/// @param frame 图像帧
/// @param pos 绘制图像的位置
/// @brief 绘制图像帧
/// @param frame 图像帧
/// @param pos 绘制图像的位置
void DrawFrame(FramePtr frame, const Point& pos);
/// \~chinese
/// @brief 绘制图像帧
/// @param frame 图像帧
/// @param pos 绘制图像的位置
/// @param size 渲染的图像大小
/// @brief 绘制图像帧
/// @param frame 图像帧
/// @param pos 绘制图像的位置
/// @param size 渲染的图像大小
void DrawFrame(FramePtr frame, const Point& pos, const Size& size);
/// \~chinese
/// @brief 绘制文字布局
/// @param text 文字
/// @param style 文字样式
/// @param point 绘制文字的位置
/// @brief 绘制文字布局
/// @param text 文字
/// @param style 文字样式
/// @param point 绘制文字的位置
void DrawTextLayout(const String& text, const TextStyle& style, const Point& point);
/// \~chinese
/// @brief 绘制文字布局
/// @param layout 文字布局
/// @param point 绘制布局的位置
/// @brief 绘制文字布局
/// @param layout 文字布局
/// @param point 绘制布局的位置
void DrawTextLayout(TextLayoutPtr layout, const Point& point);
/// \~chinese
/// @brief 开始绘制路径
/// @param begin_pos 路径起始点
/// @brief 开始绘制路径
/// @param begin_pos 路径起始点
void BeginPath(const Point& begin_pos);
/// \~chinese
/// @brief 结束路径
/// @param closed 路径是否闭合
/// @brief 结束路径
/// @param closed 路径是否闭合
void EndPath(bool closed = false);
/// \~chinese
/// @brief 添加一条线段
/// @param point 端点
/// @brief 添加一条线段
/// @param point 端点
void AddLine(const Point& point);
/// \~chinese
/// @brief 添加多条线段
/// @param points 端点集合
/// @brief 添加多条线段
/// @param points 端点集合
void AddLines(const Vector<Point>& points);
/// \~chinese
/// @brief 添加一条三次方贝塞尔曲线
/// @param point1 贝塞尔曲线的第一个控制点
/// @param point2 贝塞尔曲线的第二个控制点
/// @param point3 贝塞尔曲线的终点
/// @brief 添加一条三次方贝塞尔曲线
/// @param point1 贝塞尔曲线的第一个控制点
/// @param point2 贝塞尔曲线的第二个控制点
/// @param point3 贝塞尔曲线的终点
void AddBezier(const Point& point1, const Point& point2, const Point& point3);
/// \~chinese
/// @brief 添加弧线
/// @param point 终点
/// @param radius 椭圆半径
/// @param rotation 椭圆旋转角度
/// @param clockwise 顺时针 or 逆时针
/// @param is_small 是否取小于 180° 的弧
/// @brief 添加弧线
/// @param point 终点
/// @param radius 椭圆半径
/// @param rotation 椭圆旋转角度
/// @param clockwise 顺时针 or 逆时针
/// @param is_small 是否取小于 180° 的弧
void AddArc(const Point& point, const Size& radius, float rotation, bool clockwise = true, bool is_small = true);
/// \~chinese
/// @brief 以描边的方式绘制路径
/// @brief 以描边的方式绘制路径
void StrokePath();
/// \~chinese
/// @brief 以填充的方式绘制路径
/// @brief 以填充的方式绘制路径
void FillPath();
/// \~chinese
/// @brief 清空画布
/// @brief 清空画布
void Clear();
/// \~chinese
/// @brief 清空画布
/// @param clear_color 清空颜色
/// @brief 清空画布
/// @param clear_color 清空颜色
void Clear(const Color& clear_color);
/// \~chinese
/// @brief 设置填充颜色
/// @param color 填充颜色
/// @brief 设置填充颜色
/// @param color 填充颜色
void SetFillColor(const Color& color);
/// \~chinese
/// @brief 设置填充画刷
/// @param[in] brush 填充画刷
/// @brief 设置填充画刷
/// @param[in] brush 填充画刷
void SetFillBrush(BrushPtr brush);
/// \~chinese
/// @brief 设置轮廓颜色
/// @param color 轮廓颜色
/// @brief 设置轮廓颜色
/// @param color 轮廓颜色
void SetStrokeColor(const Color& color);
/// \~chinese
/// @brief 设置轮廓画刷
/// @param[in] brush 轮廓画刷
/// @brief 设置轮廓画刷
/// @param[in] brush 轮廓画刷
void SetStrokeBrush(BrushPtr brush);
/// \~chinese
/// @brief 设置轮廓样式
/// @param stroke_style 轮廓样式
/// @brief 设置轮廓样式
/// @param stroke_style 轮廓样式
void SetStrokeStyle(StrokeStylePtr stroke_style);
/// \~chinese
/// @brief 设置画刷
/// @param[in] brush 画刷
/// @brief 设置画刷
/// @param[in] brush 画刷
void SetBrush(BrushPtr brush);
/// \~chinese
/// @brief 设置画刷二维变换
/// @param transform 二维变换
/// @brief 设置画刷二维变换
/// @param transform 二维变换
void SetBrushTransform(const Transform& transform);
/// \~chinese
/// @brief 设置画刷二维变换矩阵
/// @param transform 二维变换矩阵
/// @brief 设置画刷二维变换矩阵
/// @param transform 二维变换矩阵
void SetBrushTransform(const Matrix3x2& transform);
/// \~chinese
/// @brief 添加一个图层
/// @param layer 图层
/// @brief 添加一个图层
/// @param layer 图层
void PushLayer(LayerPtr layer);
/// \~chinese
/// @brief 删除最近添加的图层
/// @brief 删除最近添加的图层
void PopLayer();
/// \~chinese
/// @brief 添加一个裁剪区域
/// @param clip_rect 裁剪矩形
/// @brief 添加一个裁剪区域
/// @param clip_rect 裁剪矩形
void PushClipRect(const Rect& clip_rect);
/// \~chinese
/// @brief 删除最近添加的裁剪区域
/// @brief 删除最近添加的裁剪区域
void PopClipRect();
/// \~chinese
/// @brief 获取填充画刷
/// @brief 获取填充画刷
BrushPtr GetFillBrush() const;
/// \~chinese
/// @brief 获取轮廓画刷
/// @brief 获取轮廓画刷
BrushPtr GetStrokeBrush() const;
/// \~chinese
/// @brief 清空画布大小并重设画布大小
/// @brief 清空画布大小并重设画布大小
void ResizeAndClear(Size size);
/// \~chinese
/// @brief 导出纹理
/// @brief 导出纹理
TexturePtr ExportToTexture() const;
void OnRender(RenderContext& ctx) override;

View File

@ -33,12 +33,12 @@ class Event;
KGE_DECLARE_SMART_PTR(Component);
/// \~chinese
/// @brief 组件列表
/// @brief 组件列表
typedef IntrusiveList<ComponentPtr> ComponentList;
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Component
: public ObjectBase
@ -49,19 +49,19 @@ class KGE_API Component
public:
/// \~chinese
/// @brief 是否启用组件
/// @brief 是否启用组件
bool IsEnable() const;
/// \~chinese
/// @brief 设置组件启用或禁用
/// @brief 设置组件启用或禁用
void SetEnabled(bool enabled);
/// \~chinese
/// @brief 获取绑定的角色
/// @brief 获取绑定的角色
Actor* GetBoundActor() const;
/// \~chinese
/// @brief 从角色中移除
/// @brief 从角色中移除
void RemoveFromActor();
protected:
@ -70,23 +70,23 @@ protected:
virtual ~Component();
/// \~chinese
/// @brief 初始化组件
/// @brief 初始化组件
virtual void InitComponent(Actor* actor);
/// \~chinese
/// @brief 销毁组件
/// @brief 销毁组件
virtual void DestroyComponent();
/// \~chinese
/// @brief 更新组件
/// @brief 更新组件
virtual void OnUpdate(Duration dt);
/// \~chinese
/// @brief 渲染组件
/// @brief 渲染组件
virtual void OnRender(RenderContext& ctx);
/// \~chinese
/// @brief 处理角色事件
/// @brief 处理角色事件
virtual void HandleEvent(Event* evt);
private:

View File

@ -31,7 +31,7 @@ namespace kiwano
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API DebugActor : public Actor
{

View File

@ -28,88 +28,88 @@ KGE_DECLARE_SMART_PTR(Frame);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Frame : public ObjectBase
{
public:
/// \~chinese
/// @brief 创建图像帧
/// @param file_path 图像路径
/// @brief 创建图像帧
/// @param file_path 图像路径
static FramePtr Create(const String& file_path);
/// \~chinese
/// @brief 创建图像帧
/// @param res 图像资源
/// @brief 创建图像帧
/// @param res 图像资源
static FramePtr Create(const Resource& res);
/// \~chinese
/// @brief 创建图像帧
/// @param texture 纹理
/// @brief 创建图像帧
/// @param texture 纹理
static FramePtr Create(TexturePtr texture);
/// \~chinese
/// @brief 构建空图像帧
/// @brief 构建空图像帧
Frame();
/// \~chinese
/// @brief 加载图像
/// @param file_path 图像路径
/// @brief 加载图像
/// @param file_path 图像路径
bool Load(const String& file_path);
/// \~chinese
/// @brief 加载图像
/// @param res 图像资源
/// @brief 加载图像
/// @param res 图像资源
bool Load(const Resource& res);
/// \~chinese
/// @brief 裁剪图像帧为矩形
/// @param crop_rect 裁剪矩形定义
/// @brief 裁剪图像帧为矩形
/// @param crop_rect 裁剪矩形定义
void SetCropRect(const Rect& crop_rect);
/// \~chinese
/// @brief 设置纹理
/// @param texture 纹理
/// @brief 设置纹理
/// @param texture 纹理
void SetTexture(TexturePtr texture);
/// \~chinese
/// @brief 是否有效
/// @brief 是否有效
bool IsValid() const;
/// \~chinese
/// @brief 获取宽度
/// @brief 获取宽度
float GetWidth() const;
/// \~chinese
/// @brief 获取高度
/// @brief 获取高度
float GetHeight() const;
/// \~chinese
/// @brief 获取大小
/// @brief 获取大小
Size GetSize() const;
/// \~chinese
/// @brief 获取裁剪位置
/// @brief 获取裁剪位置
Point GetCropPoint() const;
/// \~chinese
/// @brief 获取裁剪矩形
/// @brief 获取裁剪矩形
const Rect& GetCropRect() const;
/// \~chinese
/// @brief 获取图像原宽度
/// @brief 获取图像原宽度
float GetSourceWidth() const;
/// \~chinese
/// @brief 获取图像原高度
/// @brief 获取图像原高度
float GetSourceHeight() const;
/// \~chinese
/// @brief 获取图像原大小
/// @brief 获取图像原大小
Size GetSourceSize() const;
/// \~chinese
/// @brief 获取纹理
/// @brief 获取纹理
TexturePtr GetTexture() const;
private:

View File

@ -29,76 +29,76 @@ KGE_DECLARE_SMART_PTR(FrameSequence);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API FrameSequence : public ObjectBase
{
public:
/// \~chinese
/// @brief 创建序列帧
/// @brief 创建序列帧
static FrameSequencePtr Create();
/// \~chinese
/// @brief 创建序列帧
/// @param frames 图像帧集合
/// @brief 创建序列帧
/// @param frames 图像帧集合
static FrameSequencePtr Create(const Vector<FramePtr>& frames);
/// \~chinese
/// @brief 按行列分割图像并创建序列帧
/// @param frame 图像帧
/// @param cols 列数
/// @param rows 行数
/// @param max_num 最大帧数量,设-1为将分割后的图像全部作为序列帧
/// @param padding_x X方向间隔
/// @param padding_y Y方向间隔
/// @brief 按行列分割图像并创建序列帧
/// @param frame 图像帧
/// @param cols 列数
/// @param rows 行数
/// @param max_num 最大帧数量,设-1为将分割后的图像全部作为序列帧
/// @param padding_x X方向间隔
/// @param padding_y Y方向间隔
static FrameSequencePtr Create(FramePtr frame, int cols, int rows = 1, int max_num = -1, float padding_x = 0,
float padding_y = 0);
/// \~chinese
/// @brief 构建空序列帧
/// @brief 构建空序列帧
FrameSequence();
virtual ~FrameSequence();
/// \~chinese
/// @brief 添加关键帧
/// @param frame 图像帧
/// @brief 添加关键帧
/// @param frame 图像帧
void AddFrame(FramePtr frame);
/// \~chinese
/// @brief 添加多个关键帧
/// @param frames 图像帧集合
/// @brief 添加多个关键帧
/// @param frames 图像帧集合
void AddFrames(const Vector<FramePtr>& frames);
/// \~chinese
/// @brief 按行列分割图像并添加序列帧
/// @param frame 图像帧
/// @param cols 列数
/// @param rows 行数
/// @param max_num 最大帧数量,设-1为将分割后的图像全部作为序列帧
/// @param padding_x X方向间隔
/// @param padding_y Y方向间隔
/// @brief 按行列分割图像并添加序列帧
/// @param frame 图像帧
/// @param cols 列数
/// @param rows 行数
/// @param max_num 最大帧数量,设-1为将分割后的图像全部作为序列帧
/// @param padding_x X方向间隔
/// @param padding_y Y方向间隔
void AddFrames(FramePtr frame, int cols, int rows = 1, int max_num = -1, float padding_x = 0, float padding_y = 0);
/// \~chinese
/// @brief 获取关键帧
/// @param index 图像帧下标
/// @brief 获取关键帧
/// @param index 图像帧下标
FramePtr GetFrame(size_t index) const;
/// \~chinese
/// @brief 获取所有关键帧
/// @brief 获取所有关键帧
const Vector<FramePtr>& GetFrames() const;
/// \~chinese
/// @brief 获取关键帧数量
/// @brief 获取关键帧数量
size_t GetFramesCount() const;
/// \~chinese
/// @brief 获取序列帧的拷贝对象
/// @brief 获取序列帧的拷贝对象
FrameSequencePtr Clone() const;
/// \~chinese
/// @brief 获取序列帧的倒转
/// @brief 获取序列帧的倒转
FrameSequencePtr Reverse() const;
private:

View File

@ -35,81 +35,81 @@ KGE_DECLARE_SMART_PTR(GifSprite);
/**
* \~chinese
* @brief GIF
* @brief GIF
*/
class KGE_API GifSprite : public Actor
{
public:
/// \~chinese
/// @brief GIF播放循环结束回调
/// @brief GIF播放循环结束回调
using LoopDoneCallback = Function<void(int /* times */)>;
/// \~chinese
/// @brief GIF播放结束回调
/// @brief GIF播放结束回调
using DoneCallback = Function<void()>;
/// \~chinese
/// @brief 创建GIF精灵
/// @param file_path GIF图片路径
/// @brief 创建GIF精灵
/// @param file_path GIF图片路径
static GifSpritePtr Create(const String& file_path);
/// \~chinese
/// @brief 创建GIF精灵
/// @param res GIF图片资源
/// @brief 创建GIF精灵
/// @param res GIF图片资源
static GifSpritePtr Create(const Resource& res);
/// \~chinese
/// @brief 创建GIF精灵
/// @param gif GIF图片
/// @brief 创建GIF精灵
/// @param gif GIF图片
static GifSpritePtr Create(GifImagePtr gif);
GifSprite();
/// \~chinese
/// @brief 加载GIF图片
/// @param file_path GIF图片路径
/// @brief 加载GIF图片
/// @param file_path GIF图片路径
bool Load(const String& file_path);
/// \~chinese
/// @brief 加载GIF图片
/// @param res GIF图片资源
/// @brief 加载GIF图片
/// @param res GIF图片资源
bool Load(const Resource& res);
/// \~chinese
/// @brief 加载GIF图片
/// @param gif GIF图片
/// @brief 加载GIF图片
/// @param gif GIF图片
bool Load(GifImagePtr gif);
/// \~chinese
/// @brief 设置 GIF 动画循环次数
/// @brief 设置 GIF 动画循环次数
void SetLoopCount(int loops);
/// \~chinese
/// @brief 设置 GIF 动画每次循环结束回调函数
/// @brief 设置 GIF 动画每次循环结束回调函数
void SetLoopDoneCallback(const LoopDoneCallback& cb);
/// \~chinese
/// @brief 设置 GIF 动画结束回调函数
/// @brief 设置 GIF 动画结束回调函数
void SetDoneCallback(const DoneCallback& cb);
/// \~chinese
/// @brief 设置 GIF 图像
/// @brief 设置 GIF 图像
void SetGifImage(GifImagePtr gif);
/// \~chinese
/// @brief 重新播放 GIF 动画
/// @brief 重新播放 GIF 动画
void RestartAnimation();
/// \~chinese
/// @brief 获取 GIF 动画循环结束回调
/// @brief 获取 GIF 动画循环结束回调
LoopDoneCallback GetLoopDoneCallback() const;
/// \~chinese
/// @brief 获取 GIF 动画播放结束回调
/// @brief 获取 GIF 动画播放结束回调
DoneCallback GetDoneCallback() const;
/// \~chinese
/// @brief 获取 GIF 图片
/// @brief 获取 GIF 图片
GifImagePtr GetGifImage() const;
void OnRender(RenderContext& ctx) override;
@ -118,35 +118,35 @@ private:
void Update(Duration dt) override;
/// \~chinese
/// @brief 是否是最后一帧
/// @brief 是否是最后一帧
bool IsLastFrame() const;
/// \~chinese
/// @brief 动画是否已结束
/// @brief 动画是否已结束
bool EndOfAnimation() const;
/// \~chinese
/// @brief 合成下一帧
/// @brief 合成下一帧
void ComposeNextFrame();
/// \~chinese
/// @brief 解析当前图像帧
/// @brief 解析当前图像帧
void DisposeCurrentFrame();
/// \~chinese
/// @brief 覆盖下一帧
/// @brief 覆盖下一帧
void OverlayNextFrame();
/// \~chinese
/// @brief 保存合成后的图像帧
/// @brief 保存合成后的图像帧
void SaveComposedFrame();
/// \~chinese
/// @brief 恢复已保存的图像帧
/// @brief 恢复已保存的图像帧
void RestoreSavedFrame();
/// \~chinese
/// @brief 清空当前图像区域
/// @brief 清空当前图像区域
void ClearCurrentFrameArea();
private:

View File

@ -34,13 +34,13 @@ KGE_DECLARE_SMART_PTR(LayerActor);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API LayerActor : public Actor
{
public:
/// \~chinese
/// @brief 创建图层
/// @brief 创建图层
static LayerActorPtr Create();
LayerActor();
@ -48,26 +48,26 @@ public:
virtual ~LayerActor();
/// \~chinese
/// @brief 是否开启消息吞没
/// @brief 是否开启消息吞没
bool IsSwallowEventsEnabled() const;
/// \~chinese
/// @brief 获取图层
/// @brief 获取图层
LayerPtr GetLayer() const;
/// \~chinese
/// @brief 设置图层
/// @param layer 图层
/// @brief 设置图层
/// @param layer 图层
void SetLayer(LayerPtr layer);
/// \~chinese
/// @brief 设置消息吞没功能
/// @param enabled 是否启用
/// @brief 设置消息吞没功能
/// @param enabled 是否启用
void SetSwallowEvents(bool enabled);
/// \~chinese
/// @brief 设置图层透明度
/// @param opacity 透明度
/// @brief 设置图层透明度
/// @param opacity 透明度
void SetOpacity(float opacity) override;
bool DispatchEvent(Event* evt) override;

View File

@ -43,90 +43,90 @@ KGE_DECLARE_SMART_PTR(PolygonActor);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API ShapeActor : public Actor
{
public:
/// \~chinese
/// @brief 创建形状角色
/// @param shape 形状
/// @brief 创建形状角色
/// @param shape 形状
static ShapeActorPtr Create(ShapePtr shape);
/// \~chinese
/// @brief 创建形状角色
/// @param shape 形状
/// @param fill_color 填充颜色
/// @param stroke_color 轮廓颜色
/// @brief 创建形状角色
/// @param shape 形状
/// @param fill_color 填充颜色
/// @param stroke_color 轮廓颜色
static ShapeActorPtr Create(ShapePtr shape, const Color& fill_color, const Color& stroke_color);
/// \~chinese
/// @brief 创建形状角色
/// @param shape 形状
/// @param fill_brush 填充画刷
/// @param stroke_brush 轮廓画刷
/// @brief 创建形状角色
/// @param shape 形状
/// @param fill_brush 填充画刷
/// @param stroke_brush 轮廓画刷
static ShapeActorPtr Create(ShapePtr shape, BrushPtr fill_brush, BrushPtr stroke_brush);
/// \~chinese
/// @brief 构造形状角色
/// @brief 构造形状角色
ShapeActor();
virtual ~ShapeActor();
/// \~chinese
/// @brief 获取填充画刷
/// @brief 获取填充画刷
BrushPtr GetFillBrush() const;
/// \~chinese
/// @brief 获取轮廓画刷
/// @brief 获取轮廓画刷
BrushPtr GetStrokeBrush() const;
/// \~chinese
/// @brief 获取线条样式
/// @brief 获取线条样式
StrokeStylePtr GetStrokeStyle() const;
/// \~chinese
/// @brief 获取形状
/// @brief 获取形状
ShapePtr GetShape() const;
/// \~chinese
/// @brief 获取边界
/// @brief 获取边界
Rect GetBounds() const override;
/// \~chinese
/// @brief 获取外切包围盒
/// @brief 获取外切包围盒
Rect GetBoundingBox() const override;
/// \~chinese
/// @brief 判断点是否在形状内
/// @brief 判断点是否在形状内
bool ContainsPoint(const Point& point) const override;
/// \~chinese
/// @brief 设置填充颜色
/// @param color 填充颜色
/// @brief 设置填充颜色
/// @param color 填充颜色
void SetFillColor(const Color& color);
/// \~chinese
/// @brief 设置填充画刷
/// @param[in] brush 填充画刷
/// @brief 设置填充画刷
/// @param[in] brush 填充画刷
void SetFillBrush(BrushPtr brush);
/// \~chinese
/// @brief 设置轮廓颜色
/// @param color 轮廓颜色
/// @brief 设置轮廓颜色
/// @param color 轮廓颜色
void SetStrokeColor(const Color& color);
/// \~chinese
/// @brief 设置轮廓画刷
/// @param[in] brush 轮廓画刷
/// @brief 设置轮廓画刷
/// @param[in] brush 轮廓画刷
void SetStrokeBrush(BrushPtr brush);
/// \~chinese
/// @brief 设置线条样式
/// @brief 设置线条样式
void SetStrokeStyle(StrokeStylePtr stroke_style);
/// \~chinese
/// @brief 设置形状
/// @brief 设置形状
void SetShape(ShapePtr shape);
void OnRender(RenderContext& ctx) override;
@ -143,14 +143,14 @@ private:
};
/// \~chinese
/// @brief 线段角色
/// @brief 线段角色
class KGE_API LineActor : public ShapeActor
{
public:
/// \~chinese
/// @brief 创建线段角色
/// @param begin 线段起点
/// @param end 线段终点
/// @brief 创建线段角色
/// @param begin 线段起点
/// @param end 线段终点
static LineActorPtr Create(const Point& begin, const Point& end);
LineActor();
@ -158,27 +158,27 @@ public:
virtual ~LineActor();
/// \~chinese
/// @brief 获取线段起点
/// @brief 获取线段起点
const Point& GetBeginPoint() const;
/// \~chinese
/// @brief 获取线段终点
/// @brief 获取线段终点
const Point& GetEndPoint() const;
/// \~chinese
/// @brief 设置线段起点
/// @param begin 线段起点
/// @brief 设置线段起点
/// @param begin 线段起点
void SetBeginPoint(const Point& begin);
/// \~chinese
/// @brief 设置线段终点
/// @param end 线段终点
/// @brief 设置线段终点
/// @param end 线段终点
void SetEndPoint(const Point& end);
/// \~chinese
/// @brief 设置线段起点和终点
/// @param begin 线段起点
/// @param end 线段终点
/// @brief 设置线段起点和终点
/// @param begin 线段起点
/// @param end 线段终点
void SetLine(const Point& begin, const Point& end);
private:
@ -187,13 +187,13 @@ private:
};
/// \~chinese
/// @brief 矩形角色
/// @brief 矩形角色
class KGE_API RectActor : public ShapeActor
{
public:
/// \~chinese
/// @brief 创建矩形角色
/// @param size 矩形大小
/// @brief 创建矩形角色
/// @param size 矩形大小
static RectActorPtr Create(const Size& size);
RectActor();
@ -201,12 +201,12 @@ public:
virtual ~RectActor();
/// \~chinese
/// @brief 获取矩形大小
/// @brief 获取矩形大小
const Size& GetRectSize() const;
/// \~chinese
/// @brief 设置矩形大小
/// @param size 矩形大小
/// @brief 设置矩形大小
/// @param size 矩形大小
void SetRectSize(const Size& size);
private:
@ -214,14 +214,14 @@ private:
};
/// \~chinese
/// @brief 圆角矩形角色
/// @brief 圆角矩形角色
class KGE_API RoundedRectActor : public ShapeActor
{
public:
/// \~chinese
/// @brief 创建圆角矩形角色
/// @param size 圆角矩形大小
/// @param radius 圆角半径
/// @brief 创建圆角矩形角色
/// @param size 圆角矩形大小
/// @param radius 圆角半径
static RoundedRectActorPtr Create(const Size& size, const Vec2& radius);
RoundedRectActor();
@ -229,27 +229,27 @@ public:
virtual ~RoundedRectActor();
/// \~chinese
/// @brief 获取圆角半径
/// @brief 获取圆角半径
Vec2 GetRadius() const;
/// \~chinese
/// @brief 获取圆角矩形大小
/// @brief 获取圆角矩形大小
Size GetRectSize() const;
/// \~chinese
/// @brief 设置圆角半径
/// @param radius 圆角半径
/// @brief 设置圆角半径
/// @param radius 圆角半径
void SetRadius(const Vec2& radius);
/// \~chinese
/// @brief 设置圆角矩形大小
/// @param size 圆角矩形大小
/// @brief 设置圆角矩形大小
/// @param size 圆角矩形大小
void SetRectSize(const Size& size);
/// \~chinese
/// @brief 设置圆角矩形
/// @param size 圆角矩形大小
/// @param radius 圆角半径
/// @brief 设置圆角矩形
/// @param size 圆角矩形大小
/// @param radius 圆角半径
void SetRoundedRect(const Size& size, const Vec2& radius);
private:
@ -258,13 +258,13 @@ private:
};
/// \~chinese
/// @brief 圆形角色
/// @brief 圆形角色
class KGE_API CircleActor : public ShapeActor
{
public:
/// \~chinese
/// @brief 创建圆形角色
/// @param radius 圆形半径
/// @brief 创建圆形角色
/// @param radius 圆形半径
static CircleActorPtr Create(float radius);
CircleActor();
@ -272,12 +272,12 @@ public:
virtual ~CircleActor();
/// \~chinese
/// @brief 获取圆形半径
/// @brief 获取圆形半径
float GetRadius() const;
/// \~chinese
/// @brief 设置圆形半径
/// @param radius 圆形半径
/// @brief 设置圆形半径
/// @param radius 圆形半径
void SetRadius(float radius);
private:
@ -285,13 +285,13 @@ private:
};
/// \~chinese
/// @brief 椭圆角色
/// @brief 椭圆角色
class KGE_API EllipseActor : public ShapeActor
{
public:
/// \~chinese
/// @brief 创建椭圆角色
/// @param radius 椭圆半径
/// @brief 创建椭圆角色
/// @param radius 椭圆半径
static EllipseActorPtr Create(const Vec2& radius);
EllipseActor();
@ -299,12 +299,12 @@ public:
virtual ~EllipseActor();
/// \~chinese
/// @brief 获取椭圆半径
/// @brief 获取椭圆半径
Vec2 GetRadius() const;
/// \~chinese
/// @brief 设置椭圆半径
/// @param radius 椭圆半径
/// @brief 设置椭圆半径
/// @param radius 椭圆半径
void SetRadius(const Vec2& radius);
private:
@ -312,13 +312,13 @@ private:
};
/// \~chinese
/// @brief 多边形角色
/// @brief 多边形角色
class KGE_API PolygonActor : public ShapeActor
{
public:
/// \~chinese
/// @brief 创建多边形角色
/// @param points 多边形端点集合
/// @brief 创建多边形角色
/// @param points 多边形端点集合
static PolygonActorPtr Create(const Vector<Point>& points);
PolygonActor();
@ -326,8 +326,8 @@ public:
virtual ~PolygonActor();
/// \~chinese
/// @brief 设置多边形端点
/// @param points 多边形端点集合
/// @brief 设置多边形端点
/// @param points 多边形端点集合
void SetVertices(const Vector<Point>& points);
};

View File

@ -33,36 +33,36 @@ KGE_DECLARE_SMART_PTR(Sprite);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Sprite : public Actor
{
public:
/// \~chinese
/// @brief 创建精灵
/// @param file_path 本地图片路径
/// @brief 创建精灵
/// @param file_path 本地图片路径
static SpritePtr Create(const String& file_path);
/// \~chinese
/// @brief 创建精灵
/// @param res 图片资源
/// @brief 创建精灵
/// @param res 图片资源
static SpritePtr Create(const Resource& res);
/// \~chinese
/// @brief 创建精灵
/// @param frame 图像帧
/// @brief 创建精灵
/// @param frame 图像帧
static SpritePtr Create(FramePtr frame);
/// \~chinese
/// @brief 创建精灵
/// @param file_path 本地图片路径
/// @param crop_rect 裁剪矩形
/// @brief 创建精灵
/// @param file_path 本地图片路径
/// @param crop_rect 裁剪矩形
static SpritePtr Create(const String& file_path, const Rect& crop_rect);
/// \~chinese
/// @brief 创建精灵
/// @param res 图片资源
/// @param crop_rect 裁剪矩形
/// @brief 创建精灵
/// @param res 图片资源
/// @param crop_rect 裁剪矩形
static SpritePtr Create(const Resource& res, const Rect& crop_rect);
Sprite();
@ -70,46 +70,46 @@ public:
virtual ~Sprite();
/// \~chinese
/// @brief 加载本地图片
/// @param file_path 本地图片路径
/// @param autoresize 是否自动调整自身大小为图像大小
/// @brief 加载本地图片
/// @param file_path 本地图片路径
/// @param autoresize 是否自动调整自身大小为图像大小
bool Load(const String& file_path, bool autoresize = true);
/// \~chinese
/// @brief 加载图像资源
/// @param res 图片资源
/// @param autoresize 是否自动调整自身大小为图像大小
/// @brief 加载图像资源
/// @param res 图片资源
/// @param autoresize 是否自动调整自身大小为图像大小
bool Load(const Resource& res, bool autoresize = true);
/// \~chinese
/// @brief 获取图像原宽度
/// @brief 获取图像原宽度
float GetSourceWidth() const;
/// \~chinese
/// @brief 获取图像原高度
/// @brief 获取图像原高度
float GetSourceHeight() const;
/// \~chinese
/// @brief 获取图像原大小
/// @brief 获取图像原大小
Size GetSourceSize() const;
/// \~chinese
/// @brief 获取裁剪矩形
/// @brief 获取裁剪矩形
Rect GetCropRect() const;
/// \~chinese
/// @brief 使用矩形区域裁剪精灵
/// @param crop_rect 裁剪矩形
/// @brief 使用矩形区域裁剪精灵
/// @param crop_rect 裁剪矩形
void SetCropRect(const Rect& crop_rect);
/// \~chinese
/// @brief 获取帧图像
/// @brief 获取帧图像
FramePtr GetFrame() const;
/// \~chinese
/// @brief 设置图像帧
/// @param[in] frame 图像帧
/// @param autoresize 是否自动调整自身大小为图像大小
/// @brief 设置图像帧
/// @param[in] frame 图像帧
/// @param autoresize 是否自动调整自身大小为图像大小
void SetFrame(FramePtr frame, bool autoresize = true);
void OnRender(RenderContext& ctx) override;

View File

@ -33,8 +33,8 @@ KGE_DECLARE_SMART_PTR(Stage);
/**
* \~chinese
* @brief
* @details
* @brief
* @details
* @see kiwano::Actor kiwano::Director
*/
class KGE_API Stage : public Actor
@ -44,7 +44,7 @@ class KGE_API Stage : public Actor
public:
/// \~chinese
/// @brief 进入舞台时
/// @brief 进入舞台时
static StagePtr Create();
Stage();
@ -52,34 +52,34 @@ public:
virtual ~Stage();
/// \~chinese
/// @brief 进入舞台时
/// @details 重载该函数以处理进入舞台前的行为
/// @brief 进入舞台时
/// @details 重载该函数以处理进入舞台前的行为
virtual void OnEnter();
/// \~chinese
/// @brief 退出舞台时
/// @details 重载该函数以处理退出舞台前的行为
/// @brief 退出舞台时
/// @details 重载该函数以处理退出舞台前的行为
virtual void OnExit();
/// \~chinese
/// @brief 获取角色边界填充画刷
/// @brief 获取角色边界填充画刷
BrushPtr GetBorderFillBrush() const;
/// \~chinese
/// @brief 获取角色边界轮廓画刷
/// @brief 获取角色边界轮廓画刷
BrushPtr GetBorderStrokeBrush() const;
/// \~chinese
/// @brief 设置角色边界填充画刷
/// @brief 设置角色边界填充画刷
void SetBorderFillBrush(BrushPtr brush);
/// \~chinese
/// @brief 设置角色边界轮廓画刷
/// @brief 设置角色边界轮廓画刷
void SetBorderStrokeBrush(BrushPtr brush);
protected:
/// \~chinese
/// @brief 绘制所有子角色的边界
/// @brief 绘制所有子角色的边界
void RenderBorder(RenderContext& ctx) override;
private:

View File

@ -34,20 +34,20 @@ KGE_DECLARE_SMART_PTR(TextActor);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API TextActor : public Actor
{
public:
/// \~chinese
/// @brief 创建文本角色
/// @param text 文字内容
/// @brief 创建文本角色
/// @param text 文字内容
static TextActorPtr Create(const String& text);
/// \~chinese
/// @brief 创建文本角色
/// @param text 文字内容
/// @param style 文本样式
/// @brief 创建文本角色
/// @param text 文字内容
/// @param style 文本样式
static TextActorPtr Create(const String& text, const TextStyle& style);
TextActor();
@ -55,117 +55,117 @@ public:
virtual ~TextActor();
/// \~chinese
/// @brief 获取文本
/// @brief 获取文本
String GetText() const;
/// \~chinese
/// @brief 获取文本样式
/// @brief 获取文本样式
TextStyle GetStyle() const;
/// \~chinese
/// @brief 获取文本布局
/// @brief 获取文本布局
TextLayoutPtr GetLayout() const;
/// \~chinese
/// @brief 获取大小
/// @brief 获取大小
Size GetSize() const override;
/// \~chinese
/// @brief 获取填充画刷
/// @brief 获取填充画刷
BrushPtr GetFillBrush() const;
/// \~chinese
/// @brief 获取描边画刷
/// @brief 获取描边画刷
BrushPtr GetOutlineBrush() const;
/// \~chinese
/// @brief 获取描边线条样式
/// @brief 获取描边线条样式
StrokeStylePtr GetOutlineStrokeStyle() const;
/// \~chinese
/// @brief 获取字体
/// @brief 获取字体
FontPtr GetFont() const;
/// \~chinese
/// @brief 设置文本
/// @brief 设置文本
void SetText(const String& text);
/// \~chinese
/// @brief 设置文本样式
/// @brief 设置文本样式
void SetStyle(const TextStyle& style);
/// \~chinese
/// @brief 设置字体
/// @brief 设置字体
void SetFont(FontPtr font);
/// \~chinese
/// @brief 设置字体族
/// @brief 设置字体族
void SetFontFamily(const String& family);
/// \~chinese
/// @brief 设置字号(默认值为 18
/// @brief 设置字号(默认值为 18
void SetFontSize(float size);
/// \~chinese
/// @brief 设置字体粗细值(默认值为 FontWeight::Normal
/// @brief 设置字体粗细值(默认值为 FontWeight::Normal
void SetFontWeight(uint32_t weight);
/// \~chinese
/// @brief 设置文字填充画刷
/// @brief 设置文字填充画刷
void SetFillBrush(BrushPtr brush);
/// \~chinese
/// @brief 设置文字填充颜色(默认值为 Color::White
/// @brief 设置文字填充颜色(默认值为 Color::White
void SetFillColor(const Color& color);
/// \~chinese
/// @brief 设置文字斜体(默认值为 false
/// @brief 设置文字斜体(默认值为 false
void SetItalic(bool italic);
/// \~chinese
/// @brief 设置文本自动换行的宽度(默认为 0
/// @brief 设置文本自动换行的宽度(默认为 0
void SetWrapWidth(float wrap_width);
/// \~chinese
/// @brief 设置行间距(默认为 0
/// @brief 设置行间距(默认为 0
void SetLineSpacing(float line_spacing);
/// \~chinese
/// @brief 设置对齐方式(默认为 TextAlign::Left
/// @brief 设置对齐方式(默认为 TextAlign::Left
void SetAlignment(TextAlign align);
/// \~chinese
/// @brief 设置文字描边画刷
/// @brief 设置文字描边画刷
void SetOutlineBrush(BrushPtr brush);
/// \~chinese
/// @brief 设置文字描边颜色
/// @brief 设置文字描边颜色
void SetOutlineColor(const Color& outline_color);
/// \~chinese
/// @brief 设置描边线条样式
/// @brief 设置描边线条样式
void SetOutlineStrokeStyle(StrokeStylePtr stroke);
/// \~chinese
/// @brief 设置是否显示下划线(默认值为 false
/// @brief 设置是否显示下划线(默认值为 false
void SetUnderline(bool enable);
/// \~chinese
/// @brief 设置是否显示删除线(默认值为 false
/// @brief 设置是否显示删除线(默认值为 false
void SetStrikethrough(bool enable);
/// \~chinese
/// @brief 设置文本布局
/// @brief 设置文本布局
void SetTextLayout(TextLayoutPtr layout);
/// \~chinese
/// @brief 更新脏文字布局
/// @details 仅当文字布局脏时更新
/// @brief 更新脏文字布局
/// @details 仅当文字布局脏时更新
void UpdateDirtyLayout();
/// \~chinese
/// @brief 强制更新文字布局
/// @details 文字布局是懒更新的,手动更新文字布局以更新节点状态
/// @brief 强制更新文字布局
/// @details 文字布局是懒更新的,手动更新文字布局以更新节点状态
void ForceUpdateLayout();
void OnRender(RenderContext& ctx) override;

View File

@ -36,7 +36,7 @@ KGE_DECLARE_SMART_PTR(RotationTransition);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Transition : public ObjectBase
{
@ -49,48 +49,48 @@ public:
/**
* \~chinese
* @brief
* @brief
*/
void SetDuration(Duration dt);
/**
* \~chinese
* @brief
* @brief
*/
bool IsDone();
protected:
/**
* \~chinese
* @brief
* @param[in] prev
* @param[in] next
* @brief
* @param[in] prev
* @param[in] next
*/
virtual void Init(StagePtr prev, StagePtr next);
/**
* \~chinese
* @brief
* @param dt
* @brief
* @param dt
*/
virtual void Update(Duration dt);
/**
* \~chinese
* @brief
* @param[in] ctx
* @brief
* @param[in] ctx
*/
virtual void Render(RenderContext& ctx);
/**
* \~chinese
* @brief
* @brief
*/
virtual void Stop();
/**
* \~chinese
* @brief
* @brief
*/
virtual void Reset() {}
@ -108,16 +108,16 @@ protected:
/**
* \~chinese
* @brief
* @details
* @brief
* @details
*/
class FadeTransition : public Transition
{
public:
/**
* \~chinese
* @brief
* @param duration
* @brief
* @param duration
*/
static FadeTransitionPtr Create(Duration duration);
@ -131,16 +131,16 @@ protected:
/**
* \~chinese
* @brief
* @details
* @brief
* @details
*/
class EmergeTransition : public Transition
{
public:
/**
* \~chinese
* @brief
* @param duration
* @brief
* @param duration
*/
static EmergeTransitionPtr Create(Duration duration);
@ -154,16 +154,16 @@ protected:
/**
* \~chinese
* @brief
* @details
* @brief
* @details
*/
class BoxTransition : public Transition
{
public:
/**
* \~chinese
* @brief
* @param duration
* @brief
* @param duration
*/
static BoxTransitionPtr Create(Duration duration);
@ -177,29 +177,29 @@ protected:
/**
* \~chinese
* @brief
* @details
* @brief
* @details
*/
class MoveTransition : public Transition
{
public:
/**
* \~chinese
* @brief
* @brief
*/
enum class Type : int
{
Up, ///< 上移
Down, ///< 下移
Left, ///< 左移
Right ///< 右移
Up, ///< 上移
Down, ///< 下移
Left, ///< 左移
Right ///< 右移
};
/**
* \~chinese
* @brief
* @param duration
* @param type
* @brief
* @param duration
* @param type
*/
static MoveTransitionPtr Create(Duration duration, Type type);
@ -220,17 +220,17 @@ private:
/**
* \~chinese
* @brief
* @details
* @brief
* @details
*/
class RotationTransition : public Transition
{
public:
/**
* \~chinese
* @brief
* @param duration
* @param rotation
* @brief
* @param duration
* @param rotation
*/
static RotationTransitionPtr Create(Duration duration, float rotation = 360.0f);

View File

@ -34,12 +34,12 @@ class ActionManager;
KGE_DECLARE_SMART_PTR(Action);
/// \~chinese
/// @brief 动画列表
/// @brief 动画列表
typedef IntrusiveList<ActionPtr> ActionList;
/**
* \~chinese
* \defgroup Actions
* \defgroup Actions
*/
/**
@ -48,7 +48,7 @@ typedef IntrusiveList<ActionPtr> ActionList;
*/
/// \~chinese
/// @brief 动画
/// @brief 动画
class KGE_API Action
: public ObjectBase
, protected IntrusiveListValue<ActionPtr>
@ -59,7 +59,7 @@ class KGE_API Action
public:
/// \~chinese
/// @brief 动画结束时的回调函数
/// @brief 动画结束时的回调函数
using DoneCallback = Function<void(Actor* /* target */)>;
Action();
@ -67,120 +67,120 @@ public:
virtual ~Action();
/// \~chinese
/// @brief 继续动画
/// @brief 继续动画
void Resume();
/// \~chinese
/// @brief 暂停动画
/// @brief 暂停动画
void Pause();
/// \~chinese
/// @brief 停止动画
/// @brief 停止动画
void Stop();
/// \~chinese
/// @brief 设置动画延时
/// @brief 设置动画延时
void SetDelay(Duration delay);
/// \~chinese
/// @brief 设置循环次数
/// @param loops 循环次数,-1 为永久循环
/// @brief 设置循环次数
/// @param loops 循环次数,-1 为永久循环
void SetLoops(int loops);
/// \~chinese
/// @brief 动画结束时移除目标角色
/// @brief 动画结束时移除目标角色
void RemoveTargetWhenDone();
/// \~chinese
/// @brief 设置动画结束时的回调函数
/// @brief 设置动画结束时的回调函数
void SetDoneCallback(const DoneCallback& cb);
/// \~chinese
/// @brief 设置动画循环结束时的回调函数
/// @brief 设置动画循环结束时的回调函数
void SetLoopDoneCallback(const DoneCallback& cb);
/// \~chinese
/// @brief 获取动画的拷贝
/// @brief 获取动画的拷贝
virtual ActionPtr Clone() const = 0;
/// \~chinese
/// @brief 获取动画的倒转
/// @brief 获取动画的倒转
virtual ActionPtr Reverse() const = 0;
/// \~chinese
/// @brief 获取动画的运行状态
/// @brief 获取动画的运行状态
bool IsRunning() const;
/// \~chinese
/// @brief 获取动画的循环次数
/// @brief 获取动画的循环次数
int GetLoops() const;
/// \~chinese
/// @brief 获取动画的延时
/// @brief 获取动画的延时
Duration GetDelay() const;
/// \~chinese
/// @brief 获取动画结束时的回调函数
/// @brief 获取动画结束时的回调函数
DoneCallback GetDoneCallback() const;
/// \~chinese
/// @brief 获取动画循环结束时的回调函数
/// @brief 获取动画循环结束时的回调函数
DoneCallback GetLoopDoneCallback() const;
protected:
/// \~chinese
/// @brief 初始化动画
/// @brief 初始化动画
virtual void Init(Actor* target);
/// \~chinese
/// @brief 更新动画
/// @brief 更新动画
virtual void Update(Actor* target, Duration dt);
/// \~chinese
/// @brief 更新一个时间步
/// @brief 更新一个时间步
void UpdateStep(Actor* target, Duration dt);
/// \~chinese
/// @brief 完成动画
/// @brief 完成动画
void Complete(Actor* target);
/// \~chinese
/// @brief 重新开始动画
/// @brief 重新开始动画
void Restart(Actor* target);
/// \~chinese
/// @brief 动画状态
/// @brief 动画状态
enum class Status
{
NotStarted, ///< 未开始
Delayed, ///< 等待延时
Started, ///< 已开始
Done, ///< 已结束
Removeable ///< 可移除
NotStarted, ///< 未开始
Delayed, ///< 等待延时
Started, ///< 已开始
Done, ///< 已结束
Removeable ///< 可移除
};
/// \~chinese
/// @brief 获取动画状态
/// @brief 获取动画状态
Status GetStatus() const;
/// \~chinese
/// @brief 获取消逝时间
/// @brief 获取消逝时间
Duration GetElapsed() const;
/// \~chinese
/// @brief 获取完成的循环次数
/// @brief 获取完成的循环次数
int GetLoopsDone() const;
/// \~chinese
/// @brief 结束动画
/// @brief 结束动画
void Done();
/// \~chinese
/// @brief 是否已结束
/// @brief 是否已结束
bool IsDone() const;
/// \~chinese
/// @brief 是否可移除
/// @brief 是否可移除
bool IsRemoveable() const;
protected:

View File

@ -32,21 +32,21 @@ KGE_DECLARE_SMART_PTR(ActionDelay);
*/
/// \~chinese
/// @brief 延时动画
/// @brief 延时动画
class KGE_API ActionDelay : public Action
{
public:
/// \~chinese
/// @brief 创建延时动画
/// @param delay 延时时长
/// @brief 创建延时动画
/// @param delay 延时时长
static ActionDelayPtr Create(Duration delay);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
ActionPtr Reverse() const override;
};

View File

@ -31,16 +31,16 @@ KGE_DECLARE_SMART_PTR(ActionGroup);
*/
/// \~chinese
/// @brief 动画组合
/// @brief 动画组合
class KGE_API ActionGroup : public Action
{
public:
using ActionList = IntrusiveList<ActionPtr>;
/// \~chinese
/// @brief 创建动画组合
/// @param actions 动画集合
/// @param sync 同步执行
/// @brief 创建动画组合
/// @param actions 动画集合
/// @param sync 同步执行
static ActionGroupPtr Create(const Vector<ActionPtr>& actions, bool sync = false);
ActionGroup();
@ -50,25 +50,25 @@ public:
virtual ~ActionGroup();
/// \~chinese
/// @brief 添加动画
/// @param action 动画
/// @brief 添加动画
/// @param action 动画
void AddAction(ActionPtr action);
/// \~chinese
/// @brief 添加多个动画
/// @param actions 动画集合
/// @brief 添加多个动画
/// @param actions 动画集合
void AddActions(const Vector<ActionPtr>& actions);
/// \~chinese
/// @brief 获取所有动画
/// @brief 获取所有动画
const ActionList& GetActions() const;
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
ActionPtr Reverse() const override;
protected:

View File

@ -33,13 +33,13 @@ namespace kiwano
*/
/// \~chinese
/// @brief 动画辅助类
/// @brief 动画辅助类
struct ActionHelper
{
using DoneCallback = Action::DoneCallback;
/// \~chinese
/// @brief 设置循环次数
/// @brief 设置循环次数
inline ActionHelper& SetLoops(int loops)
{
ptr->SetLoops(loops);
@ -47,7 +47,7 @@ struct ActionHelper
}
/// \~chinese
/// @brief 设置动画延迟
/// @brief 设置动画延迟
inline ActionHelper& SetDelay(Duration delay)
{
ptr->SetDelay(delay);
@ -55,7 +55,7 @@ struct ActionHelper
}
/// \~chinese
/// @brief 设置动画结束回调函数
/// @brief 设置动画结束回调函数
inline ActionHelper& SetDoneCallback(const DoneCallback& cb)
{
ptr->SetDoneCallback(cb);
@ -63,7 +63,7 @@ struct ActionHelper
}
/// \~chinese
/// @brief 设置动画循环结束时的回调函数
/// @brief 设置动画循环结束时的回调函数
inline ActionHelper& SetLoopDoneCallback(const DoneCallback& cb)
{
ptr->SetLoopDoneCallback(cb);
@ -71,7 +71,7 @@ struct ActionHelper
}
/// \~chinese
/// @brief 动画结束时移除目标角色
/// @brief 动画结束时移除目标角色
inline ActionHelper& RemoveTargetWhenDone()
{
ptr->RemoveTargetWhenDone();
@ -79,7 +79,7 @@ struct ActionHelper
}
/// \~chinese
/// @brief 设置名称
/// @brief 设置名称
inline ActionHelper& SetName(const String& name)
{
ptr->SetName(name);
@ -87,7 +87,7 @@ struct ActionHelper
}
/// \~chinese
/// @brief 获取指针
/// @brief 获取指针
inline ActionPtr Get() const
{
return ptr;
@ -113,13 +113,13 @@ private:
};
/// \~chinese
/// @brief 补间动画辅助类
/// @brief 补间动画辅助类
struct TweenHelper
{
using DoneCallback = Action::DoneCallback;
/// \~chinese
/// @brief 设置动画持续时长
/// @brief 设置动画持续时长
inline TweenHelper& SetDuration(Duration dur)
{
ptr->SetDuration(dur);
@ -127,7 +127,7 @@ struct TweenHelper
}
/// \~chinese
/// @brief 设置循环次数
/// @brief 设置循环次数
inline TweenHelper& SetLoops(int loops)
{
ptr->SetLoops(loops);
@ -135,7 +135,7 @@ struct TweenHelper
}
/// \~chinese
/// @brief 设置缓动函数
/// @brief 设置缓动函数
inline TweenHelper& SetEaseFunc(EaseFunc ease)
{
ptr->SetEaseFunc(ease);
@ -143,7 +143,7 @@ struct TweenHelper
}
/// \~chinese
/// @brief 设置动画延迟
/// @brief 设置动画延迟
inline TweenHelper& SetDelay(Duration delay)
{
ptr->SetDelay(delay);
@ -151,7 +151,7 @@ struct TweenHelper
}
/// \~chinese
/// @brief 设置动画结束回调函数
/// @brief 设置动画结束回调函数
inline TweenHelper& SetDoneCallback(const DoneCallback& cb)
{
ptr->SetDoneCallback(cb);
@ -159,7 +159,7 @@ struct TweenHelper
}
/// \~chinese
/// @brief 设置动画循环结束时的回调函数
/// @brief 设置动画循环结束时的回调函数
inline TweenHelper& SetLoopDoneCallback(const DoneCallback& cb)
{
ptr->SetLoopDoneCallback(cb);
@ -167,7 +167,7 @@ struct TweenHelper
}
/// \~chinese
/// @brief 动画结束时移除目标角色
/// @brief 动画结束时移除目标角色
inline TweenHelper& RemoveTargetWhenDone()
{
ptr->RemoveTargetWhenDone();
@ -175,7 +175,7 @@ struct TweenHelper
}
/// \~chinese
/// @brief 设置名称
/// @brief 设置名称
inline TweenHelper& SetName(const String& name)
{
ptr->SetName(name);
@ -183,7 +183,7 @@ struct TweenHelper
}
/// \~chinese
/// @brief 获取指针
/// @brief 获取指针
inline ActionTweenPtr Get() const
{
return ptr;
@ -214,120 +214,120 @@ private:
};
/// \~chinese
/// @brief 动画构造器
/// @brief 动画构造器
struct Tween
{
public:
/// \~chinese
/// @brief 构造相对位移动画
/// @param duration 动画时长
/// @param vector 移动向量
/// @brief 构造相对位移动画
/// @param duration 动画时长
/// @param vector 移动向量
static inline TweenHelper MoveBy(Duration dur, const Point& vector)
{
return TweenHelper(ActionMoveBy::Create(dur, vector));
}
/// \~chinese
/// @brief 构造位移动画
/// @param duration 动画时长
/// @param pos 目的坐标
/// @brief 构造位移动画
/// @param duration 动画时长
/// @param pos 目的坐标
static inline TweenHelper MoveTo(Duration dur, const Point& pos)
{
return TweenHelper(ActionMoveTo::Create(dur, pos));
}
/// \~chinese
/// @brief 构造相对跳跃动画
/// @param duration 动画时长
/// @param vec 跳跃位移向量
/// @param height 跳跃高度
/// @param jumps 跳跃次数
/// @brief 构造相对跳跃动画
/// @param duration 动画时长
/// @param vec 跳跃位移向量
/// @param height 跳跃高度
/// @param jumps 跳跃次数
static inline TweenHelper JumpBy(Duration duration, const Vec2& vec, float height, int jumps = 1)
{
return TweenHelper(ActionJumpBy::Create(duration, vec, height, jumps));
}
/// \~chinese
/// @brief 构造跳跃动画
/// @param duration 动画时长
/// @param pos 目的坐标
/// @param height 跳跃高度
/// @param jumps 跳跃次数
/// @brief 构造跳跃动画
/// @param duration 动画时长
/// @param pos 目的坐标
/// @param height 跳跃高度
/// @param jumps 跳跃次数
static inline TweenHelper JumpTo(Duration duration, const Point& pos, float height, int jumps = 1)
{
return TweenHelper(ActionJumpTo::Create(duration, pos, height, jumps));
}
/// \~chinese
/// @brief 构造相对缩放动画
/// @param duration 动画时长
/// @param scale_x 横向缩放相对变化值
/// @param scale_y 纵向缩放相对变化值
/// @brief 构造相对缩放动画
/// @param duration 动画时长
/// @param scale_x 横向缩放相对变化值
/// @param scale_y 纵向缩放相对变化值
static inline TweenHelper ScaleBy(Duration dur, float scale_x, float scale_y)
{
return TweenHelper(ActionScaleBy::Create(dur, scale_x, scale_y));
}
/// \~chinese
/// @brief 构造缩放动画
/// @param duration 动画时长
/// @param scale_x 横向缩放目标值
/// @param scale_y 纵向缩放目标值
/// @brief 构造缩放动画
/// @param duration 动画时长
/// @param scale_x 横向缩放目标值
/// @param scale_y 纵向缩放目标值
static inline TweenHelper ScaleTo(Duration dur, float scale_x, float scale_y)
{
return TweenHelper(ActionScaleTo::Create(dur, scale_x, scale_y));
}
/// \~chinese
/// @brief 构造透明度渐变动画
/// @param duration 动画时长
/// @param opacity 目标透明度
/// @brief 构造透明度渐变动画
/// @param duration 动画时长
/// @param opacity 目标透明度
static inline TweenHelper FadeTo(Duration dur, float opacity)
{
return TweenHelper(ActionFadeTo::Create(dur, opacity));
}
/// \~chinese
/// @brief 构造淡入动画
/// @param duration 动画时长
/// @brief 构造淡入动画
/// @param duration 动画时长
static inline TweenHelper FadeIn(Duration dur)
{
return TweenHelper(ActionFadeIn::Create(dur));
}
/// \~chinese
/// @brief 构造淡出动画
/// @param duration 动画时长
/// @brief 构造淡出动画
/// @param duration 动画时长
static inline TweenHelper FadeOut(Duration dur)
{
return TweenHelper(ActionFadeOut::Create(dur));
}
/// \~chinese
/// @brief 构造相对旋转动画
/// @param duration 动画时长
/// @param rotation 角度相对变化值
/// @brief 构造相对旋转动画
/// @param duration 动画时长
/// @param rotation 角度相对变化值
static inline TweenHelper RotateBy(Duration dur, float rotation)
{
return TweenHelper(ActionRotateBy::Create(dur, rotation));
}
/// \~chinese
/// @brief 构造旋转动画
/// @param duration 动画时长
/// @param rotation 目标角度
/// @brief 构造旋转动画
/// @param duration 动画时长
/// @param rotation 目标角度
static inline TweenHelper RotateTo(Duration dur, float rotation)
{
return TweenHelper(ActionRotateTo::Create(dur, rotation));
}
/// \~chinese
/// @brief 构造路径行走动画
/// @param duration 持续时长
/// @param path 路径形状
/// @param rotating 是否沿路径切线方向旋转
/// @param start 路径起点(百分比)
/// @param end 路径终点(百分比)
/// @brief 构造路径行走动画
/// @param duration 持续时长
/// @param path 路径形状
/// @param rotating 是否沿路径切线方向旋转
/// @param start 路径起点(百分比)
/// @param end 路径终点(百分比)
static inline TweenHelper Walk(Duration duration, ShapePtr path, bool rotating = false, float start = 0.f,
float end = 1.f)
{
@ -335,35 +335,35 @@ public:
}
/// \~chinese
/// @brief 构建帧动画
/// @param duration 动画时长
/// @param[in] frame_seq 序列帧
/// @brief 构建帧动画
/// @param duration 动画时长
/// @param[in] frame_seq 序列帧
static inline TweenHelper Animation(Duration dur, FrameSequencePtr frames)
{
return TweenHelper(Animation::Create(dur, frames));
}
/// \~chinese
/// @brief 构造自定义动画
/// @param duration 动画时长
/// @param tween_func 动画回调函数
/// @brief 构造自定义动画
/// @param duration 动画时长
/// @param tween_func 动画回调函数
static inline TweenHelper Custom(Duration dur, ActionCustom::TweenFunc tween_func)
{
return TweenHelper(ActionCustom::Create(dur, tween_func));
}
/// \~chinese
/// @brief 构建延时动画
/// @param delay 延时时长
/// @brief 构建延时动画
/// @param delay 延时时长
static inline ActionHelper Delay(Duration delay)
{
return ActionHelper(ActionDelay::Create(delay));
}
/// \~chinese
/// @brief 动画组合
/// @param actions 动画集合
/// @param sync 同步执行
/// @brief 动画组合
/// @param actions 动画集合
/// @param sync 同步执行
static inline ActionHelper Group(const Vector<ActionPtr>& actions, bool sync = false)
{
return ActionHelper(ActionGroup::Create(actions, sync));

View File

@ -30,39 +30,39 @@ namespace kiwano
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API ActionManager
{
public:
/// \~chinese
/// @brief 添加动画
/// @brief 添加动画
Action* AddAction(ActionPtr action);
/// \~chinese
/// @brief 继续所有暂停动画
/// @brief 继续所有暂停动画
void ResumeAllActions();
/// \~chinese
/// @brief 暂停所有动画
/// @brief 暂停所有动画
void PauseAllActions();
/// \~chinese
/// @brief 停止所有动画
/// @brief 停止所有动画
void StopAllActions();
/// \~chinese
/// @brief 获取指定名称的动画
/// @param name 动画名称
/// @brief 获取指定名称的动画
/// @param name 动画名称
ActionPtr GetAction(const String& name);
/// \~chinese
/// @brief 获取所有动画
/// @brief 获取所有动画
const ActionList& GetAllActions() const;
protected:
/// \~chinese
/// @brief 更新动画
/// @brief 更新动画
void UpdateActions(Actor* target, Duration dt);
private:

View File

@ -25,27 +25,27 @@
namespace kiwano
{
/// \~chinese
/// @brief 缓动函数
/// @brief 缓动函数
using EaseFunc = Function<float(float)>;
/// \~chinese
/// @brief 缓动函数枚举
/// @details 查看 https://easings.net 获取更多信息
/// @brief 缓动函数枚举
/// @details 查看 https://easings.net 获取更多信息
struct Ease
{
static KGE_API EaseFunc Linear; ///< 线性
static KGE_API EaseFunc EaseIn; ///< 由慢变快
static KGE_API EaseFunc EaseOut; ///< 由快变慢
static KGE_API EaseFunc EaseInOut; ///< 由慢变快, 再由快变慢
static KGE_API EaseFunc ExpoIn; ///< 由慢变极快
static KGE_API EaseFunc ExpoOut; ///< 由极快变慢
static KGE_API EaseFunc ExpoInOut; ///< 由慢至极快, 再由极快边慢
static KGE_API EaseFunc ElasticIn; ///< 自起点赋予弹性
static KGE_API EaseFunc ElasticOut; ///< 自终点赋予弹性
static KGE_API EaseFunc ElasticInOut; ///< 再起点和终点赋予弹性
static KGE_API EaseFunc BounceIn; ///< 自起点赋予反弹力
static KGE_API EaseFunc BounceOut; ///< 自终点赋予反弹力
static KGE_API EaseFunc BounceInOut; ///< 在起点和终点赋予反弹力
static KGE_API EaseFunc Linear; ///< 线性
static KGE_API EaseFunc EaseIn; ///< 由慢变快
static KGE_API EaseFunc EaseOut; ///< 由快变慢
static KGE_API EaseFunc EaseInOut; ///< 由慢变快, 再由快变慢
static KGE_API EaseFunc ExpoIn; ///< 由慢变极快
static KGE_API EaseFunc ExpoOut; ///< 由极快变慢
static KGE_API EaseFunc ExpoInOut; ///< 由慢至极快, 再由极快边慢
static KGE_API EaseFunc ElasticIn; ///< 自起点赋予弹性
static KGE_API EaseFunc ElasticOut; ///< 自终点赋予弹性
static KGE_API EaseFunc ElasticInOut; ///< 再起点和终点赋予弹性
static KGE_API EaseFunc BounceIn; ///< 自起点赋予反弹力
static KGE_API EaseFunc BounceOut; ///< 自终点赋予反弹力
static KGE_API EaseFunc BounceInOut; ///< 在起点和终点赋予反弹力
static KGE_API EaseFunc BackIn;
static KGE_API EaseFunc BackOut;
static KGE_API EaseFunc BackInOut;
@ -86,32 +86,32 @@ KGE_DECLARE_SMART_PTR(ActionCustom);
*/
/// \~chinese
/// @brief 补间动画
/// @brief 补间动画
class KGE_API ActionTween : public Action
{
public:
ActionTween();
/// \~chinese
/// @brief 补间动画
/// @param duration 动画时长
/// @param func 动画速度缓动函数
/// @brief 补间动画
/// @param duration 动画时长
/// @param func 动画速度缓动函数
ActionTween(Duration duration, EaseFunc ease);
/// \~chinese
/// @brief 获取动画时长
/// @brief 获取动画时长
Duration GetDuration() const;
/// \~chinese
/// @brief 设置动画时长
/// @brief 设置动画时长
void SetDuration(Duration duration);
/// \~chinese
/// @brief 获取动画速度缓动函数
/// @brief 获取动画速度缓动函数
const EaseFunc& GetEaseFunc() const;
/// \~chinese
/// @brief 设置动画速度缓动函数
/// @brief 设置动画速度缓动函数
void SetEaseFunc(const EaseFunc& func);
protected:
@ -127,32 +127,32 @@ private:
};
/// \~chinese
/// @brief 相对位移动画
/// @brief 相对位移动画
class KGE_API ActionMoveBy : public ActionTween
{
public:
/// \~chinese
/// @brief 创建相对位移动画
/// @param duration 动画时长
/// @param displacement 位移向量
/// @brief 创建相对位移动画
/// @param duration 动画时长
/// @param displacement 位移向量
static ActionMoveByPtr Create(Duration duration, const Vec2& displacement);
ActionMoveBy();
/// \~chinese
/// @brief 获取位移向量
/// @brief 获取位移向量
Vec2 GetDisplacement() const;
/// \~chinese
/// @brief 设置位移向量
/// @brief 设置位移向量
void SetDisplacement(const Vec2& displacement);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
ActionPtr Reverse() const override;
protected:
@ -167,32 +167,32 @@ protected:
};
/// \~chinese
/// @brief 位移动画
/// @brief 位移动画
class KGE_API ActionMoveTo : public ActionMoveBy
{
public:
/// \~chinese
/// @brief 创建位移动画
/// @param duration 动画时长
/// @param distination 目的坐标
/// @brief 创建位移动画
/// @param duration 动画时长
/// @param distination 目的坐标
static ActionMoveToPtr Create(Duration duration, const Point& distination);
ActionMoveTo();
/// \~chinese
/// @brief 获取目的坐标
/// @brief 获取目的坐标
Point GetDistination() const;
/// \~chinese
/// @brief 设置目的坐标
/// @brief 设置目的坐标
void SetDistination(const Point& distination);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
virtual ActionPtr Reverse() const override
{
KGE_ERROR("Reverse() not supported in ActionMoveTo");
@ -207,51 +207,51 @@ private:
};
/// \~chinese
/// @brief 相对跳跃动画
/// @brief 相对跳跃动画
class KGE_API ActionJumpBy : public ActionTween
{
public:
/// \~chinese
/// @brief 创建相对跳跃动画
/// @param duration 动画时长
/// @param displacement 跳跃位移向量
/// @param height 跳跃高度
/// @param count 跳跃次数
/// @brief 创建相对跳跃动画
/// @param duration 动画时长
/// @param displacement 跳跃位移向量
/// @param height 跳跃高度
/// @param count 跳跃次数
static ActionJumpByPtr Create(Duration duration, const Vec2& displacement, float height, int count = 1,
EaseFunc ease = nullptr);
ActionJumpBy();
/// \~chinese
/// @brief 获取跳跃位移
/// @brief 获取跳跃位移
Vec2 GetDisplacement() const;
/// \~chinese
/// @brief 获取跳跃高度
/// @brief 获取跳跃高度
float GetJumpHeight() const;
/// \~chinese
/// @brief 获取跳跃次数
/// @brief 获取跳跃次数
int GetJumpCount() const;
/// \~chinese
/// @brief 设置跳跃位移
/// @brief 设置跳跃位移
void SetDisplacement(const Vec2& displacement);
/// \~chinese
/// @brief 设置跳跃高度
/// @brief 设置跳跃高度
void SetJumpHeight(float height);
/// \~chinese
/// @brief 设置跳跃次数
/// @brief 设置跳跃次数
void SetJumpCount(int count);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
ActionPtr Reverse() const override;
protected:
@ -268,35 +268,35 @@ protected:
};
/// \~chinese
/// @brief 跳跃动画
/// @brief 跳跃动画
class KGE_API ActionJumpTo : public ActionJumpBy
{
public:
/// \~chinese
/// @brief 创建跳跃动画
/// @param duration 动画时长
/// @param distination 目的坐标
/// @param height 跳跃高度
/// @param count 跳跃次数
/// @brief 创建跳跃动画
/// @param duration 动画时长
/// @param distination 目的坐标
/// @param height 跳跃高度
/// @param count 跳跃次数
static ActionJumpToPtr Create(Duration duration, const Point& distination, float height, int count = 1,
EaseFunc ease = nullptr);
ActionJumpTo();
/// \~chinese
/// @brief 获取目的坐标
/// @brief 获取目的坐标
Point GetDistination() const;
/// \~chinese
/// @brief 设置目的坐标
/// @brief 设置目的坐标
void SetDistination(const Point& distination);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
virtual ActionPtr Reverse() const override
{
KGE_ERROR("Reverse() not supported in ActionJumpTo");
@ -311,41 +311,41 @@ private:
};
/// \~chinese
/// @brief 相对缩放动画
/// @brief 相对缩放动画
class KGE_API ActionScaleBy : public ActionTween
{
public:
/// \~chinese
/// @brief 创建相对缩放动画
/// @param duration 动画时长
/// @param scale_x 横向缩放相对变化值
/// @param scale_y 纵向缩放相对变化值
/// @brief 创建相对缩放动画
/// @param duration 动画时长
/// @param scale_x 横向缩放相对变化值
/// @param scale_y 纵向缩放相对变化值
static ActionScaleByPtr Create(Duration duration, float scale_x, float scale_y);
ActionScaleBy();
/// \~chinese
/// @brief 获取横向缩放相对变化值
/// @brief 获取横向缩放相对变化值
float GetScaleX() const;
/// \~chinese
/// @brief 获取横向缩放相对变化值
/// @brief 获取横向缩放相对变化值
float GetScaleY() const;
/// \~chinese
/// @brief 设置纵向缩放相对变化值
/// @brief 设置纵向缩放相对变化值
void SetScaleX(float scale_x);
/// \~chinese
/// @brief 设置纵向缩放相对变化值
/// @brief 设置纵向缩放相对变化值
void SetScaleY(float scale_y);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
ActionPtr Reverse() const override;
protected:
@ -361,41 +361,41 @@ protected:
};
/// \~chinese
/// @brief 缩放动画
/// @brief 缩放动画
class KGE_API ActionScaleTo : public ActionScaleBy
{
public:
/// \~chinese
/// @brief 创建缩放动画
/// @param duration 动画时长
/// @param scale_x 横向缩放目标值
/// @param scale_y 纵向缩放目标值
/// @brief 创建缩放动画
/// @param duration 动画时长
/// @param scale_x 横向缩放目标值
/// @param scale_y 纵向缩放目标值
static ActionScaleToPtr Create(Duration duration, float scale_x, float scale_y);
ActionScaleTo();
/// \~chinese
/// @brief 获取横向缩放目标值
/// @brief 获取横向缩放目标值
float GetTargetScaleX() const;
/// \~chinese
/// @brief 获取横向缩放目标值
/// @brief 获取横向缩放目标值
float GetTargetScaleY() const;
/// \~chinese
/// @brief 设置纵向缩放目标值
/// @brief 设置纵向缩放目标值
void SetTargetScaleX(float scale_x);
/// \~chinese
/// @brief 设置纵向缩放目标值
/// @brief 设置纵向缩放目标值
void SetTargetScaleY(float scale_y);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
virtual ActionPtr Reverse() const override
{
KGE_ERROR("Reverse() not supported in ActionScaleTo");
@ -411,32 +411,32 @@ private:
};
/// \~chinese
/// @brief 透明度渐变动画
/// @brief 透明度渐变动画
class KGE_API ActionFadeTo : public ActionTween
{
public:
/// \~chinese
/// @brief 创建透明度渐变动画
/// @param duration 动画时长
/// @param opacity 目标透明度
/// @brief 创建透明度渐变动画
/// @param duration 动画时长
/// @param opacity 目标透明度
static ActionFadeToPtr Create(Duration duration, float opacity);
ActionFadeTo();
/// \~chinese
/// @brief 获取目标透明度
/// @brief 获取目标透明度
float GetTargetOpacity() const;
/// \~chinese
/// @brief 设置目标透明度
/// @brief 设置目标透明度
void SetTargetOpacity(float opacity);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
virtual ActionPtr Reverse() const override
{
KGE_ERROR("Reverse() not supported in ActionFadeTo");
@ -455,54 +455,54 @@ private:
};
/// \~chinese
/// @brief 淡入动画
/// @brief 淡入动画
class KGE_API ActionFadeIn : public ActionFadeTo
{
public:
/// \~chinese
/// @brief 创建淡入动画
/// @param duration 动画时长
/// @brief 创建淡入动画
/// @param duration 动画时长
static ActionFadeInPtr Create(Duration duration);
};
/// \~chinese
/// @brief 淡出动画
/// @brief 淡出动画
class KGE_API ActionFadeOut : public ActionFadeTo
{
public:
/// \~chinese
/// @brief 创建淡出动画
/// @param duration 动画时长
/// @brief 创建淡出动画
/// @param duration 动画时长
static ActionFadeOutPtr Create(Duration duration);
};
/// \~chinese
/// @brief 相对旋转动画
/// @brief 相对旋转动画
class KGE_API ActionRotateBy : public ActionTween
{
public:
/// \~chinese
/// @brief 创建相对旋转动画
/// @param duration 动画时长
/// @param rotation 角度相对变化值
/// @brief 创建相对旋转动画
/// @param duration 动画时长
/// @param rotation 角度相对变化值
static ActionRotateByPtr Create(Duration duration, float rotation);
ActionRotateBy();
/// \~chinese
/// @brief 获取角度相对变化值
/// @brief 获取角度相对变化值
float GetRotation() const;
/// \~chinese
/// @brief 设置角度相对变化值
/// @brief 设置角度相对变化值
void SetRotation(float rotation);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
ActionPtr Reverse() const override;
protected:
@ -516,32 +516,32 @@ protected:
};
/// \~chinese
/// @brief 旋转动画
/// @brief 旋转动画
class KGE_API ActionRotateTo : public ActionRotateBy
{
public:
/// \~chinese
/// @brief 创建旋转动画
/// @param duration 动画时长
/// @param rotation 目标角度
/// @brief 创建旋转动画
/// @param duration 动画时长
/// @param rotation 目标角度
static ActionRotateToPtr Create(Duration duration, float rotation);
ActionRotateTo();
/// \~chinese
/// @brief 获取目标角度
/// @brief 获取目标角度
float GetTargetRotation() const;
/// \~chinese
/// @brief 设置目标角度
/// @brief 设置目标角度
void SetTargetRotation(float rotation);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
virtual ActionPtr Reverse() const override
{
KGE_ERROR("Reverse() not supported in ActionRotateTo");
@ -556,37 +556,37 @@ private:
};
/// \~chinese
/// @brief 自定义动画
/// @brief 自定义动画
class KGE_API ActionCustom : public ActionTween
{
public:
/// \~chinese
/// @brief 动画回调函数
/// @details 在动画更新时回调该函数第一个参数是执行动画的目标第二个参数是动画进度0.0 - 1.0
/// @brief 动画回调函数
/// @details 在动画更新时回调该函数第一个参数是执行动画的目标第二个参数是动画进度0.0 - 1.0
using TweenFunc = Function<void(Actor* /* target */, float /* percent */)>;
/// \~chinese
/// @brief 创建自定义动画
/// @param duration 动画时长
/// @param tween_func 动画回调函数
/// @brief 创建自定义动画
/// @param duration 动画时长
/// @param tween_func 动画回调函数
static ActionCustomPtr Create(Duration duration, TweenFunc tween_func);
ActionCustom();
/// \~chinese
/// @brief 获取动画回调函数
/// @brief 获取动画回调函数
TweenFunc GetTweenFunc() const;
/// \~chinese
/// @brief 设置动画回调函数
/// @brief 设置动画回调函数
void SetTweenFunc(const TweenFunc& tween_func);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
ActionPtr Reverse() const override
{
KGE_ERROR("Reverse() not supported in ActionCustom");

View File

@ -33,60 +33,60 @@ KGE_DECLARE_SMART_PTR(ActionWalk);
*/
/// \~chinese
/// @brief 路径行走动画
/// @brief 路径行走动画
class KGE_API ActionWalk : public ActionTween
{
public:
/// \~chinese
/// @brief 创建路径行走动画
/// @param duration 持续时长
/// @param path 路径形状
/// @param rotating 是否沿路径切线方向旋转
/// @param start 路径起点(百分比)
/// @param end 路径终点(百分比)
/// @brief 创建路径行走动画
/// @param duration 持续时长
/// @param path 路径形状
/// @param rotating 是否沿路径切线方向旋转
/// @param start 路径起点(百分比)
/// @param end 路径终点(百分比)
static ActionWalkPtr Create(Duration duration, ShapePtr path, bool rotating = false, float start = 0.f,
float end = 1.f);
ActionWalk();
/// \~chinese
/// @brief 获取路线
/// @brief 获取路线
ShapePtr GetPath() const;
/// \~chinese
/// @brief 是否沿路径切线方向旋转
/// @brief 是否沿路径切线方向旋转
bool IsRotating() const;
/// \~chinese
/// @brief 获取路径起点(百分比)
/// @brief 获取路径起点(百分比)
float GetStartValue() const;
/// \~chinese
/// @brief 获取路径终点(百分比)
/// @brief 获取路径终点(百分比)
float GetEndValue() const;
/// \~chinese
/// @brief 设置路径形状
/// @brief 设置路径形状
void SetPath(ShapePtr path);
/// \~chinese
/// @brief 设置沿路径切线方向旋转
/// @brief 设置沿路径切线方向旋转
void SetRotating(bool rotating);
/// \~chinese
/// @brief 设置路径起点(百分比)
/// @brief 设置路径起点(百分比)
void SetStartValue(float start);
/// \~chinese
/// @brief 设置路径终点(百分比)
/// @brief 设置路径终点(百分比)
void SetEndValue(float end);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
ActionPtr Reverse() const override;
protected:

View File

@ -32,14 +32,14 @@ KGE_DECLARE_SMART_PTR(Animation);
*/
/// \~chinese
/// @brief 帧动画
/// @brief 帧动画
class KGE_API Animation : public ActionTween
{
public:
/// \~chinese
/// @brief 创建帧动画
/// @param duration 动画时长
/// @param[in] frame_seq 序列帧
/// @brief 创建帧动画
/// @param duration 动画时长
/// @param[in] frame_seq 序列帧
static AnimationPtr Create(Duration duration, FrameSequencePtr frame_seq);
Animation();
@ -47,20 +47,20 @@ public:
virtual ~Animation();
/// \~chinese
/// @brief 获取序列帧
/// @brief 获取序列帧
FrameSequencePtr GetFrameSequence() const;
/// \~chinese
/// @brief 设置序列帧
/// @param[in] frame_seq 序列帧
/// @brief 设置序列帧
/// @param[in] frame_seq 序列帧
void SetFrameSequence(FrameSequencePtr frame_seq);
/// \~chinese
/// @brief 获取该动画的拷贝对象
/// @brief 获取该动画的拷贝对象
ActionPtr Clone() const override;
/// \~chinese
/// @brief 获取该动画的倒转
/// @brief 获取该动画的倒转
ActionPtr Reverse() const override;
protected:

View File

@ -29,29 +29,29 @@ namespace memory
{
/// \~chinese
/// @brief 内存分配器
/// @brief 内存分配器
class KGE_API MemoryAllocator
{
public:
/// \~chinese
/// @brief 申请内存
/// @brief 申请内存
virtual void* Alloc(size_t size) = 0;
/// \~chinese
/// @brief 释放内存
/// @brief 释放内存
virtual void Free(void* ptr) = 0;
};
/// \~chinese
/// @brief 获取当前内存分配器
/// @brief 获取当前内存分配器
MemoryAllocator* GetAllocator();
/// \~chinese
/// @brief 设置当前内存分配器
/// @brief 设置当前内存分配器
void SetAllocator(MemoryAllocator* allocator);
/// \~chinese
/// @brief 使用当前内存分配器分配内存
/// @brief 使用当前内存分配器分配内存
template <typename _Ty>
inline void* Alloc()
{
@ -59,14 +59,14 @@ inline void* Alloc()
}
/// \~chinese
/// @brief 使用当前内存分配器释放内存
/// @brief 使用当前内存分配器释放内存
inline void Free(void* ptr)
{
return memory::GetAllocator()->Free(ptr);
}
/// \~chinese
/// @brief 使用当前内存分配器创建对象
/// @brief 使用当前内存分配器创建对象
template <typename _Ty>
inline _Ty* New()
{
@ -79,7 +79,7 @@ inline _Ty* New()
}
/// \~chinese
/// @brief 使用当前内存分配器创建对象
/// @brief 使用当前内存分配器创建对象
template <typename _Ty, typename... _Args>
inline _Ty* New(_Args&&... args)
{
@ -92,7 +92,7 @@ inline _Ty* New(_Args&&... args)
}
/// \~chinese
/// @brief 使用当前内存分配器销毁对象
/// @brief 使用当前内存分配器销毁对象
template <typename _Ty>
inline void Delete(_Ty* ptr)
{
@ -104,21 +104,21 @@ inline void Delete(_Ty* ptr)
}
/// \~chinese
/// @brief 全局内存分配器使用malloc和free分配内存
/// @brief 全局内存分配器使用malloc和free分配内存
class KGE_API GlobalAllocator : public MemoryAllocator
{
public:
/// \~chinese
/// @brief 申请内存
/// @brief 申请内存
virtual void* Alloc(size_t size) override;
/// \~chinese
/// @brief 释放内存
/// @brief 释放内存
virtual void Free(void* ptr) override;
};
/// \~chinese
/// @brief 获取全局内存分配器
/// @brief 获取全局内存分配器
GlobalAllocator* GetGlobalAllocator();
} // namespace memory

View File

@ -27,7 +27,7 @@ namespace kiwano
{
/// \~chinese
/// @brief 可储存单个任意对象的容器
/// @brief 可储存单个任意对象的容器
class Any
{
public:
@ -72,7 +72,7 @@ public:
}
/// \~chinese
/// @brief 获取含有对象类型
/// @brief 获取含有对象类型
inline const type_info& GetType() const noexcept
{
const type_info* const info = GetTypeinfo();
@ -84,14 +84,14 @@ public:
}
/// \~chinese
/// @brief 是否含有对象
/// @brief 是否含有对象
inline bool HasValue() const noexcept
{
return GetTypeinfo() != nullptr;
}
/// \~chinese
/// @brief 从参数构造对象
/// @brief 从参数构造对象
template <typename _Ty, typename... _Args>
void Emplace(_Args&&... args)
{
@ -102,7 +102,7 @@ public:
}
/// \~chinese
/// @brief 交换容器
/// @brief 交换容器
void Swap(Any& rhs) noexcept
{
Any old = std::move(rhs);
@ -111,14 +111,14 @@ public:
}
/// \~chinese
/// @brief 销毁所含对象
/// @brief 销毁所含对象
inline void Clear() noexcept
{
Tidy();
}
/// \~chinese
/// @brief 转换为指定类型的指针
/// @brief 转换为指定类型的指针
template <typename _Ty>
_Ty* CastPtr() noexcept
{
@ -126,7 +126,7 @@ public:
}
/// \~chinese
/// @brief 转换为指定类型的指针
/// @brief 转换为指定类型的指针
template <typename _Ty>
const _Ty* CastPtr() const noexcept
{
@ -148,8 +148,8 @@ public:
}
/// \~chinese
/// @brief 转换为指定类型
/// @throw std::bad_cast 转换失败时抛出
/// @brief 转换为指定类型
/// @throw std::bad_cast 转换失败时抛出
template <typename _Ty>
_Ty Cast()
{
@ -164,8 +164,8 @@ public:
}
/// \~chinese
/// @brief 转换为指定类型
/// @throw std::bad_cast 转换失败时抛出
/// @brief 转换为指定类型
/// @throw std::bad_cast 转换失败时抛出
template <typename _Ty>
_Ty Cast() const
{

View File

@ -39,68 +39,68 @@ namespace kiwano
{
/// \~chinese
/// @brief 输入流
/// @brief 输入流
using InputStream = std::istream;
/// \~chinese
/// @brief 输出流
/// @brief 输出流
using OutputStream = std::ostream;
/// \~chinese
/// @brief 字符串流
/// @brief 字符串流
using StringStream = std::stringstream;
/// \~chinese
/// @brief 宽字符串流
/// @brief 宽字符串流
using WideStringStream = std::wstringstream;
/// \~chinese
/// @brief 线性数组容器
/// @brief 线性数组容器
template <typename _Ty, typename... _Args>
using Vector = std::vector<_Ty, _Args...>;
/// \~chinese
/// @brief 链表容器
/// @brief 链表容器
template <typename _Ty, typename... _Args>
using List = std::list<_Ty, _Args...>;
/// \~chinese
/// @brief 队列容器
/// @brief 队列容器
template <typename _Ty, typename... _Args>
using Queue = std::queue<_Ty, _Args...>;
/// \~chinese
/// @brief 集合容器
/// @brief 集合容器
template <typename _Ty, typename... _Args>
using Set = std::set<_Ty, _Args...>;
/// \~chinese
/// @brief 对容器
/// @brief 对容器
template <typename _Ty1, typename _Ty2>
using Pair = std::pair<_Ty1, _Ty2>;
/// \~chinese
/// @brief 无序集合容器
/// @brief 无序集合容器
template <typename _Ty, typename... _Args>
using UnorderedSet = std::unordered_set<_Ty, _Args...>;
/// \~chinese
/// @brief 栈容器
/// @brief 栈容器
template <typename _Ty, typename... _Args>
using Stack = std::stack<_Ty, _Args...>;
/// \~chinese
/// @brief 字符串容器
/// @brief 字符串容器
template <typename _Kty, typename _Ty, typename... _Args>
using Map = std::map<_Kty, _Ty, _Args...>;
/// \~chinese
/// @brief 字符串容器
/// @brief 字符串容器
template <typename _Kty, typename _Ty, typename... _Args>
using UnorderedMap = std::unordered_map<_Kty, _Ty, _Args...>;
/// \~chinese
/// @brief 不可拷贝对象
/// @brief 不可拷贝对象
class Noncopyable
{
protected:

View File

@ -28,8 +28,8 @@ namespace kiwano
{
/**
* \~chinese
* @brief
* @details
* @brief
* @details
* @see kiwano::Stage
*/
class KGE_API Director
@ -43,51 +43,51 @@ class KGE_API Director
public:
/**
* \~chinese
* @brief
* @param[in] stage
* @param[in] transition
* @brief
* @param[in] stage
* @param[in] transition
*/
void EnterStage(StagePtr stage, TransitionPtr transition = nullptr);
/**
* \~chinese
* @brief
* @param[in] stage
* @param[in] transition
* @brief
* @param[in] stage
* @param[in] transition
*/
void PushStage(StagePtr stage, TransitionPtr transition = nullptr);
/**
* \~chinese
* @brief 退
* @param[in] transition
* @brief 退
* @param[in] transition
*/
void PopStage(TransitionPtr transition = nullptr);
/**
* \~chinese
* @brief
* @return
* @brief
* @return
*/
StagePtr GetCurrentStage();
/**
* \~chinese
* @brief
* @param enabled
* @brief
* @param enabled
*/
void SetRenderBorderEnabled(bool enabled);
/**
* \~chinese
* @brief
* @param show
* @brief
* @param show
*/
void ShowDebugInfo(bool show = true);
/**
* \~chinese
* @brief 退
* @brief 退
*/
void ClearStages();

View File

@ -25,32 +25,32 @@ namespace kiwano
{
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API EventDispatcher
{
public:
/// \~chinese
/// @brief 添加监听器
/// @brief 添加监听器
EventListener* AddListener(EventListenerPtr listener);
/// \~chinese
/// @brief 添加监听器
/// @param type 监听的事件类型
/// @param callback 回调函数
/// @brief 添加监听器
/// @param type 监听的事件类型
/// @param callback 回调函数
EventListener* AddListener(EventType type, EventListener::Callback callback);
/// \~chinese
/// @brief 添加监听器
/// @param name 监听器名称
/// @param type 监听的事件类型
/// @param callback 回调函数
/// @brief 添加监听器
/// @param name 监听器名称
/// @param type 监听的事件类型
/// @param callback 回调函数
EventListener* AddListener(const String& name, EventType type, EventListener::Callback callback);
/// \~chinese
/// @brief 添加监听器
/// @tparam _EventTy 事件类型
/// @param callback 回调函数
/// @brief 添加监听器
/// @tparam _EventTy 事件类型
/// @param callback 回调函数
template <typename _EventTy, typename = typename std::enable_if<IsEvent<_EventTy>::value, int>::type>
EventListener* AddListener(EventListener::Callback callback)
{
@ -58,10 +58,10 @@ public:
}
/// \~chinese
/// @brief 添加监听器
/// @tparam _EventTy 事件类型
/// @param name 监听器名称
/// @param callback 回调函数
/// @brief 添加监听器
/// @tparam _EventTy 事件类型
/// @param name 监听器名称
/// @param callback 回调函数
template <typename _EventTy, typename = typename std::enable_if<IsEvent<_EventTy>::value, int>>
EventListener* AddListener(const String& name, EventListener::Callback callback)
{
@ -69,55 +69,55 @@ public:
}
/// \~chinese
/// @brief 启动监听器
/// @param name 监听器名称
/// @brief 启动监听器
/// @param name 监听器名称
void StartListeners(const String& name);
/// \~chinese
/// @brief 停止监听器
/// @param name 监听器名称
/// @brief 停止监听器
/// @param name 监听器名称
void StopListeners(const String& name);
/// \~chinese
/// @brief 移除监听器
/// @param name 监听器名称
/// @brief 移除监听器
/// @param name 监听器名称
void RemoveListeners(const String& name);
/// \~chinese
/// @brief 启动监听器
/// @param type 监听的事件类型
/// @brief 启动监听器
/// @param type 监听的事件类型
void StartListeners(const EventType& type);
/// \~chinese
/// @brief 停止监听器
/// @param type 监听的事件类型
/// @brief 停止监听器
/// @param type 监听的事件类型
void StopListeners(const EventType& type);
/// \~chinese
/// @brief 移除监听器
/// @param type 监听的事件类型
/// @brief 移除监听器
/// @param type 监听的事件类型
void RemoveListeners(const EventType& type);
/// \~chinese
/// @brief 启动所有监听器
/// @brief 启动所有监听器
void StartAllListeners();
/// \~chinese
/// @brief 停止所有监听器
/// @brief 停止所有监听器
void StopAllListeners();
/// \~chinese
/// @brief 移除所有监听器
/// @brief 移除所有监听器
void RemoveAllListeners();
/// \~chinese
/// @brief 获取所有监听器
/// @brief 获取所有监听器
const ListenerList& GetAllListeners() const;
/// \~chinese
/// @brief 分发事件
/// @param evt 事件
/// @return 是否继续分发该事件
/// @brief 分发事件
/// @param evt 事件
/// @return 是否继续分发该事件
bool DispatchEvent(Event* evt);
private:

View File

@ -35,12 +35,12 @@ class EventDispatcher;
KGE_DECLARE_SMART_PTR(EventListener);
/// \~chinese
/// @brief 监听器列表
/// @brief 监听器列表
typedef IntrusiveList<EventListenerPtr> ListenerList;
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API EventListener
: public ObjectBase
@ -51,26 +51,26 @@ class KGE_API EventListener
public:
/// \~chinese
/// @brief 监听器回调函数
/// @brief 监听器回调函数
using Callback = Function<void(Event*)>;
/// \~chinese
/// @brief 创建监听器
/// @param type 监听的事件类型
/// @param callback 回调函数
/// @brief 创建监听器
/// @param type 监听的事件类型
/// @param callback 回调函数
static EventListenerPtr Create(EventType type, const Callback& callback);
/// \~chinese
/// @brief 创建监听器
/// @param name 监听器名称
/// @param type 监听的事件类型
/// @param callback 回调函数
/// @brief 创建监听器
/// @param name 监听器名称
/// @param type 监听的事件类型
/// @param callback 回调函数
static EventListenerPtr Create(const String& name, EventType type, const Callback& callback);
/// \~chinese
/// @brief 创建监听器
/// @tparam _EventTy 事件类型
/// @param callback 回调函数
/// @brief 创建监听器
/// @tparam _EventTy 事件类型
/// @param callback 回调函数
template <typename _EventTy, typename = typename std::enable_if<IsEvent<_EventTy>::value, int>::type>
static inline EventListenerPtr Create(const Callback& callback)
{
@ -78,10 +78,10 @@ public:
}
/// \~chinese
/// @brief 创建监听器
/// @tparam _EventTy 事件类型
/// @param name 监听器名称
/// @param callback 回调函数
/// @brief 创建监听器
/// @tparam _EventTy 事件类型
/// @param name 监听器名称
/// @param callback 回调函数
template <typename _EventTy, typename = typename std::enable_if<IsEvent<_EventTy>::value, int>::type>
static inline EventListenerPtr Create(const String& name, const Callback& callback)
{
@ -93,53 +93,53 @@ public:
virtual ~EventListener();
/// \~chinese
/// @brief 启动监听器
/// @brief 启动监听器
void Start();
/// \~chinese
/// @brief 停止监听器
/// @brief 停止监听器
void Stop();
/// \~chinese
/// @brief 移除监听器
/// @brief 移除监听器
void Remove();
/// \~chinese
/// @brief 是否正在运行
/// @brief 是否正在运行
bool IsRunning() const;
/// \~chinese
/// @brief 是否可移除
/// @brief 是否可移除
bool IsRemoveable() const;
/// \~chinese
/// @brief 是否开启消息吞没
/// @brief 是否开启消息吞没
bool IsSwallowEnabled() const;
/// \~chinese
/// @brief 设置消息吞没功能
/// @param enabled 是否启用
/// @brief 设置消息吞没功能
/// @param enabled 是否启用
void SetSwallowEnabled(bool enabled);
/// \~chinese
/// @brief 获取回调函数
/// @brief 获取回调函数
const Callback& GetCallback() const;
/// \~chinese
/// @brief 设置回调函数
/// @brief 设置回调函数
void SetCallback(const Callback& cb);
/// \~chinese
/// @brief 获取监听的事件类型
/// @brief 获取监听的事件类型
EventType GetEventType() const;
/// \~chinese
/// @brief 设置监听的事件类型
/// @brief 设置监听的事件类型
void SetEventType(const EventType& type);
/// \~chinese
/// @brief 设置监听的事件类型
/// @tparam _EventTy 事件类型
/// @brief 设置监听的事件类型
/// @tparam _EventTy 事件类型
template <typename _EventTy, typename = typename std::enable_if<IsEvent<_EventTy>::value, int>::type>
inline void SetEventType()
{
@ -147,7 +147,7 @@ public:
}
/// \~chinese
/// @brief 接收消息
/// @brief 接收消息
void Receive(Event* evt);
private:

View File

@ -41,15 +41,15 @@ namespace kiwano
{
/// \~chinese
/// @brief 异常
/// @brief 异常
typedef std::exception Exception;
/// \~chinese
/// @brief 运行时异常
/// @brief 运行时异常
typedef std::runtime_error RuntimeError;
/// \~chinese
/// @brief 系统异常
/// @brief 系统异常
typedef std::system_error SystemError;
class StackTracer

View File

@ -28,7 +28,7 @@ namespace kiwano
{
/// \~chinese
/// @brief 侵入式链表
/// @brief 侵入式链表
template <typename _PtrTy>
class IntrusiveList
{
@ -49,42 +49,42 @@ public:
}
/// \~chinese
/// @brief 获取首元素
/// @brief 获取首元素
const value_type& GetFirst() const
{
return first_;
}
/// \~chinese
/// @brief 获取首元素
/// @brief 获取首元素
value_type& GetFirst()
{
return first_;
}
/// \~chinese
/// @brief 获取尾元素
/// @brief 获取尾元素
const value_type& GetLast() const
{
return last_;
}
/// \~chinese
/// @brief 获取尾元素
/// @brief 获取尾元素
value_type& GetLast()
{
return last_;
}
/// \~chinese
/// @brief 链表是否为空
/// @brief 链表是否为空
inline bool IsEmpty() const
{
return first_ == nullptr;
}
/// \~chinese
/// @brief 在链表尾部添加对象
/// @brief 在链表尾部添加对象
void PushBack(reference child)
{
if (child->prev_)
@ -108,7 +108,7 @@ public:
}
/// \~chinese
/// @brief 在链表头部添加对象
/// @brief 在链表头部添加对象
void PushFront(reference child)
{
if (child->prev_)
@ -132,7 +132,7 @@ public:
}
/// \~chinese
/// @brief 在链表的对象前插入新对象
/// @brief 在链表的对象前插入新对象
void InsertBefore(reference child, reference before)
{
if (child->prev_)
@ -151,7 +151,7 @@ public:
}
/// \~chinese
/// @brief 在链表的对象后插入新对象
/// @brief 在链表的对象后插入新对象
void InsertAfter(reference child, reference after)
{
if (child->prev_)
@ -170,7 +170,7 @@ public:
}
/// \~chinese
/// @brief 移除对象
/// @brief 移除对象
void Remove(reference child)
{
if (child->next_)
@ -196,7 +196,7 @@ public:
}
/// \~chinese
/// @brief 清空所有对象
/// @brief 清空所有对象
void Clear()
{
value_type p = first_;
@ -215,7 +215,7 @@ public:
}
/// \~chinese
/// @brief 检查链表是否有效
/// @brief 检查链表是否有效
bool CheckValid()
{
if (!first_)
@ -429,7 +429,7 @@ private:
/// \~chinese
/// @brief 侵入式链表元素
/// @brief 侵入式链表元素
template <typename _PtrTy>
class IntrusiveListValue
{
@ -456,28 +456,28 @@ public:
}
/// \~chinese
/// @brief 获取前一元素
/// @brief 获取前一元素
const value_type& GetPrev() const
{
return prev_;
}
/// \~chinese
/// @brief 获取前一元素
/// @brief 获取前一元素
value_type& GetPrev()
{
return prev_;
}
/// \~chinese
/// @brief 获取下一元素
/// @brief 获取下一元素
const value_type& GetNext() const
{
return next_;
}
/// \~chinese
/// @brief 获取下一元素
/// @brief 获取下一元素
value_type& GetNext()
{
return next_;

View File

@ -26,7 +26,7 @@ namespace kiwano
{
/// \~chinese
/// @brief JSON对象容器
/// @brief JSON对象容器
using Json = nlohmann::basic_json<Map, Vector, String>;
} // namespace kiwano

View File

@ -24,97 +24,97 @@
namespace kiwano
{
/// \~chinese
/// @brief 鼠标按键
/// @brief 鼠标按键
enum class MouseButton
{
Left, ///< 鼠标左键
Right, ///< 鼠标右键
Middle, ///< 鼠标中键
Left, ///< 鼠标左键
Right, ///< 鼠标右键
Middle, ///< 鼠标中键
Last
};
/// \~chinese
/// @brief 按键键值
/// @brief 按键键值
enum class KeyCode
{
Unknown, ///< 未知
Up, ///< 上键
Left, ///< 左键
Right, ///< 右键
Down, ///< 下键
Enter, ///< 回车键
Space, ///< 空格键
Esc, ///< 退出键
Ctrl, ///< CTRL键
Shift, ///< SHIFT键
Alt, ///< ALT键
Tab, ///< TAB键
Delete, ///< 删除键
Back, ///< 退格键
Super, ///< Cmd|Super|Windows键
Unknown, ///< 未知
Up, ///< 上键
Left, ///< 左键
Right, ///< 右键
Down, ///< 下键
Enter, ///< 回车键
Space, ///< 空格键
Esc, ///< 退出键
Ctrl, ///< CTRL键
Shift, ///< SHIFT键
Alt, ///< ALT键
Tab, ///< TAB键
Delete, ///< 删除键
Back, ///< 退格键
Super, ///< Cmd|Super|Windows键
A, ///< A键
B, ///< B键
C, ///< C键
D, ///< D键
E, ///< E键
F, ///< F键
G, ///< G键
H, ///< H键
I, ///< I键
J, ///< J键
K, ///< K键
L, ///< L键
M, ///< M键
N, ///< N键
O, ///< O键
P, ///< P键
Q, ///< Q键
R, ///< R键
S, ///< S键
T, ///< T键
U, ///< U键
V, ///< V键
W, ///< W键
X, ///< X键
Y, ///< Y键
Z, ///< Z键
A, ///< A键
B, ///< B键
C, ///< C键
D, ///< D键
E, ///< E键
F, ///< F键
G, ///< G键
H, ///< H键
I, ///< I键
J, ///< J键
K, ///< K键
L, ///< L键
M, ///< M键
N, ///< N键
O, ///< O键
P, ///< P键
Q, ///< Q键
R, ///< R键
S, ///< S键
T, ///< T键
U, ///< U键
V, ///< V键
W, ///< W键
X, ///< X键
Y, ///< Y键
Z, ///< Z键
Num0, ///< 数字0键
Num1, ///< 数字1键
Num2, ///< 数字2键
Num3, ///< 数字3键
Num4, ///< 数字4键
Num5, ///< 数字5键
Num6, ///< 数字6键
Num7, ///< 数字7键
Num8, ///< 数字8键
Num9, ///< 数字9键
Num0, ///< 数字0键
Num1, ///< 数字1键
Num2, ///< 数字2键
Num3, ///< 数字3键
Num4, ///< 数字4键
Num5, ///< 数字5键
Num6, ///< 数字6键
Num7, ///< 数字7键
Num8, ///< 数字8键
Num9, ///< 数字9键
Numpad0, ///< 数字小键盘0键
Numpad1, ///< 数字小键盘1键
Numpad2, ///< 数字小键盘2键
Numpad3, ///< 数字小键盘3键
Numpad4, ///< 数字小键盘4键
Numpad5, ///< 数字小键盘5键
Numpad6, ///< 数字小键盘6键
Numpad7, ///< 数字小键盘7键
Numpad8, ///< 数字小键盘8键
Numpad9, ///< 数字小键盘9键
Numpad0, ///< 数字小键盘0键
Numpad1, ///< 数字小键盘1键
Numpad2, ///< 数字小键盘2键
Numpad3, ///< 数字小键盘3键
Numpad4, ///< 数字小键盘4键
Numpad5, ///< 数字小键盘5键
Numpad6, ///< 数字小键盘6键
Numpad7, ///< 数字小键盘7键
Numpad8, ///< 数字小键盘8键
Numpad9, ///< 数字小键盘9键
F1, ///< F1键
F2, ///< F2键
F3, ///< F3键
F4, ///< F4键
F5, ///< F5键
F6, ///< F6键
F7, ///< F7键
F8, ///< F8键
F9, ///< F9键
F10, ///< F10键
F11, ///< F11键
F12, ///< F12键
F1, ///< F1键
F2, ///< F2键
F3, ///< F3键
F4, ///< F4键
F5, ///< F5键
F6, ///< F6键
F7, ///< F7键
F8, ///< F8键
F9, ///< F9键
F10, ///< F10键
F11, ///< F11键
F12, ///< F12键
Last
};

View File

@ -25,43 +25,43 @@ namespace kiwano
{
/**
* \~chinese
* @brief DLL库
* @brief DLL库
*/
class KGE_API Library
{
public:
/// \~chinese
/// @brief 构造DLL库
/// @brief 构造DLL库
Library();
/// \~chinese
/// @brief 构造DLL库
/// @param lib DLL文件路径
/// @brief 构造DLL库
/// @param lib DLL文件路径
Library(const String& lib);
virtual ~Library();
/// \~chinese
/// @brief 加载DLL
/// @param lib DLL文件路径
/// @brief 加载DLL
/// @param lib DLL文件路径
bool Load(const String& lib);
/// \~chinese
/// @brief 是否有效
/// @brief 是否有效
bool IsValid() const;
/// \~chinese
/// @brief 释放DLL
/// @brief 释放DLL
void Free();
/// \~chinese
/// @brief 检索指定的DLL中的输出库函数地址
/// @param proc_name 函数名
/// @brief 检索指定的DLL中的输出库函数地址
/// @param proc_name 函数名
FARPROC GetProcess(const String& proc_name);
/// \~chinese
/// @brief 检索指定的DLL中的输出库函数地址
/// @param proc_name 函数名
/// @brief 检索指定的DLL中的输出库函数地址
/// @param proc_name 函数名
template <typename _Proc>
inline _Proc GetProcess(const String& proc_name)
{

View File

@ -53,7 +53,7 @@ namespace kiwano
{
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Logger : public Singleton<Logger>
{
@ -61,66 +61,66 @@ class KGE_API Logger : public Singleton<Logger>
public:
/// \~chinese
/// @brief 日志级别
/// @brief 日志级别
enum class Level
{
Info, ///< 信息
System, ///< 系统
Warning, ///< 警告
Error ///< 错误
Info, ///< 信息
System, ///< 系统
Warning, ///< 警告
Error ///< 错误
};
/// \~chinese
/// @brief 打印日志
/// @param level 日志级别
/// @param format 格式字符串
/// @brief 打印日志
/// @param level 日志级别
/// @param format 格式字符串
void Printf(Level level, const char* format, ...);
/// \~chinese
/// @brief 打印日志
/// @param level 日志级别
/// @param args 参数
/// @brief 打印日志
/// @param level 日志级别
/// @param args 参数
template <typename... _Args>
void Print(Level level, _Args&&... args);
/// \~chinese
/// @brief 打印一行日志
/// @param level 日志级别
/// @param args 参数
/// @brief 打印一行日志
/// @param level 日志级别
/// @param args 参数
template <typename... _Args>
void Println(Level level, _Args&&... args);
/// \~chinese
/// @brief 显示或关闭控制台
/// @note 此操作会重置输出流
/// @brief 显示或关闭控制台
/// @note 此操作会重置输出流
void ShowConsole(bool show);
/// \~chinese
/// @brief 启用日志
/// @brief 启用日志
void Enable();
/// \~chinese
/// @brief 禁用日志
/// @brief 禁用日志
void Disable();
/// \~chinese
/// @brief 获取输出流
/// @brief 获取输出流
OutputStream& GetOutputStream();
/// \~chinese
/// @brief 获取错误流
/// @brief 获取错误流
OutputStream& GetErrorStream();
/// \~chinese
/// @brief 重定向输出流
/// @brief 重定向输出流
std::streambuf* RedirectOutputStreamBuffer(std::streambuf* buf);
/// \~chinese
/// @brief 重定向错误流
/// @brief 重定向错误流
std::streambuf* RedirectErrorStreamBuffer(std::streambuf* buf);
/// \~chinese
/// @brief 重置输出流
/// @brief 重置输出流
void ResetOutputStream();
private:

View File

@ -31,17 +31,17 @@ struct ModuleFlag;
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Module
{
public:
/// \~chinese
/// @brief 启动模块
/// @brief 启动模块
virtual void SetupModule() {}
/// \~chinese
/// @brief 销毁模块
/// @brief 销毁模块
virtual void DestroyModule() {}
template <typename _CompTy>
@ -61,22 +61,22 @@ protected:
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API RenderModule : public virtual Module
{
public:
/// \~chinese
/// @brief 渲染前
/// @brief 渲染前
virtual void BeforeRender() {}
/// \~chinese
/// @brief 渲染时
/// @param ctx 渲染上下文
/// @brief 渲染时
/// @param ctx 渲染上下文
virtual void OnRender(RenderContext& ctx) {}
/// \~chinese
/// @brief 渲染后
/// @brief 渲染后
virtual void AfterRender() {}
public:
@ -85,22 +85,22 @@ public:
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API UpdateModule : public virtual Module
{
public:
/// \~chinese
/// @brief 更新前
/// @brief 更新前
virtual void BeforeUpdate() {}
/// \~chinese
/// @brief 更新时
/// @param dt 间隔时间
/// @brief 更新时
/// @param dt 间隔时间
virtual void OnUpdate(Duration dt) {}
/// \~chinese
/// @brief 更新后
/// @brief 更新后
virtual void AfterUpdate() {}
public:
@ -109,14 +109,14 @@ public:
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API EventModule : public virtual Module
{
public:
/// \~chinese
/// @brief 事件处理
/// @param evt 事件
/// @brief 事件处理
/// @param evt 事件
virtual void HandleEvent(Event* evt) {}
public:

View File

@ -30,65 +30,65 @@ KGE_DECLARE_SMART_PTR(ObjectBase);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API ObjectBase : public RefCounter
{
public:
/// \~chinese
/// @brief 构造基础对象
/// @brief 构造基础对象
ObjectBase();
virtual ~ObjectBase();
/// \~chinese
/// @brief 设置对象名
/// @brief 设置对象名
void SetName(const String& name);
/// \~chinese
/// @brief 获取对象名
/// @brief 获取对象名
String GetName() const;
/// \~chinese
/// @brief 判断对象的名称是否相同
/// @param name 需要判断的名称
/// @brief 判断对象的名称是否相同
/// @param name 需要判断的名称
bool IsName(const String& name) const;
/// \~chinese
/// @brief 获取用户数据
/// @brief 获取用户数据
const Any& GetUserData() const;
/// \~chinese
/// @brief 设置用户数据
/// @brief 设置用户数据
void SetUserData(const Any& data);
/// \~chinese
/// @brief 获取对象ID
/// @brief 获取对象ID
uint32_t GetObjectID() const;
/// \~chinese
/// @brief 序列化对象
/// @brief 序列化对象
String DumpObject();
public:
/// \~chinese
/// @brief 是否启用了内存泄漏追踪
/// @brief 是否启用了内存泄漏追踪
static bool IsTracingLeaks();
/// \~chinese
/// @brief 开始追踪内存泄漏
/// @brief 开始追踪内存泄漏
static void StartTracingLeaks();
/// \~chinese
/// @brief 停止追踪内存泄漏
/// @brief 停止追踪内存泄漏
static void StopTracingLeaks();
/// \~chinese
/// @brief 打印所有追踪中的对象信息
/// @brief 打印所有追踪中的对象信息
static void DumpTracingObjects();
/// \~chinese
/// @brief 获取所有追踪中的对象
/// @brief 获取所有追踪中的对象
static Vector<ObjectBase*>& GetTracingObjects();
private:

View File

@ -26,7 +26,7 @@ namespace kiwano
{
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API RefCounter : protected Noncopyable
{
@ -36,15 +36,15 @@ public:
virtual ~RefCounter();
/// \~chinese
/// @brief 增加引用计数
/// @brief 增加引用计数
void Retain();
/// \~chinese
/// @brief 减少引用计数
/// @brief 减少引用计数
void Release();
/// \~chinese
/// @brief 获取引用计数
/// @brief 获取引用计数
uint32_t GetRefCount() const;
private:

View File

@ -26,26 +26,26 @@ namespace kiwano
{
/**
* \~chinese
* @brief
* @brief
* @details
* exe
* "WAVE"
* IDR_WAVE_1:
* exe
* "WAVE"
* IDR_WAVE_1:
* @code
* Resource(IDR_WAVE_1, "WAVE");
* @endcode
* :
* :
* https://docs.microsoft.com/en-us/windows/desktop/menurc/resources
*/
class KGE_API Resource
{
public:
/// \~chinese
/// @brief 资源的二进制数据
/// @brief 资源的二进制数据
struct Data
{
void* buffer; ///< 资源数据
uint32_t size; ///< 资源数据大小
void* buffer; ///< 资源数据
uint32_t size; ///< 资源数据大小
Data();
@ -53,26 +53,26 @@ public:
};
/// \~chinese
/// @brief 构造资源
/// @brief 构造资源
Resource();
/// \~chinese
/// @brief 构造资源
/// @param id 资源 ID
/// @param type 资源类型
/// @brief 构造资源
/// @param id 资源 ID
/// @param type 资源类型
Resource(uint32_t id, const wchar_t* type);
/// \~chinese
/// @brief 获取资源的二进制数据
/// @return 资源数据
/// @brief 获取资源的二进制数据
/// @return 资源数据
Resource::Data GetData() const;
/// \~chinese
/// @brief 获取资源 ID
/// @brief 获取资源 ID
uint32_t GetId() const;
/// \~chinese
/// @brief 获取资源类型
/// @brief 获取资源类型
const wchar_t* GetType() const;
private:

View File

@ -29,7 +29,7 @@ namespace kiwano
/**
* \~chinese
* @brief
* @brief
*/
struct DefaultSmartPtrRefProxy
{
@ -48,7 +48,7 @@ struct DefaultSmartPtrRefProxy
/**
* \~chinese
* @brief
* @brief
*/
template <typename _Ty, typename _ProxyTy = DefaultSmartPtrRefProxy>
class SmartPtr

View File

@ -29,11 +29,6 @@ namespace strings
#if defined(KGE_PLATFORM_WINDOWS)
//
// This 中文 comment will enable utf-8 encoding in Visual Studio
// Otherwise 'CP_UTF8' cannot work
//
String Format(const char* format, ...)
{
String result;
@ -53,18 +48,37 @@ String Format(const char* format, ...)
return result;
}
WideString Format(const wchar_t* format, ...)
{
WideString result;
if (format)
{
va_list args = nullptr;
va_start(args, format);
const auto len = static_cast<size_t>(::_vscwprintf(format, args) + 1);
if (len)
{
result.resize(len);
::_vsnwprintf_s(&result[0], len, len, format, args);
}
va_end(args);
}
return result;
}
String ToNarrow(const WideString& str)
{
if (str.empty())
return String();
int chars_num = ::WideCharToMultiByte(CP_UTF8, 0, str.c_str(), -1, NULL, 0, NULL, NULL);
int chars_num = ::WideCharToMultiByte(CP_ACP, 0, str.c_str(), -1, NULL, 0, NULL, NULL);
if (chars_num)
{
String result;
result.resize(chars_num);
::WideCharToMultiByte(CP_UTF8, 0, str.c_str(), -1, &result[0], chars_num, NULL, NULL);
::WideCharToMultiByte(CP_ACP, 0, str.c_str(), -1, &result[0], chars_num, NULL, NULL);
return result;
}
return String();
@ -75,13 +89,13 @@ WideString ToWide(const String& str)
if (str.empty())
return WideString();
int chars_num = ::MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0);
int chars_num = ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0);
if (chars_num)
{
WideString result;
result.resize(chars_num);
::MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, &result[0], chars_num);
::MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, &result[0], chars_num);
return result;
}
return WideString();

View File

@ -25,26 +25,30 @@ namespace kiwano
{
/// \~chinese
/// @brief 字符串容器
/// @brief 字符串容器
using String = std::string;
/// \~chinese
/// @brief 宽字符串容器
/// @brief 宽字符串容器
using WideString = std::wstring;
namespace strings
{
/// \~chinese
/// @brief 格式化字符串
/// @brief 格式化字符串
String Format(const char* format, ...);
/// \~chinese
/// @brief 宽字符串转窄字符串
/// @brief 格式化字符串
WideString Format(const wchar_t* format, ...);
/// \~chinese
/// @brief 宽字符串转窄字符串
String ToNarrow(const WideString& str);
/// \~chinese
/// @brief 窄字符串转宽字符串
/// @brief 窄字符串转宽字符串
WideString ToWide(const String& str);
}

View File

@ -366,7 +366,7 @@ Duration Duration::Parse(const String& format)
return ret;
}
// 符号位
// 符号位
if (format[0] == '-' || format[0] == '+')
{
negative = (format[0] == '-');
@ -375,7 +375,7 @@ Duration Duration::Parse(const String& format)
while (pos < len)
{
// 数值
// 数值
size_t i = pos;
for (; i < len; ++i)
{
@ -393,7 +393,7 @@ Duration Duration::Parse(const String& format)
if (num_str.empty() || num_str == ".")
KGE_THROW("Duration::Parse failed, invalid duration");
// 单位
// 单位
for (; i < len; ++i)
{
wchar_t ch = format[i];

View File

@ -25,94 +25,94 @@ namespace kiwano
{
/**
* \~chinese
* @brief
* @brief
* @par
* :
* :
* @code
* time::Second * 5 // 5 秒
* time::Hour * 1.5 // 1.5 小时
* time::Hour * 3 + time::Minute * 45 + time::Second * 15 // 3 小时 45 分 15
*
* time::Second * 5 // 5 秒
* time::Hour * 1.5 // 1.5 小时
* time::Hour * 3 + time::Minute * 45 + time::Second * 15 // 3 小时 45 分 15
*
* @endcode
* VS2015 使 time literals:
* VS2015 使 time literals:
* @code
* using namespace kiwano;
* 5_sec // 5 秒
* 1.5_hour // 1.5 小时
* 3_hour + 45_min + 15_sec // 3 小时 45 分 15 秒
* 5_sec // 5 秒
* 1.5_hour // 1.5 小时
* 3_hour + 45_min + 15_sec // 3 小时 45 分 15 秒
* @endcode
*/
struct KGE_API Duration
{
/// \~chinese
/// @brief 构造时间段
/// @brief 构造时间段
Duration();
/// \~chinese
/// @brief 构造时间段
/// @param milliseconds 毫秒数
/// @brief 构造时间段
/// @param milliseconds 毫秒数
Duration(long milliseconds);
/// \~chinese
/// @brief 获取毫秒数
/// @brief 获取毫秒数
long Milliseconds() const;
/// \~chinese
/// @brief 获取秒数
/// @brief 获取秒数
float Seconds() const;
/// \~chinese
/// @brief 获取分钟数
/// @brief 获取分钟数
float Minutes() const;
/// \~chinese
/// @brief 获取小时数
/// @brief 获取小时数
float Hours() const;
/// \~chinese
/// @brief 时长是否是零
/// @return 若时长是零返回true
/// @brief 时长是否是零
/// @return 若时长是零返回true
bool IsZero() const;
/// \~chinese
/// @brief 设置毫秒数
/// @param ms 毫秒数
/// @brief 设置毫秒数
/// @param ms 毫秒数
void SetMilliseconds(long ms);
/// \~chinese
/// @brief 设置秒数
/// @param seconds 秒数
/// @brief 设置秒数
/// @param seconds 秒数
void SetSeconds(float seconds);
/// \~chinese
/// @brief 设置分钟数
/// @param minutes 分钟数
/// @brief 设置分钟数
/// @param minutes 分钟数
void SetMinutes(float minutes);
/// \~chinese
/// @brief 设置小时数
/// @param hours 小时数
/// @brief 设置小时数
/// @param hours 小时数
void SetHours(float hours);
/// \~chinese
/// @brief 转为字符串
/// @brief 转为字符串
String ToString() const;
/// \~chinese
/// @brief 解析时间段字符串
/// @param str 时间段字符串
/// @brief 解析时间段字符串
/// @param str 时间段字符串
/// @details
/// 时间段字符串允许是有符号的浮点数, 并且带有时间单位后缀
/// 例如: "300ms", "-1.5h", "2h45m"
/// 允许的时间单位有 "ms", "s", "m", "h"
/// @return 解析出的时间段
/// @throw kiwano::RuntimeError 传入一个不合法的格式时抛出
/// 时间段字符串允许是有符号的浮点数, 并且带有时间单位后缀
/// 例如: "300ms", "-1.5h", "2h45m"
/// 允许的时间单位有 "ms", "s", "m", "h"
/// @return 解析出的时间段
/// @throw kiwano::RuntimeError 传入一个不合法的格式时抛出
static Duration Parse(const String& str);
static const Duration Ms; ///< 毫秒
static const Duration Second; ///< 秒
static const Duration Minute; ///< 分钟
static const Duration Hour; ///< 小时
static const Duration Ms; ///< 毫秒
static const Duration Second; ///< 秒
static const Duration Minute; ///< 分钟
static const Duration Hour; ///< 小时
bool operator==(const Duration&) const;
bool operator!=(const Duration&) const;
@ -158,28 +158,28 @@ private:
/**
* \~chinese
* @brief
* @par
* @brief
* @par
* @code
* // 两时间相减, 可得到一个 Duration 对象
* // 两时间相减, 可得到一个 Duration 对象
* Time t1 = Time::Now();
* // 等待一段时间后
* // 等待一段时间后
* Time t2 = Time::Now();
* int ms = (t2 - t1).Milliseconds(); // 获取两时间相差的毫秒数
* int ms = (t2 - t1).Milliseconds(); // 获取两时间相差的毫秒数
* @endcode
* @note
* @note
*/
struct KGE_API Time
{
Time();
/// \~chinese
/// @brief 是否是零时
/// @return 若是零时返回true
/// @brief 是否是零时
/// @return 若是零时返回true
bool IsZero() const;
/// \~chinese
/// @brief 获取当前时间
/// @brief 获取当前时间
static Time Now() noexcept;
const Duration operator-(const Time&) const;

View File

@ -30,12 +30,12 @@ class TimerManager;
KGE_DECLARE_SMART_PTR(Timer);
/// \~chinese
/// @brief 定时器列表
/// @brief 定时器列表
typedef IntrusiveList<TimerPtr> TimerList;
/// \~chinese
/// @brief 定时器
/// @details 定时器用于每隔一段时间执行一次回调函数,且可以指定执行总次数
/// @brief 定时器
/// @details 定时器用于每隔一段时间执行一次回调函数,且可以指定执行总次数
class KGE_API Timer
: public ObjectBase
, protected IntrusiveListValue<TimerPtr>
@ -45,85 +45,85 @@ class KGE_API Timer
public:
/// \~chinese
/// @brief 定时器回调函数
/// @brief 定时器回调函数
/// @details
/// 回调函数第一个参数是定时器自身,第二个参数是距离上次更新的时间间隔
/// 回调函数第一个参数是定时器自身,第二个参数是距离上次更新的时间间隔
using Callback = Function<void(Timer* /* self */, Duration /* dt */)>;
/// \~chinese
/// @brief 创建定时器
/// @param cb 回调函数
/// @param interval 时间间隔
/// @param times 执行次数(设 -1 为永久执行)
/// @brief 创建定时器
/// @param cb 回调函数
/// @param interval 时间间隔
/// @param times 执行次数(设 -1 为永久执行)
static TimerPtr Create(const Callback& cb, Duration interval, int times = -1);
/// \~chinese
/// @brief 创建定时器
/// @param name 名称
/// @param cb 回调函数
/// @param interval 时间间隔
/// @param times 执行次数(设 -1 为永久执行)
/// @brief 创建定时器
/// @param name 名称
/// @param cb 回调函数
/// @param interval 时间间隔
/// @param times 执行次数(设 -1 为永久执行)
static TimerPtr Create(const String& name, const Callback& cb, Duration interval, int times = -1);
/// \~chinese
/// @brief 构造空定时器
/// @brief 构造空定时器
Timer();
/// \~chinese
/// @brief 启动定时器
/// @brief 启动定时器
void Start();
/// \~chinese
/// @brief 停止定时器
/// @brief 停止定时器
void Stop();
/// \~chinese
/// @brief 移除定时器
/// @brief 移除定时器
void Remove();
/// \~chinese
/// @brief 定时器是否在运行
/// @brief 定时器是否在运行
bool IsRunning() const;
/// \~chinese
/// @brief 定时器是否可移除
/// @brief 定时器是否可移除
bool IsRemoveable() const;
/// \~chinese
/// @brief 获取定时器执行过回调函数的次数
/// @brief 获取定时器执行过回调函数的次数
int GetRunTimes() const;
/// \~chinese
/// @brief 获取定时器执行回调函数的总次数
/// @brief 获取定时器执行回调函数的总次数
int GetTotalRunTimes() const;
/// \~chinese
/// @brief 设置定时器执行回调函数的总次数
/// @brief 设置定时器执行回调函数的总次数
void SetTotalRunTimes(int times);
/// \~chinese
/// @brief 获取定时器执行时间间隔
/// @brief 获取定时器执行时间间隔
Duration GetInterval() const;
/// \~chinese
/// @brief 设置定时器执行时间间隔
/// @brief 设置定时器执行时间间隔
void SetInterval(Duration interval);
/// \~chinese
/// @brief 获取定时器回调函数
/// @brief 获取定时器回调函数
Callback GetCallback() const;
/// \~chinese
/// @brief 设置定时器回调函数
/// @brief 设置定时器回调函数
void SetCallback(const Callback& callback);
private:
/// \~chinese
/// @brief 更新定时器
/// @brief 更新定时器
void Update(Duration dt);
/// \~chinese
/// @brief 重置定时器
/// @brief 重置定时器
void Reset();
private:

View File

@ -25,61 +25,61 @@ namespace kiwano
{
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API TimerManager
{
public:
/// \~chinese
/// @brief 添加定时器
/// @param cb 回调函数
/// @param interval 时间间隔
/// @param times 执行次数(设 -1 为永久执行)
/// @brief 添加定时器
/// @param cb 回调函数
/// @param interval 时间间隔
/// @param times 执行次数(设 -1 为永久执行)
Timer* AddTimer(const Timer::Callback& cb, Duration interval, int times = -1);
/// \~chinese
/// @brief 添加定时器
/// @param name 定时器名称
/// @param cb 回调函数
/// @param interval 时间间隔
/// @param times 执行次数(设 -1 为永久执行)
/// @brief 添加定时器
/// @param name 定时器名称
/// @param cb 回调函数
/// @param interval 时间间隔
/// @param times 执行次数(设 -1 为永久执行)
Timer* AddTimer(const String& name, const Timer::Callback& cb, Duration interval, int times = -1);
/// \~chinese
/// @brief 添加定时器
/// @brief 添加定时器
Timer* AddTimer(TimerPtr timer);
/// \~chinese
/// @brief 启动定时器
/// @brief 启动定时器
void StartTimers(const String& timer_name);
/// \~chinese
/// @brief 停止定时器
/// @brief 停止定时器
void StopTimers(const String& timer_name);
/// \~chinese
/// @brief 移除定时器
/// @brief 移除定时器
void RemoveTimers(const String& timer_name);
/// \~chinese
/// @brief 启动所有定时器
/// @brief 启动所有定时器
void StartAllTimers();
/// \~chinese
/// @brief 停止所有定时器
/// @brief 停止所有定时器
void StopAllTimers();
/// \~chinese
/// @brief 移除所有定时器
/// @brief 移除所有定时器
void RemoveAllTimers();
/// \~chinese
/// @brief 获取所有定时器
/// @brief 获取所有定时器
const TimerList& GetAllTimers() const;
protected:
/// \~chinese
/// @brief 更新定时器
/// @brief 更新定时器
void UpdateTimers(Duration dt);
private:

View File

@ -26,11 +26,11 @@ namespace kiwano
{
/// \~chinese
/// @brief XML文档
/// @brief XML文档
using XmlDocument = pugi::xml_document;
/// \~chinese
/// @brief XML文档
/// @brief XML文档
using XmlNode = pugi::xml_node;
} // namespace kiwano

View File

@ -29,7 +29,7 @@ KGE_DECLARE_SMART_PTR(Event);
/**
* \~chinese
* \defgroup Events
* \defgroup Events
*/
/**
@ -38,35 +38,35 @@ KGE_DECLARE_SMART_PTR(Event);
*/
/// \~chinese
/// @brief 事件
/// @brief 事件
class KGE_API Event : public RefCounter
{
public:
/// \~chinese
/// @brief 构造事件
/// @brief 构造事件
Event(const EventType& type);
virtual ~Event();
/// \~chinese
/// @brief 获取类型事件
/// @brief 获取类型事件
const EventType& GetType() const;
/// \~chinese
/// @brief 判断事件类型
/// @return 是否是指定事件类型
/// @brief 判断事件类型
/// @return 是否是指定事件类型
template <typename _Ty, typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type>
bool IsType() const;
/// \~chinese
/// @brief 安全转换为其他类型事件
/// @throw std::bad_cast 类型无法转换时抛出
/// @brief 安全转换为其他类型事件
/// @throw std::bad_cast 类型无法转换时抛出
template <typename _Ty, typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type>
const _Ty* SafeCast() const;
/// \~chinese
/// @brief 安全转换为其他类型事件
/// @throw std::bad_cast 类型无法转换时抛出
/// @brief 安全转换为其他类型事件
/// @throw std::bad_cast 类型无法转换时抛出
template <typename _Ty, typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type>
_Ty* SafeCast();
@ -75,14 +75,14 @@ private:
};
/// \~chinese
/// @brief 事件特性:判断指定类型是否是事件
/// @brief 事件特性:判断指定类型是否是事件
template <typename _Ty>
struct IsEvent : public std::bool_constant<std::is_base_of<Event, _Ty>::value || std::is_same<Event, _Ty>::value>
{
};
/// \~chinese
/// @brief 事件特性:判断一个事件能否安全转换到另一事件类型
/// @brief 事件特性:判断一个事件能否安全转换到另一事件类型
template <typename _Ty, typename = typename std::enable_if<IsEvent<_Ty>::value, int>::type>
struct IsEventType
{

View File

@ -31,7 +31,7 @@ namespace kiwano
*/
/// \~chinese
/// @brief 事件类型
/// @brief 事件类型
class EventType : public std::type_index
{
class Dummy
@ -40,7 +40,7 @@ class EventType : public std::type_index
public:
/// \~chinese
/// @brief 构建事件类型
/// @brief 构建事件类型
EventType();
using std::type_index::type_index;

View File

@ -35,7 +35,7 @@ KGE_DECLARE_SMART_PTR(KeyCharEvent);
*/
/// \~chinese
/// @brief 键盘事件
/// @brief 键盘事件
class KGE_API KeyEvent : public Event
{
public:
@ -43,31 +43,31 @@ public:
};
/// \~chinese
/// @brief 键盘按下事件
/// @brief 键盘按下事件
class KGE_API KeyDownEvent : public KeyEvent
{
public:
KeyCode code; ///< 键值
KeyCode code; ///< 键值
KeyDownEvent();
};
/// \~chinese
/// @brief 键盘抬起事件
/// @brief 键盘抬起事件
class KGE_API KeyUpEvent : public KeyEvent
{
public:
KeyCode code; ///< 键值
KeyCode code; ///< 键值
KeyUpEvent();
};
/// \~chinese
/// @brief 键盘字符事件
/// @brief 键盘字符事件
class KGE_API KeyCharEvent : public KeyEvent
{
public:
char value; ///< 字符
char value; ///< 字符
KeyCharEvent();
};

View File

@ -40,17 +40,17 @@ KGE_DECLARE_SMART_PTR(MouseWheelEvent);
*/
/// \~chinese
/// @brief 鼠标事件
/// @brief 鼠标事件
class KGE_API MouseEvent : public Event
{
public:
Point pos; ///< 鼠标位置
Point pos; ///< 鼠标位置
MouseEvent(const EventType& type);
};
/// \~chinese
/// @brief 鼠标移动事件
/// @brief 鼠标移动事件
class KGE_API MouseMoveEvent : public MouseEvent
{
public:
@ -58,37 +58,37 @@ public:
};
/// \~chinese
/// @brief 鼠标按键按下事件
/// @brief 鼠标按键按下事件
class KGE_API MouseDownEvent : public MouseEvent
{
public:
MouseButton button; ///< 鼠标键值
MouseButton button; ///< 鼠标键值
MouseDownEvent();
};
/// \~chinese
/// @brief 鼠标按键抬起事件
/// @brief 鼠标按键抬起事件
class KGE_API MouseUpEvent : public MouseEvent
{
public:
MouseButton button; ///< 鼠标键值
MouseButton button; ///< 鼠标键值
MouseUpEvent();
};
/// \~chinese
/// @brief 鼠标点击事件
/// @brief 鼠标点击事件
class KGE_API MouseClickEvent : public MouseEvent
{
public:
MouseButton button; ///< 鼠标键值
MouseButton button; ///< 鼠标键值
MouseClickEvent();
};
/// \~chinese
/// @brief 鼠标移入事件
/// @brief 鼠标移入事件
class KGE_API MouseHoverEvent : public MouseEvent
{
public:
@ -96,7 +96,7 @@ public:
};
/// \~chinese
/// @brief 鼠标移出事件
/// @brief 鼠标移出事件
class KGE_API MouseOutEvent : public MouseEvent
{
public:
@ -104,11 +104,11 @@ public:
};
/// \~chinese
/// @brief 鼠标滚轮事件
/// @brief 鼠标滚轮事件
class KGE_API MouseWheelEvent : public MouseEvent
{
public:
float wheel; ///< 滚轮值
float wheel; ///< 滚轮值
MouseWheelEvent();
};

View File

@ -36,7 +36,7 @@ KGE_DECLARE_SMART_PTR(WindowClosedEvent);
*/
/// \~chinese
/// @brief 窗口事件
/// @brief 窗口事件
class KGE_API WindowEvent : public Event
{
public:
@ -44,49 +44,49 @@ public:
};
/// \~chinese
/// @brief 窗口移动事件
/// @brief 窗口移动事件
class KGE_API WindowMovedEvent : public WindowEvent
{
public:
int x; ///< 窗口左上角 x 坐标
int y; ///< 窗口左上角 y 坐标
int x; ///< 窗口左上角 x 坐标
int y; ///< 窗口左上角 y 坐标
WindowMovedEvent();
};
/// \~chinese
/// @brief 窗口大小变化事件
/// @brief 窗口大小变化事件
class KGE_API WindowResizedEvent : public WindowEvent
{
public:
uint32_t width; ///< 窗口宽度
uint32_t height; ///< 窗口高度
uint32_t width; ///< 窗口宽度
uint32_t height; ///< 窗口高度
WindowResizedEvent();
};
/// \~chinese
/// @brief 窗口焦点变化事件
/// @brief 窗口焦点变化事件
class KGE_API WindowFocusChangedEvent : public WindowEvent
{
public:
bool focus; ///< 是否获取到焦点
bool focus; ///< 是否获取到焦点
WindowFocusChangedEvent();
};
/// \~chinese
/// @brief 窗口标题更改事件
/// @brief 窗口标题更改事件
class KGE_API WindowTitleChangedEvent : public WindowEvent
{
public:
String title; ///< 标题
String title; ///< 标题
WindowTitleChangedEvent();
};
/// \~chinese
/// @brief 窗口关闭事件
/// @brief 窗口关闭事件
class KGE_API WindowClosedEvent : public WindowEvent
{
public:

View File

@ -26,11 +26,11 @@ namespace kiwano
namespace math
{
//
// 随机数
// 随机数
//
// 获取指定范围内的一个随机数, 如:
// int n = math::Random(1, 5); // 获取 1~5 内的随机整数, 包含 1 和 5
// 产生的随机数类型取决于参数的类型, 如获取随机浮点数:
// 获取指定范围内的一个随机数, 如:
// int n = math::Random(1, 5); // 获取 1~5 内的随机整数, 包含 1 和 5
// 产生的随机数类型取决于参数的类型, 如获取随机浮点数:
// float d = math::Random(1.2f, 1.5f);
//

View File

@ -29,7 +29,7 @@ namespace math
/**
* \~chinese
* @brief
* @brief
*/
template <typename _Ty>
class TransformT
@ -37,16 +37,16 @@ class TransformT
public:
using ValueType = _Ty;
float rotation; ///< 旋转
Vec2T<ValueType> position; ///< 坐标
Vec2T<ValueType> scale; ///< 缩放
Vec2T<ValueType> skew; ///< 错切角度
float rotation; ///< 旋转
Vec2T<ValueType> position; ///< 坐标
Vec2T<ValueType> scale; ///< 缩放
Vec2T<ValueType> skew; ///< 错切角度
public:
TransformT();
/// \~chinese
/// @brief 将二维放射变换转换为矩阵
/// @brief 将二维放射变换转换为矩阵
Matrix3x2T<ValueType> ToMatrix() const;
bool operator==(const TransformT& rhs) const;

View File

@ -32,7 +32,7 @@ namespace kiwano
{
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Application : public Singleton<Application>
{
@ -45,85 +45,85 @@ public:
/**
* \~chinese
* @brief
* @param runner
* @param debug
* @note
* @brief
* @param runner
* @param debug
* @note
*/
void Run(RunnerPtr runner, bool debug = false);
/**
* \~chinese
* @brief
* @brief
*/
void Quit();
/**
* \~chinese
* @brief
* @brief
*/
RunnerPtr GetRunner() const;
/**
* \~chinese
* @brief
* @brief
*/
WindowPtr GetMainWindow() const;
/**
* \~chinese
* @brief
* @brief
*/
int GetVersion() const;
/**
* \~chinese
* @brief
* @param[in] module
* @brief
* @param[in] module
*/
void Use(Module& module);
/**
* \~chinese
* @brief
* @details
* @param scale_factor
* @warning
* @brief
* @details
* @param scale_factor
* @warning
*/
void SetTimeScale(float scale_factor);
/**
* \~chinese
* @brief
* @details
* @param evt
* @brief
* @details
* @param evt
*/
void DispatchEvent(Event* evt);
/**
* \~chinese
* @brief 线
* @details 线 Kiwano
* @param func
* @brief 线
* @details 线 Kiwano
* @param func
*/
void PreformInMainThread(Function<void()> func);
/**
* \~chinese
* @brief
* @param dt
* @brief
* @param dt
*/
void Update(Duration dt);
/**
* \~chinese
* @brief
* @brief
*/
void Render();
/**
* \~chinese
* @brief
* @brief
*/
void Destroy();

View File

@ -25,7 +25,7 @@ namespace kiwano
{
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API FileSystem : public Singleton<FileSystem>
{
@ -34,71 +34,71 @@ class KGE_API FileSystem : public Singleton<FileSystem>
public:
/**
* \~chinese
* @brief
* @param path
* @brief
* @param path
*/
void AddSearchPath(const String& path);
/**
* \~chinese
* @brief
* @param paths
* @brief
* @param paths
*/
void SetSearchPaths(const Vector<String>& paths);
/**
* \~chinese
* @brief
* @param file
* @return
* @brief
* @param file
* @return
*/
String GetFullPathForFile(const String& file) const;
/**
* \~chinese
* @brief
* @param key
* @param file_path
* @brief
* @param key
* @param file_path
*/
void AddFileLookupRule(const String& key, const String& file_path);
/**
* \~chinese
* @brief
* @param dict
* @brief
* @param dict
*/
void SetFileLookupDictionary(const UnorderedMap<String, String>& dict);
/**
* \~chinese
* @brief
* @param file_path
* @return true
* @brief
* @param file_path
* @return true
*/
bool IsFileExists(const String& file_path) const;
/**
* \~chinese
* @brief
* @param path
* @return true
* @brief
* @param path
* @return true
*/
bool IsAbsolutePath(const String& path) const;
/**
* \~chinese
* @brief
* @param file_path
* @return
* @brief
* @param file_path
* @return
*/
bool RemoveFile(const String& file_path) const;
/**
* \~chinese
* @brief
* @param res
* @param dest_file_name
* @return
* @brief
* @param res
* @param dest_file_name
* @return
*/
bool ExtractResourceToFile(const Resource& res, const String& dest_file_name) const;

View File

@ -31,7 +31,7 @@ namespace kiwano
{
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Input
: public Singleton<Input>
@ -43,63 +43,63 @@ class KGE_API Input
public:
/**
* \~chinese
* @brief
* @param key
* @brief
* @param key
*/
bool IsDown(KeyCode key) const;
/**
* \~chinese
* @brief
* @param key
* @brief
* @param key
*/
bool WasPressed(KeyCode key) const;
/**
* \~chinese
* @brief
* @param key
* @brief
* @param key
*/
bool WasReleased(KeyCode key) const;
/**
* \~chinese
* @brief
* @param btn
* @brief
* @param btn
*/
bool IsDown(MouseButton btn) const;
/**
* \~chinese
* @brief
* @param btn
* @brief
* @param btn
*/
bool WasPressed(MouseButton btn) const;
/**
* \~chinese
* @brief
* @param btn
* @brief
* @param btn
*/
bool WasReleased(MouseButton btn) const;
/**
* \~chinese
* @brief x
* @return x
* @brief x
* @return x
*/
float GetMouseX() const;
/**
* \~chinese
* @brief y
* @return y
* @brief y
* @return y
*/
float GetMouseY() const;
/**
* \~chinese
* @brief
* @return
* @brief
* @return
*/
Point GetMousePos() const;

View File

@ -32,7 +32,7 @@ KGE_DECLARE_SMART_PTR(Runner);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Runner : public ObjectBase
{
@ -40,15 +40,15 @@ class KGE_API Runner : public ObjectBase
public:
/// \~chinese
/// @brief 创建程序运行器
/// @param main_window 主窗口
/// @brief 创建程序运行器
/// @param main_window 主窗口
static RunnerPtr Create(WindowPtr main_window);
/// \~chinese
/// @brief 创建程序运行器
/// @param main_window 主窗口
/// @param on_ready 应用程序初始化完成后执行的回调函数
/// @param on_destroy 应用程序销毁时执行的回调函数
/// @brief 创建程序运行器
/// @param main_window 主窗口
/// @param on_ready 应用程序初始化完成后执行的回调函数
/// @param on_destroy 应用程序销毁时执行的回调函数
static RunnerPtr Create(WindowPtr main_window, Function<void()> on_ready, Function<void()> on_destroy = nullptr);
Runner();
@ -56,37 +56,37 @@ public:
virtual ~Runner();
/// \~chinese
/// @brief 初始化完成处理
/// @details 重载该函数以在应用程序初始化完成后自动执行
/// @brief 初始化完成处理
/// @details 重载该函数以在应用程序初始化完成后自动执行
virtual void OnReady();
/// \~chinese
/// @brief 应用程序销毁处理
/// @details 重载该函数以处理应用程序销毁时的行为,如完成资源回收等
/// @brief 应用程序销毁处理
/// @details 重载该函数以处理应用程序销毁时的行为,如完成资源回收等
virtual void OnDestroy();
/// \~chinese
/// @brief 应用程序关闭处理
/// @details 重载该函数以处理用户关闭应用程序时的行为,如保存用户数据等
/// @return 返回true允许用户关闭程序否则阻止程序关闭
/// @brief 应用程序关闭处理
/// @details 重载该函数以处理用户关闭应用程序时的行为,如保存用户数据等
/// @return 返回true允许用户关闭程序否则阻止程序关闭
virtual bool OnClosing();
/// \~chinese
/// @brief 应用程序主循环
/// @details 重载该函数以
/// @return 返回false退出主循环否则继续运行主循环
/// @brief 应用程序主循环
/// @details 重载该函数以
/// @return 返回false退出主循环否则继续运行主循环
virtual bool MainLoop();
/// \~chinese
/// @brief 获取主窗口
/// @brief 获取主窗口
WindowPtr GetMainWindow() const;
/// \~chinese
/// @brief 设置主窗口
/// @brief 设置主窗口
void SetMainWindow(WindowPtr window);
/// \~chinese
/// @brief 获取上一次更新时间
/// @brief 获取上一次更新时间
Time GetLastUpdateTime() const;
private:

View File

@ -31,18 +31,18 @@ KGE_DECLARE_SMART_PTR(Window);
/**
* \~chinese
* @brief
* @brief
*/
enum class CursorType
{
Arrow, ///< 指针
TextInput, ///< 文本
Hand, ///< 手
SizeAll, ///< 指向四个方向的箭头
SizeWE, ///< 指向左右方向的箭头
SizeNS, ///< 指向上下方向的箭头
SizeNESW, ///< 指向左下到右上方向的箭头
SizeNWSE, ///< 指向左上到右下方向的箭头
Arrow, ///< 指针
TextInput, ///< 文本
Hand, ///< 手
SizeAll, ///< 指向四个方向的箭头
SizeWE, ///< 指向左右方向的箭头
SizeNS, ///< 指向上下方向的箭头
SizeNESW, ///< 指向左下到右上方向的箭头
SizeNWSE, ///< 指向左上到右下方向的箭头
};
@ -53,133 +53,133 @@ typedef HWND WindowHandle;
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Window : public ObjectBase
{
public:
/**
* \~chinese
* @brief
* @param title
* @param width
* @param height
* @param icon ID
* @param resizable
* @param fullscreen
* @throw kiwano::SystemError
* @brief
* @param title
* @param width
* @param height
* @param icon ID
* @param resizable
* @param fullscreen
* @throw kiwano::SystemError
*/
static WindowPtr Create(const String& title, uint32_t width, uint32_t height, uint32_t icon = 0,
bool resizable = false, bool fullscreen = false);
/**
* \~chinese
* @brief
* @return
* @brief
* @return
*/
String GetTitle() const;
/**
* \~chinese
* @brief
* @return
* @brief
* @return
*/
Size GetSize() const;
/**
* \~chinese
* @brief
* @return
* @brief
* @return
*/
uint32_t GetWidth() const;
/**
* \~chinese
* @brief
* @return
* @brief
* @return
*/
uint32_t GetHeight() const;
/**
* \~chinese
* @brief
* @brief
*/
WindowHandle GetHandle() const;
/**
* \~chinese
* @brief
* @param title
* @brief
* @param title
*/
virtual void SetTitle(const String& title) = 0;
/**
* \~chinese
* @brief
* @param icon_resource ID
* @brief
* @param icon_resource ID
*/
virtual void SetIcon(uint32_t icon_resource) = 0;
/**
* \~chinese
* @brief
* @param width
* @param height
* @brief
* @param width
* @param height
*/
virtual void Resize(uint32_t width, uint32_t height) = 0;
/**
* \~chinese
* @brief
* @param fullscreen
* @param width
* @param height
* @brief
* @param fullscreen
* @param width
* @param height
*/
virtual void SetFullscreen(bool fullscreen) = 0;
/**
* \~chinese
* @brief
* @param cursor
* @brief
* @param cursor
*/
virtual void SetCursor(CursorType cursor) = 0;
/**
* \~chinese
* @brief
* @return \n
*
* @brief
* @return \n
*
*/
EventPtr PollEvent();
/**
* \~chinese
* @brief
* @param evt
* @brief
* @param evt
*/
void PushEvent(EventPtr evt);
/**
* \~chinese
* @brief
* @brief
*/
virtual void PumpEvents() = 0;
/**
* \~chinese
* @brief
* @brief
*/
bool ShouldClose();
/**
* \~chinese
* @brief
* @brief
*/
void SetShouldClose(bool should);
/**
* \~chinese
* @brief
* @brief
*/
virtual void Destroy();

View File

@ -77,9 +77,9 @@ private:
bool resizable_;
bool is_fullscreen_;
CursorType mouse_cursor_;
String device_name_;
std::unique_ptr<wchar_t[]> device_name_;
std::array<KeyCode, 256> key_map_;
std::array<KeyCode, 256> key_map_;
};
WindowPtr Window::Create(const String& title, uint32_t width, uint32_t height, uint32_t icon, bool resizable,
@ -104,14 +104,14 @@ namespace kiwano
namespace
{
MONITORINFOEX GetMoniterInfoEx(HWND hwnd)
MONITORINFOEXA GetMoniterInfoEx(HWND hwnd)
{
HMONITOR monitor = ::MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
MONITORINFOEX monitor_info;
HMONITOR monitor = ::MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
MONITORINFOEXA monitor_info;
memset(&monitor_info, 0, sizeof(MONITORINFOEX));
monitor_info.cbSize = sizeof(MONITORINFOEX);
::GetMonitorInfoW(monitor, &monitor_info);
memset(&monitor_info, 0, sizeof(MONITORINFOEXA));
monitor_info.cbSize = sizeof(MONITORINFOEXA);
::GetMonitorInfoA(monitor, &monitor_info);
return monitor_info;
}
@ -125,7 +125,7 @@ void AdjustWindow(uint32_t width, uint32_t height, DWORD style, uint32_t* win_wi
*win_width = rc.right - rc.left;
*win_height = rc.bottom - rc.top;
MONITORINFOEX info = GetMoniterInfoEx(NULL);
MONITORINFOEXA info = GetMoniterInfoEx(NULL);
uint32_t screenw = info.rcWork.right - info.rcWork.left;
uint32_t screenh = info.rcWork.bottom - info.rcWork.top;
@ -136,25 +136,24 @@ void AdjustWindow(uint32_t width, uint32_t height, DWORD style, uint32_t* win_wi
*win_height = screenh;
}
void ChangeFullScreenResolution(uint32_t width, uint32_t height, WCHAR* device_name)
void ChangeFullScreenResolution(uint32_t width, uint32_t height, const CHAR* device_name)
{
DEVMODE mode;
DEVMODEA mode;
memset(&mode, 0, sizeof(mode));
mode.dmSize = sizeof(DEVMODE);
mode.dmSize = sizeof(DEVMODEA);
mode.dmBitsPerPel = ::GetDeviceCaps(::GetDC(0), BITSPIXEL);
;
mode.dmPelsWidth = width;
mode.dmPelsHeight = height;
mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
if (::ChangeDisplaySettingsExW(device_name, &mode, NULL, CDS_FULLSCREEN, NULL) != DISP_CHANGE_SUCCESSFUL)
if (::ChangeDisplaySettingsExA(device_name, &mode, NULL, CDS_FULLSCREEN, NULL) != DISP_CHANGE_SUCCESSFUL)
KGE_ERROR("ChangeDisplaySettings failed");
}
void RestoreResolution(WCHAR* device_name)
void RestoreResolution(const CHAR* device_name)
{
::ChangeDisplaySettingsExW(device_name, NULL, NULL, 0, NULL);
::ChangeDisplaySettingsExA(device_name, NULL, NULL, 0, NULL);
}
} // namespace
@ -211,42 +210,39 @@ WindowWin32Impl::~WindowWin32Impl() {}
void WindowWin32Impl::Init(const String& title, uint32_t width, uint32_t height, uint32_t icon, bool resizable,
bool fullscreen)
{
HINSTANCE hinst = GetModuleHandleW(nullptr);
WNDCLASSEX wcex = { 0 };
HINSTANCE hinst = GetModuleHandle(nullptr);
WNDCLASSEXA wcex = { 0 };
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.lpszClassName = L"KiwanoAppWnd";
wcex.lpszClassName = "KiwanoAppWnd";
wcex.style = CS_HREDRAW | CS_VREDRAW /* | CS_DBLCLKS */;
wcex.lpfnWndProc = WindowWin32Impl::StaticWndProc;
wcex.hIcon = nullptr;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = sizeof(LONG_PTR);
wcex.hInstance = hinst;
wcex.hbrBackground = (HBRUSH)(::GetStockObject(BLACK_BRUSH));
wcex.hbrBackground = (HBRUSH)::GetStockObject(BLACK_BRUSH);
wcex.lpszMenuName = nullptr;
wcex.hCursor = ::LoadCursorW(hinst, IDC_ARROW);
wcex.hCursor = ::LoadCursor(hinst, IDC_ARROW);
if (icon)
{
wcex.hIcon = (HICON)::LoadImageW(hinst, MAKEINTRESOURCE(icon), IMAGE_ICON, 0, 0,
LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
wcex.hIcon = (HICON)::LoadImage(hinst, MAKEINTRESOURCE(icon), IMAGE_ICON, 0, 0,
LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
}
::RegisterClassExW(&wcex);
::RegisterClassExA(&wcex);
// Get the nearest monitor to this window
HMONITOR monitor = ::MonitorFromPoint(POINT{ 0, 0 }, MONITOR_DEFAULTTOPRIMARY);
// Get the target monitor info
MONITORINFOEX monitor_info_ex;
memset(&monitor_info_ex, 0, sizeof(MONITORINFOEX));
monitor_info_ex.cbSize = sizeof(MONITORINFOEX);
::GetMonitorInfoW(monitor, &monitor_info_ex);
MONITORINFOEXA monitor_info_ex;
memset(&monitor_info_ex, 0, sizeof(MONITORINFOEXA));
monitor_info_ex.cbSize = sizeof(MONITORINFOEXA);
::GetMonitorInfoA(monitor, &monitor_info_ex);
// Save the device name
int len = lstrlenW(monitor_info_ex.szDevice);
device_name_ = std::unique_ptr<wchar_t[]>(new wchar_t[len + 1]);
lstrcpyW(device_name_.get(), monitor_info_ex.szDevice);
device_name_ = monitor_info_ex.szDevice;
int left = -1, top = -1;
@ -278,14 +274,12 @@ void WindowWin32Impl::Init(const String& title, uint32_t width, uint32_t height,
height = win_height;
}
WideString wide_title = strings::ToWide(title);
handle_ = ::CreateWindowExW(is_fullscreen_ ? WS_EX_TOPMOST : 0, L"KiwanoAppWnd", wide_title.c_str(), GetStyle(),
handle_ = ::CreateWindowExA(is_fullscreen_ ? WS_EX_TOPMOST : 0, "KiwanoAppWnd", title.c_str(), GetStyle(),
left, top, width, height, nullptr, nullptr, hinst, nullptr);
if (handle_ == nullptr)
{
::UnregisterClassW(L"KiwanoAppWnd", hinst);
::UnregisterClassA("KiwanoAppWnd", hinst);
KGE_THROW_SYSTEM_ERROR(HRESULT_FROM_WIN32(GetLastError()), "Create window failed");
}
@ -296,24 +290,24 @@ void WindowWin32Impl::Init(const String& title, uint32_t width, uint32_t height,
::ImmAssociateContext(handle_, nullptr);
// use Application instance in message loop
::SetWindowLongPtr(handle_, GWLP_USERDATA, LONG_PTR(this));
::SetWindowLongPtrA(handle_, GWLP_USERDATA, LONG_PTR(this));
::ShowWindow(handle_, SW_SHOWNORMAL);
::UpdateWindow(handle_);
if (is_fullscreen_)
{
ChangeFullScreenResolution(width, height, device_name_.get());
ChangeFullScreenResolution(width, height, device_name_.c_str());
}
}
void WindowWin32Impl::PumpEvents()
{
MSG msg;
while (::PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE))
while (::PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
{
::TranslateMessage(&msg);
::DispatchMessageW(&msg);
::DispatchMessage(&msg);
}
}
@ -321,8 +315,7 @@ void WindowWin32Impl::SetTitle(const String& title)
{
if (handle_)
{
WideString wide_title = strings::ToWide(title);
::SetWindowTextW(handle_, wide_title.c_str());
::SetWindowTextA(handle_, title.c_str());
}
}
@ -330,9 +323,9 @@ void WindowWin32Impl::SetIcon(uint32_t icon_resource)
{
if (handle_)
{
HINSTANCE hinstance = GetModuleHandle(nullptr);
HICON icon = (HICON)::LoadImageW(hinstance, MAKEINTRESOURCE(icon_resource), IMAGE_ICON, 0, 0,
LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
HINSTANCE hinstance = ::GetModuleHandle(nullptr);
HICON icon = (HICON)::LoadImage(hinstance, MAKEINTRESOURCE(icon_resource), IMAGE_ICON, 0, 0,
LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
::SendMessage(handle_, WM_SETICON, ICON_BIG, (LPARAM)icon);
::SendMessage(handle_, WM_SETICON, ICON_SMALL, (LPARAM)icon);
@ -366,19 +359,19 @@ void WindowWin32Impl::SetFullscreen(bool fullscreen)
// move window to (0, 0) before display switch
::SetWindowPos(handle_, HWND_TOPMOST, 0, 0, width, height, SWP_NOACTIVATE);
ChangeFullScreenResolution(width, height, device_name_.get());
ChangeFullScreenResolution(width, height, device_name_.c_str());
MONITORINFOEX info = GetMoniterInfoEx(handle_);
MONITORINFOEXA info = GetMoniterInfoEx(handle_);
::SetWindowLongPtr(handle_, GWL_STYLE, GetStyle());
::SetWindowLongPtrA(handle_, GWL_STYLE, GetStyle());
::SetWindowPos(handle_, HWND_TOPMOST, info.rcMonitor.top, info.rcMonitor.left, width, height,
SWP_NOACTIVATE);
}
else
{
RestoreResolution(device_name_.get());
RestoreResolution(device_name_.c_str());
MONITORINFOEX info = GetMoniterInfoEx(handle_);
MONITORINFOEXA info = GetMoniterInfoEx(handle_);
uint32_t screenw = uint32_t(info.rcWork.right - info.rcWork.left);
uint32_t screenh = uint32_t(info.rcWork.bottom - info.rcWork.top);
@ -386,7 +379,7 @@ void WindowWin32Impl::SetFullscreen(bool fullscreen)
int left = screenw > width ? ((screenw - width) / 2) : 0;
int top = screenh > height ? ((screenh - height) / 2) : 0;
::SetWindowLongPtr(handle_, GWL_STYLE, GetStyle());
::SetWindowLongPtrA(handle_, GWL_STYLE, GetStyle());
::SetWindowPos(handle_, HWND_NOTOPMOST, left, top, width, height, SWP_DRAWFRAME | SWP_FRAMECHANGED);
}
@ -402,9 +395,7 @@ void WindowWin32Impl::SetCursor(CursorType cursor)
void WindowWin32Impl::Destroy()
{
if (is_fullscreen_)
RestoreResolution(device_name_.get());
device_name_.reset();
RestoreResolution(device_name_.c_str());
if (handle_)
{
@ -450,7 +441,7 @@ void WindowWin32Impl::UpdateCursor()
win32_cursor = IDC_HAND;
break;
}
::SetCursor(::LoadCursorW(nullptr, win32_cursor));
::SetCursor(::LoadCursor(nullptr, win32_cursor));
}
void WindowWin32Impl::SetActive(bool actived)
@ -462,15 +453,15 @@ void WindowWin32Impl::SetActive(bool actived)
{
if (actived)
{
ChangeFullScreenResolution(GetWidth(), GetHeight(), device_name_.get());
ChangeFullScreenResolution(GetWidth(), GetHeight(), device_name_.c_str());
MONITORINFOEX info = GetMoniterInfoEx(handle_);
MONITORINFOEXA info = GetMoniterInfoEx(handle_);
::SetWindowPos(handle_, HWND_TOPMOST, info.rcMonitor.top, info.rcMonitor.left, GetWidth(), GetHeight(),
SWP_NOACTIVATE);
}
else
{
RestoreResolution(device_name_.get());
RestoreResolution(device_name_.c_str());
::SetWindowPos(handle_, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
::ShowWindow(handle_, SW_MINIMIZE);
@ -679,18 +670,18 @@ LRESULT WindowWin32Impl::MessageProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARA
break;
}
return ::DefWindowProcW(hwnd, msg, wparam, lparam);
return ::DefWindowProcA(hwnd, msg, wparam, lparam);
}
LRESULT CALLBACK WindowWin32Impl::StaticWndProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARAM lparam)
{
LONG_PTR ptr = static_cast<LONG_PTR>(::GetWindowLongPtrW(hwnd, GWLP_USERDATA));
LONG_PTR ptr = static_cast<LONG_PTR>(::GetWindowLongPtrA(hwnd, GWLP_USERDATA));
if (ptr)
{
WindowWin32Impl* window = reinterpret_cast<WindowWin32Impl*>(ptr);
return window->MessageProc(hwnd, msg, wparam, lparam);
}
return ::DefWindowProcW(hwnd, msg, wparam, lparam);
return ::DefWindowProcA(hwnd, msg, wparam, lparam);
}
} // namespace kiwano

View File

@ -33,11 +33,11 @@ KGE_DECLARE_SMART_PTR(Brush);
*/
/// \~chinese
/// @brief 渐变转换点
/// @brief 渐变转换点
struct GradientStop
{
float offset; ///< 偏移距离
Color color; ///< 渐变点颜色
float offset; ///< 偏移距离
Color color; ///< 渐变点颜色
GradientStop();
@ -45,37 +45,37 @@ struct GradientStop
};
/// \~chinese
/// @brief 渐变扩充模式
/// @details 该模式用于指定画笔如何绘制正常区域外的部分
/// @brief 渐变扩充模式
/// @details 该模式用于指定画笔如何绘制正常区域外的部分
enum class GradientExtendMode
{
Clamp, ///< 夹模式,重复绘制边界颜色
Wrap, ///< 包裹模式,重复画笔内容
Mirror ///< 镜像模式,反转画笔内容
Clamp, ///< 夹模式,重复绘制边界颜色
Wrap, ///< 包裹模式,重复画笔内容
Mirror ///< 镜像模式,反转画笔内容
};
/// \~chinese
/// @brief 线性渐变样式
/// @brief 线性渐变样式
struct LinearGradientStyle
{
Point begin; ///< 渐变起始点
Point end; ///< 渐变终止点
Vector<GradientStop> stops; ///< 渐变转换点集合
GradientExtendMode extend_mode; ///< 渐变扩充模式
Point begin; ///< 渐变起始点
Point end; ///< 渐变终止点
Vector<GradientStop> stops; ///< 渐变转换点集合
GradientExtendMode extend_mode; ///< 渐变扩充模式
LinearGradientStyle(const Point& begin, const Point& end, const Vector<GradientStop>& stops,
GradientExtendMode extend_mode = GradientExtendMode::Clamp);
};
/// \~chinese
/// @brief 径向渐变样式
/// @brief 径向渐变样式
struct RadialGradientStyle
{
Point center; ///< 径向渐变圆心
Vec2 offset; ///< 径向渐变偏移
Vec2 radius; ///< 径向渐变半径
Vector<GradientStop> stops; ///< 渐变转换点集合
GradientExtendMode extend_mode; ///< 渐变扩充模式
Point center; ///< 径向渐变圆心
Vec2 offset; ///< 径向渐变偏移
Vec2 radius; ///< 径向渐变半径
Vector<GradientStop> stops; ///< 渐变转换点集合
GradientExtendMode extend_mode; ///< 渐变扩充模式
RadialGradientStyle(const Point& center, const Vec2& offset, const Vec2& radius, const Vector<GradientStop>& stops,
GradientExtendMode extend_mode = GradientExtendMode::Clamp);
@ -83,66 +83,66 @@ struct RadialGradientStyle
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Brush : public NativeObject
{
public:
/// \~chinese
/// @brief 创建纯色画刷
/// @param color 画刷颜色
/// @brief 创建纯色画刷
/// @param color 画刷颜色
static BrushPtr Create(const Color& color);
/// \~chinese
/// @brief 创建线性渐变样式
/// @param style 线性渐变样式
/// @brief 创建线性渐变样式
/// @param style 线性渐变样式
static BrushPtr Create(const LinearGradientStyle& style);
/// \~chinese
/// @brief 创建径向渐变样式
/// @param style 径向渐变样式
/// @brief 创建径向渐变样式
/// @param style 径向渐变样式
static BrushPtr Create(const RadialGradientStyle& style);
Brush();
/// \~chinese
/// @brief 设置纯色画刷颜色
/// @brief 设置纯色画刷颜色
void SetColor(const Color& color);
/// \~chinese
/// @brief 设置线性渐变样式
/// @brief 设置线性渐变样式
void SetStyle(const LinearGradientStyle& style);
/// \~chinese
/// @brief 设置径向渐变样式
/// @brief 设置径向渐变样式
void SetStyle(const RadialGradientStyle& style);
/// \~chinese
/// @brief 设置纹理
/// @brief 设置纹理
void SetTexture(TexturePtr texture);
/// \~chinese
/// @brief 设置二维变换
/// @brief 设置二维变换
void SetTransform(const Transform& transform);
/// \~chinese
/// @brief 设置二维变换
/// @brief 设置二维变换
void SetTransform(const Matrix3x2& transform);
public:
/// \~chinese
/// @brief 画刷类型
/// @brief 画刷类型
enum class Type
{
None,
SolidColor, ///< 纯色填充画刷
LinearGradient, ///< 线性渐变画刷
RadialGradient, ///< 径向渐变画刷
Texture ///< 纹理画刷
SolidColor, ///< 纯色填充画刷
LinearGradient, ///< 线性渐变画刷
RadialGradient, ///< 径向渐变画刷
Texture ///< 纹理画刷
};
/// \~chinese
/// @brief 获取画刷类型
/// @brief 获取画刷类型
Type GetType() const;
private:

View File

@ -31,46 +31,46 @@ namespace kiwano
/*
* \~chinese
* @brief
* @brief
* @details
* 使: @code Color blue = Color::Blue; @endcode
* 使 RGB : @code Color red = Color(1.0f, 0.0f, 0.0f); @endcode
* 使 RGBA : @code Color not_white = Color(1.0f, 1.0f,
* 使: @code Color blue = Color::Blue; @endcode
* 使 RGB : @code Color red = Color(1.0f, 0.0f, 0.0f); @endcode
* 使 RGBA : @code Color not_white = Color(1.0f, 1.0f,
* 1.0f, 0.5f); @endcode
* 使16 RGB : @code Color black(0x000000); @endcode
* 使16 RGB : @code Color black(0x000000); @endcode
*/
class KGE_API Color
{
public:
/// \~chinese
/// @brief 构造颜色
/// @details 默认颜色为 R: 0.0, G: 0.0, B: 0.0, A: 1.0
/// @brief 构造颜色
/// @details 默认颜色为 R: 0.0, G: 0.0, B: 0.0, A: 1.0
Color();
/// \~chinese
/// @brief 构造 RGB 颜色
/// @param r 红色值,范围 0.0 - 1.0
/// @param g 绿色值,范围 0.0 - 1.0
/// @param b 蓝色值,范围 0.0 - 1.0
/// @brief 构造 RGB 颜色
/// @param r 红色值,范围 0.0 - 1.0
/// @param g 绿色值,范围 0.0 - 1.0
/// @param b 蓝色值,范围 0.0 - 1.0
Color(float r, float g, float b);
/// \~chinese
/// @brief 构造 RGBA 颜色
/// @param r 红色值,范围 0.0 - 1.0
/// @param g 绿色值,范围 0.0 - 1.0
/// @param b 蓝色值,范围 0.0 - 1.0
/// @param a Alpha值范围 0.0 - 1.0
/// @brief 构造 RGBA 颜色
/// @param r 红色值,范围 0.0 - 1.0
/// @param g 绿色值,范围 0.0 - 1.0
/// @param b 蓝色值,范围 0.0 - 1.0
/// @param a Alpha值范围 0.0 - 1.0
Color(float r, float g, float b, float alpha);
/// \~chinese
/// @brief 构造 RGB 颜色
/// @param rgb 使用16进制整形值表示 RGB颜色
/// @brief 构造 RGB 颜色
/// @param rgb 使用16进制整形值表示 RGB颜色
Color(uint32_t rgb);
/// \~chinese
/// @brief 构造 RGBA 颜色
/// @param rgb 使用16进制整形值表示 RGB 颜色
/// @param a Alpha值范围 0.0 - 1.0
/// @brief 构造 RGBA 颜色
/// @param rgb 使用16进制整形值表示 RGB 颜色
/// @param a Alpha值范围 0.0 - 1.0
Color(uint32_t rgb, float alpha);
bool operator==(const Color& rhs) const;
@ -79,7 +79,7 @@ public:
public:
/// \~chinese
/// @brief 常见颜色枚举
/// @brief 常见颜色枚举
enum Value : uint32_t
{
Black = 0x000000,
@ -124,14 +124,14 @@ public:
};
/// \~chinese
/// @brief 透明色
/// @brief 透明色
static const Color Transparent;
public:
float r; ///< 红色值
float g; ///< 绿色值
float b; ///< 蓝色值
float a; ///< Alpha值
float r; ///< 红色值
float g; ///< 绿色值
float b; ///< 蓝色值
float a; ///< Alpha值
};
/** @} */

View File

@ -159,7 +159,8 @@ HRESULT STDMETHODCALLTYPE FontCollectionLoader::CreateEnumeratorFromKey(
if (SUCCEEDED(hr))
{
*fontFileEnumerator = DX::SafeAcquire(pEnumerator);
DX::SafeRelease(*fontFileEnumerator);
(*fontFileEnumerator) = pEnumerator;
}
}
return hr;
@ -468,7 +469,8 @@ HRESULT STDMETHODCALLTYPE ResourceFontCollectionLoader::CreateEnumeratorFromKey(
if (SUCCEEDED(hr))
{
*fontFileEnumerator = DX::SafeAcquire(pEnumerator);
DX::SafeRelease(*fontFileEnumerator);
(*fontFileEnumerator) = pEnumerator;
}
}
return hr;
@ -574,7 +576,7 @@ HRESULT STDMETHODCALLTYPE ResourceFontFileLoader::CreateStreamFromKey(void const
if (SUCCEEDED(hr))
{
DX::SafeRelease(*fontFileStream);
*fontFileStream = DX::SafeAcquire(pFileStream);
(*fontFileStream) = pFileStream;
}
}
return hr;

View File

@ -88,15 +88,15 @@ public:
void Present() override;
/// \~chinese
/// @brief 获取Direct2D设备资源
/// @brief 获取Direct2D设备资源
ID2DDeviceResources* GetD2DDeviceResources();
/// \~chinese
/// @brief 获取Direct3D设备资源
/// @brief 获取Direct3D设备资源
ID3DDeviceResources* GetD3DDeviceResources();
/// \~chinese
/// @brief 重设渲染输出大小
/// @brief 重设渲染输出大小
void Resize(uint32_t width, uint32_t height) override;
protected:

View File

@ -35,7 +35,7 @@ class Renderer;
/**
* \~chinese
* @brief
* @brief
*/
class Font : public NativeObject
{
@ -43,21 +43,21 @@ class Font : public NativeObject
public:
/// \~chinese
/// @brief 创建字体
/// @brief 创建字体
static FontPtr Create(const String& file);
/// \~chinese
/// @brief 创建字体
/// @brief 创建字体
static FontPtr Create(const Resource& resource);
Font();
/// \~chinese
/// @brief 加载字体文件
/// @brief 加载字体文件
bool Load(const String& file);
/// \~chinese
/// @brief 加载字体资源
/// @brief 加载字体资源
bool Load(const Resource& resource);
};

View File

@ -121,10 +121,10 @@ bool GifImage::GetGlobalMetadata()
PROPVARIANT prop_val;
::PropVariantInit(&prop_val);
// 获取全局 frame 大小
// 获取全局 frame 大小
if (SUCCEEDED(hr))
{
// 获取宽度
// 获取宽度
hr = metadata_reader->GetMetadataByName(L"/logscrdesc/Width", &prop_val);
if (SUCCEEDED(hr))
@ -140,7 +140,7 @@ bool GifImage::GetGlobalMetadata()
if (SUCCEEDED(hr))
{
// 获取高度
// 获取高度
hr = metadata_reader->GetMetadataByName(L"/logscrdesc/Height", &prop_val);
if (SUCCEEDED(hr))
@ -156,7 +156,7 @@ bool GifImage::GetGlobalMetadata()
if (SUCCEEDED(hr))
{
// 获得像素纵横比
// 获得像素纵横比
hr = metadata_reader->GetMetadataByName(L"/logscrdesc/PixelAspectRatio", &prop_val);
if (SUCCEEDED(hr))
@ -166,11 +166,11 @@ bool GifImage::GetGlobalMetadata()
{
if (prop_val.bVal != 0)
{
// 需要计算比率
// 最高像素 14最宽像素 41增量为 1/64
// 需要计算比率
// 最高像素 14最宽像素 41增量为 1/64
float pixel_asp_ratio = (prop_val.bVal + 15.f) / 64.f;
// 根据像素长宽比计算像素中的图像宽度和高度,只缩小图像
// 根据像素长宽比计算像素中的图像宽度和高度,只缩小图像
if (pixel_asp_ratio > 1.f)
{
size_in_pixels_ = { width, static_cast<uint32_t>(height / pixel_asp_ratio) };
@ -182,7 +182,7 @@ bool GifImage::GetGlobalMetadata()
}
else
{
// 值为 0, 所以像素比为 1
// 值为 0, 所以像素比为 1
size_in_pixels_ = { width, height };
}
}

View File

@ -33,71 +33,71 @@ KGE_DECLARE_SMART_PTR(GifImage);
/**
* \~chinese
* @brief GIF图像
* @brief GIF图像
*/
class KGE_API GifImage : public NativeObject
{
public:
/// \~chinese
/// @brief 创建GIF图片
/// @brief 创建GIF图片
static GifImagePtr Create(const String& file_path);
/// \~chinese
/// @brief 创建GIF图片
/// @brief 创建GIF图片
static GifImagePtr Create(const Resource& res);
GifImage();
/// \~chinese
/// @brief 加载本地GIF图片
/// @brief 加载本地GIF图片
bool Load(const String& file_path);
/// \~chinese
/// @brief 加载GIF资源
/// @brief 加载GIF资源
bool Load(const Resource& res);
/// \~chinese
/// @brief 获取像素宽度
/// @brief 获取像素宽度
uint32_t GetWidthInPixels() const;
/// \~chinese
/// @brief 获取像素高度
/// @brief 获取像素高度
uint32_t GetHeightInPixels() const;
/// \~chinese
/// @brief 获取像素大小
/// @brief 获取像素大小
PixelSize GetSizeInPixels() const;
/// \~chinese
/// @brief 获取帧数量
/// @brief 获取帧数量
uint32_t GetFramesCount() const;
public:
/// \~chinese
/// @brief GIF帧的处置方式
/// @brief GIF帧的处置方式
enum class DisposalType
{
Unknown, ///< 未知
None, ///< 不处理
Background, ///< 背景
Previous ///< 恢复前一帧
Unknown, ///< 未知
None, ///< 不处理
Background, ///< 背景
Previous ///< 恢复前一帧
};
/// \~chinese
/// @brief GIF帧
/// @brief GIF帧
struct Frame
{
Duration delay; ///< 帧延迟
TexturePtr texture; ///< 帧图像
Rect rect; ///< 绘制区域
DisposalType disposal_type; ///< 处置方式
Duration delay; ///< 帧延迟
TexturePtr texture; ///< 帧图像
Rect rect; ///< 绘制区域
DisposalType disposal_type; ///< 处置方式
Frame();
};
/// \~chinese
/// @brief 获取GIF帧
/// @param index 帧下标
/// @brief 获取GIF帧
/// @param index 帧下标
Frame GetFrame(uint32_t index);
private:

View File

@ -33,7 +33,7 @@ KGE_DECLARE_SMART_PTR(Layer);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Layer : public NativeObject
{
@ -41,35 +41,35 @@ public:
Layer();
/// \~chinese
/// @brief 获取图层裁剪区域
/// @brief 삿혤暠꿔꼴숏혐堵
const Rect& GetClipRect() const;
/// \~chinese
/// @brief 获取图层透明度
/// @brief 삿혤暠꿔拷츠똑
float GetOpacity() const;
/// \~chinese
/// @brief 获取几何蒙层
/// @brief 삿혤섯부촁꿔
ShapePtr GetMaskShape() const;
/// \~chinese
/// @brief 获取几何蒙层变换
/// @brief 삿혤섯부촁꿔긴뻣
const Matrix3x2& GetMaskTransform() const;
/// \~chinese
/// @brief 设置图层裁剪区域
/// @brief <EFBFBD>零暠꿔꼴숏혐堵
void SetClipRect(const Rect& rect);
/// \~chinese
/// @brief 设置图层透明度
/// @brief <EFBFBD>零暠꿔拷츠똑
void SetOpacity(float opacity);
/// \~chinese
/// @brief 设置几何蒙层
/// @brief <EFBFBD>零섯부촁꿔
void SetMaskShape(ShapePtr mask);
/// \~chinese
/// @brief 设置几何蒙层变换
/// @brief <EFBFBD>零섯부촁꿔긴뻣
void SetMaskTransform(const Matrix3x2& matrix);
private:

View File

@ -37,7 +37,7 @@ KGE_DECLARE_SMART_PTR(NativeObject);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API NativeObject : public ObjectBase
{

View File

@ -37,218 +37,218 @@ KGE_DECLARE_SMART_PTR(RenderContext);
*/
/// \~chinese
/// @brief 文字抗锯齿模式
/// @brief 文字抗锯齿模式
enum class TextAntialiasMode
{
Default, ///< 系统默认
ClearType, ///< ClearType 抗锯齿
GrayScale, ///< 灰度抗锯齿
None ///< 不启用抗锯齿
Default, ///< 系统默认
ClearType, ///< ClearType 抗锯齿
GrayScale, ///< 灰度抗锯齿
None ///< 不启用抗锯齿
};
/// \~chinese
/// @brief 渲染上下文
/// @details 渲染上下文将完成基础图元的绘制,并将绘制结果输出到特定的平面中
/// @brief 渲染上下文
/// @details 渲染上下文将完成基础图元的绘制,并将绘制结果输出到特定的平面中
class KGE_API RenderContext : public NativeObject
{
public:
/// \~chinese
/// @brief 创建纹理渲染上下文,将绘制结果输出到纹理中
/// @param texture 保存绘制结果的纹理
/// @brief 创建纹理渲染上下文,将绘制结果输出到纹理中
/// @param texture 保存绘制结果的纹理
static RenderContextPtr Create(Texture& texture);
/// \~chinese
/// @brief 创建纹理渲染上下文,将绘制结果输出到纹理中
/// @param texture 保存绘制结果的纹理
/// @param size 渲染输出大小
/// @brief 创建纹理渲染上下文,将绘制结果输出到纹理中
/// @param texture 保存绘制结果的纹理
/// @param size 渲染输出大小
static RenderContextPtr Create(Texture& texture, const Size& size);
/// \~chinese
/// @brief 开始渲染
/// @brief 开始渲染
virtual void BeginDraw();
/// \~chinese
/// @brief 结束渲染
/// @brief 结束渲染
virtual void EndDraw();
/// \~chinese
/// @brief 绘制纹理
/// @param texture 纹理
/// @param src_rect 源纹理裁剪矩形
/// @param dest_rect 绘制的目标区域
/// @brief 绘制纹理
/// @param texture 纹理
/// @param src_rect 源纹理裁剪矩形
/// @param dest_rect 绘制的目标区域
virtual void DrawTexture(const Texture& texture, const Rect* src_rect = nullptr,
const Rect* dest_rect = nullptr) = 0;
/// \~chinese
/// @brief 绘制文本布局
/// @param layout 文本布局
/// @param offset 偏移量
/// @brief 绘制文本布局
/// @param layout 文本布局
/// @param offset 偏移量
virtual void DrawTextLayout(const TextLayout& layout, const Point& offset = Point()) = 0;
/// \~chinese
/// @brief 绘制形状轮廓
/// @param shape 形状
/// @brief 绘制形状轮廓
/// @param shape 形状
virtual void DrawShape(const Shape& shape) = 0;
/// \~chinese
/// @brief 绘制线段
/// @param point1 线段起点
/// @param point2 线段终点
/// @brief 绘制线段
/// @param point1 线段起点
/// @param point2 线段终点
virtual void DrawLine(const Point& point1, const Point& point2) = 0;
/// \~chinese
/// @brief 绘制矩形边框
/// @param rect 矩形
/// @brief 绘制矩形边框
/// @param rect 矩形
virtual void DrawRectangle(const Rect& rect) = 0;
/// \~chinese
/// @brief 绘制圆角矩形边框
/// @param rect 矩形
/// @param radius 圆角半径
/// @brief 绘制圆角矩形边框
/// @param rect 矩形
/// @param radius 圆角半径
virtual void DrawRoundedRectangle(const Rect& rect, const Vec2& radius) = 0;
/// \~chinese
/// @brief 绘制椭圆边框
/// @param center 圆心
/// @param radius 椭圆半径
/// @brief 绘制椭圆边框
/// @param center 圆心
/// @param radius 椭圆半径
virtual void DrawEllipse(const Point& center, const Vec2& radius) = 0;
/// \~chinese
/// @brief 填充形状
/// @param shape 形状
/// @brief 填充形状
/// @param shape 形状
virtual void FillShape(const Shape& shape) = 0;
/// \~chinese
/// @brief 填充矩形
/// @param rect 矩形
/// @brief 填充矩形
/// @param rect 矩形
virtual void FillRectangle(const Rect& rect) = 0;
/// \~chinese
/// @brief 填充圆角矩形
/// @param rect 矩形
/// @param radius 圆角半径
/// @brief 填充圆角矩形
/// @param rect 矩形
/// @param radius 圆角半径
virtual void FillRoundedRectangle(const Rect& rect, const Vec2& radius) = 0;
/// \~chinese
/// @brief 填充椭圆
/// @param center 圆心
/// @param radius 椭圆半径
/// @brief 填充椭圆
/// @param center 圆心
/// @param radius 椭圆半径
virtual void FillEllipse(const Point& center, const Vec2& radius) = 0;
/// \~chinese
/// @brief 创建纹理
/// @param texture 纹理
/// @param size 纹理像素大小
/// @brief 创建纹理
/// @param texture 纹理
/// @param size 纹理像素大小
virtual void CreateTexture(Texture& texture, math::Vec2T<uint32_t> size) = 0;
/// \~chinese
/// @brief 设置绘制的裁剪区域
/// @param clip_rect 裁剪矩形
/// @brief 设置绘制的裁剪区域
/// @param clip_rect 裁剪矩形
virtual void PushClipRect(const Rect& clip_rect) = 0;
/// \~chinese
/// @brief 取消上一次设置的绘制裁剪区域
/// @brief 取消上一次设置的绘制裁剪区域
virtual void PopClipRect() = 0;
/// \~chinese
/// @brief 设置图层区域
/// @param layer 图层区域
/// @brief 设置图层区域
/// @param layer 图层区域
virtual void PushLayer(Layer& layer) = 0;
/// \~chinese
/// @brief 取消上一次设置的图层区域
/// @brief 取消上一次设置的图层区域
virtual void PopLayer() = 0;
/// \~chinese
/// @brief 清空渲染内容
/// @brief 清空渲染内容
virtual void Clear() = 0;
/// \~chinese
/// @brief 使用纯色清空渲染内容
/// @param clear_color 清屏颜色
/// @brief 使用纯色清空渲染内容
/// @param clear_color 清屏颜色
virtual void Clear(const Color& clear_color) = 0;
/// \~chinese
/// @brief 获取渲染区域大小
/// @brief 获取渲染区域大小
virtual Size GetSize() const = 0;
/// \~chinese
/// @brief 获取画刷透明度
/// @brief 获取画刷透明度
virtual float GetBrushOpacity() const;
/// \~chinese
/// @brief 获取当前画刷
/// @brief 获取当前画刷
virtual BrushPtr GetCurrentBrush() const;
/// \~chinese
/// @brief 获取全局二维变换
/// @brief 获取全局二维变换
virtual const Matrix3x2& GetGlobalTransform() const;
/// \~chinese
/// @brief 设置画刷透明度
/// @brief 设置画刷透明度
virtual void SetBrushOpacity(float opacity);
/// \~chinese
/// @brief 设置当前使用的画刷
/// @brief 设置当前使用的画刷
virtual void SetCurrentBrush(BrushPtr brush);
/// \~chinese
/// @brief 设置当前使用的线条样式
/// @brief 设置当前使用的线条样式
virtual void SetCurrentStrokeStyle(StrokeStylePtr stroke);
/// \~chinese
/// @brief 设置抗锯齿模式
/// @brief 设置抗锯齿模式
virtual void SetAntialiasMode(bool enabled) = 0;
/// \~chinese
/// @brief 设置文字抗锯齿模式
/// @brief 设置文字抗锯齿模式
virtual void SetTextAntialiasMode(TextAntialiasMode mode) = 0;
/// \~chinese
/// @brief 检查边界是否在视区内
/// @brief 检查边界是否在视区内
virtual bool CheckVisibility(const Rect& bounds, const Matrix3x2& transform) = 0;
/// \~chinese
/// @brief 重设渲染上下文大小
/// @brief 重设渲染上下文大小
virtual void Resize(const Size& size) = 0;
/// \~chinese
/// @brief 设置上下文的二维变换
/// @brief 设置上下文的二维变换
virtual void SetTransform(const Matrix3x2& matrix) = 0;
/// \~chinese
/// @brief 设置全局二维变换
/// @brief 设置全局二维变换
virtual void SetGlobalTransform(const Matrix3x2& matrix);
/// \~chinese
/// @brief 设置全局二维变换
/// @brief 设置全局二维变换
virtual void SetGlobalTransform(const Matrix3x2* matrix);
public:
/// \~chinese
/// @brief 渲染上下文状态
/// @brief 渲染上下文状态
struct Status
{
uint32_t primitives; ///< 渲染图元数量
Time start; ///< 渲染起始时间
Duration duration; ///< 渲染时长
uint32_t primitives; ///< 渲染图元数量
Time start; ///< 渲染起始时间
Duration duration; ///< 渲染时长
Status();
};
/// \~chinese
/// @brief 启用或禁用状态收集功能
/// @brief 启用或禁用状态收集功能
void SetCollectingStatus(bool enable);
/// \~chinese
/// @brief 获取渲染上下文状态
/// @brief 获取渲染上下文状态
const Status& GetStatus() const;
protected:
RenderContext();
/// \~chinese
/// @brief 增加渲染图元数量
/// @brief 增加渲染图元数量
void IncreasePrimitivesCount(uint32_t increase = 1) const;
protected:

View File

@ -31,7 +31,7 @@ namespace kiwano
/**
* \~chinese
* \defgroup Render
* \defgroup Render
*/
/**
@ -41,197 +41,197 @@ namespace kiwano
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Renderer : public EventModule
{
public:
/// \~chinese
/// @brief 获取实例
/// @brief 获取实例
static Renderer& GetInstance();
/// \~chinese
/// @brief 获取清屏颜色
/// @brief 获取清屏颜色
virtual Color GetClearColor() const;
/// \~chinese
/// @brief 设置清屏颜色
/// @brief 设置清屏颜色
virtual void SetClearColor(const Color& clear_color);
/// \~chinese
/// @brief 开启或关闭垂直同步
/// @brief 开启或关闭垂直同步
virtual void SetVSyncEnabled(bool enabled);
/// \~chinese
/// @brief 创建纹理内部资源
/// @param[out] texture 纹理
/// @param[in] file_path 图片路径
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建纹理内部资源
/// @param[out] texture 纹理
/// @param[in] file_path 图片路径
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateTexture(Texture& texture, const String& file_path) = 0;
/// \~chinese
/// @brief 创建纹理内部资源
/// @param[out] texture 纹理
/// @param[in] resource 图片资源
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建纹理内部资源
/// @param[out] texture 纹理
/// @param[in] resource 图片资源
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateTexture(Texture& texture, const Resource& resource) = 0;
/// \~chinese
/// @brief 创建GIF图像内部资源
/// @param[out] gif GIF图像
/// @param[in] file_path 图片路径
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建GIF图像内部资源
/// @param[out] gif GIF图像
/// @param[in] file_path 图片路径
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateGifImage(GifImage& gif, const String& file_path) = 0;
/// \~chinese
/// @brief 创建GIF图像内部资源
/// @param[out] gif GIF图像
/// @param[in] resource 图片资源
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建GIF图像内部资源
/// @param[out] gif GIF图像
/// @param[in] resource 图片资源
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateGifImage(GifImage& gif, const Resource& resource) = 0;
/// \~chinese
/// @brief 创建GIF图像帧内部资源
/// @param[out] frame GIF图像帧
/// @param[in] gif GIF图像
/// @param[in] frame_index 帧下标
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建GIF图像帧内部资源
/// @param[out] frame GIF图像帧
/// @param[in] gif GIF图像
/// @param[in] frame_index 帧下标
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateGifImageFrame(GifImage::Frame& frame, const GifImage& gif, size_t frame_index) = 0;
/// \~chinese
/// @brief 创建字体集内部资源
/// @param[out] font 字体
/// @param[in] file_paths 字体文件路径
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建字体集内部资源
/// @param[out] font 字体
/// @param[in] file_paths 字体文件路径
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateFontCollection(Font& font, const String& file_path) = 0;
/// \~chinese
/// @brief 创建字体集内部资源
/// @param[out] font 字体
/// @param[in] res_arr 字体资源
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建字体集内部资源
/// @param[out] font 字体
/// @param[in] res_arr 字体资源
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateFontCollection(Font& font, const Resource& res) = 0;
/// \~chinese
/// @brief 创建文字布局内部资源
/// @param[out] layout 字体布局
/// @param text 文字内容
/// @param style 文本样式
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建文字布局内部资源
/// @param[out] layout 字体布局
/// @param text 文字内容
/// @param style 文本样式
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateTextLayout(TextLayout& layout, const String& content, const TextStyle& style) = 0;
/// \~chinese
/// @brief 创建线段形状内部资源
/// @param[out] shape 形状
/// @param[in] begin_pos 线段起点
/// @param[in] end_pos 线段终点
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建线段形状内部资源
/// @param[out] shape 形状
/// @param[in] begin_pos 线段起点
/// @param[in] end_pos 线段终点
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateLineShape(Shape& shape, const Point& begin_pos, const Point& end_pos) = 0;
/// \~chinese
/// @brief 创建矩形形状内部资源
/// @param[out] shape 形状
/// @param[in] rect 矩形大小
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建矩形形状内部资源
/// @param[out] shape 形状
/// @param[in] rect 矩形大小
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateRectShape(Shape& shape, const Rect& rect) = 0;
/// \~chinese
/// @brief 创建圆角矩形形状内部资源
/// @param[out] shape 形状
/// @param[in] rect 矩形大小
/// @param[in] radius 圆角半径
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建圆角矩形形状内部资源
/// @param[out] shape 形状
/// @param[in] rect 矩形大小
/// @param[in] radius 圆角半径
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateRoundedRectShape(Shape& shape, const Rect& rect, const Vec2& radius) = 0;
/// \~chinese
/// @brief 创建椭圆形状内部资源
/// @param[out] shape 形状
/// @param[in] center 椭圆圆心
/// @param[in] radius 椭圆半径
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建椭圆形状内部资源
/// @param[out] shape 形状
/// @param[in] center 椭圆圆心
/// @param[in] radius 椭圆半径
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateEllipseShape(Shape& shape, const Point& center, const Vec2& radius) = 0;
/// \~chinese
/// @brief 创建几何图形生成器内部资源
/// @param[out] maker 形状生成器
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建几何图形生成器内部资源
/// @param[out] maker 形状生成器
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateShapeSink(ShapeMaker& maker) = 0;
/// \~chinese
/// @brief 创建纯色画刷内部资源
/// @param[out] brush 画刷
/// @param[in] color 颜色
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建纯色画刷内部资源
/// @param[out] brush 画刷
/// @param[in] color 颜色
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateBrush(Brush& brush, const Color& color) = 0;
/// \~chinese
/// @brief 创建线性渐变画刷内部资源
/// @param[out] brush 画刷
/// @param[in] style 线性渐变样式
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建线性渐变画刷内部资源
/// @param[out] brush 画刷
/// @param[in] style 线性渐变样式
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateBrush(Brush& brush, const LinearGradientStyle& style) = 0;
/// \~chinese
/// @brief 创建径向渐变画刷内部资源
/// @param[out] brush 画刷
/// @param[in] style 径向渐变样式
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建径向渐变画刷内部资源
/// @param[out] brush 画刷
/// @param[in] style 径向渐变样式
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateBrush(Brush& brush, const RadialGradientStyle& style) = 0;
/// \~chinese
/// @brief 创建纹理画刷内部资源
/// @param[out] brush 画刷
/// @param[in] texture 纹理
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建纹理画刷内部资源
/// @param[out] brush 画刷
/// @param[in] texture 纹理
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateBrush(Brush& brush, TexturePtr texture) = 0;
/// \~chinese
/// @brief 创建线条样式内部资源
/// @param[out] stroke_style 线条样式
/// @param[in] cap 线段端点样式
/// @param[in] line_join 线段相交样式
/// @param[in] dash_array 虚线长度与间隙数组
/// @param[in] dash_size 虚线数组大小
/// @param[in] dash_offset 虚线偏移量
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建线条样式内部资源
/// @param[out] stroke_style 线条样式
/// @param[in] cap 线段端点样式
/// @param[in] line_join 线段相交样式
/// @param[in] dash_array 虚线长度与间隙数组
/// @param[in] dash_size 虚线数组大小
/// @param[in] dash_offset 虚线偏移量
/// @throw kiwano::SystemError 创建失败时抛出
virtual void CreateStrokeStyle(StrokeStyle& stroke_style) = 0;
/// \~chinese
/// @brief 创建纹理渲染上下文,将上下文的渲染输出到纹理中
/// @param[in,out] texture 渲染输出的纹理
/// @param[in] desired_size 期望的输出大小
/// @return 纹理渲染上下文
/// @throw kiwano::SystemError 创建失败时抛出
/// @brief 创建纹理渲染上下文,将上下文的渲染输出到纹理中
/// @param[in,out] texture 渲染输出的纹理
/// @param[in] desired_size 期望的输出大小
/// @return 纹理渲染上下文
/// @throw kiwano::SystemError 创建失败时抛出
virtual RenderContextPtr CreateTextureRenderContext(Texture& texture, const Size* desired_size = nullptr) = 0;
public:
/// \~chinese
/// @brief 获取渲染上下文
/// @brief 获取渲染上下文
RenderContext& GetContext();
/// \~chinese
/// @brief 获取渲染输出大小
/// @brief 获取渲染输出大小
Size GetOutputSize() const;
/// \~chinese
/// @brief 开始渲染
/// @brief 开始渲染
virtual void BeginDraw();
/// \~chinese
/// @brief 结束渲染
/// @brief 结束渲染
virtual void EndDraw();
/// \~chinese
/// @brief 清除绘制内容
/// @brief 清除绘制内容
virtual void Clear() = 0;
/// \~chinese
/// @brief 将绘制内容呈现至窗口
/// @throw kiwano::SystemError 呈现失败时抛出
/// @brief 将绘制内容呈现至窗口
/// @throw kiwano::SystemError 呈现失败时抛出
virtual void Present() = 0;
/// \~chinese
/// @brief 重设渲染输出大小
/// @brief 重设渲染输出大小
virtual void Resize(uint32_t width, uint32_t height) = 0;
public:

View File

@ -34,7 +34,7 @@ KGE_DECLARE_SMART_PTR(Shape);
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API Shape : public NativeObject
{
@ -42,68 +42,68 @@ class KGE_API Shape : public NativeObject
public:
/// \~chinese
/// @brief 创建线段形状
/// @param begin 线段起点
/// @param end 线段终点
/// @brief 创建线段形状
/// @param begin 线段起点
/// @param end 线段终点
static ShapePtr CreateLine(const Point& begin, const Point& end);
/// \~chinese
/// @brief 创建矩形
/// @param rect 矩形
/// @brief 创建矩形
/// @param rect 矩形
static ShapePtr CreateRect(const Rect& rect);
/// \~chinese
/// @brief 创建圆角矩形
/// @param rect 矩形
/// @param radius 矩形圆角半径
/// @brief 创建圆角矩形
/// @param rect 矩形
/// @param radius 矩形圆角半径
static ShapePtr CreateRoundedRect(const Rect& rect, const Vec2& radius);
/// \~chinese
/// @brief 创建圆形
/// @param center 圆形原点
/// @param radius 圆形半径
/// @brief 创建圆形
/// @param center 圆形原点
/// @param radius 圆形半径
static ShapePtr CreateCircle(const Point& center, float radius);
/// \~chinese
/// @brief 创建椭圆形
/// @param center 椭圆原点
/// @param radius 椭圆半径
/// @brief 创建椭圆形
/// @param center 椭圆原点
/// @param radius 椭圆半径
static ShapePtr CreateEllipse(const Point& center, const Vec2& radius);
Shape();
/// \~chinese
/// @brief 获取外切包围盒
/// @brief 获取外切包围盒
Rect GetBoundingBox() const;
/// \~chinese
/// @brief 获取外切包围盒
/// @param transform 二维变换
/// @brief 获取外切包围盒
/// @param transform 二维变换
Rect GetBoundingBox(const Matrix3x2& transform) const;
/// \~chinese
/// @brief 判断图形是否包含点
/// @param point 点
/// @param transform 应用到点上的二维变换
/// @brief 判断图形是否包含点
/// @param point 点
/// @param transform 应用到点上的二维变换
bool ContainsPoint(const Point& point, const Matrix3x2* transform = nullptr) const;
/// \~chinese
/// @brief 获取图形展开成一条直线的长度
/// @brief 获取图形展开成一条直线的长度
float GetLength() const;
/// \~chinese
/// @brief 计算图形面积
/// @brief 计算图形面积
float ComputeArea() const;
/// \~chinese
/// @brief 计算图形上点的位置和切线向量
/// @param[in] length 点在图形上的位置,范围 [0.0 - 1.0]
/// @param[out] point 点的位置
/// @param[out] tangent 点的切线向量
/// @brief 计算图形上点的位置和切线向量
/// @param[in] length 点在图形上的位置,范围 [0.0 - 1.0]
/// @param[out] point 点的位置
/// @param[out] tangent 点的切线向量
bool ComputePointAtLength(float length, Point& point, Vec2& tangent) const;
/// \~chinese
/// @brief 清除形状
/// @brief 清除形状
void Clear();
};

View File

@ -32,22 +32,22 @@ KGE_DECLARE_SMART_PTR(ShapeMaker);
*/
/// \~chinese
/// @brief 形状合并方式
/// @brief 形状合并方式
enum class CombineMode
{
Union, ///< 并集 (A + B)
Intersect, ///< 交集 (A + B)
Xor, ///< 对称差集 ((A - B) + (B - A))
Exclude ///< 差集 (A - B)
Union, ///< 并集 (A + B)
Intersect, ///< 交集 (A + B)
Xor, ///< 对称差集 ((A - B) + (B - A))
Exclude ///< 差集 (A - B)
};
/// \~chinese
/// @brief 形状生成器
/// @brief 形状生成器
class KGE_API ShapeMaker : public NativeObject
{
public:
/// \~chinese
/// @brief 创建形状生成器
/// @brief 创建形状生成器
static ShapeMakerPtr Create();
ShapeMaker();
@ -55,83 +55,83 @@ public:
~ShapeMaker();
/// \~chinese
/// @brief 获取生成的形状
/// @brief 获取生成的形状
ShapePtr GetShape();
/// \~chinese
/// @brief 清空图形
/// @brief 清空图形
void Clear();
/// \~chinese
/// @brief 开始添加路径并打开输入流
/// @param begin_pos 路径起始点
/// @brief 开始添加路径并打开输入流
/// @param begin_pos 路径起始点
void BeginPath(const Point& begin_pos = Point());
/// \~chinese
/// @brief 结束路径并关闭输入流
/// @param closed 路径是否闭合
/// @brief 结束路径并关闭输入流
/// @param closed 路径是否闭合
void EndPath(bool closed = false);
/// \~chinese
/// @brief 添加一条线段
/// @param point 端点
/// @brief 添加一条线段
/// @param point 端点
void AddLine(const Point& point);
/// \~chinese
/// @brief 添加多条线段
/// @param points 端点集合
/// @brief 添加多条线段
/// @param points 端点集合
void AddLines(const Vector<Point>& points);
/// \~chinese
/// @brief 添加多条线段
/// @param points 端点数组
/// @param count 端点数量
/// @brief 添加多条线段
/// @param points 端点数组
/// @param count 端点数量
void AddLines(const Point* points, size_t count);
/// \~chinese
/// @brief 添加一条三次方贝塞尔曲线
/// @param point1 贝塞尔曲线的第一个控制点
/// @param point2 贝塞尔曲线的第二个控制点
/// @param point3 贝塞尔曲线的终点
/// @brief 添加一条三次方贝塞尔曲线
/// @param point1 贝塞尔曲线的第一个控制点
/// @param point2 贝塞尔曲线的第二个控制点
/// @param point3 贝塞尔曲线的终点
void AddBezier(const Point& point1, const Point& point2, const Point& point3);
/// \~chinese
/// @brief 添加弧线
/// @param point 终点
/// @param radius 椭圆半径
/// @param rotation 椭圆旋转角度
/// @param clockwise 顺时针 or 逆时针
/// @param is_small 是否取小于 180° 的弧
/// @brief 添加弧线
/// @param point 终点
/// @param radius 椭圆半径
/// @param rotation 椭圆旋转角度
/// @param clockwise 顺时针 or 逆时针
/// @param is_small 是否取小于 180° 的弧
void AddArc(const Point& point, const Size& radius, float rotation, bool clockwise = true, bool is_small = true);
/// \~chinese
/// @brief 合并形状
/// @param shape_a 输入的形状A
/// @param shape_b 输入的形状B
/// @param mode 合并方式
/// @param matrix 应用到输入形状B上的二维变换
/// @return 返回合并后的形状
/// @brief 合并形状
/// @param shape_a 输入的形状A
/// @param shape_b 输入的形状B
/// @param mode 合并方式
/// @param matrix 应用到输入形状B上的二维变换
/// @return 返回合并后的形状
static ShapePtr Combine(ShapePtr shape_a, ShapePtr shape_b, CombineMode mode, const Matrix3x2* matrix = nullptr);
/// \~chinese
/// @brief 设置生成的形状
/// @note 应由系统调用该函数
/// @brief 设置生成的形状
/// @note 应由系统调用该函数
void SetShape(ShapePtr shape);
private:
/// \~chinese
/// @brief 打开输入流
/// @note 应由系统调用该函数
/// @brief 打开输入流
/// @note 应由系统调用该函数
void OpenStream();
/// \~chinese
/// @brief 关闭输入流
/// @note 应由系统调用该函数
/// @brief 关闭输入流
/// @note 应由系统调用该函数
void CloseStream();
/// \~chinese
/// @brief 输入流是否已经打开
/// @note 应由系统调用该函数
/// @brief 输入流是否已经打开
/// @note 应由系统调用该函数
bool IsStreamOpened() const;
private:

View File

@ -32,80 +32,80 @@ KGE_DECLARE_SMART_PTR(StrokeStyle);
*/
/// \~chinese
/// @brief 线条端点样式
/// @details 线条端点样式表示线段端点部分的形状
/// @brief 线条端点样式
/// @details 线条端点样式表示线段端点部分的形状
enum class CapStyle
{
Flat, ///< 扁端点
Square, ///< 方形端点,方形突出部分等于线段宽度的一半
Round, ///< 圆形端点,圆直径等于线段宽度
Triangle, ///< 三角样式,三角斜边长度等于线段宽度
Flat, ///< 扁端点
Square, ///< 方形端点,方形突出部分等于线段宽度的一半
Round, ///< 圆形端点,圆直径等于线段宽度
Triangle, ///< 三角样式,三角斜边长度等于线段宽度
};
/// \~chinese
/// @brief 线条交点样式
/// @details 线条交点样式表示两条线相交部分的形状
/// @brief 线条交点样式
/// @details 线条交点样式表示两条线相交部分的形状
enum class LineJoinStyle
{
Miter, ///< 斜切样式
Bevel, ///< 斜角样式
Round ///< 圆角样式
Miter, ///< 斜切样式
Bevel, ///< 斜角样式
Round ///< 圆角样式
};
/// \~chinese
/// @brief 线条虚线样式
/// @details 线条虚线样式表示线段的间隙
/// @brief 线条虚线样式
/// @details 线条虚线样式表示线段的间隙
enum class DashStyle
{
Solid, ///< 无间断的实线
Dash, ///< 斜角样式
Dot, ///< 圆角样式
DashDot, ///< 圆角样式
DashDotDot, ///< 圆角样式
Solid, ///< 无间断的实线
Dash, ///< 斜角样式
Dot, ///< 圆角样式
DashDot, ///< 圆角样式
DashDotDot, ///< 圆角样式
};
/// \~chinese
/// @brief 线条样式
/// @brief 线条样式
class StrokeStyle : public NativeObject
{
public:
/// \~chinese
/// @brief 创建线条样式
/// @param width 线条宽度
/// @param cap 线条端点样式
/// @param line_join 线条交点样式
/// @brief 创建线条样式
/// @param width 线条宽度
/// @param cap 线条端点样式
/// @param line_join 线条交点样式
static StrokeStylePtr Create(float width, CapStyle cap = CapStyle::Flat,
LineJoinStyle line_join = LineJoinStyle::Miter);
/// \~chinese
/// @brief 创建线条样式
/// @param width 线条宽度
/// @param cap 线条端点样式
/// @param line_join 线条交点样式
/// @param dash 线条虚线样式
/// @param dash_offset 线条虚线偏移量
/// @brief 创建线条样式
/// @param width 线条宽度
/// @param cap 线条端点样式
/// @param line_join 线条交点样式
/// @param dash 线条虚线样式
/// @param dash_offset 线条虚线偏移量
static StrokeStylePtr Create(float width, CapStyle cap, LineJoinStyle line_join, DashStyle dash,
float dash_offset = 0.0f);
/// \~chinese
/// @brief 创建线条样式
/// @param width 线条宽度
/// @param cap 线条端点样式
/// @param line_join 线条交点样式
/// @param dash_array 线条虚线的长度与间隙数组
/// @param dash_size 线条虚线数组大小
/// @param dash_offset 线条虚线偏移量
/// @brief 创建线条样式
/// @param width 线条宽度
/// @param cap 线条端点样式
/// @param line_join 线条交点样式
/// @param dash_array 线条虚线的长度与间隙数组
/// @param dash_size 线条虚线数组大小
/// @param dash_offset 线条虚线偏移量
static StrokeStylePtr Create(float width, CapStyle cap, LineJoinStyle line_join, const float* dash_array,
size_t dash_size, float dash_offset = 0.0f);
/// \~chinese
/// @brief 创建线条样式
/// @tparam _DashSize 线条虚线数组大小
/// @param width 线条宽度
/// @param cap 线条端点样式
/// @param line_join 线条交点样式
/// @param dash_array 线条虚线的长度与间隙数组
/// @param dash_offset 线条虚线偏移量
/// @brief 创建线条样式
/// @tparam _DashSize 线条虚线数组大小
/// @param width 线条宽度
/// @param cap 线条端点样式
/// @param line_join 线条交点样式
/// @param dash_array 线条虚线的长度与间隙数组
/// @param dash_offset 线条虚线偏移量
template <size_t _DashSize>
static inline StrokeStylePtr Create(float width, CapStyle cap, LineJoinStyle line_join,
float (&dash_array)[_DashSize], float dash_offset = 0.0f)
@ -116,59 +116,59 @@ public:
StrokeStyle();
/// \~chinese
/// @brief 获取线条宽度
/// @param width 线条宽度
/// @brief 获取线条宽度
/// @param width 线条宽度
float GetStrokeWidth() const;
/// \~chinese
/// @brief 获取线条端点样式
/// @brief 获取线条端点样式
CapStyle GetCapStyle() const;
/// \~chinese
/// @brief 获取线条交点样式
/// @brief 获取线条交点样式
LineJoinStyle GetLineJoinStyle() const;
/// \~chinese
/// @brief 获取线条虚线的长度与间隙数组
/// @brief 获取线条虚线的长度与间隙数组
const Vector<float>& GetDashArray() const;
/// \~chinese
/// @brief 获取虚线偏移量
/// @brief 获取虚线偏移量
float GetDashOffset() const;
/// \~chinese
/// @brief 设置线条宽度
/// @param width 线条宽度
/// @brief 设置线条宽度
/// @param width 线条宽度
void SetStrokeWidth(float width);
/// \~chinese
/// @brief 设置线条端点样式
/// @brief 设置线条端点样式
void SetCapStyle(CapStyle cap);
/// \~chinese
/// @brief 设置线条交点样式
/// @brief 设置线条交点样式
void SetLineJoinStyle(LineJoinStyle line_join);
/// \~chinese
/// @brief 设置虚线样式
/// @param dash_style 线条虚线样式
/// @brief 设置虚线样式
/// @param dash_style 线条虚线样式
void SetDashStyle(DashStyle dash_style);
/// \~chinese
/// @brief 设置虚线样式
/// @param dash_array 线条虚线的长度与间隙数组
/// @brief 设置虚线样式
/// @param dash_array 线条虚线的长度与间隙数组
void SetDashStyle(const Vector<float>& dash_array);
/// \~chinese
/// @brief 设置虚线样式
/// @param dash_array 线条虚线的长度与间隙数组
/// @param dash_size 线条虚线数组大小
/// @brief 设置虚线样式
/// @param dash_array 线条虚线的长度与间隙数组
/// @param dash_size 线条虚线数组大小
void SetDashStyle(const float* dash_array, size_t dash_size);
/// \~chinese
/// @brief 设置虚线样式
/// @tparam _DashSize 线条虚线数组大小
/// @param dash_array 线条虚线的长度与间隙数组
/// @brief 设置虚线样式
/// @tparam _DashSize 线条虚线数组大小
/// @param dash_array 线条虚线的长度与间隙数组
template <size_t _DashSize>
inline void SetDashStyle(float (&dash_array)[_DashSize])
{
@ -176,8 +176,8 @@ public:
}
/// \~chinese
/// @brief 设置虚线偏移量
/// @param dash_offset 线条虚线偏移量
/// @brief 设置虚线偏移量
/// @param dash_offset 线条虚线偏移量
void SetDashOffset(float dash_offset);
private:

View File

@ -34,186 +34,186 @@ KGE_DECLARE_SMART_PTR(TextLayout);
*/
/// \~chinese
/// @brief 文本布局
/// @brief 文本布局
class KGE_API TextLayout : public NativeObject
{
public:
/// \~chinese
/// @brief 创建文本布局
/// @brief 创建文本布局
static TextLayoutPtr Create();
/// \~chinese
/// @brief 创建文本布局
/// @param content 文字内容
/// @param style 文本样式
/// @brief 创建文本布局
/// @param content 文字内容
/// @param style 文本样式
static TextLayoutPtr Create(const String& content, const TextStyle& style);
/// \~chinese
/// @brief 构造空的文本布局
/// @brief 构造空的文本布局
TextLayout();
/// \~chinese
/// @brief 文本布局是否陈旧
/// @brief 文本布局是否陈旧
bool IsDirty() const;
/// \~chinese
/// @brief 清空文本布局
/// @brief 清空文本布局
void Clear();
/// \~chinese
/// @brief 重设文本布局
/// @param style 文本样式
/// @brief 重设文本布局
/// @param style 文本样式
void Reset(const TextStyle& style);
/// \~chinese
/// @brief 重设文本布局
/// @param content 文字内容
/// @param style 文本样式
/// @brief 重设文本布局
/// @param content 文字内容
/// @param style 文本样式
void Reset(const String& content, const TextStyle& style);
/// \~chinese
/// @brief 获取文字内容
/// @brief 获取文字内容
String GetContent() const;
/// \~chinese
/// @brief 获取文字内容的长度
/// @brief 获取文字内容的长度
uint32_t GetContentLength() const;
/// \~chinese
/// @brief 获取文本布局大小
/// @brief 获取文本布局大小
Size GetSize() const;
/// \~chinese
/// @brief 获取文本行数
/// @brief 获取文本行数
uint32_t GetLineCount() const;
/// \~chinese
/// @brief 获取默认填充画刷
/// @brief 获取默认填充画刷
BrushPtr GetDefaultFillBrush() const;
/// \~chinese
/// @brief 获取默认描边画刷
/// @brief 获取默认描边画刷
BrushPtr GetDefaultOutlineBrush() const;
/// \~chinese
/// @brief 获取默认描边线条样式
/// @brief 获取默认描边线条样式
StrokeStylePtr GetDefaultOutlineStrokeStyle() const;
/// \~chinese
/// @brief 文字范围
/// @brief 文字范围
struct TextRange
{
uint32_t start; ///< 起始位置
uint32_t length; ///< 长度
uint32_t start; ///< 起始位置
uint32_t length; ///< 长度
};
/// \~chinese
/// @brief 设置字体
/// @param font 字体
/// @param range 文字范围
/// @brief 设置字体
/// @param font 字体
/// @param range 文字范围
void SetFont(FontPtr font, TextRange range);
/// \~chinese
/// @brief 设置字体族
/// @param family 字体族
/// @param range 文字范围
/// @brief 设置字体族
/// @param family 字体族
/// @param range 文字范围
void SetFontFamily(const String& family, TextRange range);
/// \~chinese
/// @brief 设置字号(默认值为 18
/// @param size 字号
/// @param range 文字范围
/// @brief 设置字号(默认值为 18
/// @param size 字号
/// @param range 文字范围
void SetFontSize(float size, TextRange range);
/// \~chinese
/// @brief 设置字体粗细值(默认值为 FontWeight::Normal
/// @param weight 粗细值
/// @param range 文字范围
/// @brief 设置字体粗细值(默认值为 FontWeight::Normal
/// @param weight 粗细值
/// @param range 文字范围
void SetFontWeight(uint32_t weight, TextRange range);
/// \~chinese
/// @brief 设置文字斜体(默认值为 false
/// @param italic 是否是斜体
/// @param range 文字范围
/// @brief 设置文字斜体(默认值为 false
/// @param italic 是否是斜体
/// @param range 文字范围
void SetItalic(bool italic, TextRange range);
/// \~chinese
/// @brief 设置下划线
/// @param enable 是否显示下划线
/// @param range 文字范围
/// @brief 设置下划线
/// @param enable 是否显示下划线
/// @param range 文字范围
void SetUnderline(bool enable, TextRange range);
/// \~chinese
/// @brief 设置删除线
/// @param enable 是否显示删除线
/// @param range 文字范围
/// @brief 设置删除线
/// @param enable 是否显示删除线
/// @param range 文字范围
void SetStrikethrough(bool enable, TextRange range);
/// \~chinese
/// @brief 设置文字填充画刷,描边画刷和描边线宽
/// @param brush 画刷
/// @param range 文字范围
/// @brief 设置文字填充画刷,描边画刷和描边线宽
/// @param brush 画刷
/// @param range 文字范围
void SetFillBrush(BrushPtr brush, TextRange range);
/// \~chinese
/// @brief 设置文字描边画刷
/// @param brush 画刷
/// @param range 文字范围
/// @brief 设置文字描边画刷
/// @param brush 画刷
/// @param range 文字范围
void SetOutlineBrush(BrushPtr brush, TextRange range);
/// \~chinese
/// @brief 设置描边线条样式
/// @param stroke 线条样式
/// @param range 文字范围
/// @brief 设置描边线条样式
/// @param stroke 线条样式
/// @param range 文字范围
void SetOutlineStrokeStyle(StrokeStylePtr stroke, TextRange range);
/// \~chinese
/// @brief 设置对齐方式
/// @param align 对齐方式
/// @brief 设置对齐方式
/// @param align 对齐方式
void SetAlignment(TextAlign align);
/// \~chinese
/// @brief 设置文本自动换行的宽度
/// @brief 设置文本自动换行的宽度
void SetWrapWidth(float wrap_width);
/// \~chinese
/// @brief 设置行间距(默认为 0
/// @brief 设置行间距(默认为 0
void SetLineSpacing(float line_spacing);
/// \~chinese
/// @brief 设置默认文字填充画刷
/// @param brush 画刷
/// @brief 设置默认文字填充画刷
/// @param brush 画刷
void SetDefaultFillBrush(BrushPtr brush);
/// \~chinese
/// @brief 设置默认文字描边画刷
/// @param brush 画刷
/// @brief 设置默认文字描边画刷
/// @param brush 画刷
void SetDefaultOutlineBrush(BrushPtr brush);
/// \~chinese
/// @brief 设置默认描边线条样式
/// @param stroke 线条样式
/// @brief 设置默认描边线条样式
/// @param stroke 线条样式
void SetDefaultOutlineStrokeStyle(StrokeStylePtr stroke);
/// \~chinese
/// @brief 脏布局标志
/// @brief 脏布局标志
enum class DirtyFlag : uint8_t
{
Clean = 0, ///< 干净布局
Dirty = 1 << 0 ///< 脏布局
Clean = 0, ///< 干净布局
Dirty = 1 << 0 ///< 脏布局
};
/// \~chinese
/// @brief 获取脏布局标志
/// @brief 获取脏布局标志
DirtyFlag GetDirtyFlag() const;
/// \~chinese
/// @brief 设置脏布局标志
/// @brief 设置脏布局标志
void SetDirtyFlag(DirtyFlag flag);
/// \~chinese
/// @brief 更新脏布局
/// @return 是否需要更新
/// @brief 更新脏布局
/// @return 是否需要更新
bool UpdateWhenDirty();
private:

View File

@ -33,19 +33,19 @@ namespace kiwano
/**
* \~chinese
* @brief
* @brief
*/
enum class TextAlign
{
Left, ///< 左对齐
Right, ///< 右对齐
Center, ///< 居中对齐
Justified ///< 两端对齐
Left, ///< 左对齐
Right, ///< 右对齐
Center, ///< 居中对齐
Justified ///< 两端对齐
};
/**
* \~chinese
* @brief
* @brief
*/
struct FontWeight
{
@ -54,7 +54,7 @@ struct FontWeight
Thin = 100U,
ExtraLight = 200U,
Light = 300U,
Normal = 400U, ///< 正常
Normal = 400U, ///< 正常
Medium = 500U,
Bold = 700U,
ExtraBold = 800U,
@ -65,38 +65,38 @@ struct FontWeight
/**
* \~chinese
* @brief
* @brief
*/
class KGE_API TextStyle
{
public:
FontPtr font; ///< 字体
String font_family; ///< 字体族
float font_size; ///< 字号
uint32_t font_weight; ///< 粗细值
bool italic; ///< 是否斜体
TextAlign alignment; ///< 对齐方式
BrushPtr fill_brush; ///< 填充画刷
BrushPtr outline_brush; ///< 描边画刷
StrokeStylePtr outline_stroke; ///< 描边样式
float wrap_width; ///< 自动换行宽度
float line_spacing; ///< 行间距
bool show_underline; ///< 显示下划线
bool show_strikethrough; ///< 显示删除线
FontPtr font; ///< 字体
String font_family; ///< 字体族
float font_size; ///< 字号
uint32_t font_weight; ///< 粗细值
bool italic; ///< 是否斜体
TextAlign alignment; ///< 对齐方式
BrushPtr fill_brush; ///< 填充画刷
BrushPtr outline_brush; ///< 描边画刷
StrokeStylePtr outline_stroke; ///< 描边样式
float wrap_width; ///< 自动换行宽度
float line_spacing; ///< 行间距
bool show_underline; ///< 显示下划线
bool show_strikethrough; ///< 显示删除线
public:
/**
* \~chinese
* @brief
* @brief
*/
TextStyle();
/**
* \~chinese
* @brief
* @param font_family
* @param font_size
* @param font_weight
* @brief
* @param font_family
* @param font_size
* @param font_weight
*/
TextStyle(const String& font_family, float font_size, uint32_t font_weight = FontWeight::Normal);
};

Some files were not shown because too many files have changed in this diff Show More