消除警告

This commit is contained in:
Nanako 2025-04-21 23:29:13 +08:00
parent 21a12b257f
commit 057967a5c9
18 changed files with 776 additions and 852 deletions

View File

@ -23,7 +23,7 @@ add_definitions(-DMIRAGE_HDR_FORMAT=${MIRAGE_HDR_FORMAT} -DMIRAGE_PIXEL_FORMAT=$
# CMAKE_CURRENT_SOURCE_DIR CMakeLists.txt # CMAKE_CURRENT_SOURCE_DIR CMakeLists.txt
# 使 PARENT_SCOPE 使 CMakeLists.txt # 使 PARENT_SCOPE 使 CMakeLists.txt
set(MIRAGE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(MIRAGE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "mirage 项目根源目录 MIRAGE_ROOT_DIR 设置为: ${MIRAGE_ROOT_DIR}") message(STATUS "mirage 项目根源目录 (MIRAGE_ROOT_DIR) 设置为: ${MIRAGE_ROOT_DIR}")
include(cmake/retrieve_files.cmake) include(cmake/retrieve_files.cmake)
include(cmake/detect_os.cmake) include(cmake/detect_os.cmake)

View File

@ -12,22 +12,76 @@ file(REMOVE ${SHADER_PATH_FILE})
file(WRITE ${SHADER_PATH_FILE} "") file(WRITE ${SHADER_PATH_FILE} "")
# #
# :
# path: .slang
# :
# 1. 将路径转换为适合目标系统的格式 (特别是处理 Cygwin)
# 2. SHADER_PATH_FILE
# 3. .slang
# 4. .slang CMake
# 便
# :
# - 使 CMAKE_BINARY_DIR SHADER_PATH_FILE
# : set(SHADER_PATH_FILE ${CMAKE_BINARY_DIR}/shader_paths.txt)
# - SHADER_PATH_FILE 使
# ( Cygwin Windows )
function(add_mirage_shader_directory path) function(add_mirage_shader_directory path)
# shader_paths.txt # SHADER_PATH_FILE
file(APPEND ${SHADER_PATH_FILE} "${path}\n") if(NOT DEFINED SHADER_PATH_FILE)
message(FATAL_ERROR "**错误**: SHADER_PATH_FILE 变量未定义。请在使用 add_mirage_shader_directory 前设置此变量。")
endif()
# , compile_shaders #
file(GLOB_RECURSE SHADER_FILES "${path}/*.slang") get_filename_component(abs_path ${path} ABSOLUTE)
# shader #
set(path_to_write ${abs_path})
# cygwin, Windows
if (CYGWIN)
message(STATUS "检测到 Cygwin 环境,尝试使用 cygpath 转换路径: ${abs_path}")
# ****: 使 cygpath -w Cygwin Windows
execute_process(
COMMAND cygpath -w ${abs_path}
OUTPUT_VARIABLE path_windows
OUTPUT_STRIP_TRAILING_WHITESPACE #
RESULT_VARIABLE cygpath_result
ERROR_QUIET # cygpath result
)
if(cygpath_result EQUAL 0 AND path_windows) # cygpath
#
set(path_to_write ${path_windows})
message(STATUS "路径已成功转换为 Windows 格式: ${path_to_write}")
else()
# cygpath 退
message(WARNING "无法使用 cygpath 转换路径 ${abs_path}。将使用原始路径。请确保 cygpath 在系统 PATH 中。")
# path_to_write abs_path
endif()
endif()
# shader_paths.txt
# ****: ${SHADER_PATH_FILE}
file(APPEND ${SHADER_PATH_FILE} "${path_to_write}\n")
# .slang
# ****: ${abs_path} *.slang
file(GLOB_RECURSE SHADER_FILES LIST_DIRECTORIES false "${abs_path}/*.slang")
# shaderCMake
# ****: CMake
foreach(SHADER_FILE ${SHADER_FILES}) foreach(SHADER_FILE ${SHADER_FILES})
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${SHADER_FILE}) get_filename_component(ABS_SHADER_FILE ${SHADER_FILE} ABSOLUTE)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${ABS_SHADER_FILE})
endforeach() endforeach()
# ****:
message(STATUS "添加着色器源文件目录: ${path_to_write}")
endfunction() endfunction()
set(SHADER_COMPILE_ARGS "") set(SHADER_COMPILE_ARGS "")
set(SHADER_SHDC "") set(SHADER_SHDC "")
if (WIN32) if (WIN32 OR CYGWIN)
list(APPEND SHADER_COMPILE_ARGS "--hlsl") list(APPEND SHADER_COMPILE_ARGS "--hlsl")
set(SHADER_SHDC ${MIRAGE_ROOT_DIR}/tools/win_mirage_shdc.exe) set(SHADER_SHDC ${MIRAGE_ROOT_DIR}/tools/win_mirage_shdc.exe)
elseif (APPLE) elseif (APPLE)
@ -38,6 +92,8 @@ else()
set(SHADER_SHDC ${MIRAGE_ROOT_DIR}/tools/linux_mirage_shdc) set(SHADER_SHDC ${MIRAGE_ROOT_DIR}/tools/linux_mirage_shdc)
endif() endif()
message(STATUS "使用着色器编译器: ${SHADER_SHDC}")
# Debug, --debug # Debug, --debug
if (CMAKE_BUILD_TYPE STREQUAL "Debug") if (CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND SHADER_COMPILE_ARGS "--debug") list(APPEND SHADER_COMPILE_ARGS "--debug")
@ -53,7 +109,7 @@ add_custom_target(compile_shaders ALL
VERBATIM VERBATIM
) )
# #
function(add_shader_dependencies target) function(add_shader_dependencies target)
add_dependencies(${target} compile_shaders) add_dependencies(${target} compile_shaders)
endfunction() endfunction()

View File

