Skip to content

Commit 9a521cb

Browse files
forkercatctreffs
andauthored
Update to 1.86 and update OSX backend (fix keyboard issue) (#7)
* Update to 1.86 and update README/HOWTO * Update backend (1.86) to support keyboard/gamepad/clipboard events * Update CI Co-authored-by: Christian Treffs <ctreffs@gmail.com>
1 parent dbf41bd commit 9a521cb

28 files changed

+9491
-4847
lines changed

.github/workflows/ci-linux.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: [ master ]
66
pull_request:
77
branches: [ master ]
8+
workflow_dispatch:
89

910
jobs:
1011
linux-test-build-release:

.github/workflows/ci-macos.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ on:
55
branches: [ master ]
66
pull_request:
77
branches: [ master ]
8+
workflow_dispatch:
89

910
jobs:
1011
macos-test-build-release-xcode:
1112
runs-on: macOS-latest
1213
strategy:
1314
matrix:
14-
xcode: ["12.4"]
15+
xcode: ["13.2.1"]
1516
steps:
1617
- name: Checkout
1718
uses: actions/checkout@master

.github/workflows/ci-windows.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ on:
55
branches: [ master ]
66
pull_request:
77
branches: [ master ]
8+
workflow_dispatch:
89

910
jobs:
1011
windows-test-build-release:
1112
runs-on: windows-latest
1213
env:
13-
SNAPSHOT: "https://swift.org/builds/swift-5.4.1-release/windows10/swift-5.4.1-RELEASE/swift-5.4.1-RELEASE-windows10.exe"
14+
SNAPSHOT: "https://download.swift.org/swift-5.6-release/windows10/swift-5.6-RELEASE/swift-5.6-RELEASE-windows10.exe"
1415
steps:
1516
- uses: actions/checkout@master
1617
- uses: seanmiddleditch/gha-setup-vsdevenv@master

README.md

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
</p>
1313

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

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

20+
Currently it is based on **v1.86** of ImGui.
21+
1922
## 🚀 Getting Started
2023

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

5457
## 📝 Code Example
5558

59+
### Minimal
60+
5661
A minimal example is located at [Sources/Demos/Minimal/main.swift](Sources/Demos/Minimal/main.swift).
62+
5763
This is an excerpt:
5864

5965
```swift
@@ -85,25 +91,38 @@ for n in 0..<20 {
8591
ImGuiDestroyContext(ctx)
8692
```
8793

94+
### Metal + OSX
95+
96+
This is another demo displaying ImGui demo window at [Sources/Demos/Metal](Sources/Demos/Metal).
97+
98+
<p align="center">
99+
<img src="docs/imgui_demo.png" width="70%" alt="imgui_demo"/>
100+
</p>
101+
102+
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.
103+
88104
## 🆕 Update SwiftImGui
89105

90-
SwiftImGui uses a mutli-stage process to update to the latest imgui version. See [HOWTO.md](docs/HOWTO.md) for details.
106+
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.
91107

92-
## 💁 Help needed
108+
See [HOWTO.md](docs/HOWTO.md) for steps about how to contribute.
109+
110+
## 💁 Help Needed
93111

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

97115
Things that need to be done among others are:
98116

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

104123
## 🏷️ Versioning
105124

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

108127
## ✍️ Authors
109128

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

121-
## 🙏 Original code
140+
## 🙏 Original Code
141+
142+
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).
122143

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

127146
### imgui
128147

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

150+
> 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).
151+
>
152+
> 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.
153+
>
154+
> 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.
155+
131156
<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>
132157

133-
Businesses: support continued development via invoiced technical support, maintenance, sponsoring contracts:
158+
- **Businesses:** support continued development via invoiced technical support, maintenance, sponsoring contracts:
134159
<br>&nbsp;&nbsp;_E-mail: contact @ dearimgui dot org_
135-
136-
Individuals/hobbyists: support continued maintenance and development via the monthly Patreon:
160+
- **Individuals/hobbyists:** support continued maintenance and development via the monthly Patreon:
137161
<br>&nbsp;&nbsp;[![Patreon](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/patreon_02.png)](http://www.patreon.com/imgui)
138-
139-
Individuals/hobbyists: support continued maintenance and development via PayPal:
162+
- **Individuals/hobbyists:** support continued maintenance and development via PayPal:
140163
<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)
141164

142165
----
143166

144-
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).
145-
146-
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.
147-
148-
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.
149-
150-
151167
### cimgui
152168

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

155-
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)
171+
> 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)
156172
157173

158174
## ☮️ Alternatives

Sources/AutoWrapper/ArgT.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public struct ArgsT: Decodable {
5252
public let ret: String?
5353
public let signature: String?
5454

55+
private let escapingCallbackExceptions: Set<String> = [
56+
"ImGuiErrorLogCallback"
57+
]
58+
5559
public enum Keys: String, CodingKey {
5660
case name
5761
case type
@@ -83,7 +87,8 @@ public struct ArgsT: Decodable {
8387

8488
public var toSwift: String {
8589
switch self.type.type {
86-
case let .custom(name) where name.hasSuffix("Callback") && escapedName.contains("callback"):
90+
case let .custom(name) where name.hasSuffix("Callback") && escapedName.contains("callback")
91+
&& !escapingCallbackExceptions.contains(name):
8792
return "_ \(escapedName): @escaping \(self.type.toString(self, .argSwift))"
8893
default:
8994
return "_ \(escapedName): \(self.type.toString(self, .argSwift, defaultArg: true))"

0 commit comments

Comments
 (0)