dl
dl_system.h
浏览该文件的文档.
1
12#pragma once
13
14#ifndef DL_DISABLE_RENDER
15#include <string_view>
16#include <vector>
17
18#include "dl_type.h"
19#include "base/dl_type_user.h"
20
21namespace dl
22{
30
38
41{
42 std::string _strTitle;
44 FullScreenMode _fullScreenMode; //0.窗口 1.全屏 2.全屏窗口
46
48 _strTitle{ "C++ drawing library" },
49 _size{ 800,600 },
51 _bHideTitle{ false }
52 {}
53};
54
63
64class SystemImp;
66class System
67{
68public:
69 using Func = void (*)(void);
72
78 void Start(std::string_view json_window,
79 std::string_view json_path = "");
80
84 void Start(const ParamWindow& param = {});
88 void Exit();
92 void SetFuncInit(Func func) { _funcInit = func; }
96 void SetFuncRun(Func func) { _funcRun = func; }
97
104
116 void SetWindowPoint(const Point& xy);
117
125 void SetWindowTitle(std::string_view str);
130
134
138 void ScreenShot(std::string_view path_name);
139
140 enum class CursorMode
141 {
145 };
146
151
155 void SetClipboardString(std::string_view str);
159 std::string GetClipboardString();
160
165 {
166 _vecDropFile.clear();
167 }
168
171 const std::vector<std::string>& GetDropFile()
172 {
173 return _vecDropFile;
174 }
175
180 void ShowMessageBox(std::string_view title, std::string_view text);
181
183 void SetFullScreen(FullScreenMode mode, const Size& size = {});
184
186 void SetWindowSize(const Size& size);
187
189 {
190 _dir = dir;
191 }
192
195
197 SystemStep GetStep() { return _step; }
198
200 void _add_drop_file(std::string_view str)
201 {
202 _vecDropFile.push_back(std::string{ str });
203 }
204
205 SystemImp* GetImp() { return _imp; }
206
207 // 提前初始化,以便使用glfw的一些接口,例如显示器相关
210
211 // 触发窗口大小变更(用户请勿调用)
212 void _resize();
213 // 设置屏幕方向(用户请勿调用)
214 void _set_dir(WindowDirection dir) { _dir = dir; }
215 // 屏幕方向处理glfw输入坐标
218 //--------------------------lua----------------------------
219 void lua_SetFuncUpdate(std::string_view str);
220private:
221 SystemImp* _imp;
222 Func _funcInit;
223 Func _funcRun;
224 SystemStep _step;
225
226 CursorMode _cursorMode;
227 bool _bCursorModeChange;
228
229 void* _nativeWindow;
230
231 std::vector<std::string> _vecDropFile;
232 FullScreenMode _fullScreenMode;
233 Size _desktopSize;// 仅用于恢复全屏到窗口全屏使用
234 WindowDirection _dir;
235
236 struct
237 {
238 std::string _funcUpdate;
239 }_lua;
240
241 bool _start_init(const ParamWindow& param);
242 void _start_loop();
243};
244extern System* g_system;
245}
246
247#endif
void SetWindowDirection(WindowDirection dir)
void _convert_system_to_glfw(Point &xy)
void SetFuncInit(Func func)
设置 初始化函数
void SetFullScreen(FullScreenMode mode, const Size &size={})
设置全屏
const std::vector< std::string > & GetDropFile()
返回拖入文件列表
void Start(const ParamWindow &param={})
创建窗口 并进入 游戏循环
void _init_glfw()
void SetWindowTitle(std::string_view str)
设置窗口标题
void SetFuncRun(Func func)
设置 帧函数
SystemStep GetStep()
返回引擎运行状态
void _delete_glfw()
void ScreenShot(std::string_view path_name)
截屏
std::string GetClipboardString()
返回剪贴板
Size GetWindowSize()
返回窗口大小
void _convert_glfw_to_system(Point &xy)
void SetWindowPoint(const Point &xy)
设置窗口位置
void _add_drop_file(std::string_view str)
内部调用
bool IsWindowExist()
窗口是否存在
std::string _funcUpdate
const RenderInfo2D & GetRenderInfo2D()
返回上一帧绘图信息
void _resize()
void SetWindowCenter()
设置窗口居中(以工作区大小)
SystemImp * GetImp()
void SetWindowSize(const Size &size)
设置窗口大小
void ClearDropFile()
清空拖入文件列表
void Exit()
创建窗口 并进入 游戏循环
void SetClipboardString(std::string_view str)
设置剪贴板
void SetCursorMode(CursorMode mode)
设置光标模式
void SetCursorPosition(Point xy)
设置鼠标位置,不用此来实现摄像机
const RenderInfo3D & GetRenderInfo3D()
WindowDirection GetWindowDirection()
返回屏幕方向
void Start(std::string_view json_window, std::string_view json_path="")
进入 游戏循环
void ShowMessageBox(std::string_view title, std::string_view text)
系统框提示
void _set_dir(WindowDirection dir)
void lua_SetFuncUpdate(std::string_view str)
Size GetWorkArea()
获取桌面大小,不包含任务栏
void(*)(void) Func
通用类型
常用类型
SystemStep
运行步骤
WindowDirection
屏幕方向
System * g_system
FullScreenMode
全屏模式
PointU Size
Point2 Point
创建窗口参数
std::string _strTitle
FullScreenMode _fullScreenMode