forked from zbx1425/imgui-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): add bindings for imgui-knobs (SpaiR#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>
- Loading branch information
Showing
9 changed files
with
155 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
imgui-binding/src/main/java/imgui/extension/imguiknobs/ImGuiKnobs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
*/ | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
imgui-binding/src/main/java/imgui/extension/imguiknobs/flag/ImGuiKnobFlags.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
imgui-binding/src/main/java/imgui/extension/imguiknobs/flag/ImGuiKnobVariant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#pragma once | ||
#include <string> | ||
#include "_common.h" | ||
#include "imgui-knobs.h" |
Submodule imgui-knobs
added at
4f2075