[API] Make all imgui.type classes to implement Comparable<> interface

This commit is contained in:
SpaiR committed 2023-02-28 19:02:41 +02:00
1 parent 068c1e0faa
commit 25fc8bae8f
7 files changed
+64 -16

No files matched your search

@@ -1,6 +1,6 @@
package imgui.type;
public final class ImBoolean implements Cloneable {
public final class ImBoolean implements Cloneable, Comparable<ImBoolean> {
private final boolean[] data = new boolean[]{false};
public ImBoolean() {
@@ -53,7 +53,13 @@ public final class ImBoolean implements Cloneable {
}
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ImBoolean clone() {
return new ImBoolean(this);
}
@Override
public int compareTo(final ImBoolean o) {
return Boolean.compare(get(), o.get());
}
}
@@ -1,6 +1,6 @@
package imgui.type;
public final class ImDouble implements Cloneable {
public final class ImDouble implements Cloneable, Comparable<ImDouble> {
private final double[] data = new double[]{0.0d};
public ImDouble() {
@@ -53,7 +53,13 @@ public final class ImDouble implements Cloneable {
}
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ImDouble clone() {
return new ImDouble(this);
}
@Override
public int compareTo(final ImDouble o) {
return Double.compare(get(), o.get());
}
}
@@ -1,6 +1,6 @@
package imgui.type;
public final class ImFloat implements Cloneable {
public final class ImFloat implements Cloneable, Comparable<ImFloat> {
private final float[] data = new float[]{0};
public ImFloat() {
@@ -53,7 +53,13 @@ public final class ImFloat implements Cloneable {
}
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ImFloat clone() {
return new ImFloat(this);
}
@Override
public int compareTo(final ImFloat o) {
return Float.compare(get(), o.get());
}
}
@@ -1,6 +1,6 @@
package imgui.type;
public final class ImInt implements Cloneable {
public final class ImInt implements Cloneable, Comparable<ImInt> {
private final int[] data = new int[]{0};
public ImInt() {
@@ -53,7 +53,13 @@ public final class ImInt implements Cloneable {
}
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ImInt clone() {
return new ImInt(this);
}
@Override
public int compareTo(final ImInt o) {
return Integer.compare(get(), o.get());
}
}
@@ -1,6 +1,6 @@
package imgui.type;
public final class ImLong implements Cloneable {
public final class ImLong implements Cloneable, Comparable<ImLong> {
private final long[] data = new long[]{0};
public ImLong() {
@@ -53,7 +53,13 @@ public final class ImLong implements Cloneable {
}
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ImLong clone() {
return new ImLong(this);
}
@Override
public int compareTo(final ImLong o) {
return Long.compare(get(), o.get());
}
}
@@ -1,6 +1,6 @@
package imgui.type;
public final class ImShort implements Cloneable {
public final class ImShort implements Cloneable, Comparable<ImShort> {
private final short[] data = new short[]{0};
public ImShort() {
@@ -53,7 +53,13 @@ public final class ImShort implements Cloneable {
}
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ImShort clone() {
return new ImShort(this);
}
@Override
public int compareTo(final ImShort o) {
return Short.compare(get(), o.get());
}
}
@@ -4,9 +4,9 @@ import java.nio.charset.StandardCharsets;
import java.util.Objects;
/**
* Wrapper for {@link String} to use inside of th Dear ImGui input widgets.
* Wrapper for {@link String} to use inside th Dear ImGui input widgets.
*/
public final class ImString implements Cloneable {
public final class ImString implements Cloneable, Comparable<ImString> {
/**
* Default size of the inner buffer, if {@link ImString} created with a constructor without args.
*/
@@ -17,8 +17,8 @@ public final class ImString implements Cloneable {
public static final short CARET_LEN = 1;
/**
* Configuration class to setup some specific behaviour for current string.
* This is useful when string used inside of ImGui#InputText*() methods.
* Configuration class to set up some specific behaviour for current string.
* This is useful when string used inside ImGui#InputText*() methods.
*/
public final InputData inputData = new InputData();
@@ -32,6 +32,7 @@ public final class ImString implements Cloneable {
this(DEFAULT_LENGTH);
}
@SuppressWarnings("CopyConstructorMissesField")
public ImString(final ImString imString) {
this(imString.text, imString.data.length);
this.inputData.allowedChars = imString.inputData.allowedChars;
@@ -44,6 +45,7 @@ public final class ImString implements Cloneable {
/**
* Creates an {@link ImString} instance with provided size for the inner buffer.
*
* @param length size of the inner buffer to use
*/
public ImString(final int length) {
@@ -53,6 +55,7 @@ public final class ImString implements Cloneable {
/**
* Creates an {@link ImString} instance from provided string.
* Inner buffer size will be equal to the length of the string + {@link ImString#CARET_LEN}.
*
* @param text string to create a new {@link ImString}
*/
public ImString(final String text) {
@@ -61,7 +64,8 @@ public final class ImString implements Cloneable {
/**
* Create an {@link ImString} instance from provided string with custom size for the inner buffer.
* @param text string to a create a new {@link ImString}
*
* @param text string to a creation a new {@link ImString}
* @param length custom size for the inner buffer
*/
public ImString(final String text, final int length) {
@@ -140,8 +144,9 @@ public final class ImString implements Cloneable {
}
/**
* Get the length of the text inside of the data buffer.
* @return length of the text inside of the data buffer
* Get the length of the text inside the data buffer.
*
* @return length of the text inside the data buffer
*/
public int getLength() {
return get().length();
@@ -149,6 +154,7 @@ public final class ImString implements Cloneable {
/**
* Get the size of the data buffer. Buffer size will always have '+1' to its size, since it's used by the Dear ImGui to draw a caret char.
*
* @return size of the data buffer
*/
public int getBufferSize() {
@@ -156,14 +162,14 @@ public final class ImString implements Cloneable {
}
/**
* @return true if the length of the text inside of the data buffer is 0
* @return true if the length of the text inside the data buffer is 0
*/
public boolean isEmpty() {
return getLength() == 0;
}
/**
* @return true if the length of the text inside of the data buffer is not 0
* @return true if the length of the text inside the data buffer is not 0
*/
public boolean isNotEmpty() {
return !isEmpty();
@@ -199,10 +205,16 @@ public final class ImString implements Cloneable {
}
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public ImString clone() {
return new ImString(this);
}
@Override
public int compareTo(final ImString o) {
return get().compareTo(o.get());
}
/**
* Use this class to customize your ImGui input.
*/
@@ -216,7 +228,7 @@ public final class ImString implements Cloneable {
public String allowedChars = "";
/**
* If true, then string will be resized during the the {@link imgui.ImGui#inputText} and {@link imgui.ImGui#inputTextMultiline} methods.
* If true, then string will be resized during the {@link imgui.ImGui#inputText} and {@link imgui.ImGui#inputTextMultiline} methods.
* Alternatively you can provide {@link imgui.flag.ImGuiInputTextFlags#CallbackResize} flag to the input text widgets to enable string resizing.
* Resize factor of the string could be modified by changing {@link #resizeFactor} field.
*/