├── .github ├── CONTRIBUTING.md ├── FUNDING.yaml ├── ISSUE_TEMPLATE │ ├── bug-report.md │ └── feature-request.md ├── auto-issue-template.md ├── dependabot.yml └── workflows │ ├── ci.yaml │ ├── release.yaml │ └── update-dependencies.yaml ├── .gitignore ├── .gitmodules ├── Config ├── Core │ ├── DefaultLayout.ini │ ├── FallbackLayout.ini │ ├── Keybindings.yaml │ ├── Modules.yaml │ ├── Renderer.yaml │ └── Window.yaml ├── Resources │ ├── Icon.icns │ ├── Icon.ico │ ├── Icon.iconset │ │ ├── icon_128x128.png │ │ ├── icon_128x128@2x.png │ │ ├── icon_16x16.png │ │ ├── icon_16x16@2x.png │ │ ├── icon_256x256.png │ │ ├── icon_256x256@2x.png │ │ ├── icon_32x32.png │ │ ├── icon_32x32@2x.png │ │ ├── icon_512x512.png │ │ └── icon_512x512@2x.png │ ├── Info.plist │ ├── resource.h │ └── resource.rc ├── Theme │ └── default.theme.yaml ├── Translations │ └── ui18n-config.yaml └── WASM │ ├── post.js │ └── pre.js ├── Content ├── example-icon.png └── madladsquadlogo.png ├── Framework ├── C │ ├── CAllocator.cpp │ ├── CAllocator.h │ ├── CDefines.h │ ├── CTypes.h │ ├── Components │ │ ├── CComponentCommon.h │ │ ├── CInlineComponent.cpp │ │ ├── CInlineComponent.h │ │ ├── CInstance.cpp │ │ ├── CInstance.h │ │ ├── CTitlebarComponent.cpp │ │ ├── CTitlebarComponent.h │ │ ├── CWindowComponent.cpp │ │ └── CWindowComponent.h │ ├── Interfaces │ │ ├── CInput.cpp │ │ ├── CInput.h │ │ ├── CLayoutsInterface.cpp │ │ ├── CLayoutsInterface.h │ │ ├── CPluginInterface.cpp │ │ ├── CPluginInterface.h │ │ ├── CRendererInterface.cpp │ │ ├── CRendererInterface.h │ │ ├── CUtility.cpp │ │ ├── CUtility.h │ │ ├── CWindowInterface.cpp │ │ └── CWindowInterface.h │ ├── Internal │ │ ├── CMonitor.cpp │ │ ├── CMonitor.h │ │ ├── Keys.h │ │ └── RendererData.h │ ├── Modules │ │ ├── Manager │ │ │ ├── CModulesManager.cpp │ │ │ └── CModulesManager.hpp │ │ └── Undo │ │ │ ├── Undo.cpp │ │ │ └── Undo.h │ ├── README.md │ ├── Rendering │ │ ├── CClientSideBar.cpp │ │ ├── CClientSideBar.h │ │ ├── CGenericRenderer.cpp │ │ ├── CGenericRenderer.h │ │ ├── CGenericTexture.cpp │ │ ├── CGenericTexture.h │ │ ├── CRendererUtils.cpp │ │ ├── CRendererUtils.h │ │ ├── CTexture.cpp │ │ └── CTexture.h │ └── UImGuiCAPI.h ├── Core │ ├── Allocator.cpp │ ├── Allocator.hpp │ ├── CDeallocation.hpp │ ├── Components │ │ ├── InlineComponent.cpp │ │ ├── InlineComponent.hpp │ │ ├── Instance.cpp │ │ ├── Instance.hpp │ │ ├── TitlebarComponent.cpp │ │ ├── TitlebarComponent.hpp │ │ ├── WindowComponent.cpp │ │ └── WindowComponent.hpp │ ├── Core.hpp │ ├── Defines.hpp │ ├── FrameworkMain.cpp │ ├── FrameworkMain.hpp │ ├── Global.cpp │ ├── Global.hpp │ ├── Interfaces │ │ ├── Input.cpp │ │ ├── Input.hpp │ │ ├── LayoutsInterface.cpp │ │ ├── LayoutsInterface.hpp │ │ ├── PluginInterface.cpp │ │ ├── PluginInterface.hpp │ │ ├── RendererInterface.cpp │ │ ├── RendererInterface.hpp │ │ ├── WindowInterface.cpp │ │ └── WindowInterface.hpp │ ├── Platform │ │ ├── WASM.cpp │ │ ├── WASM.hpp │ │ └── framework_pre.js │ ├── Types.cpp │ ├── Types.hpp │ ├── Utilities.cpp │ └── Utilities.hpp ├── Framework.hpp ├── Modules │ ├── Manager │ │ ├── ModulesManager.cpp │ │ └── ModulesManager.hpp │ ├── Modules.hpp │ ├── OS │ │ └── src │ │ │ ├── OS.cpp │ │ │ └── OS.hpp │ ├── Undo │ │ └── src │ │ │ ├── Undo.cpp │ │ │ └── Undo.hpp │ └── i18n │ │ └── src │ │ ├── CI18NModule.h │ │ ├── I18NModule.cpp │ │ └── I18NModule.hpp ├── Renderer │ ├── GenericRenderer │ │ ├── GenericRenderer.cpp │ │ ├── GenericRenderer.hpp │ │ ├── GenericTexture.cpp │ │ └── GenericTexture.hpp │ ├── ImGui │ │ ├── ClientSideBar.cpp │ │ ├── ClientSideBar.hpp │ │ ├── ImGui.cpp │ │ ├── ImGui.hpp │ │ ├── UImGuiExtensions.cpp │ │ └── UImGuiExtensions.hpp │ ├── OpenGL │ │ ├── OpenGLRenderer.cpp │ │ ├── OpenGLRenderer.hpp │ │ ├── OpenGLTexture.cpp │ │ └── OpenGLTexture.hpp │ ├── Renderer.cpp │ ├── Renderer.hpp │ ├── RendererUtils.cpp │ ├── RendererUtils.hpp │ ├── Texture.cpp │ ├── Texture.hpp │ ├── Vulkan │ │ ├── Components │ │ │ ├── VKDescriptors.cpp │ │ │ ├── VKDescriptors.hpp │ │ │ ├── VKDevice.cpp │ │ │ ├── VKDevice.hpp │ │ │ ├── VKDraw.cpp │ │ │ ├── VKDraw.hpp │ │ │ ├── VKInstance.cpp │ │ │ ├── VKInstance.hpp │ │ │ ├── VKSurface.cpp │ │ │ ├── VKSurface.hpp │ │ │ ├── VKUtility.cpp │ │ │ └── VKUtility.hpp │ │ ├── VulkanRenderer.cpp │ │ ├── VulkanRenderer.hpp │ │ ├── VulkanTexture.cpp │ │ └── VulkanTexture.hpp │ ├── WebGPU │ │ ├── WebGPURenderer.cpp │ │ ├── WebGPURenderer.hpp │ │ ├── WebGPUTexture.cpp │ │ └── WebGPUTexture.hpp │ └── Window │ │ ├── Callbacks.cpp │ │ ├── Monitors.cpp │ │ ├── Platform.cpp │ │ ├── Window.cpp │ │ ├── Window.hpp │ │ └── macOS │ │ ├── MacOSWindowPlatform.h │ │ └── MacOSWindowPlatform.mm ├── ThirdParty │ ├── glad │ │ ├── include │ │ │ ├── KHR │ │ │ │ └── khrplatform.h │ │ │ └── glad │ │ │ │ ├── gl.h │ │ │ │ ├── gles1.h │ │ │ │ ├── gles2.h │ │ │ │ └── glsc2.h │ │ └── src │ │ │ ├── gl.c │ │ │ ├── gles1.c │ │ │ ├── gles2.c │ │ │ └── glsc2.c │ ├── source-libraries │ │ ├── LICENSE-STB │ │ ├── cimgui │ │ │ ├── cimgui.cpp │ │ │ └── cimgui.h │ │ ├── stb_image.h │ │ └── stb_image_write.h │ └── vulkan │ │ ├── libvulkan.1.dylib │ │ └── vulkan-1.lib └── cmake │ ├── CompileProject.cmake │ ├── FindYamlCpp.cmake │ ├── PluginDefaultsInit.cmake │ ├── PluginDefaultsPostInst.cmake │ ├── SetupCompilation.cmake │ ├── SetupLanguageBoilerplate.cmake │ ├── SetupSources.cmake │ ├── SetupTargetSettings.cmake │ ├── UImGuiHeader.cmake │ ├── UImGuiSetupCMake.cmake │ ├── UntitledImGuiFramework.pc.in │ └── Version.cmake ├── LICENSE ├── README.md ├── create-plugin.sh ├── create-project.sh ├── example.gitignore ├── export.sh ├── install.sh ├── shell.nix └── update.sh /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing guidelines 2 | These are the guidelines 3 | - Follow the ToS 4 | - Follow the CoC 5 | - Contribute useful information, i.e. fixing a bug, adding a feature, etc, not removing whitespaces, etc 6 | - Check if your code works and test for any vulnerabilities before contributing 7 | -------------------------------------------------------------------------------- /.github/FUNDING.yaml: -------------------------------------------------------------------------------- 1 | ko_fi: madladsquad -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behaviour: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See an error 19 | 20 | **Expected behaviour** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | Share screenshots if any 25 | 26 | **Technical information** 27 | - OS: (eg. Windows) 28 | - Release: (eg. 0.5.1) 29 | - Any other applicable technical information 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/auto-issue-template.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Daily automatic dependency update issue! 3 | assignees: Madman10K 4 | labels: enhancement 5 | --- 6 | Automatic issue for updating the submodules to latest! [Go to PR](https://github.com/MadLadSquad/UntitledImGuiFramework/compare/master...auto)! 7 | 8 | @MadLadSquad/dependencies 9 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "monthly" 7 | groups: 8 | github-actions: 9 | patterns: 10 | - "*" 11 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | tags: 4 | - 'v*' 5 | name: Create Release 6 | 7 | jobs: 8 | build: 9 | name: Create Release 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout code 13 | uses: actions/checkout@v4 14 | with: 15 | lfs: true 16 | submodules: true 17 | - name: Checkout submodules 18 | shell: bash 19 | run: | 20 | git submodule sync --recursive 21 | git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 22 | - name: "Import bot's GPG key for signing commits" 23 | id: import-gpg 24 | uses: crazy-max/ghaction-import-gpg@v6 25 | with: 26 | gpg_private_key: ${{ secrets.ACTION_COMMIT_SING_PRIVATE_KEY }} 27 | passphrase: ${{ secrets.ACTION_COMMIT_SING_PASS }} 28 | git_config_global: true 29 | git_user_signingkey: true 30 | git_commit_gpgsign: true 31 | - name: Extract commit data 32 | uses: rlespinasse/git-commit-data-action@v1.x 33 | - name: Get tag 34 | id: tag 35 | shell: bash 36 | run: | 37 | git config --global user.name "Madman10K" 38 | git config --global user.email "contact@madladsquad.com" 39 | git fetch --all 40 | git submodule update --remote --merge --init --recursive 41 | tag="${{ github.ref_name }}" 42 | tag="${tag:1}" 43 | numeric_tag="${tag//.}" 44 | numeric_tag="$(echo ${numeric_tag} | sed 's/^0*//')" 45 | 46 | echo "out=untitled-imgui-framework-${tag}" >> $GITHUB_OUTPUT 47 | 48 | sed -i "s/set(UIMGUI_FRAMEWORK_VERSION .*/set(UIMGUI_FRAMEWORK_VERSION ${tag})/g" Framework/cmake/Version.cmake 49 | sed -i "s/set(UIMGUI_FRAMEWORK_VERSION_NUMERIC .*)/set(UIMGUI_FRAMEWORK_VERSION_NUMERIC ${numeric_tag})/g" Framework/cmake/Version.cmake 50 | (git add . && git commit -m "Automatically bump version" && git push origin HEAD:master) || echo "Nothing to commit" 51 | - name: Create archive 52 | shell: bash 53 | run: | 54 | rm -rf .git/ 55 | 56 | mkdir "${{ steps.tag.outputs.out }}" || exit 57 | mv * ${{ steps.tag.outputs.out }}/ || echo "Errors in move" 58 | mv .* "${{ steps.tag.outputs.out }}" || echo "Errors in move" 59 | 60 | tar cfJ ${{ steps.tag.outputs.out }}.tar.xz ${{ steps.tag.outputs.out }} || echo "Might have failed" 61 | - name: Create Release 62 | uses: softprops/action-gh-release@v2 63 | with: 64 | body: | 65 | Check our discord for patch notes: https://discord.gg/4kyWu2Vu 66 | More on what is done this month can be found on the latest newsletter entry: https://madladsquad.com/#monthly-newsletter 67 | draft: false 68 | prerelease: false 69 | files: ${{ steps.tag.outputs.out }}.tar.xz 70 | generate_release_notes: false 71 | -------------------------------------------------------------------------------- /.github/workflows/update-dependencies.yaml: -------------------------------------------------------------------------------- 1 | name: Update Dependencies 2 | on: 3 | push: 4 | branches: [ master ] 5 | schedule: 6 | - cron: "0 2 * * *" 7 | - cron: "0 8 * * *" 8 | - cron: "0 14 * * *" 9 | - cron: "0 20 * * *" 10 | jobs: 11 | Update: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: checking out code 15 | uses: actions/checkout@v4 16 | with: 17 | ref: master 18 | token: ${{ secrets.GITHUB_TOKEN }} 19 | lfs: false 20 | submodules: true 21 | clean: false 22 | fetch-depth: 0 23 | #persist-credentials: false 24 | - name: "Import bot's GPG key for signing commits" 25 | id: import-gpg 26 | uses: crazy-max/ghaction-import-gpg@v6 27 | with: 28 | gpg_private_key: ${{ secrets.ACTION_COMMIT_SING_PRIVATE_KEY }} 29 | passphrase: ${{ secrets.ACTION_COMMIT_SING_PASS }} 30 | git_config_global: true 31 | git_user_signingkey: true 32 | git_commit_gpgsign: true 33 | 34 | - name: Extract commit data 35 | uses: rlespinasse/git-commit-data-action@v1.x 36 | - name: Update submodules 37 | id: mod 38 | run: | 39 | git config --global user.name "Madman10K" 40 | git config --global user.email "contact@madladsquad.com" 41 | git fetch --all 42 | git checkout auto || git checkout -b auto 43 | git submodule update --remote --merge --init 44 | cd Framework/ThirdParty/source-libraries/cimgui || exit 45 | git clone https://github.com/dearimgui/dear_bindings.git --recursive || exit 46 | cd dear_bindings || exit 47 | python3 -m venv venv 48 | source venv/bin/activate 49 | pip install -r requirements.txt 50 | python3 dear_bindings.py --imconfig-path ../../../imgui/core/imconfig.h -o cimgui ../../../imgui/core/imgui.h 51 | mv cimgui.cpp cimgui.h ../ 52 | cd .. || exit 53 | deactivate 54 | rm -rf dear_bindings 55 | cd ../../glad || exit 56 | rm -rf include src || exit 57 | git clone https://github.com/Dav1dde/glad.git --recursive 58 | cd glad 59 | python3 -m venv venv 60 | source venv/bin/activate 61 | pip install -r requirements.txt 62 | python3 -m glad --api gl:core,gles1,gles2,glsc2 --out-path ../ 63 | cd .. 64 | sed -i "s/generated by glad .*//g" include/glad/gl.h include/glad/gles1.h include/glad/gles2.h include/glad/glsc2.h 65 | rm -rf glad 66 | cd ../../../ || exit 67 | (git add . && git commit -m "auto" && git push origin HEAD:auto && echo "out=s" >> $GITHUB_OUTPUT) || echo "out=?" >> $GITHUB_OUTPUT 68 | - name: Create PR 69 | if: "steps.mod.outputs.out != '?'" 70 | uses: JasonEtco/create-an-issue@v2 71 | env: 72 | GITHUB_TOKEN: ${{ secrets.ACTION_ISSUE_SECRET }} 73 | with: 74 | filename: .github/auto-issue-template.md 75 | update_existing: true 76 | search_existing: open 77 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | !libvulkan.1.dylib 18 | *.dll 19 | 20 | # Fortran module files 21 | *.mod 22 | *.smod 23 | 24 | # Compiled Static libraries 25 | *.lai 26 | *.la 27 | *.a 28 | *.lib 29 | 30 | # Executables 31 | *.exe 32 | *.out 33 | *.app 34 | *.aps 35 | 36 | !Framework/ThirdParty/vulkan/vulkan-1.lib 37 | 38 | build/ 39 | cmake-build-relwithdebinfo/ 40 | cmake-build-debug/ 41 | cmake-build-release/ 42 | main.cpp 43 | .vs/ 44 | .idea/ 45 | Projects/ 46 | Generated/ 47 | Source/ 48 | 49 | uvproj.yaml 50 | CMakeLists.txt 51 | 52 | docs/ 53 | 54 | .DS_Store 55 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "UVKBuildTool"] 2 | path = UVKBuildTool 3 | url = https://github.com/MadLadSquad/UVKBuildTool.git 4 | branch = master 5 | [submodule "Framework/ThirdParty/logger"] 6 | path = Framework/ThirdParty/logger 7 | url = https://github.com/MadLadSquad/UntitledLog.git 8 | branch = master 9 | [submodule "Framework/ThirdParty/yaml-cpp"] 10 | path = Framework/ThirdParty/yaml-cpp 11 | url = https://github.com/MadLadSquad/yaml-cpp.git 12 | [submodule "Framework/ThirdParty/imgui"] 13 | path = Framework/ThirdParty/imgui 14 | url = https://github.com/MadLadSquad/imgui.git 15 | [submodule "Framework/ThirdParty/glfw"] 16 | path = Framework/ThirdParty/glfw 17 | url = https://github.com/MadLadSquad/glfw.git 18 | [submodule "Framework/Modules/Plotting/ThirdParty/implot"] 19 | path = Framework/Modules/Plotting/ThirdParty/implot 20 | url = https://github.com/MadLadSquad/implot.git 21 | [submodule "Framework/ThirdParty/source-libraries/urll"] 22 | path = Framework/ThirdParty/source-libraries/urll 23 | url = https://github.com/MadLadSquad/UntitledRuntimeLibraryLoader.git 24 | [submodule "Framework/Modules/OS/ThirdParty/uexec"] 25 | path = Framework/Modules/OS/ThirdParty/uexec 26 | url = https://github.com/MadLadSquad/UntitledExec.git 27 | [submodule "Framework/Modules/Knobs/ThirdParty/imgui-knobs"] 28 | path = Framework/Modules/Knobs/ThirdParty/imgui-knobs 29 | url = https://github.com/altschuler/imgui-knobs.git 30 | [submodule "Framework/Modules/Spinners/ThirdParty/imspinner"] 31 | path = Framework/Modules/Spinners/ThirdParty/imspinner 32 | url = https://github.com/dalerank/imspinner.git 33 | [submodule "Framework/Modules/Toggles/ThirdParty/imgui_toggle"] 34 | path = Framework/Modules/Toggles/ThirdParty/imgui_toggle 35 | url = https://github.com/cmdwtf/imgui_toggle.git 36 | [submodule "Framework/ThirdParty/freetype"] 37 | path = Framework/ThirdParty/freetype 38 | url = https://github.com/MadLadSquad/freetype.git 39 | [submodule "Framework/Modules/CLIParser/ThirdParty/UntitledCLIParser"] 40 | path = Framework/Modules/CLIParser/ThirdParty/UntitledCLIParser 41 | url = https://github.com/MadLadSquad/UntitledCLIParser.git 42 | [submodule "Framework/ThirdParty/vulkan-headers"] 43 | path = Framework/ThirdParty/vulkan-headers 44 | url = https://github.com/KhronosGroup/Vulkan-Headers.git 45 | [submodule "Framework/Modules/OS/ThirdParty/UntitledXDGBasedir"] 46 | path = Framework/Modules/OS/ThirdParty/UntitledXDGBasedir 47 | url = https://github.com/MadLadSquad/UntitledXDGBasedir.git 48 | [submodule "Framework/Modules/TextUtils/ThirdParty/UntitledImGuiTextUtils"] 49 | path = Framework/Modules/TextUtils/ThirdParty/UntitledImGuiTextUtils 50 | url = https://github.com/MadLadSquad/UntitledImGuiTextUtils.git 51 | [submodule "Framework/Modules/OS/ThirdParty/UntitledDBusUtils"] 52 | path = Framework/Modules/OS/ThirdParty/UntitledDBusUtils 53 | url = https://github.com/MadLadSquad/UntitledDBusUtils.git 54 | [submodule "Framework/Modules/Theming/ThirdParty/UntitledImGuiTheme"] 55 | path = Framework/Modules/Theming/ThirdParty/UntitledImGuiTheme 56 | url = https://github.com/MadLadSquad/UntitledImGuiTheme.git 57 | [submodule "Framework/Modules/i18n/ThirdParty/UntitledI18N"] 58 | path = Framework/Modules/i18n/ThirdParty/UntitledI18N 59 | url = https://github.com/MadLadSquad/UntitledI18N.git 60 | [submodule "Framework/Modules/OS/ThirdParty/UntitledOpen"] 61 | path = Framework/Modules/OS/ThirdParty/UntitledOpen 62 | url = https://github.com/MadLadSquad/UntitledOpen.git 63 | [submodule "Framework/ThirdParty/source-libraries/parallel-hashmap"] 64 | path = Framework/ThirdParty/source-libraries/parallel-hashmap 65 | url = https://github.com/MadLadSquad/parallel-hashmap.git 66 | [submodule "Framework/ThirdParty/utfcpp"] 67 | path = Framework/ThirdParty/utfcpp 68 | url = https://github.com/MadLadSquad/utfcpp.git 69 | [submodule "Framework/ThirdParty/source-libraries/cimgui/cimgui_extra"] 70 | path = Framework/ThirdParty/source-libraries/cimgui/cimgui_extra 71 | url = https://github.com/MadLadSquad/cimgui_extra.git 72 | -------------------------------------------------------------------------------- /Config/Core/DefaultLayout.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Config/Core/DefaultLayout.ini -------------------------------------------------------------------------------- /Config/Core/FallbackLayout.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Config/Core/FallbackLayout.ini -------------------------------------------------------------------------------- /Config/Core/Keybindings.yaml: -------------------------------------------------------------------------------- 1 | bindings: 2 | - key: empty-binding 3 | val: [ 1 ] -------------------------------------------------------------------------------- /Config/Core/Modules.yaml: -------------------------------------------------------------------------------- 1 | undo-max-transactions: 100 2 | theme-location: "default" -------------------------------------------------------------------------------- /Config/Core/Renderer.yaml: -------------------------------------------------------------------------------- 1 | renderer: opengl # For built-in OpenGL(opengl, gl, ogl or legacy), for built-in Vulkan/WebGPU(vulkan, vk, webgpu, wgpu), custom for custom renderers 2 | v-sync: true # To run or not to run in V-Sync mode 3 | msaa-samples: 8 # Multisampling sample count 4 | power-saving: # The power saving mode limits the number of frames that are drawn when idling. Will not work for applications with live plots or animations 5 | enabled: true 6 | idle-frames: 9 # The number of frames to output while idling -------------------------------------------------------------------------------- /Config/Core/Window.yaml: -------------------------------------------------------------------------------- 1 | layout-location: "DefaultLayout" # The location of the layout file ImGui writes to 2 | load-layout: true # Whether to load the layout file ImGui writes to 3 | save-layout: true # Whether to automatically save to the layout file ImGui writes to 4 | icon: "example-icon.png" # The location of the window icon image 5 | width: 800 # Width of the window in pixels 6 | height: 600 # Height of the window in pixels 7 | fullscreen: false # Enable or disable fullscreen mode 8 | window-name: UntitledImGuiFramework Application # The name of the window 9 | resizeable: false # Can the window be resized 10 | transparent-surface: true # Transparency for the render surface, platform dependant, ImGuiCol_WindowBg.w controls this 11 | hidden: false # The default visibility of the window 12 | focused: true # Default focused state 13 | size-limits: [ -1, -1, -1, -1 ] # Limit the size of the Window in vec4 format: x = min x, y = min y, z = max x, w = max y. -1 = no limit 14 | aspect-ratio-size-limit: [ -1, -1 ] # Limit the size of the Window using an aspect ratio x/y. -1 = no limit 15 | decorated: false # Enable or disable window decorations 16 | maximised: false # Enable or disable window maximisation -------------------------------------------------------------------------------- /Config/Resources/Icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Config/Resources/Icon.icns -------------------------------------------------------------------------------- /Config/Resources/Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Config/Resources/Icon.ico -------------------------------------------------------------------------------- /Config/Resources/Icon.iconset/icon_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Config/Resources/Icon.iconset/icon_128x128.png -------------------------------------------------------------------------------- /Config/Resources/Icon.iconset/icon_128x128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Config/Resources/Icon.iconset/icon_128x128@2x.png -------------------------------------------------------------------------------- /Config/Resources/Icon.iconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Config/Resources/Icon.iconset/icon_16x16.png -------------------------------------------------------------------------------- /Config/Resources/Icon.iconset/icon_16x16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Config/Resources/Icon.iconset/icon_16x16@2x.png -------------------------------------------------------------------------------- /Config/Resources/Icon.iconset/icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Config/Resources/Icon.iconset/icon_256x256.png -------------------------------------------------------------------------------- /Config/Resources/Icon.iconset/icon_256x256@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Config/Resources/Icon.iconset/icon_256x256@2x.png -------------------------------------------------------------------------------- /Config/Resources/Icon.iconset/icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Config/Resources/Icon.iconset/icon_32x32.png -------------------------------------------------------------------------------- /Config/Resources/Icon.iconset/icon_32x32@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Config/Resources/Icon.iconset/icon_32x32@2x.png -------------------------------------------------------------------------------- /Config/Resources/Icon.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Config/Resources/Icon.iconset/icon_512x512.png -------------------------------------------------------------------------------- /Config/Resources/Icon.iconset/icon_512x512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Config/Resources/Icon.iconset/icon_512x512@2x.png -------------------------------------------------------------------------------- /Config/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | CFBundleName 7 | UImGuiDemo 8 | 9 | CFBundleDisplayName 10 | UntitledImGuiFramework Demo 11 | 12 | CFBundleIdentifier 13 | com.madladsquad.UImGuiDemo 14 | 15 | CFBundleVersion 16 | 1.0 17 | 18 | CFBundleShortVersionString 19 | 1.0.0 20 | 21 | 22 | CFBundleExecutable 23 | UImGuiDemo 24 | 25 | CFBundlePackageType 26 | APPL 27 | 28 | 29 | CFBundleIconFile 30 | Icon.icns 31 | 32 | 33 | LSMinimumSystemVersion 34 | 12.0.0 35 | 36 | 37 | NSHighResolutionCapable 38 | 39 | 40 | 41 | LSApplicationCategoryType 42 | public.app-category.utilities 43 | 44 | 45 | NSAppTransportSecurity 46 | 47 | NSAllowsArbitraryLoads 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /Config/Resources/resource.h: -------------------------------------------------------------------------------- 1 | #define IDI_APP_ICON 101 2 | #define IDS_APP_TITLE 102 3 | -------------------------------------------------------------------------------- /Config/Resources/resource.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | 3 | IDI_APP_ICON ICON "Icon.ico" -------------------------------------------------------------------------------- /Config/Theme/default.theme.yaml: -------------------------------------------------------------------------------- 1 | Text: [ 1.00, 1.00, 1.00, 1.00 ] 2 | TextDisabled": [ 0.50, 0.50, 0.50, 1.00 ] 3 | WindowBg": [ 0.06, 0.06, 0.06, 0.94 ] 4 | ChildBg": [ 0.00, 0.00, 0.00, 0.00 ] 5 | PopupBg": [ 0.08, 0.08, 0.08, 0.94 ] 6 | Border": [ 0.43, 0.43, 0.50, 0.50 ] 7 | BorderShadow": [ 0.00, 0.00, 0.00, 0.00 ] 8 | FrameBg": [ 0.16, 0.29, 0.48, 0.54 ] 9 | FrameBgHovered": [ 0.26, 0.59, 0.98, 0.40 ] 10 | FrameBgActive": [ 0.26, 0.59, 0.98, 0.67 ] 11 | TitleBg": [ 0.04, 0.04, 0.04, 1.00 ] 12 | TitleBgActive": [ 0.16, 0.29, 0.48, 1.00 ] 13 | TitleBgCollapsed": [ 0.00, 0.00, 0.00, 0.51 ] 14 | MenuBarBg": [ 0.14, 0.14, 0.14, 1.00 ] 15 | ScrollbarBg": [ 0.02, 0.02, 0.02, 0.53 ] 16 | ScrollbarGrab": [ 0.31, 0.31, 0.31, 1.00 ] 17 | ScrollbarGrabHovered": [ 0.41, 0.41, 0.41, 1.00 ] 18 | ScrollbarGrabActive": [ 0.51, 0.51, 0.51, 1.00 ] 19 | CheckMark": [ 0.26, 0.59, 0.98, 1.00 ] 20 | SliderGrab": [ 0.24, 0.52, 0.88, 1.00 ] 21 | SliderGrabActive": [ 0.26, 0.59, 0.98, 1.00 ] 22 | Button": [ 0.26, 0.59, 0.98, 0.40 ] 23 | ButtonHovered": [ 0.26, 0.59, 0.98, 1.00 ] 24 | ButtonActive": [ 0.06, 0.53, 0.98, 1.00 ] 25 | Header": [ 0.26, 0.59, 0.98, 0.31 ] 26 | HeaderHovered": [ 0.26, 0.59, 0.98, 0.80 ] 27 | HeaderActive": [ 0.26, 0.59, 0.98, 1.00 ] 28 | Separator": [ 0.43, 0.43, 0.50, 0.50 ] 29 | SeparatorHovered": [ 0.10, 0.40, 0.75, 0.78 ] 30 | SeparatorActive": [ 0.10, 0.40, 0.75, 1.00 ] 31 | ResizeGrip": [ 0.26, 0.59, 0.98, 0.20 ] 32 | ResizeGripHovered": [ 0.26, 0.59, 0.98, 0.67 ] 33 | ResizeGripActive": [ 0.26, 0.59, 0.98, 0.95 ] 34 | Tab": [ 0.336 0.336 0.684 0.786 ] 35 | TabHovered": [ 0.26, 0.59, 0.98, 0.80 ] 36 | TabActive": [ 0.336 0.336 0.684 0.786 ] 37 | TabUnfocused": [ 0.336 0.336 0.684 0.786 ] 38 | TabUnfocusedActive": [ 0.336 0.336 0.684 0.786 ] 39 | DockingPreview": [ 0.336 0.336 0.684 0.786 ] 40 | DockingEmptyBg": [ 0.20, 0.20, 0.20, 1.00 ] 41 | PlotLines": [ 0.61, 0.61, 0.61, 1.00 ] 42 | PlotLinesHovered": [ 1.00, 0.43, 0.35, 1.00 ] 43 | PlotHistogram": [ 0.90, 0.70, 0.00, 1.00 ] 44 | PlotHistogramHovered": [ 1.00, 0.60, 0.00, 1.00 ] 45 | TableHeaderBg": [ 0.19, 0.19, 0.20, 1.00 ] 46 | TableBorderStrong": [ 0.31, 0.31, 0.35, 1.00 ] 47 | TableBorderLight": [ 0.23, 0.23, 0.25, 1.00 ] 48 | TableRowBg": [ 0.00, 0.00, 0.00, 0.00 ] 49 | TableRowBgAlt": [ 1.00, 1.00, 1.00, 0.06 ] 50 | TextSelectedBg": [ 0.26, 0.59, 0.98, 0.35 ] 51 | DragDropTarget": [ 1.00, 1.00, 0.00, 0.90 ] 52 | NavHighlight": [ 0.26, 0.59, 0.98, 1.00 ] 53 | NavWindowingHighlight": [ 1.00, 1.00, 1.00, 0.70 ] 54 | NavWindowingDimBg": [ 0.80, 0.80, 0.80, 0.20 ] 55 | ModalWindowDimBg": [ 0.80, 0.80, 0.80, 0.35 ] 56 | Alpha: 1 57 | DisabledAlpha: 0.6 58 | WindowPadding: [ 8, 8 ] 59 | WindowRounding: 0 60 | WindowBorderSize: 1 61 | WindowMinSize: [ 32, 32 ] 62 | WindowTitleAlign: [ 0, 0.5 ] 63 | ChildRounding: 0 64 | ChildBorderSize: 1 65 | PopupRounding: 0 66 | PopupBorderSize: 1 67 | FramePadding: [ 4, 3 ] 68 | FrameRounding: 0 69 | FrameBorderSize: 0 70 | ItemSpacing: [ 8, 4 ] 71 | ItemInnerSpacing: [ 4, 4 ] 72 | IndentSpacing: 21 73 | CellPadding: [ 4, 2 ] 74 | ScrollbarSize: 14 75 | ScrollbarRounding: 9 76 | GrabMinSize: 12 77 | GrabRounding: 0 78 | TabRounding: 4 79 | ButtonTextAlign: [ 0.5, 0.5 ] 80 | SelectableTextAlign: [ 0, 0 ] 81 | SeparatorTextBorderSize: 3 82 | SeparatorTextAlign: [ 0, 0.5 ] 83 | SeparatorTextPadding: [ 20, 3 ] 84 | DockingSeparatorSize: 2 -------------------------------------------------------------------------------- /Config/Translations/ui18n-config.yaml: -------------------------------------------------------------------------------- 1 | terms: 2 | - example: example -------------------------------------------------------------------------------- /Config/WASM/post.js: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Config/WASM/pre.js: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Content/example-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Content/example-icon.png -------------------------------------------------------------------------------- /Content/madladsquadlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Content/madladsquadlogo.png -------------------------------------------------------------------------------- /Framework/C/CAllocator.cpp: -------------------------------------------------------------------------------- 1 | #include "CAllocator.h" 2 | #include 3 | 4 | void* UImGui_Allocator_private_allocate(const size_t n) 5 | { 6 | return malloc(n); 7 | } 8 | 9 | void UImGui_Allocator_private_deallocate(void* ptr) 10 | { 11 | free(ptr); 12 | } 13 | 14 | void* UImGui_Allocator_allocate(const size_t n) 15 | { 16 | return UImGui::AllocatorFuncs::get().allocate(n); 17 | } 18 | 19 | void UImGui_Allocator_deallocate(void* ptr) 20 | { 21 | UImGui::AllocatorFuncs::get().deallocate(ptr); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Framework/C/CAllocator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "CDefines.h" 3 | 4 | #ifdef __cplusplus 5 | extern "C" 6 | { 7 | #endif 8 | UIMGUI_PUBLIC_API void* UImGui_Allocator_private_allocate(size_t n); 9 | UIMGUI_PUBLIC_API void UImGui_Allocator_private_deallocate(void* ptr); 10 | 11 | UIMGUI_PUBLIC_API void* UImGui_Allocator_allocate(size_t n); 12 | UIMGUI_PUBLIC_API void UImGui_Allocator_deallocate(void* ptr); 13 | #ifdef __cplusplus 14 | } 15 | #endif -------------------------------------------------------------------------------- /Framework/C/CDefines.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" 8 | { 9 | #else 10 | #include 11 | #endif 12 | // Dll macro magic 13 | #ifdef _WIN32 14 | #ifdef UIMGUI_COMPILE_LIB 15 | #define UIMGUI_PUBLIC_API __declspec(dllexport) 16 | #define IMGUI_API __declspec(dllexport) 17 | #define CIMGUI_API __declspec(dllexport) 18 | #else 19 | #define UIMGUI_PUBLIC_API __declspec(dllimport) 20 | #define IMGUI_API __declspec(dllimport) 21 | #define CIMGUI_API __declspec(dllimport) 22 | #endif 23 | #else 24 | #define UIMGUI_PUBLIC_API 25 | #endif 26 | 27 | #define X11_WINDOW_TYPE_DESKTOP "_NET_WM_WINDOW_TYPE_DESKTOP" 28 | #define X11_WINDOW_TYPE_DOCK "_NET_WM_WINDOW_TYPE_DOCK" 29 | #define X11_WINDOW_TYPE_TOOLBAR "_NET_WM_WINDOW_TYPE_TOOLBAR" 30 | #define X11_WINDOW_TYPE_MENU "_NET_WM_WINDOW_TYPE_MENU" 31 | #define X11_WINDOW_TYPE_UTILITY "_NET_WM_WINDOW_TYPE_UTILITY" 32 | #define X11_WINDOW_TYPE_SPLASH "_NET_WM_WINDOW_TYPE_SPLASH" 33 | #define X11_WINDOW_TYPE_DIALOG "_NET_WM_WINDOW_TYPE_DIALOG" 34 | #define X11_WINDOW_TYPE_DROPDOWN_MENU "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU" 35 | #define X11_WINDOW_TYPE_POPUP_MENU "_NET_WM_WINDOW_TYPE_POPUP_MENU" 36 | #define X11_WINDOW_TYPE_TOOLTIP "_NET_WM_WINDOW_TYPE_TOOLTIP" 37 | #define X11_WINDOW_TYPE_NOTIFICATION "_NET_WM_WINDOW_TYPE_NOTIFICATION" 38 | #define X11_WINDOW_TYPE_COMBO "_NET_WM_WINDOW_TYPE_COMBO" 39 | #define X11_WINDOW_TYPE_DND "_NET_WM_WINDOW_TYPE_DND" 40 | #define X11_WINDOW_TYPE_NORMAL "_NET_WM_WINDOW_TYPE_NORMAL" 41 | 42 | #define UNUSED(x) (void)(x); 43 | #define CARRAY_SIZE(x) ((int)(sizeof(x) / sizeof(*(x)))) 44 | 45 | /** 46 | * @brief The ComponentState enum defines 3 fields that represent the event state of the given component, the given 47 | * component can then check its own state(if in PAUSED or RUNNING state) and call specific components of its event 48 | * functions. The OFF state is there to make it easy to fully shut down a component until the program closes 49 | */ 50 | typedef enum UImGui_ComponentState 51 | { 52 | // The component is not running but its events are still running 53 | UIMGUI_COMPONENT_STATE_PAUSED, 54 | // The component is running 55 | UIMGUI_COMPONENT_STATE_RUNNING, 56 | // The component is not running and its events are not running, only the constructor and destructor are called 57 | UIMGUI_COMPONENT_STATE_OFF, 58 | } UImGui_ComponentState; 59 | 60 | /** 61 | * @brief An enum that defines component types to be used by various functions 62 | * @var UIMGUI_COMPONENT_TYPE_INLINE - Defines an inline component 63 | * @var UIMGUI_COMPONENT_TYPE_TITLEBAR - Defines a titlebar component 64 | * @var UIMGUI_COMPONENT_PYE_WINDOW - Defines a window component 65 | */ 66 | typedef enum [[maybe_unused]] UImGui_ComponentType 67 | { 68 | UIMGUI_COMPONENT_TYPE_INLINE, 69 | UIMGUI_COMPONENT_TYPE_TITLEBAR, 70 | UIMGUI_COMPONENT_TYPE_WINDOW 71 | } UImGui_ComponentType; 72 | 73 | #ifdef __cplusplus 74 | }; 75 | #endif -------------------------------------------------------------------------------- /Framework/C/CTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "CDefines.h" 3 | 4 | #ifdef __cplusplus 5 | extern "C" 6 | { 7 | #endif 8 | typedef struct UIMGUI_PUBLIC_API UImGui_FVector2 9 | { 10 | float x; 11 | float y; 12 | } UImGui_FVector2; 13 | 14 | typedef struct UIMGUI_PUBLIC_API UImGui_FVector 15 | { 16 | float x; 17 | float y; 18 | float z; 19 | } UImGui_FVector; 20 | 21 | typedef struct UIMGUI_PUBLIC_API UImGui_FVector4 22 | { 23 | float x; 24 | float y; 25 | float z; 26 | float w; 27 | } UImGui_FVector4; 28 | 29 | typedef const char* UImGui_String; 30 | 31 | #ifdef __cplusplus 32 | }; 33 | #endif -------------------------------------------------------------------------------- /Framework/C/Components/CComponentCommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" 7 | { 8 | #endif 9 | typedef struct UIMGUI_PUBLIC_API UImGui_CComponentData 10 | { 11 | UImGui_ComponentState state; 12 | 13 | UImGui_String name; 14 | uint64_t id; 15 | } UImGui_CComponentData; 16 | 17 | typedef struct UIMGUI_PUBLIC_API UImGui_CComponentData_P 18 | { 19 | UImGui_ComponentState* state; 20 | uint64_t* id; 21 | } UImGui_CComponentData_P; 22 | 23 | typedef void* UImGui_CComponentHandle; 24 | typedef void(*UImGui_ComponentRegularFun)(UImGui_CComponentData_P*); 25 | typedef void(*UImGui_ComponentTickFun)(UImGui_CComponentData_P*, float); 26 | #ifdef __cplusplus 27 | } 28 | #endif -------------------------------------------------------------------------------- /Framework/C/Components/CInlineComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "CInlineComponent.h" 2 | #include 3 | 4 | class CInlineComponentInternalClass final : public UImGui::InlineComponent 5 | { 6 | public: 7 | CInlineComponentInternalClass() 8 | { 9 | construct(&data); 10 | } 11 | 12 | virtual void begin() override 13 | { 14 | beginAutohandle(); 15 | beginF(&data); 16 | } 17 | 18 | virtual void tick(const float deltaTime) override 19 | { 20 | tickAutohandle(deltaTime); 21 | tickF(&data, deltaTime); 22 | } 23 | 24 | virtual void end() override 25 | { 26 | endAutohandle(); 27 | endF(&data); 28 | } 29 | 30 | virtual ~CInlineComponentInternalClass() override 31 | { 32 | destruct(&data); 33 | } 34 | 35 | UImGui_CComponentData_P data = 36 | { 37 | .state = &state, 38 | .id = &id 39 | }; 40 | 41 | UImGui_ComponentRegularFun construct = [](UImGui_CComponentData_P*) -> void {}; 42 | UImGui_ComponentRegularFun beginF = [](UImGui_CComponentData_P*) -> void {}; 43 | UImGui_ComponentTickFun tickF = [](UImGui_CComponentData_P*, float) -> void {}; 44 | UImGui_ComponentRegularFun endF = [](UImGui_CComponentData_P*) -> void {}; 45 | UImGui_ComponentRegularFun destruct = [](UImGui_CComponentData_P*) -> void {}; 46 | }; 47 | 48 | 49 | UImGui_CComponentHandle UImGui_Inline_makeCInlineComponent(const UImGui_ComponentRegularFun construct, 50 | const UImGui_ComponentRegularFun begin, const UImGui_ComponentTickFun tick, const UImGui_ComponentRegularFun end, 51 | const UImGui_ComponentRegularFun destruct, const UImGui_CComponentData data) 52 | { 53 | auto* handle = dynamic_cast(UImGui::InlineComponent::make()); 54 | handle->state = data.state; 55 | handle->name = data.name; 56 | handle->id = data.id; 57 | 58 | handle->construct = construct; 59 | handle->beginF = begin; 60 | handle->tickF = tick; 61 | handle->endF = end; 62 | handle->destruct = destruct; 63 | 64 | return handle; 65 | } 66 | 67 | UImGui_CComponentData_P* UImGui_Inline_getCInlineComponentData(UImGui_CComponentHandle handle) 68 | { 69 | return &static_cast(handle)->data; 70 | } 71 | 72 | void UImGui_Inline_destroyCInlineComponent(UImGui_CComponentHandle handle) 73 | { 74 | delete (CInlineComponentInternalClass*)handle; 75 | } 76 | 77 | UImGui_String UImGui_Inline_getCInlineComponentName(UImGui_CComponentHandle handle) 78 | { 79 | return static_cast(handle)->name.c_str(); 80 | } -------------------------------------------------------------------------------- /Framework/C/Components/CInlineComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "CComponentCommon.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" 7 | { 8 | #endif 9 | // Event safety - Any time 10 | UIMGUI_PUBLIC_API UImGui_CComponentHandle UImGui_Inline_makeCInlineComponent(UImGui_ComponentRegularFun construct, 11 | UImGui_ComponentRegularFun begin, UImGui_ComponentTickFun tick, UImGui_ComponentRegularFun end, 12 | UImGui_ComponentRegularFun destruct, UImGui_CComponentData data); 13 | 14 | // Event safety - Any time 15 | UIMGUI_PUBLIC_API UImGui_CComponentData_P* UImGui_Inline_getCInlineComponentData(UImGui_CComponentHandle handle); 16 | 17 | // Event safety - Any time 18 | UIMGUI_PUBLIC_API UImGui_String UImGui_Inline_getCInlineComponentName(UImGui_CComponentHandle handle); 19 | 20 | // Event safety - Any time 21 | UIMGUI_PUBLIC_API void UImGui_Inline_destroyCInlineComponent(UImGui_CComponentHandle handle); 22 | #ifdef __cplusplus 23 | } 24 | #endif -------------------------------------------------------------------------------- /Framework/C/Components/CInstance.cpp: -------------------------------------------------------------------------------- 1 | #include "CInstance.h" 2 | #include 3 | 4 | #define INIT_INFO UImGui::Instance::get()->initInfo 5 | 6 | void UImGui_Instance_setCInitInfo(UImGui_CInitInfo* initInfo) 7 | { 8 | INIT_INFO.cInitInfo = initInfo; 9 | } 10 | 11 | void* UImGui_Instance_getCppInitInfoGlobalData(bool* bAllocatedOnHeap) 12 | { 13 | *bAllocatedOnHeap = INIT_INFO.bGlobalAllocatedOnHeap; 14 | return INIT_INFO.globalData; 15 | } 16 | 17 | char** UImGui_Instance_getCLIArguments(int* argc) 18 | { 19 | const auto* instance = UImGui::Instance::get(); 20 | *argc = instance->argc; 21 | 22 | return instance->argv; 23 | } 24 | 25 | UImGui_String UImGui_InitInfo_getFrameworkLibraryDir() 26 | { 27 | return INIT_INFO.frameworkLibraryDir.c_str(); 28 | } 29 | 30 | UImGui_String UImGui_InitInfo_getApplicationDir() 31 | { 32 | return INIT_INFO.applicationDir.c_str(); 33 | } 34 | 35 | UImGui_String UImGui_InitInfo_getApplicationLibraryDir() 36 | { 37 | return INIT_INFO.applicationLibraryDir.c_str(); 38 | } 39 | 40 | UImGui_String UImGui_InitInfo_getConfigDir() 41 | { 42 | return INIT_INFO.configDir.c_str(); 43 | } 44 | 45 | UImGui_String UImGui_InitInfo_getProjectDir() 46 | { 47 | return INIT_INFO.projectDir.c_str(); 48 | } 49 | 50 | UImGui_String UImGui_InitInfo_getContentDir() 51 | { 52 | return INIT_INFO.contentDir.c_str(); 53 | } 54 | 55 | UImGui_String UImGui_InitInfo_getFrameworkIncludeDir() 56 | { 57 | return INIT_INFO.frameworkIncludeDir.c_str(); 58 | } 59 | 60 | UImGui_String UImGui_InitInfo_getApplicationIncludeDir() 61 | { 62 | return INIT_INFO.applicationIncludeDir.c_str(); 63 | } -------------------------------------------------------------------------------- /Framework/C/Components/CInstance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "CComponentCommon.h" 5 | #include 6 | #include 7 | 8 | #ifdef __cplusplus 9 | extern "C" 10 | { 11 | #endif 12 | struct UImGui_CInitInfo; 13 | typedef void(*UImGui_CInstanceRegularFun)(struct UImGui_CInitInfo*); 14 | typedef void(*UImGui_CInstanceTickFun)(struct UImGui_CInitInfo*, float); 15 | 16 | /** 17 | * @brief C alternative of the InitInfo struct. std::vector members are replaced by pointers and size variables 18 | * @note This struct doesn't allow modification of the directory strings 19 | */ 20 | typedef struct UIMGUI_PUBLIC_API UImGui_CInitInfo 21 | { 22 | UImGui_CComponentHandle* inlineComponents; 23 | size_t inlineComponentsSize; 24 | 25 | UImGui_CComponentHandle* titlebarComponents; 26 | size_t titlebarComponentsSize; 27 | 28 | UImGui_CComponentHandle* windowComponents; 29 | size_t windowComponentsSize; 30 | 31 | UImGui_CInstanceRegularFun* constructFuncs; 32 | size_t constructSize; 33 | 34 | UImGui_CInstanceRegularFun* beginFuncs; 35 | size_t beginSize; 36 | 37 | UImGui_CInstanceTickFun* tickFuncs; 38 | size_t tickSize; 39 | 40 | UImGui_CInstanceRegularFun* endFuncs; 41 | size_t endSize; 42 | 43 | UImGui_CInstanceRegularFun* destructFuncs; 44 | size_t destructSize; 45 | 46 | void* globalData; 47 | bool bGlobalAllocatedOnHeap; 48 | 49 | UImGui_CGenericRenderer* customRenderer; 50 | UImGui_CGenericTexture* customTexture; 51 | } UImGui_CInitInfo; 52 | 53 | // Event Safety - Any time 54 | UIMGUI_PUBLIC_API void UImGui_Instance_setCInitInfo(UImGui_CInitInfo* initInfo); 55 | // Event Safety - Any time 56 | UIMGUI_PUBLIC_API void* UImGui_Instance_getCppInitInfoGlobalData(bool* bAllocatedOnHeap); 57 | 58 | // Event Safety - Any time 59 | UIMGUI_PUBLIC_API char** UImGui_Instance_getCLIArguments(int* argc); 60 | 61 | // Event Safety - Any time 62 | UIMGUI_PUBLIC_API UImGui_String UImGui_InitInfo_getFrameworkLibraryDir(); 63 | // Event Safety - Any time 64 | UIMGUI_PUBLIC_API UImGui_String UImGui_InitInfo_getApplicationDir(); 65 | // Event Safety - Any time 66 | UIMGUI_PUBLIC_API UImGui_String UImGui_InitInfo_getApplicationLibraryDir(); 67 | 68 | // Event Safety - Any time 69 | UIMGUI_PUBLIC_API UImGui_String UImGui_InitInfo_getConfigDir(); 70 | // Event Safety - Any time 71 | UIMGUI_PUBLIC_API UImGui_String UImGui_InitInfo_getProjectDir(); 72 | 73 | // Event Safety - Any time 74 | UIMGUI_PUBLIC_API UImGui_String UImGui_InitInfo_getContentDir(); 75 | 76 | // Event Safety - Any time 77 | UIMGUI_PUBLIC_API UImGui_String UImGui_InitInfo_getFrameworkIncludeDir(); 78 | // Event Safety - Any time 79 | UIMGUI_PUBLIC_API UImGui_String UImGui_InitInfo_getApplicationIncludeDir(); 80 | 81 | #ifdef __cplusplus 82 | }; 83 | #endif 84 | -------------------------------------------------------------------------------- /Framework/C/Components/CTitlebarComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "CTitlebarComponent.h" 2 | #include 3 | 4 | class CTitlebarComponentInternalClass final : public UImGui::TitlebarComponent 5 | { 6 | public: 7 | CTitlebarComponentInternalClass() 8 | { 9 | construct(&dataP); 10 | } 11 | 12 | virtual void begin() override 13 | { 14 | beginAutohandle(); 15 | beginF(&dataP); 16 | } 17 | 18 | virtual void tick(float deltaTime) override 19 | { 20 | tickAutohandle(deltaTime); 21 | tickF(&dataP, deltaTime); 22 | } 23 | 24 | virtual void end() override 25 | { 26 | endAutohandle(); 27 | endF(&dataP); 28 | } 29 | 30 | virtual ~CTitlebarComponentInternalClass() override 31 | { 32 | destruct(&dataP); 33 | } 34 | 35 | UImGui_CComponentData_P dataP = 36 | { 37 | .state = &state, 38 | .id = &id, 39 | }; 40 | 41 | UImGui_ComponentRegularFun construct = [](UImGui_CComponentData_P*) -> void {}; 42 | UImGui_ComponentRegularFun beginF = [](UImGui_CComponentData_P*) -> void {}; 43 | UImGui_ComponentTickFun tickF = [](UImGui_CComponentData_P*, float) -> void {}; 44 | UImGui_ComponentRegularFun endF = [](UImGui_CComponentData_P*) -> void {}; 45 | UImGui_ComponentRegularFun destruct = [](UImGui_CComponentData_P*) -> void {}; 46 | }; 47 | 48 | 49 | UImGui_CComponentHandle UImGui_Titlebar_makeCTitlebarComponent(UImGui_ComponentRegularFun construct, 50 | UImGui_ComponentRegularFun begin, UImGui_ComponentTickFun tick, UImGui_ComponentRegularFun end, 51 | UImGui_ComponentRegularFun destruct, UImGui_CComponentData data) 52 | { 53 | auto* handle = dynamic_cast(UImGui::TitlebarComponent::make()); 54 | handle->state = data.state; 55 | handle->name = data.name; 56 | handle->id = data.id; 57 | 58 | handle->construct = construct; 59 | handle->beginF = begin; 60 | handle->tickF = tick; 61 | handle->endF = end; 62 | handle->destruct = destruct; 63 | 64 | return handle; 65 | } 66 | 67 | UImGui_CComponentData_P* UImGui_Titlebar_getCTitlebarComponentData(UImGui_CComponentHandle handle) 68 | { 69 | return &static_cast(handle)->dataP; 70 | } 71 | 72 | void UImGui_Titlebar_destroyCTitlebarComponent(UImGui_CComponentHandle handle) 73 | { 74 | delete (CTitlebarComponentInternalClass*)handle; 75 | } 76 | 77 | UImGui_String UImGui_Titlebar_getCTitlebarComponentName(UImGui_CComponentHandle handle) 78 | { 79 | return static_cast(handle)->name.c_str(); 80 | } -------------------------------------------------------------------------------- /Framework/C/Components/CTitlebarComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "CComponentCommon.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" 7 | { 8 | #endif 9 | // Event safety - Any time 10 | UIMGUI_PUBLIC_API UImGui_CComponentHandle UImGui_Titlebar_makeCTitlebarComponent(UImGui_ComponentRegularFun construct, 11 | UImGui_ComponentRegularFun begin, UImGui_ComponentTickFun tick, UImGui_ComponentRegularFun end, 12 | UImGui_ComponentRegularFun destruct, UImGui_CComponentData data); 13 | 14 | // Event safety - Any time 15 | UIMGUI_PUBLIC_API UImGui_CComponentData_P* UImGui_Titlebar_getCTitlebarComponentData(UImGui_CComponentHandle handle); 16 | 17 | // Event safety - Any time 18 | UIMGUI_PUBLIC_API UImGui_String UImGui_Titlebar_getCTitlebarComponentName(UImGui_CComponentHandle handle); 19 | 20 | // Event safety - Any time 21 | UIMGUI_PUBLIC_API void UImGui_Titlebar_destroyCTitlebarComponent(UImGui_CComponentHandle handle); 22 | #ifdef __cplusplus 23 | } 24 | #endif -------------------------------------------------------------------------------- /Framework/C/Components/CWindowComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "CWindowComponent.h" 2 | #include 3 | 4 | class CWindowComponentInternalClass final : public UImGui::WindowComponent 5 | { 6 | public: 7 | CWindowComponentInternalClass() 8 | { 9 | construct(&data); 10 | } 11 | 12 | virtual void begin() override 13 | { 14 | beginAutohandle(); 15 | beginF(&data); 16 | } 17 | 18 | virtual void tick(const float deltaTime) override 19 | { 20 | tickAutohandle(deltaTime); 21 | tickF(&data, deltaTime); 22 | } 23 | 24 | virtual void end() override 25 | { 26 | endAutohandle(); 27 | endF(&data); 28 | } 29 | 30 | virtual ~CWindowComponentInternalClass() override 31 | { 32 | destruct(&data); 33 | } 34 | 35 | UImGui_CComponentData_P data = 36 | { 37 | .state = &state, 38 | .id = &id, 39 | }; 40 | 41 | UImGui_ComponentRegularFun construct = [](UImGui_CComponentData_P*) -> void {}; 42 | UImGui_ComponentRegularFun beginF = [](UImGui_CComponentData_P*) -> void {}; 43 | UImGui_ComponentTickFun tickF = [](UImGui_CComponentData_P*, float) -> void {}; 44 | UImGui_ComponentRegularFun endF = [](UImGui_CComponentData_P*) -> void {}; 45 | UImGui_ComponentRegularFun destruct = [](UImGui_CComponentData_P*) -> void {}; 46 | }; 47 | 48 | 49 | UImGui_CComponentHandle UImGui_WindowComponent_makeCWindowComponent(const UImGui_ComponentRegularFun construct, 50 | const UImGui_ComponentRegularFun begin, const UImGui_ComponentTickFun tick, const UImGui_ComponentRegularFun end, 51 | const UImGui_ComponentRegularFun destruct, UImGui_CComponentData data) 52 | { 53 | auto* handle = dynamic_cast(UImGui::WindowComponent::make()); 54 | handle->state = data.state; 55 | handle->name = data.name; 56 | handle->id = data.id; 57 | 58 | handle->construct = construct; 59 | handle->beginF = begin; 60 | handle->tickF = tick; 61 | handle->endF = end; 62 | handle->destruct = destruct; 63 | 64 | return handle; 65 | } 66 | 67 | UImGui_CComponentData_P* UImGui_WindowComponent_getCWindowComponentData(UImGui_CComponentHandle handle) 68 | { 69 | return &static_cast(handle)->data; 70 | } 71 | 72 | void UImGui_WindowComponent_destroyCWindowComponent(UImGui_CComponentHandle handle) 73 | { 74 | delete (CWindowComponentInternalClass*)handle; 75 | } 76 | 77 | UImGui_String UImGui_WindowComponent_getCWindowComponentName(UImGui_CComponentHandle handle) 78 | { 79 | return static_cast(handle)->name.c_str(); 80 | } -------------------------------------------------------------------------------- /Framework/C/Components/CWindowComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "CComponentCommon.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" 7 | { 8 | #endif 9 | // Event safety - Any time 10 | UIMGUI_PUBLIC_API UImGui_CComponentHandle UImGui_WindowComponent_makeCWindowComponent(UImGui_ComponentRegularFun construct, 11 | UImGui_ComponentRegularFun begin, UImGui_ComponentTickFun tick, UImGui_ComponentRegularFun end, 12 | UImGui_ComponentRegularFun destruct, UImGui_CComponentData data); 13 | 14 | // Event safety - Any time 15 | UIMGUI_PUBLIC_API UImGui_CComponentData_P* UImGui_WindowComponent_getCWindowComponentData(UImGui_CComponentHandle handle); 16 | 17 | // Event safety - Any time 18 | UIMGUI_PUBLIC_API UImGui_String UImGui_WindowComponent_getCWindowComponentName(UImGui_CComponentHandle handle); 19 | 20 | // Event safety - Any time 21 | UIMGUI_PUBLIC_API void UImGui_WindowComponent_destroyCWindowComponent(UImGui_CComponentHandle handle); 22 | #ifdef __cplusplus 23 | } 24 | #endif -------------------------------------------------------------------------------- /Framework/C/Interfaces/CInput.cpp: -------------------------------------------------------------------------------- 1 | #include "CInput.h" 2 | #include "Interfaces/Input.hpp" 3 | 4 | void UImGui_Input_setCursorVisibility(const UImGui_CursorVisibilityState visibility) 5 | { 6 | UImGui::Input::setCursorVisibility(visibility); 7 | } 8 | 9 | UImGui_CursorVisibilityState UImGui_Input_getCurrentCursorVisibility() 10 | { 11 | return UImGui::Input::getCurrentCursorVisibility(); 12 | } 13 | 14 | void UImGui_Input_setStickyKeys(const bool bEnable) 15 | { 16 | UImGui::Input::setStickyKeys(bEnable); 17 | } 18 | 19 | bool UImGui_Input_getStickyKeys() 20 | { 21 | return UImGui::Input::getStickyKeys(); 22 | } 23 | 24 | void UImGui_Input_setRawMouseMotion(const bool bEnable) 25 | { 26 | UImGui::Input::setRawMouseMotion(bEnable); 27 | } 28 | 29 | bool UImGui_Input_getRawMouseMotion() 30 | { 31 | return UImGui::Input::getRawMouseMotion(); 32 | } 33 | 34 | void UImGui_Input_setLockKeyMods(const bool bEnable) 35 | { 36 | UImGui::Input::setLockKeyMods(bEnable); 37 | } 38 | 39 | bool UImGui_Input_getLockKeyMods() 40 | { 41 | return UImGui::Input::getLockKeyMods(); 42 | } 43 | 44 | uint8_t UImGui_Input_getKey(const uint16_t key) 45 | { 46 | return UImGui::Input::getKey(key); 47 | } 48 | 49 | UImGui_CInputAction UImGui_Input_getAction(const UImGui_String name) 50 | { 51 | auto& a = UImGui::Input::getAction(name); 52 | return UImGui_CInputAction 53 | { 54 | .name = a.name.c_str(), 55 | .keyCodes = const_cast(a.keyCodes.data()), 56 | .keyCodesSize = a.keyCodes.size(), 57 | .state = a.state, 58 | }; 59 | } 60 | 61 | UImGui_FVector2 UImGui_Input_getMousePositionChange() 62 | { 63 | return UImGui::Input::getMousePositionChange(); 64 | } 65 | 66 | UImGui_FVector2 UImGui_Input_getCurrentMousePosition() 67 | { 68 | return UImGui::Input::getCurrentMousePosition(); 69 | } 70 | 71 | UImGui_FVector2 UImGui_Input_getLastMousePosition() 72 | { 73 | return UImGui::Input::getLastMousePosition(); 74 | } 75 | 76 | UImGui_FVector2 UImGui_Input_getScroll() 77 | { 78 | return UImGui::Input::getScroll(); 79 | } -------------------------------------------------------------------------------- /Framework/C/Interfaces/CInput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #ifdef __cplusplus 5 | extern "C" 6 | { 7 | #endif 8 | /** 9 | * @brief A struct to hold the data for an input action 10 | * @var name - The name ID for the action 11 | * @var keyCode - The keyCode at which the action gets activated 12 | * @var keyCodesSize - The size of the key codes array 13 | * @var state - The current state of the action 14 | * @note Event Safety - Any time 15 | */ 16 | typedef struct UImGui_CInputAction 17 | { 18 | const char* name; 19 | 20 | uint16_t* keyCodes; 21 | size_t keyCodesSize; 22 | 23 | uint8_t state; 24 | } UImGui_CInputAction; 25 | 26 | /** 27 | * @brief Defines the 3 visibility states of a mouse cursor 28 | * @enum UIMGUI_CURSOR_VISIBILITY_STATE_NORMAL - Cursor is visible and can leave the window at any point. 29 | * For normal GUI applications 30 | * @enum UIMGUI_CURSOR_VISIBILITY_STATE_HIDDEN - Hides the cursor when it's over the window, but allows the user to 31 | * leave the window area. 32 | * @enum UIMGUI_CURSOR_VISIBILITY_STATE_DISABLED - Hides the cursor and locks it to the window. This is useful for 33 | * 3D cameras like in games. 34 | */ 35 | typedef enum UImGui_CursorVisibilityState 36 | { 37 | UIMGUI_CURSOR_VISIBILITY_STATE_NORMAL = 0x00034001, 38 | UIMGUI_CURSOR_VISIBILITY_STATE_HIDDEN = 0x00034002, 39 | UIMGUI_CURSOR_VISIBILITY_STATE_DISABLED = 0x00034003 40 | } UImGui_CursorVisibilityState; 41 | 42 | // Event Safety - begin, style, post-begin 43 | UIMGUI_PUBLIC_API void UImGui_Input_setCursorVisibility(UImGui_CursorVisibilityState visibility); 44 | // Event Safety - begin, style, post-begin 45 | UIMGUI_PUBLIC_API UImGui_CursorVisibilityState UImGui_Input_getCurrentCursorVisibility(); 46 | 47 | // Event Safety - begin, style, post-begin 48 | UIMGUI_PUBLIC_API void UImGui_Input_setStickyKeys(bool bEnable); 49 | // Event Safety - begin, style, post-begin 50 | UIMGUI_PUBLIC_API bool UImGui_Input_getStickyKeys(); 51 | 52 | // Event Safety - begin, style, post-begin 53 | // This may not be set if the system doesn't support raw mouse motion or if the mouse cursor is not in the 54 | // UIMGUI_CURSOR_VISIBILITY_STATE_DISABLED state 55 | UIMGUI_PUBLIC_API void UImGui_Input_setRawMouseMotion(bool bEnable); 56 | // Event Safety - begin, style, post-begin 57 | UIMGUI_PUBLIC_API bool UImGui_Input_getRawMouseMotion(); 58 | 59 | // Event Safety - begin, style, post-begin 60 | UIMGUI_PUBLIC_API void UImGui_Input_setLockKeyMods(bool bEnable); 61 | // Event Safety - begin, style, post-begin 62 | UIMGUI_PUBLIC_API bool UImGui_Input_getLockKeyMods(); 63 | 64 | // Event Safety - Any time 65 | UIMGUI_PUBLIC_API uint8_t UImGui_Input_getKey(uint16_t key); 66 | // Event Safety - Any time 67 | UIMGUI_PUBLIC_API UImGui_CInputAction UImGui_Input_getAction(UImGui_String name); 68 | 69 | // Event Safety - Any time 70 | UIMGUI_PUBLIC_API UImGui_FVector2 UImGui_Input_getMousePositionChange(); 71 | // Event Safety - Any time 72 | UIMGUI_PUBLIC_API UImGui_FVector2 UImGui_Input_getCurrentMousePosition(); 73 | // Event Safety - Any time 74 | UIMGUI_PUBLIC_API UImGui_FVector2 UImGui_Input_getLastMousePosition(); 75 | 76 | // Event Safety - Any time 77 | UIMGUI_PUBLIC_API UImGui_FVector2 UImGui_Input_getScroll(); 78 | #ifdef __cplusplus 79 | } 80 | #endif -------------------------------------------------------------------------------- /Framework/C/Interfaces/CLayoutsInterface.cpp: -------------------------------------------------------------------------------- 1 | #include "CLayoutsInterface.h" 2 | #include 3 | 4 | bool* UImGui_Layouts_getLoadLayout() 5 | { 6 | return &UImGui::Layouts::getLoadLayout(); 7 | } 8 | 9 | bool* UImGui_Layouts_getSaveLayout() 10 | { 11 | return &UImGui::Layouts::getSaveLayout(); 12 | } 13 | 14 | UImGui_String UImGui_Layouts_layoutLocation() 15 | { 16 | return UImGui::Layouts::layoutLocation().c_str(); 17 | } -------------------------------------------------------------------------------- /Framework/C/Interfaces/CLayoutsInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #ifdef __cplusplus 5 | extern "C" 6 | { 7 | #endif 8 | // Event Safety - begin, style, post-begin 9 | UIMGUI_PUBLIC_API bool* UImGui_Layouts_getLoadLayout(); 10 | // Event Safety - begin, style, post-begin 11 | UIMGUI_PUBLIC_API bool* UImGui_Layouts_getSaveLayout(); 12 | // Event Safety - begin, style, post-begin 13 | UIMGUI_PUBLIC_API UImGui_String UImGui_Layouts_layoutLocation(); 14 | #ifdef __cplusplus 15 | } 16 | #endif -------------------------------------------------------------------------------- /Framework/C/Interfaces/CPluginInterface.cpp: -------------------------------------------------------------------------------- 1 | #include "CPluginInterface.h" 2 | #include 3 | #include 4 | #include 5 | 6 | bool UImGui_Plugins_load(const UImGui_String location) 7 | { 8 | return UImGui::Plugins::load(location); 9 | } 10 | 11 | void UImGui_Plugins_loadStandard() 12 | { 13 | UImGui::Plugins::loadStandard(); 14 | } 15 | 16 | UImGui_CPlugin* UImGui_Plugins_getPlugins(size_t* size) 17 | { 18 | auto& plugins = UImGui::Global::get().deallocationStruct.plugins; 19 | auto& cppPlugins = UImGui::Plugins::getPlugins(); 20 | 21 | plugins.resize(cppPlugins.size()); 22 | *size = plugins.size(); 23 | 24 | for (size_t i = 0; i < *size; i++) 25 | { 26 | plugins[i].name = cppPlugins[i].name.c_str(); 27 | plugins[i].handle = cppPlugins[i].handle; 28 | } 29 | return plugins.data(); 30 | } 31 | -------------------------------------------------------------------------------- /Framework/C/Interfaces/CPluginInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #ifdef __cplusplus 5 | extern "C" 6 | { 7 | #endif 8 | typedef struct UIMGUI_PUBLIC_API UImGui_CPlugin 9 | { 10 | const char* name; 11 | void* handle; 12 | } UImGui_CPlugin; 13 | 14 | /** 15 | * @brief Loads a plugin from a location string 16 | * @param location - the file location for the plugin shared library 17 | * @note Event safety - post-startup 18 | * @return A boolean that is true on success and false on error 19 | */ 20 | UIMGUI_PUBLIC_API bool UImGui_Plugins_load(UImGui_String location); 21 | 22 | /** 23 | * @brief A helper function that automatically loads all plugins that are added by the user through the standard 24 | * plugins interface 25 | * @note Event safety - post-startup 26 | */ 27 | UIMGUI_PUBLIC_API void UImGui_Plugins_loadStandard(); 28 | 29 | /** 30 | * @brief Returns a list of plugins 31 | * @param size - A pointer that will get filled with the size of the array of C Plugin structs 32 | * @note Does not give you access to the attach and detach functions. These can only be accessed through the C++ API 33 | * @note Event safety - post-startup 34 | * @return A list of C Plugin structs 35 | */ 36 | UIMGUI_PUBLIC_API UImGui_CPlugin* UImGui_Plugins_getPlugins(size_t* size); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif -------------------------------------------------------------------------------- /Framework/C/Interfaces/CRendererInterface.cpp: -------------------------------------------------------------------------------- 1 | #include "CRendererInterface.h" 2 | #include "Interfaces/RendererInterface.hpp" 3 | #include "Renderer/GenericRenderer/GenericRenderer.hpp" 4 | #include "Global.hpp" 5 | 6 | UImGui_RendererData* UImGui_Renderer_data() 7 | { 8 | return &UImGui::Renderer::data(); 9 | } 10 | 11 | void UImGui_Renderer_saveSettings() 12 | { 13 | UImGui::Renderer::saveSettings(); 14 | } 15 | 16 | UImGui_String UImGui_Renderer_getVendorString() 17 | { 18 | return UImGui::Renderer::getVendorString().c_str(); 19 | } 20 | 21 | UImGui_String UImGui_Renderer_getAPIVersion() 22 | { 23 | return UImGui::Renderer::getAPIVersion().c_str(); 24 | } 25 | 26 | UImGui_String UImGui_Renderer_getGPUName() 27 | { 28 | return UImGui::Renderer::getGPUName().c_str(); 29 | } 30 | 31 | UImGui_String UImGui_Renderer_getDriverVersion() 32 | { 33 | return UImGui::Renderer::getDriverVersion().c_str(); 34 | } 35 | 36 | void UImGui_RendererInternalMetadata_setVendorString(UImGui_String str) 37 | { 38 | UImGui::Global::get().renderer->metadata.vendorString = str; 39 | } 40 | 41 | void UImGui_RendererInternalMetadata_setApiVersion(UImGui_String str) 42 | { 43 | UImGui::Global::get().renderer->metadata.apiVersion = str; 44 | 45 | } 46 | 47 | void UImGui_RendererInternalMetadata_setDriverVersion(UImGui_String str) 48 | { 49 | UImGui::Global::get().renderer->metadata.driverVersion = str; 50 | 51 | } 52 | 53 | void UImGui_RendererInternalMetadata_setGPUName(UImGui_String str) 54 | { 55 | UImGui::Global::get().renderer->metadata.gpuName = str; 56 | } 57 | -------------------------------------------------------------------------------- /Framework/C/Interfaces/CRendererInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" 8 | { 9 | #endif 10 | // Event Safety - Any time 11 | UIMGUI_PUBLIC_API UImGui_RendererData* UImGui_Renderer_data(); 12 | // Event Safety - Any time 13 | UIMGUI_PUBLIC_API void UImGui_Renderer_saveSettings(); 14 | 15 | // Event Safety - begin, post-begin 16 | UIMGUI_PUBLIC_API UImGui_String UImGui_Renderer_getVendorString(); 17 | // Event Safety - begin, post-begin 18 | UIMGUI_PUBLIC_API UImGui_String UImGui_Renderer_getAPIVersion(); 19 | // Event Safety - begin, post-begin 20 | UIMGUI_PUBLIC_API UImGui_String UImGui_Renderer_getGPUName(); 21 | // Event Safety - begin, post-begin 22 | UIMGUI_PUBLIC_API UImGui_String UImGui_Renderer_getDriverVersion(); 23 | 24 | // Event Safety - post-startup 25 | UIMGUI_PUBLIC_API void UImGui_RendererInternalMetadata_setVendorString(UImGui_String str); 26 | // Event Safety - post-startup 27 | UIMGUI_PUBLIC_API void UImGui_RendererInternalMetadata_setApiVersion(UImGui_String str); 28 | // Event Safety - post-startup 29 | UIMGUI_PUBLIC_API void UImGui_RendererInternalMetadata_setDriverVersion(UImGui_String str); 30 | // Event Safety - post-startup 31 | UIMGUI_PUBLIC_API void UImGui_RendererInternalMetadata_setGPUName(UImGui_String str); 32 | 33 | // Event Safety - begin, post-begin 34 | UIMGUI_PUBLIC_API void UImGui_Renderer_forceUpdate(); 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /Framework/C/Interfaces/CUtility.cpp: -------------------------------------------------------------------------------- 1 | #include "CUtility.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | UImGui_String UImGui_Utility_sanitiseFilepath(const UImGui_String str) 11 | { 12 | UImGui::FString s = str; 13 | UImGui::Utility::sanitiseFilepath(s); 14 | 15 | auto* ss = static_cast(UImGui_Allocator_allocate(s.size())); 16 | memcpy(ss, s.data(), s.size() + 1); 17 | return ss; 18 | } 19 | 20 | UImGui_String UImGui_Utility_keyToText(const uint16_t key, const bool bLong) 21 | { 22 | auto& global = UImGui::Global::get(); 23 | const auto text = UImGui::Utility::keyToText(key, bLong); 24 | for (auto& f : global.deallocationStruct.keyStrings) 25 | if (f == text) 26 | return f.c_str(); 27 | 28 | global.deallocationStruct.keyStrings.push_back(text); 29 | return global.deallocationStruct.keyStrings.back().c_str(); 30 | } 31 | 32 | UImGui_String UImGui_Utility_keyToTextInputAction(const UImGui_CInputAction* action, const bool bLong) 33 | { 34 | UImGui::InputAction a; 35 | a.keyCodes.resize(action->keyCodesSize); 36 | memcpy(a.keyCodes.data(), action->keyCodes, a.keyCodes.size() * sizeof(size_t)); 37 | 38 | auto& deallocationStruct = UImGui::Global::get().deallocationStruct; 39 | const auto text = UImGui::Utility::keyToText(a, bLong); 40 | for (auto& f : deallocationStruct.keyStrings) 41 | if (f == text) 42 | return f.c_str(); 43 | 44 | deallocationStruct.keyStrings.push_back(text); 45 | return deallocationStruct.keyStrings.back().c_str(); 46 | } 47 | 48 | void UImGui_Utility_removeConsole() 49 | { 50 | UImGui::Utility::removeConsole(); 51 | } 52 | 53 | void UImGui_Utility_sleep(const uint64_t milliseconds) 54 | { 55 | UImGui::Utility::sleep(milliseconds); 56 | } 57 | 58 | void UImGui_Utility_loadContext(void* context) 59 | { 60 | UImGui::Utility::loadContext(context); 61 | } 62 | 63 | 64 | UImGui_CGlobal* UImGui_Global_get(UImGui_CGlobal* parent) 65 | { 66 | return &UImGui::Global::get(static_cast(parent)); 67 | } 68 | 69 | UImGui_String UImGui_Utility_toLower(char* str) 70 | { 71 | UImGui::FString u8tmp = str; 72 | std::u32string tmp = utf8::utf8to32(u8tmp); 73 | 74 | for (auto& a : tmp) 75 | #ifdef _WIN32 76 | a = std::tolower(a, std::locale("")); 77 | #else 78 | a = std::tolower(static_cast(a), std::locale("")); 79 | #endif 80 | u8tmp = utf8::utf32to8(tmp); 81 | 82 | auto tmpRealloc = static_cast(realloc(str, u8tmp.size())); 83 | if (tmpRealloc == nullptr) 84 | { 85 | free(str); 86 | tmpRealloc = static_cast(UImGui_Allocator_allocate(u8tmp.size())); 87 | } 88 | return strcpy(tmpRealloc, u8tmp.data()); 89 | } 90 | 91 | UImGui_String UImGui_Utility_toUpper(char* str) 92 | { 93 | UImGui::FString u8tmp = str; 94 | std::u32string tmp = utf8::utf8to32(u8tmp); 95 | 96 | for (auto& a : tmp) 97 | #ifdef _WIN32 98 | a = std::toupper(a, std::locale("")); 99 | #else 100 | a = std::toupper(static_cast(a), std::locale("")); 101 | #endif 102 | u8tmp = utf8::utf32to8(tmp); 103 | 104 | auto tmpRealloc = static_cast(realloc(str, u8tmp.size())); 105 | if (tmpRealloc == nullptr) 106 | { 107 | free(str); 108 | tmpRealloc = static_cast(UImGui_Allocator_allocate(u8tmp.size())); 109 | } 110 | return strcpy(tmpRealloc, u8tmp.data()); 111 | } -------------------------------------------------------------------------------- /Framework/C/Interfaces/CUtility.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" 8 | { 9 | #endif 10 | typedef void UImGui_CGlobal; 11 | 12 | // Event Safety - Any time 13 | // WARNING: Alling this function you become the owner of the string and your should dispose of it correctly using 14 | // the UImGui_Allocator_deallocate function 15 | UIMGUI_PUBLIC_API UImGui_String UImGui_Utility_sanitiseFilepath(UImGui_String str); 16 | 17 | // Event Safety - Any time 18 | UIMGUI_PUBLIC_API UImGui_String UImGui_Utility_keyToText(uint16_t key, bool bLong); 19 | 20 | // Event Safety - Any time 21 | UIMGUI_PUBLIC_API UImGui_String UImGui_Utility_keyToTextInputAction(const UImGui_CInputAction* action, bool bLong); 22 | 23 | // Event Safety - Any time 24 | UIMGUI_PUBLIC_API void UImGui_Utility_removeConsole(); 25 | 26 | // Event Safety - Any time 27 | // Sleep for X milliseconds 28 | UIMGUI_PUBLIC_API void UImGui_Utility_sleep(uint64_t milliseconds); 29 | 30 | UIMGUI_PUBLIC_API void UImGui_Utility_loadContext(void* context); 31 | 32 | /** 33 | * @brief Converts a string to lower case using the default locale settings 34 | * @warning str will be overwritten, reassign to the return value 35 | * @note Event Safety - Any time 36 | * @note The returned string has to be freed 37 | * @returns A lower case string 38 | */ 39 | UIMGUI_PUBLIC_API UImGui_String UImGui_Utility_toLower(char* str); 40 | 41 | /** 42 | * @brief Converts a string to upper case using the default locale settings 43 | * @warning str will be overwritten, reassign to the return value 44 | * @note Event Safety - Any time 45 | * @note The returned string has to be freed 46 | * @returns A upper case string 47 | */ 48 | UIMGUI_PUBLIC_API UImGui_String UImGui_Utility_toUpper(char* str); 49 | 50 | // Event Safety - Any time 51 | UIMGUI_PUBLIC_API UImGui_CGlobal* UImGui_Global_get(UImGui_CGlobal* parent); 52 | #ifdef __cplusplus 53 | } 54 | #endif -------------------------------------------------------------------------------- /Framework/C/Internal/CMonitor.cpp: -------------------------------------------------------------------------------- 1 | #include "CMonitor.h" 2 | #include 3 | #include 4 | 5 | void UImGui_Monitor_init(UImGui_CMonitorData* data) 6 | { 7 | data->monitor = nullptr; 8 | 9 | data->additionalData = nullptr; 10 | data->additionalDataSize = 0; 11 | } 12 | 13 | void UImGui_Monitor_initWithMonitor_Internal(UImGui_CMonitorData* data, GLFWmonitor* monitor) 14 | { 15 | UImGui_Monitor_init(data); 16 | data->monitor = monitor; 17 | } 18 | 19 | UImGui_FVector2 UImGui_Monitor_getPhysicalSize(const UImGui_CMonitorData* data) 20 | { 21 | const UImGui::Monitor monitor(data->monitor); 22 | return monitor.getPhysicalSize(); 23 | } 24 | 25 | UImGui_FVector2 UImGui_Monitor_getContentScale(const UImGui_CMonitorData* data) 26 | { 27 | const UImGui::Monitor monitor(data->monitor); 28 | return monitor.getContentScale(); 29 | } 30 | 31 | UImGui_FVector2 UImGui_Monitor_getVirtualPosition(const UImGui_CMonitorData* data) 32 | { 33 | const UImGui::Monitor monitor(data->monitor); 34 | return monitor.getVirtualPosition(); 35 | } 36 | 37 | UImGui_FVector4 UImGui_Monitor_getWorkArea(const UImGui_CMonitorData* data) 38 | { 39 | const UImGui::Monitor monitor(data->monitor); 40 | return monitor.getWorkArea(); 41 | } 42 | 43 | UImGui_String UImGui_Monitor_getName(const UImGui_CMonitorData* data) 44 | { 45 | // Use glfw here, instead of the getName function, as we're skipping up to 2 re-allocations, since the internal glfw 46 | // const char*, will be allocated into an FString, which will then have to be pushed to the 47 | // CDeallocationStruct (another copy), and then the const char* data will be returned from the function. Using this, 48 | // we're only using the internal const char*. 49 | return glfwGetMonitorName(data->monitor); 50 | } 51 | 52 | void UImGui_Monitor_pushEvent(UImGui_CMonitorData* data, const UImGui_Monitor_EventsFun f) 53 | { 54 | UImGui::Monitor::CInternalGetMonitorClassDoNotTouch::UImGui_Monitor_pushEvent(data, f); 55 | } -------------------------------------------------------------------------------- /Framework/C/Internal/CMonitor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" 7 | { 8 | #endif 9 | struct UImGui_CMonitorData; 10 | 11 | typedef enum UImGui_MonitorState 12 | { 13 | UIMGUI_MONITOR_STATE_CONNECTED = 0x00040001, 14 | UIMGUI_MONITOR_STATE_DISCONNECTED = 0x00040002 15 | } UImGui_MonitorState; 16 | 17 | typedef void(*UImGui_Monitor_EventsFun)(struct UImGui_CMonitorData*, UImGui_MonitorState); 18 | typedef struct GLFWmonitor GLFWmonitor; 19 | 20 | // Do not create this manually!!! This should be fetched using the UImGui_Window_getWindowMonitor or 21 | // UImGui_Window_getMonitors functions 22 | typedef struct UIMGUI_PUBLIC_API UImGui_CMonitorData 23 | { 24 | void* additionalData; 25 | size_t additionalDataSize; 26 | 27 | // Do not touch 28 | GLFWmonitor* monitor; 29 | } UImGui_CMonitorData; 30 | 31 | typedef void(*UImGui_Window_pushGlobalMonitorCallbackFun)(UImGui_CMonitorData*, UImGui_MonitorState); 32 | 33 | #ifndef __EMSCRIPTEN__ 34 | 35 | // Event safety - any time 36 | UIMGUI_PUBLIC_API void UImGui_Monitor_init(UImGui_CMonitorData* data); 37 | // Event safety - any time 38 | UIMGUI_PUBLIC_API void UImGui_Monitor_initWithMonitor_Internal(UImGui_CMonitorData* data, GLFWmonitor* monitor); 39 | 40 | // Event safety - begin, style, post-begin 41 | UIMGUI_PUBLIC_API UImGui_FVector2 UImGui_Monitor_getPhysicalSize(const UImGui_CMonitorData* data); 42 | 43 | // Event safety - begin, style, post-begin 44 | UIMGUI_PUBLIC_API UImGui_FVector2 UImGui_Monitor_getContentScale(const UImGui_CMonitorData* data); 45 | 46 | // Event safety - begin, style, post-begin 47 | UIMGUI_PUBLIC_API UImGui_FVector2 UImGui_Monitor_getVirtualPosition(const UImGui_CMonitorData* data); 48 | 49 | // Event safety - begin, style, post-begin 50 | // Returns work area as FVector4 where x = x position, y = y position, z = width, w = height 51 | UIMGUI_PUBLIC_API UImGui_FVector4 UImGui_Monitor_getWorkArea(const UImGui_CMonitorData* data); 52 | 53 | // Event safety - begin, style, post-begin 54 | // May not be unique 55 | UIMGUI_PUBLIC_API UImGui_String UImGui_Monitor_getName(const UImGui_CMonitorData* data); 56 | 57 | // Event safety - begin, style, post-begin 58 | UIMGUI_PUBLIC_API void UImGui_Monitor_pushEvent(UImGui_CMonitorData* data, UImGui_Monitor_EventsFun f); 59 | 60 | #endif 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif -------------------------------------------------------------------------------- /Framework/C/Internal/RendererData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #ifdef __cplusplus 5 | extern "C" 6 | { 7 | #endif 8 | typedef void UImGui_CGenericRenderer; 9 | 10 | // Keep in sync with the strings in Renderer.cpp 11 | typedef enum UImGui_RendererType 12 | { 13 | UIMGUI_RENDERER_TYPE_OPENGL, 14 | UIMGUI_RENDERER_TYPE_VULKAN_WEBGPU, 15 | UIMGUI_RENDERER_TYPE_CUSTOM, 16 | UIMGUI_RENDERER_TYPE_COUNT, 17 | UIMGUI_RENDERER_TYPE_ALT_NAMES_COUNT 18 | } UImGui_RendererType; 19 | 20 | /** 21 | * @brief Renderer data struct 22 | * @var rendererType - The current selected renderer 23 | * @var textureRendererType - The current selected texture renderer 24 | * @var bUsingVSync - Whether the application uses VSync(sync the application framerate with monitor refresh rate) 25 | * @var msaaSamples - Number of samples for MSAA antialiasing 26 | * @var bEnablePowerSavingMode - Whether to enable power saving(rendering with a reduce frame rate when the 27 | * application sits idle). Note: do not use for highly dynamic applications with plots or animations 28 | * @var idleFrameRate - The number of frames to render per second when idle 29 | */ 30 | typedef struct UIMGUI_PUBLIC_API UImGui_RendererData 31 | { 32 | UImGui_RendererType rendererType; 33 | UImGui_RendererType textureRendererType; 34 | bool bUsingVSync; 35 | uint32_t msaaSamples; 36 | 37 | bool bEnablePowerSavingMode; 38 | float idleFrameRate; 39 | } UImGui_RendererData; 40 | #ifdef __cplusplus 41 | } 42 | #endif -------------------------------------------------------------------------------- /Framework/C/Modules/Manager/CModulesManager.cpp: -------------------------------------------------------------------------------- 1 | #include "CModulesManager.hpp" 2 | #include 3 | 4 | void UImGui_Modules_save() 5 | { 6 | UImGui::Modules::save(); 7 | } 8 | 9 | UImGui_ModuleSettings* UImGui_Modules_data() 10 | { 11 | return &UImGui::Modules::data(); 12 | } -------------------------------------------------------------------------------- /Framework/C/Modules/Manager/CModulesManager.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" 7 | { 8 | #endif 9 | /** 10 | * @brief Struct containing settings for all modules. 11 | * @var maxTransactions - Maximum number of undo/redo transactions before removing old transactions 12 | * @var themeLocation - The string location of the theme file to be loaded and saved to by the theming module. Path 13 | * is prefixed by UIMGUI_CONFIG_DIR/Theme/ 14 | * @var os, dbus, uexec, theming, ufont, i18n, undo_redo, plotting, knobs, spinners, toggles, text_utils, 15 | * cli_parser, xdg, open - Boolean that marks whether the module with the given name is enabled 16 | */ 17 | typedef struct UIMGUI_PUBLIC_API UImGui_ModuleSettings 18 | { 19 | size_t maxTransactions; 20 | UImGui_String themeLocation; 21 | 22 | bool os; 23 | bool dbus; 24 | bool uexec; 25 | bool theming; 26 | bool i18n; 27 | bool undo_redo; 28 | bool plotting; 29 | bool knobs; 30 | bool spinners; 31 | bool toggles; 32 | bool text_utils; 33 | bool cli_parser; 34 | bool xdg; 35 | bool open; 36 | } UImGui_ModuleSettings; 37 | 38 | // Event safety - begin, style, post-begin 39 | UIMGUI_PUBLIC_API void UImGui_Modules_save(); 40 | // Event safety - begin, style, post-begin 41 | UIMGUI_PUBLIC_API UImGui_ModuleSettings* UImGui_Modules_data(); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif -------------------------------------------------------------------------------- /Framework/C/Modules/Undo/Undo.cpp: -------------------------------------------------------------------------------- 1 | #include "Undo.h" 2 | #ifdef UIMGUI_UNDO_MODULE_ENABLED 3 | #ifdef __cplusplus 4 | #include "Modules/Undo/src/Undo.hpp" 5 | extern "C" 6 | { 7 | #endif 8 | void UImGui_StateTracker_push(const UImGui_CTransaction transaction, const bool bRedoIsInit) 9 | { 10 | UImGui::StateTracker::push({ 11 | .undofunc = [&](UImGui::TransactionPayload& payload) -> void 12 | { 13 | transaction.undoFunc(&payload); 14 | }, 15 | .redofunc = [&](UImGui::TransactionPayload& payload) -> void 16 | { 17 | transaction.redoFunc(&payload); 18 | }, 19 | .payload = transaction.payload 20 | }, bRedoIsInit); 21 | } 22 | 23 | void UImGui_StateTracker_undo() 24 | { 25 | UImGui::StateTracker::undo(); 26 | } 27 | 28 | void UImGui_StateTracker_redo() 29 | { 30 | UImGui::StateTracker::redo(); 31 | } 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | #endif -------------------------------------------------------------------------------- /Framework/C/Modules/Undo/Undo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef UIMGUI_UNDO_MODULE_ENABLED 3 | #include 4 | #include 5 | #ifdef __cplusplus 6 | extern "C" 7 | { 8 | #endif 9 | typedef struct UIMGUI_PUBLIC_API UImGui_TransactionPayload 10 | { 11 | void* payload; 12 | size_t size; 13 | } UImGui_TransactionPayload; 14 | 15 | typedef void(*UImGui_CTransactionCallbackFun)(UImGui_TransactionPayload*); 16 | 17 | typedef struct UIMGUI_PUBLIC_API UImGui_CTransaction 18 | { 19 | UImGui_CTransactionCallbackFun undoFunc; 20 | UImGui_CTransactionCallbackFun redoFunc; 21 | UImGui_TransactionPayload payload; 22 | } UImGui_CTransaction; 23 | 24 | // UntitledImGuiFramework Event Safety - Post-begin 25 | // bRedoIsInit defaults to false in the C++ API 26 | UIMGUI_PUBLIC_API void UImGui_StateTracker_push(UImGui_CTransaction transaction, bool bRedoIsInit); 27 | // UntitledImGuiFramework Event Safety - Post-begin 28 | UIMGUI_PUBLIC_API void UImGui_StateTracker_undo(); 29 | // UntitledImGuiFramework Event Safety - Post-begin 30 | UIMGUI_PUBLIC_API void UImGui_StateTracker_redo(); 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | #endif -------------------------------------------------------------------------------- /Framework/C/README.md: -------------------------------------------------------------------------------- 1 | # About the C API 2 | The C API is a light C wrapper on top of the C++ user-facing API. 3 | 4 | The C API should only be used for creating plugins in a language, other than C++, as C's simplicity requires a good 5 | number of heap allocations that are otherwise not done, due to C++'s zero-cost abstractions. -------------------------------------------------------------------------------- /Framework/C/Rendering/CClientSideBar.cpp: -------------------------------------------------------------------------------- 1 | #include "CClientSideBar.h" 2 | #include 3 | 4 | void UImGui_ClientSideBar_Begin() 5 | { 6 | UImGui::ClientSideBar::Begin(); 7 | } 8 | 9 | void UImGui_ClientSideBar_End(const UImGui_ClientSideBarFlags flags, const UImGui_FVector4 destructiveColour, const UImGui_FVector4 destructiveColourActive) 10 | { 11 | UImGui::ClientSideBar::End(flags, destructiveColour, destructiveColourActive); 12 | } -------------------------------------------------------------------------------- /Framework/C/Rendering/CClientSideBar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #ifdef __cplusplus 6 | extern "C" 7 | { 8 | #endif 9 | typedef enum UImGui_ClientSideBarFlags 10 | { 11 | UIMGUI_CLIENT_SIDE_BAR_FLAG_NONE = 0, 12 | UIMGUI_CLIENT_SIDE_BAR_FLAG_MINIMISE_BUTTON, 13 | UIMGUI_CLIENT_SIDE_BAR_FLAG_MAXIMISE_BUTTON, 14 | UIMGUI_CLIENT_SIDE_BAR_FLAG_CLOSE_BUTTON, 15 | UIMGUI_CLIENT_SIDE_BAR_FLAG_MOVEABLE, 16 | UIMGUI_CLIENT_SIDE_BAR_FLAG_ALL = UIMGUI_CLIENT_SIDE_BAR_FLAG_MINIMISE_BUTTON 17 | | UIMGUI_CLIENT_SIDE_BAR_FLAG_MAXIMISE_BUTTON 18 | | UIMGUI_CLIENT_SIDE_BAR_FLAG_CLOSE_BUTTON 19 | | UIMGUI_CLIENT_SIDE_BAR_FLAG_MOVEABLE 20 | } UImGui_ClientSideBarFlags; 21 | 22 | // Initialises the client-side bar 23 | // Event Safety - Post-begin 24 | UIMGUI_PUBLIC_API void UImGui_ClientSideBar_Begin(); 25 | 26 | // Renders the bar. In C++, flags defaults to UIMGUI_CLIENT_SIDE_BAR_FLAG_ALL, { 1.0, 0.482, 0.388f, 1.0f }, { 0.753f, 0.110f, 0.157f, 1.0f } 27 | // Event Safety - Post-begin 28 | UIMGUI_PUBLIC_API void UImGui_ClientSideBar_End(UImGui_ClientSideBarFlags flags, UImGui_FVector4 destructiveColour, UImGui_FVector4 destructiveColourActive); 29 | #ifdef __cplusplus 30 | } 31 | #endif -------------------------------------------------------------------------------- /Framework/C/Rendering/CGenericRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #ifdef __APPLE__ 5 | #include 6 | #else 7 | #include 8 | #endif 9 | 10 | #ifdef __cplusplus 11 | extern "C" 12 | { 13 | #endif 14 | 15 | typedef void(*UImGui_CGenericRenderer_VoidVoidFun)(void); 16 | typedef void(*UImGui_CGenericRenderer_TickEvent)(float); 17 | 18 | UIMGUI_PUBLIC_API UImGui_CGenericRenderer* UImGui_CGenericRenderer_init( 19 | UImGui_CGenericRenderer_VoidVoidFun setupWindowIntegration, 20 | UImGui_CGenericRenderer_VoidVoidFun setupPostWindowIntegration, 21 | 22 | UImGui_CGenericRenderer_VoidVoidFun init, 23 | UImGui_CGenericRenderer_TickEvent renderStart, 24 | UImGui_CGenericRenderer_TickEvent renderEnd, 25 | UImGui_CGenericRenderer_VoidVoidFun destroy, 26 | 27 | UImGui_CGenericRenderer_VoidVoidFun ImGuiNewFrame, 28 | UImGui_CGenericRenderer_VoidVoidFun ImGuiShutdown, 29 | UImGui_CGenericRenderer_VoidVoidFun ImGuiInit, 30 | UImGui_CGenericRenderer_VoidVoidFun ImGuiRenderData, 31 | 32 | UImGui_CGenericRenderer_VoidVoidFun waitOnGPU, 33 | UImGui_CGenericRenderer_VoidVoidFun destruct 34 | ); 35 | UIMGUI_PUBLIC_API void UImGui_CGenericRenderer_free(UImGui_CGenericRenderer* data); 36 | #ifdef __cplusplus 37 | } 38 | #endif -------------------------------------------------------------------------------- /Framework/C/Rendering/CGenericTexture.cpp: -------------------------------------------------------------------------------- 1 | #include "CGenericTexture.h" 2 | #include 3 | 4 | class CGenericTexture final : public UImGui::GenericTexture 5 | { 6 | public: 7 | CGenericTexture() noexcept = default; 8 | virtual void init(UImGui::TextureData& dt, const UImGui::String location, const bool bFiltered) noexcept override 9 | { 10 | initFun(&dt, location, bFiltered); 11 | defaultInit(dt, location, bFiltered); 12 | } 13 | 14 | virtual uintptr_t get(UImGui::TextureData& dt) noexcept override 15 | { 16 | return getFun(&dt); 17 | } 18 | 19 | virtual void load(UImGui::TextureData& dt, void* data, UImGui::FVector2 size, const uint32_t depth, bool const bFreeImageData, const TFunction& freeFunc) noexcept override 20 | { 21 | beginLoad(dt, &data, size); 22 | loadFun(&dt, data, size, depth, bFreeImageData); 23 | endLoad(dt, data, bFreeImageData, freeFunc); 24 | } 25 | 26 | virtual void clear(UImGui::TextureData& dt) noexcept override 27 | { 28 | clearFun(&dt); 29 | defaultClear(dt); 30 | } 31 | 32 | ~CGenericTexture() noexcept override = default; 33 | 34 | UImGui_CGenericTexture_InitFun initFun; 35 | UImGui_CGenericTexture_GetFun getFun; 36 | UImGui_CGenericTexture_LoadFun loadFun; 37 | UImGui_CGenericTexture_Clear clearFun; 38 | }; 39 | 40 | UImGui_CGenericTexture* UImGui_CGenericTexture_make( 41 | const UImGui_CGenericTexture_InitFun init, 42 | const UImGui_CGenericTexture_GetFun get, 43 | const UImGui_CGenericTexture_LoadFun load, 44 | const UImGui_CGenericTexture_Clear clear) 45 | { 46 | auto* a = new CGenericTexture{}; 47 | a->initFun = init; 48 | a->getFun = get, 49 | a->loadFun = load; 50 | a->clearFun = clear; 51 | 52 | return static_cast(a); 53 | } 54 | 55 | void UImGui_CGenericTexture_free(UImGui_CGenericTexture* texture) 56 | { 57 | delete static_cast(texture); 58 | } -------------------------------------------------------------------------------- /Framework/C/Rendering/CGenericTexture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" 8 | { 9 | #endif 10 | typedef void UImGui_CGenericTexture; 11 | typedef void(*UImGui_CGenericTexture_VoidFun)(UImGui_TextureData*); 12 | 13 | typedef void(*UImGui_CGenericTexture_InitFun)(UImGui_TextureData*, UImGui_String, bool); 14 | typedef uintptr_t(*UImGui_CGenericTexture_GetFun)(UImGui_TextureData*); 15 | typedef void(*UImGui_CGenericTexture_LoadFun)(UImGui_TextureData*, void*, UImGui_FVector2, uint32_t, bool); 16 | 17 | typedef UImGui_CGenericTexture_VoidFun UImGui_CGenericTexture_Clear; 18 | 19 | // Event safety - any-time 20 | UIMGUI_PUBLIC_API UImGui_CGenericTexture* UImGui_CGenericTexture_make( 21 | UImGui_CGenericTexture_InitFun init, 22 | UImGui_CGenericTexture_GetFun get, 23 | UImGui_CGenericTexture_LoadFun load, 24 | UImGui_CGenericTexture_Clear clear 25 | ); 26 | 27 | // Event safety - end 28 | UIMGUI_PUBLIC_API void UImGui_CGenericTexture_free(UImGui_CGenericTexture* texture); 29 | #ifdef __cplusplus 30 | } 31 | #endif -------------------------------------------------------------------------------- /Framework/C/Rendering/CRendererUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "CRendererUtils.h" 2 | #include 3 | 4 | void UImGui_RendererUtils_setupManually() 5 | { 6 | UImGui::RendererUtils::setupManually(); 7 | } 8 | 9 | void UImGui_RendererUtils_OpenGL_setHints(const int majorVersion, const int minorVersion, const UImGui_RendererClientAPI clientApi, const UImGui_OpenGLProfile profile, const bool bForwardCompatible) 10 | { 11 | UImGui::RendererUtils::OpenGL::setHints(majorVersion, minorVersion, clientApi, profile, bForwardCompatible); 12 | } 13 | 14 | void UImGui_RendererUtils_OpenGL_swapFramebuffer() 15 | { 16 | UImGui::RendererUtils::OpenGL::swapFramebuffer(); 17 | } 18 | 19 | bool UImGui_RendererUtils_WebGPU_supported() 20 | { 21 | return UImGui::RendererUtils::WebGPU::supported(); 22 | } 23 | 24 | void UImGui_RendererUtils_beginImGuiFrame() 25 | { 26 | UImGui::RendererUtils::beginImGuiFrame(); 27 | } 28 | -------------------------------------------------------------------------------- /Framework/C/Rendering/CRendererUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #ifdef __cplusplus 5 | extern "C" 6 | { 7 | #endif 8 | 9 | #define UIMGUI_EMSCRIPTEN_LATEST_OPENGL_VERSION 2, 0 10 | #define UIMGUI_EMSCRIPTEN_LATEST_GLSL_VERSION "#version 100" 11 | 12 | #define UIMGUI_APPLE_LATEST_OPENGL_VERSION 4, 1 13 | #define UIMGUI_APPLE_LATEST_GLSL_VERSION "#version 410" 14 | 15 | #define UIMGUI_ANY_LATEST_OPENGL_VERSION 4, 5 16 | #define UIMGUI_ANY_LATEST_GLSL_VERSION "#version 450" 17 | 18 | #ifdef __EMSCRIPTEN__ 19 | #define UIMGUI_LATEST_OPENGL_VERSION UIMGUI_EMSCRIPTEN_LATEST_OPENGL_VERSION 20 | #define UIMGUI_LATEST_GLSL_VERSION UIMGUI_EMSCRIPTEN_LATEST_GLSL_VERSION 21 | #else 22 | #ifdef __APPLE__ 23 | #define UIMGUI_LATEST_OPENGL_VERSION UIMGUI_APPLE_LATEST_OPENGL_VERSION 24 | #define UIMGUI_LATEST_GLSL_VERSION UIMGUI_APPLE_LATEST_GLSL_VERSION 25 | #else 26 | #define UIMGUI_LATEST_OPENGL_VERSION UIMGUI_ANY_LATEST_OPENGL_VERSION 27 | #define UIMGUI_LATEST_GLSL_VERSION UIMGUI_ANY_LATEST_GLSL_VERSION 28 | #endif 29 | #endif 30 | 31 | struct GLFWwindow; 32 | 33 | typedef enum UImGui_RendererClientAPI 34 | { 35 | UIMGUI_RENDERER_CLIENT_API_MANUAL = 0, 36 | UIMGUI_RENDERER_CLIENT_API_OPENGL = 0x00030001, 37 | UIMGUI_RENDERER_CLIENT_API_OPENGL_ES = 0x00030002 38 | } UImGui_RendererClientAPI; 39 | 40 | typedef enum UImGui_OpenGLProfile 41 | { 42 | UIMGUI_OPENGL_PROFILE_ANY = 0, 43 | UIMGUI_OPENGL_PROFILE_CORE = 0x00032001, 44 | UIMGUI_OPENGL_PROFILE_COMPAT = 0x00032002, 45 | } UImGui_OpenGLProfile; 46 | 47 | // Call this inside the window hints interface function of the GenericRenderer class 48 | // 49 | // Use this for every graphics API, except for OpenGL. For OpenGL you should use: UImGui_RendererUtils_setOpenGLHints 50 | // Event safety - startup, post-startup 51 | UIMGUI_PUBLIC_API void UImGui_RendererUtils_setupManually(); 52 | 53 | // Call this inside the window hints interface function of the GenericRenderer class 54 | // 55 | // Recommended args: 56 | // Emscripten/Web targets - UIMGUI_LATEST_OPENGL_VERSION, UIMGUI_RENDERER_CLIENT_API_OPENGL_ES, UIMGUI_OPENGL_PROFILE_ANY, false 57 | // Desktop - UIMGUI_LATEST_OPENGL_VERSION, UIMGUI_RENDERER_CLIENT_API_OPENGL, UIMGUI_OPENGL_PROFILE_CORE, true 58 | // 59 | // Event safety - startup, post-startup 60 | UIMGUI_PUBLIC_API void UImGui_RendererUtils_OpenGL_setHints(int majorVersion, int minorVersion, UImGui_RendererClientAPI clientApi, UImGui_OpenGLProfile profile, bool bForwardCompatible); 61 | 62 | // Swaps buffers for OpenGL. 63 | // Event safety - post-begin 64 | UIMGUI_PUBLIC_API void UImGui_RendererUtils_OpenGL_swapFramebuffer(); 65 | 66 | // Check for WebGPU support 67 | // Event safety - any time 68 | UIMGUI_PUBLIC_API bool UImGui_RendererUtils_WebGPU_supported(); 69 | 70 | // Renderer a new dear imgui frame 71 | // Event safety - tick 72 | UIMGUI_PUBLIC_API void UImGui_RendererUtils_beginImGuiFrame(); 73 | #ifdef __cplusplus 74 | } 75 | #endif -------------------------------------------------------------------------------- /Framework/C/Rendering/CTexture.cpp: -------------------------------------------------------------------------------- 1 | #include "CTexture.h" 2 | #include 3 | #include 4 | #include 5 | 6 | #define cast(x) ((UImGui::Texture*)(x)) 7 | 8 | void UImGui_Texture_defaultFreeFunc(void* data) 9 | { 10 | stbi_image_free(data); 11 | } 12 | 13 | UImGui_CTexture* UImGui_Texture_init(const UImGui_String file, const bool bFiltered) 14 | { 15 | UImGui::Texture tex(file); 16 | return tex.init(file, bFiltered) ? &UImGui::Global::get().deallocationStruct.textures.emplace_back(tex) : nullptr; 17 | } 18 | 19 | void UImGui_Texture_load(UImGui_CTexture* texture, void* data, const UImGui_FVector2 size, const uint32_t depth, 20 | const bool bFreeImageData, const UImGui_Texture_FreeFunctionT defaultFreeFunc) 21 | { 22 | cast(texture)->load(data, size, depth, bFreeImageData, defaultFreeFunc); 23 | } 24 | 25 | uintptr_t UImGui_Texture_get(UImGui_CTexture* texture) 26 | { 27 | return cast(texture)->get(); 28 | } 29 | 30 | UImGui_FVector2 UImGui_Texture_size(UImGui_CTexture* texture) 31 | { 32 | return cast(texture)->size(); 33 | } 34 | 35 | void UImGui_Texture_clear(UImGui_CTexture* texture) 36 | { 37 | cast(texture)->clear(); 38 | } 39 | 40 | bool UImGui_Texture_saveToFile(UImGui_CTexture* texture, const UImGui_String location, const UImGui_TextureFormat fmt, const uint8_t jpegQuality) 41 | { 42 | return UImGui::GenericTexture::saveToFile(cast(texture)->getData(), location, fmt, jpegQuality); 43 | } 44 | 45 | void UImGui_Texture_setCustomSaveFunction(UImGui_CTexture* texture, const UImGui_Texture_CustomSaveFunction f) 46 | { 47 | cast(texture)->setCustomSaveFunction(f); 48 | } 49 | 50 | void UImGui_Texture_release(const UImGui_CTexture* texture) 51 | { 52 | // Could use pointer arithmetic but that would be really unsafe 53 | auto& textures = UImGui::Global::get().deallocationStruct.textures; 54 | for (size_t i = 0; i < textures.size(); i++) 55 | { 56 | if (texture == &textures[i]) 57 | { 58 | textures.erase(textures.begin() + static_cast(i)); 59 | return; 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Framework/C/UImGuiCAPI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include -------------------------------------------------------------------------------- /Framework/Core/Allocator.cpp: -------------------------------------------------------------------------------- 1 | #include "Allocator.hpp" 2 | 3 | UImGui::AllocatorFuncs& UImGui::AllocatorFuncs::get(AllocatorFuncs* parent) noexcept 4 | { 5 | static AllocatorFuncs* allocators = parent == nullptr ? getWithCreate() : parent; 6 | return *allocators; 7 | } 8 | 9 | UImGui::AllocatorFuncs* UImGui::AllocatorFuncs::getWithCreate() noexcept 10 | { 11 | static AllocatorFuncs allocators 12 | { 13 | .allocate = UImGui_Allocator_private_allocate, 14 | .deallocate = UImGui_Allocator_private_deallocate 15 | }; 16 | return &allocators; 17 | } 18 | -------------------------------------------------------------------------------- /Framework/Core/Allocator.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace UImGui 5 | { 6 | class UIMGUI_PUBLIC_API AllocatorFuncs 7 | { 8 | public: 9 | void*(*allocate)(size_t); 10 | void(*deallocate)(void*); 11 | 12 | static AllocatorFuncs& get(AllocatorFuncs* parent = nullptr) noexcept; 13 | private: 14 | static AllocatorFuncs* getWithCreate() noexcept; 15 | }; 16 | 17 | template 18 | class UIMGUI_PUBLIC_API Allocator 19 | { 20 | public: 21 | using value_type = T; 22 | 23 | Allocator() noexcept = default; 24 | 25 | template 26 | Allocator(const Allocator&) noexcept 27 | { 28 | } 29 | 30 | static T* allocate(const size_t n) noexcept 31 | { 32 | return (n == 0) ? nullptr : static_cast(UImGui_Allocator_allocate(n * sizeof(T))); 33 | } 34 | 35 | static void deallocate(T* ptr, size_t) noexcept 36 | { 37 | if (ptr != nullptr) 38 | UImGui_Allocator_deallocate(ptr); 39 | } 40 | 41 | template 42 | bool operator==(const Allocator&) const noexcept 43 | { 44 | return true; 45 | } 46 | 47 | template 48 | bool operator!=(const Allocator&) const noexcept 49 | { 50 | return false; 51 | } 52 | }; 53 | } 54 | -------------------------------------------------------------------------------- /Framework/Core/CDeallocation.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace UImGui 8 | { 9 | // A struct for storing variables for the C API, that will be deallocated when the application closes 10 | struct UIMGUI_PUBLIC_API CDeallocationStruct 11 | { 12 | TVector keyStrings; 13 | TVector monitors; 14 | TVector textures; 15 | TVector plugins; 16 | }; 17 | } -------------------------------------------------------------------------------- /Framework/Core/Components/InlineComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "InlineComponent.hpp" 2 | 3 | void UImGui::InlineComponent::beginAutohandle() noexcept 4 | { 5 | 6 | } 7 | 8 | void UImGui::InlineComponent::tickAutohandle(float) noexcept 9 | { 10 | 11 | } 12 | 13 | void UImGui::InlineComponent::endAutohandle() noexcept 14 | { 15 | 16 | } -------------------------------------------------------------------------------- /Framework/Core/Components/InlineComponent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace UImGui 6 | { 7 | /** 8 | * @brief A component that directly draws to the window's frame-buffer(the opposite of the WindowComponent) 9 | * @implements InlineComponent - The constructor for the component 10 | * @implements begin - The default begin event as detailed in the docs 11 | * @implements tick - The default tick event as detailed in the docs 12 | * @implements end - The default end event as detailed in the docs 13 | * @static make - Creates an InlineComponent of a given subclass type 14 | * @implements beginAutohandle - Used to automatically handle downstream begin events 15 | * @implements tickAutohandle - Used to automatically handle downstream tick events 16 | * @implements endAutohandle - Used to automatically handle downstream end events 17 | * @var state - The default initial state of the component 18 | * @var componentType - The constexpr type of the component 19 | * @var name - The name identifier of the component 20 | * @var id - The numeric identifier of the component 21 | */ 22 | class UIMGUI_PUBLIC_API InlineComponent 23 | { 24 | public: 25 | InlineComponent() = default; 26 | 27 | // Event Safety - All ready 28 | virtual void begin() = 0; 29 | // Event Safety - All ready 30 | virtual void tick(float deltaTime) = 0; 31 | // Event Safety - Pre-destruct 32 | virtual void end() = 0; 33 | 34 | /** 35 | * @brief Instantiates the component of type T and using polymorphism converts it to the base class of InlineComponent 36 | * @tparam T The type of the InlineComponent subclass 37 | * @return The new instance pointer 38 | * @note Event Safety - Any time 39 | */ 40 | template 41 | static InlineComponent* make() noexcept 42 | { 43 | T* n = new T(); 44 | return n; 45 | } 46 | 47 | /** 48 | * @brief Used to automatically handle downstream begin events 49 | * @note Event Safety - Any time 50 | */ 51 | void beginAutohandle() noexcept; 52 | /** 53 | * @brief Used to automatically handle downstream tick events 54 | * @param deltaTime - the delta time calculated in the application's render loop 55 | * @note Event Safety - Any time 56 | */ 57 | void tickAutohandle(float deltaTime) noexcept; 58 | /** 59 | * @brief Used to automatically handle downstream end events 60 | * @note Event Safety - Any time 61 | */ 62 | void endAutohandle() noexcept; 63 | 64 | /** 65 | * @brief The current state of the component 66 | */ 67 | ComponentState state = UIMGUI_COMPONENT_STATE_RUNNING; 68 | /** 69 | * @brief The type of the component represented by a ComponentType constexpr static variable 70 | */ 71 | static constexpr ComponentType componentType = UIMGUI_COMPONENT_TYPE_INLINE; 72 | /** 73 | * @brief The name ID of the component as to provide a human readable way to differentiate between components, 74 | * not guaranteed to be unique 75 | */ 76 | FString name{}; 77 | /** 78 | * @brief The numeric ID of the component, it's not a UUID and is provided by the user! 79 | */ 80 | uint64_t id{}; 81 | 82 | virtual ~InlineComponent() = default; 83 | private: 84 | 85 | }; 86 | } -------------------------------------------------------------------------------- /Framework/Core/Components/Instance.cpp: -------------------------------------------------------------------------------- 1 | #include "Instance.hpp" 2 | #include 3 | #include 4 | 5 | UImGui::Instance::Instance() noexcept 6 | { 7 | if (initInfo.cInitInfo != nullptr && initInfo.cInitInfo->constructFuncs != nullptr) 8 | for (size_t i = 0; i < initInfo.cInitInfo->constructSize; i++) 9 | initInfo.cInitInfo->constructFuncs[i](initInfo.cInitInfo); 10 | } 11 | 12 | UImGui::Instance::~Instance() noexcept 13 | { 14 | if (initInfo.cInitInfo != nullptr && initInfo.cInitInfo->destructFuncs != nullptr) 15 | for (size_t i = 0; i < initInfo.cInitInfo->destructSize; i++) 16 | initInfo.cInitInfo->destructFuncs[i](initInfo.cInitInfo); 17 | 18 | initInfo.titlebarComponents.clear(); 19 | initInfo.windowComponents.clear(); 20 | initInfo.inlineComponents.clear(); 21 | 22 | // Delete doesn't work with void* 23 | if (initInfo.bGlobalAllocatedOnHeap) 24 | free(initInfo.globalData); 25 | if (initInfo.cInitInfo != nullptr && initInfo.cInitInfo->bGlobalAllocatedOnHeap) 26 | free(initInfo.cInitInfo->globalData); 27 | 28 | for (auto& a : Plugins::getPlugins()) 29 | a.detach(); 30 | } 31 | 32 | void UImGui::Instance::beginAutohandle() const noexcept 33 | { 34 | if (initInfo.cInitInfo != nullptr && initInfo.cInitInfo->beginFuncs != nullptr) 35 | for (size_t i = 0; i < initInfo.cInitInfo->beginSize; i++) 36 | initInfo.cInitInfo->beginFuncs[i](initInfo.cInitInfo); 37 | } 38 | 39 | void UImGui::Instance::tickAutohandle(const float deltaTime) const noexcept 40 | { 41 | if (initInfo.cInitInfo != nullptr && initInfo.cInitInfo->tickFuncs != nullptr) 42 | for (size_t i = 0; i < initInfo.cInitInfo->tickSize; i++) 43 | initInfo.cInitInfo->tickFuncs[i](initInfo.cInitInfo, deltaTime); 44 | } 45 | 46 | void UImGui::Instance::endAutohandle() const noexcept 47 | { 48 | if (initInfo.cInitInfo != nullptr && initInfo.cInitInfo->endFuncs != nullptr) 49 | for (size_t i = 0; i < initInfo.cInitInfo->endSize; i++) 50 | initInfo.cInitInfo->endFuncs[i](initInfo.cInitInfo); 51 | } 52 | 53 | void* UImGui::Instance::getGlobal() noexcept 54 | { 55 | return get()->initInfo.globalData; 56 | } 57 | 58 | void UImGui::Instance::shutdown() noexcept 59 | { 60 | Window::get().close(); 61 | } 62 | 63 | UImGui::Instance* UImGui::Instance::get() noexcept 64 | { 65 | return Global::get().instance; 66 | } 67 | 68 | void UImGui::Instance::reloadApplicationMetadata() noexcept 69 | { 70 | YAML::Node node; 71 | try 72 | { 73 | node = YAML::LoadFile((initInfo.projectDir + "uvproj.yaml").c_str()); 74 | } 75 | catch (YAML::BadFile&) 76 | { 77 | Logger::log("Couldn't open the uvproj.yaml file. Application name, application, version and engine version not available!", ULOG_LOG_TYPE_WARNING); 78 | return; 79 | } 80 | if (node["name"]) 81 | applicationName = node["name"].as(); 82 | if (node["version"]) 83 | applicationVersion = node["version"].as(); 84 | if (node["engine-version"]) 85 | engineVersion = node["engine-version"].as(); 86 | } 87 | -------------------------------------------------------------------------------- /Framework/Core/Components/TitlebarComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "TitlebarComponent.hpp" 2 | 3 | void UImGui::TitlebarComponent::beginAutohandle() noexcept 4 | { 5 | 6 | } 7 | 8 | void UImGui::TitlebarComponent::tickAutohandle(float) noexcept 9 | { 10 | 11 | } 12 | 13 | void UImGui::TitlebarComponent::endAutohandle() noexcept 14 | { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Framework/Core/Components/TitlebarComponent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace UImGui 6 | { 7 | /** 8 | * @brief A UI component that implements the standard top title bar 9 | * @implements TitlebarComponent - The constructor for the component 10 | * @implements begin - The default begin event as detailed in the docs 11 | * @implements tick - The default tick event as detailed in the docs 12 | * @implements end - The default end event as detailed in the docs 13 | * @static make - Creates a titlebar component of a given subclass type 14 | * @var componentType - The type of the component as a constexpr 15 | * @var state - The default initial state of the component 16 | * @var name - The name identifier of the component 17 | * @var id - The numeric identifier of the component 18 | * @implements beginAutohandle - Used to automatically handle downstream begin events 19 | * @implements tickAutohandle - Used to automatically handle downstream tick events 20 | * @implements endAutohandle - Used to automatically handle downstream end events 21 | */ 22 | class UIMGUI_PUBLIC_API TitlebarComponent 23 | { 24 | public: 25 | TitlebarComponent() = default; 26 | // Event Safety - All ready 27 | virtual void begin() = 0; 28 | // Event Safety - All ready 29 | virtual void tick(float deltaTime) = 0; 30 | // Event Safety - Pre-destruct 31 | virtual void end() = 0; 32 | 33 | /** 34 | * @brief Easily initializes a component of a certain subclass provided as a template argument 35 | * @tparam T - The subclass type 36 | * @return A pointer to the newly created component 37 | * @note Event Safety - Any time 38 | */ 39 | template 40 | static TitlebarComponent* make() noexcept 41 | { 42 | T* n = new T(); 43 | return n; 44 | } 45 | 46 | /** 47 | * @brief Used to automatically handle downstream begin events 48 | * @note Event Safety - Any time 49 | */ 50 | void beginAutohandle() noexcept; 51 | /** 52 | * @brief Used to automatically handle downstream tick events 53 | * @param deltaTime - the delta time calculated in the application's render loop 54 | * @note Event Safety - Any time 55 | */ 56 | void tickAutohandle(float deltaTime) noexcept; 57 | /** 58 | * @brief Used to automatically handle downstream end events 59 | * @note Event Safety - Any time 60 | */ 61 | void endAutohandle() noexcept; 62 | 63 | /** 64 | * @brief The current state of the component 65 | */ 66 | ComponentState state = UIMGUI_COMPONENT_STATE_RUNNING; 67 | /** 68 | * @brief The type of the component represented by a ComponentType constexpr static variable 69 | */ 70 | static constexpr ComponentType componentType = UIMGUI_COMPONENT_TYPE_TITLEBAR; 71 | /** 72 | * @brief The name ID of the component as to provide a human readable way to differentiate between components, 73 | * not guaranteed to be unique 74 | */ 75 | FString name{}; 76 | /** 77 | * @brief The numeric ID of the component, it's not a UUID and is provided by the user! 78 | */ 79 | uint64_t id{}; 80 | 81 | virtual ~TitlebarComponent() = default; 82 | private: 83 | }; 84 | } -------------------------------------------------------------------------------- /Framework/Core/Components/WindowComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "WindowComponent.hpp" 2 | 3 | void UImGui::WindowComponent::beginAutohandle() noexcept 4 | { 5 | 6 | } 7 | 8 | void UImGui::WindowComponent::tickAutohandle(float) noexcept 9 | { 10 | 11 | } 12 | 13 | void UImGui::WindowComponent::endAutohandle() noexcept 14 | { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Framework/Core/Components/WindowComponent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace UImGui 6 | { 7 | /** 8 | * @brief A component that draws to a movable and dockable window 9 | * @implements WindowComponent - The constructor for the component 10 | * @implements begin - The default begin event as detailed in the docs 11 | * @implements tick - The default tick event as detailed in the docs 12 | * @implements end - The default end event as detailed in the docs 13 | * @static make - Creates a WindowComponent of a given subclass type 14 | * @implements beginAutohandle - Used to automatically handle downstream begin events 15 | * @implements tickAutohandle - Used to automatically handle downstream tick events 16 | * @implements endAutohandle - Used to automatically handle downstream end events 17 | * @var state - The default initial state of the component 18 | * @var componentType - The constexpr type of the component 19 | * @var name - The name identifier of the component 20 | * @var id - The numeric identifier of the component 21 | */ 22 | class UIMGUI_PUBLIC_API WindowComponent 23 | { 24 | public: 25 | WindowComponent() = default; 26 | // Event Safety - All ready 27 | virtual void begin() = 0; 28 | // Event Safety - All ready 29 | virtual void tick(float deltaTime) = 0; 30 | // Event Safety - Pre-destruct 31 | virtual void end() = 0; 32 | 33 | /** 34 | * @brief Instantiates the component of type T and using polymorphism converts it to the base class of WindowComponent 35 | * @tparam T The type of the WindowComponent subclass 36 | * @return The new instance pointer 37 | * @note Event Safety - Any time 38 | */ 39 | template 40 | static WindowComponent* make() noexcept 41 | { 42 | T* n = new T(); 43 | return n; 44 | } 45 | 46 | /** 47 | * @brief Used to automatically handle downstream begin events 48 | * @note Event Safety - Any time 49 | */ 50 | void beginAutohandle() noexcept; 51 | /** 52 | * @brief Used to automatically handle downstream tick events 53 | * @param deltaTime - the delta time calculated in the application's render loop 54 | * @note Event Safety - Any time 55 | */ 56 | void tickAutohandle(float deltaTime) noexcept; 57 | /** 58 | * @brief Used to automatically handle downstream end events 59 | * @note Event Safety - Any time 60 | */ 61 | void endAutohandle() noexcept; 62 | 63 | /** 64 | * @brief The current state of the component 65 | */ 66 | ComponentState state = UIMGUI_COMPONENT_STATE_RUNNING; 67 | /** 68 | * @brief The type of the component represented by a ComponentType constexpr static variable 69 | */ 70 | static constexpr ComponentType componentType = UIMGUI_COMPONENT_TYPE_WINDOW; 71 | /** 72 | * @brief The name ID of the component as to provide a human readable way to differentiate between components, 73 | * not guaranteed to be unique 74 | */ 75 | FString name{}; 76 | /** 77 | * @brief The numeric ID of the component, it's not a UUID and is provided by the user! 78 | */ 79 | uint64_t id{}; 80 | 81 | virtual ~WindowComponent() = default; 82 | private: 83 | 84 | }; 85 | } -------------------------------------------------------------------------------- /Framework/Core/Core.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | -------------------------------------------------------------------------------- /Framework/Core/Defines.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // This header only contains C++ code. Check out the C header for a lot more defines. 3 | #include 4 | 5 | // Define a macro for accessing std::filesystem 6 | #ifndef __MINGW32__ 7 | #if __has_include() 8 | #include 9 | #define std_filesystem std::filesystem 10 | #else 11 | #include 12 | #define std_filesystem std::experimental::filesystem 13 | #endif 14 | #else 15 | #error "Compiling against MinGW is not supported!" 16 | #endif 17 | 18 | #ifdef PRODUCTION 19 | #define UIMGUI_START(x) std::ios_base::sync_with_stdio(!(x)); \ 20 | UNUSED(UImGui::AllocatorFuncs::get()); \ 21 | UNUSED(UImGui::Global::get()); \ 22 | logger.setCrashOnError(true); \ 23 | UImGui::Utility::removeConsole() 24 | #else 25 | #define UIMGUI_START(x) std::ios_base::sync_with_stdio(!(x)); \ 26 | UNUSED(UImGui::AllocatorFuncs::get()); \ 27 | UNUSED(UImGui::Global::get()) 28 | #endif 29 | 30 | #define CAST(x, y) static_cast(y) 31 | #define FCAST(x, y) (x)y 32 | 33 | namespace UImGui 34 | { 35 | /** 36 | * @brief The ComponentState enum defines 3 fields that represent the event state of the given component, the given 37 | * component can then check its own state(if in PAUSED or RUNNING state) and call specific components of its event 38 | * functions. The OFF state is there to make it easy to fully shut down a component until the program closes 39 | */ 40 | typedef UImGui_ComponentState ComponentState; 41 | 42 | /** 43 | * @brief An enum that defines component types to be used by various functions 44 | * @var UIMGUI_COMPONENT_TYPE_INLINE - Defines an inline component 45 | * @var UIMGUI_COMPONENT_TYPE_TITLEBAR - Defines a titlebar component 46 | * @var UIMGUI_COMPONENT_PYE_WINDOW - Defines a window component 47 | */ 48 | typedef UImGui_ComponentType ComponentType; 49 | } -------------------------------------------------------------------------------- /Framework/Core/FrameworkMain.cpp: -------------------------------------------------------------------------------- 1 | #include "FrameworkMain.hpp" 2 | 3 | #include 4 | #include 5 | 6 | void UImGui::FrameworkMain::setupGlobal(Global* global, AllocatorFuncs* funcs, LoggerInternal* logger) noexcept 7 | { 8 | UNUSED(Global::get(global)); 9 | UNUSED(AllocatorFuncs::get(funcs)); 10 | UNUSED(LoggerInternal::get(logger)); 11 | } 12 | 13 | void UImGui::FrameworkMain::parseArguments(Instance* instance, const int argc, char** argv) noexcept 14 | { 15 | instance->argc = argc; 16 | instance->argv = argv; 17 | instance->reloadApplicationMetadata(); 18 | 19 | instance->arguments.resize(argc); 20 | for (int i = 0; i < argc; i++) 21 | instance->arguments[i] = argv[i]; 22 | Global::get().instance = instance; 23 | } -------------------------------------------------------------------------------- /Framework/Core/FrameworkMain.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Global.hpp" 4 | 5 | namespace UImGui 6 | { 7 | class UIMGUI_PUBLIC_API FrameworkMain 8 | { 9 | public: 10 | FrameworkMain() = delete; 11 | FrameworkMain(const FrameworkMain&) = delete; 12 | void operator=(FrameworkMain const&) = delete; 13 | 14 | // Shares the important global context pointers between the executable and the shared library 15 | static void setupGlobal(Global* global, AllocatorFuncs* funcs, LoggerInternal* logger) noexcept; 16 | // Parser CLI arguments 17 | static void parseArguments(Instance* instance, int argc, char** argv) noexcept; 18 | }; 19 | } -------------------------------------------------------------------------------- /Framework/Core/Global.cpp: -------------------------------------------------------------------------------- 1 | #include "Global.hpp" 2 | #include 3 | 4 | UImGui::Global::Global() noexcept 5 | { 6 | Utility::interruptSignalHandler(); 7 | } 8 | 9 | UImGui::Global::~Global() noexcept 10 | { 11 | #ifdef _WIN32 12 | ExitProcess(0); 13 | #endif 14 | } 15 | 16 | UImGui::Global& UImGui::Global::get(Global* parent) noexcept 17 | { 18 | static Global* global = parent == nullptr ? getWithCreate() : parent; 19 | return *global; 20 | } 21 | 22 | UImGui::Global* UImGui::Global::getWithCreate() noexcept 23 | { 24 | static Global global{}; 25 | return &global; 26 | } 27 | -------------------------------------------------------------------------------- /Framework/Core/Global.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Modules/Manager/ModulesManager.hpp" 4 | #include "CDeallocation.hpp" 5 | #include 6 | #ifdef _WIN32 7 | #include 8 | #endif 9 | 10 | namespace UImGui 11 | { 12 | class RendererInternal; 13 | class Instance; 14 | 15 | class UIMGUI_PUBLIC_API Global 16 | { 17 | public: 18 | Global() noexcept; 19 | ~Global() noexcept; 20 | 21 | static Global& get(Global* parent = nullptr) noexcept; 22 | 23 | Instance* instance = nullptr; 24 | RendererInternal* renderer = nullptr; 25 | 26 | CDeallocationStruct deallocationStruct; 27 | private: 28 | friend class Window; 29 | friend class Renderer; 30 | friend class Modules; 31 | friend class ModulesManager; 32 | friend class RendererInternal; 33 | friend class Plugins; 34 | 35 | WindowInternal window{}; 36 | ModulesManager modulesManagerr{}; 37 | Plugins plugins{}; 38 | 39 | static Global* getWithCreate() noexcept; 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /Framework/Core/Interfaces/Input.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | bool UImGui::InputAction::operator==(const uint8_t& st) const noexcept 6 | { 7 | return state == st; 8 | } 9 | 10 | bool UImGui::InputAction::operator!=(const uint8_t& st) const noexcept 11 | { 12 | return state != st; 13 | } 14 | 15 | uint8_t UImGui::Input::getKey(const uint16_t key) noexcept 16 | { 17 | return Window::get().keys[key]; 18 | } 19 | 20 | const UImGui::InputAction& UImGui::Input::getAction(const FString& name) noexcept 21 | { 22 | for (auto& a : Window::get().inputActionList) 23 | if (a.name == name) 24 | return a; 25 | Logger::log("Input action with name: ", ULOG_LOG_TYPE_ERROR, name, ", does not exist!"); 26 | std::terminate(); 27 | } 28 | 29 | UImGui::TVector& UImGui::Input::getActions() noexcept 30 | { 31 | return Window::get().inputActionList; 32 | } 33 | 34 | UImGui::FVector2 UImGui::Input::getMousePositionChange() noexcept 35 | { 36 | return Window::get().getMousePositionChange(); 37 | } 38 | 39 | UImGui::FVector2 UImGui::Input::getCurrentMousePosition() noexcept 40 | { 41 | return Window::get().mousePos; 42 | } 43 | 44 | UImGui::FVector2 UImGui::Input::getLastMousePosition() noexcept 45 | { 46 | return Window::get().mouseLastPos; 47 | } 48 | 49 | UImGui::FVector2 UImGui::Input::getScroll() noexcept 50 | { 51 | return Window::get().getScroll(); 52 | } 53 | 54 | void UImGui::Input::setCursorVisibility(const CursorVisibilityState visibility) noexcept 55 | { 56 | glfwSetInputMode(Window::getInternal(), GLFW_CURSOR, visibility); 57 | } 58 | 59 | UImGui::CursorVisibilityState UImGui::Input::getCurrentCursorVisibility() noexcept 60 | { 61 | return static_cast(glfwGetInputMode(Window::getInternal(), GLFW_CURSOR)); 62 | } 63 | 64 | void UImGui::Input::setStickyKeys(const bool bEnable) noexcept 65 | { 66 | glfwSetInputMode(Window::getInternal(), GLFW_STICKY_KEYS, bEnable); 67 | glfwSetInputMode(Window::getInternal(), GLFW_STICKY_MOUSE_BUTTONS, bEnable); 68 | } 69 | 70 | bool UImGui::Input::getStickyKeys() noexcept 71 | { 72 | // Use this since we set both anyway 73 | return glfwGetInputMode(Window::getInternal(), GLFW_STICKY_KEYS); 74 | } 75 | 76 | void UImGui::Input::setRawMouseMotion(const bool bEnable) noexcept 77 | { 78 | if (glfwRawMouseMotionSupported()) 79 | glfwSetInputMode(Window::getInternal(), GLFW_RAW_MOUSE_MOTION, bEnable); 80 | } 81 | 82 | bool UImGui::Input::getRawMouseMotion() noexcept 83 | { 84 | return glfwGetInputMode(Window::getInternal(), GLFW_RAW_MOUSE_MOTION); 85 | } 86 | 87 | void UImGui::Input::setLockKeyMods(const bool bEnable) noexcept 88 | { 89 | glfwSetInputMode(Window::getInternal(), GLFW_LOCK_KEY_MODS, bEnable); 90 | } 91 | 92 | bool UImGui::Input::getLockKeyMods() noexcept 93 | { 94 | return glfwGetInputMode(Window::getInternal(), GLFW_LOCK_KEY_MODS); 95 | } 96 | -------------------------------------------------------------------------------- /Framework/Core/Interfaces/Input.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | // Imports the C API, contains definitions of the C InputAction struct and other uniform API structs and enum 5 | #include 6 | 7 | namespace UImGui 8 | { 9 | 10 | /** 11 | * @brief A struct to hold the data for an input action 12 | * @var name - The name ID for the action 13 | * @var keyCode - The keyCode at which the action gets activated 14 | * @var state - The current state of the action 15 | * @note Event Safety - Any time 16 | */ 17 | struct UIMGUI_PUBLIC_API InputAction 18 | { 19 | InputAction() = default; 20 | 21 | bool operator==(const uint8_t& st) const noexcept; 22 | bool operator!=(const uint8_t& st) const noexcept; 23 | 24 | // The ID for the action 25 | FString name{}; 26 | TVector keyCodes; 27 | 28 | // Set by the input system, do not set this manually 29 | uint8_t state{}; 30 | }; 31 | 32 | typedef UImGui_CursorVisibilityState CursorVisibilityState; 33 | 34 | /** 35 | * @brief Implements a public interface to the Input system 36 | * @implements getKey - Given a keycode, returns the state of the key 37 | * @implements getAction - Given the name of an action, returns the action 38 | * @implements getActions - Returns the list of actions 39 | * @implements getMousePositionChange, getCurrentMousePosition, getLastMousePosition, getScroll 40 | * @note Event Safety - Any time 41 | */ 42 | class UIMGUI_PUBLIC_API Input 43 | { 44 | public: 45 | Input() = delete; 46 | Input(const Input&) = delete; 47 | void operator=(Input const&) = delete; 48 | 49 | // Event Safety - begin, style, post-begin 50 | static void setCursorVisibility(CursorVisibilityState visibility) noexcept; 51 | // Event Safety - begin, style, post-begin 52 | static CursorVisibilityState getCurrentCursorVisibility() noexcept; 53 | 54 | // Event Safety - begin, style, post-begin 55 | static void setStickyKeys(bool bEnable) noexcept; 56 | // Event Safety - begin, style, post-begin 57 | static bool getStickyKeys() noexcept; 58 | 59 | // Event Safety - begin, style, post-begin 60 | // This may not be set if the system doesn't support raw mouse motion or if the mouse cursor is not in the 61 | // UIMGUI_CURSOR_VISIBILITY_STATE_DISABLED state 62 | static void setRawMouseMotion(bool bEnable) noexcept; 63 | // Event Safety - begin, style, post-begin 64 | static bool getRawMouseMotion() noexcept; 65 | 66 | // Event Safety - begin, style, post-begin 67 | static void setLockKeyMods(bool bEnable) noexcept; 68 | // Event Safety - begin, style, post-begin 69 | static bool getLockKeyMods() noexcept; 70 | 71 | // Event Safety - Any time 72 | static uint8_t getKey(uint16_t key) noexcept; 73 | // Event Safety - Any time 74 | static const InputAction& getAction(const UImGui::FString& name) noexcept; 75 | 76 | // Event Safety - Any time 77 | static TVector& getActions() noexcept; 78 | 79 | // Event Safety - Any time 80 | static FVector2 getMousePositionChange() noexcept; 81 | // Event Safety - Any time 82 | static FVector2 getCurrentMousePosition() noexcept; 83 | // Event Safety - Any time 84 | static FVector2 getLastMousePosition() noexcept; 85 | 86 | // Event Safety - Any time 87 | static FVector2 getScroll() noexcept; 88 | }; 89 | } -------------------------------------------------------------------------------- /Framework/Core/Interfaces/LayoutsInterface.cpp: -------------------------------------------------------------------------------- 1 | #include "LayoutsInterface.hpp" 2 | #include "WindowInterface.hpp" 3 | #include "imgui.h" 4 | 5 | bool& UImGui::Layouts::getLoadLayout() noexcept 6 | { 7 | return Window::get().windowData.bLoadLayout; 8 | } 9 | 10 | bool& UImGui::Layouts::getSaveLayout() noexcept 11 | { 12 | return Window::get().windowData.bSaveLayout; 13 | } 14 | 15 | UImGui::FString& UImGui::Layouts::layoutLocation() noexcept 16 | { 17 | return Window::get().windowData.layoutLocation; 18 | } 19 | 20 | void UImGui::Layouts::loadLayout(String layout) noexcept 21 | { 22 | ImGui::LoadIniSettingsFromDisk(layout); 23 | } 24 | 25 | void UImGui::Layouts::saveLayout(String layout) noexcept 26 | { 27 | ImGui::SaveIniSettingsToDisk(layout); 28 | } 29 | -------------------------------------------------------------------------------- /Framework/Core/Interfaces/LayoutsInterface.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace UImGui 5 | { 6 | class UIMGUI_PUBLIC_API Layouts 7 | { 8 | public: 9 | Layouts() = delete; 10 | Layouts(const Layouts&) = delete; 11 | void operator=(Layouts const&) = delete; 12 | 13 | // Event Safety - begin, style, post-begin 14 | static bool& getLoadLayout() noexcept; 15 | // Event Safety - begin, style, post-begin 16 | static bool& getSaveLayout() noexcept; 17 | // Event Safety - begin, style, post-begin 18 | static FString& layoutLocation() noexcept; 19 | 20 | static void loadLayout(String layout) noexcept; 21 | static void saveLayout(String layout) noexcept; 22 | }; 23 | } -------------------------------------------------------------------------------- /Framework/Core/Interfaces/PluginInterface.cpp: -------------------------------------------------------------------------------- 1 | #include "PluginInterface.hpp" 2 | #include 3 | #include 4 | 5 | bool UImGui::Plugins::load(String location) noexcept 6 | { 7 | #ifndef __EMSCRIPTEN__ 8 | auto* handle = URLL::dlopen(location); 9 | if (handle == nullptr) 10 | { 11 | Logger::log("Couldn't load the plugin at location: ", ULOG_LOG_TYPE_WARNING, location, "', Error: ", URLL::dlerror()); 12 | return false; 13 | } 14 | 15 | Plugin temp 16 | { 17 | .name = location, 18 | .handle = handle 19 | }; 20 | 21 | if (URLL::dlsym(handle, "UImGui_Plugin_attach", temp.attach) != handle) 22 | { 23 | Logger::log("Couldn't load the attach symbol from the plugin at location: '", ULOG_LOG_TYPE_WARNING, location, "', Error: ", URLL::dlerror()); 24 | return false; 25 | } 26 | if (URLL::dlsym(handle, "UImGui_Plugin_detach", temp.detach) != handle) 27 | { 28 | Logger::log("Couldn't load the detach symbol from the plugin at location: ", ULOG_LOG_TYPE_WARNING, location, "', Error: ", URLL::dlerror()); 29 | return false; 30 | } 31 | 32 | ImGuiMemAllocFunc alloc; 33 | ImGuiMemFreeFunc free; 34 | void* userData; 35 | 36 | ImGui::GetAllocatorFunctions(&alloc, &free, &userData); 37 | 38 | PluginContext ctx 39 | { 40 | .global = &Global::get(), 41 | .allocators = &AllocatorFuncs::get(), 42 | .loggerContext = &LoggerInternal::get(), 43 | .imguiContext = ImGui::GetCurrentContext(), 44 | .allocFunc = &alloc, 45 | .freeFunc = &free, 46 | .userData = &userData, 47 | #ifdef UIMGUI_PLOTTING_MODULE_ENABLED 48 | .implotContext = Modules::data().plotting ? ImPlot::GetCurrentContext() : nullptr, 49 | #else 50 | .implotContext = nullptr, 51 | #endif 52 | #ifdef UIMGUI_TEXT_UTILS_MODULE_ENABLED 53 | .textUtilsContext = Modules::data().text_utils ? TextUtils::getTextUtilsData() : nullptr, 54 | #else 55 | .textUtilsContext = nullptr 56 | #endif 57 | }; 58 | temp.attach(&ctx); 59 | get().plugins.push_back(temp); 60 | Logger::log("Loaded plugin at location: ", ULOG_LOG_TYPE_SUCCESS, location); 61 | #endif 62 | return true; 63 | } 64 | 65 | const UImGui::TVector& UImGui::Plugins::getPlugins() noexcept 66 | { 67 | return get().plugins; 68 | } 69 | 70 | void UImGui::Plugins::loadStandard() noexcept 71 | { 72 | for (auto& a : get().standardPlugins) 73 | load(a.c_str()); 74 | } 75 | 76 | UImGui::Plugins::~Plugins() noexcept 77 | { 78 | } 79 | 80 | UImGui::Plugins& UImGui::Plugins::get() noexcept 81 | { 82 | return Global::get().plugins; 83 | } 84 | -------------------------------------------------------------------------------- /Framework/Core/Interfaces/PluginInterface.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace UImGui 6 | { 7 | class Global; 8 | 9 | struct UIMGUI_PUBLIC_API PluginContext 10 | { 11 | Global* global = nullptr; 12 | AllocatorFuncs* allocators = nullptr; 13 | LoggerInternal* loggerContext = nullptr; 14 | ImGuiContext* imguiContext = nullptr; 15 | ImGuiMemAllocFunc* allocFunc = nullptr; 16 | ImGuiMemFreeFunc* freeFunc = nullptr; 17 | void** userData = nullptr; 18 | void* implotContext = nullptr; 19 | void* textUtilsContext = nullptr; 20 | }; 21 | 22 | struct UIMGUI_PUBLIC_API Plugin 23 | { 24 | FString name{}; 25 | void* handle = nullptr; 26 | 27 | // 1. Global context pointer 28 | // 2. Dear imgui context pointer 29 | // 3. Dear imgui allocate function 30 | // 4. Dear imgui free function 31 | // 5. Dear imgui memory user data 32 | // 6. ImPlot context pointer(if enabled) 33 | TFunction attach = [](void*) -> void {}; 34 | TFunction detach = []() -> void {}; 35 | }; 36 | 37 | class UIMGUI_PUBLIC_API Plugins 38 | { 39 | public: 40 | Plugins() noexcept = default; 41 | 42 | /** 43 | * @brief Loads a plugin from a location string 44 | * @param location - the file location for the plugin shared library 45 | * @note Event safety - post-startup 46 | * @return A boolean that is true on success and false on error 47 | */ 48 | static bool load(String location) noexcept; 49 | 50 | /** 51 | * @note Event safety - post-startup 52 | * @return A constant reference to an array of strings that represent the list of user-defined plugins, fetched 53 | * using the standard plugins interface 54 | */ 55 | static const TVector& getPlugins() noexcept; 56 | 57 | /** 58 | * @brief A helper function that automatically loads all plugins that are added by the user through the standard 59 | * plugins interface 60 | * @note Event safety - post-startup 61 | */ 62 | static void loadStandard() noexcept; 63 | 64 | ~Plugins() noexcept; 65 | private: 66 | friend class ModulesManager; 67 | static Plugins& get() noexcept; 68 | 69 | TVector plugins{}; 70 | TVector standardPlugins{}; 71 | }; 72 | } -------------------------------------------------------------------------------- /Framework/Core/Interfaces/RendererInterface.cpp: -------------------------------------------------------------------------------- 1 | #include "RendererInterface.hpp" 2 | #include 3 | 4 | UImGui::RendererData& UImGui::Renderer::data() noexcept 5 | { 6 | return get().data; 7 | } 8 | 9 | void UImGui::Renderer::saveSettings() noexcept 10 | { 11 | get().saveConfig(); 12 | } 13 | 14 | UImGui::RendererInternal& UImGui::Renderer::get() noexcept 15 | { 16 | return *Global::get().renderer; 17 | } 18 | 19 | const UImGui::FString& UImGui::Renderer::getVendorString() noexcept 20 | { 21 | return get().metadata.vendorString; 22 | } 23 | 24 | const UImGui::FString& UImGui::Renderer::getAPIVersion() noexcept 25 | { 26 | return get().metadata.apiVersion; 27 | } 28 | 29 | const UImGui::FString& UImGui::Renderer::getGPUName() noexcept 30 | { 31 | return get().metadata.gpuName; 32 | } 33 | 34 | const UImGui::FString& UImGui::Renderer::getDriverVersion() noexcept 35 | { 36 | return get().metadata.driverVersion; 37 | } 38 | 39 | void UImGui::Renderer::forceUpdate() noexcept 40 | { 41 | get().bIdling = false; 42 | } 43 | -------------------------------------------------------------------------------- /Framework/Core/Interfaces/RendererInterface.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Renderer.hpp" 4 | 5 | namespace UImGui 6 | { 7 | class UIMGUI_PUBLIC_API Renderer 8 | { 9 | public: 10 | Renderer() = delete; 11 | Renderer(const Renderer&) = delete; 12 | void operator=(Renderer const&) = delete; 13 | 14 | // Event Safety - Any time 15 | static RendererData& data() noexcept; 16 | // Event Safety - Any time 17 | static void saveSettings() noexcept; 18 | 19 | // Event Safety - begin, post-begin 20 | static const FString& getVendorString() noexcept; 21 | // Event Safety - begin, post-begin 22 | static const FString& getAPIVersion() noexcept; 23 | // Event Safety - begin, post-begin 24 | static const FString& getGPUName() noexcept; 25 | // Event Safety - begin, post-begin 26 | static const FString& getDriverVersion() noexcept; 27 | 28 | // Forces an update even when idling in power saving mode 29 | // Event Safety - begin, post-begin 30 | static void forceUpdate() noexcept; 31 | private: 32 | friend class RendererInternal; 33 | friend class RendererUtils; 34 | friend class WindowInternal; 35 | friend class Texture; 36 | 37 | static RendererInternal& get() noexcept; 38 | }; 39 | } -------------------------------------------------------------------------------- /Framework/Core/Platform/WASM.cpp: -------------------------------------------------------------------------------- 1 | #include "WASM.hpp" 2 | 3 | #ifdef __EMSCRIPTEN__ 4 | EM_JS(bool, em_is_on_macOS, (), { 5 | let platform = navigator.platform.toLowerCase(); 6 | return platform.indexOf("mac") === 0 7 | || platform.indexOf("ipad") === 0 8 | || platform.indexOf("ipod") === 0 9 | || platform.indexOf("iphone") === 0; 10 | }); 11 | 12 | EM_JS(bool, em_supports_wgpu, (), { 13 | return navigator.gpu !== undefined && navigator.gpu !== null && bWebGPUEnabled; 14 | }); 15 | #else 16 | bool em_is_on_macOS() 17 | { 18 | #ifdef __APPLE__ 19 | return true; 20 | #else 21 | return false; 22 | #endif 23 | } 24 | #endif -------------------------------------------------------------------------------- /Framework/Core/Platform/WASM.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef __EMSCRIPTEN__ 3 | #include 4 | #endif 5 | 6 | // We need to check whether macOS is used, in order to correctly swap Control & Command on when targeting WASM 7 | #if __cplusplus || __EMSCRIPTEN__ 8 | extern "C" 9 | { 10 | #endif 11 | bool em_is_on_macOS(); 12 | #ifdef __EMSCRIPTEN__ 13 | bool em_supports_wgpu(); 14 | #endif 15 | #if __cplusplus || __EMSCRIPTEN__ 16 | } 17 | #endif -------------------------------------------------------------------------------- /Framework/Core/Platform/framework_pre.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | var bWebGPUEnabled = false; 4 | 5 | async function configure_WebGPU() { 6 | if (navigator.gpu !== undefined && navigator.gpu !== null) 7 | { 8 | const adapter = await navigator.gpu.requestAdapter(); 9 | if (adapter !== undefined && adapter !== null) 10 | { 11 | const device = await adapter.requestDevice(); 12 | if (device !== undefined && device !== null) 13 | { 14 | bWebGPUEnabled = true; 15 | Module.preinitializedWebGPUDevice = device; 16 | } 17 | } 18 | } 19 | } 20 | configure_WebGPU(); -------------------------------------------------------------------------------- /Framework/Core/Utilities.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | struct ImGuiContext; 6 | typedef void* (*ImGuiMemAllocFunc)(size_t sz, void* user_data); 7 | typedef void (*ImGuiMemFreeFunc )(void* ptr, void* user_data); 8 | 9 | namespace UImGui 10 | { 11 | class Global; 12 | class InputAction; 13 | 14 | class UIMGUI_PUBLIC_API Utility 15 | { 16 | public: 17 | Utility() = delete; 18 | Utility(const Utility&) = delete; 19 | void operator=(Utility const&) = delete; 20 | ~Utility() = delete; 21 | 22 | // Event Safety - Any time 23 | static void sanitiseFilepath(FString& str) noexcept; 24 | 25 | // Event Safety - Any time 26 | static void keyToText(FString& text, const uint16_t& key, bool bLong) noexcept; 27 | // Event Safety - Any time 28 | static FString keyToText(const uint16_t& key, bool bLong) noexcept; 29 | 30 | // Event Safety - Any time 31 | static void keyToText(FString& text, const InputAction& action, bool bLong) noexcept; 32 | // Event Safety - Any time 33 | static FString keyToText(const InputAction& action, bool bLong) noexcept; 34 | 35 | // Event Safety - Any time 36 | static void removeConsole() noexcept; 37 | 38 | // Event Safety - Any time 39 | static FString toLower(String str) noexcept; 40 | // Event Safety - Any time 41 | static void toLower(FString& str) noexcept; 42 | 43 | // Event Safety - Any time 44 | static FString toUpper(String str) noexcept; 45 | // Event Safety - Any time 46 | static void toUpper(FString& str) noexcept; 47 | 48 | // Loads a framework context from the plugin's side 49 | static void loadContext(void* context) noexcept; 50 | 51 | // Event Safety - Any time 52 | // Sleep for X milliseconds 53 | static void sleep(uint64_t milliseconds) noexcept; 54 | private: 55 | friend class Global; 56 | static void interruptSignalHandler() noexcept; 57 | 58 | typedef TArray, Keys_UnknownKey + 1> KeyStringsArrType; 59 | static void initializeKeyStrings(KeyStringsArrType& keyStrings) noexcept; 60 | }; 61 | } -------------------------------------------------------------------------------- /Framework/Framework.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | #ifdef __EMSCRIPTEN__ 31 | #include 32 | #include 33 | #include 34 | #include 35 | #else 36 | #include 37 | #endif 38 | #include 39 | #include -------------------------------------------------------------------------------- /Framework/Modules/Manager/ModulesManager.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | // This imports the C API, look here for the definition of the ModuleSettings struct 5 | #include 6 | 7 | #ifdef UIMGUI_I18N_MODULE_ENABLED 8 | #include 9 | #include 10 | #endif 11 | 12 | #ifdef UIMGUI_UNDO_MODULE_ENABLED 13 | #include "Modules/Undo/src/Undo.hpp" 14 | #endif 15 | 16 | #ifdef UIMGUI_PLOTTING_MODULE_ENABLED 17 | #include "Modules/Plotting/ThirdParty/implot/implot.h" 18 | #endif 19 | 20 | #ifdef UIMGUI_OS_MODULE_ENABLED 21 | #include "Modules/OS/src/OS.hpp" 22 | #endif 23 | 24 | #ifdef UIMGUI_KNOBS_MODULE_ENABLED 25 | #define AddBezierCurve AddBezierCubic 26 | #include "Modules/Knobs/ThirdParty/imgui-knobs/imgui-knobs.h" 27 | #endif 28 | 29 | #ifdef UIMGUI_SPINNERS_MODULE_ENABLED 30 | #ifndef UIMGUI_EXECUTABLE 31 | #define IMSPINNER_DEMO 32 | #include "Modules/Spinners/ThirdParty/imspinner/imspinner.h" 33 | #endif 34 | #endif 35 | 36 | #ifdef UIMGUI_TOGGLES_MODULE_ENABLED 37 | #include "Modules/Toggles/ThirdParty/imgui_toggle/imgui_toggle.h" 38 | #endif 39 | 40 | #ifdef UIMGUI_CLI_PARSER_MODULE_ENABLED 41 | #include "Modules/CLIParser/ThirdParty/UntitledCLIParser/CLIParser.hpp" 42 | #include "Modules/CLIParser/ThirdParty/UntitledCLIParser/C/cucli.h" 43 | #endif 44 | 45 | #ifdef UIMGUI_TEXT_UTILS_MODULE_ENABLED 46 | #include 47 | #endif 48 | 49 | #ifdef UIMGUI_THEME_MODULE_ENABLED 50 | #include 51 | #endif 52 | 53 | namespace UImGui 54 | { 55 | typedef UImGui_ModuleSettings ModuleSettings; 56 | 57 | class UIMGUI_PUBLIC_API ModulesManager 58 | { 59 | public: 60 | ModulesManager() = default; 61 | private: 62 | friend class Modules; 63 | friend class Global; 64 | friend class RendererInternal; 65 | friend class GUIRenderer; 66 | 67 | friend class Locale; 68 | friend class LocaleManager; 69 | friend class StateTracker; 70 | friend class I18N; 71 | 72 | ModuleSettings settings = 73 | { 74 | .maxTransactions = 100, 75 | .themeLocation = "", 76 | .os = false, 77 | .dbus = false, 78 | .uexec = false, 79 | .theming = false, 80 | .i18n = false, 81 | .undo_redo = false, 82 | .plotting = false, 83 | .knobs = false, 84 | .spinners = false, 85 | .toggles = false, 86 | .text_utils = false, 87 | .cli_parser = false, 88 | .xdg = false, 89 | .open = false, 90 | }; 91 | #ifdef UIMGUI_I18N_MODULE_ENABLED 92 | UI18N::TranslationEngine translationEngine{}; 93 | #endif 94 | 95 | #ifdef UIMGUI_UNDO_MODULE_ENABLED 96 | StateTracker stateTracker{}; 97 | #endif 98 | 99 | void init(const FString& configDir); 100 | void initModules(const FString& projectDir); 101 | 102 | // Runs directly after creating the dear imgui context 103 | void initialiseWithImGuiContext() const noexcept; 104 | // Runs after the dear imgui context is created, but after everything is set up to be used by the user 105 | void applyCustomisations() const noexcept; 106 | 107 | void destroy() const noexcept; 108 | 109 | void save(const FString& configDir) const noexcept; 110 | }; 111 | 112 | class UIMGUI_PUBLIC_API Modules 113 | { 114 | public: 115 | // Event Safety - Post-begin 116 | static ModuleSettings& data() noexcept; 117 | // Event Safety - Post-begin 118 | static void save() noexcept; 119 | // Event Safety - Post-begin 120 | static ModulesManager& get() noexcept; 121 | private: 122 | friend class StateTracker; 123 | friend class Locale; 124 | }; 125 | } 126 | -------------------------------------------------------------------------------- /Framework/Modules/Modules.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Manager/ModulesManager.hpp" -------------------------------------------------------------------------------- /Framework/Modules/OS/src/OS.cpp: -------------------------------------------------------------------------------- 1 | #include "OS.hpp" 2 | -------------------------------------------------------------------------------- /Framework/Modules/OS/src/OS.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef UIMGUI_OS_MODULE_ENABLED 3 | #ifdef UIMGUI_UEXEC_SUBMODULE_ENABLED 4 | #include "../ThirdParty/uexec/uexec.hpp" 5 | #include "../ThirdParty/uexec/C/cuexec.h" 6 | #endif 7 | 8 | #ifdef UIMGUI_XDG_BASEDIR_SUBMODULE_ENABLED 9 | #ifndef _WIN32 10 | #include "../ThirdParty/UntitledXDGBasedir/UXDGBaseDir.hpp" 11 | #include "../ThirdParty/UntitledXDGBasedir/CUXDGBaseDir.h" 12 | #endif 13 | #endif 14 | 15 | #ifdef UIMGUI_DBUS_SUBMODULE_ENABLED 16 | #include 17 | #endif 18 | 19 | #ifdef UIMGUI_OPEN_SUBMODULE_ENABLED 20 | #include "UntitledOpen/C/CUntitledOpen.h" 21 | #include "UntitledOpen/UntitledOpen.hpp" 22 | #endif 23 | #endif 24 | -------------------------------------------------------------------------------- /Framework/Modules/Undo/src/Undo.cpp: -------------------------------------------------------------------------------- 1 | #ifdef UIMGUI_UNDO_MODULE_ENABLED 2 | #include "Undo.hpp" 3 | #include 4 | 5 | void eraseWhenOverBufferSize(UImGui::TDeque& container, const UImGui::TDeque& transactions, const size_t i) noexcept 6 | { 7 | for (size_t j = 0; j < container.size(); j++) 8 | if (&transactions[i] == container[j]) 9 | container.erase(container.begin(), container.begin() + static_cast::difference_type>(j)); 10 | } 11 | 12 | void UImGui::StateTracker::init() noexcept 13 | { 14 | transactionSize = Modules::data().maxTransactions; 15 | } 16 | 17 | void UImGui::StateTracker::push(const Transaction& transaction, const bool bRedoIsInit) noexcept 18 | { 19 | Modules::get().stateTracker.pushAction(transaction, bRedoIsInit); 20 | } 21 | 22 | void UImGui::StateTracker::undo() noexcept 23 | { 24 | Modules::get().stateTracker.uundo(); 25 | } 26 | 27 | void UImGui::StateTracker::redo() noexcept 28 | { 29 | Modules::get().stateTracker.rredo(); 30 | } 31 | 32 | void UImGui::StateTracker::pushAction(const Transaction& transaction, const bool bRedoIsInit) 33 | { 34 | if (transactions.size() == transactionSize) 35 | { 36 | // Destroying half of the buffer saves memory and performance for future transactions 37 | const size_t size = transactionSize / 2; 38 | 39 | for (size_t i = 0; i < size; i++) 40 | { 41 | eraseWhenOverBufferSize(undoStack, transactions, i); 42 | eraseWhenOverBufferSize(redoStack, transactions, i); 43 | } 44 | transactions.erase(transactions.begin(), transactions.begin() + static_cast(size)); 45 | } 46 | transactions.push_back(transaction); 47 | undoStack.push_back(&transactions.back()); 48 | if (bRedoIsInit) 49 | transactions.back().redofunc(transactions.back().payload); 50 | } 51 | 52 | void UImGui::StateTracker::uundo() noexcept 53 | { 54 | if (!undoStack.empty()) 55 | { 56 | redoStack.emplace_back(undoStack.back()); 57 | undoStack.back()->undofunc(redoStack.back()->payload); 58 | 59 | undoStack.pop_back(); 60 | } 61 | } 62 | 63 | void UImGui::StateTracker::rredo() noexcept 64 | { 65 | if (!redoStack.empty()) 66 | { 67 | undoStack.emplace_back(redoStack.back()); 68 | redoStack.back()->redofunc(redoStack.back()->payload); 69 | 70 | redoStack.pop_back(); 71 | } 72 | } 73 | #endif -------------------------------------------------------------------------------- /Framework/Modules/Undo/src/Undo.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef UIMGUI_UNDO_MODULE_ENABLED 3 | #include 4 | #include 5 | #include 6 | 7 | namespace UImGui 8 | { 9 | typedef UImGui_TransactionPayload TransactionPayload; 10 | 11 | struct UIMGUI_PUBLIC_API Transaction 12 | { 13 | TFunction undofunc{}; 14 | TFunction redofunc{}; 15 | TransactionPayload payload{}; 16 | }; 17 | 18 | class UIMGUI_PUBLIC_API StateTracker 19 | { 20 | public: 21 | StateTracker() = default; 22 | StateTracker(const StateTracker&) = delete; 23 | void operator=(StateTracker const&) = delete; 24 | 25 | // UntitledImGuiFramework Event Safety - Post-begin 26 | static void push(const Transaction& transaction, bool bRedoIsInit = false) noexcept; 27 | 28 | // UntitledImGuiFramework Event Safety - Post-begin 29 | static void undo() noexcept; 30 | // UntitledImGuiFramework Event Safety - Post-begin 31 | static void redo() noexcept; 32 | private: 33 | friend class ModulesManager; 34 | 35 | void init() noexcept; 36 | void pushAction(const Transaction& transaction, bool bRedoIsInit); 37 | 38 | void uundo() noexcept; 39 | void rredo() noexcept; 40 | 41 | size_t transactionSize = 100; 42 | 43 | TDeque undoStack; 44 | TDeque redoStack; 45 | TDeque transactions; 46 | }; 47 | } 48 | #endif -------------------------------------------------------------------------------- /Framework/Modules/i18n/src/CI18NModule.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef UIMGUI_I18N_MODULE_ENABLED 3 | #include 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" 8 | { 9 | #endif 10 | // Event Safety - Any time 11 | UIMGUI_PUBLIC_API const char* UImGui_I18N_get(const char* id, char** pargv, size_t pargc, UI18N_Pair* argv, size_t argc); 12 | // Event Safety - Any time 13 | UIMGUI_PUBLIC_API void UImGui_I18N_pushVariable(const char* name, const char* val); 14 | // Event Safety - Any time 15 | UIMGUI_PUBLIC_API void UImGui_I18N_setCurrentLocale(UI18N_LanguageCodes locale); 16 | // Event Safety - Any time 17 | UIMGUI_PUBLIC_API const UI18N_LanguageCodes* UImGui_I18N_getExistingLocales(size_t* size); 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | #endif -------------------------------------------------------------------------------- /Framework/Modules/i18n/src/I18NModule.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #ifdef UIMGUI_I18N_MODULE_ENABLED 3 | #include "I18NModule.hpp" 4 | #include 5 | 6 | void UImGui::I18N::setCurrentLocale(const UI18N::LanguageCodes locale) noexcept 7 | { 8 | getEngine().setCurrentLocale(locale); 9 | } 10 | 11 | ui18nstring UImGui::I18N::get(const char* id, const std::vector& positionalArgs, const ui18nmap& args) noexcept 12 | { 13 | return getEngine().get(id, positionalArgs, args); 14 | } 15 | 16 | void UImGui::I18N::pushVariable(const ui18nstring& name, const ui18nstring& val) noexcept 17 | { 18 | getEngine().pushVariable(name, val); 19 | } 20 | 21 | const std::vector& UImGui::I18N::getExistingLocales() noexcept 22 | { 23 | return getEngine().getExistingLocales(); 24 | } 25 | 26 | UI18N::TranslationEngine& UImGui::I18N::getEngine() noexcept 27 | { 28 | return Modules::get().translationEngine; 29 | } 30 | 31 | const UI18N_LanguageCodes* UImGui_I18N_getExistingLocales(size_t* size) 32 | { 33 | return UI18N_TranslationEngine_getExistingLocales(&UImGui::I18N::getEngine(), size); 34 | } 35 | 36 | void UImGui_I18N_setCurrentLocale(const UI18N_LanguageCodes locale) 37 | { 38 | UImGui::I18N::setCurrentLocale(locale); 39 | } 40 | 41 | void UImGui_I18N_pushVariable(const char* name, const char* val) 42 | { 43 | UImGui::I18N::pushVariable(name, val); 44 | } 45 | 46 | const char* UImGui_I18N_get(const char* id, char** pargv, const size_t pargc, UI18N_Pair* argv, const size_t argc) 47 | { 48 | return UI18N_TranslationEngine_get(&UImGui::I18N::getEngine(), id, pargv, pargc, argv, argc); 49 | } 50 | #endif -------------------------------------------------------------------------------- /Framework/Modules/i18n/src/I18NModule.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef UIMGUI_I18N_MODULE_ENABLED 3 | #include 4 | #include 5 | 6 | namespace UImGui 7 | { 8 | class UIMGUI_PUBLIC_API I18N 9 | { 10 | public: 11 | I18N() = delete; 12 | I18N(const I18N&) = delete; 13 | void operator=(I18N const&) = delete; 14 | 15 | // Event Safety - Any time 16 | static void setCurrentLocale(UI18N::LanguageCodes locale) noexcept; 17 | 18 | // Event Safety - Any time 19 | static ui18nstring get(const char* id, const std::vector& positionalArgs = {}, const ui18nmap& args = {}) noexcept; 20 | // Event Safety - Any time 21 | static void pushVariable(const ui18nstring& name, const ui18nstring& val) noexcept; 22 | 23 | // Event Safety - Any time 24 | static const std::vector& getExistingLocales() noexcept; 25 | 26 | // Event Safety - Any time 27 | static UI18N::TranslationEngine& getEngine() noexcept; 28 | }; 29 | } 30 | #endif -------------------------------------------------------------------------------- /Framework/Renderer/GenericRenderer/GenericRenderer.cpp: -------------------------------------------------------------------------------- 1 | #include "GenericRenderer.hpp" 2 | -------------------------------------------------------------------------------- /Framework/Renderer/GenericRenderer/GenericRenderer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace UImGui 5 | { 6 | class RendererInternal; 7 | struct RendererInternalMetadata; 8 | 9 | class UIMGUI_PUBLIC_API GenericRenderer 10 | { 11 | public: 12 | GenericRenderer() noexcept = default; 13 | 14 | virtual void parseCustomConfig(YAML::Node& config) noexcept = 0; 15 | 16 | virtual void setupWindowIntegration() noexcept = 0; 17 | virtual void setupPostWindowCreation() noexcept = 0; 18 | 19 | virtual void init(RendererInternalMetadata& metadata) noexcept = 0; 20 | virtual void renderStart(double deltaTime) noexcept = 0; 21 | virtual void renderEnd(double deltaTime) noexcept = 0; 22 | virtual void destroy() noexcept = 0; 23 | 24 | virtual void ImGuiNewFrame() noexcept = 0; 25 | virtual void ImGuiShutdown() noexcept = 0; 26 | virtual void ImGuiInit() noexcept = 0; 27 | virtual void ImGuiRenderData() noexcept = 0; 28 | 29 | // Only called on Vulkan, because there we need to wait for resources to be used before freeing resources, 30 | // like textures 31 | virtual void waitOnGPU() noexcept = 0; 32 | 33 | virtual ~GenericRenderer() noexcept = default; 34 | }; 35 | } -------------------------------------------------------------------------------- /Framework/Renderer/GenericRenderer/GenericTexture.cpp: -------------------------------------------------------------------------------- 1 | #define STB_IMAGE_WRITE_IMPLEMENTATION 2 | #include "GenericTexture.hpp" 3 | #include 4 | #include 5 | #include 6 | 7 | void UImGui::GenericTexture::beginLoad(TextureData& dt, void** data, FVector2& size) noexcept 8 | { 9 | if (*data == nullptr || (size.x == 0 && size.y == 0)) 10 | { 11 | int x = static_cast(size.x); 12 | int y = static_cast(size.y); 13 | 14 | *data = stbi_load(dt.filename, &x, &y, &dt.channels, 4); 15 | if (*data == nullptr) 16 | { 17 | Logger::log("Failed to load a texture with the following location: ", ULOG_LOG_TYPE_ERROR, dt.filename); 18 | return; 19 | } 20 | size.x = static_cast(x); 21 | size.y = static_cast(y); 22 | dt.size = size; 23 | } 24 | } 25 | 26 | void UImGui::GenericTexture::endLoad(TextureData& dt, void* data, const bool bFreeImageData, const TFunction& freeFunc) noexcept 27 | { 28 | if (bFreeImageData) 29 | freeFunc(data); 30 | else 31 | dt.data = data; 32 | } 33 | 34 | void UImGui::GenericTexture::defaultInit(TextureData& dt, const String location, const bool bFiltered) noexcept 35 | { 36 | auto& strings = Global::get().deallocationStruct.keyStrings; 37 | 38 | strings.emplace_back(location); 39 | dt.filename = strings.back().c_str(); 40 | dt.storageIndex = strings.size() - 1; 41 | 42 | dt.size = { 0.0f, 0.0f }; 43 | dt.channels = 0; 44 | dt.bFiltered = bFiltered; 45 | 46 | dt.data = nullptr; 47 | dt.customSaveFunction = [](TextureData*, String) -> bool { return false; }; 48 | dt.id = 0; 49 | } 50 | 51 | void UImGui::GenericTexture::defaultClear(TextureData& dt) noexcept 52 | { 53 | dt.size = { 0.0f, 0.0f }; 54 | 55 | auto& strings = Global::get().deallocationStruct.keyStrings; 56 | if (!strings.empty() && dt.storageIndex < strings.size()) 57 | strings.erase(strings.begin() + static_cast(dt.storageIndex)); 58 | } 59 | -------------------------------------------------------------------------------- /Framework/Renderer/ImGui/ClientSideBar.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | struct ImGuiStyle; 6 | 7 | namespace UImGui 8 | { 9 | typedef UImGui_ClientSideBarFlags ClientSideBarFlags; 10 | 11 | class UIMGUI_PUBLIC_API ClientSideBar 12 | { 13 | public: 14 | ClientSideBar() = delete; 15 | ClientSideBar(const ClientSideBar&) = delete; 16 | void operator=(ClientSideBar const&) = delete; 17 | 18 | // Initialises the client-side bar 19 | // Event Safety - Post-begin 20 | static void Begin() noexcept; 21 | 22 | // Renders the bar 23 | // Event Safety - Post-begin 24 | static void End(ClientSideBarFlags flags = UIMGUI_CLIENT_SIDE_BAR_FLAG_ALL, FVector4 destructiveColour = { 1.0, 0.482, 0.388f, 1.0f }, FVector4 destructiveColourActive = { 0.753f, 0.110f, 0.157f, 1.0f }) noexcept; 25 | private: 26 | static void renderMinimiseButton(float& width, const ImGuiStyle& style) noexcept; 27 | static void renderMaximiseButton(float& width, const ImGuiStyle& style) noexcept; 28 | static void renderCloseButton(float& width, const ImGuiStyle& style, FVector4 destructiveColour, FVector4 destructiveColourActive) noexcept; 29 | }; 30 | } -------------------------------------------------------------------------------- /Framework/Renderer/ImGui/ImGui.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | struct ImVec4; 5 | struct GLFWwindow; 6 | 7 | namespace UImGui 8 | { 9 | class Window; 10 | class UIMGUI_PUBLIC_API GUIRenderer 11 | { 12 | public: 13 | GUIRenderer() = default; 14 | 15 | private: 16 | friend class RendererUtils; 17 | friend class RendererInternal; 18 | 19 | static void init(GenericRenderer* renderer) noexcept; 20 | static void beginUI(float deltaTime, GenericRenderer* renderer) noexcept; 21 | static void beginFrame() noexcept; 22 | static void shutdown(GenericRenderer* renderer) noexcept; 23 | }; 24 | } -------------------------------------------------------------------------------- /Framework/Renderer/ImGui/UImGuiExtensions.cpp: -------------------------------------------------------------------------------- 1 | #include "UImGuiExtensions.hpp" 2 | 3 | struct InputTextCallbackUserData 4 | { 5 | UImGui::FString* str = nullptr; 6 | ImGuiInputTextCallback chainCallback{}; 7 | void* chainCallbackContext = nullptr; 8 | }; 9 | 10 | static int InputTextCallback(ImGuiInputTextCallbackData* data) 11 | { 12 | const auto* user_data = static_cast(data->UserData); 13 | if (data->EventFlag == ImGuiInputTextFlags_CallbackResize) 14 | { 15 | // Resize string callback 16 | // If for some reason we refuse the new length (BufTextLen) and/or capacity (BufSize) we need to set them back to what we want. 17 | auto* str = user_data->str; 18 | IM_ASSERT(data->Buf == str->c_str()); 19 | str->resize(data->BufTextLen); 20 | data->Buf = str->data(); 21 | } 22 | else if (user_data->chainCallback) 23 | { 24 | // Forward to user callback, if any 25 | data->UserData = user_data->chainCallbackContext; 26 | return user_data->chainCallback(data); 27 | } 28 | return 0; 29 | } 30 | 31 | bool ImGui::InputText(const char* label, UImGui::FString* str, ImGuiInputTextFlags flags, const ImGuiInputTextCallback callback, void* user_data) 32 | { 33 | IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); 34 | flags |= ImGuiInputTextFlags_CallbackResize; 35 | 36 | InputTextCallbackUserData cb_user_data = 37 | { 38 | .str = str, 39 | .chainCallback = callback, 40 | .chainCallbackContext = user_data, 41 | }; 42 | return InputText(label, str->data(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data); 43 | } 44 | 45 | bool ImGui::InputTextMultiline(const char* label, UImGui::FString* str, const ImVec2& size, ImGuiInputTextFlags flags, const ImGuiInputTextCallback callback, void* user_data) 46 | { 47 | IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); 48 | flags |= ImGuiInputTextFlags_CallbackResize; 49 | 50 | InputTextCallbackUserData cb_user_data = 51 | { 52 | .str = str, 53 | .chainCallback = callback, 54 | .chainCallbackContext = user_data, 55 | }; 56 | return InputTextMultiline(label, str->data(), str->capacity() + 1, size, flags, InputTextCallback, &cb_user_data); 57 | } 58 | 59 | bool ImGui::InputTextWithHint(const char* label, const char* hint, UImGui::FString* str, ImGuiInputTextFlags flags, const ImGuiInputTextCallback callback, void* user_data) 60 | { 61 | IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); 62 | flags |= ImGuiInputTextFlags_CallbackResize; 63 | 64 | InputTextCallbackUserData cb_user_data = 65 | { 66 | .str = str, 67 | .chainCallback = callback, 68 | .chainCallbackContext = user_data, 69 | }; 70 | return InputTextWithHint(label, hint, str->data(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data); 71 | } -------------------------------------------------------------------------------- /Framework/Renderer/ImGui/UImGuiExtensions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | // Custom InputText that uses FString 6 | namespace ImGui 7 | { 8 | UIMGUI_PUBLIC_API bool InputText(const char* label, UImGui::FString* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr); 9 | UIMGUI_PUBLIC_API bool InputTextMultiline(const char* label, UImGui::FString* str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr); 10 | UIMGUI_PUBLIC_API bool InputTextWithHint(const char* label, const char* hint, UImGui::FString* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr); 11 | } -------------------------------------------------------------------------------- /Framework/Renderer/OpenGL/OpenGLRenderer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "GenericRenderer/GenericRenderer.hpp" 3 | 4 | namespace UImGui 5 | { 6 | class UIMGUI_PUBLIC_API OpenGLRenderer final : public GenericRenderer 7 | { 8 | public: 9 | OpenGLRenderer() noexcept = default; 10 | 11 | virtual void parseCustomConfig(YAML::Node&) noexcept override; 12 | 13 | virtual void setupWindowIntegration() noexcept override; 14 | virtual void setupPostWindowCreation() noexcept override; 15 | 16 | virtual void init(RendererInternalMetadata& metadata) noexcept override; 17 | virtual void renderStart(double deltaTime) noexcept override; 18 | virtual void renderEnd(double deltaTime) noexcept override; 19 | virtual void destroy() noexcept override; 20 | 21 | virtual void ImGuiNewFrame() noexcept override; 22 | virtual void ImGuiShutdown() noexcept override; 23 | virtual void ImGuiInit() noexcept override; 24 | virtual void ImGuiRenderData() noexcept override; 25 | 26 | virtual void waitOnGPU() noexcept override; 27 | 28 | virtual ~OpenGLRenderer() noexcept override = default; 29 | private: 30 | 31 | }; 32 | } -------------------------------------------------------------------------------- /Framework/Renderer/OpenGL/OpenGLTexture.cpp: -------------------------------------------------------------------------------- 1 | #include "OpenGLTexture.hpp" 2 | #ifndef __APPLE__ 3 | #include 4 | #elif __EMSCRIPTEN__ 5 | #include 6 | #else 7 | #include 8 | #endif 9 | #include 10 | 11 | void UImGui::OpenGLTexture::init(TextureData& dt, const String location, const bool bFiltered) noexcept 12 | { 13 | defaultInit(dt, location, bFiltered); 14 | } 15 | 16 | uintptr_t UImGui::OpenGLTexture::get(TextureData& dt) noexcept 17 | { 18 | return dt.id; 19 | } 20 | 21 | void UImGui::OpenGLTexture::clear(TextureData& dt) noexcept 22 | { 23 | const GLuint tmp = dt.id; 24 | if (Renderer::data().textureRendererType == UIMGUI_RENDERER_TYPE_OPENGL) 25 | glDeleteTextures(1, &tmp); 26 | dt.id = 0; 27 | defaultClear(dt); 28 | } 29 | 30 | void UImGui::OpenGLTexture::load(TextureData& dt, void* data, FVector2 size, const uint32_t depth, const bool bFreeImageData, const TFunction& freeFunc) noexcept 31 | { 32 | beginLoad(dt, &data, size); 33 | 34 | GLuint tmp = 0; 35 | 36 | glGenTextures(1, &tmp); 37 | glBindTexture(GL_TEXTURE_2D, tmp); 38 | 39 | dt.id = tmp; 40 | 41 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, dt.bFiltered ? GL_LINEAR : GL_NEAREST); 42 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, dt.bFiltered ? GL_LINEAR : GL_NEAREST); 43 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 44 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 45 | 46 | #if defined(GL_UNPACK_ROW_LENGTH) && !defined(__EMSCRIPTEN__) 47 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); 48 | #endif 49 | uint32_t dataType = GL_UNSIGNED_BYTE; 50 | if (depth > 8) 51 | dataType = GL_UNSIGNED_SHORT; 52 | 53 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, static_cast(size.x), static_cast(size.y), 0, GL_RGBA, dataType, data); 54 | 55 | endLoad(dt, data, bFreeImageData, freeFunc); 56 | } 57 | -------------------------------------------------------------------------------- /Framework/Renderer/OpenGL/OpenGLTexture.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace UImGui 5 | { 6 | class UIMGUI_PUBLIC_API OpenGLTexture final : public GenericTexture 7 | { 8 | public: 9 | OpenGLTexture() noexcept = default; 10 | 11 | // Event Safety - Any time 12 | virtual void init(TextureData& dt, String location, bool bFiltered) noexcept override; 13 | 14 | virtual void load(TextureData& dt, void* data, FVector2 size, uint32_t depth, bool bFreeImageData, 15 | const TFunction& freeFunc) noexcept override; 16 | 17 | // Event Safety - Post-begin 18 | virtual uintptr_t get(TextureData& dt) noexcept override; 19 | 20 | // Cleans up the image data 21 | // Event Safety - All initiated 22 | virtual void clear(TextureData& dt) noexcept override; 23 | virtual ~OpenGLTexture() noexcept override = default; 24 | }; 25 | } -------------------------------------------------------------------------------- /Framework/Renderer/Renderer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | // C API, contains the renderer data header, since it is shared between the 2 APIs 5 | #include 6 | 7 | // Renderers 8 | #include 9 | #include 10 | #include 11 | 12 | namespace UImGui 13 | { 14 | typedef UImGui_RendererData RendererData; 15 | typedef UImGui_RendererType RendererType; 16 | 17 | struct UIMGUI_PUBLIC_API RendererInternalMetadata 18 | { 19 | FString vendorString; 20 | FString apiVersion; 21 | FString driverVersion; 22 | FString gpuName; 23 | }; 24 | 25 | class UIMGUI_PUBLIC_API RendererInternal 26 | { 27 | public: 28 | RendererInternal() = default; 29 | 30 | void start(); 31 | void stop() const noexcept; 32 | 33 | RendererInternalMetadata metadata; 34 | private: 35 | friend class Renderer; 36 | friend class RendererUtils; 37 | 38 | static void tick(void* rendererInstance) noexcept; 39 | 40 | void loadConfig() noexcept; 41 | void saveConfig() const noexcept; 42 | 43 | OpenGLRenderer opengl{}; 44 | #ifdef __EMSCRIPTEN__ 45 | WebGPURenderer wgpu{}; 46 | #else 47 | VulkanRenderer vulkan{}; 48 | #endif 49 | GenericRenderer* custom = nullptr; 50 | 51 | GenericRenderer* renderers[UIMGUI_RENDERER_TYPE_COUNT] = 52 | { 53 | &opengl, 54 | #ifdef __EMSCRIPTEN__ 55 | &wgpu, 56 | #else 57 | &vulkan, 58 | #endif 59 | custom 60 | }; 61 | 62 | GenericRenderer* renderer = nullptr; 63 | RendererData data = 64 | { 65 | .rendererType = UIMGUI_RENDERER_TYPE_OPENGL, 66 | .textureRendererType = UIMGUI_RENDERER_TYPE_OPENGL, 67 | .bUsingVSync = true, 68 | .msaaSamples = 1, 69 | .bEnablePowerSavingMode = false, 70 | .idleFrameRate = 9.0f 71 | }; 72 | 73 | YAML::Node customConfig; 74 | 75 | double lastTime = 0.0f; 76 | bool bIdling = false; 77 | }; 78 | 79 | } -------------------------------------------------------------------------------- /Framework/Renderer/RendererUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "RendererUtils.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | UImGui::GenericRenderer* UImGui::RendererUtils::getRenderer() noexcept 10 | { 11 | return Renderer::get().renderer; 12 | } 13 | 14 | void UImGui::RendererUtils::setupManually() noexcept 15 | { 16 | glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); 17 | } 18 | 19 | void UImGui::RendererUtils::OpenGL::setHints(const int majorVersion, const int minorVersion, const RendererClientAPI clientApi, const Profile profile, const bool bForwardCompatible) noexcept 20 | { 21 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, majorVersion); 22 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minorVersion); 23 | glfwWindowHint(GLFW_CLIENT_API, CAST(int, clientApi)); 24 | glfwWindowHint(GLFW_OPENGL_PROFILE, CAST(int, profile)); 25 | glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, CAST(int, bForwardCompatible)); 26 | } 27 | 28 | void UImGui::RendererUtils::OpenGL::swapFramebuffer() noexcept 29 | { 30 | glfwSwapBuffers(Window::getInternal()); 31 | } 32 | 33 | bool UImGui::RendererUtils::WebGPU::supported() noexcept 34 | { 35 | #ifdef __EMSCRIPTEN__ 36 | return em_supports_wgpu(); 37 | #else 38 | return false; 39 | #endif 40 | } 41 | 42 | void UImGui::RendererUtils::beginImGuiFrame() noexcept 43 | { 44 | GUIRenderer::beginFrame(); 45 | } -------------------------------------------------------------------------------- /Framework/Renderer/RendererUtils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace UImGui 5 | { 6 | typedef UImGui_RendererClientAPI RendererClientAPI; 7 | class GenericRenderer; 8 | 9 | class UIMGUI_PUBLIC_API RendererUtils 10 | { 11 | public: 12 | RendererUtils() = delete; 13 | RendererUtils(const RendererUtils&) = delete; 14 | void operator=(RendererUtils const&) = delete; 15 | 16 | // Call this inside the window hints interface function of the GenericRenderer class 17 | // Event safety - startup, post-startup 18 | static void setupManually() noexcept; 19 | 20 | // Returns a pointer to the current renderer 21 | // Event safety - any-time 22 | static GenericRenderer* getRenderer() noexcept; 23 | 24 | // Renderer a new dear imgui frame 25 | // Event safety - post-begin 26 | static void beginImGuiFrame() noexcept; 27 | 28 | class UIMGUI_PUBLIC_API OpenGL 29 | { 30 | public: 31 | OpenGL() = delete; 32 | OpenGL(const OpenGL&) = delete; 33 | void operator=(OpenGL const&) = delete; 34 | 35 | typedef UImGui_OpenGLProfile Profile; 36 | 37 | // Call this inside the window hints interface function of the GenericRenderer class 38 | // 39 | // Recommended args: 40 | // Emscripten/Web targets - UIMGUI_LATEST_OPENGL_VERSION, UIMGUI_RENDERER_CLIENT_API_OPENGL_ES, UIMGUI_OPENGL_PROFILE_ANY, false 41 | // Desktop - UIMGUI_LATEST_OPENGL_VERSION, UIMGUI_RENDERER_CLIENT_API_OPENGL, UIMGUI_OPENGL_PROFILE_CORE, true 42 | // 43 | // Event safety - startup, post-startup 44 | static void setHints(int majorVersion, int minorVersion, RendererClientAPI clientApi, Profile profile, bool bForwardCompatible) noexcept; 45 | 46 | // Swaps buffers for OpenGL. 47 | // Event safety - post-begin 48 | static void swapFramebuffer() noexcept; 49 | }; 50 | 51 | class UIMGUI_PUBLIC_API WebGPU 52 | { 53 | public: 54 | WebGPU() = delete; 55 | WebGPU(const WebGPU&) = delete; 56 | void operator=(WebGPU const&) = delete; 57 | 58 | // Check for WebGPU support 59 | // Event safety - any time 60 | static bool supported() noexcept; 61 | }; 62 | private: 63 | }; 64 | } 65 | -------------------------------------------------------------------------------- /Framework/Renderer/Texture.cpp: -------------------------------------------------------------------------------- 1 | #include "Texture.hpp" 2 | #include 3 | 4 | UImGui::Texture::Texture(const String location, const bool bFiltered) noexcept 5 | { 6 | init(location, bFiltered); 7 | } 8 | 9 | bool UImGui::Texture::init(const String location, const bool bFiltered) noexcept 10 | { 11 | if (Renderer::data().textureRendererType == UIMGUI_RENDERER_TYPE_CUSTOM) 12 | { 13 | auto& initInfo = Instance::get()->initInfo; 14 | if (initInfo.customTexture != nullptr) 15 | textures[UIMGUI_RENDERER_TYPE_CUSTOM] = initInfo.customTexture; 16 | else if (initInfo.cInitInfo != nullptr && initInfo.cInitInfo->customTexture != nullptr) 17 | textures[UIMGUI_RENDERER_TYPE_CUSTOM] = static_cast(initInfo.cInitInfo->customTexture); 18 | else 19 | { 20 | Logger::log("Invalid custom renderer backend!", ULOG_LOG_TYPE_ERROR); 21 | return false; 22 | } 23 | } 24 | bCleared = false; 25 | textures[Renderer::data().textureRendererType]->init(dt, location, bFiltered); 26 | return true; 27 | } 28 | 29 | void UImGui::Texture::load(void* data, const FVector2 size, const uint32_t depth, const bool bFreeImageData, 30 | const TFunction& freeFunc) noexcept 31 | { 32 | TEX_RUN(load(dt, data, size, depth, bFreeImageData, freeFunc)); 33 | } 34 | 35 | uintptr_t UImGui::Texture::get() noexcept 36 | { 37 | TEX_RUN(get(dt)); 38 | } 39 | 40 | void UImGui::Texture::setCustomSaveFunction(const CustomSaveFunction f) noexcept 41 | { 42 | dt.customSaveFunction = f; 43 | } 44 | 45 | UImGui::FVector2 UImGui::Texture::size() const noexcept 46 | { 47 | return dt.size; 48 | } 49 | 50 | void UImGui::Texture::clear() noexcept 51 | { 52 | if (!bCleared) 53 | { 54 | bCleared = true; 55 | RendererUtils::getRenderer()->waitOnGPU(); 56 | TEX_RUN(clear(dt)); 57 | } 58 | } 59 | 60 | UImGui::Texture::~Texture() noexcept 61 | { 62 | clear(); 63 | } 64 | 65 | UImGui::TextureData& UImGui::Texture::getData() noexcept 66 | { 67 | return dt; 68 | } 69 | -------------------------------------------------------------------------------- /Framework/Renderer/Texture.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define TEX_RUN(x) return textures[static_cast(Renderer::data().textureRendererType)]->x; 9 | 10 | namespace UImGui 11 | { 12 | class UIMGUI_PUBLIC_API Texture 13 | { 14 | public: 15 | typedef UImGui_Texture_CustomSaveFunction CustomSaveFunction; 16 | 17 | Texture() noexcept = default; 18 | // Event Safety - Post-begin 19 | Texture(String location, bool bFiltered = true) noexcept; 20 | // Event Safety - Post-begin 21 | bool init(String location, bool bFiltered = true) noexcept; 22 | 23 | // Event Safety - Post-begin 24 | void load(void* data = nullptr, 25 | FVector2 size = { 0.0f, 0.0f }, 26 | uint32_t depth = 0, 27 | bool bFreeImageData = false, 28 | const TFunction& freeFunc = UImGui_Texture_defaultFreeFunc) noexcept; 29 | 30 | // Event Safety - Post-begin 31 | [[nodiscard]] uintptr_t get() noexcept; 32 | 33 | /** 34 | * @brief Outputs an image with a given format to a file. Only works if the image buffer is not freed 35 | * automatically when loading the image. 36 | * @tparam format - The format of an image 37 | * @param location - File location 38 | * @param fmt - Format of the image, defaults to the value of the template argument. If template argument is set 39 | * to UIMGUI_TEXTURE_FORMAT_OTHER, it will check this value. If it reaches OTHER again, the custom save function 40 | * is called 41 | * @param jpegQuality - Quality of the output of the JPEG image from 0(lowest) and 100(highest). Default 42 | * argument sets it to 100 43 | */ 44 | template 45 | bool saveToFile(const String location, const TextureFormat fmt = format, const uint8_t jpegQuality = 100) const noexcept 46 | { 47 | return GenericTexture::saveToFile(dt, location, fmt, jpegQuality); 48 | } 49 | 50 | // Set a function for saving custom image file formats 51 | // Event Safety - All initiated 52 | void setCustomSaveFunction(CustomSaveFunction f) noexcept; 53 | 54 | // Returns the size of the image 55 | // Event Safety - Any time 56 | [[nodiscard]] FVector2 size() const noexcept; 57 | 58 | // Event Safety - Any time 59 | TextureData& getData() noexcept; 60 | 61 | // Cleans up the image data 62 | // Event Safety - All initiated 63 | void clear() noexcept; 64 | ~Texture() noexcept; 65 | private: 66 | bool bCleared = false; 67 | 68 | OpenGLTexture opengl{}; 69 | #ifdef __EMSCRIPTEN__ 70 | WebGPUTexture webgpu{}; 71 | #else 72 | VulkanTexture vulkan{}; 73 | #endif 74 | GenericTexture* custom = nullptr; 75 | 76 | GenericTexture* textures[UIMGUI_RENDERER_TYPE_COUNT] = 77 | { 78 | &opengl, 79 | #ifdef __EMSCRIPTEN__ 80 | &webgpu, 81 | #else 82 | &vulkan, 83 | #endif 84 | custom 85 | }; 86 | TextureData dt{}; 87 | }; 88 | } 89 | -------------------------------------------------------------------------------- /Framework/Renderer/Vulkan/Components/VKDescriptors.cpp: -------------------------------------------------------------------------------- 1 | #include "VKDescriptors.hpp" 2 | #ifndef __EMSCRIPTEN__ 3 | #include "VKDevice.hpp" 4 | #include 5 | 6 | UImGui::VKDescriptorPools::VKDescriptorPools(VKDevice& dev) noexcept 7 | { 8 | device = &dev; 9 | } 10 | 11 | void UImGui::VKDescriptorPools::allocate() noexcept 12 | { 13 | constexpr vk::DescriptorPoolSize descriptorPoolSizes[] = 14 | { 15 | { 16 | .type = vk::DescriptorType::eCombinedImageSampler, 17 | .descriptorCount = 2000 18 | }, 19 | }; 20 | const vk::DescriptorPoolCreateInfo descriptorPoolCreateInfo = 21 | { 22 | .flags = vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet, 23 | .maxSets = 2000, 24 | .poolSizeCount = CARRAY_SIZE(descriptorPoolSizes), 25 | .pPoolSizes = descriptorPoolSizes, 26 | }; 27 | pool = device->get().createDescriptorPool(descriptorPoolCreateInfo, nullptr); 28 | Logger::log("Allocated Vulkan descriptor pools!", ULOG_LOG_TYPE_NOTE); 29 | } 30 | 31 | void UImGui::VKDescriptorPools::destroy() const noexcept 32 | { 33 | device->get().destroyDescriptorPool(pool, nullptr); 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /Framework/Renderer/Vulkan/Components/VKDescriptors.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef __EMSCRIPTEN__ 3 | #include "VKInstance.hpp" 4 | 5 | namespace UImGui 6 | { 7 | class VKDevice; 8 | class UIMGUI_PUBLIC_API VKDescriptorPools 9 | { 10 | public: 11 | VKDescriptorPools() noexcept = default; 12 | explicit VKDescriptorPools(VKDevice& dev) noexcept; 13 | 14 | void allocate() noexcept; 15 | void destroy() const noexcept; 16 | private: 17 | friend class VKDraw; 18 | 19 | VKDevice* device = nullptr; 20 | vk::DescriptorPool pool{}; 21 | }; 22 | } 23 | #endif -------------------------------------------------------------------------------- /Framework/Renderer/Vulkan/Components/VKDevice.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef __EMSCRIPTEN__ 3 | #include "VKInstance.hpp" 4 | #include "VKSurface.hpp" 5 | #include "VKDescriptors.hpp" 6 | #include "VKUtility.hpp" 7 | 8 | namespace UImGui 9 | { 10 | struct RendererInternalMetadata; 11 | 12 | class UIMGUI_PUBLIC_API VKDevice 13 | { 14 | public: 15 | VKDevice() = default; 16 | explicit VKDevice(VKInstance& inst) noexcept; 17 | 18 | void create(RendererInternalMetadata& metadata) noexcept; 19 | [[nodiscard]] const vk::Device& get() const noexcept; 20 | void destroy() const noexcept; 21 | 22 | ~VKDevice() = default; 23 | private: 24 | friend class VKDraw; 25 | friend class VulkanTexture; 26 | 27 | void createPhysicalDevice() noexcept; 28 | void setMSAASamples() const noexcept; 29 | 30 | VKInstance* instance = nullptr; 31 | 32 | VKSurface surface{}; 33 | VKDescriptorPools descriptorPools{ *this }; 34 | QueueFamilyIndices indices; 35 | 36 | vk::Queue queue{}; 37 | vk::Queue presentationQueue{}; 38 | 39 | vk::Device device{}; 40 | 41 | vk::PhysicalDevice physicalDevice{}; 42 | vk::PhysicalDeviceProperties deviceProperties{}; 43 | }; 44 | } 45 | #endif -------------------------------------------------------------------------------- /Framework/Renderer/Vulkan/Components/VKDraw.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef __EMSCRIPTEN__ 3 | #include "VKInstance.hpp" 4 | #include "VKDevice.hpp" 5 | #include 6 | 7 | namespace UImGui 8 | { 9 | // Struct that combines framebuffers, swapchains, render passes, etc. in one package 10 | class UIMGUI_PUBLIC_API VKDraw 11 | { 12 | public: 13 | VKDraw() noexcept = default; 14 | VKDraw(VKInstance& inst, VKDevice& dev) noexcept; 15 | 16 | void init() noexcept; 17 | void destroy() noexcept; 18 | 19 | void ImGuiInit() const noexcept; 20 | void ImGuiPreDraw() noexcept; 21 | void ImGuiDraw(void* drawData) noexcept; 22 | 23 | void waitOnGPU() const noexcept; 24 | private: 25 | friend class WindowInternal; 26 | friend class VulkanTexture; 27 | friend class VulkanRenderer; 28 | 29 | VKInstance* instance = nullptr; 30 | VKDevice* device = nullptr; 31 | 32 | ImGui_ImplVulkanH_Window window{}; 33 | bool bRebuildSwapchain = false; 34 | int minimalImageCount = 2; 35 | 36 | void recordCommands(void* drawData, VkSemaphore& imageAcquired, VkSemaphore& renderComplete) noexcept; 37 | void present() noexcept; 38 | }; 39 | } 40 | #endif -------------------------------------------------------------------------------- /Framework/Renderer/Vulkan/Components/VKInstance.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef __EMSCRIPTEN__ 3 | #include 4 | #include 5 | #include 6 | 7 | #define VK_NOT_SUCCESS(x) x != vk::Result::eSuccess 8 | 9 | namespace UImGui 10 | { 11 | class UIMGUI_PUBLIC_API VKInstance 12 | { 13 | public: 14 | VKInstance() = default; 15 | ~VKInstance() = default; 16 | 17 | void init() noexcept; 18 | void destroy() const noexcept; 19 | 20 | vk::Instance& data() noexcept; 21 | private: 22 | static bool checkInstanceExtensionsSupport(const TVector& extensions) noexcept; 23 | static bool checkValidationLayerSupport(const TVector& validationLayers) noexcept; 24 | 25 | vk::Instance instance; 26 | VkDebugReportCallbackEXT callback{}; 27 | 28 | static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t obj, 29 | size_t location, int32_t code, const char* layerPrefix, const char* message, void* userData) noexcept; 30 | 31 | void createDebugCallback() noexcept; 32 | }; 33 | } 34 | #endif -------------------------------------------------------------------------------- /Framework/Renderer/Vulkan/Components/VKSurface.cpp: -------------------------------------------------------------------------------- 1 | #include "VKSurface.hpp" 2 | #ifndef __EMSCRIPTEN__ 3 | #include 4 | #include 5 | #include 6 | 7 | void UImGui::VKSurface::create(VKInstance& instance) noexcept 8 | { 9 | VkSurfaceKHR surf; 10 | const auto result = glfwCreateWindowSurface(instance.data(), Window::getInternal(), nullptr, &surf); 11 | if (result != VK_SUCCESS) 12 | { 13 | Logger::log("Failed to create a window surface! Error code: ", ULOG_LOG_TYPE_ERROR, result); 14 | std::terminate(); 15 | } 16 | surface = surf; 17 | Logger::log("Created Vulkan render surface!", ULOG_LOG_TYPE_NOTE); 18 | } 19 | 20 | bool UImGui::VKSurface::getPhysicalDeviceSurfaceSupport(const vk::PhysicalDevice& device, const QueueFamilyIndices& indices) noexcept 21 | { 22 | const auto result = device.getSurfaceSupportKHR(indices.graphicsFamily, surface); 23 | if (result == VK_FALSE) 24 | return false; 25 | 26 | details.surfaceCapabilities = device.getSurfaceCapabilitiesKHR(surface); 27 | details.surfaceFormats = device.getSurfaceFormatsKHR>(surface); 28 | if (details.surfaceFormats.empty()) 29 | return false; 30 | 31 | details.presentationModes = device.getSurfacePresentModesKHR>(surface); 32 | return !details.presentationModes.empty(); 33 | } 34 | 35 | vk::SurfaceKHR& UImGui::VKSurface::get() noexcept 36 | { 37 | return surface; 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /Framework/Renderer/Vulkan/Components/VKSurface.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef __EMSCRIPTEN__ 3 | #include "VKInstance.hpp" 4 | #include "VKUtility.hpp" 5 | 6 | namespace UImGui 7 | { 8 | class UIMGUI_PUBLIC_API VKSurface 9 | { 10 | public: 11 | VKSurface() noexcept = default; 12 | 13 | void create(VKInstance& instance) noexcept; 14 | 15 | bool getPhysicalDeviceSurfaceSupport(const vk::PhysicalDevice& device, const QueueFamilyIndices& indices) noexcept; 16 | 17 | vk::SurfaceKHR& get() noexcept; 18 | private: 19 | vk::SurfaceKHR surface{}; 20 | SwapchainDetails details{}; 21 | }; 22 | } 23 | #endif -------------------------------------------------------------------------------- /Framework/Renderer/Vulkan/Components/VKUtility.cpp: -------------------------------------------------------------------------------- 1 | #include "VKUtility.hpp" 2 | #ifndef __EMSCRIPTEN__ 3 | bool UImGui::QueueFamilyIndices::valid() const noexcept 4 | { 5 | return graphicsFamily >= 0 && presentationFamily >= 0; 6 | } 7 | #endif -------------------------------------------------------------------------------- /Framework/Renderer/Vulkan/Components/VKUtility.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #ifndef __EMSCRIPTEN__ 5 | #include 6 | 7 | namespace UImGui 8 | { 9 | class VKDevice; 10 | 11 | struct UIMGUI_PUBLIC_API SwapchainDetails 12 | { 13 | vk::SurfaceCapabilitiesKHR surfaceCapabilities; 14 | TVector surfaceFormats; 15 | TVector presentationModes; 16 | }; 17 | 18 | struct QueueFamilyIndices 19 | { 20 | int graphicsFamily = -1; 21 | int presentationFamily = -1; 22 | 23 | [[nodiscard]] bool valid() const noexcept; 24 | }; 25 | } 26 | #endif -------------------------------------------------------------------------------- /Framework/Renderer/Vulkan/VulkanRenderer.cpp: -------------------------------------------------------------------------------- 1 | #include "VulkanRenderer.hpp" 2 | #include 3 | #include 4 | 5 | #include "Framework/Core/Interfaces/WindowInterface.hpp" 6 | 7 | void UImGui::VulkanRenderer::parseCustomConfig(YAML::Node&) noexcept{}; 8 | 9 | void UImGui::VulkanRenderer::setupWindowIntegration() noexcept 10 | { 11 | RendererUtils::setupManually(); 12 | } 13 | 14 | void UImGui::VulkanRenderer::setupPostWindowCreation() noexcept{}; 15 | 16 | void UImGui::VulkanRenderer::init(RendererInternalMetadata& metadata) noexcept 17 | { 18 | #ifndef __EMSCRIPTEN__ 19 | instance.init(); 20 | device.create(metadata); 21 | draw.init(); 22 | 23 | Window::pushWindowResizeCallback([&](const int, const int) -> void 24 | { 25 | draw.bRebuildSwapchain = true; 26 | }); 27 | #endif 28 | } 29 | 30 | void UImGui::VulkanRenderer::renderStart(double deltaTime) noexcept 31 | { 32 | 33 | } 34 | 35 | void UImGui::VulkanRenderer::renderEnd(double deltaTime) noexcept 36 | { 37 | #ifndef __EMSCRIPTEN__ 38 | draw.ImGuiDraw(ImGui::GetDrawData()); 39 | #endif 40 | } 41 | 42 | void UImGui::VulkanRenderer::destroy() noexcept 43 | { 44 | #ifndef __EMSCRIPTEN__ 45 | draw.destroy(); 46 | device.destroy(); 47 | instance.destroy(); 48 | #endif 49 | } 50 | 51 | void UImGui::VulkanRenderer::ImGuiNewFrame() noexcept 52 | { 53 | #ifndef __EMSCRIPTEN__ 54 | ImGui_ImplVulkan_NewFrame(); 55 | RendererUtils::beginImGuiFrame(); 56 | #endif 57 | } 58 | 59 | void UImGui::VulkanRenderer::ImGuiShutdown() noexcept 60 | { 61 | #ifndef __EMSCRIPTEN__ 62 | device.get().waitIdle(); 63 | ImGui_ImplVulkan_Shutdown(); 64 | #endif 65 | } 66 | 67 | void UImGui::VulkanRenderer::ImGuiInit() noexcept 68 | { 69 | #ifndef __EMSCRIPTEN__ 70 | draw.ImGuiInit(); 71 | #endif 72 | } 73 | 74 | void UImGui::VulkanRenderer::ImGuiRenderData() noexcept 75 | { 76 | 77 | } 78 | 79 | void UImGui::VulkanRenderer::waitOnGPU() noexcept 80 | { 81 | #ifndef __EMSCRIPTEN__ 82 | draw.waitOnGPU(); 83 | #endif 84 | } 85 | -------------------------------------------------------------------------------- /Framework/Renderer/Vulkan/VulkanRenderer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace UImGui 9 | { 10 | class UIMGUI_PUBLIC_API VulkanRenderer final : public GenericRenderer 11 | { 12 | public: 13 | VulkanRenderer() = default; 14 | 15 | virtual void parseCustomConfig(YAML::Node&) noexcept override; 16 | 17 | virtual void setupWindowIntegration() noexcept override; 18 | virtual void setupPostWindowCreation() noexcept override; 19 | 20 | virtual void init(RendererInternalMetadata& metadata) noexcept override; 21 | virtual void renderStart(double deltaTime) noexcept override; 22 | virtual void renderEnd(double deltaTime) noexcept override; 23 | virtual void destroy() noexcept override; 24 | 25 | virtual void ImGuiNewFrame() noexcept override; 26 | virtual void ImGuiShutdown() noexcept override; 27 | virtual void ImGuiInit() noexcept override; 28 | virtual void ImGuiRenderData() noexcept override; 29 | 30 | virtual void waitOnGPU() noexcept override; 31 | private: 32 | friend class WindowInternal; 33 | friend class VulkanTexture; 34 | 35 | #ifndef __EMSCRIPTEN__ 36 | VKInstance instance{}; 37 | VKDevice device{ instance }; 38 | VKDraw draw{ instance, device }; 39 | #endif 40 | }; 41 | } -------------------------------------------------------------------------------- /Framework/Renderer/Vulkan/VulkanTexture.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #ifndef __EMSCRIPTEN__ 4 | #include 5 | #endif 6 | 7 | namespace UImGui 8 | { 9 | class UIMGUI_PUBLIC_API VulkanTexture final : public GenericTexture 10 | { 11 | public: 12 | VulkanTexture() noexcept = default; 13 | 14 | // Event Safety - Any time 15 | virtual void init(TextureData& dt, String location, bool bFiltered) noexcept override; 16 | 17 | virtual void load(TextureData& dt, void* data, FVector2 size, uint32_t depth, bool bFreeImageData, 18 | const TFunction& freeFunc) noexcept override; 19 | 20 | // Event Safety - Post-begin 21 | virtual uintptr_t get(TextureData& dt) noexcept override; 22 | 23 | // Cleans up the image data 24 | // Event Safety - All initiated 25 | virtual void clear(TextureData& dt) noexcept override; 26 | virtual ~VulkanTexture() noexcept override = default; 27 | private: 28 | #ifndef __EMSCRIPTEN__ 29 | struct VulkanTextureData 30 | { 31 | bool bCreated = false; 32 | VkDescriptorSet descriptorSet = nullptr; 33 | 34 | vk::ImageView imageView{}; 35 | vk::Image image{}; 36 | vk::DeviceMemory imageMemory{}; 37 | vk::Sampler sampler{}; 38 | vk::Buffer uploadBuffer{}; 39 | vk::DeviceMemory uploadBufferMemory{}; 40 | }; 41 | #endif 42 | }; 43 | } -------------------------------------------------------------------------------- /Framework/Renderer/WebGPU/WebGPURenderer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #ifdef __EMSCRIPTEN__ 4 | #include 5 | #include 6 | #endif 7 | 8 | namespace UImGui 9 | { 10 | class UIMGUI_PUBLIC_API WebGPURenderer final : public GenericRenderer 11 | { 12 | public: 13 | WebGPURenderer() noexcept = default; 14 | 15 | virtual void parseCustomConfig(YAML::Node&) noexcept override; 16 | 17 | virtual void setupWindowIntegration() noexcept override; 18 | virtual void setupPostWindowCreation() noexcept override; 19 | 20 | virtual void init(RendererInternalMetadata& metadata) noexcept override; 21 | virtual void renderStart(double deltaTime) noexcept override; 22 | virtual void renderEnd(double deltaTime) noexcept override; 23 | virtual void destroy() noexcept override; 24 | 25 | virtual void ImGuiNewFrame() noexcept override; 26 | virtual void ImGuiShutdown() noexcept override; 27 | virtual void ImGuiInit() noexcept override; 28 | virtual void ImGuiRenderData() noexcept override; 29 | 30 | virtual void waitOnGPU() noexcept override; 31 | 32 | virtual ~WebGPURenderer() noexcept = default; 33 | private: 34 | friend class WebGPUTexture; 35 | #ifdef __EMSCRIPTEN__ 36 | WGPUInstance instance = nullptr; 37 | WGPUDevice device = nullptr; 38 | WGPUSurface surface = nullptr; 39 | WGPUSwapChain swapchain = nullptr; 40 | WGPUTextureFormat preferredFormat = WGPUTextureFormat_RGBA8Unorm; 41 | uint32_t swapchainWidth = 800; 42 | uint32_t swapchainHeight = 600; 43 | 44 | WGPUTextureDescriptor multisampledTextureDescriptor{}; 45 | WGPUTexture multisampledTexture = nullptr; 46 | WGPUTextureView multisampledTextureView = nullptr; 47 | uint32_t multisampledTextureWidth = 800; 48 | uint32_t multisampledTextureHeight = 600; 49 | 50 | void createSwapchain() noexcept; 51 | #endif 52 | }; 53 | } -------------------------------------------------------------------------------- /Framework/Renderer/WebGPU/WebGPUTexture.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void UImGui::WebGPUTexture::init(TextureData& dt, const String location, const bool bFiltered) noexcept 6 | { 7 | defaultInit(dt, location, bFiltered); 8 | #ifdef __EMSCRIPTEN__ 9 | dt.context = new WebGPUTextureData{}; 10 | dt.contextSize = sizeof(WebGPUTextureData); 11 | #endif 12 | } 13 | 14 | void UImGui::WebGPUTexture::load(TextureData& dt, void* data, FVector2 size, uint32_t depth, const bool bFreeImageData, 15 | const TFunction& freeFunc) noexcept 16 | { 17 | beginLoad(dt, &data, size); 18 | #ifdef __EMSCRIPTEN__ 19 | auto* texDt = static_cast(dt.context); 20 | 21 | texDt->textureDescriptor = WGPUTextureDescriptor 22 | { 23 | .nextInChain = nullptr, 24 | .usage = WGPUTextureUsage_TextureBinding | WGPUTextureUsage_CopyDst, 25 | .dimension = WGPUTextureDimension_2D, 26 | .size = { static_cast(size.x), static_cast(size.y), 1 }, 27 | .format = WGPUTextureFormat_RGBA8Unorm, 28 | .mipLevelCount = 1, 29 | .sampleCount = 1, 30 | .viewFormatCount = 0, 31 | .viewFormats = nullptr, 32 | }; 33 | auto* renderer = dynamic_cast(RendererUtils::getRenderer()); 34 | texDt->texture = wgpuDeviceCreateTexture(renderer->device, &texDt->textureDescriptor); 35 | 36 | const WGPUImageCopyTexture destination = 37 | { 38 | .texture = texDt->texture, 39 | .mipLevel = 0, 40 | .origin = { 0, 0, 0 }, 41 | .aspect = WGPUTextureAspect_All, 42 | }; 43 | 44 | const WGPUTextureDataLayout source = 45 | { 46 | .offset = 0, 47 | .bytesPerRow = 4 * texDt->textureDescriptor.size.width, 48 | .rowsPerImage = texDt->textureDescriptor.size.height, 49 | }; 50 | 51 | // * 4 because RGBA 52 | wgpuQueueWriteTexture(wgpuDeviceGetQueue(renderer->device), &destination, data, static_cast(size.x * size.y * 4), &source, &texDt->textureDescriptor.size); 53 | 54 | constexpr WGPUTextureViewDescriptor textureViewDescriptor = 55 | { 56 | .format = WGPUTextureFormat_RGBA8Unorm, 57 | .dimension = WGPUTextureViewDimension_2D, 58 | .baseMipLevel = 0, 59 | .mipLevelCount = 1, 60 | .baseArrayLayer = 0, 61 | .arrayLayerCount = 1, 62 | .aspect = WGPUTextureAspect_All, 63 | }; 64 | texDt->textureView = wgpuTextureCreateView(texDt->texture, &textureViewDescriptor); 65 | texDt->bCreated = true; 66 | #endif 67 | endLoad(dt, data, bFreeImageData, freeFunc); 68 | } 69 | 70 | uintptr_t UImGui::WebGPUTexture::get(TextureData& dt) noexcept 71 | { 72 | #ifdef __EMSCRIPTEN__ 73 | return reinterpret_cast(static_cast(dt.context)->textureView); 74 | #else 75 | return 0; 76 | #endif 77 | } 78 | 79 | void UImGui::WebGPUTexture::clear(TextureData& dt) noexcept 80 | { 81 | #ifdef __EMSCRIPTEN__ 82 | auto* texDt = static_cast(dt.context); 83 | if (Renderer::data().textureRendererType == UIMGUI_RENDERER_TYPE_VULKAN_WEBGPU && texDt->bCreated) 84 | { 85 | wgpuTextureViewRelease(texDt->textureView); 86 | wgpuTextureDestroy(texDt->texture); 87 | wgpuTextureRelease(texDt->texture); 88 | texDt->bCreated = false; 89 | } 90 | #endif 91 | defaultClear(dt); 92 | } 93 | -------------------------------------------------------------------------------- /Framework/Renderer/WebGPU/WebGPUTexture.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #ifdef __EMSCRIPTEN__ 4 | #include "imgui_impl_wgpu.h" 5 | #include 6 | #include 7 | #include 8 | #endif 9 | 10 | namespace UImGui 11 | { 12 | class UIMGUI_PUBLIC_API WebGPUTexture final : public GenericTexture 13 | { 14 | public: 15 | WebGPUTexture() noexcept = default; 16 | 17 | // Event Safety - Any time 18 | virtual void init(TextureData& dt, String location, bool bFiltered) noexcept override; 19 | 20 | virtual void load(TextureData& dt, void* data, FVector2 size, uint32_t depth, bool bFreeImageData, 21 | const TFunction& freeFunc) noexcept override; 22 | 23 | // Event Safety - Post-begin 24 | virtual uintptr_t get(TextureData& dt) noexcept override; 25 | 26 | // Cleans up the image data 27 | // Event Safety - All initiated 28 | virtual void clear(TextureData& dt) noexcept override; 29 | virtual ~WebGPUTexture() noexcept override = default; 30 | private: 31 | #ifdef __EMSCRIPTEN__ 32 | struct WebGPUTextureData 33 | { 34 | WGPUTextureDescriptor textureDescriptor{}; 35 | WGPUTexture texture = nullptr; 36 | WGPUTextureView textureView = nullptr; 37 | bool bCreated = false; 38 | }; 39 | #endif 40 | }; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Framework/Renderer/Window/macOS/MacOSWindowPlatform.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef __APPLE__ 3 | 4 | namespace UImGui::MacOSWindow 5 | { 6 | void setWindowAlwaysBelow(void* window); 7 | void setWindowAlwaysAbove(void* window); 8 | } 9 | #endif -------------------------------------------------------------------------------- /Framework/Renderer/Window/macOS/MacOSWindowPlatform.mm: -------------------------------------------------------------------------------- 1 | #import "MacOSWindowPlatform.h" 2 | #import 3 | #import 4 | 5 | void UImGui::MacOSWindow::setWindowAlwaysBelow(void* window) 6 | { 7 | id w = (id)window; 8 | [w setLevel:NSWindowBelow]; 9 | } 10 | 11 | void UImGui::MacOSWindow::setWindowAlwaysAbove(void* window) 12 | { 13 | id w = (id)window; 14 | [w makeKeyAndOrderFront:nil]; 15 | [w setLevel:NSStatusWindowLevel]; 16 | } -------------------------------------------------------------------------------- /Framework/ThirdParty/source-libraries/LICENSE-STB: -------------------------------------------------------------------------------- 1 | This software is available under 2 licenses -- choose whichever you prefer. 2 | ------------------------------------------------------------------------------ 3 | ALTERNATIVE A - MIT License 4 | Copyright (c) 2017 Sean Barrett 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | ------------------------------------------------------------------------------ 21 | ALTERNATIVE B - Public Domain (www.unlicense.org) 22 | This is free and unencumbered software released into the public domain. 23 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 24 | software, either in source code form or as a compiled binary, for any purpose, 25 | commercial or non-commercial, and by any means. 26 | In jurisdictions that recognize copyright laws, the author or authors of this 27 | software dedicate any and all copyright interest in the software to the public 28 | domain. We make this dedication for the benefit of the public at large and to 29 | the detriment of our heirs and successors. We intend this dedication to be an 30 | overt act of relinquishment in perpetuity of all present and future rights to 31 | this software under copyright law. 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 36 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 37 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 38 | -------------------------------------------------------------------------------- /Framework/ThirdParty/vulkan/libvulkan.1.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Framework/ThirdParty/vulkan/libvulkan.1.dylib -------------------------------------------------------------------------------- /Framework/ThirdParty/vulkan/vulkan-1.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MadLadSquad/UntitledImGuiFramework/66cdf8301378eddf00f8e88a092bad413944b0f1/Framework/ThirdParty/vulkan/vulkan-1.lib -------------------------------------------------------------------------------- /Framework/cmake/FindYamlCpp.cmake: -------------------------------------------------------------------------------- 1 | set(_yamlcpp_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) 2 | 3 | find_path(YamlCpp_INCLUDE_PATH yaml-cpp/yaml.h) 4 | 5 | find_path(YamlCpp_NEW_API yaml-cpp/node/node.h) 6 | if(YamlCpp_INCLUDE_PATH AND NOT YamlCpp_NEW_API) 7 | message(FATAL_ERROR "The new yaml-cpp 0.5 API is not available.") 8 | endif() 9 | 10 | if (YamlCpp_STATIC) 11 | if (WIN32) 12 | set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) 13 | else (WIN32) 14 | set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) 15 | endif (WIN32) 16 | endif (YamlCpp_STATIC) 17 | find_library(YamlCpp_LIBRARY NAMES libyaml-cppmt libyaml-cppmtd yaml-cpp) 18 | 19 | if(YamlCpp_INCLUDE_PATH AND YamlCpp_LIBRARY) 20 | set(YamlCpp_FOUND TRUE) 21 | endif(YamlCpp_INCLUDE_PATH AND YamlCpp_LIBRARY) 22 | if(YamlCpp_FOUND) 23 | if(NOT YamlCpp_FIND_QUIETLY) 24 | message(STATUS "Found yaml-cpp: ${YamlCpp_LIBRARY}") 25 | endif(NOT YamlCpp_FIND_QUIETLY) 26 | else(YamlCpp_FOUND) 27 | if(YamlCpp_FIND_REQUIRED) 28 | message(FATAL_ERROR "Could not find yaml-cpp library.") 29 | endif(YamlCpp_FIND_REQUIRED) 30 | endif(YamlCpp_FOUND) 31 | 32 | set(CMAKE_FIND_LIBRARY_SUFFIXES ${_yamlcpp_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) 33 | -------------------------------------------------------------------------------- /Framework/cmake/PluginDefaultsInit.cmake: -------------------------------------------------------------------------------- 1 | if (WIN32) 2 | set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}") 3 | set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}") 4 | endif() 5 | include(UImGuiHeader) 6 | 7 | include_directories(. ${UIMGUI_PLUGIN_APP_NAME}/Source ${UIMGUI_PLUGIN_APP_NAME}/Generated ${UIMGUI_PLUGIN_APP_NAME}/Framework ${UIMGUI_PLUGIN_APP_NAME}/) 8 | 9 | set(OLD_SRC "${CMAKE_SOURCE_DIR}") 10 | set(PLUGIN_PREFIX "${CMAKE_SOURCE_DIR}/${UIMGUI_PLUGIN_APP_NAME}") 11 | 12 | add_subdirectory(${UIMGUI_PLUGIN_APP_NAME}) 13 | 14 | set(CMAKE_SOURCE_DIR "${OLD_SRC}") 15 | include_directories(${FRAMEWORK_INCLUDE_DIRS}) -------------------------------------------------------------------------------- /Framework/cmake/PluginDefaultsPostInst.cmake: -------------------------------------------------------------------------------- 1 | add_library(${UIMGUI_PLUGIN_NAME} SHARED plugin.cpp) 2 | if (NOT WIN32) 3 | target_link_libraries(${UIMGUI_PLUGIN_NAME} PUBLIC "${UIMGUI_PLUGIN_APP_NAME}Lib") 4 | else() 5 | target_compile_options(${UIMGUI_PLUGIN_NAME} PRIVATE "/Zc:__cplusplus") 6 | endif () 7 | target_link_libraries(${UIMGUI_PLUGIN_NAME} PUBLIC UntitledImGuiFramework) -------------------------------------------------------------------------------- /Framework/cmake/SetupLanguageBoilerplate.cmake: -------------------------------------------------------------------------------- 1 | if (WIN32) 2 | set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}") 3 | set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}") 4 | endif() 5 | set(VULKAN_HEADERS_ENABLE_MODULE FALSE) 6 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 7 | 8 | set(CMAKE_CXX_STANDARD 23) 9 | set(CMAKE_C_STANDARD 99) 10 | 11 | if (APPLE) 12 | enable_language(OBJC) 13 | enable_language(OBJCXX) 14 | endif() 15 | 16 | function(multicast fun) 17 | set(optionals ${ARGN}) 18 | if (NOT EMSCRIPTEN) 19 | if (NOT UIMGUI_SKIP_FRAMEWORK) 20 | cmake_language(CALL ${fun} UntitledImGuiFramework ${optionals}) 21 | endif() 22 | if (NOT WIN32) 23 | cmake_language(CALL ${fun} ${APP_LIB_TARGET} ${optionals}) 24 | endif() 25 | endif() 26 | cmake_language(CALL ${fun} ${APP_TARGET} ${optionals}) 27 | endfunction() 28 | -------------------------------------------------------------------------------- /Framework/cmake/UImGuiHeader.cmake: -------------------------------------------------------------------------------- 1 | if (WIN32) 2 | set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") 3 | add_compile_options("/MD") 4 | elseif (APPLE) 5 | # Fixes to be able to use the shared vulkan library 6 | set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks") 7 | set(CMAKE_MACOSX_RPATH TRUE) 8 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) 9 | elseif (EMSCRIPTEN) 10 | # Fixes freetype not compiling 11 | add_compile_options(-fwasm-exceptions) 12 | add_link_options(-fwasm-exceptions) 13 | endif() 14 | option(UIMGUI_SKIP_FRAMEWORK "Enable this option in order to compile directly with the system framework" OFF) -------------------------------------------------------------------------------- /Framework/cmake/UImGuiSetupCMake.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/Config/cmake/") 2 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/Generated/") 3 | include(${APP_TARGET}) 4 | 5 | include(SetupLanguageBoilerplate) 6 | include(SetupCompilation) 7 | include(SetupSources) 8 | include(CompileProject) -------------------------------------------------------------------------------- /Framework/cmake/UntitledImGuiFramework.pc.in: -------------------------------------------------------------------------------- 1 | prefix="@UIMGUI_INSTALL_PREFIX@" 2 | exec_prefix="${prefix}" 3 | libdir="${prefix}/lib64" 4 | includedir="${prefix}/include" 5 | compile_defs="@compile_defs@" 6 | 7 | Name: UntitledImGuiFramework 8 | Description: Cross-platform desktop application framework based on dear imgui 9 | URL: https://github.com/MadLadSquad/UntitledImGuiFramework 10 | Version: @UIMGUI_FRAMEWORK_VERSION@ 11 | Cflags: -I"${includedir}" 12 | Libs: -L"${libdir}" -lUntitledImGuiFramework 13 | Libs.private: -L"${libdir}" -lUntitledImGuiFramework 14 | -------------------------------------------------------------------------------- /Framework/cmake/Version.cmake: -------------------------------------------------------------------------------- 1 | set(UIMGUI_FRAMEWORK_VERSION 1.0.0.0) 2 | set(UIMGUI_FRAMEWORK_VERSION_NUMERIC 1000) 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 - 2025 MadLadSquad 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /create-plugin.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | windows=false 4 | 5 | # Used to automatically find and add the Visual Studio MSBuild.exe directory to the environment variables! 6 | function find_visual_studio_directory() 7 | { 8 | env | grep "OS=Windows" > /dev/null && windows=true 9 | 10 | if [ "${windows}" = true ]; then 11 | wd=$(pwd) 12 | cd "C:/Program Files (x86)/Microsoft Visual Studio/Installer/" || exit 13 | find "vswhere.exe" -maxdepth 0 &> /dev/null || (cd "${wd}" && download_vswhere) 14 | 15 | VSShortVer=$(./vswhere.exe | grep "catalog_productLine: Dev17") 16 | VSShortVer="${VSShortVer:24}" 17 | 18 | VSVer=$(./vswhere.exe | grep "catalog_productLineVersion:") 19 | VSVer="${VSVer:28}" 20 | 21 | cd "${wd}" || exit 22 | fi 23 | return 24 | } 25 | 26 | function create() 27 | { 28 | cd Projects || exit 29 | mkdir "${plugin_name}" || echo "Project already exists" 30 | cd "${plugin_name}" || exit 31 | 32 | echo "\ 33 | #include 34 | #include 35 | 36 | #ifdef _WIN32 37 | #define PLUGIN_EXPORT __declspec(dllexport) 38 | #else 39 | #define PLUGIN_EXPORT 40 | #endif 41 | 42 | #ifdef __cplusplus 43 | extern \"C\" 44 | { 45 | #endif 46 | PLUGIN_EXPORT void UImGui_Plugin_attach(void* context) 47 | { 48 | UImGui::Utility::loadContext(context); 49 | } 50 | 51 | PLUGIN_EXPORT void UImGui_Plugin_detach() 52 | { 53 | } 54 | #ifdef __cplusplus 55 | } 56 | #endif" > plugin.cpp 57 | 58 | echo "\ 59 | cmake_minimum_required(VERSION 3.21) 60 | 61 | set(CMAKE_CXX_STANDARD 20) 62 | set(CMAKE_C_STANDARD 99) 63 | 64 | set(UIMGUI_PLUGIN_APP_NAME \"${prjname}\") 65 | set(UIMGUI_PLUGIN_NAME \"${plugin_name}\") 66 | set(CMAKE_MODULE_PATH \${CMAKE_MODULE_PATH} \"\${CMAKE_SOURCE_DIR}/\${UIMGUI_PLUGIN_APP_NAME}/Framework/cmake/\") 67 | 68 | include(PluginDefaultsInit) 69 | project(${plugin_name}) 70 | include(PluginDefaultsPostInst) 71 | " > CMakeLists.txt 72 | 73 | cp ../../example.gitignore .gitignore 74 | 75 | # Create symbolic links 76 | if [ "${windows}" == true ]; then 77 | cmd //c mklink //d .\\"${prjname}" ..\\"${prjname}" && return 78 | fi 79 | ln -s "../${prjname}/" "${prjname}" 2> /dev/null || cp -r ../"${prjname}" . 80 | } 81 | 82 | function compile() 83 | { 84 | mkdir build || exit 85 | cd build || exit 86 | cp ../"${prjname}"/Framework/ThirdParty/vulkan/vulkan-1.lib ../"${prjname}"/Framework/ThirdParty/vulkan/libvulkan.1.dylib . || exit 87 | if [ "${windows}" == true ]; then 88 | cmake .. -G "Visual Studio ${VSShortVer} ${VSVer}" -DCMAKE_BUILD_TYPE=RELEASE || exit 89 | MSBuild.exe "${plugin_name}".sln -property:Configuration=Release -property:Platform=x64 -property:maxCpuCount="${cpus}" || exit 90 | else 91 | cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE || exit 92 | make -j "${cpus}" || exit 93 | fi 94 | } 95 | 96 | if [ "$1" != "" ] && [ "$2" != "" ]; then 97 | plugin_name="$1" 98 | prjname="$2" 99 | 100 | headless=true 101 | else 102 | read -rp "Enter your plugin's name: " plugin_name # read the project name 103 | read -rp "Enter the target application's name: " prjname 104 | fi 105 | prjname=${prjname/ /} 106 | plugin_name=${plugin_name/ /} 107 | 108 | cpus=$(grep -c processor /proc/cpuinfo 2> /dev/null) || cpus=$(sysctl -n hw.ncpu) # get the cpu threads for maximum performance when compiling. The second command is for macOS systems if we even try to support them 109 | echo -e "\x1B[32mCopiling with ${cpus} compute jobs!\033[0m" 110 | 111 | find_visual_studio_directory 112 | create 113 | if [ "$3" != "--skip-compilation" ]; then 114 | compile 115 | fi 116 | echo -e "\x1B[32mPlugin successfully installed!\x1B[0m" 117 | -------------------------------------------------------------------------------- /example.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | .vs/ 35 | .idea/ 36 | build/ 37 | cmake-build-*/ 38 | Framework 39 | UVKBuildTool 40 | Generated/ 41 | export.sh 42 | CMakeLists.txt* 43 | Exported/ 44 | .DS_Store 45 | *.aps 46 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | VSVer=" " 3 | VSShortVer="1" 4 | cpus=" " 5 | windows=false 6 | 7 | oldpwd=$(pwd) 8 | 9 | # Standard cleanup error handler. Should be used everywhere exit is used 10 | # Gentoo Linux uses the die command so I'm not sure we should use just die 11 | die_() { 12 | rm -rf "${oldpwd}"/Projects &> /dev/null 13 | rm -rf "${oldpwd}"/UVKBuildTool/build &> /dev/null 14 | exit 15 | } 16 | 17 | download_vswhere() { 18 | # Get the raw JSON code for the releases from Github, get the lines that have the browser download URL and truncate the string in the front and back 19 | # to get the URL, then we use the URL to download the application, this only happens if we cannot find 20 | line=$(curl https://api.github.com/repos/microsoft/vswhere/releases 2> /dev/null | grep "https://github.com/microsoft/vswhere/releases/download/") 21 | line="${line:33}" 22 | line="${line%\"*}" 23 | 24 | # Set a fake user agent string here so that we evade being blocked by GitHub 25 | curl "${line}" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:106.0) Gecko/20100101 Firefox/106.0" -o vswhere.exe 26 | } 27 | 28 | 29 | # Used to automatically find and add the Visual Studio MSBuild.exe directory to the environment variables! 30 | function find_visual_studio_directory() 31 | { 32 | env | grep "OS=Windows" > /dev/null && windows=true 33 | 34 | if [ "${windows}" = true ]; then 35 | wd=$(pwd) 36 | cd "C:/Program Files (x86)/Microsoft Visual Studio/Installer/" || die_ 37 | find "vswhere.exe" -maxdepth 0 &> /dev/null || (cd "${wd}" && download_vswhere) 38 | vs_path=$(./vswhere.exe | grep "installationPath") 39 | vs_path="${vs_path:18}" 40 | 41 | VSShortVer=$(./vswhere.exe | grep "catalog_productLine: Dev17") 42 | VSShortVer="${VSShortVer:24}" 43 | 44 | VSVer=$(./vswhere.exe | grep "catalog_productLineVersion:") 45 | VSVer="${VSVer:28}" 46 | 47 | setx PATH "${vs_path}/MSBuild/Current/Bin/amd64/;%PATH%" 2> /dev/null 48 | cd "${wd}" || die_ 49 | fi 50 | 51 | return 52 | } 53 | 54 | # Installs the UVKBuildTool 55 | function install_build_tool() 56 | { 57 | cd UVKBuildTool/ || die_ 58 | mkdir build || die_ 59 | cd build || die_ 60 | 61 | if [ "${windows}" == true ]; then 62 | cmake .. -G "Visual Studio ${VSShortVer} ${VSVer}" -DUBT_COMPILING_FOR_WEB=OFF -DCMAKE_BUILD_TYPE=RELEASE -DUBT_FRAMEWORK_DIR="$(realpath ../../)" || die_ 63 | MSBuild.exe UVKBuildTool.sln -property:Configuration=Release -property:Platform=x64 -property:maxCpuCount="${cpus}" || die_ 64 | 65 | cp Release/UVKBuildTool.exe . &> /dev/null 66 | cp Release/*.dll . &> /dev/null 67 | else 68 | cmake .. -G "Unix Makefiles" -DUBT_COMPILING_FOR_WEB=OFF -DCMAKE_BUILD_TYPE=RELEASE -DUBT_FRAMEWORK_DIR="$(realpath ../../)" || die_ 69 | make -j "${cpus}" || die_ 70 | fi 71 | 72 | cd ../../ || die_ 73 | return 74 | } 75 | 76 | if [ "$1" == "" ]; then 77 | while true; do 78 | read -rp "Start installation? Y(Yes)/N(No): " yn 79 | case $yn in 80 | [Yy]* ) break;; 81 | [Nn]* ) exit;; 82 | * ) echo "Please answer with Y(Yes) or N(No)!";; 83 | esac 84 | done 85 | 86 | while true; do 87 | read -rp "Do you want to download offline documentation Y(Yes)/N(No): " yn 88 | case $yn in 89 | [Yy]* ) git clone https://github.com/MadLadSquad/UntitledImGuiFramework.wiki.git docs/; break;; 90 | [Nn]* ) break;; 91 | * ) echo "Please answer with Y(Yes) or N(No)!";; 92 | esac 93 | done 94 | fi 95 | cpus=$(grep -c processor /proc/cpuinfo 2> /dev/null) || cpus=$(sysctl -n hw.ncpu) # get the cpu threads for maximum performance when compiling 96 | echo -e "\x1B[32mCopiling with ${cpus} compute jobs!\033[0m" 97 | 98 | find_visual_studio_directory 99 | mkdir Projects/ 100 | install_build_tool "$1" 101 | 102 | echo -e "\x1b[32mFramework successfully installed!\x1b[0m" 103 | -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | let 2 | pkgs = import {}; 3 | in 4 | pkgs.mkShell { 5 | buildInputs = with pkgs; [ 6 | dbus 7 | webkitgtk 8 | openssl 9 | libxkbcommon 10 | ]; 11 | nativeBuildInputs = with pkgs; [ 12 | pkg-config 13 | cmake 14 | gnumake 15 | gdb 16 | rr 17 | yaml-cpp 18 | freetype 19 | glew 20 | glfw 21 | fontconfig 22 | shaderc 23 | glslang 24 | vulkan-headers 25 | vulkan-loader 26 | vulkan-validation-layers 27 | libxkbcommon 28 | ]; 29 | dbus = pkgs.dbus; 30 | shellHook = '' 31 | export LD_LIBRARY_PATH=${pkgs.wayland}/lib:${pkgs.libxkbcommon}/lib:$LD_LIBRARY_PATH 32 | ''; 33 | } 34 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | cpus=$(grep -c processor /proc/cpuinfo) || cpus=$(sysctl -n hw.ncpu) 3 | echo -e "\x1b[32mCompiling with ${cpus} jobs!\x1b[0m" 4 | 5 | git pull 6 | git submodule update --remote --merge --init --recursive 7 | 8 | cd UVKBuildTool || exit 9 | git pull origin master 10 | git submodule update --remote --merge --init --recursive 11 | 12 | cd build || exit 13 | cmake .. -DUBT_FRAMEWORK_DIR="$(realpath ../../)" || exit 14 | MSBuild.exe UVKBuildTool.sln -property:Configuration=Release -property:Platform=x64 -property:maxCpuCount="${cpus}" || make -j "${cpus}" || exit 15 | 16 | cd ../../ || exit 17 | echo -e "\x1b[32mSuccessfully updated the framework!\x1b[0m" 18 | --------------------------------------------------------------------------------