Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
linux-test-build-release:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
macos-test-build-release-xcode:
runs-on: macOS-latest
strategy:
matrix:
xcode: ["12.4"]
xcode: ["13.2.1"]
steps:
- name: Checkout
uses: actions/checkout@master
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
windows-test-build-release:
runs-on: windows-latest
env:
SNAPSHOT: "https://swift.org/builds/swift-5.4.1-release/windows10/swift-5.4.1-RELEASE/swift-5.4.1-RELEASE-windows10.exe"
SNAPSHOT: "https://download.swift.org/swift-5.6-release/windows10/swift-5.6-RELEASE/swift-5.6-RELEASE-windows10.exe"
steps:
- uses: actions/checkout@master
- uses: seanmiddleditch/gha-setup-vsdevenv@master
Expand Down
62 changes: 39 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
</p>

This is a **lightweight**, **auto-generated** and **thin** Swift wrapper around the popular and excellent [**dear imgui**](https://github.com/ocornut/imgui) library.
It provides a **swifty** and -especially - **typesafe** API. It is easily maintainable and updatable, as well, since it relies heavily on automated code generation.

It provides a **swifty** and especially **typesafe** API. It is easily maintainable and updatable, as well, since it relies heavily on automated code generation.

There are working [demo examples](Sources/Demos/), too, provided as part of the library.

Currently it is based on **v1.86** of ImGui.

## 🚀 Getting Started

These instructions will get your copy of the project up and running on your local machine and provide a code example.
Expand All @@ -39,7 +42,7 @@ import PackageDescription
let package = Package(
name: "YourPackageName",
dependencies: [
.package(url: "https://github.com/ctreffs/SwiftImGui.git", from: "1.82.0")
.package(url: "https://github.com/ctreffs/SwiftImGui.git", from: "1.86.0")
],
targets: [
.target(
Expand All @@ -53,7 +56,10 @@ let package = Package(

## 📝 Code Example

### Minimal

A minimal example is located at [Sources/Demos/Minimal/main.swift](Sources/Demos/Minimal/main.swift).

This is an excerpt:

```swift
Expand Down Expand Up @@ -85,25 +91,38 @@ for n in 0..<20 {
ImGuiDestroyContext(ctx)
```

### Metal + OSX

This is another demo displaying ImGui demo window at [Sources/Demos/Metal](Sources/Demos/Metal).

<p align="center">
<img src="docs/imgui_demo.png" width="70%" alt="imgui_demo"/>
</p>

It provides two backend files ([imgui_impl_metal.swift](Sources/Demos/Metal/imgui_impl_metal.swift), [imgui_impl_osx.swift](Sources/Demos/Metal/imgui_impl_metal.swift)). Feel free to include more backends for GLFW, SDL2, etc.

## 🆕 Update SwiftImGui

SwiftImGui uses a mutli-stage process to update to the latest imgui version. See [HOWTO.md](docs/HOWTO.md) for details.
SwiftImGui uses a mutli-stage process to update to the latest [cimgui](https://github.com/cimgui/cimgui) and [imgui](https://github.com/ocornut/imgui) versions.

## 💁 Help needed
See [HOWTO.md](docs/HOWTO.md) for steps about how to contribute.

## 💁 Help Needed

This project needs a lot of love.
If you are interested in contributing please feel free to do so!

Things that need to be done among others are:

- [ ] Extend the AutoWrapper to wrap more cimgui functions (currently there are 105 'invalid' functions that will not be wrapped. 927 will be wrapped properly.)
- [ ] Some functions are not available via the c interface - see `Sources/AutoWrapper/Exceptions.swift`
- [ ] Extend the AutoWrapper to wrap more cimgui functions
- Currently there are **112** 'invalid' functions that will not be wrapped and **974** will be wrapped properly.
- [ ] Some functions are not available via the C interface - see `Sources/AutoWrapper/Exceptions.swift`
- [ ] Find a solution for manual adjustments in cimgui generator template
- [ ] Write some more tests

## 🏷️ Versioning

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [releases on this repository](https://github.com/ctreffs/SwiftImGui/releases).
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [releases](https://github.com/ctreffs/SwiftImGui/releases) in this repository.

## ✍️ Authors

Expand All @@ -118,41 +137,38 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
* imgui licensed under [MIT License](https://github.com/ocornut/imgui/blob/master/LICENSE.txt)
* CImGui licensed under [MIT License](https://github.com/cimgui/cimgui/blob/master/LICENSE)

## 🙏 Original code
## 🙏 Original Code

SwiftImGui is merely a wrapper around [**imgui**](https://github.com/ocornut/imgui). It also makes use of the excellent C-API wrapper [**cimgui**](https://github.com/cimgui/cimgui).

Since SwiftImGui is merely a wrapper around [**imgui**](https://github.com/ocornut/imgui) it obviously depends on it.
It also makes use of the excellent c-api wrapper [**cimgui**](https://github.com/cimgui/cimgui).
Support them if you can!

### imgui

##### From [ocornut/imgui/docs/README.md](https://github.com/ocornut/imgui/blob/master/docs/README.md):

> Dear ImGui is a **bloat-free graphical user interface library for C++**. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).
>
> Dear ImGui is designed to **enable fast iterations** and to **empower programmers** to create **content creation tools and visualization / debug tools** (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and lacks certain features normally found in more high-level libraries.
>
> Dear ImGui is particularly suited to integration in games engine (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard.

<sub>(This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using dear imgui, please consider reaching out. If you are an individual using dear imgui, please consider supporting the project via Patreon or PayPal.)</sub>

Businesses: support continued development via invoiced technical support, maintenance, sponsoring contracts:
- **Businesses:** support continued development via invoiced technical support, maintenance, sponsoring contracts:
<br>&nbsp;&nbsp;_E-mail: contact @ dearimgui dot org_

Individuals/hobbyists: support continued maintenance and development via the monthly Patreon:
- **Individuals/hobbyists:** support continued maintenance and development via the monthly Patreon:
<br>&nbsp;&nbsp;[![Patreon](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/patreon_02.png)](http://www.patreon.com/imgui)

Individuals/hobbyists: support continued maintenance and development via PayPal:
- **Individuals/hobbyists:** support continued maintenance and development via PayPal:
<br>&nbsp;&nbsp;[![PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S)

----

Dear ImGui is a **bloat-free graphical user interface library for C++**. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).

Dear ImGui is designed to **enable fast iterations** and to **empower programmers** to create **content creation tools and visualization / debug tools** (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and lacks certain features normally found in more high-level libraries.

Dear ImGui is particularly suited to integration in games engine (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard.


### cimgui

##### From [cimgui/cimgui/README.md](https://github.com/cimgui/cimgui/blob/master/README.md)

CImGui is a thin c-api wrapper programmatically generated for the excellent C++ immediate mode gui Dear ImGui. All imgui.h functions are programmatically wrapped. Generated files are: cimgui.cpp, cimgui.h for C compilation. Also for helping in bindings creation, definitions.lua with function definition information and structs_and_enums.lua. This library is intended as a intermediate layer to be able to use Dear ImGui from other languages that can interface with C (like D - see D-binding)
> CImGui is a thin C-API wrapper programmatically generated for the excellent C++ immediate mode GUI Dear ImGui. All imgui.h functions are programmatically wrapped. Generated files are: cimgui.cpp, cimgui.h for C compilation. Also for helping in bindings creation, definitions.lua with function definition information and structs_and_enums.lua. This library is intended as a intermediate layer to be able to use Dear ImGui from other languages that can interface with C (like D - see D-binding)


## ☮️ Alternatives
Expand Down
7 changes: 6 additions & 1 deletion Sources/AutoWrapper/ArgT.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public struct ArgsT: Decodable {
public let ret: String?
public let signature: String?

private let escapingCallbackExceptions: Set<String> = [
"ImGuiErrorLogCallback"
]

public enum Keys: String, CodingKey {
case name
case type
Expand Down Expand Up @@ -83,7 +87,8 @@ public struct ArgsT: Decodable {

public var toSwift: String {
switch self.type.type {
case let .custom(name) where name.hasSuffix("Callback") && escapedName.contains("callback"):
case let .custom(name) where name.hasSuffix("Callback") && escapedName.contains("callback")
&& !escapingCallbackExceptions.contains(name):
return "_ \(escapedName): @escaping \(self.type.toString(self, .argSwift))"
default:
return "_ \(escapedName): \(self.type.toString(self, .argSwift, defaultArg: true))"
Expand Down
Loading