Skip to content

Commit 92a9d43

Browse files
committed
Add shortcut methods to add/remove config/backend flags
1 parent 258b9fe commit 92a9d43

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

imgui-binding/src/main/java/imgui/ImGuiIO.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ public final class ImGuiIO {
3838
ImGui::GetIO().ConfigFlags = configFlags;
3939
*/
4040

41+
/**
42+
* See ImGuiConfigFlags enum. Set by user/application. Gamepad/keyboard navigation options, etc.
43+
*/
44+
public void addConfigFlags(int configFlags) {
45+
setConfigFlags(getConfigFlags() | configFlags);
46+
}
47+
48+
/**
49+
* See ImGuiConfigFlags enum. Set by user/application. Gamepad/keyboard navigation options, etc.
50+
*/
51+
public void removeConfigFlags(int configFlags) {
52+
setConfigFlags(getConfigFlags() & ~(configFlags));
53+
}
54+
4155
/**
4256
* See ImGuiBackendFlags enum. Set by back-end to communicate features supported by the back-end.
4357
*/
@@ -52,6 +66,19 @@ public final class ImGuiIO {
5266
ImGui::GetIO().BackendFlags = backendFlags;
5367
*/
5468

69+
/**
70+
* See ImGuiBackendFlags enum. Set by back-end to communicate features supported by the back-end.
71+
*/
72+
public void addBackendFlags(int backendFlags) {
73+
setBackendFlags(getBackendFlags() | backendFlags);
74+
}
75+
76+
/**
77+
* See ImGuiBackendFlags enum. Set by back-end to communicate features supported by the back-end.
78+
*/
79+
public void removeBackendFlags(int backendFlags) {
80+
setBackendFlags(getBackendFlags() & ~(backendFlags));
81+
}
5582

5683
/**
5784
* Minimum time between saving positions/sizes to .ini file, in seconds.

imgui-lwjgl3/src/main/java/imgui/glfw/ImGuiImplGlfw.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public boolean init(final long windowId, final boolean installCallbacks) {
193193

194194
final ImGuiIO io = ImGui.getIO();
195195

196-
io.setBackendFlags(ImGuiBackendFlags.HasMouseCursors | ImGuiBackendFlags.HasSetMousePos);
196+
io.addBackendFlags(ImGuiBackendFlags.HasMouseCursors | ImGuiBackendFlags.HasSetMousePos);
197197
io.setBackendPlatformName("imgui_java_impl_glfw");
198198

199199
// Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.

imgui-lwjgl3/src/test/java/ImGuiGlfwExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ private void setupImGui() {
167167
final ImGuiIO io = ImGui.getIO();
168168

169169
io.setIniFilename(null); // We don't want to save .ini file
170-
io.setConfigFlags(ImGuiConfigFlags.NavEnableKeyboard | ImGuiConfigFlags.DockingEnable); // Navigation with keyboard and enabled docking
170+
io.addConfigFlags(ImGuiConfigFlags.NavEnableKeyboard | ImGuiConfigFlags.DockingEnable); // Navigation with keyboard and enabled docking
171171

172172
// ------------------------------------------------------------
173173
// Fonts configuration

0 commit comments

Comments
 (0)