feat(api): Dear ImGui v1.87 + ImPlot v0.13 (#252)

* build(deps): bump Dear ImGui from 1.86 to 1.87

* build(deps): bump implot from 0.12 to 0.13

* feat(api,binding): adapt API to Dear ImGui v1.87

* feat(api,binding): adapt API to implot v0.13

* build: generate API for latest changes

* chore(binding): add missing super call for ImGuiStructDestroyable constructor

* chore: minor code style

* feat: adapt ImGuiImplGlfw to 1.87

* feat: adapt ImGuiImplGl3 to 1.87

* feat: adapt imgui-app module to 1.87

* fix: javadoc for updated imgui-binding

* fix: loosing data when setting struct field of char* type

Since we manually release chars, to store them in field we need to do a local copy.

* fix: invalid methods to check program linking in OpenGL

* chore: remove dedicated method to check GLFW version

* fix: add missing include
This commit is contained in:
SpaiR authored and GitHub committed 2024-08-16 15:35:42 +03:00
1 parent 341b0af179
commit 47d97102f7
80 files changed
+12211 -7373

No files matched your search

@@ -15,6 +15,7 @@ import imgui.binding.annotation.ReturnValue;
@BindingSource
public final class ImFont extends ImGuiStructDestroyable {
public ImFont() {
super();
}
public ImFont(final long ptr) {
@@ -36,6 +36,7 @@ public final class ImFontAtlas extends ImGuiStructDestroyable {
private ByteBuffer rgba32pixels = null;
public ImFontAtlas() {
super();
}
public ImFontAtlas(final long ptr) {
@@ -11,6 +11,7 @@ import imgui.binding.annotation.BindingSource;
@BindingSource
public final class ImFontGlyph extends ImGuiStructDestroyable {
public ImFontGlyph() {
super();
}
public ImFontGlyph(final long ptr) {
+19 -8
View File
@@ -2572,38 +2572,49 @@ public class ImGui {
*/
// Inputs Utilities: Keyboard
// - For 'int user_key_index' you can use your own indices/enums according to how your backend/engine stored them in io.KeysDown[].
// - We don't know the meaning of those value. You can use GetKeyIndex() to map a ImGuiKey_ value into the user index.
// Without IMGUI_DISABLE_OBSOLETE_KEYIO: (legacy support)
// - For 'ImGuiKey key' you can still use your legacy native/user indices according to how your backend/engine stored them in io.KeysDown[].
// With IMGUI_DISABLE_OBSOLETE_KEYIO: (this is the way forward)
// - Any use of 'ImGuiKey' will assert when key < 512 will be passed, previously reserved as native/user keys indices
// - GetKeyIndex() is pass-through and therefore deprecated (gone if IMGUI_DISABLE_OBSOLETE_KEYIO is defined)
/**
* Map ImGuiKey_* values into user's key index. == io.KeyMap[key]
*/
@BindingMethod
public static native int GetKeyIndex(int imguiKey);
@Deprecated
public static native int GetKeyIndex(@ArgValue(staticCast = "ImGuiKey") int key);
/**
* Is key being held. == io.KeysDown[user_key_index].
*/
@BindingMethod
public static native boolean IsKeyDown(int userKeyIndex);
public static native boolean IsKeyDown(@ArgValue(staticCast = "ImGuiKey") int key);
/**
* Was key pressed (went from !Down to Down)? if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate
*/
@BindingMethod
public static native boolean IsKeyPressed(int userKeyIndex, @OptArg boolean repeat);
public static native boolean IsKeyPressed(@ArgValue(staticCast = "ImGuiKey") int key, @OptArg boolean repeat);
/**
* Was key released (went from Down to !Down)..
* Was key released (went from Down to !Down)
*/
@BindingMethod
public static native boolean IsKeyReleased(int userKeyIndex);
public static native boolean IsKeyReleased(@ArgValue(staticCast = "ImGuiKey") int key);
/**
* Uses provided repeat rate/delay.
* Return a count, most often 0 or 1 but might be {@code >1} if RepeatRate is small enough that {@code DeltaTime > RepeatRate}
*/
@BindingMethod
public static native boolean GetKeyPressedAmount(int keyIndex, float repeatDelay, float rate);
public static native boolean GetKeyPressedAmount(@ArgValue(staticCast = "ImGuiKey") int key, float repeatDelay, float rate);
/**
* [DEBUG] returns English name of the key. Those names a provided for debugging purpose and are not meant to be saved persistently not compared.
*/
@BindingMethod
public static native String GetKeyName(@ArgValue(staticCast = "ImGuiKey") int key);
/**
* Attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle).
+141 -83
View File
@@ -5,6 +5,7 @@ import imgui.binding.annotation.ArgValue;
import imgui.binding.annotation.BindingField;
import imgui.binding.annotation.BindingMethod;
import imgui.binding.annotation.BindingSource;
import imgui.binding.annotation.OptArg;
import imgui.binding.annotation.ReturnValue;
import imgui.binding.annotation.TypeArray;
import imgui.callback.ImStrConsumer;
@@ -89,13 +90,6 @@ public final class ImGuiIO extends ImGuiStruct {
@BindingField
public float MouseDragThreshold;
/**
* Map of indices into the KeysDown[512] entries array which represent your "native" keyboard state.
*/
@BindingField
@TypeArray(type = "int", size = "ImGuiKey_COUNT")
public int[] KeyMap;
/**
* When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.).
*/
@@ -205,6 +199,12 @@ public final class ImGuiIO extends ImGuiStruct {
@BindingField
public boolean ConfigMacOSXBehaviors;
/**
* Enable input queue trickling: some types of events submitted during the same frame (e.g. button down + up) will be spread over multiple frames, improving interactions with low framerates.
*/
@BindingField
public boolean ConfigInputTrickleEventQueue;
/**
* Set to false to disable blinking cursor, for users who consider it distracting.
*/
@@ -285,82 +285,52 @@ public final class ImGuiIO extends ImGuiStruct {
*/
//------------------------------------------------------------------
// Input - Fill before calling NewFrame()
// Input - Call before calling NewFrame()
//------------------------------------------------------------------
/**
* Mouse position, in pixels. Set to ImVec2(-FLT_MAX, -FLT_MAX) if mouse is unavailable (on another screen, etc.)
*/
@BindingField
public ImVec2 MousePos;
// Input Functions
/**
* Mouse buttons: 0=left, 1=right, 2=middle + extras (ImGuiMouseButton_COUNT == 5). Dear ImGui mostly uses left and right buttons.
* Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API.
* Queue a new key down/up event. Key should be "translated" (as in, generally ImGuiKey_A matches the key end-user would use to emit an 'A' character)
*/
@BindingField
@TypeArray(type = "boolean", size = "5")
public boolean[] MouseDown;
@BindingMethod
public native void AddKeyEvent(@ArgValue(staticCast = "ImGuiKey") int key, boolean down);
/**
* Mouse wheel Vertical: 1 unit scrolls about 5 lines text.
* Queue a new key down/up event for analog values (e.g. ImGuiKey_Gamepad_ values). Dead-zones should be handled by the backend.
*/
@BindingField
public float MouseWheel;
@BindingMethod
public native void AddKeyAnalogEvent(@ArgValue(staticCast = "ImGuiKey") int key, boolean down, float v);
/**
* Mouse wheel Horizontal. Most users don't have a mouse with an horizontal wheel, may not be filled by all backends.
* Queue a mouse position update. Use -FLT_MAX,-FLT_MAX to signify no mouse (e.g. app not focused and not hovered)
*/
@BindingField
public float MouseWheelH;
@BindingMethod
public native void AddMousePosEvent(float x, float y);
/**
* (Optional) When using multiple viewports: viewport the OS mouse cursor is hovering _IGNORING_ viewports with the ImGuiViewportFlags_NoInputs flag,
* and _REGARDLESS_ of whether another viewport is focused. Set io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport if you can provide this info.
* If you don't imgui will infer the value using the rectangles and last focused time of the viewports it knows about (ignoring other OS windows).
* Queue a mouse button change
*/
@BindingField
public int MouseHoveredViewport;
@BindingMethod
public native void AddMouseButtonEvent(int button, boolean down);
/**
* Keyboard modifier pressed: Control
* Queue a mouse wheel update
*/
@BindingField
public boolean KeyCtrl;
@BindingMethod
public native void AddMouseWheelEvent(float whX, float whY);
/**
* Keyboard modifier pressed: Shift
* Queue a mouse hovered viewport. Requires backend to set ImGuiBackendFlags_HasMouseHoveredViewport to call this (for multi-viewport support).
*/
@BindingField
public boolean KeyShift;
@BindingMethod
public native void AddMouseViewportEvent(@ArgValue(staticCast = "ImGuiID") int id);
/**
* Keyboard modifier pressed: Alt
* Queue a gain/loss of focus for the application (generally based on OS/platform focus of your window)
*/
@BindingField
public boolean KeyAlt;
/**
* Keyboard modifier pressed: Cmd/Super/Windows
*/
@BindingField
public boolean KeySuper;
/**
* Keyboard keys that are pressed (ideally left in the "native" order your engine has access to keyboard keys, so you can use your own defines/enums for keys).
*/
@BindingField
@TypeArray(type = "boolean", size = "512")
public boolean[] KeysDown;
/**
* Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame().
*/
@BindingField
@TypeArray(type = "float", size = "512")
public float[] NavInputs;
// Functions
@BindingMethod
public native void AddFocusEvent(boolean focused);
/**
* Queue new character input.
@@ -380,12 +350,6 @@ public final class ImGuiIO extends ImGuiStruct {
@BindingMethod
public native void AddInputCharactersUTF8(String str);
/**
* Notifies Dear ImGui when hosting platform windows lose or gain input focus
*/
@BindingMethod
public native void AddFocusEvent(boolean focused);
/**
* [Internal] Clear the text input buffer manually
*/
@@ -398,6 +362,12 @@ public final class ImGuiIO extends ImGuiStruct {
@BindingMethod
public native void ClearInputKeys();
/**
* [Optional] Specify index for legacy before 1.87 IsKeyXXX() functions with native indices + specify native keycode, scancode.
*/
@BindingMethod
public native void SetKeyEventNativeData(@ArgValue(staticCast = "ImGuiKey") int key, int nativeKeycode, int nativeScancode, @OptArg int nativeLegacyIndex);
//------------------------------------------------------------------
// Output - Updated by NewFrame() or EndFrame()/Render()
// (when reading from the io.WantCaptureMouse, io.WantCaptureKeyboard flags to dispatch your inputs, it is
@@ -496,15 +466,92 @@ public final class ImGuiIO extends ImGuiStruct {
@BindingField
public ImVec2 MouseDelta;
/**
* Map of indices into the KeysDown[512] entries array which represent your "native" keyboard state.
*/
@BindingField
@TypeArray(type = "int", size = "ImGuiKey_COUNT")
@Deprecated
public int[] KeyMap;
/**
* Keyboard keys that are pressed (ideally left in the "native" order your engine has access to keyboard keys, so you can use your own defines/enums for keys).
*/
@BindingField
@TypeArray(type = "boolean", size = "512")
@Deprecated
public boolean[] KeysDown;
//------------------------------------------------------------------
// [Internal] Dear ImGui will maintain those fields. Forward compatibility not guaranteed!
//------------------------------------------------------------------
/**
* Alternative to WantCaptureMouse: (WantCaptureMouse == true {@code &&} WantCaptureMouseUnlessPopupClose == false) when a click over void is expected to close a popup.
* Mouse position, in pixels. Set to ImVec2(-FLT_MAX, -FLT_MAX) if mouse is unavailable (on another screen, etc.)
*/
@BindingField
public boolean WantCaptureMouseUnlessPopupClose;
public ImVec2 MousePos;
/**
* Mouse buttons: 0=left, 1=right, 2=middle + extras (ImGuiMouseButton_COUNT == 5). Dear ImGui mostly uses left and right buttons.
* Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API.
*/
@BindingField
@TypeArray(type = "boolean", size = "5")
public boolean[] MouseDown;
/**
* Mouse wheel Vertical: 1 unit scrolls about 5 lines text.
*/
@BindingField
public float MouseWheel;
/**
* Mouse wheel Horizontal. Most users don't have a mouse with an horizontal wheel, may not be filled by all backends.
*/
@BindingField
public float MouseWheelH;
/**
* (Optional) When using multiple viewports: viewport the OS mouse cursor is hovering _IGNORING_ viewports with the ImGuiViewportFlags_NoInputs flag,
* and _REGARDLESS_ of whether another viewport is focused. Set io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport if you can provide this info.
* If you don't imgui will infer the value using the rectangles and last focused time of the viewports it knows about (ignoring other OS windows).
*/
@BindingField
public int MouseHoveredViewport;
/**
* Keyboard modifier pressed: Control
*/
@BindingField
public boolean KeyCtrl;
/**
* Keyboard modifier pressed: Shift
*/
@BindingField
public boolean KeyShift;
/**
* Keyboard modifier pressed: Alt
*/
@BindingField
public boolean KeyAlt;
/**
* Keyboard modifier pressed: Cmd/Super/Windows
*/
@BindingField
public boolean KeySuper;
/**
* Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame().
*/
@BindingField
@TypeArray(type = "float", size = "512")
public float[] NavInputs;
// Other state maintained from data above + IO function calls
/**
* Key mods flags (same as io.KeyCtrl/KeyShift/KeyAlt/KeySuper but merged into flags), updated by NewFrame()
@@ -513,11 +560,24 @@ public final class ImGuiIO extends ImGuiStruct {
public int KeyMods;
/**
* Previous key mods
* Key mods flags (from previous frame)
*/
@BindingField
public int KeyModsPrev;
/**
* Key state for all known keys. Use IsKeyXXX() functions to access this.
*/
@BindingField
@TypeArray(type = "ImGuiKeyData", size = "ImGuiKey_KeysData_SIZE")
public ImGuiKeyData[] KeysData;
/**
* Alternative to WantCaptureMouse: (WantCaptureMouse == true {@code &&} WantCaptureMouseUnlessPopupClose == false) when a click over void is expected to close a popup.
*/
@BindingField
public boolean WantCaptureMouseUnlessPopupClose;
/**
* Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid)
*/
@@ -615,20 +675,6 @@ public final class ImGuiIO extends ImGuiStruct {
@TypeArray(type = "float", size = "5")
public float[] MouseDragMaxDistanceSqr;
/**
* Duration the keyboard key has been down (0.0f == just pressed)
*/
@BindingField
@TypeArray(type = "float", size = "512")
public float[] KeysDownDuration;
/**
* Previous duration the key has been down
*/
@BindingField
@TypeArray(type = "float", size = "512")
public float[] KeysDownDurationPrev;
@BindingField
@TypeArray(type = "float", size = "ImGuiNavInput_COUNT")
public float[] NavInputsDownDuration;
@@ -646,6 +692,18 @@ public final class ImGuiIO extends ImGuiStruct {
@BindingField
public boolean AppFocusLost;
/**
* -1: unknown, 0: using AddKeyEvent(), 1: using legacy io.KeysDown[]
*/
@BindingField
public short BackendUsingLegacyKeyArrays;
/**
* 0: using AddKeyAnalogEvent(), 1: writing to legacy io.NavInputs[] directly
*/
@BindingField
public boolean BackendUsingLegacyNavInputArray;
/**
* For AddInputCharacterUTF16
*/
@@ -0,0 +1,62 @@
package imgui;
import imgui.binding.ImGuiStructDestroyable;
import imgui.binding.annotation.BindingField;
import imgui.binding.annotation.BindingSource;
/**
* [Internal] Storage used by IsKeyDown(), IsKeyPressed() etc functions.
* If prior to 1.87 you used io.KeysDownDuration[] (which was marked as internal), you should use GetKeyData(key).DownDuration and not io.KeysData[key].DownDuration.
*/
@BindingSource
public final class ImGuiKeyData extends ImGuiStructDestroyable {
public ImGuiKeyData() {
super();
}
public ImGuiKeyData(final long ptr) {
super(ptr);
}
@Override
protected long create() {
return nCreate();
}
/*JNI
#include "_common.h"
#define THIS ((ImGuiKeyData*)STRUCT_PTR)
*/
private native long nCreate(); /*
return (intptr_t)(new ImGuiKeyData());
*/
/**
* True for if key is down
*/
@BindingField
public boolean Down;
/**
* Duration the key has been down ({@code <}0.0f: not pressed, 0.0f: just pressed, {@code >}0.0f: time held)
*/
@BindingField
public float DownDuration;
/**
* Last frame duration the key has been down
*/
@BindingField
public float DownDurationPrev;
/**
* 0.0f..1.0f for gamepad values
*/
@BindingField
public float AnalogValue;
/*JNI
#undef THIS
*/
}
@@ -18,6 +18,7 @@ import imgui.binding.annotation.OptArg;
@BindingSource
public final class ImGuiStorage extends ImGuiStructDestroyable {
public ImGuiStorage() {
super();
}
public ImGuiStorage(final long ptr) {
@@ -14,6 +14,7 @@ import imgui.binding.annotation.TypeArray;
@BindingSource
public final class ImGuiStyle extends ImGuiStructDestroyable {
public ImGuiStyle() {
super();
}
public ImGuiStyle(final long ptr) {
@@ -13,7 +13,6 @@ import imgui.binding.annotation.BindingSource;
*/
@BindingSource
public final class ImGuiTableSortSpecs extends ImGuiStruct {
public ImGuiTableSortSpecs(final long ptr) {
super(ptr);
}
@@ -27,8 +26,8 @@ public final class ImGuiTableSortSpecs extends ImGuiStruct {
* Pointer to sort spec array.
*/
public ImGuiTableColumnSortSpecs[] getSpecs() {
long[] specsPointers = nGetSpecs();
ImGuiTableColumnSortSpecs[] specs = new ImGuiTableColumnSortSpecs[specsPointers.length];
final long[] specsPointers = nGetSpecs();
final ImGuiTableColumnSortSpecs[] specs = new ImGuiTableColumnSortSpecs[specsPointers.length];
for (int i = 0; i < specsPointers.length; i++) {
specs[i] = new ImGuiTableColumnSortSpecs(specsPointers[i]);
}
@@ -16,6 +16,7 @@ import imgui.binding.annotation.BindingSource;
@BindingSource
public final class ImGuiWindowClass extends ImGuiStructDestroyable {
public ImGuiWindowClass() {
super();
}
public ImGuiWindowClass(final long ptr) {
@@ -0,0 +1,15 @@
package imgui.binding.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Marker interface for string types, which a represented in native with std::string instead of char*.
*/
@ExcludedSource
@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
public @interface TypeStdString {
}
@@ -23,7 +23,7 @@ public final class ImPlot {
*/
//-----------------------------------------------------------------------------
// ImPlot Context
// [SECTION] Contexts
//-----------------------------------------------------------------------------
/**
@@ -54,42 +54,28 @@ public final class ImPlot {
public static native void SetImGuiContext(ImGuiContext ctx);
//-----------------------------------------------------------------------------
// Begin/End Plot
// [SECTION] Begin/End Plot
//-----------------------------------------------------------------------------
// Starts a 2D plotting context. If this function returns true, EndPlot() MUST
// be called! You are encouraged to use the following convention:
//
// if (ImPlot.beginPlot(...)) {
// ImPlot.plotLine(...);
// if (BeginPlot(...)) {
// PlotLine(...);
// ...
// ImPlot.endPlot();
// EndPlot();
// }
//
// Important notes:
//
// - #titleID must be unique to the current ImGui ID scope. If you need to avoid ID
// - #title_id must be unique to the current ImGui ID scope. If you need to avoid ID
// collisions or don't want to display a title in the plot, use double hashes
// (e.g. "MyPlot##HiddenIdText" or "##NoTitle").
// - If #xLabel and/or #yLabel are provided, axes labels will be displayed.
// - #size is the **frame** size of the plot widget, not the plot area. The default
// size of plots (i.e. when ImVec2(0,0)) can be modified in your ImPlotStyle
// (default is 400x300 px).
// - Auxiliary y-axes must be enabled with ImPlotFlags_YAxis2/3 to be displayed.
// - See ImPlotFlags and ImPlotAxisFlags for more available options.
// size of plots (i.e. when ImVec2(0,0)) can be modified in your ImPlotStyle.
@BindingMethod
public static native boolean BeginPlot(String titleID,
@OptArg String xLabel,
@OptArg String yLabel,
@OptArg(callValue = "ImVec2(-1,0)") ImVec2 size,
@OptArg int flags,
@OptArg int xFlags,
@OptArg int yFlags,
@OptArg int y2Flags,
@OptArg int y3Flags,
@OptArg String y2Label,
@OptArg String y3Label);
public static native boolean BeginPlot(String titleId, @OptArg(callValue = "ImVec2(-1,0)") ImVec2 size, @OptArg int flags);
/**
* Only call EndPlot() if beginPlot() returns true! Typically called at the end
@@ -99,7 +85,7 @@ public final class ImPlot {
public static native void EndPlot();
//-----------------------------------------------------------------------------
// Begin/EndSubplots
// [SECTION] Begin/End Subplots
//-----------------------------------------------------------------------------
// Starts a subdivided plotting context. If the function returns true,
@@ -122,14 +108,15 @@ public final class ImPlot {
//
// Produces:
//
// [0][1][2]
// [3][4][5]
// [0] | [1] | [2]
// ----|-----|----
// [3] | [4] | [5]
//
// Important notes:
//
// - #title_id must be unique to the current ImGui ID scope. If you need to avoid ID
// collisions or don't want to display a title in the plot, use double hashes
// (e.g. "MyPlot##HiddenIdText" or "##NoTitle").
// (e.g. "MySubplot##HiddenIdText" or "##NoTitle").
// - #rows and #cols must be greater than 0.
// - #size is the size of the entire grid of subplots, not the individual plots
// - #row_ratios and #col_ratios must have AT LEAST #rows and #cols elements,
@@ -164,16 +151,174 @@ public final class ImPlot {
public static native void EndSubplots();
//-----------------------------------------------------------------------------
// Plot Items
// [SECTION] Setup
//-----------------------------------------------------------------------------
/*JNI
// For a proper type conversion, since C++ doesn't have a "long" type.
#define long ImS64
#define LEN(arg) (int)env->GetArrayLength(obj_##arg)
*/
// The following API allows you to setup and customize various aspects of the
// current plot. The functions should be called immediately after BeginPlot
// and before any other API calls. Typical usage is as follows:
// The template functions below are explicitly instantiated in implot_items.cpp.
// if (BeginPlot(...)) { 1) begin a new plot
// SetupAxis(ImAxis_X1, "My X-Axis"); 2) make Setup calls
// SetupAxis(ImAxis_Y1, "My Y-Axis");
// SetupLegend(ImPlotLocation_North);
// ...
// SetupFinish(); 3) [optional] explicitly finish setup
// PlotLine(...); 4) plot items
// ...
// EndPlot(); 5) end the plot
// }
//
// Important notes:
//
// - Always call Setup code at the top of your BeginPlot conditional statement.
// - Setup is locked once you start plotting or explicitly call SetupFinish.
// Do NOT call Setup code after you begin plotting or after you make
// any non-Setup API calls (e.g. utils like PlotToPixels also lock Setup)
// - Calling SetupFinish is OPTIONAL, but probably good practice. If you do not
// call it yourself, then the first subsequent plotting or utility function will
// call it for you.
/**
* Enables an axis or sets the label and/or flags for an existing axis.
* Leave `label` as NULL for no label.
*/
@BindingMethod
public static native void SetupAxis(int axis, @OptArg(callValue = "NULL") String label, @OptArg int flags);
/**
* Sets an axis range limits. If ImPlotCond_Always is used, the axes limits will be locked.
*/
@BindingMethod
public static native void SetupAxisLimits(int axis, double vMin, double vMax, @OptArg int cond);
/**
* Links an axis range limits to external values. Set to NULL for no linkage.
* The pointer data must remain valid until EndPlot.
*/
@BindingMethod
public static native void SetupAxisLinks(int axis, ImDouble linkMin, ImDouble linkMax);
/**
* Sets the format of numeric axis labels via formatter specifier (default="%g").
* Formatted values will be double (i.e. use %f).
*/
@BindingMethod
public static native void SetupAxisFormat(int axis, String fmt);
// TODO: support ImPlotFormatter
/**
* Sets an axis' ticks and optionally the labels. To keep the default ticks,
* set `keepDefault=true`.
*/
@BindingMethod
public static native void SetupAxisTicks(int axis, double[] values, int nTicks, @OptArg(callValue = "NULL") String[] labels, @OptArg boolean keepDefault);
/**
* Sets an axis' ticks and optionally the labels for the next plot.
* To keep the default ticks, set `keepDefault=true`.
*/
@BindingMethod
public static native void SetupAxisTicks(int axis, double vMin, double vMax, int nTicks, @OptArg(callValue = "NULL") String[] labels, @OptArg boolean keepDefault);
/**
* Sets the label and/or flags for primary X and Y axes (shorthand for two calls to SetupAxis).
*/
@BindingMethod
public static native void SetupAxes(String xLabel, String yLabel, @OptArg int xFlags, @OptArg int yFlags);
/**
* Sets the primary X and Y axes range limits. If ImPlotCond_Always is used,
* the axes limits will be locked (shorthand for two calls to SetupAxisLimits).
*/
@BindingMethod
public static native void SetupAxesLimits(double xMin, double xMax, double yMin, double yMax, @OptArg int cond);
/**
* Sets up the plot legend.
*/
@BindingMethod
public static native void SetupLegend(int location, @OptArg int flags);
/**
* Sets the location of the current plot's mouse position text (default = South|East).
*/
@BindingMethod
public static native void SetupMouseText(int location, @OptArg int flags);
/**
* Explicitly finalize plot setup. Once you call this, you cannot make any more
* Setup calls for the current plot! Note that calling this function is OPTIONAL;
* it will be called by the first subsequent setup-locking API call.
*/
@BindingMethod
public static native void SetupFinish();
//-----------------------------------------------------------------------------
// [SECTION] SetNext
//-----------------------------------------------------------------------------
// Though you should default to the `Setup` API above, there are some scenarios
// where (re)configuring a plot or axis before `BeginPlot` is needed (e.g. if
// using a preceding button or slider widget to change the plot limits). In
// this case, you can use the `SetNext` API below. While this is not as feature
// rich as the Setup API, most common needs are provided. These functions can be
// called anwhere except for inside of `Begin/EndPlot`. For example:
// if (ImGui::Button("Center Plot"))
// ImPlot::SetNextPlotLimits(-1,1,-1,1);
// if (ImPlot::BeginPlot(...)) {
// ...
// ImPlot::EndPlot();
// }
//
// Important notes:
//
// - You must still enable non-default axes with SetupAxis for these functions
// to work properly.
/**
* Sets an upcoming axis range limits. If ImPlotCond_Always is used, the axes limits will be locked.
*/
@BindingMethod
public static native void SetNextAxisLimits(int axis, double vMin, double vMax, @OptArg int cond);
/**
* Links an upcoming axis range limits to external values. Set to NULL for no linkage.
* The pointer data must remain valid until EndPlot!
*/
@BindingMethod
public static native void SetNextAxisLinks(int axis, ImDouble linkMin, ImDouble linkMax);
/**
* Set an upcoming axis to auto fit to its data.
*/
@BindingMethod
public static native void SetNextAxisToFit(int axis);
/**
* Sets the upcoming primary X and Y axes range limits. If ImPlotCond_Always is used,
* the axes limits will be locked (shorthand for two calls to SetupAxisLimits).
*/
@BindingMethod
public static native void SetNextAxesLimits(double xMin, double xMax, double yMin, double yMax, @OptArg int cond);
/**
* Sets all upcoming axes to auto fit to their data.
*/
@BindingMethod
public static native void SetNextAxesToFit();
//-----------------------------------------------------------------------------
// [SECTION] Plot Items
//-----------------------------------------------------------------------------
// The main plotting API is provied below. Call these functions between
// Begin/EndPlot and after any Setup API calls. Each plots data on the current
// x and y axes, which can be changed with `SetAxis/Axes`.
//
// The templated functions are explicitly instantiated in implot_items.cpp.
// They are not intended to be used generically with custom types. You will get
// a linker error if you try! All functions support the following scalar types:
//
@@ -217,6 +362,12 @@ public final class ImPlot {
// NB: All types are converted to double before plotting. You may lose information
// if you try plotting extremely large 64-bit integral types. Proceed with caution!
/*JNI
// For a proper type conversion, since C++ doesn't have a "long" type.
#define long ImS64
#define LEN(arg) (int)env->GetArrayLength(obj_##arg)
*/
// values
/**
@@ -1170,7 +1321,7 @@ public final class ImPlot {
@OptArg int xBins,
@OptArg int yBins,
@OptArg(callValue = "false") boolean density,
@OptArg(callValue = "ImPlotLimits()") ImPlotLimits range,
@OptArg(callValue = "ImPlotRect()") ImPlotRect range,
@OptArg boolean outliers);
/**
@@ -1186,7 +1337,7 @@ public final class ImPlot {
@OptArg int xBins,
@OptArg int yBins,
@OptArg(callValue = "false") boolean density,
@OptArg(callValue = "ImPlotLimits()") ImPlotLimits range,
@OptArg(callValue = "ImPlotRect()") ImPlotRect range,
@OptArg boolean outliers);
/**
@@ -1202,7 +1353,7 @@ public final class ImPlot {
@OptArg int xBins,
@OptArg int yBins,
@OptArg(callValue = "false") boolean density,
@OptArg(callValue = "ImPlotLimits()") ImPlotLimits range,
@OptArg(callValue = "ImPlotRect()") ImPlotRect range,
@OptArg boolean outliers);
/**
@@ -1218,7 +1369,7 @@ public final class ImPlot {
@OptArg int xBins,
@OptArg int yBins,
@OptArg(callValue = "false") boolean density,
@OptArg(callValue = "ImPlotLimits()") ImPlotLimits range,
@OptArg(callValue = "ImPlotRect()") ImPlotRect range,
@OptArg boolean outliers);
/**
@@ -1234,7 +1385,7 @@ public final class ImPlot {
@OptArg int xBins,
@OptArg int yBins,
@OptArg(callValue = "false") boolean density,
@OptArg(callValue = "ImPlotLimits()") ImPlotLimits range,
@OptArg(callValue = "ImPlotRect()") ImPlotRect range,
@OptArg boolean outliers);
/**
@@ -1291,111 +1442,130 @@ public final class ImPlot {
*/
//-----------------------------------------------------------------------------
// Plot Utils
// [SECTION] Plot Tools
//-----------------------------------------------------------------------------
// The following can be used to render interactive elements and/or annotations.
// Like the item plotting functions above, they apply to the current x and y
// axes, which can be changed with `SetAxis/SetAxes`.
/**
* Shows a draggable point at x, y. `col` defaults to ImGuiCol_Text.
*/
@BindingMethod
public static native boolean DragPoint(int id, ImDouble x, ImDouble y, ImVec4 col, @OptArg(callValue = "4") float size, @OptArg int flags);
/**
* Shows a draggable vertical guide line at an x-value. `col` defaults to ImGuiCol_Text.
*/
@BindingMethod
public static native boolean DragLineX(int id, ImDouble x, ImVec4 col, @OptArg(callValue = "1") float thickness, @OptArg int flags);
/**
* Shows a draggable horizontal guide line at a y-value. `col` defaults to ImGuiCol_Text.
*/
@BindingMethod
public static native boolean DragLineY(int id, ImDouble y, ImVec4 col, @OptArg(callValue = "1") float thickness, @OptArg int flags);
/**
* Shows a draggable and resizeable rectangle.
*/
@BindingMethod
public static native boolean DragRect(int id, ImDouble xMin, ImDouble yMin, ImDouble xMax, ImDouble yMax, ImVec4 col, @OptArg int flags);
/**
* Shows an annotation callout at a chosen point. Clamping keeps annotations in the plot area.
* Annotations are always rendered on top.
*/
@BindingMethod
public static native void Annotation(double x, double y, ImVec4 color, ImVec2 pixOffset, boolean clamp, @OptArg boolean round);
/**
* Shows an annotation callout at a chosen point with formatted text.
* Clamping keeps annotations in the plot area. Annotations are always rendered on top.
*/
@BindingMethod
public static native void Annotation(double x, double y, ImVec4 color, ImVec2 pixOffset, boolean clamp, String fmt, Void NULL);
/**
* Shows a x-axis tag at the specified coordinate value.
*/
@BindingMethod
public static native void TagX(double x, ImVec4 color, @OptArg boolean round);
/**
* Shows a x-axis tag at the specified coordinate value with formatted text.
*/
@BindingMethod
public static native void TagX(double x, ImVec4 color, String fmt, Void NULL);
/**
* Shows a y-axis tag at the specified coordinate value.
*/
@BindingMethod
public static native void TagY(double y, ImVec4 color, @OptArg boolean round);
/**
* Shows a y-axis tag at the specified coordinate value with formatted text.
*/
@BindingMethod
public static native void TagY(double y, ImVec4 color, String fmt, Void NULL);
//-----------------------------------------------------------------------------
// [SECTION] Plot Utils
//-----------------------------------------------------------------------------
/**
* Set the axes range limits of the next plot. Call right before BeginPlot(). If ImGuiCond_Always is used, the axes limits will be locked.
* Selects which axis will be used for subsequent plot elements.
*/
@BindingMethod
public static native void SetNextPlotLimits(double xMin, double xMax, double yMin, double yMax, @OptArg int cond);
public static native void SetAxis(int axis);
/**
* Set the X axis range limits of the next plot. Call right before BeginPlot(). If ImGuiCond_Always is used, the X axis limits will be locked.
* Selects which axes will be used for subsequent plot elements.
*/
@BindingMethod
public static native void SetNextPlotLimitsX(double xMin, double xMax, @OptArg int cond);
public static native void SetAxes(int xAxis, int yAxis);
/**
* Set the Y axis range limits of the next plot. Call right before BeginPlot(). If ImGuiCond_Always is used, the Y axis limits will be locked.
* Converts pixels to a position in the current plot's coordinate system.
* Passing IMPLOT_AUTO uses the current axes.
*/
@BindingMethod
public static native void SetNextPlotLimitsY(double yMin, double yMax, @OptArg int cond);
public static native ImPlotPoint PixelsToPlot(ImVec2 pix, @OptArg int xAxis, @OptArg int yAxis);
/**
* Links the next plot limits to external values. Set to NULL for no linkage. The pointer data must remain valid until the matching call to EndPlot.
* Converts a position in the current plot's coordinate system to pixels.
* Passing IMPLOT_AUTO uses the current axes.
*/
@BindingMethod
public static native void LinkNextPlotLimits(ImDouble xMin, ImDouble xMax, ImDouble yMin, ImDouble yMax, @OptArg ImDouble yMin2, @OptArg ImDouble yMax2, @OptArg ImDouble yMin3, @OptArg ImDouble yMax3);
public static native ImVec2 PlotToPixels(ImPlotPoint plt, @OptArg int xAxis, @OptArg int yAxis);
/**
* Fits the next plot axes to all plotted data if they are unlocked (equivalent to double-clicks).
*/
@BindingMethod
public static native void FitNextPlotAxes(@OptArg boolean x, @OptArg boolean y, @OptArg boolean y2, @OptArg boolean y3);
/**
* Set the X axis ticks and optionally the labels for the next plot. To keep the default ticks, set #keep_default=true.
*/
@BindingMethod
public static native void SetNextPlotTicksX(double[] values, int nTicks, @OptArg(callValue = "NULL") String[] labels, @OptArg boolean keepDefault);
/**
* Set the X axis ticks and optionally the labels for the next plot. To keep the default ticks, set #keep_default=true.
*/
@BindingMethod
public static native void SetNextPlotTicksX(double xMin, double xMax, int nTicks, @OptArg(callValue = "NULL") String[] labels, @OptArg boolean keepDefault);
/**
* Set the Y axis ticks and optionally the labels for the next plot. To keep the default ticks, set #keep_default=true.
*/
@BindingMethod
public static native void SetNextPlotTicksY(double[] values, int nTicks, @OptArg(callValue = "NULL") String[] labels, @OptArg(callValue = "false") boolean keepDefault, @OptArg int yAxis);
/**
* Set the Y axis ticks and optionally the labels for the next plot. To keep the default ticks, set #keep_default=true.
*/
@BindingMethod
public static native void SetNextPlotTicksY(double yMin, double yMax, int nTicks, @OptArg(callValue = "NULL") String[] labels, @OptArg(callValue = "false") boolean keepDefault, @OptArg int yAxis);
/**
* Set the format for numeric X axis labels (default="%g"). Formated values will be doubles (i.e. don't supply %d, %i, etc.). Not applicable if ImPlotAxisFlags_Time enabled.
*/
@BindingMethod
public static native void SetNextPlotFormatX(String fmt);
/**
* Set the format for numeric Y axis labels (default="%g"). Formated values will be doubles (i.e. don't supply %d, %i, etc.).
*/
@BindingMethod
public static native void SetNextPlotFormatY(String fmt, @OptArg int yAxis);
/**
* Select which Y axis will be used for subsequent plot elements. The default is ImPlotYAxis_1, or the first (left) Y axis. Enable 2nd and 3rd axes with ImPlotFlags_YAxisX.
*/
@BindingMethod
public static native void SetPlotYAxis(int yAxis);
/**
* Hides the next plot item. Use ImGuiCond.Always if you need to forcefully set this every frame (default ImGuiCond.Once).
*/
@BindingMethod
public static native void HideNextItem(@OptArg(callValue = "true") boolean hidden, @OptArg int cond);
/**
* Convert pixels to a position in the current plot's coordinate system. A negative yAxis uses the current value of SetPlotYAxis (ImPlotYAxis_1 initially).
*/
@BindingMethod
public static native ImPlotPoint PixelsToPlot(ImVec2 pix, @OptArg int yAxis);
/**
* Convert a position in the current plot's coordinate system to pixels. A negative yAxis uses the current value of SetPlotYAxis (ImPlotYAxis_1 initially).
*/
@BindingMethod
public static native ImVec2 PlotToPixels(ImPlotPoint plt, @OptArg int yAxis);
/**
* Get the current Plot position (top-left) in pixels.
* Gets the current Plot position (top-left) in pixels.
*/
@BindingMethod
public static native ImVec2 GetPlotPos();
/**
* Get the current Plot size in pixels.
* Gets the current Plot size in pixels.
*/
@BindingMethod
public static native ImVec2 GetPlotSize();
/**
* Returns the mouse position in x, y coordinates of the current plot.
* Passing IMPLOT_AUTO uses the current axes.
*/
@BindingMethod
public static native ImPlotPoint GetPlotMousePos(@OptArg int xAxis, @OptArg int yAxis);
/**
* Returns the current plot axis range.
*/
@BindingMethod
public static native ImPlotRect GetPlotLimits(@OptArg int xAxis, @OptArg int yAxis);
/**
* Returns true if the plot area in the current plot is hovered.
*/
@@ -1403,28 +1573,16 @@ public final class ImPlot {
public static native boolean IsPlotHovered();
/**
* Returns true if the XAxis plot area in the current plot is hovered.
* Returns true if the axis label area in the current plot is hovered.
*/
@BindingMethod
public static native boolean IsPlotXAxisHovered();
public static native boolean IsAxisHovered(int axis);
/**
* Returns true if the YAxis[n] plot area in the current plot is hovered.
* Returns true if the bounding frame of a subplot is hovered.
*/
@BindingMethod
public static native boolean IsPlotYAxisHovered(@OptArg int yAxis);
/**
* Returns the mouse position in x,y coordinates of the current plot. A negative yAxis uses the current value of SetPlotYAxis (ImPlotYAxis_1 initially).
*/
@BindingMethod
public static native ImPlotPoint GetPlotMousePos(@OptArg int yAxis);
/**
* Returns the current plot axis range. A negative yAxis uses the current value of SetPlotYAxis (ImPlotYAxis_1 initially).
*/
@BindingMethod
public static native ImPlotLimits GetPlotLimits(@OptArg int yAxis);
public static native boolean IsSubplotsHovered();
/**
* Returns true if the current plot is being box selected.
@@ -1434,115 +1592,57 @@ public final class ImPlot {
/**
* Returns the current plot box selection bounds.
* Passing IMPLOT_AUTO uses the current axes.
*/
@BindingMethod
public static native ImPlotLimits GetPlotSelection(@OptArg int yAxis);
public static native ImPlotRect GetPlotSelection(@OptArg int xAxis, @OptArg int yAxis);
/**
* Returns true if the current plot is being queried or has an active query. Query must be enabled with ImPlotFlags_Query.
* Cancels the current plot box selection.
*/
@BindingMethod
public static native boolean IsPlotQueried();
public static native void CancelPlotSelection();
/**
* Returns the current plot query bounds. Query must be enabled with ImPlotFlags_Query.
* Hides or shows the next plot item (i.e. as if it were toggled from the legend).
* Use ImPlotCond_Always if you need to forcefully set this every frame.
*/
@BindingMethod
public static native ImPlotLimits GetPlotQuery(@OptArg int yAxis);
/**
* Set the current plot query bounds. Query must be enabled with ImPlotFlags_Query.
*/
@BindingMethod
public static native void SetPlotQuery(ImPlotLimits query, @OptArg int yAxis);
/**
* Returns true if the bounding frame of a subplot is hovered
*/
@BindingMethod
public static native boolean IsSubplotsHovered();
//-----------------------------------------------------------------------------
// Aligned Plots
//-----------------------------------------------------------------------------
public static native void HideNextItem(@OptArg(callValue = "true") boolean hidden, @OptArg int cond);
// Use the following around calls to Begin/EndPlot to align l/r/t/b padding.
// Consider using Begin/EndSubplots first. They are more feature rich and
// accomplish the same behaviour by default. The functions below offer lower
// level control of plot alignment.
/**
* Align axis padding over multiple plots in a single row or column. If this function returns true, EndAlignedPlots() must be called. #group_id must be unique.
* Aligns axis padding over multiple plots in a single row or column.
* `group_id` must be unique. If this function returns true, EndAlignedPlots() must be called.
*/
@BindingMethod
public static native boolean BeginAlignedPlots(String groupId, @OptArg int orientation);
public static native boolean BeginAlignedPlots(String groupId, @OptArg boolean vertical);
/**
* Only call EndAlignedPlots() if BeginAlignedPlots() returns true!
* Ends aligned plots. Only call EndAlignedPlots() if BeginAlignedPlots() returns true.
*/
@BindingMethod
public static native void EndAlignedPlots();
//-----------------------------------------------------------------------------
// Plot Tools
// [SECTION] Legend Utils
//-----------------------------------------------------------------------------
/**
* Shows an annotation callout at a chosen point.
* Begins a popup for a legend entry.
*/
@BindingMethod
public static native void Annotate(double x, double y, ImVec2 pixOffset, String fmt, Void NULL);
public static native boolean BeginLegendPopup(String labelId, @OptArg int mouseButton);
/**
* Shows an annotation callout at a chosen point.
* Ends a popup for a legend entry.
*/
@BindingMethod
public static native void Annotate(double x, double y, ImVec2 pixOffset, ImVec4 color, String fmt, Void NULL);
/**
* Same as above, but the annotation will always be clamped to stay inside the plot area.
*/
@BindingMethod
public static native void AnnotateClamped(double x, double y, ImVec2 pixOffset, String fmt, Void NULL);
/**
* Same as above, but the annotation will always be clamped to stay inside the plot area.
*/
@BindingMethod
public static native void AnnotateClamped(double x, double y, ImVec2 pixOffset, ImVec4 color, String fmt, Void NULL);
/**
* Shows a draggable vertical guide line at an x-value. #col defaults to ImGuiCol_Text.
*/
@BindingMethod
public static native boolean DragLineX(String id, ImDouble xValue, @OptArg(callValue = "true") boolean showLabel, @OptArg(callValue = "IMPLOT_AUTO_COL") ImVec4 color, @OptArg float thickness);
/**
* Shows a draggable horizontal guide line at a y-value. #col defaults to ImGuiCol_Text.
*/
@BindingMethod
public static native boolean DragLineY(String id, ImDouble yValue, @OptArg(callValue = "true") boolean showLabel, @OptArg(callValue = "IMPLOT_AUTO_COL") ImVec4 color, @OptArg float thickness);
/**
* Shows a draggable point at x,y. #col defaults to ImGuiCol_Text.
*/
@BindingMethod
public static native boolean DragPoint(String id, ImDouble x, ImDouble y, @OptArg(callValue = "true") boolean showLabel, @OptArg(callValue = "IMPLOT_AUTO_COL") ImVec4 color, @OptArg float radius);
//-----------------------------------------------------------------------------
// Legend Utils and Tools
//-----------------------------------------------------------------------------
/**
* Set the location of the current plot's legend
*/
@BindingMethod
public static native void SetLegendLocation(int location, @OptArg(callValue = "ImPlotOrientation_Vertical") int orientation, @OptArg boolean outside);
/**
* Set the location of the current plot's mouse position text
*/
@BindingMethod
public static native void SetMousePosLocation(int location);
public static native void EndLegendPopup();
/**
* Returns true if a plot item legend entry is hovered.
@@ -1550,48 +1650,33 @@ public final class ImPlot {
@BindingMethod
public static native boolean IsLegendEntryHovered(String labelId);
/**
* Begin a popup for a legend entry.
*/
@BindingMethod
public static native boolean BeginLegendPopup(String labelID, @OptArg int mouseButton);
/**
* End a popup for a legend entry.
*/
@BindingMethod
public static native void EndLegendPopup();
//-----------------------------------------------------------------------------
// Drag and Drop Utils
// [SECTION] Drag and Drop
//-----------------------------------------------------------------------------
/**
* Turns the current plot's plotting area into a drag and drop target. Don't forget to call EndDragDropTarget!
* Turns the current plot's plotting area into a drag and drop target.
* Don't forget to call EndDragDropTarget!
*/
@BindingMethod
public static native boolean BeginDragDropTarget();
public static native boolean BeginDragDropTargetPlot();
/**
* Turns the current plot's X-axis into a drag and drop target. Don't forget to call EndDragDropTarget!
* Turns the current plot's X-axis into a drag and drop target.
* Don't forget to call EndDragDropTarget!
*/
@BindingMethod
public static native boolean BeginDragDropTargetX();
public static native boolean BeginDragDropTargetAxis(int axis);
/**
* Turns the current plot's Y-Axis into a drag and drop target. Don't forget to call EndDragDropTarget!
*/
@BindingMethod
public static native boolean BeginDragDropTargetY(@OptArg int yAxis);
/**
* Turns the current plot's legend into a drag and drop target. Don't forget to call EndDragDropTarget!
* Turns the current plot's legend into a drag and drop target.
* Don't forget to call EndDragDropTarget!
*/
@BindingMethod
public static native boolean BeginDragDropTargetLegend();
/**
* Ends a drag and drop target.
* Ends a drag and drop target (currently just an alias for ImGui::EndDragDropTarget).
*/
@BindingMethod
public static native void EndDragDropTarget();
@@ -1600,37 +1685,34 @@ public final class ImPlot {
// You can change the modifier if desired. If ImGuiKeyModFlags_None is provided, the axes will be locked from panning.
/**
* Turns the current plot's plotting area into a drag and drop source. Don't forget to call EndDragDropSource!
* Turns the current plot's plotting area into a drag and drop source.
* You must hold Ctrl. Don't forget to call EndDragDropSource!
*/
@BindingMethod
public static native boolean BeginDragDropSource(@OptArg int keyMods, @OptArg int dragDropFlags);
public static native boolean BeginDragDropSourcePlot(@OptArg int flags);
/**
* Turns the current plot's X-axis into a drag and drop source. Don't forget to call EndDragDropSource!
* Turns the current plot's X-axis into a drag and drop source.
* You must hold Ctrl. Don't forget to call EndDragDropSource!
*/
@BindingMethod
public static native boolean BeginDragDropSourceX(@OptArg int keyMods, @OptArg int dragDropFlags);
public static native boolean BeginDragDropSourceAxis(int axis, @OptArg int flags);
/**
* Turns the current plot's Y-axis into a drag and drop source. Don't forget to call EndDragDropSource!
* Turns an item in the current plot's legend into a drag and drop source.
* Don't forget to call EndDragDropSource!
*/
@BindingMethod
public static native boolean BeginDragDropSourceY(@OptArg int yAxis, @OptArg int keyMods, @OptArg int dragDropFlags);
public static native boolean BeginDragDropSourceItem(String labelId, @OptArg int flags);
/**
* Turns an item in the current plot's legend into drag and drop source. Don't forget to call EndDragDropSource!
*/
@BindingMethod
public static native boolean BeginDragDropSourceItem(String labelID, @OptArg int dragDropFlags);
/**
* Ends a drag and drop source.
* Ends a drag and drop source (currently just an alias for ImGui::EndDragDropSource).
*/
@BindingMethod
public static native void EndDragDropSource();
//-----------------------------------------------------------------------------
// Plot and Item Styling
// [SECTION] Styling
//-----------------------------------------------------------------------------
// Styling colors in ImPlot works similarly to styling colors in ImGui, but
@@ -1785,7 +1867,7 @@ public final class ImPlot {
public static native String GetMarkerName(int idx);
//-----------------------------------------------------------------------------
// Colormaps
// [SECTION] Colormaps
//-----------------------------------------------------------------------------
// Item styling is based on colormaps when the relevant ImPlotCol_XXX is set to
@@ -1875,7 +1957,7 @@ public final class ImPlot {
* Shows a vertical color scale with linear spaced ticks using the specified color map. Use double hashes to hide label (e.g. "##NoLabel").
*/
@BindingMethod
public static native void ColormapScale(String label, double scaleMin, double scaleMax, @OptArg(callValue = "ImVec2(0,0)") ImVec2 size, @OptArg(callValue = "IMPLOT_AUTO") int cmap, @OptArg String fmt);
public static native void ColormapScale(String label, double scaleMin, double scaleMax, @OptArg(callValue = "ImVec2(0,0)") ImVec2 size, @OptArg(callValue = "IMPLOT_AUTO") int cmap, @OptArg String format);
/**
* Shows a horizontal slider with a colormap gradient background.
@@ -1903,7 +1985,32 @@ public final class ImPlot {
public static native void BustColorCache(@OptArg String plotTitleId);
//-----------------------------------------------------------------------------
// Miscellaneous
// [SECTION] Input Mapping
//-----------------------------------------------------------------------------
/**
* Provides access to the input mapping structure for permanent modifications to controls for pan, select, etc.
*/
@BindingMethod
@ReturnValue(callPrefix = "&", isStatic = true)
public static native ImPlotInputMap GetInputMap();
/**
* Default input mapping: pan = LMB drag, box select = RMB drag,
* fit = LMB double click, context menu = RMB click, zoom = scroll.
*/
@BindingMethod
public static native void MapInputDefault(@OptArg ImPlotInputMap dst);
/**
* Reverse input mapping: pan = RMB drag, box select = LMB drag,
* fit = LMB double click, context menu = RMB click, zoom = scroll.
*/
@BindingMethod
public static native void MapInputReverse(@OptArg ImPlotInputMap dst);
//-----------------------------------------------------------------------------
// [SECTION] Miscellaneous
//-----------------------------------------------------------------------------
// Render icons similar to those that appear in legends (nifty for data lists).
@@ -1947,6 +2054,12 @@ public final class ImPlot {
@BindingMethod
public static native boolean ShowColormapSelector(String label);
/**
* Shows ImPlot input map selector dropdown menu.
*/
@BindingMethod
public static native boolean ShowInputMapSelector(String label);
/**
* Shows ImPlot style editor block (not a window).
*/
@@ -1966,7 +2079,7 @@ public final class ImPlot {
public static native void ShowMetricsWindow(@OptArg ImBoolean pOpen);
//-----------------------------------------------------------------------------
// Demo
// [SECTION] Demo
//-----------------------------------------------------------------------------
/**
@@ -0,0 +1,112 @@
package imgui.extension.implot;
import imgui.binding.ImGuiStructDestroyable;
import imgui.binding.annotation.BindingField;
import imgui.binding.annotation.BindingSource;
@BindingSource
public final class ImPlotInputMap extends ImGuiStructDestroyable {
public ImPlotInputMap() {
super();
}
public ImPlotInputMap(final long ptr) {
super(ptr);
}
@Override
protected long create() {
return nCreate();
}
/*JNI
#include "_implot.h"
#define THIS ((ImPlotInputMap*)STRUCT_PTR)
*/
private native long nCreate(); /*
return (intptr_t)(new ImPlotInputMap());
*/
/**
* LMB enables panning when held
*/
@BindingField
public int Pan;
/**
* Optional modifier that must be held for panning/fitting
*/
@BindingField
public int PanMod;
/**
* LMB initiates fit when double clicked
*/
@BindingField
public int Fit;
/**
* RMB begins box selection when pressed and confirms
* selection when released
*/
@BindingField
public int Select;
/**
* LMB cancels active box selection when pressed;
* cannot be the same as Select
*/
@BindingField
public int SelectCancel;
/**
* Optional modifier that must be held for box selection
*/
@BindingField
public int SelectMod;
/**
* Alt expands active box selection horizontally
* to plot edge when held
*/
@BindingField
public int SelectHorzMod;
/**
* Shift expands active box selection vertically
* to plot edge when held
*/
@BindingField
public int SelectVertMod;
/**
* RMB opens context menus (if enabled) when clicked
*/
@BindingField
public int Menu;
/**
* Ctrl when held, all input is ignored;
* used to enable axis/plots as DND sources
*/
@BindingField
public int OverrideMod;
/**
* Optional modifier that must be held for scroll wheel zooming
*/
@BindingField
public int ZoomMod;
/**
* Zoom rate for scroll (e.g. 0.1f = 10% plot range every scroll click);
* make negative to invert
*/
@BindingField
public float ZoomRate;
/*JNI
#undef THIS
*/
}
@@ -25,6 +25,10 @@ public final class ImPlotRange implements Cloneable {
return max - min;
}
public double clamp(final double value) {
return Math.max(min, Math.min(max, value));
}
public ImPlotRange set(final double min, final double max) {
this.min = min;
this.max = max;
@@ -4,22 +4,22 @@ import imgui.ImVec2;
import java.util.Objects;
public final class ImPlotLimits implements Cloneable {
public final class ImPlotRect implements Cloneable {
public final ImPlotRange x = new ImPlotRange();
public final ImPlotRange y = new ImPlotRange();
public ImPlotLimits() {
public ImPlotRect() {
}
public ImPlotLimits(final double xMin, final double yMin, final double xMax, final double yMax) {
public ImPlotRect(final double xMin, final double yMin, final double xMax, final double yMax) {
set(xMin, yMin, xMax, yMax);
}
public ImPlotLimits(final ImVec2 min, final ImVec2 max) {
public ImPlotRect(final ImVec2 min, final ImVec2 max) {
set(min, max);
}
public ImPlotLimits(final ImPlotLimits value) {
public ImPlotRect(final ImPlotRect value) {
set(value);
}
@@ -31,6 +31,18 @@ public final class ImPlotLimits implements Cloneable {
return contains(value.x, value.y);
}
public ImPlotPoint size() {
return new ImPlotPoint(x.size(), y.size());
}
public ImPlotPoint clamp(final double x, final double y) {
return new ImPlotPoint(this.x.clamp(x), this.y.clamp(y));
}
public ImPlotPoint clamp(ImPlotPoint p) {
return clamp(p.x, p.y);
}
public ImPlotPoint min() {
return new ImPlotPoint(x.min, y.min);
}
@@ -54,13 +66,13 @@ public final class ImPlotLimits implements Cloneable {
set(x.min, y.min, x.max, y.max);
}
public void set(final ImPlotLimits value) {
public void set(final ImPlotRect value) {
set(value.x, value.y);
}
@Override
public String toString() {
return "ImPlotLimits{"
return "ImPlotRect{"
+ "x=" + x
+ ", y=" + y
+ '}';
@@ -76,8 +88,8 @@ public final class ImPlotLimits implements Cloneable {
return false;
}
final ImPlotLimits imPlotLimits = (ImPlotLimits) o;
return Objects.equals(x, imPlotLimits.x) && Objects.equals(y, imPlotLimits.y);
final ImPlotRect imPlotRect = (ImPlotRect) o;
return Objects.equals(x, imPlotRect.x) && Objects.equals(y, imPlotRect.y);
}
@Override
@@ -87,7 +99,7 @@ public final class ImPlotLimits implements Cloneable {
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ImPlotLimits clone() {
return new ImPlotLimits(this);
public ImPlotRect clone() {
return new ImPlotRect(this);
}
}
@@ -10,6 +10,7 @@ import imgui.binding.annotation.TypeArray;
@BindingSource
public final class ImPlotStyle extends ImGuiStructDestroyable {
public ImPlotStyle() {
super();
}
public ImPlotStyle(final long ptr) {
@@ -0,0 +1,13 @@
package imgui.extension.implot.flag;
import imgui.binding.annotation.BindingAstEnum;
import imgui.binding.annotation.BindingSource;
@BindingSource
public final class ImPlotAxis {
private ImPlotAxis() {
}
@BindingAstEnum(file = "ast-implot.json", qualType = "ImAxis_")
public Void __;
}
@@ -0,0 +1,13 @@
package imgui.extension.implot.flag;
import imgui.binding.annotation.BindingAstEnum;
import imgui.binding.annotation.BindingSource;
@BindingSource
public final class ImPlotBarGroupsFlags {
private ImPlotBarGroupsFlags() {
}
@BindingAstEnum(file = "ast-implot.json", qualType = "ImPlotBarGroupsFlags_")
public Void __;
}
@@ -4,10 +4,10 @@ import imgui.binding.annotation.BindingAstEnum;
import imgui.binding.annotation.BindingSource;
@BindingSource
public final class ImPlotOrientation {
private ImPlotOrientation() {
public final class ImPlotCond {
private ImPlotCond() {
}
@BindingAstEnum(file = "ast-implot.json", qualType = "ImPlotOrientation_")
@BindingAstEnum(file = "ast-implot.json", qualType = "ImPlotCond_")
public Void __;
}
@@ -4,10 +4,10 @@ import imgui.binding.annotation.BindingAstEnum;
import imgui.binding.annotation.BindingSource;
@BindingSource
public final class ImPlotYAxis {
private ImPlotYAxis() {
public final class ImPlotDragToolFlags {
private ImPlotDragToolFlags() {
}
@BindingAstEnum(file = "ast-implot.json", qualType = "ImPlotYAxis_", sanitizeName = "ImPlot")
@BindingAstEnum(file = "ast-implot.json", qualType = "ImPlotDragToolFlags_")
public Void __;
}
@@ -0,0 +1,13 @@
package imgui.extension.implot.flag;
import imgui.binding.annotation.BindingAstEnum;
import imgui.binding.annotation.BindingSource;
@BindingSource
public final class ImPlotLegendFlags {
private ImPlotLegendFlags() {
}
@BindingAstEnum(file = "ast-implot.json", qualType = "ImPlotLegendFlags_")
public Void __;
}
@@ -0,0 +1,13 @@
package imgui.extension.implot.flag;
import imgui.binding.annotation.BindingAstEnum;
import imgui.binding.annotation.BindingSource;
@BindingSource
public final class ImPlotMouseTextFlags {
private ImPlotMouseTextFlags() {
}
@BindingAstEnum(file = "ast-implot.json", qualType = "ImPlotMouseTextFlags_")
public Void __;
}
@@ -14,6 +14,7 @@ import imgui.binding.annotation.OptArg;
@BindingSource
public final class MemoryEditor extends ImGuiStructDestroyable {
public MemoryEditor() {
super();
}
public MemoryEditor(final long ptr) {
@@ -7,6 +7,7 @@ import imgui.binding.annotation.BindingSource;
@BindingSource
public final class MemoryEditorSizes extends ImGuiStructDestroyable {
public MemoryEditorSizes() {
super();
}
public MemoryEditorSizes(final long ptr) {
@@ -13,6 +13,7 @@ import java.util.Map;
@BindingSource
public final class TextEditor extends ImGuiStructDestroyable {
public TextEditor() {
super();
}
public TextEditor(final long ptr) {
@@ -5,12 +5,14 @@ import imgui.binding.annotation.BindingField;
import imgui.binding.annotation.BindingMethod;
import imgui.binding.annotation.BindingSource;
import imgui.binding.annotation.ReturnValue;
import imgui.binding.annotation.TypeStdString;
import java.util.Map;
@BindingSource
public final class TextEditorLanguageDefinition extends ImGuiStructDestroyable {
public TextEditorLanguageDefinition() {
super();
}
public TextEditorLanguageDefinition(final long ptr) {
@@ -33,6 +35,7 @@ public final class TextEditorLanguageDefinition extends ImGuiStructDestroyable {
*/
@BindingField(callName = "mName")
@TypeStdString
@ReturnValue(callSuffix = ".c_str()")
public String Name;
@@ -96,14 +99,17 @@ public final class TextEditorLanguageDefinition extends ImGuiStructDestroyable {
*/
@BindingField(callName = "mCommentStart")
@TypeStdString
@ReturnValue(callSuffix = ".c_str()")
public String CommentStart;
@BindingField(callName = "mCommentEnd")
@TypeStdString
@ReturnValue(callSuffix = ".c_str()")
public String CommentEnd;
@BindingField(callName = "mSingleLineComment")
@TypeStdString
@ReturnValue(callSuffix = ".c_str()")
public String SingleLineComment;