feat(api): add bindings for imgui-knobs (#211)

* feat(api): add bindings for imgui-knobs

Add bindings for the imgui-knobs extension

* Update example/src/main/java/Extra.java

Update styling

Co-authored-by: SpaiR <klimbetoo@gmail.com>

* Update example/src/main/java/Extra.java

Update styling

Co-authored-by: SpaiR <klimbetoo@gmail.com>

* Update .gitignore

Remove gradle.properties from git ignore

* Update styling

Update styling, field names set to UPPER_CASE, remove throwing exceptions from constructors, refactored flags to general style

---------

Co-authored-by: SpaiR <klimbetoo@gmail.com>
This commit is contained in:
ΔeltaandSpaiR authored and GitHub committed 2024-01-09 10:34:10 +02:00
1 parent 89cbacbf97
commit 194381c44e
9 files changed
+155 -1

No files matched your search

@@ -0,0 +1,66 @@
package imgui.extension.imguiknobs;
import imgui.type.ImFloat;
import imgui.type.ImInt;
/**
* ImGuiKnobs extension for ImGui
* Repo: https://github.com/altschuler/imgui-knobs
*/
public final class ImGuiKnobs {
private ImGuiKnobs() {
throw new UnsupportedOperationException();
}
/*JNI
#include "_imguiknobs.h"
*/
/**
* Create a knob with float values
*
* @param label knob Label
* @param pValue knob value
* @param minValue minimum value
* @param maxValue maximum value
* @param speed speed of the knob
* @param format string format
* @param variant ImGuiKnobVariant
* @param size size of the knob
* @param flags ImGuiKnobFlags
* @param steps determines the number of steps draw, it is only used for the ImGuiKnobVariant_Stepped variant.
*/
public static boolean knobFloat(final String label, final ImFloat pValue, final float minValue, final float maxValue, final float speed, final String format, final int variant, final float size, final int flags, final int steps) {
return nKnob(label, pValue.getData(), minValue, maxValue, speed, format, variant, size, flags, steps);
}
private static native boolean nKnob(String label, float[] pValue, float minValue, float maxValue, float speed, String format, int variant, float size, int flags, int steps); /*
return ImGuiKnobs::Knob(label, pValue, minValue, maxValue, speed, format, (ImGuiKnobVariant)variant, size, (ImGuiKnobFlags)flags, steps);
*/
/**
* Create a knob with int values
*
* @param label knob Label
* @param pValue knob value
* @param minValue minimum value
* @param maxValue maximum value
* @param speed speed of the knob
* @param format string format
* @param variant ImGuiKnobVariant
* @param size Size for the knob
* @param flags ImGuiKnobFlags
* @param steps determines the number of steps draw, it is only used for the ImGuiKnobVariant_Stepped variant.
*/
public static boolean knobInt(final String label, final ImInt pValue, final int minValue, final int maxValue, final float speed, final String format, final int variant, final float size, final int flags, final int steps) {
return nKnobInt(label, pValue.getData(), minValue, maxValue, speed, format, variant, size, flags, steps);
}
private static native boolean nKnobInt(String label, int[] pValue, int minValue, int maxValue, float speed, String format, int variant, float size, int flags, int steps); /*
return ImGuiKnobs::KnobInt(label, pValue, minValue, maxValue, speed, format, (ImGuiKnobVariant)variant, size, (ImGuiKnobFlags)flags, steps);
*/
}
@@ -0,0 +1,14 @@
package imgui.extension.imguiknobs.flag;
public final class ImGuiKnobFlags {
private ImGuiKnobFlags() {
}
public static final int NONE = 0;
public static final int NO_TITLE = 1;
public static final int NO_INPUT = 1 << 1;
public static final int VALUE_TOOLTIP = 1 << 2;
public static final int DRAG_HORIZONTAL = 1 << 3;
}
@@ -0,0 +1,14 @@
package imgui.extension.imguiknobs.flag;
public final class ImGuiKnobVariant {
private ImGuiKnobVariant() {
}
public static final int TICK = 1;
public static final int DOT = 1 << 1;
public static final int WIPER = 1 << 2;
public static final int WIPER_ONLY = 1 << 3;
public static final int WIPER_DOT = 1 << 4;
public static final int STEPPED = 1 << 5;
public static final int SPACE = 1 << 6;
}
@@ -0,0 +1,4 @@
#pragma once
#include <string>
#include "_common.h"
#include "imgui-knobs.h"