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:
1 parent
89cbacbf97
commit
194381c44e
9 files changed
+155
-1
No files matched your search
@@ -22,3 +22,6 @@
|
||||
[submodule "include/imgui_club"]
|
||||
path = include/imgui_club
|
||||
url = https://github.com/ocornut/imgui_club
|
||||
[submodule "include/imgui-knobs"]
|
||||
path = include/imgui-knobs
|
||||
url = https://github.com/altschuler/imgui-knobs
|
||||
@@ -48,7 +48,7 @@ class GenerateLibs extends DefaultTask {
|
||||
project.copy { CopySpec spec ->
|
||||
['include/imgui', 'include/imnodes', 'include/imgui-node-editor',
|
||||
'include/imguizmo', 'include/implot', 'include/ImGuiColorTextEdit',
|
||||
'include/ImGuiFileDialog', 'include/imgui_club/imgui_memory_editor'].each {
|
||||
'include/ImGuiFileDialog', 'include/imgui_club/imgui_memory_editor', 'include/imgui-knobs'].each {
|
||||
spec.from(project.rootProject.file(it)) { CopySpec s -> s.include('*.h', '*.cpp', '*.inl') }
|
||||
}
|
||||
spec.from(project.rootProject.file('imgui-binding/src/main/native'))
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import imgui.ImGui;
|
||||
import imgui.extension.imguiknobs.ImGuiKnobs;
|
||||
import imgui.extension.imguiknobs.flag.ImGuiKnobFlags;
|
||||
import imgui.extension.imguiknobs.flag.ImGuiKnobVariant;
|
||||
import imgui.flag.ImGuiCond;
|
||||
import imgui.flag.ImGuiWindowFlags;
|
||||
import imgui.type.ImBoolean;
|
||||
import imgui.type.ImFloat;
|
||||
|
||||
public class ExampleKnobs {
|
||||
|
||||
private static final ImFloat EXAMPLE_TICK_KNOB_VAL = new ImFloat(0);
|
||||
private static final ImFloat EXAMPLE_DOT_KNOB_VAL = new ImFloat(0);
|
||||
private static final ImFloat EXAMPLE_SPACE_KNOB_VAL = new ImFloat(0);
|
||||
private static final ImFloat EXAMPLE_WIPER_KNOB_VAL = new ImFloat(0);
|
||||
private static final ImFloat EXAMPLE_WIPER_DOT_KNOB_VAL = new ImFloat(0);
|
||||
private static final ImFloat EXAMPLE_WIPER_ONLY_KNOB_VAL = new ImFloat(0);
|
||||
private static final ImFloat EXAMPLE_STEPPED_KNOB_VAL = new ImFloat(0);
|
||||
|
||||
public static void show(final ImBoolean showKnobsWindow) {
|
||||
ImGui.setNextWindowSize(200, 400, ImGuiCond.Once);
|
||||
ImGui.setNextWindowPos(ImGui.getMainViewport().getPosX() + 200, ImGui.getMainViewport().getPosY() + 200, ImGuiCond.Once);
|
||||
if (ImGui.begin("Knobs Demo Window", showKnobsWindow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse)) {
|
||||
ImGui.textWrapped("This is a demo for dear ImGui Knobs");
|
||||
if (ImGui.beginChild("Float Knobs")) {
|
||||
ImGuiKnobs.knobFloat("Example Tick Knob", EXAMPLE_TICK_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.TICK, 50.0f, ImGuiKnobFlags.NONE, 1);
|
||||
|
||||
ImGuiKnobs.knobFloat("Example Dot Knob", EXAMPLE_DOT_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.DOT, 50.0f, ImGuiKnobFlags.NONE, 1);
|
||||
|
||||
ImGuiKnobs.knobFloat("Example Space Knob", EXAMPLE_SPACE_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.SPACE, 50.0f, ImGuiKnobFlags.NONE, 1);
|
||||
|
||||
ImGuiKnobs.knobFloat("Example Wiper Knob", EXAMPLE_WIPER_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.WIPER, 50.0f, ImGuiKnobFlags.NONE, 1);
|
||||
|
||||
ImGuiKnobs.knobFloat("Example Wiper Dot Knob", EXAMPLE_WIPER_DOT_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.WIPER_DOT, 50.0f, ImGuiKnobFlags.NONE, 1);
|
||||
|
||||
ImGuiKnobs.knobFloat("Example Wiper Only Knob", EXAMPLE_WIPER_ONLY_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.WIPER_ONLY, 50.0f, ImGuiKnobFlags.NONE, 1);
|
||||
|
||||
ImGuiKnobs.knobFloat("Example Stepped Knob", EXAMPLE_STEPPED_KNOB_VAL, 0.0f, 10.0f, 0.2f, "%.1f", ImGuiKnobVariant.STEPPED, 50.0f, ImGuiKnobFlags.NONE, 1);
|
||||
ImGui.endChild();
|
||||
}
|
||||
|
||||
ImGui.end();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,7 @@ public class Extra {
|
||||
private static final ImBoolean SHOW_IMGUI_MEMORY_EDITOR_WINDOW = new ImBoolean(false);
|
||||
private static final ImBoolean SHOW_IMGUI_CANVAS_EDITOR_WINDOW = new ImBoolean(false);
|
||||
private static final ImBoolean SHOW_IMGUI_INPUT_CALLBACK_WINDOW = new ImBoolean(false);
|
||||
private static final ImBoolean SHOW_IMGUI_KNOBS_DEMO = new ImBoolean(false);
|
||||
|
||||
private static final Graph GRAPH = new Graph();
|
||||
|
||||
@@ -30,6 +31,7 @@ public class Extra {
|
||||
ImGui.checkbox("Show ImGui MemoryEditor Demo Window", SHOW_IMGUI_MEMORY_EDITOR_WINDOW);
|
||||
ImGui.checkbox("Show ImGui Canvas Demo Window", SHOW_IMGUI_CANVAS_EDITOR_WINDOW);
|
||||
ImGui.checkbox("Show Imgui InputText Callback Window", SHOW_IMGUI_INPUT_CALLBACK_WINDOW);
|
||||
ImGui.checkbox("Show Imgui Knobs Demo", SHOW_IMGUI_KNOBS_DEMO);
|
||||
|
||||
if (SHOW_DEMO_WINDOW.get()) {
|
||||
ImGui.showDemoWindow(SHOW_DEMO_WINDOW);
|
||||
@@ -74,5 +76,9 @@ public class Extra {
|
||||
if (SHOW_IMGUI_INPUT_CALLBACK_WINDOW.get()) {
|
||||
ExampleInputTextCallback.show(SHOW_IMGUI_INPUT_CALLBACK_WINDOW);
|
||||
}
|
||||
|
||||
if (SHOW_IMGUI_KNOBS_DEMO.get()) {
|
||||
ExampleKnobs.show(SHOW_IMGUI_KNOBS_DEMO);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
Submodule
+1
Submodule include/imgui-knobs added at 4f207526f9.
Reference in new issue
Block a user