├── .clang-format ├── .gitattributes ├── .github └── ISSUE_TEMPLATE │ ├── I_have_quesiton.yml │ ├── bug_report.yml │ ├── config.yml │ ├── document_enhance.yml │ └── feature_request.yml ├── .gitignore ├── .gitmodules ├── .idea ├── .gitignore ├── VUILib.iml ├── codeStyles │ └── codeStyleConfig.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── README_ZH_CN.md ├── demo ├── CreateWidget │ └── main.cpp ├── PanelTester │ └── main.cpp ├── SimpleButton │ └── main.cpp ├── TestSkia │ └── main.cpp └── TestSkiaShader │ └── main.cpp ├── include ├── app │ └── vApplication.h ├── base │ ├── binding │ │ └── vBindingType.h │ ├── command │ │ └── vCommand.h │ ├── event │ │ └── vEvent.h │ ├── geometry │ │ ├── vPoint.h │ │ └── vRect.h │ ├── message │ │ ├── vKeyMap.h │ │ └── vMessage.h │ ├── object │ │ ├── vObject.h │ │ └── vObjectProperty.h │ ├── test │ │ └── vTest.h │ └── vBase.h ├── control │ ├── button │ │ ├── vAbstractButton.h │ │ └── vPushButton.h │ └── shape │ │ └── vRectangleControl.h ├── layout │ ├── vPanelLayout.h │ ├── vStackPanelLayout.h │ └── vWrapPanelLayout.h ├── mvvm │ ├── vModelBase.h │ ├── vViewBase.h │ └── vViewModelBase.h ├── parser │ └── html │ │ ├── vHTMLAST.h │ │ ├── vHTMLEscapeCharacter.h │ │ └── vHTMLLexer.h ├── renderer │ ├── vColorFactory.h │ ├── vGLHeader.h │ ├── vRenderContext.h │ ├── vRenderInterface.h │ ├── vRenderTarget.h │ ├── vRendererBase.h │ └── vSurface.h ├── style │ ├── vRadixStyle.h │ ├── vStyleCollection.h │ └── vStyleFunction.h ├── widget │ ├── vGLFWCallback.h │ ├── vGLFWException.h │ ├── vMainWindow.h │ ├── vMonitor.h │ └── vWidget.h ├── window │ └── vWindowView.h └── write │ ├── vRichTextNativeLabel.h │ └── vRichTextRenderer.h ├── libs └── skia │ └── README.txt ├── main.cpp ├── readme ├── icon.svg └── radix logo.svg ├── source ├── app │ └── vApplication.cpp ├── base │ ├── binding │ │ └── vBindingType.cpp │ ├── command │ │ └── vCommand.cpp │ ├── message │ │ └── vMessage.cpp │ ├── object │ │ ├── vObject.cpp │ │ └── vObjectProperty.cpp │ └── vtest │ │ └── vTest.cpp ├── control │ ├── button │ │ ├── vAbstractButton.cpp │ │ └── vPushButton.cpp │ └── shape │ │ └── vRectangleControl.cpp ├── layout │ ├── vPanelLayout.cpp │ ├── vStackPanelLayout.cpp │ └── vWrapPanelLayout.cpp ├── mvvm │ ├── vModelBase.cpp │ ├── vViewBase.cpp │ └── vViewModelBase.cpp ├── parser │ └── html │ │ ├── vHTMLAST.cpp │ │ ├── vHTMLEscapeCharacter.cpp │ │ └── vHTMLLexer.cpp ├── renderer │ ├── vColorFactory.cpp │ ├── vRenderContext.cpp │ ├── vRenderInterface.cpp │ ├── vRenderTarget.cpp │ └── vSurface.cpp ├── style │ ├── vRadixStyle.cpp │ ├── vStyleCollection.cpp │ └── vStyleFunction.cpp ├── widget │ ├── vGLFWCallback.cpp │ ├── vMainWindow.cpp │ ├── vMonitor.cpp │ └── vWidget.cpp └── write │ ├── vRichTextNativeLabel.cpp │ └── vRichTextRenderer.cpp ├── third ├── SimpleJson │ ├── sJSON.cpp │ └── sJSON.h ├── glad │ ├── include │ │ ├── KHR │ │ │ └── khrplatform.h │ │ └── glad │ │ │ └── glad.h │ └── src │ │ └── glad.c └── winToast │ ├── include │ └── wintoastlib.h │ └── src │ └── wintoastlib.cpp ├── tool └── vcommit │ ├── main.cpp │ └── third │ └── include │ └── cmdparser.hpp ├── unitTest ├── base │ ├── base.binding.cpp │ ├── base.binding.h │ ├── base.command.cpp │ ├── base.command.h │ ├── base.event.cpp │ ├── base.event.h │ ├── base.geometry.cpp │ ├── base.geometry.h │ ├── base.object.property.cpp │ └── base.object.property.h ├── parser │ ├── parser.html.ast.h │ ├── parser.html.lexer.cpp │ ├── parser.html.lexer.h │ └── pasrser.html.ast.cpp └── renderer │ ├── renderer.color.factory.cpp │ └── renderer.color.factory.h └── vtest.json /.gitattributes: -------------------------------------------------------------------------------- 1 | *.c linguist-detectable=false -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/I_have_quesiton.yml: -------------------------------------------------------------------------------- 1 | name: ❓ I have a question 2 | description: Ask about the questions you met while using this project 3 | title: '[QA]: ' 4 | labels: 5 | - QA 6 | body: 7 | - type: textarea 8 | attributes: 9 | label: Describe your question 10 | description: A clear and concise description of what your question is. 11 | validations: 12 | required: true 13 | - type: input 14 | attributes: 15 | label: Write a title that summarizes the specific problem 16 | description: >- 17 | The title is the first thing that potential answerers will see. If your 18 | title isn't interesting, they won't read the rest. Also, without a good 19 | title, people may not even be able to find your question 20 | validations: 21 | required: true 22 | - type: textarea 23 | attributes: 24 | label: Expected answer 25 | description: A clear and concise description of what answer you want. 26 | validations: 27 | required: true 28 | - type: textarea 29 | attributes: 30 | label: Screenshots URL(Optional) 31 | description: If applicable, add screenshots to help explain your problem. 32 | - type: markdown 33 | attributes: 34 | value: >- 35 | This template was generated with [Issue Forms 36 | Creator](https://issue-forms-creator.netlify.app) 37 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: 🐛 Bug report 2 | description: Report the bugs you found in library 3 | title: '[Bug Report]: ' 4 | labels: 5 | - bug 6 | assignees: 7 | - FSMargoo 8 | body: 9 | - type: markdown 10 | attributes: 11 | value: >- 12 | ## 👋Welcome to the VUILib bug report page 13 | 14 | 15 | Please answer the following questions to let us know about the bug your 16 | found. 17 | 18 | 19 | Thanks of your contribution of making VUILib greater! 20 | - type: checkboxes 21 | id: bug_progress 22 | attributes: 23 | label: ✔️Things you need to do 24 | description: >- 25 | Before submitting your issue to us, please make sure that you have done 26 | following things. 27 | options: 28 | - label: I've checked that I am using VUILib in right way 29 | required: true 30 | - label: I've chcekd that the newest VUILib still have the bug 31 | required: true 32 | - label: I've checked that this bug is caused by VUILib 33 | required: true 34 | - label: I've checked that my bug wasn't found by another user 35 | required: true 36 | - label: I can provide a simplest demo to reproduce this bug 37 | required: true 38 | - type: dropdown 39 | id: type_of_bug 40 | attributes: 41 | label: 🖥️Host Operating System 42 | description: What operating system your test platform using? 43 | options: 44 | - Windows 45 | - Mac OS 46 | - Linux 47 | validations: 48 | required: true 49 | - type: textarea 50 | id: what_wrong 51 | attributes: 52 | label: ❓What went wrong 53 | description: What exactly went wrong of what bug did you encounter? 54 | validations: 55 | required: true 56 | - type: textarea 57 | id: expected_behaviour 58 | attributes: 59 | label: 🤔Expected behaviour 60 | description: What did you expect to happen instead? 61 | validations: 62 | required: true 63 | - type: textarea 64 | id: bug_reproduction 65 | attributes: 66 | label: 📃How can we reproduce the bug? 67 | description: >- 68 | How to reproduce the bug you met? A answer with a simple demo code are 69 | more likely to be accpeted. 70 | validations: 71 | required: true 72 | - type: dropdown 73 | id: compiler 74 | attributes: 75 | label: 🧮Compiler 76 | description: Which compiler you are currently using? 77 | options: 78 | - clang 79 | - MSVC 80 | - gcc 81 | - other 82 | validations: 83 | required: true 84 | - type: input 85 | id: vuilib_version 86 | attributes: 87 | label: Your VUILib version? 88 | description: >- 89 | Let us know the VUILib release version you are currently using. If you 90 | are not using the release version, please provide the version in format 91 | like: "Lasted commit at *wi:669a42c2*(On GitHub commit *410fb41*)" 92 | validations: 93 | required: true 94 | - type: textarea 95 | id: error_message 96 | attributes: 97 | label: ✉️Error message(optional) 98 | description: Please provide the error message library may give you. 99 | - type: markdown 100 | attributes: 101 | value: >- 102 | This template was generated with [Issue Forms 103 | Creator](https://issue-forms-creator.netlify.app) 104 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/document_enhance.yml: -------------------------------------------------------------------------------- 1 | name: 📄 Document enhance 2 | description: Suggest a document enhancement for this project 3 | title: '[Document Enhance]: ' 4 | labels: 5 | - documentation 6 | body: 7 | - type: dropdown 8 | attributes: 9 | label: Enhancement type 10 | description: Describe which your enhancement type is 11 | options: 12 | - Typo 13 | - Missing 14 | - Error 15 | validations: 16 | required: true 17 | - type: textarea 18 | attributes: 19 | label: Describe where the document should be modified 20 | description: Like typo or the wrong description about one API. 21 | placeholder: >- 22 | for example: > In the document about *VPushButton::OnClicked* event is 23 | incorrect, this event will only be emitted after the user's mouse button 24 | is up. 25 | validations: 26 | required: true 27 | - type: input 28 | attributes: 29 | label: Where the document is 30 | description: Paste a URL to our document website or file path to the document folde 31 | validations: 32 | required: true 33 | - type: markdown 34 | attributes: 35 | value: >- 36 | This template was generated with [Issue Forms 37 | Creator](https://issue-forms-creator.netlify.app) 38 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: 🌟 Feature request 2 | description: Request for more feature to be added 3 | title: '[Feature Request]: ' 4 | labels: 5 | - enhancement 6 | body: 7 | - type: textarea 8 | attributes: 9 | label: Description 10 | description: A clear and concise description of the problem or missing capability 11 | validations: 12 | required: true 13 | - type: textarea 14 | attributes: 15 | label: Describe the solution you'd like 16 | description: If you have a solution in mind, please describe it. 17 | validations: 18 | required: true 19 | - type: textarea 20 | attributes: 21 | label: Describe alternatives you've considered 22 | description: Have you considered any alternative solutions or workarounds? 23 | validations: 24 | required: true 25 | - type: dropdown 26 | id: accomplish_with_exist_API 27 | attributes: 28 | label: Accomplish this feature with existing API 29 | description: Can we accomplish this feature with existing API? 30 | options: 31 | - 'yes' 32 | - 'no' 33 | validations: 34 | required: true 35 | - type: markdown 36 | attributes: 37 | value: >- 38 | This template was generated with [Issue Forms 39 | Creator](https://issue-forms-creator.netlify.app) 40 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third/glfw"] 2 | path = third/glfw 3 | url = https://github.com/glfw/glfw 4 | [submodule "third/SkiaM101Binary"] 5 | path = third/SkiaM101Binary 6 | url = https://github.com/FSMargoo/SkiaM101Binary 7 | [submodule "third/OpenString-CMake"] 8 | path = third/OpenString-CMake 9 | url = https://github.com/FSMargoo/OpenString-CMake.git 10 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /.idea/VUILib.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2024~now Margoo 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | ![GitHub License](https://img.shields.io/github/license/FSMargoo/VUILib) ![GitHub Created At](https://img.shields.io/github/created-at/FSMargoo/VuiLib) 6 | 7 |

Auto Commit Status

8 | 9 | ![Static Badge](https://img.shields.io/badge/Unit%20Test-Pass-green) 10 | ![Static Badge](https://img.shields.io/badge/Last%20Commit-nf:67132584-blue) 11 | ![Static Badge](https://img.shields.io/badge/Last%20Commit%20Date-2024/10/19/11:20:37-purple) 12 | 13 | [简体中文版](./README_ZH_CN.md) 14 | 15 | 16 |

VUILib3.x

17 | A cross-platform UI Library born for flexible and efficient. Build with: 18 | 19 |
20 | 21 | 22 | 23 |
24 | 25 | Radix logo. 26 | 27 |
28 | 29 |
30 | 31 | VUILib 3.x is still under developing, please wait with our first dev release! 32 | 33 |
34 | 35 | ## Acknowledgements 36 | 37 | Thanks for $JetBrains$'s Licenses for Open Source Development 38 | 39 |
40 | 41 | JetBrains logo. 42 | 43 |
44 | 45 | Thanks for $mohabouje$'s project $WinToast$. 46 | 47 | Thanks for $FlorianRappl$'s project $CmdParser$. 48 | 49 | Thanks for $Google$'s project $Skia$ 50 | 51 | Thanks for $GLFW$ project 52 | 53 | Thanks for $Radix$ $Themes$ project 54 | 55 | Thanks for $Hoshizora Ming$'s project $OpenString$ 56 | 57 | 58 |
59 | 60 | Radix logo. 61 | 62 |
63 | 64 | ## Third-party Libraries List 65 | 66 |
67 | 68 | [mohabouje-WinToast](https://github.com/mohabouje/WinToast) 69 | 70 | [FlorianRappl-CmdParser](https://github.com/FlorianRappl/CmdParser) 71 | 72 | [Margoo-SimpleJson](https://github.com/FSMargoo/SimpleJson) 73 | 74 | [Skia](https://www.skia.org) 75 | 76 | [GLFW](https://github.com/GLFW/glfw) 77 | 78 | [Hoshizora Ming-OpenString](https://github.com/FSMargoo/OpenString-CMake) 79 | 80 |
81 | 82 | ## UI Theme Design 83 | 84 | VUILib's kits design is provided by $Radix$ $Theme$ at [here](https://www.radix-ui.com/). 85 | 86 |
87 | 88 | Radix logo. 89 | 90 |
-------------------------------------------------------------------------------- /README_ZH_CN.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | ![GitHub License](https://img.shields.io/github/license/FSMargoo/VUILib) ![GitHub Created At](https://img.shields.io/github/created-at/FSMargoo/VuiLib) 6 | 7 |

自动提交信息

8 | 9 | [前往英文版查看](./README.md) 10 | 11 |

VUILib3.x

12 | 专为灵活和高效而生的跨平台 UI 库。使用以下工具构造: 13 | 14 |
15 | 16 | 17 |
18 | Radix logo. 19 | 20 |
21 | 22 | VUILib 3 依然在开发中请耐心等待我们的第一个正式版本 23 | 24 |
25 | 26 | ## 鸣谢 27 | 28 | 感谢 $JetBrains$' 的开源许可证 29 | 30 |
31 | 32 | JetBrains logo. 33 | 34 |
35 | 36 |
37 | 38 | 感谢 $mohabouje$ 的开源项目 $WinToast$. 39 | 40 | 感谢 $FlorianRappl$ 的开源项目 $CmdParser$. 41 | 42 | 感谢 $Google$ 的开源项目 $Skia$ 43 | 44 | 感谢 $GLFW$ 项目 45 | 46 | 感谢 $Hoshizora Ming$ 的开源项目 $OpenString$ 47 | 48 | 感谢 $Radix$ $Themes$ 项目 49 | 50 | ## 第三方库列表 51 | 52 |
53 | 54 | [mohabouje-WinToast](https://github.com/mohabouje/WinToast) 55 | 56 | [FlorianRappl-CmdParser](https://github.com/FlorianRappl/CmdParser) 57 | 58 | [Margoo-SimpleJson](https://github.com/FSMargoo/SimpleJson) 59 | 60 | [Skia](skia.org) 61 | 62 | [GLFW](https://github.com/GLFW/glfw) 63 | 64 | [Hoshizora Ming-OpenString](https://github.com/FSMargoo/OpenString-CMake) 65 | 66 |
67 | 68 | ## UI 设计语言 69 | 70 | VUILib 的 UI 设计语言基于 $Radix$ $Theme$ 项目 [了解 Radix Theme 项目](https://www.radix-ui.com/). 71 | 72 |
73 | 74 | Radix logo. 75 | 76 |
-------------------------------------------------------------------------------- /demo/CreateWidget/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023~Now Margoo 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | /** 24 | * \file main.cpp 25 | * \brief The demo to create a simple widget in VUILib 26 | */ 27 | 28 | #include 29 | 30 | int main() { 31 | VApplication application; 32 | VMainWindow window(&application, 640, 480, "Hello, VUILib"); 33 | VWidget widget(&application, 640, 480, "VUILib Widget"); 34 | 35 | return application.Run(); 36 | } -------------------------------------------------------------------------------- /demo/PanelTester/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023~Now Margoo 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | /** 24 | * \file main.cpp 25 | * \brief The demo to use the panel control 26 | */ 27 | 28 | /** 29 | * \file main.cpp 30 | * \brief The demo to create a simple widget in VUILib 31 | */ 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | void CreatePanelViewer(VApplication *Target) { 39 | auto window = new VMainWindow(Target, 640, 480, "Panel Viewer"); 40 | 41 | auto panel = new VPanel(window); 42 | 43 | auto rectangleBackground = new VRectangleControl(panel); 44 | auto rectangle1 = new VRectangleControl(panel); 45 | auto rectangle2 = new VRectangleControl(panel); 46 | auto rectangle3 = new VRectangleControl(panel); 47 | auto rectangle4 = new VRectangleControl(panel); 48 | 49 | panel->P_PanelAlign.Register(rectangle1, "left"); 50 | panel->P_PanelAlign.Register(rectangle2, "right"); 51 | panel->P_PanelAlign.Register(rectangle3, "top"); 52 | panel->P_PanelAlign.Register(rectangle4, "bottom"); 53 | panel->P_PanelAlign.Register(rectangleBackground, "center"); 54 | 55 | rectangle1->SetOpacity(0.5); 56 | rectangle1->SetBackgroundColor(SK_ColorBLUE); 57 | rectangle2->SetBackgroundColor(SK_ColorCYAN); 58 | rectangle2->SetOpacity(0.5); 59 | rectangle3->SetBackgroundColor(SK_ColorGREEN); 60 | rectangle3->SetOpacity(0.5); 61 | rectangle4->SetOpacity(0.5); 62 | 63 | rectangleBackground->Resize(100, 100); 64 | rectangleBackground->LockSizing(); 65 | 66 | panel->Arrange(); 67 | 68 | window->Show(); 69 | } 70 | void CreateStackPanelViewer(VApplication *Target) { 71 | auto window = new VWidget(Target, 640, 480, "Stack Panel Viewer"); 72 | 73 | auto panel = new VStackPanel(window); 74 | 75 | auto rectangleBackground = new VRectangleControl(panel); 76 | auto rectangle1 = new VRectangleControl(400, 60, panel); 77 | auto rectangle2 = new VRectangleControl(400, 50, panel); 78 | auto rectangle3 = new VRectangleControl(400, 50, panel); 79 | auto rectangle4 = new VRectangleControl(400, 50, panel); 80 | 81 | panel->P_StackAlign.Register(rectangle1, "left"); 82 | panel->P_StackAlign.Register(rectangle2, "right"); 83 | panel->P_Margin.Register(rectangle2, 20); 84 | panel->P_StackAlign.Register(rectangle3, "center"); 85 | panel->P_StackAlign.Register(rectangle4, "right"); 86 | panel->P_MarginTop.Register(rectangle4, 12); 87 | panel->P_StackAlign.Register(rectangleBackground, "center"); 88 | 89 | rectangle1->SetOpacity(0.5); 90 | rectangle1->SetBackgroundColor(SK_ColorGREEN); 91 | rectangle2->SetBackgroundColor(SK_ColorCYAN); 92 | rectangle2->SetOpacity(0.5); 93 | rectangle3->SetBackgroundColor(SK_ColorRED); 94 | rectangle3->SetOpacity(0.5); 95 | rectangle4->SetOpacity(0.5); 96 | 97 | rectangleBackground->Resize(100, 100); 98 | rectangleBackground->LockSizing(); 99 | 100 | panel->Arrange(); 101 | 102 | window->Show(); 103 | } 104 | 105 | int main() { 106 | VApplication application; 107 | 108 | CreatePanelViewer(&application); 109 | CreateStackPanelViewer(&application); 110 | 111 | return application.Run(); 112 | } -------------------------------------------------------------------------------- /demo/SimpleButton/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023~Now Margoo 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | /** 24 | * \file main.cpp 25 | * \brief A demo in VUILib for just a simple button creation 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | int main() { 32 | VApplication application; 33 | VMainWindow window(&application, 640, 480, "Hello, VUILib"); 34 | 35 | VPushButton button(&window, 200, 400, "Hello World!"); 36 | button.SetRichText(R"(

Hello

 
World in Rich Text!

)"); 37 | 38 | window.Show(); 39 | 40 | return application.Run(); 41 | } -------------------------------------------------------------------------------- /demo/TestSkia/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023~Now Margoo 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | /** 24 | * \file main.cpp 25 | * \brief This is a demo which test the Skia wrapper of VUILib 26 | */ 27 | 28 | #include 29 | 30 | // #include 31 | 32 | sk_sp GLInterface; 33 | 34 | #define WIDTH 640 35 | #define HEIGHT 480 36 | 37 | sk_sp TextBlob; 38 | SkPaint *Paint; 39 | SkPaint *BlurPaint; 40 | 41 | GLFWwindow *GLWindow; 42 | 43 | /** 44 | * Init OpenGL interface object 45 | */ 46 | void InitGLInterface(); 47 | /** 48 | * Create GLFW window 49 | */ 50 | void InitWindow(); 51 | /** 52 | * Init Skia resource 53 | */ 54 | void InitResource(); 55 | /** 56 | * The frame buffer call back function 57 | */ 58 | void FrameBufferCallBack(GLFWwindow *Window, int Width, int Height); 59 | /** 60 | * The error call back function of GLFW 61 | * @param Error The error code 62 | * @param Description The description string of the error 63 | */ 64 | void ErrorCallBack(int Error, const char *Description); 65 | /** 66 | * Call Skia API to draw context 67 | */ 68 | void Draw(int Width, int Height); 69 | 70 | int main() { 71 | InitWindow(); 72 | InitResource(); 73 | InitGLInterface(); 74 | 75 | Draw(WIDTH, HEIGHT); 76 | while (!glfwWindowShouldClose(GLWindow)) { 77 | glfwPollEvents(); 78 | } 79 | 80 | return 0; 81 | } 82 | 83 | void InitGLInterface() { 84 | GLInterface = sk_make_sp(); 85 | } 86 | void InitWindow() { 87 | glfwSetErrorCallback(ErrorCallBack); 88 | if (!glfwInit()) { 89 | exit(EXIT_FAILURE); 90 | } 91 | 92 | GLWindow = glfwCreateWindow(WIDTH, HEIGHT, "Skia Tester", nullptr, nullptr); 93 | if (!GLWindow) { 94 | printf("Failed to create GLFW window!"); 95 | glfwTerminate(); 96 | exit(EXIT_FAILURE); 97 | } 98 | glfwSetFramebufferSizeCallback(GLWindow, FrameBufferCallBack); 99 | 100 | glfwMakeContextCurrent(GLWindow); 101 | } 102 | void InitResource() { 103 | const SkScalar sigma = 3.65f; 104 | const SkScalar textSize = 40.0f; 105 | const uint8_t blurAlpha = 127; 106 | auto face = SkTypeface::MakeFromName( 107 | "Times New Roman", {SkFontStyle::kNormal_Weight, SkFontStyle::kNormal_Width, SkFontStyle::kItalic_Slant}); 108 | auto font = SkFont(face, textSize); 109 | TextBlob = SkTextBlob::MakeFromString("Hello VUILib, hello Skia,\r\n hello GLFW", SkFont(face, textSize), SkTextEncoding::kUTF8); 110 | Paint = new SkPaint(); 111 | Paint->setAntiAlias(true); 112 | 113 | BlurPaint = new SkPaint(*Paint); 114 | 115 | BlurPaint->setAlpha(blurAlpha); 116 | BlurPaint->setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma, 0)); 117 | } 118 | void FrameBufferCallBack(GLFWwindow *Window, int Width, int Height) { 119 | Draw(Width, Height); 120 | } 121 | void Draw(int Width, int Height) { 122 | sk_sp glRenderTarget = 123 | sk_make_sp({.Width = Width, .Height = Height, .X = 0, .Y = 0}); 124 | sk_sp glContext = sk_make_sp &>(GLInterface); 125 | sk_sp glSurface = 126 | sk_make_sp &, const sk_sp &>(glRenderTarget, glContext); 127 | 128 | auto canvas = glSurface->GetNativeSurface()->getCanvas(); 129 | 130 | const SkScalar x = 8.0f; 131 | const SkScalar y = 52.0f; 132 | 133 | canvas->drawColor(SK_ColorWHITE); 134 | canvas->drawTextBlob(TextBlob.get(), x, y, *BlurPaint); 135 | canvas->drawTextBlob(TextBlob.get(), x, y, *Paint); 136 | 137 | canvas->flush(); 138 | glContext->GetNativeContext()->flushAndSubmit(); 139 | 140 | glfwSwapBuffers(GLWindow); 141 | } 142 | void ErrorCallBack(int Error, const char *Description) { 143 | fputs(Description, stderr); 144 | } -------------------------------------------------------------------------------- /include/app/vApplication.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023~Now Margoo 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | /** 24 | * \file vApplication.h 25 | * \brief The application class in the VUILib 26 | */ 27 | 28 | #pragma once 29 | 30 | #include 31 | #include 32 | 33 | /** 34 | * The interface for application to call the VUILib's widget event loop 35 | */ 36 | class VApplicationWidgetInterface { 37 | public: 38 | /** 39 | * Every time on the event loop this function will be called 40 | */ 41 | virtual void OnOnceLoop() = 0; 42 | }; 43 | 44 | /** 45 | * The application class in VUILib 46 | */ 47 | class VApplication { 48 | public: 49 | /** 50 | * Create the application in default mode; By default, it will 51 | * create a theme in light mode with the blue theme color 52 | */ 53 | VApplication(); 54 | 55 | public: 56 | /** 57 | * Get the theme property by the specified name 58 | * @param Name The id of the theme property 59 | * @return The reference of the property instance 60 | */ 61 | VStyleProperty &GetThemeProperty(const OString &Name); 62 | /** 63 | * Get the value of the specified name in specified type 64 | * @tparam Type The type of the property 65 | * @param Name The name of the property 66 | * @return The value of the property in the specified name 67 | */ 68 | template Type *GetThemePropertyValue(const OString &Name) { 69 | return _style.GetPropertyValue(Name); 70 | } 71 | 72 | public: 73 | /** 74 | * Call this function to run the application 75 | * @return The return for main function 76 | */ 77 | int Run(); 78 | 79 | private: 80 | friend class VWidget; 81 | friend class VMainWindow; 82 | 83 | protected: 84 | GLFWwindow *_mainWindow; 85 | VRadixStyleType _styleType; 86 | VStyleFunction _style; 87 | 88 | protected: 89 | std::unordered_map _interfaces; 90 | }; 91 | -------------------------------------------------------------------------------- /include/base/binding/vBindingType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023~Now Margoo 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | /** 24 | * \file vBindingType.h 25 | * \brief A wrapper type for two-way binding 26 | */ 27 | 28 | #pragma once 29 | 30 | #include 31 | 32 | /** 33 | * This is a class for two-way binding, the control defines property with 34 | * this data class. This class will maintain an instance of the type and 35 | * a pointer referred to the type. 36 | * @tparam Type The data type 37 | * @tparam Parameter The constructor parameter for the data type 38 | */ 39 | template class VBindingType { 40 | public: 41 | /** 42 | * In default, VBindingType will create an empty pointer 43 | */ 44 | VBindingType() : _pointer(nullptr), _instance() { 45 | } 46 | /** 47 | * Construct a binding type with the parameter of the 48 | * Type construction 49 | * @param Construct The construction parameter to construct a object 50 | */ 51 | explicit VBindingType(Parameter... Construct) : _pointer(nullptr), _instance(Construct...) { 52 | } 53 | 54 | public: 55 | /** 56 | * Bind a pointer; VBindingType assumes that the pointer is always available. 57 | * @param Pointer The pointer to be bound. 58 | */ 59 | void Bind(Type *Pointer) { 60 | _pointer = Pointer; 61 | } 62 | /** 63 | * Unbind, discard the pointer. Binding object will not copy the value into the 64 | * cache of binding object. 65 | */ 66 | void Unbind() { 67 | _pointer = nullptr; 68 | } 69 | 70 | public: 71 | /** 72 | * Spaceship operator 73 | * @param Value The value for judgement 74 | */ 75 | std::strong_ordering friend operator<=>(const VBindingType &Object, const Type &Value) { 76 | if (Object._pointer != nullptr) { 77 | return *(Object._pointer) <=> Value; 78 | } 79 | 80 | return Object._instance <=> Value; 81 | } 82 | /** 83 | * Spaceship operator 84 | * @param Value The value for judgement 85 | */ 86 | std::strong_ordering friend operator<=>(const Type &Value, const VBindingType &Object) { 87 | if (Object._pointer != nullptr) { 88 | return Value <=> *(Object._pointer); 89 | } 90 | 91 | return Value <=> Object._instance; 92 | } 93 | bool operator==(const Type &Value) { 94 | if (_pointer != nullptr) { 95 | return Value == *_pointer; 96 | } 97 | 98 | return Value == _instance; 99 | } 100 | 101 | public: 102 | /** 103 | * Get the pointer of instance 104 | * @return The pointer of data type 105 | */ 106 | Type *Pointer() noexcept { 107 | /* 108 | * If the _pointer != nullptr, return the pointer. 109 | * However, nobody can sure whether the _pointer object 110 | * has been released or not. 111 | * 112 | * TODO: Add a VMemoryLogger to help the memory manage. 113 | */ 114 | if (_pointer != nullptr) { 115 | return _pointer; 116 | } else { 117 | return &_instance; 118 | } 119 | } 120 | /** 121 | * Get the reference of instance 122 | * @return The reference of data type 123 | */ 124 | Type &operator*() noexcept { 125 | /* 126 | * If the _pointer != nullptr, return the pointer. 127 | * However, nobody can sure whether the _pointer object 128 | * has been released or not. 129 | * 130 | * TODO: Add a VMemoryLogger to help the memory manage. 131 | */ 132 | if (_pointer != nullptr) { 133 | return *_pointer; 134 | } else { 135 | return _instance; 136 | } 137 | } 138 | 139 | private: 140 | Type *_pointer; 141 | Type _instance; 142 | }; 143 | -------------------------------------------------------------------------------- /include/base/command/vCommand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023~Now Margoo 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | /** 24 | * \file vCommand.h 25 | * \brief The command class 26 | */ 27 | 28 | #pragma once 29 | 30 | #include 31 | 32 | /** 33 | * An empty structure for VCommand's placeholder 34 | */ 35 | struct VPlaceHolderObject {}; 36 | 37 | /** 38 | * The command class for VUILib. It just like a event which has not connection method 39 | * @tparam ObjectType The object type for class function, if not use the VPlaceHolderObject type 40 | * @tparam Parameter The parameter list of command 41 | */ 42 | template class VCommand { 43 | public: 44 | /** 45 | * The alias to VEvent class 46 | */ 47 | using Delegate = VEvent; 48 | 49 | public: 50 | /** 51 | * Construct the command by a function pointer of delegate 52 | * @param Pointer The pointer referred to command callback function 53 | */ 54 | explicit VCommand(Delegate::FunctionPointer Pointer) { 55 | _commandEvent.Connect(Pointer); 56 | } 57 | /** 58 | * Construct the command by a member function pointer 59 | * @param Object The object pointer referred to the target object 60 | * @param Pointer The pointer referred to the member function 61 | */ 62 | VCommand(ObjectType *Object, Delegate::template ClassFunctionPointer Pointer) { 63 | _commandEvent.template Connect(Object, Pointer); 64 | } 65 | 66 | public: 67 | /*** 68 | * Emit the command 69 | * @param CallList The call parameter list 70 | */ 71 | void operator()(Parameter... CallList) { 72 | _commandEvent.Emit(CallList...); 73 | } 74 | /*** 75 | * Emit the command 76 | * @param CallList The call parameter list 77 | */ 78 | void OnCommand(Parameter... CallList) { 79 | _commandEvent.Emit(CallList...); 80 | } 81 | 82 | private: 83 | Delegate _commandEvent; 84 | }; -------------------------------------------------------------------------------- /include/base/message/vKeyMap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023~Now Margoo 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | /** 24 | * \file vKeyMap.h 25 | * \brief The key map between GLFW and the VUILib 26 | */ 27 | 28 | #pragma once 29 | 30 | #define VKEY_SPACE GLFW_KEY_SPACE 31 | #define VKEY_APOSTROPHE GLFW_KEY_APOSTROPHE 32 | #define VKEY_COMMA GLFW_KEY_COMMA 33 | #define VKEY_MINUS GLFW_KEY_MINUS 34 | #define VKEY_PERIOD GLFW_KEY_PERIOD 35 | #define VKEY_SLASH GLFW_KEY_SLASH 36 | #define VKEY_0 GLFW_KEY_0 37 | #define VKEY_1 GLFW_KEY_1 38 | #define VKEY_2 GLFW_KEY_2 39 | #define VKEY_3 GLFW_KEY_3 40 | #define VKEY_4 GLFW_KEY_4 41 | #define VKEY_5 GLFW_KEY_5 42 | #define VKEY_6 GLFW_KEY_6 43 | #define VKEY_7 GLFW_KEY_7 44 | #define VKEY_8 GLFW_KEY_8 45 | #define VKEY_9 GLFW_KEY_9 46 | #define VKEY_SEMICOLON GLFW_KEY_SEMICOLON 47 | #define VKEY_EQUAL GLFW_KEY_EQUAL 48 | #define VKEY_A GLFW_KEY_A 49 | #define VKEY_B GLFW_KEY_B 50 | #define VKEY_C GLFW_KEY_C 51 | #define VKEY_D GLFW_KEY_D 52 | #define VKEY_E GLFW_KEY_E 53 | #define VKEY_F GLFW_KEY_F 54 | #define VKEY_G GLFW_KEY_G 55 | #define VKEY_H GLFW_KEY_H 56 | #define VKEY_I GLFW_KEY_I 57 | #define VKEY_J GLFW_KEY_J 58 | #define VKEY_K GLFW_KEY_K 59 | #define VKEY_L GLFW_KEY_L 60 | #define VKEY_M GLFW_KEY_M 61 | #define VKEY_N GLFW_KEY_N 62 | #define VKEY_O GLFW_KEY_O 63 | #define VKEY_P GLFW_KEY_P 64 | #define VKEY_Q GLFW_KEY_Q 65 | #define VKEY_R GLFW_KEY_R 66 | #define VKEY_S GLFW_KEY_S 67 | #define VKEY_T GLFW_KEY_T 68 | #define VKEY_U GLFW_KEY_U 69 | #define VKEY_V GLFW_KEY_V 70 | #define VKEY_W GLFW_KEY_W 71 | #define VKEY_X GLFW_KEY_X 72 | #define VKEY_Y GLFW_KEY_Y 73 | #define VKEY_Z GLFW_KEY_Z 74 | #define VKEY_LEFT_BRACKET GLFW_KEY_LEFT_BRACKET 75 | #define VKEY_BACKSLASH GLFW_KEY_BACKSLASH 76 | #define VKEY_RIGHT_BRACKET GLFW_KEY_RIGHT_BRACKET 77 | #define VKEY_GRAVE_ACCENT GLFW_KEY_GRAVE_ACCENT 78 | #define VKEY_WORLD_1 GLFW_KEY_WORLD_1 79 | #define VKEY_WORLD_2 GLFW_KEY_WORLD_2 -------------------------------------------------------------------------------- /include/base/test/vTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023~Now Margoo 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | /** 24 | * \file vTest.h 25 | * \brief The test library 26 | */ 27 | 28 | #pragma once 29 | 30 | #include 31 | #include 32 | 33 | #include 34 | 35 | #define VUnitTest(MODULE, X) __VTest_MARCO_##MODULE##X() 36 | #define VUnitTestM(MODULE, X) __VTest_MARCO_##MODULE##X 37 | 38 | /*** 39 | * The test task class 40 | */ 41 | class VTestTask { 42 | public: 43 | VTestTask(std::function Function, const std::string &TaskName); 44 | 45 | public: 46 | /*** 47 | * Start test 48 | * @return Whether the test task failed 49 | */ 50 | [[nodiscard]] bool Conduct() const { 51 | return _task(); 52 | } 53 | 54 | private: 55 | std::function _task; 56 | 57 | public: 58 | std::string TaskID; 59 | }; 60 | 61 | /*** 62 | * The test conductor class 63 | */ 64 | class VTestConductor { 65 | public: 66 | VTestConductor() = default; 67 | 68 | public: 69 | /*** 70 | * Add testing task 71 | * @param Task The test task 72 | */ 73 | void AddTask(const VTestTask &Task); 74 | /*** 75 | * Start the test task 76 | */ 77 | void StartTasks(); 78 | 79 | private: 80 | std::vector _taskList; 81 | }; -------------------------------------------------------------------------------- /include/base/vBase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023~Now Margoo 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | /** 24 | * \file vBase.h 25 | * \brief The base library in VUILib 26 | */ 27 | 28 | #pragma once 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | #include 36 | 37 | #pragma warning(disable : 4244) 38 | 39 | namespace std { 40 | /** 41 | * The template specialization for std::hash in order to provide for unordered_map key 42 | */ 43 | template <> struct hash { 44 | _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef ostr::text argument_type; 45 | _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef size_t result_type; 46 | _NODISCARD size_t operator()(const ostr::text _Keyval) const noexcept { 47 | return hash().operator()(_Keyval.c_str()); 48 | } 49 | }; 50 | } // namespace std 51 | 52 | using OString = ostr::text; 53 | using OStringView = ostr::text_view; 54 | 55 | namespace VConcept { 56 | template