[API] Simplify flags API

This commit is contained in:
SpaiR committed 2020-08-30 21:51:04 +03:00
1 parent 9e81399f1e
commit b065d004f7
7 files changed
+130 -11

No files matched your search

@@ -41,6 +41,27 @@ public final class ImDrawList extends ImGuiStruct {
IM_DRAW_LIST->Flags = imDrawListFlags;
*/
/**
* Flags, you may poke into these to adjust anti-aliasing settings per-primitive.
*/
public void addImDrawListFlags(final int flags) {
setImDrawListFlags(getImDrawListFlags() | flags);
}
/**
* Flags, you may poke into these to adjust anti-aliasing settings per-primitive.
*/
public void removeImDrawListFlags(final int flags) {
setImDrawListFlags(getImDrawListFlags() & ~(flags));
}
/**
* Flags, you may poke into these to adjust anti-aliasing settings per-primitive.
*/
public boolean hasImDrawListFlags(final int flags) {
return (getImDrawListFlags() & flags) != 0;
}
/**
* Render-level scissoring.
* This is passed down to your render function but not used for CPU-side coarse clipping.
@@ -506,19 +506,40 @@ public final class ImFontAtlas extends ImGuiStructDestroyable {
*/
/**
* Build flags (see ImFontAtlasFlags_)
* Build flags (see {@link imgui.flag.ImFontAtlasFlags})
*/
public native int getFlags(); /*
return IM_FONT_ATLAS->Flags;
*/
/**
* Build flags (see ImFontAtlasFlags_)
* Build flags (see {@link imgui.flag.ImFontAtlasFlags})
*/
public native void setFlags(int imFontAtlasFlags); /*
IM_FONT_ATLAS->Flags = imFontAtlasFlags;
*/
/**
* Build flags (see {@link imgui.flag.ImFontAtlasFlags})
*/
public void addFlags(final int flags) {
setFlags(getFlags() | flags);
}
/**
* Build flags (see {@link imgui.flag.ImFontAtlasFlags})
*/
public void removeFlags(final int flags) {
setFlags(getFlags() & ~(flags));
}
/**
* Build flags (see {@link imgui.flag.ImFontAtlasFlags})
*/
public boolean hasFlags(final int flags) {
return (getFlags() & flags) != 0;
}
/**
* User data to refer to the texture once it has been uploaded to user's graphic systems.
* It is passed back to you during rendering via the ImDrawCmd structure.
@@ -52,6 +52,13 @@ public final class ImGuiIO {
setConfigFlags(getConfigFlags() & ~(configFlags));
}
/**
* See ImGuiConfigFlags enum. Set by user/application. Gamepad/keyboard navigation options, etc.
*/
public boolean hasConfigFlags(final int flags) {
return (getConfigFlags() & flags) != 0;
}
/**
* See ImGuiBackendFlags enum. Set by back-end to communicate features supported by the back-end.
*/
@@ -80,6 +87,13 @@ public final class ImGuiIO {
setBackendFlags(getBackendFlags() & ~(backendFlags));
}
/**
* See ImGuiBackendFlags enum. Set by back-end to communicate features supported by the back-end.
*/
public boolean hasBackendFlags(final int flags) {
return (getBackendFlags() & flags) != 0;
}
/**
* Minimum time between saving positions/sizes to .ini file, in seconds.
*/
@@ -51,6 +51,27 @@ public final class ImGuiViewport extends ImGuiStruct {
IMGUI_VIEWPORT->Flags = flags;
*/
/**
* See {@link imgui.flag.ImGuiViewportFlags}.
*/
public void addFlags(final int flags) {
setFlags(getFlags() | flags);
}
/**
* See {@link imgui.flag.ImGuiViewportFlags}.
*/
public void removeFlags(final int flags) {
setFlags(getFlags() & ~(flags));
}
/**
* See {@link imgui.flag.ImGuiViewportFlags}.
*/
public boolean hasFlags(final int flags) {
return (getFlags() & flags) != 0;
}
/**
* Main Area: Position of the viewport (the imgui coordinates are the same as OS desktop/native coordinates).
*/
@@ -112,6 +112,27 @@ public final class ImGuiWindowClass extends ImGuiStructDestroyable {
IMGUI_WINDOW_CLASS->DockNodeFlagsOverrideSet = dockNodeFlagsOverrideSet;
*/
/**
* [EXPERIMENTAL] Dock node flags to set when a window of this class is hosted by a dock node (it doesn't have to be selected!)
*/
public void addDockNodeFlagsOverrideSet(final int flags) {
setDockNodeFlagsOverrideSet(getDockNodeFlagsOverrideSet() | flags);
}
/**
* [EXPERIMENTAL] Dock node flags to set when a window of this class is hosted by a dock node (it doesn't have to be selected!)
*/
public void removeDockNodeFlagsOverrideSet(final int flags) {
setDockNodeFlagsOverrideSet(getDockNodeFlagsOverrideSet() & ~(flags));
}
/**
* [EXPERIMENTAL] Dock node flags to set when a window of this class is hosted by a dock node (it doesn't have to be selected!)
*/
public boolean hasDockNodeFlagsOverrideSet(final int flags) {
return (getDockNodeFlagsOverrideSet() & flags) != 0;
}
/**
* [EXPERIMENTAL]
*/
@@ -126,6 +147,27 @@ public final class ImGuiWindowClass extends ImGuiStructDestroyable {
IMGUI_WINDOW_CLASS->DockNodeFlagsOverrideClear = dockNodeFlagsOverrideClear;
*/
/**
* [EXPERIMENTAL]
*/
public void addDockNodeFlagsOverrideClear(final int flags) {
setDockNodeFlagsOverrideClear(getDockNodeFlagsOverrideClear() | flags);
}
/**
* [EXPERIMENTAL]
*/
public void removeDockNodeFlagsOverrideClear(final int flags) {
setDockNodeFlagsOverrideClear(getDockNodeFlagsOverrideClear() & ~(flags));
}
/**
* [EXPERIMENTAL]
*/
public boolean hasDockNodeFlagsOverrideClear(final int flags) {
return (getDockNodeFlagsOverrideClear() & flags) != 0;
}
/**
* Set to true to enforce single floating windows of this class always having their own docking node
* (equivalent of setting the global io.ConfigDockingAlwaysTabBar)
@@ -122,7 +122,7 @@ public final class ImGuiImplGl3 {
createDeviceObjects();
if ((ImGui.getIO().getConfigFlags() & ImGuiConfigFlags.ViewportsEnable) != 0) {
if (ImGui.getIO().hasConfigFlags(ImGuiConfigFlags.ViewportsEnable)) {
initPlatformInterface();
}
}
@@ -422,7 +422,7 @@ public final class ImGuiImplGl3 {
ImGui.getPlatformIO().setRendererRenderWindow(new ImPlatformFuncViewport() {
@Override
public void accept(final ImGuiViewport vp) {
if ((vp.getFlags() & ImGuiViewportFlags.NoRendererClear) == 0) {
if (!vp.hasFlags(ImGuiViewportFlags.NoRendererClear)) {
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
}
@@ -246,7 +246,7 @@ public class ImGuiImplGlfw {
mainViewport.setPlatformHandleRaw(GLFWNativeWin32.glfwGetWin32Window(windowId));
}
if ((io.getConfigFlags() & ImGuiConfigFlags.ViewportsEnable) != 0) {
if (io.hasConfigFlags(ImGuiConfigFlags.ViewportsEnable)) {
initPlatformInterface();
}
@@ -332,7 +332,7 @@ public class ImGuiImplGlfw {
} else {
glfwGetCursorPos(windowPtr, mouseX, mouseY);
if ((io.getConfigFlags() & ImGuiConfigFlags.ViewportsEnable) != 0) {
if (io.hasConfigFlags(ImGuiConfigFlags.ViewportsEnable)) {
// Multi-viewport mode: mouse position in OS absolute coordinates (io.MousePos is (0,0) when the mouse is on the upper-left of the primary monitor)
glfwGetWindowPos(windowPtr, windowX, windowY);
io.setMousePos((float) mouseX[0] + windowX[0], (float) mouseY[0] + windowY[0]);
@@ -352,7 +352,7 @@ public class ImGuiImplGlfw {
private void updateMouseCursor() {
final ImGuiIO io = ImGui.getIO();
final boolean noCursorChange = (io.getConfigFlags() & ImGuiConfigFlags.NoMouseCursorChange) == ImGuiConfigFlags.NoMouseCursorChange;
final boolean noCursorChange = io.hasConfigFlags(ImGuiConfigFlags.NoMouseCursorChange);
final boolean cursorDisabled = glfwGetInputMode(windowPtr, GLFW_CURSOR) == GLFW_CURSOR_DISABLED;
if (noCursorChange || cursorDisabled) {
@@ -380,7 +380,7 @@ public class ImGuiImplGlfw {
private void updateGamepads() {
final ImGuiIO io = ImGui.getIO();
if ((io.getConfigFlags() & ImGuiConfigFlags.NavEnableGamepad) == 0) {
if (!io.hasConfigFlags(ImGuiConfigFlags.NavEnableGamepad)) {
return;
}
@@ -527,8 +527,8 @@ public class ImGuiImplGlfw {
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE);
glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_FALSE);
glfwWindowHint(GLFW_DECORATED, (vp.getFlags() & ImGuiViewportFlags.NoDecoration) != 0 ? GLFW_FALSE : GLFW_TRUE);
glfwWindowHint(GLFW_FLOATING, (vp.getFlags() & ImGuiViewportFlags.TopMost) != 0 ? GLFW_TRUE : GLFW_FALSE);
glfwWindowHint(GLFW_DECORATED, vp.hasFlags(ImGuiViewportFlags.NoDecoration) ? GLFW_FALSE : GLFW_TRUE);
glfwWindowHint(GLFW_FLOATING, vp.hasFlags(ImGuiViewportFlags.TopMost) ? GLFW_TRUE : GLFW_FALSE);
data.window = glfwCreateWindow((int) vp.getSizeX(), (int) vp.getSizeY(), "No Title Yet", NULL, windowPtr);
data.windowOwned = true;
@@ -574,7 +574,7 @@ public class ImGuiImplGlfw {
public void accept(final ImGuiViewport vp) {
final ImGuiViewportDataGlfw data = (ImGuiViewportDataGlfw) vp.getPlatformUserData();
if (IS_WINDOWS && (vp.getFlags() & ImGuiViewportFlags.NoTaskBarIcon) != 0) {
if (IS_WINDOWS && vp.hasFlags(ImGuiViewportFlags.NoTaskBarIcon)) {
ImGuiImplGlfwNative.win32hideFromTaskBar(vp.getPlatformHandleRaw());
}