@ -1,73 +1,131 @@
# DetectOS.cmake
#
function(add_os_definitions target) function(add_os_definitions target)
# 0 # target
set(PLATFORMS MIRAGE_PLATFORM_WINDOWS MIRAGE_PLATFORM_MACOS MIRAGE_PLATFORM_LINUX MIRAGE_PLATFORM_FREEBSD MIRAGE_PLATFORM_IOS MIRAGE_PLATFORM_ANDROID) if(NOT target)
message(FATAL_ERROR "函数 add_os_definitions 需要一个 target 参数。")
# 1 return()
if(WIN32)
target_compile_definitions(${target} PUBLIC MIRAGE_PLATFORM_WINDOWS=1)
message(STATUS "检测到 Windows 操作系统")
list(REMOVE_ITEM PLATFORMS MIRAGE_PLATFORM_WINDOWS)
elseif(APPLE AND NOT IOS)
target_compile_definitions(${target} PUBLIC MIRAGE_PLATFORM_MACOS=1)
message(STATUS "检测到 macOS 操作系统")
list(REMOVE_ITEM PLATFORMS MIRAGE_PLATFORM_MACOS)
elseif(UNIX)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_compile_definitions(${target} PUBLIC MIRAGE_PLATFORM_LINUX=1)
message(STATUS "检测到 Linux 操作系统")
list(REMOVE_ITEM PLATFORMS MIRAGE_PLATFORM_LINUX)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
target_compile_definitions(${target} PUBLIC MIRAGE_PLATFORM_FREEBSD=1)
message(STATUS "检测到 FreeBSD 操作系统")
list(REMOVE_ITEM PLATFORMS MIRAGE_PLATFORM_FREEBSD)
else()
message(WARNING "检测到未知的 类Unix 操作系统")
endif() endif()
# --- 1: ---
# 0
set(mirage_def_windows 0)
set(mirage_def_macos 0)
set(mirage_def_linux 0)
set(mirage_def_freebsd 0)
set(mirage_def_ios 0)
set(mirage_def_android 0)
set(mirage_def_cygwin 0)
set(mirage_def_unix 0)
set(mirage_def_posix 0)
set(mirage_def_mobile 0)
set(mirage_def_arch_64bit 0)
set(mirage_def_arch_32bit 0)
# -- --
#
if(CYGWIN)
# Cygwin Windows Unix
set(mirage_def_windows 1) # Windows
set(mirage_def_cygwin 1) # Cygwin
set(mirage_def_unix 1) # Unix API
set(mirage_def_posix 1) # POSIX API
message(STATUS "检测到 **Cygwin** 环境 (运行于 Windows)")
elseif(WIN32)
# Cygwin Windows 环境 (MSVC, MinGW, etc.)
set(mirage_def_windows 1)
message(STATUS "检测到 **Windows** 操作系统 (非 Cygwin)")
elseif(ANDROID) elseif(ANDROID)
target_compile_definitions(${target} PUBLIC MIRAGE_PLATFORM_ANDROID=1) # Android 平台 (通常需要特定工具链设置 ANDROID 变量)
message(STATUS "检测到 Android 操作系统") set(mirage_def_android 1)
list(REMOVE_ITEM PLATFORMS MIRAGE_PLATFORM_ANDROID) set(mirage_def_unix 1) # Android NDK Unix
set(mirage_def_posix 1) # NDK POSIX API
set(mirage_def_mobile 1) #
message(STATUS "检测到 **Android** 操作系统")
elseif(IOS) elseif(IOS)
target_compile_definitions(${target} PUBLIC MIRAGE_PLATFORM_IOS=1) # iOS 平台 (通常需要特定工具链设置 IOS 变量)
message(STATUS "检测到 iOS 操作系统") # APPLE iOS APPLE TRUE
list(REMOVE_ITEM PLATFORMS MIRAGE_PLATFORM_IOS) set(mirage_def_ios 1)
set(mirage_def_unix 1) # iOS (Darwin) Unix
set(mirage_def_posix 1) # POSIX API
set(mirage_def_mobile 1) #
message(STATUS "检测到 **iOS** 操作系统")
elseif(APPLE)
# iOS macOS
set(mirage_def_macos 1)
set(mirage_def_unix 1) # macOS (Darwin) Unix
set(mirage_def_posix 1) # POSIX API
message(STATUS "检测到 **macOS** 操作系统")
elseif(UNIX)
# Apple, Android, Cygwin Unix-like
set(mirage_def_unix 1)
set(mirage_def_posix 1)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(mirage_def_linux 1)
message(STATUS "检测到 **Linux** 操作系统")
elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(mirage_def_freebsd 1)
message(STATUS "检测到 **FreeBSD** 操作系统")
else() else()
message(WARNING "检测到未知的操作系统") message(WARNING "检测到未知的 类Unix 操作系统: ${CMAKE_SYSTEM_NAME}")
endif()
else()
message(WARNING "检测到未知的操作系统: ${CMAKE_SYSTEM_NAME}")
endif() endif()
foreach(PLATFORM ${PLATFORMS}) # -- --
target_compile_definitions(${target} PUBLIC ${PLATFORM}=0)
endforeach()
#
if(CMAKE_SIZEOF_VOID_P EQUAL 8) if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_compile_definitions(${target} PUBLIC MIRAGE_PLATFORM_ARCH_64BIT=1 MIRAGE_PLATFORM_ARCH_32BIT=0) set(mirage_def_arch_64bit 1)
message(STATUS "检测到 64-bit 架构") set(mirage_def_arch_32bit 0) # 0
message(STATUS "检测到 **64-bit** 架构")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(mirage_def_arch_64bit 0) # 0
set(mirage_def_arch_32bit 1)
message(STATUS "检测到 **32-bit** 架构")
else() else()
target_compile_definitions(${target} PUBLIC MIRAGE_PLATFORM_ARCH_64BIT=0 MIRAGE_PLATFORM_ARCH_32BIT=1) # 0
message(STATUS "检测到 32-bit 架构") message(WARNING "无法明确检测到 32-bit 或 64-bit 架构 (CMAKE_SIZEOF_VOID_P = ${CMAKE_SIZEOF_VOID_P})。将两者都设置为 0。")
endif() endif()
# UNIX # --- 2: ---
if(UNIX) set(definitions_list "") #
target_compile_definitions(${target} PUBLIC MIRAGE_PLATFORM_UNIX=1)
else() #
target_compile_definitions(${target} PUBLIC MIRAGE_PLATFORM_UNIX=0) list(APPEND definitions_list "MIRAGE_PLATFORM_WINDOWS=${mirage_def_windows}")
list(APPEND definitions_list "MIRAGE_PLATFORM_MACOS=${mirage_def_macos}")
list(APPEND definitions_list "MIRAGE_PLATFORM_LINUX=${mirage_def_linux}")
list(APPEND definitions_list "MIRAGE_PLATFORM_FREEBSD=${mirage_def_freebsd}")
list(APPEND definitions_list "MIRAGE_PLATFORM_IOS=${mirage_def_ios}")
list(APPEND definitions_list "MIRAGE_PLATFORM_ANDROID=${mirage_def_android}")
list(APPEND definitions_list "MIRAGE_PLATFORM_CYGWIN=${mirage_def_cygwin}")
#
list(APPEND definitions_list "MIRAGE_PLATFORM_ARCH_64BIT=${mirage_def_arch_64bit}")
list(APPEND definitions_list "MIRAGE_PLATFORM_ARCH_32BIT=${mirage_def_arch_32bit}")
#
list(APPEND definitions_list "MIRAGE_PLATFORM_UNIX=${mirage_def_unix}")
list(APPEND definitions_list "MIRAGE_PLATFORM_POSIX=${mirage_def_posix}")
list(APPEND definitions_list "MIRAGE_PLATFORM_IS_MOBILE=${mirage_def_mobile}")
# --- 3: ---
# **使**
if(definitions_list) #
target_compile_definitions(${target} PUBLIC ${definitions_list})
endif() endif()
# POSIX # mirage_def_* unset
if(UNIX OR APPLE)
target_compile_definitions(${target} PUBLIC MIRAGE_PLATFORM_POSIX=1)
else()
target_compile_definitions(${target} PUBLIC MIRAGE_PLATFORM_POSIX=0)
endif()
# IS_MOBILE
if(ANDROID OR IOS)
target_compile_definitions(${target} PUBLIC MIRAGE_PLATFORM_IS_MOBILE=1)
else()
target_compile_definitions(${target} PUBLIC MIRAGE_PLATFORM_IS_MOBILE=0)
endif()
endfunction() endfunction()
# --- 使 ---
# project(MyProject)
# add_executable(my_app main.c)
#
# # my_app
# add_os_definitions(my_app)
#
# #
# # add_library(my_lib STATIC my_lib.c)
# # add_os_definitions(my_lib)

