100 lines
2.1 KiB
C++
100 lines
2.1 KiB
C++
/**
|
|
* @file Window.h
|
|
* @brief 跨模块窗口句柄对象与基础窗口操作接口。
|
|
* @details
|
|
* window 是平台层窗口对象的轻量包装,向上层提供:
|
|
* - 全屏切换、标题设置、尺寸调整;
|
|
* - 原生窗口句柄访问;
|
|
* - 关闭状态与尺寸查询。
|
|
* 具体平台行为由 PlatformWin32.cpp 等实现体完成。
|
|
*/
|
|
#pragma once
|
|
#include "CommonHeader.h"
|
|
|
|
|
|
namespace XEngine::platform {
|
|
/**
|
|
* @brief 窗口强类型标识符。
|
|
*/
|
|
DEFINE_TYPED_ID(window_id);
|
|
|
|
/**
|
|
* @brief 平台窗口句柄对象。
|
|
*/
|
|
class window
|
|
{
|
|
public:
|
|
/**
|
|
* @brief 由窗口 ID 构造句柄。
|
|
* @param id 窗口 ID。
|
|
*/
|
|
constexpr explicit window(window_id id) : _id{ id } {}
|
|
/**
|
|
* @brief 构造无效窗口句柄。
|
|
*/
|
|
constexpr window() = default;
|
|
/**
|
|
* @brief 获取窗口 ID。
|
|
* @return 窗口 ID。
|
|
*/
|
|
constexpr window_id get_id() const { return _id; }
|
|
/**
|
|
* @brief 判断窗口句柄是否有效。
|
|
* @return 有效返回 true。
|
|
*/
|
|
constexpr bool is_valid() const { return id::is_valid(_id); }
|
|
|
|
|
|
/**
|
|
* @brief 设置全屏状态。
|
|
* @param is_fullscreen true 表示全屏。
|
|
*/
|
|
void set_fullscreen(bool is_fullscreen) const;
|
|
/**
|
|
* @brief 查询是否全屏。
|
|
* @return 全屏返回 true。
|
|
*/
|
|
bool is_fullscreen() const;
|
|
/**
|
|
* @brief 获取原生窗口句柄。
|
|
* @return 平台句柄指针。
|
|
*/
|
|
void* handle() const;
|
|
/**
|
|
* @brief 设置窗口标题文本。
|
|
* @param caption 标题字符串。
|
|
*/
|
|
void set_caption(const wchar_t* caption) const;
|
|
/**
|
|
* @brief 获取窗口矩形坐标。
|
|
* @return 左上右下坐标向量。
|
|
*/
|
|
math::u32v4 size() const;
|
|
/**
|
|
* @brief 调整窗口大小。
|
|
* @param width 目标宽度。
|
|
* @param height 目标高度。
|
|
*/
|
|
void resize(u32 width, u32 height)const;
|
|
/**
|
|
* @brief 获取窗口宽度。
|
|
* @return 宽度像素值。
|
|
*/
|
|
u32 width()const;
|
|
/**
|
|
* @brief 获取窗口高度。
|
|
* @return 高度像素值。
|
|
*/
|
|
u32 height()const;
|
|
/**
|
|
* @brief 查询窗口是否已关闭。
|
|
* @return 已关闭返回 true。
|
|
*/
|
|
bool is_closed()const;
|
|
|
|
private:
|
|
window_id _id{ id::invalid_id };
|
|
|
|
};
|
|
}
|