feat(api): extend available API for imgui.internal.ImGui (#294)

Extending available API for imgui.internal.ImGui class.
This adds multiple new methods to manipulate windows, fonts etc.
This commit is contained in:
SpaiR authored and GitHub committed 2024-10-31 09:52:30 +02:00
1 parent 80ea84b345
commit 5dab4bce55
4 files changed
+1193 -18

No files matched your search

@@ -1,5 +1,9 @@
package imgui.internal;
import imgui.ImDrawList;
import imgui.ImFont;
import imgui.ImGuiPlatformMonitor;
import imgui.ImGuiViewport;
import imgui.ImVec2;
import imgui.binding.annotation.ArgValue;
import imgui.binding.annotation.BindingMethod;
@@ -26,13 +30,247 @@ public final class ImGui extends imgui.ImGui {
Jni::InitInternal(env);
*/
// Windows
// We should always have a CurrentWindow in the stack (there is an implicit "Debug" window)
// If this ever crash because g.CurrentWindow is NULL it means that either
// - ImGui::NewFrame() has never been called, which is illegal.
// - You are calling ImGui functions after ImGui::EndFrame()/ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
@BindingMethod
public static native ImGuiWindow GetCurrentWindowRead();
@BindingMethod
public static native ImGuiWindow GetCurrentWindow();
@BindingMethod
public static native ImGuiWindow FindWindowByID(int id);
@BindingMethod
public static native ImGuiWindow FindWindowByName(String name);
@BindingMethod
public static native void UpdateWindowParentAndRootLinks(ImGuiWindow window, int flags, ImGuiWindow parentWindow);
@BindingMethod
public static native ImVec2 CalcWindowNextAutoFitSize(ImGuiWindow window);
@BindingMethod
public static native boolean IsWindowChildOf(ImGuiWindow window, ImGuiWindow potentialParent, boolean popupHierarchy, boolean dockHierarchy);
@BindingMethod
public static native boolean IsWindowWithinBeginStackOf(ImGuiWindow window, ImGuiWindow potentialParent);
@BindingMethod
public static native boolean IsWindowAbove(ImGuiWindow potentialAbove, ImGuiWindow potentialBelow);
@BindingMethod
public static native boolean IsWindowNavFocusable(ImGuiWindow window);
@BindingMethod
public static native void SetWindowPos(ImGuiWindow window, ImVec2 pos, @OptArg int cond);
@BindingMethod
public static native void SetWindowSize(ImGuiWindow window, ImVec2 size, @OptArg int cond);
@BindingMethod
public static native void SetWindowCollapsed(ImGuiWindow window, @ArgValue(staticCast = "bool") boolean collapsed, @OptArg int cond);
@BindingMethod
public static native void SetWindowHitTestHole(ImGuiWindow window, ImVec2 pos, ImVec2 size);
@BindingMethod
public static native ImRect WindowRectAbsToRel(ImGuiWindow window, ImRect r);
@BindingMethod
public static native ImRect WindowRectRelToAbs(ImGuiWindow window, ImRect r);
// Windows: Display Order and Focus Order
@BindingMethod
public static native void FocusWindow(ImGuiWindow window);
@BindingMethod
public static native void FocusTopMostWindowUnderOne(ImGuiWindow underThisWindow, ImGuiWindow ignoreWindow);
@BindingMethod
public static native void BringWindowToFocusFront(ImGuiWindow window);
@BindingMethod
public static native void BringWindowToDisplayFront(ImGuiWindow window);
@BindingMethod
public static native void BringWindowToDisplayBack(ImGuiWindow window);
@BindingMethod
public static native void BringWindowToDisplayBehind(ImGuiWindow window, ImGuiWindow aboveWindow);
@BindingMethod
public static native int FindWindowDisplayIndex(ImGuiWindow window);
@BindingMethod
public static native ImGuiWindow FindBottomMostVisibleWindowWithinBeginStack(ImGuiWindow window);
// Fonts, drawing
@BindingMethod
public static native void SetCurrentFont(ImFont font);
@BindingMethod
public static native ImFont GetDefaultFont();
@BindingMethod
public static native ImDrawList GetForegroundDrawList(ImGuiWindow window);
// Init
@BindingMethod
public static native void Initialize(ImGuiContext context);
@BindingMethod
public static native void Shutdown(ImGuiContext context);
// NewFrame
@BindingMethod
public static native void UpdateInputEvents(boolean trickleFastInputs);
@BindingMethod
public static native void UpdateHoveredWindowAndCaptureFlags();
@BindingMethod
public static native void StartMouseMovingWindow(ImGuiWindow window);
@BindingMethod
public static native void StartMouseMovingWindowOrNode(ImGuiWindow window, ImGuiDockNode node, boolean undockFloatingNode);
@BindingMethod
public static native void UpdateMouseMovingWindowNewFrame();
@BindingMethod
public static native void UpdateMouseMovingWindowEndFrame();
// TODO: Generic context hooks
// Viewports
@BindingMethod
public static native ImGuiPlatformMonitor GetViewportPlatformMonitor(ImGuiViewport viewport);
// TODO: Settings
// Scrolling
@BindingMethod
public static native void SetNextWindowScroll(ImVec2 scroll);
@BindingMethod
public static native void SetScrollX(ImGuiWindow window, float scrollX);
@BindingMethod
public static native void SetScrollY(ImGuiWindow window, float scrollY);
@BindingMethod
public static native void SetScrollFromPosX(ImGuiWindow window, float localX, float centerXRatio);
@BindingMethod
public static native void SetScrollFromPosY(ImGuiWindow window, float localY, float centerYRatio);
// Early work-in-progress API (ScrollToItem() will become public)
@BindingMethod
public static native void ScrollToItem(@OptArg int flags);
@BindingMethod
public static native void ScrollToRect(ImGuiWindow window, ImRect rect, @OptArg int flags);
@BindingMethod
public static native ImVec2 ScrollToRectEx(ImGuiWindow window, ImRect rect, @OptArg int flags);
// Basic Accessors
@BindingMethod
public static native int GetItemID();
@BindingMethod
public static native int GetItemStatusFlags();
@BindingMethod
public static native int GetItemFlags();
@BindingMethod
public static native int GetActiveID();
@BindingMethod
public static native int GetFocusID();
@BindingMethod
public static native void SetActiveID(int id, ImGuiWindow window);
@BindingMethod
public static native void SetFocusID(int id, ImGuiWindow window);
@BindingMethod
public static native void ClearActiveID();
@BindingMethod
public static native int GetHoveredID();
@BindingMethod
public static native void SetHoveredID(int id);
@BindingMethod
public static native void KeepAliveID(int id);
@BindingMethod
public static native void MarkItemEdited(int id);
@BindingMethod
public static native void PushOverrideID(int id);
@BindingMethod
public static native int GetIDWithSeed(String strIdBegin, String strIdEnd, int seed);
// Basic Helpers for widget code
@BindingMethod
public static native void ItemSize(ImVec2 size, @OptArg float textBaselineY);
@BindingMethod
public static native void ItemSize(ImRect bb, @OptArg float textBaselineY);
// TODO: ItemAdd
@BindingMethod
public static native boolean ItemHoverable(ImRect bb, int id);
@BindingMethod
public static native boolean IsClippedEx(ImRect bb, int id);
@BindingMethod
public static native void SetLastItemData(int itemId, int inFlags, int statusFlags, ImRect itemRect);
@BindingMethod
public static native ImVec2 CalcItemSize(ImVec2 size, float defaultW, float defaultH);
@BindingMethod
public static native void PushItemFlag(int imGuiItemFlags, boolean enabled);
public static native float CalcWrapWidthForPos(ImVec2 pos, float wrapPosX);
@BindingMethod
public static native void PushMultiItemsWidths(int components, float widthFull);
@BindingMethod
public static native boolean IsItemToggledSelection();
@BindingMethod
public static native ImVec2 GetContentRegionMaxAbs();
// TODO: ShrinkWidths
// Parameter stacks
@BindingMethod
public static native void PushItemFlag(int option, boolean enabled);
@BindingMethod
public static native void PopItemFlag();
@@ -51,10 +289,10 @@ public final class ImGui extends imgui.ImGui {
public static native void DockBuilderDockWindow(String windowName, int nodeId);
@BindingMethod
public static native ImGuiDockNode DockBuilderGetNode(final int nodeId);
public static native ImGuiDockNode DockBuilderGetNode(int nodeId);
@BindingMethod
public static native ImGuiDockNode DockBuilderGetCentralNode(final int nodeId);
public static native ImGuiDockNode DockBuilderGetCentralNode(int nodeId);
@BindingMethod
public static native int DockBuilderAddNode(@OptArg int nodeId, @OptArg int flags);
@@ -99,9 +337,6 @@ public final class ImGui extends imgui.ImGui {
@BindingMethod
public static native boolean SplitterBehavior(ImRect bb, int id, @ArgValue(staticCast = "ImGuiAxis") int axis, ImFloat size1, ImFloat size2, float minSize1, float minSize2, @OptArg float hoverExtend, @OptArg float hoverVisibilityDelay, @OptArg int bgCol);
@BindingMethod
public static native ImGuiWindow GetCurrentWindow();
@BindingMethod
public static native ImRect GetWindowScrollbarRect(ImGuiWindow imGuiWindow, @ArgValue(staticCast = "ImGuiAxis") int axis);
}
@@ -0,0 +1,13 @@
package imgui.internal.flag;
import imgui.binding.annotation.BindingAstEnum;
import imgui.binding.annotation.BindingSource;
@BindingSource
public class ImGuiItemStatusFlags {
private ImGuiItemStatusFlags() {
}
@BindingAstEnum(file = "ast-imgui_internal.json", qualType = "ImGuiItemStatusFlags_")
public Void __;
}