View File

@ -1,56 +1,85 @@
# C++
# standard: C++ 标准版本 (例如 11, 14, 17, 20, 23)
function(set_cpp_standard standard) function(set_cpp_standard standard)
# # --- ---
set(VALID_STANDARDS 11 14 17 20 23) set(VALID_STANDARDS 11 14 17 20 23) # C++
if(NOT ${standard} IN_LIST VALID_STANDARDS) list(FIND VALID_STANDARDS ${standard} _standard_index) # standard
message(WARNING "非标准 C++ 版本: ${standard},支持的版本有: ${VALID_STANDARDS}") if(_standard_index EQUAL -1) #
message(WARNING "**非标准 C++ 版本**: ${standard}。支持的版本有: ${VALID_STANDARDS}")
#
# message(FATAL_ERROR "不支持的 C++ 标准: ${standard}")
# set(standard 17) # C++17
# message(WARNING "已将 C++ 标准设置为默认值: ${standard}")
endif() endif()
# C++ # --- C++ ---
# C++ 使 target
set(CMAKE_CXX_STANDARD ${standard} PARENT_SCOPE) set(CMAKE_CXX_STANDARD ${standard} PARENT_SCOPE)
# # ****
set(CMAKE_CXX_STANDARD_REQUIRED ON PARENT_SCOPE) set(CMAKE_CXX_STANDARD_REQUIRED ON PARENT_SCOPE)
# 使 # ****使 C++
set(CMAKE_CXX_EXTENSIONS OFF PARENT_SCOPE) set(CMAKE_CXX_EXTENSIONS OFF PARENT_SCOPE)
# --- ---
if(WIN32) if(WIN32)
# Windows # Windows UNICODE
add_definitions(-DUNICODE -D_UNICODE) add_definitions(-DUNICODE -D_UNICODE)
# WIN32_LEAN_AND_MEAN Windows # WIN32_LEAN_AND_MEAN Windows
# add_definitions(-DWIN32_LEAN_AND_MEAN) # add_definitions(-DWIN32_LEAN_AND_MEAN)
message(STATUS "为 Windows 添加 UNICODE 定义")
endif() endif()
# --- ---
if(MSVC) if(MSVC)
# utf-8 # ** UTF-8**
add_compile_options(/utf-8) add_compile_options(/utf-8)
# MSVC __cplusplus # ** MSVC __cplusplus **便 C++
add_compile_options(/Zc:__cplusplus) add_compile_options(/Zc:__cplusplus)
# MSVC # ** W4** ()
add_compile_options(/W4) add_compile_options(/W4)
# **禁用未使用的形参警告 (C4100)** # **C4100 使** ()
add_compile_options(/wd4100) add_compile_options(/wd4100)
# C4996 使用了被标记为否决的函数或变量 (例如一些旧的 CRT 函数)
add_compile_options(/wd4996)
message(STATUS "为 MSVC 添加特定编译选项: /utf-8 /Zc:__cplusplus /W4 /wd4100 /wd4996")
endif() endif()
# GCC/Clang # GCC/Clang
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# ****
add_compile_options(-Wall -Wextra) add_compile_options(-Wall -Wextra)
# 使 # **使** ( MSVC /wd4100 )
add_compile_options(-Wno-unused-parameter) add_compile_options(-Wno-unused-parameter)
# C++ # ** UTF-8** ( MSVC /utf-8)
if(${standard} GREATER 14) # 使 GREATER_EQUAL # UTF-8
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -finput-charset=UTF-8 -fexec-charset=UTF-8")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -finput-charset=UTF-8 -fexec-charset=UTF-8")
# C++ 标准添加特定警告 (C++17 及以上)
if(${standard} GREATER 14)
# ****
add_compile_options(-Wshadow -Wnon-virtual-dtor) add_compile_options(-Wshadow -Wnon-virtual-dtor)
message(STATUS "为 GCC/Clang (C++${CMAKE_CXX_STANDARD}) 添加额外警告: -Wshadow -Wnon-virtual-dtor")
endif() endif()
message(STATUS "为 GCC/Clang 添加特定编译选项: -Wall -Wextra -Wno-unused-parameter -finput-charset=UTF-8 -fexec-charset=UTF-8")
# : / UTF-8 输出显示通常还需要操作系统环境的配合 (例如 Linux/macOS 终端本身设置Windows下 chcp 65001)
endif() endif()
# MinGW, 使C++17, libstdc++exp # MinGW 特定设置 (通常在 Windows 上使用 GCC 工具链)
if(MINGW) if(MINGW)
message(STATUS "检测到 MinGW 编译器") message(STATUS "检测到 MinGW 编译器")
# # 使 C++17 , libstdc++exp <filesystem>
if(${standard} GREATER 14) # C++17 if(${standard} GREATER 14)
message(STATUS "为C++${standard}添加libstdc++exp库支持") message(STATUS "**为 MinGW C++${CMAKE_CXX_STANDARD} 添加 libstdc++fs 库依赖** (用于 <filesystem>)")
link_libraries(-lstdc++exp) # MinGW -lstdc++fs
# link_libraries() target使 target_link_libraries()
# link_libraries() target
# stdc++fs MinGW <filesystem>
link_libraries(-lstdc++fs)
# -lstdc++fs 退 -lstdc++exp
# link_libraries(-lstdc++exp)
endif() endif()
endif() endif()
message(STATUS "已设置C++${standard}标准") message(STATUS "**C++ 标准已设置为: c++${standard}**")
endfunction() endfunction()

View File

@ -314,4 +314,3 @@ function(add_resource_file)
endif() endif()
endfunction() endfunction()

View File

@ -1,6 +1,4 @@
#pragma once #pragma once
#include <mutex>
#include "misc/mirage_type.h" #include "misc/mirage_type.h"
#include "render/render_context.h" #include "render/render_context.h"

View File

@ -26,5 +26,5 @@ consteval auto operator"" _deg(const long double in_degree) {
* : auto angle = 90_deg; * : auto angle = 90_deg;
*/ */
consteval auto operator""_deg(const unsigned long long in_degree) { consteval auto operator""_deg(const unsigned long long in_degree) {
return in_degree * 3.1415926 / 180.0; return static_cast<double>(in_degree) * 3.1415926 / 180.0;
} }

File diff suppressed because it is too large Load Diff

View File

@ -64,7 +64,7 @@ mapped_file_unix& mapped_file_unix::operator=(mapped_file_unix&& other) noexcept
bool mapped_file_unix::map_file(const std::filesystem::path& filename) { bool mapped_file_unix::map_file(const std::filesystem::path& filename) {
cleanup(); cleanup();
std::string utf8_filename(filename.begin(), filename.end()); const std::string& utf8_filename = filename.string();
fd = open(utf8_filename.c_str(), O_RDONLY); fd = open(utf8_filename.c_str(), O_RDONLY);
if (fd == -1) { if (fd == -1) {
// 无法打开文件 // 无法打开文件

View File

@ -71,7 +71,7 @@ mapped_file_win& mapped_file_win::operator=(mapped_file_win&& other) noexcept {
bool mapped_file_win::map_file(const std::filesystem::path& filename) { bool mapped_file_win::map_file(const std::filesystem::path& filename) {
cleanup(); cleanup();
file_handle_ = CreateFileW( file_handle_ = CreateFile(
filename.c_str(), filename.c_str(),
GENERIC_READ, GENERIC_READ,
FILE_SHARE_READ, FILE_SHARE_READ,

View File

@ -113,7 +113,7 @@ enum class flow_direction_preference_t {
/** /**
* @brief * @brief
*/ */
inline static auto g_flow_direction = flow_direction_t::left_to_right; // inline static auto g_flow_direction = flow_direction_t::left_to_right;
//-------------- 几何和渲染结构体 -------------- //-------------- 几何和渲染结构体 --------------
@ -304,16 +304,16 @@ struct mirage_vertex_param_t {
/** /**
* @brief - x,yz,w * @brief - x,yz,w
* @param a x和y分量 * @param in_a x和y分量
* @param b z和w分量 * @param in_b z和w分量
*/ */
template<typename A, typename B, template<typename A, typename B,
typename = decltype(std::declval<A>()[0]), typename = decltype(std::declval<A>()[0]),
typename = decltype(std::declval<B>()[0])> typename = decltype(std::declval<B>()[0])>
mirage_vertex_param_t(const A& a, const B& b) : x(static_cast<float>(a[0])), mirage_vertex_param_t(const A& in_a, const B& in_b) : x(static_cast<float>(in_a[0])),
y(static_cast<float>(a[1])), y(static_cast<float>(in_a[1])),
z(static_cast<float>(b[0])), z(static_cast<float>(in_b[0])),
w(static_cast<float>(b[1])) { w(static_cast<float>(in_b[1])) {
} }
//-------------- 辅助类型特征检测 -------------- //-------------- 辅助类型特征检测 --------------

View File

@ -49,11 +49,11 @@ struct char_key_t {
template<> template<>
struct std::hash<char_key_t> { struct std::hash<char_key_t> {
size_t operator()(const char_key_t& in_key) const { size_t operator()(const char_key_t& in_key) const {
std::hash<uint32_t> hash_fn; constexpr std::hash<uint32_t> hash_fn;
size_t hash = hash_fn(in_key.glyph_index); size_t hash_key = hash_fn(in_key.glyph_index);
hash ^= (uint64_t)in_key.font_face.get(); hash_key ^= reinterpret_cast<uint64_t>(in_key.font_face.get());
hash ^= std::hash<float>{}(in_key.font_size); hash_key ^= std::hash<float>{}(in_key.font_size);
return hash; return hash_key;
} }
}; };

View File

@ -11,11 +11,7 @@ bool mouse_tracking_ = FALSE;
std::vector<platform_window*> windows; std::vector<platform_window*> windows;
platform_window* get_window_from_hwnd(const HWND hwnd) { platform_window* get_window_from_hwnd(const HWND hwnd) {
for (const auto& window: windows) { for (const auto& window: windows) { if (window->get_window_handle() == hwnd) { return window; } }
if (window->get_window_handle() == hwnd) {
return window;
}
}
return nullptr; return nullptr;
} }
@ -23,7 +19,8 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
bool processed = false; bool processed = false;
// 窗口关闭事件 // 窗口关闭事件
if (uMsg == WM_CLOSE) { if (uMsg == WM_CLOSE) {
std::erase_if(windows, [hwnd](platform_window* window) { std::erase_if(windows,
[hwnd](platform_window* window) {
if (window->get_window_handle() == hwnd) { if (window->get_window_handle() == hwnd) {
window->close(); window->close();
return true; return true;
@ -41,7 +38,9 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
// 窗口移动事件 // 窗口移动事件
if (uMsg == WM_MOVE) { if (uMsg == WM_MOVE) {
if (const auto window = get_window_from_hwnd(hwnd)) { window->on_move(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); } if (const auto window = get_window_from_hwnd(hwnd)) {
window->on_move(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
}
processed = true; processed = true;
} }
@ -113,9 +112,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (uMsg == WM_MOUSELEAVE) { if (uMsg == WM_MOUSELEAVE) {
mouse_tracking_ = FALSE; mouse_tracking_ = FALSE;
if (const auto window = get_window_from_hwnd(hwnd)) { if (const auto window = get_window_from_hwnd(hwnd)) { window->handle_mouse_leave(); }
window->handle_mouse_leave();
}
processed = true; processed = true;
} }
@ -136,13 +133,19 @@ platform_window::platform_window(int32_t in_width, int32_t in_height, const wcha
RECT rect = { 0, 0, in_width, in_height }; RECT rect = { 0, 0, in_width, in_height };
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE); AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
window_handle_ = (void*)CreateWindowW( window_handle_ = static_cast<void*>(CreateWindowW(
L"mirage_window_class", in_title, L"mirage_window_class",
in_title,
WS_OVERLAPPEDWINDOW | WS_VISIBLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
rect.right - rect.left, rect.bottom - rect.top, CW_USEDEFAULT,
NULL, NULL, GetModuleHandleW(NULL), NULL rect.right - rect.left,
); rect.bottom - rect.top,
nullptr,
nullptr,
GetModuleHandleW(nullptr),
nullptr
));
if (!window_handle_) { if (!window_handle_) {
std::cerr << "Failed to create window" << std::endl; std::cerr << "Failed to create window" << std::endl;
@ -190,9 +193,9 @@ Eigen::Vector2i platform_window::get_window_size() const {
if (GetWindowRect(WINDOW_HANDLE, &rect)) { if (GetWindowRect(WINDOW_HANDLE, &rect)) {
int width = rect.right - rect.left; int width = rect.right - rect.left;
int height = rect.bottom - rect.top; int height = rect.bottom - rect.top;
return Eigen::Vector2i(width, height); return { width, height };
} }
return Eigen::Vector2i(0, 0); return { 0, 0 };
} }
Eigen::Vector2i platform_window::get_window_frame_size() const { Eigen::Vector2i platform_window::get_window_frame_size() const {
@ -201,14 +204,12 @@ Eigen::Vector2i platform_window::get_window_frame_size() const {
if (GetClientRect(WINDOW_HANDLE, &rect)) { if (GetClientRect(WINDOW_HANDLE, &rect)) {
int width = rect.right - rect.left; int width = rect.right - rect.left;
int height = rect.bottom - rect.top; int height = rect.bottom - rect.top;
return Eigen::Vector2i(width, height); return { width, height };
} }
return Eigen::Vector2i(0, 0); return { 0, 0 };
} }
float platform_window::get_window_dpi_scale() const { float platform_window::get_window_dpi_scale() const { return 1.f; }
return 1.f;
}
Eigen::Vector2i platform_window::get_window_position() const { Eigen::Vector2i platform_window::get_window_position() const {
RECT rect; RECT rect;
@ -219,55 +220,62 @@ Eigen::Vector2i platform_window::get_window_position() const {
void* platform_window::get_window_handle() const { return window_handle_; } void* platform_window::get_window_handle() const { return window_handle_; }
platform_window& platform_window::set_title(const wchar_t* title) { platform_window& platform_window::set_title(const wchar_t* title) {
SetWindowText(WINDOW_HANDLE, title); SetWindowTextW(WINDOW_HANDLE, title);
return *this; return *this;
} }
platform_window& platform_window::set_has_minimize_button(bool has_minimize_button) { platform_window& platform_window::set_has_minimize_button(bool has_minimize_button) {
auto style = GetWindowLong(WINDOW_HANDLE, GWL_STYLE); auto style = GetWindowLong(WINDOW_HANDLE, GWL_STYLE);
if (has_minimize_button) { style |= WS_MINIMIZEBOX; } else { style &= ~WS_MINIMIZEBOX; } if (has_minimize_button) { style |= WS_MINIMIZEBOX; }
else { style &= ~WS_MINIMIZEBOX; }
SetWindowLong(WINDOW_HANDLE, GWL_STYLE, style); SetWindowLong(WINDOW_HANDLE, GWL_STYLE, style);
return *this; return *this;
} }
platform_window& platform_window::set_has_maximize_button(bool has_maximize_button) { platform_window& platform_window::set_has_maximize_button(bool has_maximize_button) {
auto style = GetWindowLong(WINDOW_HANDLE, GWL_STYLE); auto style = GetWindowLong(WINDOW_HANDLE, GWL_STYLE);
if (has_maximize_button) { style |= WS_MAXIMIZEBOX; } else { style &= ~WS_MAXIMIZEBOX; } if (has_maximize_button) { style |= WS_MAXIMIZEBOX; }
else { style &= ~WS_MAXIMIZEBOX; }
SetWindowLong(WINDOW_HANDLE, GWL_STYLE, style); SetWindowLong(WINDOW_HANDLE, GWL_STYLE, style);
return *this; return *this;
} }
platform_window& platform_window::set_has_close_button(bool has_close_button) { platform_window& platform_window::set_has_close_button(bool has_close_button) {
auto style = GetWindowLong(WINDOW_HANDLE, GWL_STYLE); auto style = GetWindowLong(WINDOW_HANDLE, GWL_STYLE);
if (has_close_button) { style |= WS_SYSMENU; } else { style &= ~WS_SYSMENU; } if (has_close_button) { style |= WS_SYSMENU; }
else { style &= ~WS_SYSMENU; }
SetWindowLong(WINDOW_HANDLE, GWL_STYLE, style); SetWindowLong(WINDOW_HANDLE, GWL_STYLE, style);
return *this; return *this;
} }
platform_window& platform_window::set_has_border(bool has_border) { platform_window& platform_window::set_has_border(bool has_border) {
auto style = GetWindowLong(WINDOW_HANDLE, GWL_STYLE); auto style = GetWindowLong(WINDOW_HANDLE, GWL_STYLE);
if (has_border) { style |= WS_BORDER; } else { style &= ~WS_BORDER; } if (has_border) { style |= WS_BORDER; }
else { style &= ~WS_BORDER; }
SetWindowLong(WINDOW_HANDLE, GWL_STYLE, style); SetWindowLong(WINDOW_HANDLE, GWL_STYLE, style);
return *this; return *this;
} }
platform_window& platform_window::set_has_caption(bool has_caption) { platform_window& platform_window::set_has_caption(bool has_caption) {
auto style = GetWindowLong(WINDOW_HANDLE, GWL_STYLE); auto style = GetWindowLong(WINDOW_HANDLE, GWL_STYLE);
if (has_caption) { style |= WS_CAPTION; } else { style &= ~WS_CAPTION; } if (has_caption) { style |= WS_CAPTION; }
else { style &= ~WS_CAPTION; }
SetWindowLong(WINDOW_HANDLE, GWL_STYLE, style); SetWindowLong(WINDOW_HANDLE, GWL_STYLE, style);
return *this; return *this;
} }
platform_window& platform_window::set_has_resizable_border(bool has_resizable_border) { platform_window& platform_window::set_has_resizable_border(bool has_resizable_border) {
auto style = GetWindowLong(WINDOW_HANDLE, GWL_STYLE); auto style = GetWindowLong(WINDOW_HANDLE, GWL_STYLE);
if (has_resizable_border) { style |= WS_THICKFRAME; } else { style &= ~WS_THICKFRAME; } if (has_resizable_border) { style |= WS_THICKFRAME; }
else { style &= ~WS_THICKFRAME; }
SetWindowLong(WINDOW_HANDLE, GWL_STYLE, style); SetWindowLong(WINDOW_HANDLE, GWL_STYLE, style);
return *this; return *this;
} }
platform_window& platform_window::set_topmost(bool is_topmost) { platform_window& platform_window::set_topmost(bool is_topmost) {
auto style = GetWindowLong(WINDOW_HANDLE, GWL_EXSTYLE); auto style = GetWindowLong(WINDOW_HANDLE, GWL_EXSTYLE);
if (is_topmost) { style |= WS_EX_TOPMOST; } else { style &= ~WS_EX_TOPMOST; } if (is_topmost) { style |= WS_EX_TOPMOST; }
else { style &= ~WS_EX_TOPMOST; }
SetWindowLong(WINDOW_HANDLE, GWL_EXSTYLE, style); SetWindowLong(WINDOW_HANDLE, GWL_EXSTYLE, style);
return *this; return *this;
} }

View File

@ -41,15 +41,24 @@ bool windows_mirage_render_context::init() {
for (const auto& driver_type: driver_types) { for (const auto& driver_type: driver_types) {
hr = D3D11CreateDevice( hr = D3D11CreateDevice(
nullptr, // 使用默认适配器 nullptr,
driver_type, // 驱动类型 // 使用默认适配器
nullptr, // 软件栅格化模块句柄(仅用于软件设备) driver_type,
device_flags, // 设备创建标志 // 驱动类型
feature_levels, // 特性级别数组 nullptr,
ARRAYSIZE(feature_levels), // 特性级别数量 // 软件栅格化模块句柄(仅用于软件设备)
D3D11_SDK_VERSION, // SDK版本 device_flags,
&device, // 输出设备 // 设备创建标志
&feature_level, // 输出获取的特性级别 feature_levels,
// 特性级别数组
std::size(feature_levels),
// 特性级别数量
D3D11_SDK_VERSION,
// SDK版本
&device,
// 输出设备
&feature_level,
// 输出获取的特性级别
&device_context // 输出设备上下文 &device_context // 输出设备上下文
); );
@ -89,57 +98,46 @@ bool windows_mirage_render_context::init() {
// **获取适配器描述信息** // **获取适配器描述信息**
DXGI_ADAPTER_DESC adapter_desc; DXGI_ADAPTER_DESC adapter_desc;
hr = dxgi_adapter->GetDesc(&adapter_desc); hr = dxgi_adapter->GetDesc(&adapter_desc);
if (FAILED(hr)) { if (FAILED(hr)) { std::println(std::cerr, "mirage: 无法获取 DXGI 适配器描述信息. HRESULT: 0x{:#06x}", hr); }
std::println(std::cerr, "mirage: 无法获取 DXGI 适配器描述信息. HRESULT: 0x{:#06x}", hr);
}
struct dxgi_factory_func_data {
IID iid{};
std::string name;
};
#define DXGI_FUNC_DATA(dxgi_class) dxgi_factory_func_data{ __uuidof(dxgi_class), #dxgi_class }
const std::array func_datas = {
// **尝试获取最新的DXGI工厂版本 - 从最新的Factory6开始尝试** // **尝试获取最新的DXGI工厂版本 - 从最新的Factory6开始尝试**
// Windows 10 Fall Creators Update (1709)或更高版本支持 // Windows 10 Fall Creators Update (1709)或更高版本支持
hr = dxgi_adapter->GetParent(__uuidof(IDXGIFactory6), reinterpret_cast<void**>(&dxgi_factory)); DXGI_FUNC_DATA(IDXGIFactory6),
if (SUCCEEDED(hr)) {
std::println(std::cout, "mirage: 使用 DXGI Factory6");
} else {
// 尝试Factory5 - Windows 10 Anniversary Update (1607)或更高版本 // 尝试Factory5 - Windows 10 Anniversary Update (1607)或更高版本
hr = dxgi_adapter->GetParent(__uuidof(IDXGIFactory5), reinterpret_cast<void**>(&dxgi_factory)); DXGI_FUNC_DATA(IDXGIFactory5),
if (SUCCEEDED(hr)) {
std::println(std::cout, "mirage: 使用 DXGI Factory5");
} else {
// 尝试Factory4 - Windows 10初始版本 // 尝试Factory4 - Windows 10初始版本
hr = dxgi_adapter->GetParent(__uuidof(IDXGIFactory4), reinterpret_cast<void**>(&dxgi_factory)); DXGI_FUNC_DATA(IDXGIFactory4),
if (SUCCEEDED(hr)) {
std::println(std::cout, "mirage: 使用 DXGI Factory4");
} else {
// 尝试Factory3 - Windows 8.1 // 尝试Factory3 - Windows 8.1
hr = dxgi_adapter->GetParent(__uuidof(IDXGIFactory3), reinterpret_cast<void**>(&dxgi_factory)); DXGI_FUNC_DATA(IDXGIFactory3),
if (SUCCEEDED(hr)) {
std::println(std::cout, "mirage: 使用 DXGI Factory3");
} else {
// 尝试Factory2 - Windows 8支持FLIP模式交换链 // 尝试Factory2 - Windows 8支持FLIP模式交换链
hr = dxgi_adapter->GetParent(__uuidof(IDXGIFactory2), reinterpret_cast<void**>(&dxgi_factory)); DXGI_FUNC_DATA(IDXGIFactory2),
if (SUCCEEDED(hr)) {
std::println(std::cout, "mirage: 使用 DXGI Factory2");
} else {
// 回退到基本Factory1 - Windows 7 // 回退到基本Factory1 - Windows 7
hr = dxgi_adapter->GetParent(__uuidof(IDXGIFactory1), reinterpret_cast<void**>(&dxgi_factory)); DXGI_FUNC_DATA(IDXGIFactory1),
if (SUCCEEDED(hr)) {
std::println(std::cout, "mirage: 使用 DXGI Factory1");
} else {
// 最后尝试原始Factory // 最后尝试原始Factory
hr = dxgi_adapter->GetParent(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&dxgi_factory)); DXGI_FUNC_DATA(IDXGIFactory),
};
#undef DXGI_FUNC_DATA
// **获取DXGI工厂**
for (const auto& data: func_datas) {
hr = dxgi_adapter->GetParent(data.iid, reinterpret_cast<void**>(&dxgi_factory));
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
std::println(std::cout, "mirage: 使用 DXGI Factory"); std::println(std::cout, "mirage: 使用 {}", data.name);
} else { break;
}
}
if (FAILED(hr)) {
std::println(std::cerr, "mirage: 无法获取 DXGI Factory. HRESULT: 0x{:#06x}", hr); std::println(std::cerr, "mirage: 无法获取 DXGI Factory. HRESULT: 0x{:#06x}", hr);
dxgi_adapter->Release(); dxgi_adapter->Release();
cleanup(); cleanup();
return false; return false;
} }
}
}
}
}
}
}
// **检查是否支持撕裂(tearing)功能** // **检查是否支持撕裂(tearing)功能**
BOOL allow_tearing = FALSE; BOOL allow_tearing = FALSE;
@ -149,9 +147,7 @@ bool windows_mirage_render_context::init() {
if (SUCCEEDED(factory5->CheckFeatureSupport( if (SUCCEEDED(factory5->CheckFeatureSupport(
DXGI_FEATURE_PRESENT_ALLOW_TEARING, DXGI_FEATURE_PRESENT_ALLOW_TEARING,
&allow_tearing, &allow_tearing,
sizeof(allow_tearing)))) { sizeof(allow_tearing)))) { std::println(std::cout, "mirage: 防撕裂支持: {}", (bool) allow_tearing); }
std::println(std::cout, "mirage: 防撕裂支持: {}", (bool)allow_tearing);
}
factory5->Release(); factory5->Release();
} }
tearing_supported = allow_tearing == TRUE; tearing_supported = allow_tearing == TRUE;
@ -162,7 +158,7 @@ bool windows_mirage_render_context::init() {
// 输出初始化成功信息 // 输出初始化成功信息
std::println(std::cout, "mirage: 成功创建 D3D11 设备"); std::println(std::cout, "mirage: 成功创建 D3D11 设备");
{ {
std::u16string adapter_desc_str((const char16_t*)adapter_desc.Description); const std::u16string adapter_desc_str(reinterpret_cast<const char16_t*>(adapter_desc.Description));
auto str = utf8::utf16to8(adapter_desc_str); auto str = utf8::utf16to8(adapter_desc_str);
std::println(std::cout, "mirage: 适配器名称: {}", str); std::println(std::cout, "mirage: 适配器名称: {}", str);
} }
@ -171,11 +167,14 @@ bool windows_mirage_render_context::init() {
// 输出驱动类型信息 // 输出驱动类型信息
auto driver_type_str = "Unknown"; auto driver_type_str = "Unknown";
switch (used_driver_type) { switch (used_driver_type) {
case D3D_DRIVER_TYPE_HARDWARE: driver_type_str = "Hardware"; case D3D_DRIVER_TYPE_HARDWARE:
driver_type_str = "Hardware";
break; break;
case D3D_DRIVER_TYPE_WARP: driver_type_str = "WARP"; case D3D_DRIVER_TYPE_WARP:
driver_type_str = "WARP";
break; break;
case D3D_DRIVER_TYPE_REFERENCE: driver_type_str = "Reference"; case D3D_DRIVER_TYPE_REFERENCE:
driver_type_str = "Reference";
break; break;
default: ; default: ;
} }
@ -184,20 +183,25 @@ bool windows_mirage_render_context::init() {
// 输出特性级别信息 // 输出特性级别信息
auto feature_level_str = "Unknown"; auto feature_level_str = "Unknown";
switch (feature_level) { switch (feature_level) {
case D3D_FEATURE_LEVEL_11_1: feature_level_str = "11.1"; case D3D_FEATURE_LEVEL_11_1:
feature_level_str = "11.1";
break; break;
case D3D_FEATURE_LEVEL_11_0: feature_level_str = "11.0"; case D3D_FEATURE_LEVEL_11_0:
feature_level_str = "11.0";
break; break;
case D3D_FEATURE_LEVEL_10_1: feature_level_str = "10.1"; case D3D_FEATURE_LEVEL_10_1:
feature_level_str = "10.1";
break; break;
case D3D_FEATURE_LEVEL_10_0: feature_level_str = "10.0"; case D3D_FEATURE_LEVEL_10_0:
feature_level_str = "10.0";
break; break;
default: ; default: ;
} }
std::println(std::cout, "mirage: 使用特性级别: {}", feature_level_str); std::println(std::cout, "mirage: 使用特性级别: {}", feature_level_str);
return true; return true;
} catch (const std::exception& e) { }
catch (const std::exception& e) {
std::println(std::cerr, "mirage: D3D11初始化失败: {}", e.what()); std::println(std::cerr, "mirage: D3D11初始化失败: {}", e.what());
cleanup(); cleanup();
return false; return false;
@ -224,19 +228,16 @@ void windows_mirage_render_context::cleanup() {
} }
sg_environment windows_mirage_render_context::get_environment() { sg_environment windows_mirage_render_context::get_environment() {
return { sg_environment env{};
.d3d11 = { env.d3d11.device = device;
.device = device, env.d3d11.device_context = device_context;
.device_context = device_context return env;
}
};
} }
std::unique_ptr<mirage_window_state> windows_mirage_render_context::create_window_state(const Eigen::Vector2i& in_window_frame_size, void* in_window_handle) { std::unique_ptr<mirage_window_state> windows_mirage_render_context::create_window_state(
const Eigen::Vector2i& in_window_frame_size, void* in_window_handle) {
auto state = std::make_unique<windows_render_state>(); auto state = std::make_unique<windows_render_state>();
if (!state->init(device, dxgi_factory, in_window_frame_size, in_window_handle)) { if (!state->init(device, dxgi_factory, in_window_frame_size, in_window_handle)) { return {}; }
return {};
}
return state; return state;
} }

View File

@ -40,7 +40,7 @@ void mbutton::on_paint(mirage_paint_context& in_context) {
void mbutton::on_click(const Eigen::Vector2f& in_position, mouse_button in_button) { void mbutton::on_click(const Eigen::Vector2f& in_position, mouse_button in_button) {
mborder::on_click(in_position, in_button); mborder::on_click(in_position, in_button);
std::println(std::cout, "点击 Button: {}, {}", in_position.x(), in_position.y()); std::println(std::cout, "点击 Button: {}, {}", in_position.x(), in_position.y());
color_ = normal_color_; color_ = hover_color_;
invalidate(invalidate_reason::paint); invalidate(invalidate_reason::paint);
} }
@ -75,7 +75,7 @@ hit_test_handle mbutton::on_mouse_button_down(const Eigen::Vector2f& in_position
hit_test_handle mbutton::on_mouse_button_up(const Eigen::Vector2f& in_position, mouse_button in_button) { hit_test_handle mbutton::on_mouse_button_up(const Eigen::Vector2f& in_position, mouse_button in_button) {
mborder::on_mouse_button_up(in_position, in_button); mborder::on_mouse_button_up(in_position, in_button);
std::println(std::cout, "鼠标释放 Button: {}, {}", in_position.x(), in_position.y()); std::println(std::cout, "鼠标释放 Button: {}, {}", in_position.x(), in_position.y());
color_ = normal_color_; color_ = hover_color_;
invalidate(invalidate_reason::paint); invalidate(invalidate_reason::paint);
return hit_test_handle::handled(); return hit_test_handle::handled();
} }

View File

@ -4,23 +4,23 @@
struct button_args { struct button_args {
WARG(linear_color, normal_color, linear_color(0.2f, 0.2f, 0.2f, 1)) WARG(linear_color, normal_color, linear_color(0.2f, 0.2f, 0.2f, 1))
WARG(linear_color, hover_color, linear_color(0.1f, 0.1f, 0.1f, 1)) WARG(linear_color, hover_color, linear_color(0.1f, 0.1f, 0.1f, 1))
WARG(linear_color, pressed_color, linear_color(0.1f, 0.1f, 0.1f, 1)) WARG(linear_color, pressed_color, linear_color(0.05f, 0.05f, 0.05f, 1))
}; };
class mbutton : public mborder<button_args> { class mbutton : public mborder<button_args> {
public: public:
mbutton(); mbutton();
virtual void init() override; void init() override;
void setup_widget(const button_args& in_args) override; void setup_widget(const button_args& in_args) override;
virtual void on_paint(mirage_paint_context& in_context) override; void on_paint(mirage_paint_context& in_context) override;
virtual void on_click(const Eigen::Vector2f& in_position, mouse_button in_button) override; void on_click(const Eigen::Vector2f& in_position, mouse_button in_button) override;
virtual void on_double_click(const Eigen::Vector2f& in_position, mouse_button in_button) override; void on_double_click(const Eigen::Vector2f& in_position, mouse_button in_button) override;
hit_test_handle on_mouse_move(const Eigen::Vector2f& in_position) override { return hit_test_handle::handled(); } hit_test_handle on_mouse_move(const Eigen::Vector2f& in_position) override { return hit_test_handle::handled(); }
virtual void on_mouse_enter() override; void on_mouse_enter() override;
virtual void on_mouse_leave() override; void on_mouse_leave() override;
virtual hit_test_handle on_mouse_button_down(const Eigen::Vector2f& in_position, mouse_button in_button) override; hit_test_handle on_mouse_button_down(const Eigen::Vector2f& in_position, mouse_button in_button) override;
virtual hit_test_handle on_mouse_button_up(const Eigen::Vector2f& in_position, mouse_button in_button) override; hit_test_handle on_mouse_button_up(const Eigen::Vector2f& in_position, mouse_button in_button) override;
private: private:
linear_color normal_color_; linear_color normal_color_;
linear_color hover_color_; linear_color hover_color_;

View File

@ -150,4 +150,4 @@ public:
auto& name(const type* in_value) { \ auto& name(const type* in_value) { \
name##_ = *in_value; \ name##_ = *in_value; \
return *this; \ return *this; \
} \ }

View File

@ -22,7 +22,7 @@
const auto& name() const { return name##_.value(); } \ const auto& name() const { return name##_.value(); } \
auto has_##name() const { return name##_.has_value(); } \ auto has_##name() const { return name##_.has_value(); } \
protected: \ protected: \
std::optional<type> name##_; \ std::optional<type> name##_;
#define SLOT_CONTENT() \ #define SLOT_CONTENT() \
public: \ public: \